udp-stencil-component-library 26.9.0 → 26.9.1-next.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/cjs/udp-advanced-search-builder.cjs.entry.js +14 -9
- package/dist/cjs/udp-advanced-search-field-picker_3.cjs.entry.js +15 -13
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/advanced-search-builder/field-picker-tree/field-picker-tree.js +4 -7
- package/dist/collection/components/advanced-search-builder/filter-group/filter-group.js +3 -6
- package/dist/collection/components/advanced-search-builder/helperFunctions/depthOptions.js +9 -0
- package/dist/collection/components/advanced-search-builder/udp-advanced-search-builder.js +15 -10
- package/dist/components/depthOptions.js +1 -0
- package/dist/components/field-picker-tree.js +1 -1
- package/dist/components/filter-group.js +1 -1
- package/dist/components/udp-advanced-search-builder.js +1 -1
- package/dist/docs.json +2 -2
- package/dist/esm/udp-advanced-search-builder.entry.js +14 -9
- package/dist/esm/udp-advanced-search-field-picker_3.entry.js +15 -13
- package/dist/stencil-library/udp-advanced-search-builder.entry.js +1 -1
- package/dist/stencil-library/udp-advanced-search-field-picker_3.entry.js +1 -1
- package/dist/types/components/advanced-search-builder/helperFunctions/depthOptions.d.ts +9 -0
- package/dist/types/components/advanced-search-builder/udp-advanced-search-builder.d.ts +8 -0
- package/dist/types/components.d.ts +2 -2
- package/package.json +1 -1
- package/dist/components/labelHelper.js +0 -1
|
@@ -623,6 +623,9 @@ const UdpAdvancedSearchBuilder = class {
|
|
|
623
623
|
*
|
|
624
624
|
* Ignored when `associations` is set — an explicit association list implies its
|
|
625
625
|
* own depth, so the two never need to be reconciled.
|
|
626
|
+
*
|
|
627
|
+
* `0` pins the tree to the entity's own fields: like `associations`, the host
|
|
628
|
+
* owns the field list then, so no depth selector is shown.
|
|
626
629
|
*/
|
|
627
630
|
this.maxDepth = 2;
|
|
628
631
|
/**
|
|
@@ -1239,16 +1242,20 @@ const UdpAdvancedSearchBuilder = class {
|
|
|
1239
1242
|
}
|
|
1240
1243
|
return false;
|
|
1241
1244
|
}
|
|
1242
|
-
|
|
1245
|
+
/**
|
|
1246
|
+
* The host fixed the field tree — an explicit association list, or depth 0 (own
|
|
1247
|
+
* fields only) — so a depth selector would be a control with nothing to change.
|
|
1248
|
+
*/
|
|
1249
|
+
get depthFixed() {
|
|
1243
1250
|
var _a, _b;
|
|
1251
|
+
return ((_b = (_a = this.associations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 || this.maxDepth < 1;
|
|
1252
|
+
}
|
|
1253
|
+
renderFilterRows() {
|
|
1244
1254
|
const isCollapsible = this.config.collapsible === true;
|
|
1245
1255
|
const rootGroup = this.currentFilterData.filterGroups.find(g => g.parentGroupId === null);
|
|
1246
|
-
//
|
|
1247
|
-
// change depth on top of it would be a control with nothing to change. The tree
|
|
1248
|
-
// rail carries its own depth control, so the row header never doubles it.
|
|
1249
|
-
const hasAssociations = ((_b = (_a = this.associations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0;
|
|
1256
|
+
// The tree rail carries its own depth control, so the row header never doubles it.
|
|
1250
1257
|
const depthInRail = this.config.showFieldPicker === true && this.config.fieldPickerView === 'tree';
|
|
1251
|
-
return (index.h("div", { class: "anim-container", ref: el => (this.animContainerEl = el) }, index.h("div", { class: "content-wrapper" }, (this.isExpanded || !isCollapsible) && rootGroup && (index.h("udp-advanced-search-filter-group", { key: rootGroup.groupId, groupId: rootGroup.groupId, filterData: this.currentFilterData, fields: this.fieldsArray, isRoot: true, flat: this.config.flat === true, operators: this.config.operators, freeFormFields: this.config.freeFormFields === true, maxDepth: this.currentMaxDepth, showDepthSelector: !
|
|
1258
|
+
return (index.h("div", { class: "anim-container", ref: el => (this.animContainerEl = el) }, index.h("div", { class: "content-wrapper" }, (this.isExpanded || !isCollapsible) && rootGroup && (index.h("udp-advanced-search-filter-group", { key: rootGroup.groupId, groupId: rootGroup.groupId, filterData: this.currentFilterData, fields: this.fieldsArray, isRoot: true, flat: this.config.flat === true, operators: this.config.operators, freeFormFields: this.config.freeFormFields === true, maxDepth: this.currentMaxDepth, showDepthSelector: !this.depthFixed && !depthInRail, onAddFilter: e => this.handleAddFilter(e.detail), onAddGroup: e => this.handleAddGroup(e.detail), onRemoveFilter: e => this.handleRemoveFilter(e.detail), onRemoveGroup: e => this.handleRemoveGroup(e.detail), onFilterChange: this.handleFilterChange, onGroupChange: this.handleGroupChange, onDepthChange: this.handleDepthChange, openAddMenuForGroupId: this.openAddMenuForGroupId, onToggleAddMenu: this.handleToggleAddMenu })))));
|
|
1252
1259
|
}
|
|
1253
1260
|
/**
|
|
1254
1261
|
* Clear / Search, with a quiet status line explaining a disabled Search — validation
|
|
@@ -1268,7 +1275,6 @@ const UdpAdvancedSearchBuilder = class {
|
|
|
1268
1275
|
];
|
|
1269
1276
|
}
|
|
1270
1277
|
render() {
|
|
1271
|
-
var _a, _b;
|
|
1272
1278
|
if (this.loading || this.extraFieldsLoading) {
|
|
1273
1279
|
return (index.h(index.Host, { class: { 'is-loading': true } }, index.h("div", { class: "advanced-filter-loading" }, index.h("udp-spinner", { size: "large" }), index.h("span", { class: "advanced-filter-loading-label" }, "Loading filters\u2026"))));
|
|
1274
1280
|
}
|
|
@@ -1277,7 +1283,6 @@ const UdpAdvancedSearchBuilder = class {
|
|
|
1277
1283
|
const showFooter = this.config.showFooter !== false;
|
|
1278
1284
|
const showFieldPicker = this.config.showFieldPicker === true;
|
|
1279
1285
|
const isTreePicker = showFieldPicker && this.config.fieldPickerView === 'tree';
|
|
1280
|
-
const hasAssociations = ((_b = (_a = this.associations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0;
|
|
1281
1286
|
const containerClasses = {
|
|
1282
1287
|
'advanced-filter-container': true,
|
|
1283
1288
|
'is-expanded': this.isExpanded,
|
|
@@ -1297,7 +1302,7 @@ const UdpAdvancedSearchBuilder = class {
|
|
|
1297
1302
|
} }, isTreePicker && (this.isExpanded || !isCollapsible) ? (
|
|
1298
1303
|
// The rail's width is the reader's to set: a deep tree wants room, a flat
|
|
1299
1304
|
// one wants the rows to have it. `udp-sidebar-layout` owns the seam and drag.
|
|
1300
|
-
index.h("udp-sidebar-layout", { class: "picker-layout", sidebarPosition: "end", collapsible: false, resizable: true, fill: true, sidebarWidth: "340px", minSidebarWidth: 260, maxSidebarWidth: 640 }, this.renderFilterRows(), index.h("udp-advanced-search-field-picker-tree", { slot: "sidebar", class: "field-picker", fields: this.fieldsArray, rootLabel: this.rootEntityLabel, depth: this.currentMaxDepth, showDepth: !
|
|
1305
|
+
index.h("udp-sidebar-layout", { class: "picker-layout", sidebarPosition: "end", collapsible: false, resizable: true, fill: true, sidebarWidth: "340px", minSidebarWidth: 260, maxSidebarWidth: 640 }, this.renderFilterRows(), index.h("udp-advanced-search-field-picker-tree", { slot: "sidebar", class: "field-picker", fields: this.fieldsArray, rootLabel: this.rootEntityLabel, depth: this.currentMaxDepth, showDepth: !this.depthFixed, onFieldPick: this.handleFieldPick, onDepthChange: this.handleDepthChange }))) : ([
|
|
1301
1306
|
this.renderFilterRows(),
|
|
1302
1307
|
showFieldPicker && (this.isExpanded || !isCollapsible) && (index.h("udp-advanced-search-field-picker", { class: "field-picker", fields: this.fieldsArray, rootLabel: this.rootEntityLabel, onFieldPick: this.handleFieldPick })),
|
|
1303
1308
|
])), showFooter && (index.h("div", { class: "advanced-filter-footer" }, this.renderActions())))));
|
|
@@ -75,6 +75,16 @@ const UdpAdvancedSearchFieldPicker = class {
|
|
|
75
75
|
};
|
|
76
76
|
UdpAdvancedSearchFieldPicker.style = fieldPickerCss();
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* The depth selector's options: 1–3, plus the current depth when a host set a
|
|
80
|
+
* deeper one — so the control always shows the depth the tree was built with,
|
|
81
|
+
* never an empty selection.
|
|
82
|
+
*/
|
|
83
|
+
const depthOptions = (depth) => Array.from({ length: Math.max(3, depth) }, (_, index) => ({
|
|
84
|
+
value: String(index + 1),
|
|
85
|
+
label: `Depth: ${index + 1}`,
|
|
86
|
+
}));
|
|
87
|
+
|
|
78
88
|
const fieldPickerTreeCss = () => `:host{display:block;min-height:0;min-width:0;box-sizing:border-box}.rail{display:flex;flex-direction:column;height:100%;min-height:0;background:var(--colorNeutralBackground1)}.rail-head{padding:var(--spacingVerticalM) var(--spacingHorizontalM) 0}.rail-title-row{display:flex;align-items:center;justify-content:space-between;gap:var(--spacingHorizontalS);margin-bottom:var(--spacingVerticalS)}.depth-select{width:100px;flex-shrink:0}.picker-search{display:block}.picker-body{padding:var(--spacingVerticalS) var(--spacingHorizontalXS);overflow-y:auto;flex:1 1 auto;min-height:0;box-sizing:border-box}.picker-status{display:block;padding-inline:var(--spacingHorizontalS);color:var(--colorNeutralForeground3)}.picker-tree{min-width:0}.result-group-label{display:block;padding:var(--spacingVerticalM) var(--spacingHorizontalM) var(--spacingVerticalXS);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.result-group:first-child .result-group-label{padding-top:var(--spacingVerticalXS)}.result-type{color:var(--colorNeutralForeground3);white-space:nowrap}.result-add{opacity:0}udp-fluent-list-item:hover .result-add,udp-fluent-list-item:focus-within .result-add{opacity:1}`;
|
|
79
89
|
|
|
80
90
|
/** Namespaced so an association route can never collide with a field's own path. */
|
|
@@ -189,21 +199,17 @@ const UdpAdvancedSearchFieldPickerTree = class {
|
|
|
189
199
|
})))));
|
|
190
200
|
}
|
|
191
201
|
render() {
|
|
192
|
-
var _a, _b;
|
|
202
|
+
var _a, _b, _c;
|
|
193
203
|
const needle = this.query.trim().toLowerCase();
|
|
194
204
|
const isSearching = needle.length > 0;
|
|
195
205
|
const rows = isSearching ? [] : this.buildRows((_a = this.fields) !== null && _a !== void 0 ? _a : [], '', undefined, []);
|
|
196
|
-
return (index.h("div", { key: '
|
|
197
|
-
{ value: '1', label: 'Depth: 1' },
|
|
198
|
-
{ value: '2', label: 'Depth: 2' },
|
|
199
|
-
{ value: '3', label: 'Depth: 3' },
|
|
200
|
-
], value: String((_b = this.depth) !== null && _b !== void 0 ? _b : 2), onValueChanged: (e) => {
|
|
206
|
+
return (index.h("div", { key: 'a2a0b02a17a269a48d2b155de5235010f195a7b2', class: "rail" }, index.h("div", { key: '205dbec6ab3e9889dccf97f0320460b6a6aae55a', class: "rail-head" }, index.h("div", { key: 'f1c9df3d3747d0381e07e6b5319c8d470ac46b29', class: "rail-title-row" }, index.h("udp-text", { key: '71ecb0a4eda863e600c30674457459fe63aab88d', variant: "body1Strong" }, "Fields"), this.showDepth && (index.h("div", { key: '4c1b8bea4f8257fce3c36ef9edeb509e64587484', class: "depth-select" }, index.h("udp-fluent-dropdown", { key: '187a8658a77e02f37b585f06d4b1e41f09165fd1', controlSize: "small", appearance: "filled-lighter", includeErrorPadding: false, clearable: false, options: depthOptions((_b = this.depth) !== null && _b !== void 0 ? _b : 2), value: String((_c = this.depth) !== null && _c !== void 0 ? _c : 2), onValueChanged: (e) => {
|
|
201
207
|
const detail = e.detail;
|
|
202
208
|
const value = typeof detail === 'string' ? detail : detail === null || detail === void 0 ? void 0 : detail.value;
|
|
203
209
|
const parsed = parseInt(value, 10);
|
|
204
210
|
if (!isNaN(parsed))
|
|
205
211
|
this.depthChange.emit(parsed);
|
|
206
|
-
} })))), index.h("udp-search-input", { key: '
|
|
212
|
+
} })))), index.h("udp-search-input", { key: 'b8e90390fb83e9db9382d45ce27929fd7db3d86d', class: "picker-search", value: this.query, placeholder: "Search fields", ariaLabel: "Search fields", includeErrorPadding: false, onValueChanged: (e) => { var _a; return (this.query = (_a = e.detail) !== null && _a !== void 0 ? _a : ''); } })), index.h("div", { key: '2ef9f1537865ab41536074ad535b464bf3f914b7', class: "picker-body" }, isSearching ? (this.renderSearchResults(needle)) : rows.length === 0 ? (index.h("udp-text", { variant: "caption1", class: "picker-status" }, "No fields available.")) : (index.h("udp-tree", { class: "picker-tree", treeItems: rows, itemContent: this.renderRowLabel, itemAside: this.renderRowAside, itemRowToggles: ROW_TOGGLES, interaction: "button", collapsible: true, size: "small", onItemClick: this.handleItemClick })))));
|
|
207
213
|
}
|
|
208
214
|
};
|
|
209
215
|
UdpAdvancedSearchFieldPickerTree.style = fieldPickerTreeCss();
|
|
@@ -364,7 +370,7 @@ const UdpAdvancedSearchFilterGroup = class {
|
|
|
364
370
|
}
|
|
365
371
|
}
|
|
366
372
|
render() {
|
|
367
|
-
var _a;
|
|
373
|
+
var _a, _b;
|
|
368
374
|
const groupInfo = this.filterData.filterGroups.find(g => g.groupId === this.groupId);
|
|
369
375
|
if (!groupInfo) {
|
|
370
376
|
return null;
|
|
@@ -384,11 +390,7 @@ const UdpAdvancedSearchFilterGroup = class {
|
|
|
384
390
|
marginRight: '12px',
|
|
385
391
|
width: '100px',
|
|
386
392
|
flexShrink: '0',
|
|
387
|
-
} }, index.h("udp-fluent-dropdown", { class: "depth-select", controlSize: 'small', options:
|
|
388
|
-
{ value: '1', label: 'Depth: 1' },
|
|
389
|
-
{ value: '2', label: 'Depth: 2' },
|
|
390
|
-
{ value: '3', label: 'Depth: 3' },
|
|
391
|
-
], value: String((_a = this.maxDepth) !== null && _a !== void 0 ? _a : 2), appearance: "filled-lighter", includeErrorPadding: false, clearable: false, onValueChanged: e => this.depthChange.emit(parseInt(this.getDropdownValue(e.detail), 10)) })))) : (index.h("div", { class: "actions" }, index.h("udp-fluent-icon-button", { iconName: "dismiss", appearance: "subtle", size: "small", ariaLabel: "Remove group", onClick: () => this.removeGroup.emit(this.groupId) })))), index.h("div", { class: "group-content" }, myFilters.map(filter => {
|
|
393
|
+
} }, index.h("udp-fluent-dropdown", { class: "depth-select", controlSize: 'small', options: depthOptions((_a = this.maxDepth) !== null && _a !== void 0 ? _a : 2), value: String((_b = this.maxDepth) !== null && _b !== void 0 ? _b : 2), appearance: "filled-lighter", includeErrorPadding: false, clearable: false, onValueChanged: e => this.depthChange.emit(parseInt(this.getDropdownValue(e.detail), 10)) })))) : (index.h("div", { class: "actions" }, index.h("udp-fluent-icon-button", { iconName: "dismiss", appearance: "subtle", size: "small", ariaLabel: "Remove group", onClick: () => this.removeGroup.emit(this.groupId) })))), index.h("div", { class: "group-content" }, myFilters.map(filter => {
|
|
392
394
|
var _a;
|
|
393
395
|
const selectedFieldObject = catalogTree.findNodeByPath(this.fields, filter.searchField);
|
|
394
396
|
const allowedOperators = udpOperatorHelper.getAllowedSearchOperators(selectedFieldObject, this.operators);
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"components/advanced-search/filter-conditions/filter-conditions.js",
|
|
29
29
|
"components/advanced-search/ui/logical-search-indicator/logical-search-indicator.js",
|
|
30
30
|
"components/advanced-search-builder/udp-advanced-search-builder.js",
|
|
31
|
+
"components/advanced-search-builder/filter-group/filter-group.js",
|
|
31
32
|
"components/advanced-search-builder/field-picker/field-picker.js",
|
|
32
33
|
"components/advanced-search-builder/field-picker-tree/field-picker-tree.js",
|
|
33
|
-
"components/advanced-search-builder/filter-group/filter-group.js",
|
|
34
34
|
"components/attachment-list/udp-attachment-item.js",
|
|
35
35
|
"components/attachment-list/udp-attachment-list.js",
|
|
36
36
|
"components/buttons/icon-button/stencil-icon-button-grid-action-header.js",
|
package/dist/collection/components/advanced-search-builder/field-picker-tree/field-picker-tree.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
import { NON_FILTERABLE, TYPE_LABEL } from "../models";
|
|
3
3
|
import { humanizeIdentifier, isJunkEntityName } from "../helperFunctions/labelHelper";
|
|
4
|
+
import { depthOptions } from "../helperFunctions/depthOptions";
|
|
4
5
|
/** Namespaced so an association route can never collide with a field's own path. */
|
|
5
6
|
const ENTITY_ID_PREFIX = 'entity:';
|
|
6
7
|
/** Joins the entity labels of a search hit's route. */
|
|
@@ -117,21 +118,17 @@ export class UdpAdvancedSearchFieldPickerTree {
|
|
|
117
118
|
})))));
|
|
118
119
|
}
|
|
119
120
|
render() {
|
|
120
|
-
var _a, _b;
|
|
121
|
+
var _a, _b, _c;
|
|
121
122
|
const needle = this.query.trim().toLowerCase();
|
|
122
123
|
const isSearching = needle.length > 0;
|
|
123
124
|
const rows = isSearching ? [] : this.buildRows((_a = this.fields) !== null && _a !== void 0 ? _a : [], '', undefined, []);
|
|
124
|
-
return (h("div", { key: '
|
|
125
|
-
{ value: '1', label: 'Depth: 1' },
|
|
126
|
-
{ value: '2', label: 'Depth: 2' },
|
|
127
|
-
{ value: '3', label: 'Depth: 3' },
|
|
128
|
-
], value: String((_b = this.depth) !== null && _b !== void 0 ? _b : 2), onValueChanged: (e) => {
|
|
125
|
+
return (h("div", { key: 'a2a0b02a17a269a48d2b155de5235010f195a7b2', class: "rail" }, h("div", { key: '205dbec6ab3e9889dccf97f0320460b6a6aae55a', class: "rail-head" }, h("div", { key: 'f1c9df3d3747d0381e07e6b5319c8d470ac46b29', class: "rail-title-row" }, h("udp-text", { key: '71ecb0a4eda863e600c30674457459fe63aab88d', variant: "body1Strong" }, "Fields"), this.showDepth && (h("div", { key: '4c1b8bea4f8257fce3c36ef9edeb509e64587484', class: "depth-select" }, h("udp-fluent-dropdown", { key: '187a8658a77e02f37b585f06d4b1e41f09165fd1', controlSize: "small", appearance: "filled-lighter", includeErrorPadding: false, clearable: false, options: depthOptions((_b = this.depth) !== null && _b !== void 0 ? _b : 2), value: String((_c = this.depth) !== null && _c !== void 0 ? _c : 2), onValueChanged: (e) => {
|
|
129
126
|
const detail = e.detail;
|
|
130
127
|
const value = typeof detail === 'string' ? detail : detail === null || detail === void 0 ? void 0 : detail.value;
|
|
131
128
|
const parsed = parseInt(value, 10);
|
|
132
129
|
if (!isNaN(parsed))
|
|
133
130
|
this.depthChange.emit(parsed);
|
|
134
|
-
} })))), h("udp-search-input", { key: '
|
|
131
|
+
} })))), h("udp-search-input", { key: 'b8e90390fb83e9db9382d45ce27929fd7db3d86d', class: "picker-search", value: this.query, placeholder: "Search fields", ariaLabel: "Search fields", includeErrorPadding: false, onValueChanged: (e) => { var _a; return (this.query = (_a = e.detail) !== null && _a !== void 0 ? _a : ''); } })), h("div", { key: '2ef9f1537865ab41536074ad535b464bf3f914b7', class: "picker-body" }, isSearching ? (this.renderSearchResults(needle)) : rows.length === 0 ? (h("udp-text", { variant: "caption1", class: "picker-status" }, "No fields available.")) : (h("udp-tree", { class: "picker-tree", treeItems: rows, itemContent: this.renderRowLabel, itemAside: this.renderRowAside, itemRowToggles: ROW_TOGGLES, interaction: "button", collapsible: true, size: "small", onItemClick: this.handleItemClick })))));
|
|
135
132
|
}
|
|
136
133
|
static get is() { return "udp-advanced-search-field-picker-tree"; }
|
|
137
134
|
static get encapsulation() { return "shadow"; }
|
|
@@ -3,6 +3,7 @@ import { LogicalSearchOperator, SearchOperators } from "../../../udp-utilities/s
|
|
|
3
3
|
import { getAllowedSearchOperators } from "../helperFunctions/udpOperatorHelper";
|
|
4
4
|
import { buildFieldOptions, renderSearchValueInput } from "../helperFunctions/fieldRenderer";
|
|
5
5
|
import { humanizeIdentifier } from "../helperFunctions/labelHelper";
|
|
6
|
+
import { depthOptions } from "../helperFunctions/depthOptions";
|
|
6
7
|
import { findNodeByPath } from "../../../udp-utilities/catalog/index";
|
|
7
8
|
export class UdpAdvancedSearchFilterGroup {
|
|
8
9
|
constructor() {
|
|
@@ -75,7 +76,7 @@ export class UdpAdvancedSearchFilterGroup {
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
render() {
|
|
78
|
-
var _a;
|
|
79
|
+
var _a, _b;
|
|
79
80
|
const groupInfo = this.filterData.filterGroups.find(g => g.groupId === this.groupId);
|
|
80
81
|
if (!groupInfo) {
|
|
81
82
|
return null;
|
|
@@ -95,11 +96,7 @@ export class UdpAdvancedSearchFilterGroup {
|
|
|
95
96
|
marginRight: '12px',
|
|
96
97
|
width: '100px',
|
|
97
98
|
flexShrink: '0',
|
|
98
|
-
} }, h("udp-fluent-dropdown", { class: "depth-select", controlSize: 'small', options:
|
|
99
|
-
{ value: '1', label: 'Depth: 1' },
|
|
100
|
-
{ value: '2', label: 'Depth: 2' },
|
|
101
|
-
{ value: '3', label: 'Depth: 3' },
|
|
102
|
-
], value: String((_a = this.maxDepth) !== null && _a !== void 0 ? _a : 2), appearance: "filled-lighter", includeErrorPadding: false, clearable: false, onValueChanged: e => this.depthChange.emit(parseInt(this.getDropdownValue(e.detail), 10)) })))) : (h("div", { class: "actions" }, h("udp-fluent-icon-button", { iconName: "dismiss", appearance: "subtle", size: "small", ariaLabel: "Remove group", onClick: () => this.removeGroup.emit(this.groupId) })))), h("div", { class: "group-content" }, myFilters.map(filter => {
|
|
99
|
+
} }, h("udp-fluent-dropdown", { class: "depth-select", controlSize: 'small', options: depthOptions((_a = this.maxDepth) !== null && _a !== void 0 ? _a : 2), value: String((_b = this.maxDepth) !== null && _b !== void 0 ? _b : 2), appearance: "filled-lighter", includeErrorPadding: false, clearable: false, onValueChanged: e => this.depthChange.emit(parseInt(this.getDropdownValue(e.detail), 10)) })))) : (h("div", { class: "actions" }, h("udp-fluent-icon-button", { iconName: "dismiss", appearance: "subtle", size: "small", ariaLabel: "Remove group", onClick: () => this.removeGroup.emit(this.groupId) })))), h("div", { class: "group-content" }, myFilters.map(filter => {
|
|
103
100
|
var _a;
|
|
104
101
|
const selectedFieldObject = findNodeByPath(this.fields, filter.searchField);
|
|
105
102
|
const allowedOperators = getAllowedSearchOperators(selectedFieldObject, this.operators);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The depth selector's options: 1–3, plus the current depth when a host set a
|
|
3
|
+
* deeper one — so the control always shows the depth the tree was built with,
|
|
4
|
+
* never an empty selection.
|
|
5
|
+
*/
|
|
6
|
+
export const depthOptions = (depth) => Array.from({ length: Math.max(3, depth) }, (_, index) => ({
|
|
7
|
+
value: String(index + 1),
|
|
8
|
+
label: `Depth: ${index + 1}`,
|
|
9
|
+
}));
|
|
@@ -18,6 +18,9 @@ export class UdpAdvancedSearchBuilder {
|
|
|
18
18
|
*
|
|
19
19
|
* Ignored when `associations` is set — an explicit association list implies its
|
|
20
20
|
* own depth, so the two never need to be reconciled.
|
|
21
|
+
*
|
|
22
|
+
* `0` pins the tree to the entity's own fields: like `associations`, the host
|
|
23
|
+
* owns the field list then, so no depth selector is shown.
|
|
21
24
|
*/
|
|
22
25
|
this.maxDepth = 2;
|
|
23
26
|
/**
|
|
@@ -634,16 +637,20 @@ export class UdpAdvancedSearchBuilder {
|
|
|
634
637
|
}
|
|
635
638
|
return false;
|
|
636
639
|
}
|
|
637
|
-
|
|
640
|
+
/**
|
|
641
|
+
* The host fixed the field tree — an explicit association list, or depth 0 (own
|
|
642
|
+
* fields only) — so a depth selector would be a control with nothing to change.
|
|
643
|
+
*/
|
|
644
|
+
get depthFixed() {
|
|
638
645
|
var _a, _b;
|
|
646
|
+
return ((_b = (_a = this.associations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 || this.maxDepth < 1;
|
|
647
|
+
}
|
|
648
|
+
renderFilterRows() {
|
|
639
649
|
const isCollapsible = this.config.collapsible === true;
|
|
640
650
|
const rootGroup = this.currentFilterData.filterGroups.find(g => g.parentGroupId === null);
|
|
641
|
-
//
|
|
642
|
-
// change depth on top of it would be a control with nothing to change. The tree
|
|
643
|
-
// rail carries its own depth control, so the row header never doubles it.
|
|
644
|
-
const hasAssociations = ((_b = (_a = this.associations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0;
|
|
651
|
+
// The tree rail carries its own depth control, so the row header never doubles it.
|
|
645
652
|
const depthInRail = this.config.showFieldPicker === true && this.config.fieldPickerView === 'tree';
|
|
646
|
-
return (h("div", { class: "anim-container", ref: el => (this.animContainerEl = el) }, h("div", { class: "content-wrapper" }, (this.isExpanded || !isCollapsible) && rootGroup && (h("udp-advanced-search-filter-group", { key: rootGroup.groupId, groupId: rootGroup.groupId, filterData: this.currentFilterData, fields: this.fieldsArray, isRoot: true, flat: this.config.flat === true, operators: this.config.operators, freeFormFields: this.config.freeFormFields === true, maxDepth: this.currentMaxDepth, showDepthSelector: !
|
|
653
|
+
return (h("div", { class: "anim-container", ref: el => (this.animContainerEl = el) }, h("div", { class: "content-wrapper" }, (this.isExpanded || !isCollapsible) && rootGroup && (h("udp-advanced-search-filter-group", { key: rootGroup.groupId, groupId: rootGroup.groupId, filterData: this.currentFilterData, fields: this.fieldsArray, isRoot: true, flat: this.config.flat === true, operators: this.config.operators, freeFormFields: this.config.freeFormFields === true, maxDepth: this.currentMaxDepth, showDepthSelector: !this.depthFixed && !depthInRail, onAddFilter: e => this.handleAddFilter(e.detail), onAddGroup: e => this.handleAddGroup(e.detail), onRemoveFilter: e => this.handleRemoveFilter(e.detail), onRemoveGroup: e => this.handleRemoveGroup(e.detail), onFilterChange: this.handleFilterChange, onGroupChange: this.handleGroupChange, onDepthChange: this.handleDepthChange, openAddMenuForGroupId: this.openAddMenuForGroupId, onToggleAddMenu: this.handleToggleAddMenu })))));
|
|
647
654
|
}
|
|
648
655
|
/**
|
|
649
656
|
* Clear / Search, with a quiet status line explaining a disabled Search — validation
|
|
@@ -663,7 +670,6 @@ export class UdpAdvancedSearchBuilder {
|
|
|
663
670
|
];
|
|
664
671
|
}
|
|
665
672
|
render() {
|
|
666
|
-
var _a, _b;
|
|
667
673
|
if (this.loading || this.extraFieldsLoading) {
|
|
668
674
|
return (h(Host, { class: { 'is-loading': true } }, h("div", { class: "advanced-filter-loading" }, h("udp-spinner", { size: "large" }), h("span", { class: "advanced-filter-loading-label" }, "Loading filters\u2026"))));
|
|
669
675
|
}
|
|
@@ -672,7 +678,6 @@ export class UdpAdvancedSearchBuilder {
|
|
|
672
678
|
const showFooter = this.config.showFooter !== false;
|
|
673
679
|
const showFieldPicker = this.config.showFieldPicker === true;
|
|
674
680
|
const isTreePicker = showFieldPicker && this.config.fieldPickerView === 'tree';
|
|
675
|
-
const hasAssociations = ((_b = (_a = this.associations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0;
|
|
676
681
|
const containerClasses = {
|
|
677
682
|
'advanced-filter-container': true,
|
|
678
683
|
'is-expanded': this.isExpanded,
|
|
@@ -692,7 +697,7 @@ export class UdpAdvancedSearchBuilder {
|
|
|
692
697
|
} }, isTreePicker && (this.isExpanded || !isCollapsible) ? (
|
|
693
698
|
// The rail's width is the reader's to set: a deep tree wants room, a flat
|
|
694
699
|
// one wants the rows to have it. `udp-sidebar-layout` owns the seam and drag.
|
|
695
|
-
h("udp-sidebar-layout", { class: "picker-layout", sidebarPosition: "end", collapsible: false, resizable: true, fill: true, sidebarWidth: "340px", minSidebarWidth: 260, maxSidebarWidth: 640 }, this.renderFilterRows(), h("udp-advanced-search-field-picker-tree", { slot: "sidebar", class: "field-picker", fields: this.fieldsArray, rootLabel: this.rootEntityLabel, depth: this.currentMaxDepth, showDepth: !
|
|
700
|
+
h("udp-sidebar-layout", { class: "picker-layout", sidebarPosition: "end", collapsible: false, resizable: true, fill: true, sidebarWidth: "340px", minSidebarWidth: 260, maxSidebarWidth: 640 }, this.renderFilterRows(), h("udp-advanced-search-field-picker-tree", { slot: "sidebar", class: "field-picker", fields: this.fieldsArray, rootLabel: this.rootEntityLabel, depth: this.currentMaxDepth, showDepth: !this.depthFixed, onFieldPick: this.handleFieldPick, onDepthChange: this.handleDepthChange }))) : ([
|
|
696
701
|
this.renderFilterRows(),
|
|
697
702
|
showFieldPicker && (this.isExpanded || !isCollapsible) && (h("udp-advanced-search-field-picker", { class: "field-picker", fields: this.fieldsArray, rootLabel: this.rootEntityLabel, onFieldPick: this.handleFieldPick })),
|
|
698
703
|
])), showFooter && (h("div", { class: "advanced-filter-footer" }, this.renderActions())))));
|
|
@@ -815,7 +820,7 @@ export class UdpAdvancedSearchBuilder {
|
|
|
815
820
|
"optional": false,
|
|
816
821
|
"docs": {
|
|
817
822
|
"tags": [],
|
|
818
|
-
"text": "The maximum depth to traverse when building the field tree.\n\nIgnored when `associations` is set \u2014 an explicit association list implies its\nown depth, so the two never need to be reconciled."
|
|
823
|
+
"text": "The maximum depth to traverse when building the field tree.\n\nIgnored when `associations` is set \u2014 an explicit association list implies its\nown depth, so the two never need to be reconciled.\n\n`0` pins the tree to the entity's own fields: like `associations`, the host\nowns the field list then, so no depth selector is shown."
|
|
819
824
|
},
|
|
820
825
|
"getter": false,
|
|
821
826
|
"setter": false,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=/^(lut|vw)_/i,a=new Set(["id","gl","url","gps"]),e=e=>{if(!e)return e;const r=e.replace(t,"").split(/[_\s]+/).flatMap((t=>t.split(/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/))).filter(Boolean).map((t=>a.has(t.toLowerCase())?t.toUpperCase():t.toLowerCase()));return 0===r.length?e:r.map(((t,a)=>0===a&&t===t.toLowerCase()?t[0].toUpperCase()+t.slice(1):t)).join(" ")},r=t=>t.includes("+"),l=t=>Array.from({length:Math.max(3,t)},((t,a)=>({value:String(a+1),label:`Depth: ${a+1}`})));export{l as d,e as h,r as i}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import "../stencil-library/stencil-library.css";
|
|
2
|
-
import{p as e,H as t,c as a,h as i,t as s}from"./index2.js";import{N as
|
|
2
|
+
import{p as e,H as t,c as a,h as i,t as s}from"./index2.js";import{N as r,T as l}from"./models.js";import{h as o,i as d,d as n}from"./depthOptions.js";import{d as u}from"./udp-fluent-avatar2.js";import{d as c}from"./udp-fluent-badge2.js";import{d as p}from"./udp-fluent-button2.js";import{d as f}from"./udp-fluent-dropdown2.js";import{d as m}from"./udp-fluent-icon2.js";import{d as h}from"./udp-fluent-icon-button2.js";import{d as b}from"./udp-list-item2.js";import{d as v}from"./udp-list2.js";import{d as g}from"./udp-search-input2.js";import{d as k}from"./udp-spinner2.js";import{d as y}from"./udp-text2.js";import{d as w}from"./udp-tooltip2.js";import{d as x}from"./udp-tree2.js";const E=e=>"entity"===e.kind,j=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.fieldPick=a(this,"fieldPick",7),this.depthChange=a(this,"depthChange",7),this.fields=[],this.showDepth=!1,this.query="",this.renderRowLabel=e=>i("span",{title:e.path},e.label),this.renderRowAside=e=>{var t;return"field"!==e.kind?null:i("udp-text",{variant:"caption1",style:{color:"var(--colorNeutralForeground3)"}},null!==(t=l[e.type])&&void 0!==t?t:e.type)},this.handleItemClick=e=>{const t=e.detail;"field"===(null==t?void 0:t.kind)&&this.fieldPick.emit({path:t.path,type:t.type})}}buildRows(e,t,a,i){var s,l;const n=[],u=[];for(const c of null!=e?e:[]){const e=t?`${t}.${c.name}`:c.name,p=o(null!==(s=c.displayName)&&void 0!==s?s:c.name);if(null===(l=c.childFields)||void 0===l?void 0:l.length){if(d(c.name))continue;const t=`entity:${e}`,s=this.buildRows(c.childFields,e,t,[...i,p]);if(0===s.length)continue;u.push({id:t,parentId:a,kind:"entity",label:p,path:e}),u.push(...s)}else r.has(c.type)||n.push({id:e,parentId:a,kind:"field",label:p,path:e,type:c.type,chain:i.length?i.join(" › "):void 0})}return[...u,...n]}matchingGroups(e){var t,a;const i=this.buildRows(null!==(t=this.fields)&&void 0!==t?t:[],"",void 0,[]).filter((t=>"field"===t.kind&&t.label.toLowerCase().includes(e))),s=new Map;for(const e of i){const t=null!==(a=e.chain)&&void 0!==a?a:"";s.has(t)||s.set(t,[]),s.get(t).push(e)}const r=o(this.rootLabel||"Fields");return[...s.entries()].sort((([e],[t])=>""===e?-1:""===t?1:0)).map((([e,t])=>({chain:""===e?r:e,rows:t})))}renderSearchResults(e){const t=this.matchingGroups(e);return 0===t.length?i("udp-text",{variant:"caption1",class:"picker-status"},"No fields match your search."):t.map((e=>i("div",{class:"result-group",key:e.chain},i("udp-text",{variant:"body1Strong",class:"result-group-label",title:e.chain},e.chain),i("udp-list",{interactive:!0},e.rows.map((e=>{var t;return i("udp-fluent-list-item",{key:e.id,value:e.path,label:e.label,size:"small",interactive:!0,title:e.path,onItemAction:()=>this.fieldPick.emit({path:e.path,type:e.type})},i("udp-text",{slot:"end",variant:"caption1",class:"result-type"},null!==(t=l[e.type])&&void 0!==t?t:e.type),i("udp-fluent-icon-button",{slot:"end",class:"result-add",iconName:"add",appearance:"subtle",size:"small",ariaLabel:`Add filter for ${e.label}`,onClick:()=>this.fieldPick.emit({path:e.path,type:e.type})}))}))))))}render(){var e,t,a;const s=this.query.trim().toLowerCase(),r=s.length>0,l=r?[]:this.buildRows(null!==(e=this.fields)&&void 0!==e?e:[],"",void 0,[]);return i("div",{key:"a2a0b02a17a269a48d2b155de5235010f195a7b2",class:"rail"},i("div",{key:"205dbec6ab3e9889dccf97f0320460b6a6aae55a",class:"rail-head"},i("div",{key:"f1c9df3d3747d0381e07e6b5319c8d470ac46b29",class:"rail-title-row"},i("udp-text",{key:"71ecb0a4eda863e600c30674457459fe63aab88d",variant:"body1Strong"},"Fields"),this.showDepth&&i("div",{key:"4c1b8bea4f8257fce3c36ef9edeb509e64587484",class:"depth-select"},i("udp-fluent-dropdown",{key:"187a8658a77e02f37b585f06d4b1e41f09165fd1",controlSize:"small",appearance:"filled-lighter",includeErrorPadding:!1,clearable:!1,options:n(null!==(t=this.depth)&&void 0!==t?t:2),value:String(null!==(a=this.depth)&&void 0!==a?a:2),onValueChanged:e=>{const t=e.detail,a=parseInt("string"==typeof t?t:null==t?void 0:t.value,10);isNaN(a)||this.depthChange.emit(a)}}))),i("udp-search-input",{key:"b8e90390fb83e9db9382d45ce27929fd7db3d86d",class:"picker-search",value:this.query,placeholder:"Search fields",ariaLabel:"Search fields",includeErrorPadding:!1,onValueChanged:e=>{var t;return this.query=null!==(t=e.detail)&&void 0!==t?t:""}})),i("div",{key:"2ef9f1537865ab41536074ad535b464bf3f914b7",class:"picker-body"},r?this.renderSearchResults(s):0===l.length?i("udp-text",{variant:"caption1",class:"picker-status"},"No fields available."):i("udp-tree",{class:"picker-tree",treeItems:l,itemContent:this.renderRowLabel,itemAside:this.renderRowAside,itemRowToggles:E,interaction:"button",collapsible:!0,size:"small",onItemClick:this.handleItemClick})))}static get style(){return":host{display:block;min-height:0;min-width:0;box-sizing:border-box}.rail{display:flex;flex-direction:column;height:100%;min-height:0;background:var(--colorNeutralBackground1)}.rail-head{padding:var(--spacingVerticalM) var(--spacingHorizontalM) 0}.rail-title-row{display:flex;align-items:center;justify-content:space-between;gap:var(--spacingHorizontalS);margin-bottom:var(--spacingVerticalS)}.depth-select{width:100px;flex-shrink:0}.picker-search{display:block}.picker-body{padding:var(--spacingVerticalS) var(--spacingHorizontalXS);overflow-y:auto;flex:1 1 auto;min-height:0;box-sizing:border-box}.picker-status{display:block;padding-inline:var(--spacingHorizontalS);color:var(--colorNeutralForeground3)}.picker-tree{min-width:0}.result-group-label{display:block;padding:var(--spacingVerticalM) var(--spacingHorizontalM) var(--spacingVerticalXS);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.result-group:first-child .result-group-label{padding-top:var(--spacingVerticalXS)}.result-type{color:var(--colorNeutralForeground3);white-space:nowrap}.result-add{opacity:0}udp-fluent-list-item:hover .result-add,udp-fluent-list-item:focus-within .result-add{opacity:1}"}},[1,"udp-advanced-search-field-picker-tree",{fields:[16],rootLabel:[1,"root-label"],depth:[2],showDepth:[4,"show-depth"],query:[32]}]);function S(){"undefined"!=typeof customElements&&["udp-advanced-search-field-picker-tree","udp-fluent-avatar","udp-fluent-badge","udp-fluent-button","udp-fluent-dropdown","udp-fluent-icon","udp-fluent-icon-button","udp-fluent-list-item","udp-list","udp-search-input","udp-spinner","udp-text","udp-tooltip","udp-tree"].forEach((e=>{switch(e){case"udp-advanced-search-field-picker-tree":customElements.get(s(e))||customElements.define(s(e),j);break;case"udp-fluent-avatar":customElements.get(s(e))||u();break;case"udp-fluent-badge":customElements.get(s(e))||c();break;case"udp-fluent-button":customElements.get(s(e))||p();break;case"udp-fluent-dropdown":customElements.get(s(e))||f();break;case"udp-fluent-icon":customElements.get(s(e))||m();break;case"udp-fluent-icon-button":customElements.get(s(e))||h();break;case"udp-fluent-list-item":customElements.get(s(e))||b();break;case"udp-list":customElements.get(s(e))||v();break;case"udp-search-input":customElements.get(s(e))||g();break;case"udp-spinner":customElements.get(s(e))||k();break;case"udp-text":customElements.get(s(e))||y();break;case"udp-tooltip":customElements.get(s(e))||w();break;case"udp-tree":customElements.get(s(e))||x()}}))}export{j as U,S as d}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import "../stencil-library/stencil-library.css";
|
|
2
|
-
import{h as e,p as t,H as a,c as i,t as n}from"./index2.js";import{a as r,L as l}from"./searchObject.js";import{i as o,h as s}from"./labelHelper.js";import{d}from"./udp-autocomplete2.js";import{d as u}from"./udp-date-input2.js";import{d as p}from"./udp-date-range-selector2.js";import{d as c}from"./udp-date-time-input2.js";import{d as h}from"./udp-fluent-badge2.js";import{d as g}from"./udp-fluent-button2.js";import{d as m}from"./udp-fluent-dropdown2.js";import{d as f}from"./udp-fluent-icon2.js";import{d as v}from"./udp-fluent-icon-button2.js";import{d as b}from"./udp-fluent-text-input2.js";import{d as x}from"./udp-popover2.js";import{d as w}from"./udp-spinner2.js";import{d as E}from"./udp-text2.js";import{d as k}from"./udp-time-input2.js";import{d as y}from"./udp-tooltip2.js";import{f as S}from"./catalogTree.js";const C=[{value:r.EQUALS,label:"is"},{value:r.NOT_EQUALS,label:"is not"},{value:r.LESS_THAN,label:"is less than"},{value:r.GREATER_THAN,label:"is greater than"},{value:r.LESS_THAN_OR_EQUAL,label:"is at most"},{value:r.GREATER_THAN_OR_EQUAL,label:"is at least"},{value:r.LIKE,label:"contains"},{value:r.STARTSWITH,label:"begins with"},{value:r.BETWEEN,label:"is between"},{value:r.IN,label:"is any of"},{value:r.NOT_IN,label:"is none of"},{value:r.NULL,label:"is empty"},{value:r.NOT_NULL,label:"is not empty"}],V={[r.LESS_THAN]:"is before",[r.GREATER_THAN]:"is after",[r.LESS_THAN_OR_EQUAL]:"is on or before",[r.GREATER_THAN_OR_EQUAL]:"is on or after"},j=new Set(["date","datetime","time"]),z={guid:[r.EQUALS,r.NOT_EQUALS,r.LIKE,r.IN,r.NOT_IN,r.NULL,r.NOT_NULL],string:[r.EQUALS,r.NOT_EQUALS,r.LIKE,r.STARTSWITH,r.IN,r.NOT_IN,r.NULL,r.NOT_NULL],number:[r.EQUALS,r.NOT_EQUALS,r.LESS_THAN,r.GREATER_THAN,r.LESS_THAN_OR_EQUAL,r.GREATER_THAN_OR_EQUAL,r.BETWEEN,r.IN,r.NOT_IN,r.NULL,r.NOT_NULL],boolean:[r.EQUALS,r.NOT_EQUALS,r.NULL,r.NOT_NULL],date:[r.EQUALS,r.NOT_EQUALS,r.LESS_THAN,r.GREATER_THAN,r.LESS_THAN_OR_EQUAL,r.GREATER_THAN_OR_EQUAL,r.BETWEEN,r.NULL,r.NOT_NULL],datetime:[r.EQUALS,r.NOT_EQUALS,r.LESS_THAN,r.GREATER_THAN,r.LESS_THAN_OR_EQUAL,r.GREATER_THAN_OR_EQUAL,r.BETWEEN,r.NULL,r.NOT_NULL],time:[r.EQUALS,r.NOT_EQUALS,r.LESS_THAN,r.GREATER_THAN,r.LESS_THAN_OR_EQUAL,r.GREATER_THAN_OR_EQUAL,r.BETWEEN,r.NULL,r.NOT_NULL],default:[r.EQUALS,r.NOT_EQUALS]},F=(e,t)=>{var a;const i=e&&null!==(a=z[e.type])&&void 0!==a?a:z.default,n=(null==t?void 0:t.length)?i.filter((e=>t.includes(e))):i,r=e&&j.has(e.type);return C.filter((e=>n.includes(e.value))).map((e=>r&&V[e.value]?Object.assign(Object.assign({},e),{label:V[e.value]}):e))},P=e=>{var t,a;return null!==(a=null===(t=C.find((t=>t.value===e)))||void 0===t?void 0:t.label)&&void 0!==a?a:e},I=(e,t="",a="")=>{const i=[];return e.forEach((e=>{var n;const r=e.childFields&&e.childFields.length>0;if(r&&o(e.name))return;const l=t?`${t}.${e.name}`:e.name,d=s(null!==(n=e.displayName)&&void 0!==n?n:e.name),u=a?`${a} · ${d}`:d;i.push({value:l,label:u,disabled:r||void 0}),r&&i.push(...I(e.childFields,l,u))})),i},R=t(class extends a{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.addFilter=i(this,"addFilter",7),this.addGroup=i(this,"addGroup",7),this.removeFilter=i(this,"removeFilter",7),this.removeGroup=i(this,"removeGroup",7),this.filterChange=i(this,"filterChange",7),this.groupChange=i(this,"groupChange",7),this.toggleAddMenu=i(this,"toggleAddMenu",7),this.depthChange=i(this,"depthChange",7),this.isRoot=!1,this.showDepthSelector=!0,this.flat=!1,this.freeFormFields=!1,this.handleValueChange=(e,t)=>{this.filterChange.emit({filterId:t._id,field:"searchValue",value:e})},this.handleBetweenValueChange=(e,t,a)=>{const i=(t.searchValue||",").split(",");i[a]=e,this.filterChange.emit({filterId:t._id,field:"searchValue",value:i.join(",")})}}countGroupConditions(e){const t=this.filterData.filterElements.filter((t=>t.groupId===e)).length;return this.filterData.filterGroups.filter((t=>t.parentGroupId===e)).reduce(((e,t)=>e+this.countGroupConditions(t.groupId)),t)}getDropdownValue(e){return"object"==typeof e&&null!==e?e.value:String(e)}handleFilterFieldChange(e,t){var a;const i=S(this.fields,t),n=F(i,this.operators);let r="";((null==i?void 0:i.type)||"").toLowerCase().includes("bool")&&(r=!0),this.filterChange.emit({filterId:e._id,updates:{searchField:t,_type:(null==i?void 0:i.type)||"string",searchValue:r}}),n.some((t=>t.value===e.searchOperator))||this.filterChange.emit({filterId:e._id,updates:{searchOperator:(null===(a=null==n?void 0:n[0])||void 0===a?void 0:a.value)||""}})}render(){var t;const a=this.filterData.filterGroups.find((e=>e.groupId===this.groupId));if(!a)return null;const i=this.filterData.filterElements.filter((e=>e.groupId===this.groupId)),n=this.filterData.filterGroups.filter((e=>e.parentGroupId===this.groupId)),o=this.isRoot?0:this.countGroupConditions(this.groupId);return e("div",{class:{"group-box":!0,"root-group":this.isRoot},"data-group-id":String(this.groupId),"data-parent-group-id":null!=a.parentGroupId?String(a.parentGroupId):void 0},e("div",{class:"group-header"},!this.isRoot&&e("span",{class:"drag-handle","data-drag-handle":"","data-drag-type":"group","data-drag-id":String(this.groupId),"data-drag-label":`Group (${a.logicalSearchOperator===l.AND?"all":"any"})`,"data-drag-sublabel":`${o} condition${1===o?"":"s"}`},"⠿"),e("span",{class:"match-text"},"Match"),this.flat?e("span",{class:"match-text"},"all"):e("udp-fluent-dropdown",{class:"logical-op",controlSize:"small",options:[{value:"1",label:"all"},{value:"2",label:"any"}],value:String(a.logicalSearchOperator),appearance:"filled-lighter",includeErrorPadding:!1,clearable:!1,onValueChanged:e=>this.groupChange.emit({groupId:this.groupId,logicalSearchOperator:parseInt(this.getDropdownValue(e.detail))})}),e("span",{class:"match-text"},"of the following"),this.isRoot?this.showDepthSelector&&e("div",{style:{marginLeft:"auto",marginRight:"12px",width:"100px",flexShrink:"0"}},e("udp-fluent-dropdown",{class:"depth-select",controlSize:"small",options:[{value:"1",label:"Depth: 1"},{value:"2",label:"Depth: 2"},{value:"3",label:"Depth: 3"}],value:String(null!==(t=this.maxDepth)&&void 0!==t?t:2),appearance:"filled-lighter",includeErrorPadding:!1,clearable:!1,onValueChanged:e=>this.depthChange.emit(parseInt(this.getDropdownValue(e.detail),10))})):e("div",{class:"actions"},e("udp-fluent-icon-button",{iconName:"dismiss",appearance:"subtle",size:"small",ariaLabel:"Remove group",onClick:()=>this.removeGroup.emit(this.groupId)}))),e("div",{class:"group-content"},i.map((t=>{var a;const i=S(this.fields,t.searchField),n=F(i,this.operators);return e("div",{class:"filter-item",key:t._id},e("div",{class:{"filter-row":!0,"is-invalid":!!t._error&&!!t._touched},"data-filter-id":t._id,"data-group-id":String(this.groupId)},e("span",{class:"drag-handle","data-drag-handle":"","data-drag-type":"filter","data-drag-id":t._id,"data-drag-label":i?s(null!==(a=i.displayName)&&void 0!==a?a:i.name):"Filter"},"⠿"),e("udp-autocomplete",{class:"field-select",options:I(this.fields),optionLabel:"label",optionValue:"value",optionDisabled:"disabled",value:t.searchField,freeForm:this.freeFormFields,placeholder:"Search fields...",clearable:!1,includeErrorPadding:!1,onValueChanged:e=>this.handleFilterFieldChange(t,this.getDropdownValue(e.detail))}),e("udp-fluent-dropdown",{class:"operator-select",options:n,value:t.searchOperator,includeErrorPadding:!1,clearable:!1,onValueChanged:e=>{const a=this.getDropdownValue(e.detail);this.filterChange.emit({filterId:t._id,updates:a===r.NULL||a===r.NOT_NULL||a===r.BETWEEN?{searchOperator:a,searchValue:""}:{searchOperator:a}})}}),((t,a,i,n)=>{const l=null!=n?n:t._type;if(t.searchOperator===r.BETWEEN){const[a,n]=(t.searchValue||",").split(",");return"date"===l?e("div",{class:"value-input between-input-container"},e("udp-date-input",{value:a,includeErrorPadding:!1,onValueChanged:e=>i(e.detail,t,0)}),e("span",null,"and"),e("udp-date-input",{value:n,includeErrorPadding:!1,onValueChanged:e=>i(e.detail,t,1)})):"datetime"===l?e("div",{class:"value-input between-input-container"},e("udp-date-time-input",{value:a,includeErrorPadding:!1,onValueChanged:e=>i(e.detail,t,0)}),e("span",null,"and"),e("udp-date-time-input",{value:n,includeErrorPadding:!1,onValueChanged:e=>i(e.detail,t,1)})):e("div",{class:"value-input between-input-container"},e("udp-fluent-text-input",{value:a,type:"number"===l?"number":"text",includeErrorPadding:!1,onValueChanged:e=>i(e.detail,t,0)}),e("span",null,"and"),e("udp-fluent-text-input",{value:n,type:"number"===l?"number":"text",includeErrorPadding:!1,onValueChanged:e=>i(e.detail,t,1)}))}if(t.searchOperator===r.IN)return e("udp-fluent-text-input",{placeholder:"value1, value2, ...",value:t.searchValue,includeErrorPadding:!1,class:"value-input",onValueChanged:e=>a(e.detail,t)});const o=t.searchOperator===r.NULL||t.searchOperator===r.NOT_NULL;switch(l){case"number":return e("udp-fluent-text-input",{placeholder:"Enter a number value...",type:"number",value:t.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:e=>a(e.detail,t)});case"boolean":return e("udp-fluent-dropdown",{options:[{value:"true",label:"True"},{value:"false",label:"False"}],value:String(t.searchValue),includeErrorPadding:!1,clearable:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:e=>{const i=e.detail;a("object"==typeof i?i.value:i,t)}});case"date":return e("udp-date-input",{value:t.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:e=>a(e.detail,t)});case"datetime":return e("udp-date-time-input",{value:t.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:e=>a(e.detail,t)});case"time":return e("udp-time-input",{value:t.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:e=>a(e.detail,t)});case"guid":return e("udp-fluent-text-input",{placeholder:"Enter a GUID value...",value:t.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:e=>a(e.detail,t)});default:return e("udp-fluent-text-input",{placeholder:"Enter a value...",value:t.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:e=>a(e.detail,t)})}})(t,this.handleValueChange,this.handleBetweenValueChange,null==i?void 0:i.type),e("div",{class:"actions"},e("udp-fluent-icon-button",{class:"row-remove",iconName:"dismiss",appearance:"subtle",size:"small",ariaLabel:"Remove filter",onClick:()=>this.removeFilter.emit(t._id)}))),t._error&&t._touched&&e("udp-text",{variant:"caption2",class:"row-error"},t._error))})),n.map((t=>e("udp-advanced-search-filter-group",{key:t.groupId,groupId:t.groupId,filterData:this.filterData,fields:this.fields,isRoot:!1,operators:this.operators,freeFormFields:this.freeFormFields,openAddMenuForGroupId:this.openAddMenuForGroupId,onAddFilter:e=>{e.stopPropagation(),this.addFilter.emit(e.detail)},onAddGroup:e=>{e.stopPropagation(),this.addGroup.emit(e.detail)},onRemoveFilter:e=>{e.stopPropagation(),this.removeFilter.emit(e.detail)},onRemoveGroup:e=>{e.stopPropagation(),this.removeGroup.emit(e.detail)},onFilterChange:e=>{e.stopPropagation(),this.filterChange.emit(e.detail)},onGroupChange:e=>{e.stopPropagation(),this.groupChange.emit(e.detail)},onToggleAddMenu:e=>{e.stopPropagation(),this.toggleAddMenu.emit(e.detail)}}))),e("div",{class:"add-new-container"},e("udp-fluent-button",{appearance:"transparent",size:"small",onClick:()=>this.addFilter.emit(this.groupId)},"+ Add filter"),!this.flat&&e("udp-fluent-button",{class:"add-group-button",appearance:"transparent",size:"small",onClick:()=>this.addGroup.emit(this.groupId)},"+ Add group"))))}static get style(){return":host{display:block}.group-header{display:flex;align-items:center;gap:var(--spacingHorizontalS);padding-block:var(--spacingVerticalXS);position:relative}.match-text{color:var(--colorNeutralForeground2);font-size:var(--fontSizeBase300);flex-shrink:0}.logical-op{width:76px;flex-shrink:0}.group-content{display:flex;flex-direction:column;gap:var(--spacingVerticalS);border-left:2px solid var(--colorNeutralStroke1);padding-left:var(--spacingHorizontalXXL);margin-left:var(--spacingHorizontalXS)}.filter-item{display:flex;flex-direction:column;gap:var(--spacingVerticalXXS)}.filter-row{display:flex;align-items:center;gap:var(--spacingHorizontalS);position:relative;min-height:32px}.field-select{flex:1 1 240px;min-width:140px;max-width:300px}.operator-select{flex:0 0 120px}.value-input{flex:1 1 220px;min-width:170px;max-width:340px}.value-input.is-hidden{visibility:hidden}.between-input-container{display:flex;align-items:center;gap:var(--spacingHorizontalXS);flex:1 1 220px;min-width:260px;max-width:420px}.between-input-container udp-fluent-text-input,.between-input-container udp-date-input,.between-input-container udp-date-time-input,.between-input-container udp-time-input{flex:1;min-width:0}.between-input-container span{font-size:var(--fontSizeBase200);color:var(--colorNeutralForeground3);flex-shrink:0}.drag-handle{font-size:var(--fontSizeBase400);color:var(--colorNeutralForeground3);cursor:grab;flex-shrink:0;user-select:none;touch-action:none;opacity:0;transition:opacity 0.1s ease}.drag-handle:active{cursor:grabbing}.actions{display:flex;gap:var(--spacingHorizontalXXS);flex-shrink:0;opacity:0;transition:opacity 0.1s ease}.filter-row:hover .drag-handle,.filter-row:focus-within .drag-handle,.group-header:hover .drag-handle,.filter-row:hover .actions,.filter-row:focus-within .actions,.group-header:hover .actions,.group-header:focus-within .actions{opacity:1}.filter-row.drag-slot,.group-box.drag-slot{background:var(--colorNeutralBackground2);border:1px dashed var(--colorNeutralStroke2);border-radius:var(--borderRadiusMedium)}.drag-slot>*{visibility:hidden}.row-error{display:block;color:var(--colorPaletteRedForeground1);padding-left:calc(var(--spacingHorizontalL) + var(--spacingHorizontalS))}.is-invalid .value-input{--colorNeutralStroke1:var(--colorPaletteRedBorder2);--colorNeutralStrokeAccessible:var(--colorPaletteRedBorder2)}.add-new-container{display:flex;align-items:center;gap:var(--spacingHorizontalXS)}"}},[1,"udp-advanced-search-filter-group",{groupId:[2,"group-id"],filterData:[16],fields:[16],isRoot:[4,"is-root"],openAddMenuForGroupId:[2,"open-add-menu-for-group-id"],maxDepth:[2,"max-depth"],showDepthSelector:[4,"show-depth-selector"],flat:[4],operators:[16],freeFormFields:[4,"free-form-fields"]}]);function D(){"undefined"!=typeof customElements&&["udp-advanced-search-filter-group","udp-advanced-search-filter-group","udp-autocomplete","udp-date-input","udp-date-range-selector","udp-date-time-input","udp-fluent-badge","udp-fluent-button","udp-fluent-dropdown","udp-fluent-icon","udp-fluent-icon-button","udp-fluent-text-input","udp-popover","udp-spinner","udp-text","udp-time-input","udp-tooltip"].forEach((e=>{switch(e){case"udp-advanced-search-filter-group":customElements.get(n(e))||customElements.define(n(e),R);break;case"udp-advanced-search-filter-group":customElements.get(n(e))||D();break;case"udp-autocomplete":customElements.get(n(e))||d();break;case"udp-date-input":customElements.get(n(e))||u();break;case"udp-date-range-selector":customElements.get(n(e))||p();break;case"udp-date-time-input":customElements.get(n(e))||c();break;case"udp-fluent-badge":customElements.get(n(e))||h();break;case"udp-fluent-button":customElements.get(n(e))||g();break;case"udp-fluent-dropdown":customElements.get(n(e))||m();break;case"udp-fluent-icon":customElements.get(n(e))||f();break;case"udp-fluent-icon-button":customElements.get(n(e))||v();break;case"udp-fluent-text-input":customElements.get(n(e))||b();break;case"udp-popover":customElements.get(n(e))||x();break;case"udp-spinner":customElements.get(n(e))||w();break;case"udp-text":customElements.get(n(e))||E();break;case"udp-time-input":customElements.get(n(e))||k();break;case"udp-tooltip":customElements.get(n(e))||y()}}))}export{R as U,F as a,D as d,P as g}
|
|
2
|
+
import{h as e,p as t,H as a,c as i,t as n}from"./index2.js";import{a as r,L as l}from"./searchObject.js";import{i as o,h as s,d}from"./depthOptions.js";import{d as u}from"./udp-autocomplete2.js";import{d as p}from"./udp-date-input2.js";import{d as c}from"./udp-date-range-selector2.js";import{d as h}from"./udp-date-time-input2.js";import{d as g}from"./udp-fluent-badge2.js";import{d as m}from"./udp-fluent-button2.js";import{d as f}from"./udp-fluent-dropdown2.js";import{d as v}from"./udp-fluent-icon2.js";import{d as b}from"./udp-fluent-icon-button2.js";import{d as x}from"./udp-fluent-text-input2.js";import{d as w}from"./udp-popover2.js";import{d as E}from"./udp-spinner2.js";import{d as k}from"./udp-text2.js";import{d as y}from"./udp-time-input2.js";import{d as S}from"./udp-tooltip2.js";import{f as C}from"./catalogTree.js";const V=[{value:r.EQUALS,label:"is"},{value:r.NOT_EQUALS,label:"is not"},{value:r.LESS_THAN,label:"is less than"},{value:r.GREATER_THAN,label:"is greater than"},{value:r.LESS_THAN_OR_EQUAL,label:"is at most"},{value:r.GREATER_THAN_OR_EQUAL,label:"is at least"},{value:r.LIKE,label:"contains"},{value:r.STARTSWITH,label:"begins with"},{value:r.BETWEEN,label:"is between"},{value:r.IN,label:"is any of"},{value:r.NOT_IN,label:"is none of"},{value:r.NULL,label:"is empty"},{value:r.NOT_NULL,label:"is not empty"}],j={[r.LESS_THAN]:"is before",[r.GREATER_THAN]:"is after",[r.LESS_THAN_OR_EQUAL]:"is on or before",[r.GREATER_THAN_OR_EQUAL]:"is on or after"},z=new Set(["date","datetime","time"]),F={guid:[r.EQUALS,r.NOT_EQUALS,r.LIKE,r.IN,r.NOT_IN,r.NULL,r.NOT_NULL],string:[r.EQUALS,r.NOT_EQUALS,r.LIKE,r.STARTSWITH,r.IN,r.NOT_IN,r.NULL,r.NOT_NULL],number:[r.EQUALS,r.NOT_EQUALS,r.LESS_THAN,r.GREATER_THAN,r.LESS_THAN_OR_EQUAL,r.GREATER_THAN_OR_EQUAL,r.BETWEEN,r.IN,r.NOT_IN,r.NULL,r.NOT_NULL],boolean:[r.EQUALS,r.NOT_EQUALS,r.NULL,r.NOT_NULL],date:[r.EQUALS,r.NOT_EQUALS,r.LESS_THAN,r.GREATER_THAN,r.LESS_THAN_OR_EQUAL,r.GREATER_THAN_OR_EQUAL,r.BETWEEN,r.NULL,r.NOT_NULL],datetime:[r.EQUALS,r.NOT_EQUALS,r.LESS_THAN,r.GREATER_THAN,r.LESS_THAN_OR_EQUAL,r.GREATER_THAN_OR_EQUAL,r.BETWEEN,r.NULL,r.NOT_NULL],time:[r.EQUALS,r.NOT_EQUALS,r.LESS_THAN,r.GREATER_THAN,r.LESS_THAN_OR_EQUAL,r.GREATER_THAN_OR_EQUAL,r.BETWEEN,r.NULL,r.NOT_NULL],default:[r.EQUALS,r.NOT_EQUALS]},P=(e,t)=>{var a;const i=e&&null!==(a=F[e.type])&&void 0!==a?a:F.default,n=(null==t?void 0:t.length)?i.filter((e=>t.includes(e))):i,r=e&&z.has(e.type);return V.filter((e=>n.includes(e.value))).map((e=>r&&j[e.value]?Object.assign(Object.assign({},e),{label:j[e.value]}):e))},I=e=>{var t,a;return null!==(a=null===(t=V.find((t=>t.value===e)))||void 0===t?void 0:t.label)&&void 0!==a?a:e},R=(e,t="",a="")=>{const i=[];return e.forEach((e=>{var n;const r=e.childFields&&e.childFields.length>0;if(r&&o(e.name))return;const l=t?`${t}.${e.name}`:e.name,d=s(null!==(n=e.displayName)&&void 0!==n?n:e.name),u=a?`${a} · ${d}`:d;i.push({value:l,label:u,disabled:r||void 0}),r&&i.push(...R(e.childFields,l,u))})),i},G=t(class extends a{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.addFilter=i(this,"addFilter",7),this.addGroup=i(this,"addGroup",7),this.removeFilter=i(this,"removeFilter",7),this.removeGroup=i(this,"removeGroup",7),this.filterChange=i(this,"filterChange",7),this.groupChange=i(this,"groupChange",7),this.toggleAddMenu=i(this,"toggleAddMenu",7),this.depthChange=i(this,"depthChange",7),this.isRoot=!1,this.showDepthSelector=!0,this.flat=!1,this.freeFormFields=!1,this.handleValueChange=(e,t)=>{this.filterChange.emit({filterId:t._id,field:"searchValue",value:e})},this.handleBetweenValueChange=(e,t,a)=>{const i=(t.searchValue||",").split(",");i[a]=e,this.filterChange.emit({filterId:t._id,field:"searchValue",value:i.join(",")})}}countGroupConditions(e){const t=this.filterData.filterElements.filter((t=>t.groupId===e)).length;return this.filterData.filterGroups.filter((t=>t.parentGroupId===e)).reduce(((e,t)=>e+this.countGroupConditions(t.groupId)),t)}getDropdownValue(e){return"object"==typeof e&&null!==e?e.value:String(e)}handleFilterFieldChange(e,t){var a;const i=C(this.fields,t),n=P(i,this.operators);let r="";((null==i?void 0:i.type)||"").toLowerCase().includes("bool")&&(r=!0),this.filterChange.emit({filterId:e._id,updates:{searchField:t,_type:(null==i?void 0:i.type)||"string",searchValue:r}}),n.some((t=>t.value===e.searchOperator))||this.filterChange.emit({filterId:e._id,updates:{searchOperator:(null===(a=null==n?void 0:n[0])||void 0===a?void 0:a.value)||""}})}render(){var t,a;const i=this.filterData.filterGroups.find((e=>e.groupId===this.groupId));if(!i)return null;const n=this.filterData.filterElements.filter((e=>e.groupId===this.groupId)),o=this.filterData.filterGroups.filter((e=>e.parentGroupId===this.groupId)),u=this.isRoot?0:this.countGroupConditions(this.groupId);return e("div",{class:{"group-box":!0,"root-group":this.isRoot},"data-group-id":String(this.groupId),"data-parent-group-id":null!=i.parentGroupId?String(i.parentGroupId):void 0},e("div",{class:"group-header"},!this.isRoot&&e("span",{class:"drag-handle","data-drag-handle":"","data-drag-type":"group","data-drag-id":String(this.groupId),"data-drag-label":`Group (${i.logicalSearchOperator===l.AND?"all":"any"})`,"data-drag-sublabel":`${u} condition${1===u?"":"s"}`},"⠿"),e("span",{class:"match-text"},"Match"),this.flat?e("span",{class:"match-text"},"all"):e("udp-fluent-dropdown",{class:"logical-op",controlSize:"small",options:[{value:"1",label:"all"},{value:"2",label:"any"}],value:String(i.logicalSearchOperator),appearance:"filled-lighter",includeErrorPadding:!1,clearable:!1,onValueChanged:e=>this.groupChange.emit({groupId:this.groupId,logicalSearchOperator:parseInt(this.getDropdownValue(e.detail))})}),e("span",{class:"match-text"},"of the following"),this.isRoot?this.showDepthSelector&&e("div",{style:{marginLeft:"auto",marginRight:"12px",width:"100px",flexShrink:"0"}},e("udp-fluent-dropdown",{class:"depth-select",controlSize:"small",options:d(null!==(t=this.maxDepth)&&void 0!==t?t:2),value:String(null!==(a=this.maxDepth)&&void 0!==a?a:2),appearance:"filled-lighter",includeErrorPadding:!1,clearable:!1,onValueChanged:e=>this.depthChange.emit(parseInt(this.getDropdownValue(e.detail),10))})):e("div",{class:"actions"},e("udp-fluent-icon-button",{iconName:"dismiss",appearance:"subtle",size:"small",ariaLabel:"Remove group",onClick:()=>this.removeGroup.emit(this.groupId)}))),e("div",{class:"group-content"},n.map((t=>{var a;const i=C(this.fields,t.searchField),n=P(i,this.operators);return e("div",{class:"filter-item",key:t._id},e("div",{class:{"filter-row":!0,"is-invalid":!!t._error&&!!t._touched},"data-filter-id":t._id,"data-group-id":String(this.groupId)},e("span",{class:"drag-handle","data-drag-handle":"","data-drag-type":"filter","data-drag-id":t._id,"data-drag-label":i?s(null!==(a=i.displayName)&&void 0!==a?a:i.name):"Filter"},"⠿"),e("udp-autocomplete",{class:"field-select",options:R(this.fields),optionLabel:"label",optionValue:"value",optionDisabled:"disabled",value:t.searchField,freeForm:this.freeFormFields,placeholder:"Search fields...",clearable:!1,includeErrorPadding:!1,onValueChanged:e=>this.handleFilterFieldChange(t,this.getDropdownValue(e.detail))}),e("udp-fluent-dropdown",{class:"operator-select",options:n,value:t.searchOperator,includeErrorPadding:!1,clearable:!1,onValueChanged:e=>{const a=this.getDropdownValue(e.detail);this.filterChange.emit({filterId:t._id,updates:a===r.NULL||a===r.NOT_NULL||a===r.BETWEEN?{searchOperator:a,searchValue:""}:{searchOperator:a}})}}),((t,a,i,n)=>{const l=null!=n?n:t._type;if(t.searchOperator===r.BETWEEN){const[a,n]=(t.searchValue||",").split(",");return"date"===l?e("div",{class:"value-input between-input-container"},e("udp-date-input",{value:a,includeErrorPadding:!1,onValueChanged:e=>i(e.detail,t,0)}),e("span",null,"and"),e("udp-date-input",{value:n,includeErrorPadding:!1,onValueChanged:e=>i(e.detail,t,1)})):"datetime"===l?e("div",{class:"value-input between-input-container"},e("udp-date-time-input",{value:a,includeErrorPadding:!1,onValueChanged:e=>i(e.detail,t,0)}),e("span",null,"and"),e("udp-date-time-input",{value:n,includeErrorPadding:!1,onValueChanged:e=>i(e.detail,t,1)})):e("div",{class:"value-input between-input-container"},e("udp-fluent-text-input",{value:a,type:"number"===l?"number":"text",includeErrorPadding:!1,onValueChanged:e=>i(e.detail,t,0)}),e("span",null,"and"),e("udp-fluent-text-input",{value:n,type:"number"===l?"number":"text",includeErrorPadding:!1,onValueChanged:e=>i(e.detail,t,1)}))}if(t.searchOperator===r.IN)return e("udp-fluent-text-input",{placeholder:"value1, value2, ...",value:t.searchValue,includeErrorPadding:!1,class:"value-input",onValueChanged:e=>a(e.detail,t)});const o=t.searchOperator===r.NULL||t.searchOperator===r.NOT_NULL;switch(l){case"number":return e("udp-fluent-text-input",{placeholder:"Enter a number value...",type:"number",value:t.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:e=>a(e.detail,t)});case"boolean":return e("udp-fluent-dropdown",{options:[{value:"true",label:"True"},{value:"false",label:"False"}],value:String(t.searchValue),includeErrorPadding:!1,clearable:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:e=>{const i=e.detail;a("object"==typeof i?i.value:i,t)}});case"date":return e("udp-date-input",{value:t.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:e=>a(e.detail,t)});case"datetime":return e("udp-date-time-input",{value:t.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:e=>a(e.detail,t)});case"time":return e("udp-time-input",{value:t.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:e=>a(e.detail,t)});case"guid":return e("udp-fluent-text-input",{placeholder:"Enter a GUID value...",value:t.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:e=>a(e.detail,t)});default:return e("udp-fluent-text-input",{placeholder:"Enter a value...",value:t.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:e=>a(e.detail,t)})}})(t,this.handleValueChange,this.handleBetweenValueChange,null==i?void 0:i.type),e("div",{class:"actions"},e("udp-fluent-icon-button",{class:"row-remove",iconName:"dismiss",appearance:"subtle",size:"small",ariaLabel:"Remove filter",onClick:()=>this.removeFilter.emit(t._id)}))),t._error&&t._touched&&e("udp-text",{variant:"caption2",class:"row-error"},t._error))})),o.map((t=>e("udp-advanced-search-filter-group",{key:t.groupId,groupId:t.groupId,filterData:this.filterData,fields:this.fields,isRoot:!1,operators:this.operators,freeFormFields:this.freeFormFields,openAddMenuForGroupId:this.openAddMenuForGroupId,onAddFilter:e=>{e.stopPropagation(),this.addFilter.emit(e.detail)},onAddGroup:e=>{e.stopPropagation(),this.addGroup.emit(e.detail)},onRemoveFilter:e=>{e.stopPropagation(),this.removeFilter.emit(e.detail)},onRemoveGroup:e=>{e.stopPropagation(),this.removeGroup.emit(e.detail)},onFilterChange:e=>{e.stopPropagation(),this.filterChange.emit(e.detail)},onGroupChange:e=>{e.stopPropagation(),this.groupChange.emit(e.detail)},onToggleAddMenu:e=>{e.stopPropagation(),this.toggleAddMenu.emit(e.detail)}}))),e("div",{class:"add-new-container"},e("udp-fluent-button",{appearance:"transparent",size:"small",onClick:()=>this.addFilter.emit(this.groupId)},"+ Add filter"),!this.flat&&e("udp-fluent-button",{class:"add-group-button",appearance:"transparent",size:"small",onClick:()=>this.addGroup.emit(this.groupId)},"+ Add group"))))}static get style(){return":host{display:block}.group-header{display:flex;align-items:center;gap:var(--spacingHorizontalS);padding-block:var(--spacingVerticalXS);position:relative}.match-text{color:var(--colorNeutralForeground2);font-size:var(--fontSizeBase300);flex-shrink:0}.logical-op{width:76px;flex-shrink:0}.group-content{display:flex;flex-direction:column;gap:var(--spacingVerticalS);border-left:2px solid var(--colorNeutralStroke1);padding-left:var(--spacingHorizontalXXL);margin-left:var(--spacingHorizontalXS)}.filter-item{display:flex;flex-direction:column;gap:var(--spacingVerticalXXS)}.filter-row{display:flex;align-items:center;gap:var(--spacingHorizontalS);position:relative;min-height:32px}.field-select{flex:1 1 240px;min-width:140px;max-width:300px}.operator-select{flex:0 0 120px}.value-input{flex:1 1 220px;min-width:170px;max-width:340px}.value-input.is-hidden{visibility:hidden}.between-input-container{display:flex;align-items:center;gap:var(--spacingHorizontalXS);flex:1 1 220px;min-width:260px;max-width:420px}.between-input-container udp-fluent-text-input,.between-input-container udp-date-input,.between-input-container udp-date-time-input,.between-input-container udp-time-input{flex:1;min-width:0}.between-input-container span{font-size:var(--fontSizeBase200);color:var(--colorNeutralForeground3);flex-shrink:0}.drag-handle{font-size:var(--fontSizeBase400);color:var(--colorNeutralForeground3);cursor:grab;flex-shrink:0;user-select:none;touch-action:none;opacity:0;transition:opacity 0.1s ease}.drag-handle:active{cursor:grabbing}.actions{display:flex;gap:var(--spacingHorizontalXXS);flex-shrink:0;opacity:0;transition:opacity 0.1s ease}.filter-row:hover .drag-handle,.filter-row:focus-within .drag-handle,.group-header:hover .drag-handle,.filter-row:hover .actions,.filter-row:focus-within .actions,.group-header:hover .actions,.group-header:focus-within .actions{opacity:1}.filter-row.drag-slot,.group-box.drag-slot{background:var(--colorNeutralBackground2);border:1px dashed var(--colorNeutralStroke2);border-radius:var(--borderRadiusMedium)}.drag-slot>*{visibility:hidden}.row-error{display:block;color:var(--colorPaletteRedForeground1);padding-left:calc(var(--spacingHorizontalL) + var(--spacingHorizontalS))}.is-invalid .value-input{--colorNeutralStroke1:var(--colorPaletteRedBorder2);--colorNeutralStrokeAccessible:var(--colorPaletteRedBorder2)}.add-new-container{display:flex;align-items:center;gap:var(--spacingHorizontalXS)}"}},[1,"udp-advanced-search-filter-group",{groupId:[2,"group-id"],filterData:[16],fields:[16],isRoot:[4,"is-root"],openAddMenuForGroupId:[2,"open-add-menu-for-group-id"],maxDepth:[2,"max-depth"],showDepthSelector:[4,"show-depth-selector"],flat:[4],operators:[16],freeFormFields:[4,"free-form-fields"]}]);function N(){"undefined"!=typeof customElements&&["udp-advanced-search-filter-group","udp-advanced-search-filter-group","udp-autocomplete","udp-date-input","udp-date-range-selector","udp-date-time-input","udp-fluent-badge","udp-fluent-button","udp-fluent-dropdown","udp-fluent-icon","udp-fluent-icon-button","udp-fluent-text-input","udp-popover","udp-spinner","udp-text","udp-time-input","udp-tooltip"].forEach((e=>{switch(e){case"udp-advanced-search-filter-group":customElements.get(n(e))||customElements.define(n(e),G);break;case"udp-advanced-search-filter-group":customElements.get(n(e))||N();break;case"udp-autocomplete":customElements.get(n(e))||u();break;case"udp-date-input":customElements.get(n(e))||p();break;case"udp-date-range-selector":customElements.get(n(e))||c();break;case"udp-date-time-input":customElements.get(n(e))||h();break;case"udp-fluent-badge":customElements.get(n(e))||g();break;case"udp-fluent-button":customElements.get(n(e))||m();break;case"udp-fluent-dropdown":customElements.get(n(e))||f();break;case"udp-fluent-icon":customElements.get(n(e))||v();break;case"udp-fluent-icon-button":customElements.get(n(e))||b();break;case"udp-fluent-text-input":customElements.get(n(e))||x();break;case"udp-popover":customElements.get(n(e))||w();break;case"udp-spinner":customElements.get(n(e))||E();break;case"udp-text":customElements.get(n(e))||k();break;case"udp-time-input":customElements.get(n(e))||y();break;case"udp-tooltip":customElements.get(n(e))||S()}}))}export{G as U,P as a,N as d,I as g}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import "../stencil-library/stencil-library.css";
|
|
2
|
-
import{p as t,H as i,c as e,h as s,d as r,t as o}from"./index2.js";import{L as n,a}from"./searchObject.js";import{g as l}from"./entityUtilities.js";import{h as d}from"./labelHelper.js";import{g as h,a as u,d as c}from"./filter-group.js";import{d as p}from"./field-picker.js";import{d as f}from"./field-picker-tree.js";import{d as m}from"./udp-autocomplete2.js";import{d as v}from"./udp-container-query2.js";import{d as g}from"./udp-container-query-grid2.js";import{d as b}from"./udp-date-input2.js";import{d as x}from"./udp-date-range-selector2.js";import{d as y}from"./udp-date-time-input2.js";import{d as F}from"./udp-flexbox2.js";import{d as k}from"./udp-fluent-avatar2.js";import{d as w}from"./udp-fluent-badge2.js";import{d as j}from"./udp-fluent-button2.js";import{d as E}from"./udp-fluent-card2.js";import{d as D}from"./udp-fluent-dropdown2.js";import{d as S}from"./udp-fluent-icon2.js";import{d as O}from"./udp-fluent-icon-button2.js";import{d as I}from"./udp-list-item2.js";import{d as z}from"./udp-fluent-text-input2.js";import{d as A}from"./udp-list2.js";import{d as G}from"./udp-popover2.js";import{d as M}from"./udp-search-input2.js";import{d as T}from"./udp-sidebar-layout2.js";import{d as N}from"./udp-spinner2.js";import{d as C}from"./udp-text2.js";import{d as P}from"./udp-time-input2.js";import{d as L}from"./udp-tooltip2.js";import{d as $}from"./udp-tree2.js";import{g as H,c as V,b as B,f as R}from"./catalogTree.js";import{e as _,g as q,c as W,f as U,j as J,E as Y}from"./extraFields.js";const K=t=>{if(!t||!t.filterGroups||0===t.filterGroups.length)return"";const i=e=>{const s=t.filterGroups.find((t=>t.groupId===e));if(!s)return"";const r=s.logicalSearchOperator===n.AND?"AND":"OR",o=[];return t.filterElements.filter((t=>t.groupId===e)).forEach((t=>{var i,e;const s="string"==typeof t.searchValue?`"${t.searchValue}"`:t.searchValue,r=d(null!==(e=null===(i=t.searchField)||void 0===i?void 0:i.split(".").pop())&&void 0!==e?e:"");o.push(`[${r}] ${h(t.searchOperator)} ${s}`)})),t.filterGroups.filter((t=>t.parentGroupId===e)).forEach((t=>{const e=i(t.groupId);e&&o.push(`(${e})`)})),o.join(` ${r} `)},e=t.filterGroups.find((t=>null===t.parentGroupId));return e?i(e.groupId):""};class Q{constructor(t,i){this.scrollContainer=null,this.isDragStarted=!1,this.pendingItem=null,this.pendingLabel="",this.pendingSublabel="",this.sourceRowEl=null,this.startX=0,this.startY=0,this.currentState={isDragging:!1,dragItem:null,insertionPoint:null},this.sourceOriginalStyle="",this.draggedItemHeight=0,this.ghostOriginalTop=0,this.placeholder=null,this.fixedOffsetX=0,this.fixedOffsetY=0,this.slotInsetLeft=0,this.slotInsetRight=0,this.overlay=null,this.dropTargets=[],this.previousGapEls=[],this.lockedTarget=null,this.lockedPosition="before",this.autoScrollRAF=null,this.hostEl=t,this.callbacks=i,this.boundPointerDown=this.onPointerDown.bind(this),this.boundPointerMove=this.onPointerMove.bind(this),this.boundPointerUp=this.onPointerUp.bind(this),this.boundKeyDown=this.onKeyDown.bind(this),this.boundScroll=this.onScroll.bind(this),this.hostEl.addEventListener("pointerdown",this.boundPointerDown,!0)}destroy(){this.hostEl.removeEventListener("pointerdown",this.boundPointerDown,!0),this.cleanup()}setScrollContainer(t){this.scrollContainer=t}onPointerDown(t){if(0!==t.button)return;const i=t.composedPath(),e=i.find((t=>t instanceof HTMLElement&&t.hasAttribute("data-drag-handle")));if(!e)return;t.preventDefault();const s=e.dataset.dragType,r=e.dataset.dragId;if(!s||!r)return;const o=i.find((t=>t instanceof HTMLElement&&("filter"===s?t.classList.contains("filter-row"):t.classList.contains("group-box")&&!t.classList.contains("root-group"))));this.pendingItem={type:s,id:r},this.pendingLabel=e.dataset.dragLabel||("filter"===s?"Filter":"Group"),this.pendingSublabel=e.dataset.dragSublabel||"",this.sourceRowEl=o||null,this.startX=t.clientX,this.startY=t.clientY,this.isDragStarted=!1,document.addEventListener("pointermove",this.boundPointerMove),document.addEventListener("pointerup",this.boundPointerUp),document.addEventListener("keydown",this.boundKeyDown)}onPointerMove(t){const i=t.clientX-this.startX,e=t.clientY-this.startY;if(!this.isDragStarted){if(Math.sqrt(i*i+e*e)<5)return;this.beginDrag()}this.moveOverlay(t.clientX,t.clientY),this.updateInsertionPoint(t.clientY),this.handleAutoScroll(t.clientY)}onPointerUp(){this.isDragStarted&&this.currentState.insertionPoint&&this.currentState.dragItem&&this.callbacks.onDrop(this.currentState.dragItem,this.currentState.insertionPoint),this.cleanup()}onKeyDown(t){"Escape"===t.key&&this.cleanup()}beginDrag(){var t,i;if(this.isDragStarted=!0,this.fixedOffsetX=0,this.fixedOffsetY=0,this.sourceRowEl){const e=this.sourceRowEl.getBoundingClientRect();if(this.draggedItemHeight=e.height,this.sourceOriginalStyle=this.sourceRowEl.style.cssText,this.slotInsetLeft=0,this.slotInsetRight=0,"filter"===(null===(t=this.pendingItem)||void 0===t?void 0:t.type)){const t=this.sourceRowEl.querySelector(".field-select"),i=this.sourceRowEl.querySelector(".actions");t&&(this.slotInsetLeft=t.getBoundingClientRect().left-e.left);const s=null==i?void 0:i.previousElementSibling;s&&(this.slotInsetRight=e.right-s.getBoundingClientRect().right)}this.placeholder=document.createElement("div"),this.placeholder.style.height=e.height+"px",this.placeholder.style.pointerEvents="none",null===(i=this.sourceRowEl.parentNode)||void 0===i||i.insertBefore(this.placeholder,this.sourceRowEl.nextSibling),this.sourceRowEl.style.position="fixed",this.sourceRowEl.style.top=e.top+"px",this.sourceRowEl.style.left=e.left+this.slotInsetLeft+"px",this.sourceRowEl.style.width=e.width-this.slotInsetLeft-this.slotInsetRight+"px",this.sourceRowEl.style.height=e.height+"px",this.sourceRowEl.style.zIndex="10000",this.sourceRowEl.style.pointerEvents="none",this.sourceRowEl.style.boxSizing="border-box",this.sourceRowEl.classList.add("drag-slot");const s=this.sourceRowEl.getBoundingClientRect();this.fixedOffsetX=s.left-(e.left+this.slotInsetLeft),this.fixedOffsetY=s.top-e.top,0===this.fixedOffsetX&&0===this.fixedOffsetY||(this.sourceRowEl.style.top=e.top-this.fixedOffsetY+"px",this.sourceRowEl.style.left=e.left+this.slotInsetLeft-this.fixedOffsetX+"px"),this.ghostOriginalTop=e.top-this.fixedOffsetY,this.sourceRowEl.style.transition="top 80ms ease-out, left 80ms ease-out, width 80ms ease-out"}this.collectDropTargets(),this.createOverlay(),this.scrollContainer&&this.scrollContainer.addEventListener("scroll",this.boundScroll,{passive:!0}),document.body.style.cursor="grabbing",document.body.style.userSelect="none",this.currentState={isDragging:!0,dragItem:this.pendingItem,insertionPoint:null},this.callbacks.onStateChange(Object.assign({},this.currentState))}cleanup(){this.placeholder&&(this.placeholder.remove(),this.placeholder=null),this.sourceRowEl&&(this.sourceRowEl.style.cssText=this.sourceOriginalStyle,this.sourceRowEl.classList.remove("drag-slot"),this.sourceRowEl=null),this.overlay&&(this.overlay.remove(),this.overlay=null),this.clearGap(),null!==this.autoScrollRAF&&(cancelAnimationFrame(this.autoScrollRAF),this.autoScrollRAF=null),this.scrollContainer&&this.scrollContainer.removeEventListener("scroll",this.boundScroll),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("pointermove",this.boundPointerMove),document.removeEventListener("pointerup",this.boundPointerUp),document.removeEventListener("keydown",this.boundKeyDown),this.pendingItem=null,this.pendingLabel="",this.pendingSublabel="",this.isDragStarted=!1,this.dropTargets=[],this.draggedItemHeight=0,this.ghostOriginalTop=0,this.sourceOriginalStyle="",this.lockedTarget=null;const t=this.currentState.isDragging;this.currentState={isDragging:!1,dragItem:null,insertionPoint:null},t&&this.callbacks.onStateChange(Object.assign({},this.currentState))}createOverlay(){var t;this.overlay=document.createElement("div"),this.overlay.className="drag-overlay";const i=document.createElement("span");i.className="drag-overlay-grip",i.textContent="⠿";const e=document.createElement("div");e.className="drag-overlay-text";const s=document.createElement("span");if(s.className="drag-overlay-label",s.textContent=this.pendingLabel,e.appendChild(s),this.pendingSublabel){const t=document.createElement("span");t.className="drag-overlay-sub",t.textContent=this.pendingSublabel,e.appendChild(t)}this.overlay.append(i,e),null===(t=this.hostEl.shadowRoot)||void 0===t||t.appendChild(this.overlay)}moveOverlay(t,i){this.overlay&&(this.overlay.style.left=t+12-this.fixedOffsetX+"px",this.overlay.style.top=i-20-this.fixedOffsetY+"px")}positionGhost(t,i){if(!this.sourceRowEl)return;const e=this.getGapElement(t,i).getBoundingClientRect();let s;s="before"===i?e.top-this.draggedItemHeight:e.bottom;const r=this.getGhostReferenceRect(t,i);this.sourceRowEl.style.top=s-this.fixedOffsetY+"px",this.sourceRowEl.style.left=r.left+this.slotInsetLeft-this.fixedOffsetX+"px",this.sourceRowEl.style.width=r.width-this.slotInsetLeft-this.slotInsetRight+"px"}getGhostReferenceRect(t,i){if("group"===t.type&&"after"===i){const i=t.element.nextElementSibling;if(i){const t=Array.from(i.querySelectorAll(".filter-row, udp-advanced-search-filter-group"));for(const i of t)if(i!==this.sourceRowEl)return i.getBoundingClientRect();const e=i.querySelector(".add-new-container");if(e)return e.getBoundingClientRect()}}return t.element.getBoundingClientRect()}resetGhostPosition(){this.sourceRowEl&&(this.sourceRowEl.style.top=this.ghostOriginalTop+"px")}getGapElement(t,i){if("filter"===t.type)return t.element;if("after"===i)return t.element;const e=t.element.getRootNode();return e instanceof ShadowRoot&&e.host?e.host:t.element}applyGap(t,i){this.placeholder&&(this.placeholder.style.height="0px");const e=this.getGapElement(t,i);for(const t of this.previousGapEls)t!==e&&(t.style.marginTop="",t.style.marginBottom="");e.style.marginTop="",e.style.marginBottom="","before"===i?e.style.marginTop=this.draggedItemHeight+"px":e.style.marginBottom=this.draggedItemHeight+"px",this.previousGapEls=[e]}clearGap(){for(const t of this.previousGapEls)t.style.marginTop="",t.style.marginBottom="";this.previousGapEls=[],this.placeholder&&(this.placeholder.style.height=this.draggedItemHeight+"px")}collectDropTargets(){var t;this.dropTargets=[];const i=this.pendingItem,e=t=>{const s=t.shadowRoot;if(!s)return;s.querySelectorAll(".filter-row[data-filter-id]").forEach((t=>{const e=t.dataset.filterId;"filter"===(null==i?void 0:i.type)&&i.id===e||this.dropTargets.push({type:"filter",id:e,element:t,rect:t.getBoundingClientRect(),midY:0})}));const r=s.querySelector(".group-box[data-group-id]");if(r&&!r.classList.contains("root-group")){const t=r.dataset.groupId;if("group"!==(null==i?void 0:i.type)||i.id!==t){const i=r.querySelector(":scope > .group-header");i&&this.dropTargets.push({type:"group",id:t,element:i,rect:i.getBoundingClientRect(),midY:0})}}s.querySelectorAll("udp-advanced-search-filter-group").forEach((t=>e(t)))},s=null===(t=this.hostEl.shadowRoot)||void 0===t?void 0:t.querySelector("udp-advanced-search-filter-group");s&&e(s);for(const t of this.dropTargets)t.midY=t.rect.top+t.rect.height/2;this.dropTargets.sort(((t,i)=>t.rect.top-i.rect.top))}updateInsertionPoint(t){var i,e;if(0===this.dropTargets.length)return this.clearGap(),this.resetGhostPosition(),this.lockedTarget=null,void this.commitInsertionPoint(null);let s=null,r="before";for(const i of this.dropTargets){const e=i.element.getBoundingClientRect();if(t>=e.top&&t<=e.bottom){s=i,r=t<e.top+e.height/2?"before":"after";break}}if(!s){const o=null===(i=this.dropTargets[0])||void 0===i?void 0:i.element,n=null===(e=this.dropTargets[this.dropTargets.length-1])||void 0===e?void 0:e.element;if(o&&t<o.getBoundingClientRect().top)s=this.dropTargets[0],r="before";else{if(!(n&&t>n.getBoundingClientRect().bottom))return;s=this.dropTargets[this.dropTargets.length-1],r="after"}}if("before"===r){const t=this.dropTargets.indexOf(s);t>0&&(s=this.dropTargets[t-1],r="after")}if(s===this.lockedTarget&&r===this.lockedPosition)return;const o=this.currentState.dragItem||this.pendingItem;if(this.callbacks.isValidDrop&&o&&!this.callbacks.isValidDrop(o,s.type,s.id))return this.clearGap(),this.resetGhostPosition(),this.lockedTarget=null,void this.commitInsertionPoint(null);this.lockedTarget=s,this.lockedPosition=r,this.applyGap(s,r),this.positionGhost(s,r),this.commitInsertionPoint({position:r,targetId:s.id,targetType:s.type})}commitInsertionPoint(t){const i=this.currentState.insertionPoint;(null==i?void 0:i.position)===(null==t?void 0:t.position)&&(null==i?void 0:i.targetId)===(null==t?void 0:t.targetId)&&(null==i?void 0:i.targetType)===(null==t?void 0:t.targetType)||(this.currentState=Object.assign(Object.assign({},this.currentState),{insertionPoint:t}),this.callbacks.onStateChange(Object.assign({},this.currentState)))}handleAutoScroll(t){if(!this.scrollContainer)return;const i=this.scrollContainer.getBoundingClientRect(),e=t-i.top,s=i.bottom-t;let r=0;if(e>0&&e<50?r=-10*(1-e/50):s>0&&s<50&&(r=10*(1-s/50)),null!==this.autoScrollRAF&&(cancelAnimationFrame(this.autoScrollRAF),this.autoScrollRAF=null),0!==r){const t=()=>{this.scrollContainer&&(this.scrollContainer.scrollTop+=r,this.refreshDropTargetRects(),this.autoScrollRAF=requestAnimationFrame(t))};this.autoScrollRAF=requestAnimationFrame(t)}}onScroll(){this.refreshDropTargetRects()}refreshDropTargetRects(){for(const t of this.dropTargets)t.rect=t.element.getBoundingClientRect(),t.midY=t.rect.top+t.rect.height/2}}const X=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.filterSave=e(this,"filterSave",7),this.searchChange=e(this,"searchChange",7),this.validityChange=e(this,"validityChange",7),this.config={},this.maxDepth=2,this.showClearButton=!1,this.loading=!1,this.fieldsArray=[],this.extraFieldGroups=[],this.extraFieldsLoading=!1,this.extraFieldsRequestId=0,this.openAddMenuForGroupId=null,this.filterString="",this.isExpanded=!0,this.isFilterValid=!0,this.errorMessages=[],this.attentionErrors=[],this.rootEntityLabel="",this.nextGroupId=1,this.handleFieldPick=t=>{this.addFilterForPath(t.detail.path,t.detail.type)},this.handleSearch=()=>{this.isFilterValid&&this.filterSave?(this.filterSave.emit(this.currentFilterData),this.filterString=K(this.currentFilterData),this.config.collapsible&&this.toggleExpanded()):console.warn("Cannot run search: filter is invalid.")},this.handleClear=()=>{const t=this.getNormalizedData(Object.assign(Object.assign({},this.currentFilterData),{filterElements:[],filterGroups:[]}));this.currentFilterData=t,this.isFilterValid=!0,this.errorMessages=[],this.attentionErrors=[],this.searchChange.emit(t),this.validityChange.emit({isValid:!0,errors:[],attentionErrors:[]}),this.filterSave&&(this.filterSave.emit(t),this.filterString=K(t)),this.config.collapsible&&this.toggleExpanded()},this.toggleExpanded=()=>{this.isExpanded=!this.isExpanded,this.updateHostClasses()},this.handleToggleAddMenu=t=>{const i=t.detail;if(this.openAddMenuForGroupId=this.openAddMenuForGroupId===i?null:i,null!==this.openAddMenuForGroupId){const t=this.animContainerEl;t&&requestAnimationFrame((()=>{t.scrollTop=t.scrollHeight}))}},this.handleDragStateChange=()=>{},this.isValidDragDrop=(t,i,e)=>{if("group"===t.type&&"group"===i){const i=parseInt(t.id,10),s=parseInt(e,10);if(i===s)return!1;if(this.isDescendant(s,i,this.currentFilterData.filterGroups))return!1}if("group"===t.type&&"filter"===i){const i=parseInt(t.id,10),s=this.currentFilterData.filterElements.find((t=>t._id===e));if(s){const t=s.groupId;if(t===i||this.isDescendant(t,i,this.currentFilterData.filterGroups))return!1}}return!0},this.handleDragDrop=(t,i)=>{this.runUpdateCycle((e=>{"filter"===t.type?this.applyFilterDrop(e,t,i):"group"===t.type&&this.applyGroupDrop(e,t,i)}))},this.handleAddFilter=t=>{this.runUpdateCycle((i=>{var e,s;const r=null===(e=this.fieldsArray)||void 0===e?void 0:e[0],o=u(r,this.config.operators),n=(null===(s=null==o?void 0:o[0])||void 0===s?void 0:s.value)||"";i.filterElements.push({_id:"filter_"+Math.random(),_type:null==r?void 0:r.type,groupId:t,searchField:null==r?void 0:r.name,searchOperator:n,searchValue:""})})),this.openAddMenuForGroupId=null},this.handleAddGroup=t=>{this.runUpdateCycle((i=>{i.filterGroups.push({groupId:this.nextGroupId++,parentGroupId:t,logicalSearchOperator:n.AND})})),this.openAddMenuForGroupId=null},this.handleRemoveFilter=t=>{this.runUpdateCycle((i=>{const e=i.filterElements.findIndex((i=>i._id===t));e>-1&&i.filterElements.splice(e,1)}))},this.handleRemoveGroup=t=>{this.runUpdateCycle((i=>{const e=t=>{const s=i.filterGroups.filter((i=>i.parentGroupId===t));let r=s.map((t=>t.groupId));return s.forEach((t=>{r=[...r,...e(t.groupId)]})),r},s=[t,...e(t)];i.filterGroups=i.filterGroups.filter((t=>!s.includes(t.groupId))),i.filterElements=i.filterElements.filter((t=>!s.includes(t.groupId)))}))},this.handleFilterChange=t=>{const{filterId:i,field:e,value:s,updates:r}=t.detail;this.runUpdateCycle((t=>{const o=t.filterElements.find((t=>t._id===i));o&&(r?Object.assign(o,r):(o[e]=s,"searchValue"===e&&(o._touched=!0)))}))},this.handleDepthChange=t=>{const i=t.detail;"number"==typeof i&&i!==this.currentMaxDepth&&(this.currentMaxDepth=i,this.buildFieldTree())},this.handleGroupChange=t=>{const{groupId:i,logicalSearchOperator:e}=t.detail;this.runUpdateCycle((t=>{const s=t.filterGroups.find((t=>t.groupId===i));s&&(s.logicalSearchOperator=e)}))}}buildFieldTree(){var t;if(this.entityName&&this.catalogObjectList){const i=l(this.entityName),e=i[0].toUpperCase()+i.slice(1);this.rootEntityLabel=e,this.fieldsArray=H(V(B(this.catalogObjectList,e,this.currentMaxDepth,this.associations),this.includeFields,this.excludeFields),[...this.extraFieldGroups,...null!==(t=this.virtualFields)&&void 0!==t?t:[]])}}async loadExtraFields(){var t,i,e,s,r;const o=++this.extraFieldsRequestId,n=null!==(i=null===(t=this.extraFields)||void 0===t?void 0:t.domainName)&&void 0!==i?i:this.entityName;if(!this.extraFields||!n)return this.extraFieldGroups.length&&(this.extraFieldGroups=[]),void(this.extraFieldsLoading=!1);const a=null!==(e=this.extraFields.prefix)&&void 0!==e?e:Y;this.buildFieldTree();const l=[{path:"",domainName:n,definitions:this.extraFields.definitions,context:_(this.extraFields)}];for(const t of null!==(s=this.associations)&&void 0!==s?s:[]){const i=this.resolveAssociationPath(t),e=null!==(r=null==i?void 0:i.node.displayName)&&void 0!==r?r:null==i?void 0:i.node.name;i&&e&&l.push({path:i.path,domainName:e})}this.extraFieldsLoading=!0;try{const t=await Promise.all(l.map((async t=>{try{const i=t.context?await q(t.domainName,t.context):t.definitions?W(t.definitions):await U(t.domainName);return J(i,a,t.path)}catch(i){return console.error(`Failed to load extra-field definitions for ${t.domainName}:`,i),null}})));if(o!==this.extraFieldsRequestId)return;this.extraFieldGroups=t.filter((t=>null!==t))}finally{o===this.extraFieldsRequestId&&(this.extraFieldsLoading=!1)}}resolveAssociationPath(t){var i,e;let s=this.fieldsArray,r=null;const o=[];for(const n of t.split(".")){if(r=null!==(i=s.find((t=>t.name.toLowerCase()===n.toLowerCase())))&&void 0!==i?i:null,!r)return null;o.push(r.name),s=null!==(e=r.childFields)&&void 0!==e?e:[]}return r?{node:r,path:o.join(".")}:null}reloadExtraFields(){this.loadExtraFields()}rebuildFieldTree(){this.buildFieldTree(),this.currentFilterData&&(this.currentFilterData=this.getNormalizedData(this.currentFilterData))}syncMaxDepth(t){this.currentMaxDepth=t,this.buildFieldTree()}syncAssociations(){this.buildFieldTree()}syncInitialFilterData(t){this.currentFilterData=this.getNormalizedData(t),this.updateNextGroupId(this.currentFilterData)}componentWillLoad(){this.currentMaxDepth=this.maxDepth,this.buildFieldTree(),this.currentFilterData=this.getNormalizedData(this.initialFilterData),this.updateNextGroupId(this.currentFilterData),this.loadExtraFields()}componentDidLoad(){this.updateHostClasses(),this.dragManager=new Q(this.el,{onStateChange:this.handleDragStateChange,onDrop:this.handleDragDrop,isValidDrop:this.isValidDragDrop}),this.animContainerEl&&this.dragManager.setScrollContainer(this.animContainerEl)}disconnectedCallback(){var t;null===(t=this.dragManager)||void 0===t||t.destroy()}async addFilterElement(t,i){this.addFilterForPath(t,i)}async submitSearch(){this.handleSearch()}async clearFilters(){this.handleClear()}addFilterForPath(t,i){var e,s,r;const o=new Set(["object","array"]),n=R(this.fieldsArray,t),a=null!==(s=null!==(e=null==n?void 0:n.type)&&void 0!==e?e:null==i?void 0:i.toLowerCase())&&void 0!==s?s:"string";if(o.has(a))return;const l=u(null!=n?n:{type:a},this.config.operators),d=(null===(r=null==l?void 0:l[0])||void 0===r?void 0:r.value)||"=",h=this.currentFilterData.filterGroups.find((t=>null===t.parentGroupId));this.runUpdateCycle((i=>{var e;i.filterElements.push({_id:"filter_"+Math.random(),_type:a,groupId:null!==(e=null==h?void 0:h.groupId)&&void 0!==e?e:1,searchField:t,searchOperator:d,searchValue:"boolean"===a?"true":""})}))}updateHostClasses(){this.isExpanded?(this.el.classList.add("host-expanded"),this.el.classList.remove("host-collapsed")):(this.el.classList.add("host-collapsed"),this.el.classList.remove("host-expanded"),this.el.style.height=null)}updateNextGroupId(t){this.nextGroupId=t&&t.filterGroups.length>0?Math.max(...t.filterGroups.map((t=>t.groupId)))+1:2}verifyFilterState(t){const i=[],e=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;for(const e of t.filterGroups){if(null===e.parentGroupId)continue;const s=t.filterElements.some((t=>t.groupId===e.groupId)),r=t.filterGroups.some((t=>t.parentGroupId===e.groupId));s||r||i.push("A group has no filters. Add a filter or remove the group.")}return t.filterElements.forEach((t=>{var s,r;delete t._error;const o=null==t.searchField||""===t.searchField,n=!t.searchValue,l=t.searchOperator===a.NULL||t.searchOperator===a.NOT_NULL,h=d(null!==(r=null===(s=t.searchField)||void 0===s?void 0:s.split(".").pop())&&void 0!==r?r:"");if(o){const e="A filter is missing its field.";t._error=e,i.push(e)}else if(t.searchOperator===a.BETWEEN){const e=(t.searchValue||"").split(",");if(2!==e.length||!e[0]||!e[1]){const e=`"${h}" needs two values (from and to).`;t._error=e,i.push(e)}}else if(n&&!l){const e=`"${h}" needs a value.`;t._error=e,i.push(e)}else if("guid"===t._type&&!n&&!e.test(t.searchValue)){const e=`"${h}" needs a valid GUID.`;t._error=e,i.push(e)}})),{isValid:0===i.length,errors:i}}stampFilterElements(t){const i=new Set(t.map((t=>t._id)).filter(Boolean));return t.map(((t,e)=>{var s;const r=Object.assign({},t);if(!r._id){const t=`filter_ext_${null!==(s=r.groupId)&&void 0!==s?s:"root"}_${e}`;let o=t,n=1;for(;i.has(o);)o=`${t}_${n++}`;i.add(o),r._id=o}if(!r._type){const t=R(this.fieldsArray,r.searchField);(null==t?void 0:t.type)&&(r._type=t.type)}return r}))}getNormalizedData(t){var i,e,s;if(t&&(null===(i=t.filterGroups)||void 0===i?void 0:i.length)>0)return Object.assign(Object.assign({},t),{filterGroups:[...t.filterGroups],filterElements:this.stampFilterElements(null!==(e=t.filterElements)&&void 0!==e?e:[])});if(t&&(null===(s=t.filterElements)||void 0===s?void 0:s.length)>0){const i=1;return Object.assign(Object.assign({},t),{filterGroups:[{groupId:i,parentGroupId:null,logicalSearchOperator:t.logicalSearchOperator||n.AND}],filterElements:this.stampFilterElements(t.filterElements.map((t=>Object.assign(Object.assign({},t),{groupId:i}))))})}return Object.assign(Object.assign({},t),{logicalSearchOperator:n.AND,filterGroups:[{groupId:1,parentGroupId:null,logicalSearchOperator:n.AND}],filterElements:[]})}runUpdateCycle(t){const i=JSON.parse(JSON.stringify(this.currentFilterData));t(i),this.currentFilterData=i;const e=this.verifyFilterState(i);this.isFilterValid=e.isValid,this.errorMessages=e.errors,this.attentionErrors=i.filterElements.filter((t=>t._error&&t._touched)).map((t=>t._error)),this.searchChange.emit(i),this.validityChange.emit({isValid:this.isFilterValid,errors:this.errorMessages,attentionErrors:this.attentionErrors})}applyFilterDrop(t,i,e){const s=t.filterElements.find((t=>t._id===i.id));if(!s)return;const r=t.filterElements.indexOf(s);if(t.filterElements.splice(r,1),"filter"===e.targetType){const i=t.filterElements.find((t=>t._id===e.targetId));if(!i)return void t.filterElements.push(s);s.groupId=i.groupId;const r=t.filterElements.indexOf(i);t.filterElements.splice("before"===e.position?r:r+1,0,s)}else{const i=parseInt(e.targetId,10),r=t.filterGroups.find((t=>t.groupId===i));s.groupId="before"===e.position&&null!=(null==r?void 0:r.parentGroupId)?r.parentGroupId:i,t.filterElements.push(s)}}applyGroupDrop(t,i,e){const s=parseInt(i.id,10),r=t.filterGroups.find((t=>t.groupId===s));if(r)if("group"===e.targetType){const i=parseInt(e.targetId,10);if(this.isDescendant(i,s,t.filterGroups))return;if(s===i)return;const o=t.filterGroups.find((t=>t.groupId===i));if(!o)return;r.parentGroupId="before"===e.position?o.parentGroupId:i;const n=t.filterGroups.indexOf(r);t.filterGroups.splice(n,1);const a=t.filterGroups.indexOf(o);t.filterGroups.splice("before"===e.position?a:a+1,0,r)}else if("filter"===e.targetType){const i=t.filterElements.find((t=>t._id===e.targetId));i&&(r.parentGroupId=i.groupId)}}isDescendant(t,i,e){let s=e.find((i=>i.groupId===t));for(;s&&null!==s.parentGroupId;){if(s.parentGroupId===i)return!0;s=e.find((t=>t.groupId===s.parentGroupId))}return!1}renderFilterRows(){var t,i;const e=!0===this.config.collapsible,r=this.currentFilterData.filterGroups.find((t=>null===t.parentGroupId)),o=(null!==(i=null===(t=this.associations)||void 0===t?void 0:t.length)&&void 0!==i?i:0)>0;return s("div",{class:"anim-container",ref:t=>this.animContainerEl=t},s("div",{class:"content-wrapper"},(this.isExpanded||!e)&&r&&s("udp-advanced-search-filter-group",{key:r.groupId,groupId:r.groupId,filterData:this.currentFilterData,fields:this.fieldsArray,isRoot:!0,flat:!0===this.config.flat,operators:this.config.operators,freeFormFields:!0===this.config.freeFormFields,maxDepth:this.currentMaxDepth,showDepthSelector:!(o||!0===this.config.showFieldPicker&&"tree"===this.config.fieldPickerView),onAddFilter:t=>this.handleAddFilter(t.detail),onAddGroup:t=>this.handleAddGroup(t.detail),onRemoveFilter:t=>this.handleRemoveFilter(t.detail),onRemoveGroup:t=>this.handleRemoveGroup(t.detail),onFilterChange:this.handleFilterChange,onGroupChange:this.handleGroupChange,onDepthChange:this.handleDepthChange,openAddMenuForGroupId:this.openAddMenuForGroupId,onToggleAddMenu:this.handleToggleAddMenu})))}renderActions(){return[s("udp-fluent-button",{disabled:!this.isFilterValid,onClick:this.handleSearch,appearance:"primary"},"Search"),this.showClearButton&&s("udp-fluent-button",{appearance:"subtle",onClick:this.handleClear},"Clear"),!this.isFilterValid&&s("udp-text",{variant:"caption1",class:{"footer-status":!0,"is-attention":this.attentionErrors.length>0}},this.attentionErrors.length>1?this.attentionErrors.length+" filters need attention":1===this.attentionErrors.length?this.attentionErrors[0]:this.errorMessages.length>1?this.errorMessages.length+" filters to complete":"1 filter to complete")]}render(){var t,i;if(this.loading||this.extraFieldsLoading)return s(r,{class:{"is-loading":!0}},s("div",{class:"advanced-filter-loading"},s("udp-spinner",{size:"large"}),s("span",{class:"advanced-filter-loading-label"},"Loading filters…")));const e=!0===this.config.collapsible,o=!1!==this.config.resizable,n=!1!==this.config.showFooter,a=!0===this.config.showFieldPicker,l=a&&"tree"===this.config.fieldPickerView,d=(null!==(i=null===(t=this.associations)||void 0===t?void 0:t.length)&&void 0!==i?i:0)>0,h={"advanced-filter-container":!0,"is-expanded":this.isExpanded},u={};return this.isExpanded&&this.config.height&&(u.height=this.config.height),s(r,{style:u,class:{"is-resizable":o,"host-expanded":this.isExpanded,"host-collapsed":!this.isExpanded}},s("div",{class:h},e&&s("div",{class:"collapsed-view"},s("udp-fluent-text-input",{value:this.filterString,readonly:!0,appearance:"filled-darker",includeErrorPadding:!1,class:"string-display-input"}),s("udp-fluent-button",{class:"toggle-button",size:"small",appearance:"transparent",onClick:this.toggleExpanded},s("span",null,this.isExpanded?"Collapse":"Expand"),s("svg",{class:"toggle-icon",viewBox:"0 0 16 16",slot:"end"},s("path",{d:"M4 6L8 10L12 6",stroke:"currentColor","stroke-width":"2"})))),s("div",{class:{"filter-body":!0,"has-field-picker":a,"tree-picker":l}},!l||!this.isExpanded&&e?[this.renderFilterRows(),a&&(this.isExpanded||!e)&&s("udp-advanced-search-field-picker",{class:"field-picker",fields:this.fieldsArray,rootLabel:this.rootEntityLabel,onFieldPick:this.handleFieldPick})]:s("udp-sidebar-layout",{class:"picker-layout",sidebarPosition:"end",collapsible:!1,resizable:!0,fill:!0,sidebarWidth:"340px",minSidebarWidth:260,maxSidebarWidth:640},this.renderFilterRows(),s("udp-advanced-search-field-picker-tree",{slot:"sidebar",class:"field-picker",fields:this.fieldsArray,rootLabel:this.rootEntityLabel,depth:this.currentMaxDepth,showDepth:!d,onFieldPick:this.handleFieldPick,onDepthChange:this.handleDepthChange}))),n&&s("div",{class:"advanced-filter-footer"},this.renderActions())))}get el(){return this}static get watchers(){return{extraFields:[{reloadExtraFields:0}],entityName:[{reloadExtraFields:0},{rebuildFieldTree:0}],associations:[{reloadExtraFields:0},{syncAssociations:0}],catalogObjectList:[{reloadExtraFields:0},{rebuildFieldTree:0}],extraFieldGroups:[{rebuildFieldTree:0}],includeFields:[{rebuildFieldTree:0}],excludeFields:[{rebuildFieldTree:0}],virtualFields:[{rebuildFieldTree:0}],maxDepth:[{syncMaxDepth:0}],initialFilterData:[{syncInitialFilterData:0}]}}static get style(){return":host{display:flex;flex-direction:column;box-sizing:border-box;overflow:visible}.advanced-filter-loading{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;min-height:240px;width:100%}.advanced-filter-loading-label{color:var(--colorNeutralForeground3);font-size:var(--fontSizeBase300)}:host(.host-collapsed){resize:none;height:auto}:host(.host-expanded){overflow-y:auto}:host(.is-resizable.host-expanded){resize:vertical;min-height:180px;max-height:80vh;overflow:auto}.advanced-filter-container{display:flex;flex-direction:column;height:100%;width:100%;overflow:hidden}.collapsed-view{display:flex;align-items:center;gap:0.5rem;padding:var(--spacingVerticalS) var(--spacingHorizontalM);border-bottom:1px solid var(--colorNeutralStroke2)}.filter-body{display:flex;flex-direction:column;flex-grow:1;min-height:0;overflow:hidden}.anim-container{flex-grow:1;min-width:0;overflow-y:auto;overflow-x:auto;display:flex}.filter-body.has-field-picker{flex-direction:row;align-items:stretch;gap:var(--spacingHorizontalM)}.filter-body.has-field-picker .anim-container{flex:1 1 0;min-width:0;overflow-y:auto}.filter-body.has-field-picker .field-picker{flex:1 1 0;min-width:0}.filter-body.tree-picker{gap:0}.filter-body.tree-picker .picker-layout{flex:1 1 0;min-width:0;min-height:0}.filter-body.tree-picker .field-picker{height:100%}.filter-body.tree-picker .anim-container{background:var(--colorNeutralBackground2);padding:var(--spacingVerticalL) var(--spacingHorizontalL);min-height:100%;box-sizing:border-box}.content-wrapper{padding-bottom:15px;flex-grow:1}.advanced-filter-footer{display:flex;justify-content:flex-start;border-top:1px solid var(--colorNeutralStroke2);padding:var(--spacingVerticalS) var(--spacingHorizontalM);flex-shrink:0;gap:var(--spacingHorizontalS);align-items:center}.advanced-filter-footer .footer-status{color:var(--colorNeutralForeground3)}.advanced-filter-footer .footer-status.is-attention{color:var(--colorPaletteRedForeground1)}.string-display-input{width:100%}.search-button{opacity:0;transform:scale(0.95);pointer-events:none;margin-right:10px}.advanced-filter-container.is-expanded .anim-container{overflow-y:auto;min-height:130px}.advanced-filter-container.is-expanded .filter-body.has-field-picker .anim-container{min-height:0}.advanced-filter-container.is-expanded .collapsed-view{display:none}.advanced-filter-container.is-expanded .search-button{opacity:1;transform:scale(1);pointer-events:auto}.advanced-filter-container:not(.is-expanded) .anim-container{max-height:0;min-height:0;overflow:hidden}.advanced-filter-container:not(.is-expanded) .advanced-filter-footer{opacity:0;height:0;padding:0;border:none;pointer-events:none;overflow:hidden}.drag-overlay{position:fixed;pointer-events:none;z-index:10001;display:flex;align-items:center;gap:var(--spacingHorizontalS);background:var(--colorNeutralBackground1);border:1px solid var(--colorNeutralStroke2);border-radius:var(--borderRadiusMedium);box-shadow:var(--shadow16);padding:var(--spacingVerticalS) var(--spacingHorizontalM);max-width:260px;box-sizing:border-box}.drag-overlay-grip{flex-shrink:0;color:var(--colorNeutralForeground3);font-size:var(--fontSizeBase400);line-height:1;user-select:none}.drag-overlay-text{display:flex;flex-direction:column;min-width:0}.drag-overlay-label{font-size:var(--fontSizeBase300);line-height:var(--lineHeightBase300);font-weight:var(--fontWeightSemibold);color:var(--colorNeutralForeground1);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.drag-overlay-sub{font-size:var(--fontSizeBase200);line-height:var(--lineHeightBase200);color:var(--colorNeutralForeground3);white-space:nowrap}"}},[1,"udp-advanced-search-builder",{catalogObjectList:[16],entityName:[1,"entity-name"],initialFilterData:[16],config:[16],maxDepth:[2,"max-depth"],associations:[16],includeFields:[16],excludeFields:[16],virtualFields:[16],extraFields:[16],showClearButton:[4,"show-clear-button"],loading:[4],fieldsArray:[32],extraFieldGroups:[32],extraFieldsLoading:[32],openAddMenuForGroupId:[32],filterString:[32],isExpanded:[32],currentFilterData:[32],isFilterValid:[32],errorMessages:[32],attentionErrors:[32],currentMaxDepth:[32],addFilterElement:[64],submitSearch:[64],clearFilters:[64]},void 0,{extraFields:[{reloadExtraFields:0}],entityName:[{reloadExtraFields:0},{rebuildFieldTree:0}],associations:[{reloadExtraFields:0},{syncAssociations:0}],catalogObjectList:[{reloadExtraFields:0},{rebuildFieldTree:0}],extraFieldGroups:[{rebuildFieldTree:0}],includeFields:[{rebuildFieldTree:0}],excludeFields:[{rebuildFieldTree:0}],virtualFields:[{rebuildFieldTree:0}],maxDepth:[{syncMaxDepth:0}],initialFilterData:[{syncInitialFilterData:0}]}]),Z=X,tt=function(){"undefined"!=typeof customElements&&["udp-advanced-search-builder","udp-advanced-search-field-picker","udp-advanced-search-field-picker-tree","udp-advanced-search-filter-group","udp-autocomplete","udp-container-query","udp-container-query-grid","udp-date-input","udp-date-range-selector","udp-date-time-input","udp-flexbox","udp-fluent-avatar","udp-fluent-badge","udp-fluent-button","udp-fluent-card","udp-fluent-dropdown","udp-fluent-icon","udp-fluent-icon-button","udp-fluent-list-item","udp-fluent-text-input","udp-list","udp-popover","udp-search-input","udp-sidebar-layout","udp-spinner","udp-text","udp-time-input","udp-tooltip","udp-tree"].forEach((t=>{switch(t){case"udp-advanced-search-builder":customElements.get(o(t))||customElements.define(o(t),X);break;case"udp-advanced-search-field-picker":customElements.get(o(t))||p();break;case"udp-advanced-search-field-picker-tree":customElements.get(o(t))||f();break;case"udp-advanced-search-filter-group":customElements.get(o(t))||c();break;case"udp-autocomplete":customElements.get(o(t))||m();break;case"udp-container-query":customElements.get(o(t))||v();break;case"udp-container-query-grid":customElements.get(o(t))||g();break;case"udp-date-input":customElements.get(o(t))||b();break;case"udp-date-range-selector":customElements.get(o(t))||x();break;case"udp-date-time-input":customElements.get(o(t))||y();break;case"udp-flexbox":customElements.get(o(t))||F();break;case"udp-fluent-avatar":customElements.get(o(t))||k();break;case"udp-fluent-badge":customElements.get(o(t))||w();break;case"udp-fluent-button":customElements.get(o(t))||j();break;case"udp-fluent-card":customElements.get(o(t))||E();break;case"udp-fluent-dropdown":customElements.get(o(t))||D();break;case"udp-fluent-icon":customElements.get(o(t))||S();break;case"udp-fluent-icon-button":customElements.get(o(t))||O();break;case"udp-fluent-list-item":customElements.get(o(t))||I();break;case"udp-fluent-text-input":customElements.get(o(t))||z();break;case"udp-list":customElements.get(o(t))||A();break;case"udp-popover":customElements.get(o(t))||G();break;case"udp-search-input":customElements.get(o(t))||M();break;case"udp-sidebar-layout":customElements.get(o(t))||T();break;case"udp-spinner":customElements.get(o(t))||N();break;case"udp-text":customElements.get(o(t))||C();break;case"udp-time-input":customElements.get(o(t))||P();break;case"udp-tooltip":customElements.get(o(t))||L();break;case"udp-tree":customElements.get(o(t))||$()}}))};export{Z as UdpAdvancedSearchBuilder,tt as defineCustomElement}
|
|
2
|
+
import{p as t,H as i,c as e,h as s,d as r,t as o}from"./index2.js";import{L as n,a}from"./searchObject.js";import{g as l}from"./entityUtilities.js";import{h as d}from"./depthOptions.js";import{g as h,a as u,d as c}from"./filter-group.js";import{d as p}from"./field-picker.js";import{d as f}from"./field-picker-tree.js";import{d as m}from"./udp-autocomplete2.js";import{d as v}from"./udp-container-query2.js";import{d as g}from"./udp-container-query-grid2.js";import{d as b}from"./udp-date-input2.js";import{d as x}from"./udp-date-range-selector2.js";import{d as y}from"./udp-date-time-input2.js";import{d as F}from"./udp-flexbox2.js";import{d as k}from"./udp-fluent-avatar2.js";import{d as w}from"./udp-fluent-badge2.js";import{d as j}from"./udp-fluent-button2.js";import{d as E}from"./udp-fluent-card2.js";import{d as D}from"./udp-fluent-dropdown2.js";import{d as S}from"./udp-fluent-icon2.js";import{d as O}from"./udp-fluent-icon-button2.js";import{d as I}from"./udp-list-item2.js";import{d as z}from"./udp-fluent-text-input2.js";import{d as A}from"./udp-list2.js";import{d as G}from"./udp-popover2.js";import{d as M}from"./udp-search-input2.js";import{d as T}from"./udp-sidebar-layout2.js";import{d as N}from"./udp-spinner2.js";import{d as C}from"./udp-text2.js";import{d as P}from"./udp-time-input2.js";import{d as L}from"./udp-tooltip2.js";import{d as $}from"./udp-tree2.js";import{g as H,c as V,b as B,f as R}from"./catalogTree.js";import{e as _,g as q,c as W,f as U,j as J,E as Y}from"./extraFields.js";const K=t=>{if(!t||!t.filterGroups||0===t.filterGroups.length)return"";const i=e=>{const s=t.filterGroups.find((t=>t.groupId===e));if(!s)return"";const r=s.logicalSearchOperator===n.AND?"AND":"OR",o=[];return t.filterElements.filter((t=>t.groupId===e)).forEach((t=>{var i,e;const s="string"==typeof t.searchValue?`"${t.searchValue}"`:t.searchValue,r=d(null!==(e=null===(i=t.searchField)||void 0===i?void 0:i.split(".").pop())&&void 0!==e?e:"");o.push(`[${r}] ${h(t.searchOperator)} ${s}`)})),t.filterGroups.filter((t=>t.parentGroupId===e)).forEach((t=>{const e=i(t.groupId);e&&o.push(`(${e})`)})),o.join(` ${r} `)},e=t.filterGroups.find((t=>null===t.parentGroupId));return e?i(e.groupId):""};class Q{constructor(t,i){this.scrollContainer=null,this.isDragStarted=!1,this.pendingItem=null,this.pendingLabel="",this.pendingSublabel="",this.sourceRowEl=null,this.startX=0,this.startY=0,this.currentState={isDragging:!1,dragItem:null,insertionPoint:null},this.sourceOriginalStyle="",this.draggedItemHeight=0,this.ghostOriginalTop=0,this.placeholder=null,this.fixedOffsetX=0,this.fixedOffsetY=0,this.slotInsetLeft=0,this.slotInsetRight=0,this.overlay=null,this.dropTargets=[],this.previousGapEls=[],this.lockedTarget=null,this.lockedPosition="before",this.autoScrollRAF=null,this.hostEl=t,this.callbacks=i,this.boundPointerDown=this.onPointerDown.bind(this),this.boundPointerMove=this.onPointerMove.bind(this),this.boundPointerUp=this.onPointerUp.bind(this),this.boundKeyDown=this.onKeyDown.bind(this),this.boundScroll=this.onScroll.bind(this),this.hostEl.addEventListener("pointerdown",this.boundPointerDown,!0)}destroy(){this.hostEl.removeEventListener("pointerdown",this.boundPointerDown,!0),this.cleanup()}setScrollContainer(t){this.scrollContainer=t}onPointerDown(t){if(0!==t.button)return;const i=t.composedPath(),e=i.find((t=>t instanceof HTMLElement&&t.hasAttribute("data-drag-handle")));if(!e)return;t.preventDefault();const s=e.dataset.dragType,r=e.dataset.dragId;if(!s||!r)return;const o=i.find((t=>t instanceof HTMLElement&&("filter"===s?t.classList.contains("filter-row"):t.classList.contains("group-box")&&!t.classList.contains("root-group"))));this.pendingItem={type:s,id:r},this.pendingLabel=e.dataset.dragLabel||("filter"===s?"Filter":"Group"),this.pendingSublabel=e.dataset.dragSublabel||"",this.sourceRowEl=o||null,this.startX=t.clientX,this.startY=t.clientY,this.isDragStarted=!1,document.addEventListener("pointermove",this.boundPointerMove),document.addEventListener("pointerup",this.boundPointerUp),document.addEventListener("keydown",this.boundKeyDown)}onPointerMove(t){const i=t.clientX-this.startX,e=t.clientY-this.startY;if(!this.isDragStarted){if(Math.sqrt(i*i+e*e)<5)return;this.beginDrag()}this.moveOverlay(t.clientX,t.clientY),this.updateInsertionPoint(t.clientY),this.handleAutoScroll(t.clientY)}onPointerUp(){this.isDragStarted&&this.currentState.insertionPoint&&this.currentState.dragItem&&this.callbacks.onDrop(this.currentState.dragItem,this.currentState.insertionPoint),this.cleanup()}onKeyDown(t){"Escape"===t.key&&this.cleanup()}beginDrag(){var t,i;if(this.isDragStarted=!0,this.fixedOffsetX=0,this.fixedOffsetY=0,this.sourceRowEl){const e=this.sourceRowEl.getBoundingClientRect();if(this.draggedItemHeight=e.height,this.sourceOriginalStyle=this.sourceRowEl.style.cssText,this.slotInsetLeft=0,this.slotInsetRight=0,"filter"===(null===(t=this.pendingItem)||void 0===t?void 0:t.type)){const t=this.sourceRowEl.querySelector(".field-select"),i=this.sourceRowEl.querySelector(".actions");t&&(this.slotInsetLeft=t.getBoundingClientRect().left-e.left);const s=null==i?void 0:i.previousElementSibling;s&&(this.slotInsetRight=e.right-s.getBoundingClientRect().right)}this.placeholder=document.createElement("div"),this.placeholder.style.height=e.height+"px",this.placeholder.style.pointerEvents="none",null===(i=this.sourceRowEl.parentNode)||void 0===i||i.insertBefore(this.placeholder,this.sourceRowEl.nextSibling),this.sourceRowEl.style.position="fixed",this.sourceRowEl.style.top=e.top+"px",this.sourceRowEl.style.left=e.left+this.slotInsetLeft+"px",this.sourceRowEl.style.width=e.width-this.slotInsetLeft-this.slotInsetRight+"px",this.sourceRowEl.style.height=e.height+"px",this.sourceRowEl.style.zIndex="10000",this.sourceRowEl.style.pointerEvents="none",this.sourceRowEl.style.boxSizing="border-box",this.sourceRowEl.classList.add("drag-slot");const s=this.sourceRowEl.getBoundingClientRect();this.fixedOffsetX=s.left-(e.left+this.slotInsetLeft),this.fixedOffsetY=s.top-e.top,0===this.fixedOffsetX&&0===this.fixedOffsetY||(this.sourceRowEl.style.top=e.top-this.fixedOffsetY+"px",this.sourceRowEl.style.left=e.left+this.slotInsetLeft-this.fixedOffsetX+"px"),this.ghostOriginalTop=e.top-this.fixedOffsetY,this.sourceRowEl.style.transition="top 80ms ease-out, left 80ms ease-out, width 80ms ease-out"}this.collectDropTargets(),this.createOverlay(),this.scrollContainer&&this.scrollContainer.addEventListener("scroll",this.boundScroll,{passive:!0}),document.body.style.cursor="grabbing",document.body.style.userSelect="none",this.currentState={isDragging:!0,dragItem:this.pendingItem,insertionPoint:null},this.callbacks.onStateChange(Object.assign({},this.currentState))}cleanup(){this.placeholder&&(this.placeholder.remove(),this.placeholder=null),this.sourceRowEl&&(this.sourceRowEl.style.cssText=this.sourceOriginalStyle,this.sourceRowEl.classList.remove("drag-slot"),this.sourceRowEl=null),this.overlay&&(this.overlay.remove(),this.overlay=null),this.clearGap(),null!==this.autoScrollRAF&&(cancelAnimationFrame(this.autoScrollRAF),this.autoScrollRAF=null),this.scrollContainer&&this.scrollContainer.removeEventListener("scroll",this.boundScroll),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("pointermove",this.boundPointerMove),document.removeEventListener("pointerup",this.boundPointerUp),document.removeEventListener("keydown",this.boundKeyDown),this.pendingItem=null,this.pendingLabel="",this.pendingSublabel="",this.isDragStarted=!1,this.dropTargets=[],this.draggedItemHeight=0,this.ghostOriginalTop=0,this.sourceOriginalStyle="",this.lockedTarget=null;const t=this.currentState.isDragging;this.currentState={isDragging:!1,dragItem:null,insertionPoint:null},t&&this.callbacks.onStateChange(Object.assign({},this.currentState))}createOverlay(){var t;this.overlay=document.createElement("div"),this.overlay.className="drag-overlay";const i=document.createElement("span");i.className="drag-overlay-grip",i.textContent="⠿";const e=document.createElement("div");e.className="drag-overlay-text";const s=document.createElement("span");if(s.className="drag-overlay-label",s.textContent=this.pendingLabel,e.appendChild(s),this.pendingSublabel){const t=document.createElement("span");t.className="drag-overlay-sub",t.textContent=this.pendingSublabel,e.appendChild(t)}this.overlay.append(i,e),null===(t=this.hostEl.shadowRoot)||void 0===t||t.appendChild(this.overlay)}moveOverlay(t,i){this.overlay&&(this.overlay.style.left=t+12-this.fixedOffsetX+"px",this.overlay.style.top=i-20-this.fixedOffsetY+"px")}positionGhost(t,i){if(!this.sourceRowEl)return;const e=this.getGapElement(t,i).getBoundingClientRect();let s;s="before"===i?e.top-this.draggedItemHeight:e.bottom;const r=this.getGhostReferenceRect(t,i);this.sourceRowEl.style.top=s-this.fixedOffsetY+"px",this.sourceRowEl.style.left=r.left+this.slotInsetLeft-this.fixedOffsetX+"px",this.sourceRowEl.style.width=r.width-this.slotInsetLeft-this.slotInsetRight+"px"}getGhostReferenceRect(t,i){if("group"===t.type&&"after"===i){const i=t.element.nextElementSibling;if(i){const t=Array.from(i.querySelectorAll(".filter-row, udp-advanced-search-filter-group"));for(const i of t)if(i!==this.sourceRowEl)return i.getBoundingClientRect();const e=i.querySelector(".add-new-container");if(e)return e.getBoundingClientRect()}}return t.element.getBoundingClientRect()}resetGhostPosition(){this.sourceRowEl&&(this.sourceRowEl.style.top=this.ghostOriginalTop+"px")}getGapElement(t,i){if("filter"===t.type)return t.element;if("after"===i)return t.element;const e=t.element.getRootNode();return e instanceof ShadowRoot&&e.host?e.host:t.element}applyGap(t,i){this.placeholder&&(this.placeholder.style.height="0px");const e=this.getGapElement(t,i);for(const t of this.previousGapEls)t!==e&&(t.style.marginTop="",t.style.marginBottom="");e.style.marginTop="",e.style.marginBottom="","before"===i?e.style.marginTop=this.draggedItemHeight+"px":e.style.marginBottom=this.draggedItemHeight+"px",this.previousGapEls=[e]}clearGap(){for(const t of this.previousGapEls)t.style.marginTop="",t.style.marginBottom="";this.previousGapEls=[],this.placeholder&&(this.placeholder.style.height=this.draggedItemHeight+"px")}collectDropTargets(){var t;this.dropTargets=[];const i=this.pendingItem,e=t=>{const s=t.shadowRoot;if(!s)return;s.querySelectorAll(".filter-row[data-filter-id]").forEach((t=>{const e=t.dataset.filterId;"filter"===(null==i?void 0:i.type)&&i.id===e||this.dropTargets.push({type:"filter",id:e,element:t,rect:t.getBoundingClientRect(),midY:0})}));const r=s.querySelector(".group-box[data-group-id]");if(r&&!r.classList.contains("root-group")){const t=r.dataset.groupId;if("group"!==(null==i?void 0:i.type)||i.id!==t){const i=r.querySelector(":scope > .group-header");i&&this.dropTargets.push({type:"group",id:t,element:i,rect:i.getBoundingClientRect(),midY:0})}}s.querySelectorAll("udp-advanced-search-filter-group").forEach((t=>e(t)))},s=null===(t=this.hostEl.shadowRoot)||void 0===t?void 0:t.querySelector("udp-advanced-search-filter-group");s&&e(s);for(const t of this.dropTargets)t.midY=t.rect.top+t.rect.height/2;this.dropTargets.sort(((t,i)=>t.rect.top-i.rect.top))}updateInsertionPoint(t){var i,e;if(0===this.dropTargets.length)return this.clearGap(),this.resetGhostPosition(),this.lockedTarget=null,void this.commitInsertionPoint(null);let s=null,r="before";for(const i of this.dropTargets){const e=i.element.getBoundingClientRect();if(t>=e.top&&t<=e.bottom){s=i,r=t<e.top+e.height/2?"before":"after";break}}if(!s){const o=null===(i=this.dropTargets[0])||void 0===i?void 0:i.element,n=null===(e=this.dropTargets[this.dropTargets.length-1])||void 0===e?void 0:e.element;if(o&&t<o.getBoundingClientRect().top)s=this.dropTargets[0],r="before";else{if(!(n&&t>n.getBoundingClientRect().bottom))return;s=this.dropTargets[this.dropTargets.length-1],r="after"}}if("before"===r){const t=this.dropTargets.indexOf(s);t>0&&(s=this.dropTargets[t-1],r="after")}if(s===this.lockedTarget&&r===this.lockedPosition)return;const o=this.currentState.dragItem||this.pendingItem;if(this.callbacks.isValidDrop&&o&&!this.callbacks.isValidDrop(o,s.type,s.id))return this.clearGap(),this.resetGhostPosition(),this.lockedTarget=null,void this.commitInsertionPoint(null);this.lockedTarget=s,this.lockedPosition=r,this.applyGap(s,r),this.positionGhost(s,r),this.commitInsertionPoint({position:r,targetId:s.id,targetType:s.type})}commitInsertionPoint(t){const i=this.currentState.insertionPoint;(null==i?void 0:i.position)===(null==t?void 0:t.position)&&(null==i?void 0:i.targetId)===(null==t?void 0:t.targetId)&&(null==i?void 0:i.targetType)===(null==t?void 0:t.targetType)||(this.currentState=Object.assign(Object.assign({},this.currentState),{insertionPoint:t}),this.callbacks.onStateChange(Object.assign({},this.currentState)))}handleAutoScroll(t){if(!this.scrollContainer)return;const i=this.scrollContainer.getBoundingClientRect(),e=t-i.top,s=i.bottom-t;let r=0;if(e>0&&e<50?r=-10*(1-e/50):s>0&&s<50&&(r=10*(1-s/50)),null!==this.autoScrollRAF&&(cancelAnimationFrame(this.autoScrollRAF),this.autoScrollRAF=null),0!==r){const t=()=>{this.scrollContainer&&(this.scrollContainer.scrollTop+=r,this.refreshDropTargetRects(),this.autoScrollRAF=requestAnimationFrame(t))};this.autoScrollRAF=requestAnimationFrame(t)}}onScroll(){this.refreshDropTargetRects()}refreshDropTargetRects(){for(const t of this.dropTargets)t.rect=t.element.getBoundingClientRect(),t.midY=t.rect.top+t.rect.height/2}}const X=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.filterSave=e(this,"filterSave",7),this.searchChange=e(this,"searchChange",7),this.validityChange=e(this,"validityChange",7),this.config={},this.maxDepth=2,this.showClearButton=!1,this.loading=!1,this.fieldsArray=[],this.extraFieldGroups=[],this.extraFieldsLoading=!1,this.extraFieldsRequestId=0,this.openAddMenuForGroupId=null,this.filterString="",this.isExpanded=!0,this.isFilterValid=!0,this.errorMessages=[],this.attentionErrors=[],this.rootEntityLabel="",this.nextGroupId=1,this.handleFieldPick=t=>{this.addFilterForPath(t.detail.path,t.detail.type)},this.handleSearch=()=>{this.isFilterValid&&this.filterSave?(this.filterSave.emit(this.currentFilterData),this.filterString=K(this.currentFilterData),this.config.collapsible&&this.toggleExpanded()):console.warn("Cannot run search: filter is invalid.")},this.handleClear=()=>{const t=this.getNormalizedData(Object.assign(Object.assign({},this.currentFilterData),{filterElements:[],filterGroups:[]}));this.currentFilterData=t,this.isFilterValid=!0,this.errorMessages=[],this.attentionErrors=[],this.searchChange.emit(t),this.validityChange.emit({isValid:!0,errors:[],attentionErrors:[]}),this.filterSave&&(this.filterSave.emit(t),this.filterString=K(t)),this.config.collapsible&&this.toggleExpanded()},this.toggleExpanded=()=>{this.isExpanded=!this.isExpanded,this.updateHostClasses()},this.handleToggleAddMenu=t=>{const i=t.detail;if(this.openAddMenuForGroupId=this.openAddMenuForGroupId===i?null:i,null!==this.openAddMenuForGroupId){const t=this.animContainerEl;t&&requestAnimationFrame((()=>{t.scrollTop=t.scrollHeight}))}},this.handleDragStateChange=()=>{},this.isValidDragDrop=(t,i,e)=>{if("group"===t.type&&"group"===i){const i=parseInt(t.id,10),s=parseInt(e,10);if(i===s)return!1;if(this.isDescendant(s,i,this.currentFilterData.filterGroups))return!1}if("group"===t.type&&"filter"===i){const i=parseInt(t.id,10),s=this.currentFilterData.filterElements.find((t=>t._id===e));if(s){const t=s.groupId;if(t===i||this.isDescendant(t,i,this.currentFilterData.filterGroups))return!1}}return!0},this.handleDragDrop=(t,i)=>{this.runUpdateCycle((e=>{"filter"===t.type?this.applyFilterDrop(e,t,i):"group"===t.type&&this.applyGroupDrop(e,t,i)}))},this.handleAddFilter=t=>{this.runUpdateCycle((i=>{var e,s;const r=null===(e=this.fieldsArray)||void 0===e?void 0:e[0],o=u(r,this.config.operators),n=(null===(s=null==o?void 0:o[0])||void 0===s?void 0:s.value)||"";i.filterElements.push({_id:"filter_"+Math.random(),_type:null==r?void 0:r.type,groupId:t,searchField:null==r?void 0:r.name,searchOperator:n,searchValue:""})})),this.openAddMenuForGroupId=null},this.handleAddGroup=t=>{this.runUpdateCycle((i=>{i.filterGroups.push({groupId:this.nextGroupId++,parentGroupId:t,logicalSearchOperator:n.AND})})),this.openAddMenuForGroupId=null},this.handleRemoveFilter=t=>{this.runUpdateCycle((i=>{const e=i.filterElements.findIndex((i=>i._id===t));e>-1&&i.filterElements.splice(e,1)}))},this.handleRemoveGroup=t=>{this.runUpdateCycle((i=>{const e=t=>{const s=i.filterGroups.filter((i=>i.parentGroupId===t));let r=s.map((t=>t.groupId));return s.forEach((t=>{r=[...r,...e(t.groupId)]})),r},s=[t,...e(t)];i.filterGroups=i.filterGroups.filter((t=>!s.includes(t.groupId))),i.filterElements=i.filterElements.filter((t=>!s.includes(t.groupId)))}))},this.handleFilterChange=t=>{const{filterId:i,field:e,value:s,updates:r}=t.detail;this.runUpdateCycle((t=>{const o=t.filterElements.find((t=>t._id===i));o&&(r?Object.assign(o,r):(o[e]=s,"searchValue"===e&&(o._touched=!0)))}))},this.handleDepthChange=t=>{const i=t.detail;"number"==typeof i&&i!==this.currentMaxDepth&&(this.currentMaxDepth=i,this.buildFieldTree())},this.handleGroupChange=t=>{const{groupId:i,logicalSearchOperator:e}=t.detail;this.runUpdateCycle((t=>{const s=t.filterGroups.find((t=>t.groupId===i));s&&(s.logicalSearchOperator=e)}))}}buildFieldTree(){var t;if(this.entityName&&this.catalogObjectList){const i=l(this.entityName),e=i[0].toUpperCase()+i.slice(1);this.rootEntityLabel=e,this.fieldsArray=H(V(B(this.catalogObjectList,e,this.currentMaxDepth,this.associations),this.includeFields,this.excludeFields),[...this.extraFieldGroups,...null!==(t=this.virtualFields)&&void 0!==t?t:[]])}}async loadExtraFields(){var t,i,e,s,r;const o=++this.extraFieldsRequestId,n=null!==(i=null===(t=this.extraFields)||void 0===t?void 0:t.domainName)&&void 0!==i?i:this.entityName;if(!this.extraFields||!n)return this.extraFieldGroups.length&&(this.extraFieldGroups=[]),void(this.extraFieldsLoading=!1);const a=null!==(e=this.extraFields.prefix)&&void 0!==e?e:Y;this.buildFieldTree();const l=[{path:"",domainName:n,definitions:this.extraFields.definitions,context:_(this.extraFields)}];for(const t of null!==(s=this.associations)&&void 0!==s?s:[]){const i=this.resolveAssociationPath(t),e=null!==(r=null==i?void 0:i.node.displayName)&&void 0!==r?r:null==i?void 0:i.node.name;i&&e&&l.push({path:i.path,domainName:e})}this.extraFieldsLoading=!0;try{const t=await Promise.all(l.map((async t=>{try{const i=t.context?await q(t.domainName,t.context):t.definitions?W(t.definitions):await U(t.domainName);return J(i,a,t.path)}catch(i){return console.error(`Failed to load extra-field definitions for ${t.domainName}:`,i),null}})));if(o!==this.extraFieldsRequestId)return;this.extraFieldGroups=t.filter((t=>null!==t))}finally{o===this.extraFieldsRequestId&&(this.extraFieldsLoading=!1)}}resolveAssociationPath(t){var i,e;let s=this.fieldsArray,r=null;const o=[];for(const n of t.split(".")){if(r=null!==(i=s.find((t=>t.name.toLowerCase()===n.toLowerCase())))&&void 0!==i?i:null,!r)return null;o.push(r.name),s=null!==(e=r.childFields)&&void 0!==e?e:[]}return r?{node:r,path:o.join(".")}:null}reloadExtraFields(){this.loadExtraFields()}rebuildFieldTree(){this.buildFieldTree(),this.currentFilterData&&(this.currentFilterData=this.getNormalizedData(this.currentFilterData))}syncMaxDepth(t){this.currentMaxDepth=t,this.buildFieldTree()}syncAssociations(){this.buildFieldTree()}syncInitialFilterData(t){this.currentFilterData=this.getNormalizedData(t),this.updateNextGroupId(this.currentFilterData)}componentWillLoad(){this.currentMaxDepth=this.maxDepth,this.buildFieldTree(),this.currentFilterData=this.getNormalizedData(this.initialFilterData),this.updateNextGroupId(this.currentFilterData),this.loadExtraFields()}componentDidLoad(){this.updateHostClasses(),this.dragManager=new Q(this.el,{onStateChange:this.handleDragStateChange,onDrop:this.handleDragDrop,isValidDrop:this.isValidDragDrop}),this.animContainerEl&&this.dragManager.setScrollContainer(this.animContainerEl)}disconnectedCallback(){var t;null===(t=this.dragManager)||void 0===t||t.destroy()}async addFilterElement(t,i){this.addFilterForPath(t,i)}async submitSearch(){this.handleSearch()}async clearFilters(){this.handleClear()}addFilterForPath(t,i){var e,s,r;const o=new Set(["object","array"]),n=R(this.fieldsArray,t),a=null!==(s=null!==(e=null==n?void 0:n.type)&&void 0!==e?e:null==i?void 0:i.toLowerCase())&&void 0!==s?s:"string";if(o.has(a))return;const l=u(null!=n?n:{type:a},this.config.operators),d=(null===(r=null==l?void 0:l[0])||void 0===r?void 0:r.value)||"=",h=this.currentFilterData.filterGroups.find((t=>null===t.parentGroupId));this.runUpdateCycle((i=>{var e;i.filterElements.push({_id:"filter_"+Math.random(),_type:a,groupId:null!==(e=null==h?void 0:h.groupId)&&void 0!==e?e:1,searchField:t,searchOperator:d,searchValue:"boolean"===a?"true":""})}))}updateHostClasses(){this.isExpanded?(this.el.classList.add("host-expanded"),this.el.classList.remove("host-collapsed")):(this.el.classList.add("host-collapsed"),this.el.classList.remove("host-expanded"),this.el.style.height=null)}updateNextGroupId(t){this.nextGroupId=t&&t.filterGroups.length>0?Math.max(...t.filterGroups.map((t=>t.groupId)))+1:2}verifyFilterState(t){const i=[],e=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;for(const e of t.filterGroups){if(null===e.parentGroupId)continue;const s=t.filterElements.some((t=>t.groupId===e.groupId)),r=t.filterGroups.some((t=>t.parentGroupId===e.groupId));s||r||i.push("A group has no filters. Add a filter or remove the group.")}return t.filterElements.forEach((t=>{var s,r;delete t._error;const o=null==t.searchField||""===t.searchField,n=!t.searchValue,l=t.searchOperator===a.NULL||t.searchOperator===a.NOT_NULL,h=d(null!==(r=null===(s=t.searchField)||void 0===s?void 0:s.split(".").pop())&&void 0!==r?r:"");if(o){const e="A filter is missing its field.";t._error=e,i.push(e)}else if(t.searchOperator===a.BETWEEN){const e=(t.searchValue||"").split(",");if(2!==e.length||!e[0]||!e[1]){const e=`"${h}" needs two values (from and to).`;t._error=e,i.push(e)}}else if(n&&!l){const e=`"${h}" needs a value.`;t._error=e,i.push(e)}else if("guid"===t._type&&!n&&!e.test(t.searchValue)){const e=`"${h}" needs a valid GUID.`;t._error=e,i.push(e)}})),{isValid:0===i.length,errors:i}}stampFilterElements(t){const i=new Set(t.map((t=>t._id)).filter(Boolean));return t.map(((t,e)=>{var s;const r=Object.assign({},t);if(!r._id){const t=`filter_ext_${null!==(s=r.groupId)&&void 0!==s?s:"root"}_${e}`;let o=t,n=1;for(;i.has(o);)o=`${t}_${n++}`;i.add(o),r._id=o}if(!r._type){const t=R(this.fieldsArray,r.searchField);(null==t?void 0:t.type)&&(r._type=t.type)}return r}))}getNormalizedData(t){var i,e,s;if(t&&(null===(i=t.filterGroups)||void 0===i?void 0:i.length)>0)return Object.assign(Object.assign({},t),{filterGroups:[...t.filterGroups],filterElements:this.stampFilterElements(null!==(e=t.filterElements)&&void 0!==e?e:[])});if(t&&(null===(s=t.filterElements)||void 0===s?void 0:s.length)>0){const i=1;return Object.assign(Object.assign({},t),{filterGroups:[{groupId:i,parentGroupId:null,logicalSearchOperator:t.logicalSearchOperator||n.AND}],filterElements:this.stampFilterElements(t.filterElements.map((t=>Object.assign(Object.assign({},t),{groupId:i}))))})}return Object.assign(Object.assign({},t),{logicalSearchOperator:n.AND,filterGroups:[{groupId:1,parentGroupId:null,logicalSearchOperator:n.AND}],filterElements:[]})}runUpdateCycle(t){const i=JSON.parse(JSON.stringify(this.currentFilterData));t(i),this.currentFilterData=i;const e=this.verifyFilterState(i);this.isFilterValid=e.isValid,this.errorMessages=e.errors,this.attentionErrors=i.filterElements.filter((t=>t._error&&t._touched)).map((t=>t._error)),this.searchChange.emit(i),this.validityChange.emit({isValid:this.isFilterValid,errors:this.errorMessages,attentionErrors:this.attentionErrors})}applyFilterDrop(t,i,e){const s=t.filterElements.find((t=>t._id===i.id));if(!s)return;const r=t.filterElements.indexOf(s);if(t.filterElements.splice(r,1),"filter"===e.targetType){const i=t.filterElements.find((t=>t._id===e.targetId));if(!i)return void t.filterElements.push(s);s.groupId=i.groupId;const r=t.filterElements.indexOf(i);t.filterElements.splice("before"===e.position?r:r+1,0,s)}else{const i=parseInt(e.targetId,10),r=t.filterGroups.find((t=>t.groupId===i));s.groupId="before"===e.position&&null!=(null==r?void 0:r.parentGroupId)?r.parentGroupId:i,t.filterElements.push(s)}}applyGroupDrop(t,i,e){const s=parseInt(i.id,10),r=t.filterGroups.find((t=>t.groupId===s));if(r)if("group"===e.targetType){const i=parseInt(e.targetId,10);if(this.isDescendant(i,s,t.filterGroups))return;if(s===i)return;const o=t.filterGroups.find((t=>t.groupId===i));if(!o)return;r.parentGroupId="before"===e.position?o.parentGroupId:i;const n=t.filterGroups.indexOf(r);t.filterGroups.splice(n,1);const a=t.filterGroups.indexOf(o);t.filterGroups.splice("before"===e.position?a:a+1,0,r)}else if("filter"===e.targetType){const i=t.filterElements.find((t=>t._id===e.targetId));i&&(r.parentGroupId=i.groupId)}}isDescendant(t,i,e){let s=e.find((i=>i.groupId===t));for(;s&&null!==s.parentGroupId;){if(s.parentGroupId===i)return!0;s=e.find((t=>t.groupId===s.parentGroupId))}return!1}get depthFixed(){var t,i;return(null!==(i=null===(t=this.associations)||void 0===t?void 0:t.length)&&void 0!==i?i:0)>0||this.maxDepth<1}renderFilterRows(){const t=!0===this.config.collapsible,i=this.currentFilterData.filterGroups.find((t=>null===t.parentGroupId));return s("div",{class:"anim-container",ref:t=>this.animContainerEl=t},s("div",{class:"content-wrapper"},(this.isExpanded||!t)&&i&&s("udp-advanced-search-filter-group",{key:i.groupId,groupId:i.groupId,filterData:this.currentFilterData,fields:this.fieldsArray,isRoot:!0,flat:!0===this.config.flat,operators:this.config.operators,freeFormFields:!0===this.config.freeFormFields,maxDepth:this.currentMaxDepth,showDepthSelector:!(this.depthFixed||!0===this.config.showFieldPicker&&"tree"===this.config.fieldPickerView),onAddFilter:t=>this.handleAddFilter(t.detail),onAddGroup:t=>this.handleAddGroup(t.detail),onRemoveFilter:t=>this.handleRemoveFilter(t.detail),onRemoveGroup:t=>this.handleRemoveGroup(t.detail),onFilterChange:this.handleFilterChange,onGroupChange:this.handleGroupChange,onDepthChange:this.handleDepthChange,openAddMenuForGroupId:this.openAddMenuForGroupId,onToggleAddMenu:this.handleToggleAddMenu})))}renderActions(){return[s("udp-fluent-button",{disabled:!this.isFilterValid,onClick:this.handleSearch,appearance:"primary"},"Search"),this.showClearButton&&s("udp-fluent-button",{appearance:"subtle",onClick:this.handleClear},"Clear"),!this.isFilterValid&&s("udp-text",{variant:"caption1",class:{"footer-status":!0,"is-attention":this.attentionErrors.length>0}},this.attentionErrors.length>1?this.attentionErrors.length+" filters need attention":1===this.attentionErrors.length?this.attentionErrors[0]:this.errorMessages.length>1?this.errorMessages.length+" filters to complete":"1 filter to complete")]}render(){if(this.loading||this.extraFieldsLoading)return s(r,{class:{"is-loading":!0}},s("div",{class:"advanced-filter-loading"},s("udp-spinner",{size:"large"}),s("span",{class:"advanced-filter-loading-label"},"Loading filters…")));const t=!0===this.config.collapsible,i=!1!==this.config.resizable,e=!1!==this.config.showFooter,o=!0===this.config.showFieldPicker,n=o&&"tree"===this.config.fieldPickerView,a={"advanced-filter-container":!0,"is-expanded":this.isExpanded},l={};return this.isExpanded&&this.config.height&&(l.height=this.config.height),s(r,{style:l,class:{"is-resizable":i,"host-expanded":this.isExpanded,"host-collapsed":!this.isExpanded}},s("div",{class:a},t&&s("div",{class:"collapsed-view"},s("udp-fluent-text-input",{value:this.filterString,readonly:!0,appearance:"filled-darker",includeErrorPadding:!1,class:"string-display-input"}),s("udp-fluent-button",{class:"toggle-button",size:"small",appearance:"transparent",onClick:this.toggleExpanded},s("span",null,this.isExpanded?"Collapse":"Expand"),s("svg",{class:"toggle-icon",viewBox:"0 0 16 16",slot:"end"},s("path",{d:"M4 6L8 10L12 6",stroke:"currentColor","stroke-width":"2"})))),s("div",{class:{"filter-body":!0,"has-field-picker":o,"tree-picker":n}},!n||!this.isExpanded&&t?[this.renderFilterRows(),o&&(this.isExpanded||!t)&&s("udp-advanced-search-field-picker",{class:"field-picker",fields:this.fieldsArray,rootLabel:this.rootEntityLabel,onFieldPick:this.handleFieldPick})]:s("udp-sidebar-layout",{class:"picker-layout",sidebarPosition:"end",collapsible:!1,resizable:!0,fill:!0,sidebarWidth:"340px",minSidebarWidth:260,maxSidebarWidth:640},this.renderFilterRows(),s("udp-advanced-search-field-picker-tree",{slot:"sidebar",class:"field-picker",fields:this.fieldsArray,rootLabel:this.rootEntityLabel,depth:this.currentMaxDepth,showDepth:!this.depthFixed,onFieldPick:this.handleFieldPick,onDepthChange:this.handleDepthChange}))),e&&s("div",{class:"advanced-filter-footer"},this.renderActions())))}get el(){return this}static get watchers(){return{extraFields:[{reloadExtraFields:0}],entityName:[{reloadExtraFields:0},{rebuildFieldTree:0}],associations:[{reloadExtraFields:0},{syncAssociations:0}],catalogObjectList:[{reloadExtraFields:0},{rebuildFieldTree:0}],extraFieldGroups:[{rebuildFieldTree:0}],includeFields:[{rebuildFieldTree:0}],excludeFields:[{rebuildFieldTree:0}],virtualFields:[{rebuildFieldTree:0}],maxDepth:[{syncMaxDepth:0}],initialFilterData:[{syncInitialFilterData:0}]}}static get style(){return":host{display:flex;flex-direction:column;box-sizing:border-box;overflow:visible}.advanced-filter-loading{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;min-height:240px;width:100%}.advanced-filter-loading-label{color:var(--colorNeutralForeground3);font-size:var(--fontSizeBase300)}:host(.host-collapsed){resize:none;height:auto}:host(.host-expanded){overflow-y:auto}:host(.is-resizable.host-expanded){resize:vertical;min-height:180px;max-height:80vh;overflow:auto}.advanced-filter-container{display:flex;flex-direction:column;height:100%;width:100%;overflow:hidden}.collapsed-view{display:flex;align-items:center;gap:0.5rem;padding:var(--spacingVerticalS) var(--spacingHorizontalM);border-bottom:1px solid var(--colorNeutralStroke2)}.filter-body{display:flex;flex-direction:column;flex-grow:1;min-height:0;overflow:hidden}.anim-container{flex-grow:1;min-width:0;overflow-y:auto;overflow-x:auto;display:flex}.filter-body.has-field-picker{flex-direction:row;align-items:stretch;gap:var(--spacingHorizontalM)}.filter-body.has-field-picker .anim-container{flex:1 1 0;min-width:0;overflow-y:auto}.filter-body.has-field-picker .field-picker{flex:1 1 0;min-width:0}.filter-body.tree-picker{gap:0}.filter-body.tree-picker .picker-layout{flex:1 1 0;min-width:0;min-height:0}.filter-body.tree-picker .field-picker{height:100%}.filter-body.tree-picker .anim-container{background:var(--colorNeutralBackground2);padding:var(--spacingVerticalL) var(--spacingHorizontalL);min-height:100%;box-sizing:border-box}.content-wrapper{padding-bottom:15px;flex-grow:1}.advanced-filter-footer{display:flex;justify-content:flex-start;border-top:1px solid var(--colorNeutralStroke2);padding:var(--spacingVerticalS) var(--spacingHorizontalM);flex-shrink:0;gap:var(--spacingHorizontalS);align-items:center}.advanced-filter-footer .footer-status{color:var(--colorNeutralForeground3)}.advanced-filter-footer .footer-status.is-attention{color:var(--colorPaletteRedForeground1)}.string-display-input{width:100%}.search-button{opacity:0;transform:scale(0.95);pointer-events:none;margin-right:10px}.advanced-filter-container.is-expanded .anim-container{overflow-y:auto;min-height:130px}.advanced-filter-container.is-expanded .filter-body.has-field-picker .anim-container{min-height:0}.advanced-filter-container.is-expanded .collapsed-view{display:none}.advanced-filter-container.is-expanded .search-button{opacity:1;transform:scale(1);pointer-events:auto}.advanced-filter-container:not(.is-expanded) .anim-container{max-height:0;min-height:0;overflow:hidden}.advanced-filter-container:not(.is-expanded) .advanced-filter-footer{opacity:0;height:0;padding:0;border:none;pointer-events:none;overflow:hidden}.drag-overlay{position:fixed;pointer-events:none;z-index:10001;display:flex;align-items:center;gap:var(--spacingHorizontalS);background:var(--colorNeutralBackground1);border:1px solid var(--colorNeutralStroke2);border-radius:var(--borderRadiusMedium);box-shadow:var(--shadow16);padding:var(--spacingVerticalS) var(--spacingHorizontalM);max-width:260px;box-sizing:border-box}.drag-overlay-grip{flex-shrink:0;color:var(--colorNeutralForeground3);font-size:var(--fontSizeBase400);line-height:1;user-select:none}.drag-overlay-text{display:flex;flex-direction:column;min-width:0}.drag-overlay-label{font-size:var(--fontSizeBase300);line-height:var(--lineHeightBase300);font-weight:var(--fontWeightSemibold);color:var(--colorNeutralForeground1);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.drag-overlay-sub{font-size:var(--fontSizeBase200);line-height:var(--lineHeightBase200);color:var(--colorNeutralForeground3);white-space:nowrap}"}},[1,"udp-advanced-search-builder",{catalogObjectList:[16],entityName:[1,"entity-name"],initialFilterData:[16],config:[16],maxDepth:[2,"max-depth"],associations:[16],includeFields:[16],excludeFields:[16],virtualFields:[16],extraFields:[16],showClearButton:[4,"show-clear-button"],loading:[4],fieldsArray:[32],extraFieldGroups:[32],extraFieldsLoading:[32],openAddMenuForGroupId:[32],filterString:[32],isExpanded:[32],currentFilterData:[32],isFilterValid:[32],errorMessages:[32],attentionErrors:[32],currentMaxDepth:[32],addFilterElement:[64],submitSearch:[64],clearFilters:[64]},void 0,{extraFields:[{reloadExtraFields:0}],entityName:[{reloadExtraFields:0},{rebuildFieldTree:0}],associations:[{reloadExtraFields:0},{syncAssociations:0}],catalogObjectList:[{reloadExtraFields:0},{rebuildFieldTree:0}],extraFieldGroups:[{rebuildFieldTree:0}],includeFields:[{rebuildFieldTree:0}],excludeFields:[{rebuildFieldTree:0}],virtualFields:[{rebuildFieldTree:0}],maxDepth:[{syncMaxDepth:0}],initialFilterData:[{syncInitialFilterData:0}]}]),Z=X,tt=function(){"undefined"!=typeof customElements&&["udp-advanced-search-builder","udp-advanced-search-field-picker","udp-advanced-search-field-picker-tree","udp-advanced-search-filter-group","udp-autocomplete","udp-container-query","udp-container-query-grid","udp-date-input","udp-date-range-selector","udp-date-time-input","udp-flexbox","udp-fluent-avatar","udp-fluent-badge","udp-fluent-button","udp-fluent-card","udp-fluent-dropdown","udp-fluent-icon","udp-fluent-icon-button","udp-fluent-list-item","udp-fluent-text-input","udp-list","udp-popover","udp-search-input","udp-sidebar-layout","udp-spinner","udp-text","udp-time-input","udp-tooltip","udp-tree"].forEach((t=>{switch(t){case"udp-advanced-search-builder":customElements.get(o(t))||customElements.define(o(t),X);break;case"udp-advanced-search-field-picker":customElements.get(o(t))||p();break;case"udp-advanced-search-field-picker-tree":customElements.get(o(t))||f();break;case"udp-advanced-search-filter-group":customElements.get(o(t))||c();break;case"udp-autocomplete":customElements.get(o(t))||m();break;case"udp-container-query":customElements.get(o(t))||v();break;case"udp-container-query-grid":customElements.get(o(t))||g();break;case"udp-date-input":customElements.get(o(t))||b();break;case"udp-date-range-selector":customElements.get(o(t))||x();break;case"udp-date-time-input":customElements.get(o(t))||y();break;case"udp-flexbox":customElements.get(o(t))||F();break;case"udp-fluent-avatar":customElements.get(o(t))||k();break;case"udp-fluent-badge":customElements.get(o(t))||w();break;case"udp-fluent-button":customElements.get(o(t))||j();break;case"udp-fluent-card":customElements.get(o(t))||E();break;case"udp-fluent-dropdown":customElements.get(o(t))||D();break;case"udp-fluent-icon":customElements.get(o(t))||S();break;case"udp-fluent-icon-button":customElements.get(o(t))||O();break;case"udp-fluent-list-item":customElements.get(o(t))||I();break;case"udp-fluent-text-input":customElements.get(o(t))||z();break;case"udp-list":customElements.get(o(t))||A();break;case"udp-popover":customElements.get(o(t))||G();break;case"udp-search-input":customElements.get(o(t))||M();break;case"udp-sidebar-layout":customElements.get(o(t))||T();break;case"udp-spinner":customElements.get(o(t))||N();break;case"udp-text":customElements.get(o(t))||C();break;case"udp-time-input":customElements.get(o(t))||P();break;case"udp-tooltip":customElements.get(o(t))||L();break;case"udp-tree":customElements.get(o(t))||$()}}))};export{Z as UdpAdvancedSearchBuilder,tt as defineCustomElement}
|
package/dist/docs.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2026-11-
|
|
2
|
+
"timestamp": "2026-11-24T17:23:03",
|
|
3
3
|
"compiler": {
|
|
4
4
|
"name": "@stencil/core",
|
|
5
5
|
"version": "4.41.3",
|
|
@@ -29451,7 +29451,7 @@
|
|
|
29451
29451
|
"mutable": false,
|
|
29452
29452
|
"attr": "max-depth",
|
|
29453
29453
|
"reflectToAttr": false,
|
|
29454
|
-
"docs": "The maximum depth to traverse when building the field tree.\n\nIgnored when `associations` is set — an explicit association list implies its\nown depth, so the two never need to be reconciled.",
|
|
29454
|
+
"docs": "The maximum depth to traverse when building the field tree.\n\nIgnored when `associations` is set — an explicit association list implies its\nown depth, so the two never need to be reconciled.\n\n`0` pins the tree to the entity's own fields: like `associations`, the host\nowns the field list then, so no depth selector is shown.",
|
|
29455
29455
|
"docsTags": [
|
|
29456
29456
|
{
|
|
29457
29457
|
"name": "default",
|
|
@@ -621,6 +621,9 @@ const UdpAdvancedSearchBuilder = class {
|
|
|
621
621
|
*
|
|
622
622
|
* Ignored when `associations` is set — an explicit association list implies its
|
|
623
623
|
* own depth, so the two never need to be reconciled.
|
|
624
|
+
*
|
|
625
|
+
* `0` pins the tree to the entity's own fields: like `associations`, the host
|
|
626
|
+
* owns the field list then, so no depth selector is shown.
|
|
624
627
|
*/
|
|
625
628
|
this.maxDepth = 2;
|
|
626
629
|
/**
|
|
@@ -1237,16 +1240,20 @@ const UdpAdvancedSearchBuilder = class {
|
|
|
1237
1240
|
}
|
|
1238
1241
|
return false;
|
|
1239
1242
|
}
|
|
1240
|
-
|
|
1243
|
+
/**
|
|
1244
|
+
* The host fixed the field tree — an explicit association list, or depth 0 (own
|
|
1245
|
+
* fields only) — so a depth selector would be a control with nothing to change.
|
|
1246
|
+
*/
|
|
1247
|
+
get depthFixed() {
|
|
1241
1248
|
var _a, _b;
|
|
1249
|
+
return ((_b = (_a = this.associations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 || this.maxDepth < 1;
|
|
1250
|
+
}
|
|
1251
|
+
renderFilterRows() {
|
|
1242
1252
|
const isCollapsible = this.config.collapsible === true;
|
|
1243
1253
|
const rootGroup = this.currentFilterData.filterGroups.find(g => g.parentGroupId === null);
|
|
1244
|
-
//
|
|
1245
|
-
// change depth on top of it would be a control with nothing to change. The tree
|
|
1246
|
-
// rail carries its own depth control, so the row header never doubles it.
|
|
1247
|
-
const hasAssociations = ((_b = (_a = this.associations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0;
|
|
1254
|
+
// The tree rail carries its own depth control, so the row header never doubles it.
|
|
1248
1255
|
const depthInRail = this.config.showFieldPicker === true && this.config.fieldPickerView === 'tree';
|
|
1249
|
-
return (h("div", { class: "anim-container", ref: el => (this.animContainerEl = el) }, h("div", { class: "content-wrapper" }, (this.isExpanded || !isCollapsible) && rootGroup && (h("udp-advanced-search-filter-group", { key: rootGroup.groupId, groupId: rootGroup.groupId, filterData: this.currentFilterData, fields: this.fieldsArray, isRoot: true, flat: this.config.flat === true, operators: this.config.operators, freeFormFields: this.config.freeFormFields === true, maxDepth: this.currentMaxDepth, showDepthSelector: !
|
|
1256
|
+
return (h("div", { class: "anim-container", ref: el => (this.animContainerEl = el) }, h("div", { class: "content-wrapper" }, (this.isExpanded || !isCollapsible) && rootGroup && (h("udp-advanced-search-filter-group", { key: rootGroup.groupId, groupId: rootGroup.groupId, filterData: this.currentFilterData, fields: this.fieldsArray, isRoot: true, flat: this.config.flat === true, operators: this.config.operators, freeFormFields: this.config.freeFormFields === true, maxDepth: this.currentMaxDepth, showDepthSelector: !this.depthFixed && !depthInRail, onAddFilter: e => this.handleAddFilter(e.detail), onAddGroup: e => this.handleAddGroup(e.detail), onRemoveFilter: e => this.handleRemoveFilter(e.detail), onRemoveGroup: e => this.handleRemoveGroup(e.detail), onFilterChange: this.handleFilterChange, onGroupChange: this.handleGroupChange, onDepthChange: this.handleDepthChange, openAddMenuForGroupId: this.openAddMenuForGroupId, onToggleAddMenu: this.handleToggleAddMenu })))));
|
|
1250
1257
|
}
|
|
1251
1258
|
/**
|
|
1252
1259
|
* Clear / Search, with a quiet status line explaining a disabled Search — validation
|
|
@@ -1266,7 +1273,6 @@ const UdpAdvancedSearchBuilder = class {
|
|
|
1266
1273
|
];
|
|
1267
1274
|
}
|
|
1268
1275
|
render() {
|
|
1269
|
-
var _a, _b;
|
|
1270
1276
|
if (this.loading || this.extraFieldsLoading) {
|
|
1271
1277
|
return (h(Host, { class: { 'is-loading': true } }, h("div", { class: "advanced-filter-loading" }, h("udp-spinner", { size: "large" }), h("span", { class: "advanced-filter-loading-label" }, "Loading filters\u2026"))));
|
|
1272
1278
|
}
|
|
@@ -1275,7 +1281,6 @@ const UdpAdvancedSearchBuilder = class {
|
|
|
1275
1281
|
const showFooter = this.config.showFooter !== false;
|
|
1276
1282
|
const showFieldPicker = this.config.showFieldPicker === true;
|
|
1277
1283
|
const isTreePicker = showFieldPicker && this.config.fieldPickerView === 'tree';
|
|
1278
|
-
const hasAssociations = ((_b = (_a = this.associations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0;
|
|
1279
1284
|
const containerClasses = {
|
|
1280
1285
|
'advanced-filter-container': true,
|
|
1281
1286
|
'is-expanded': this.isExpanded,
|
|
@@ -1295,7 +1300,7 @@ const UdpAdvancedSearchBuilder = class {
|
|
|
1295
1300
|
} }, isTreePicker && (this.isExpanded || !isCollapsible) ? (
|
|
1296
1301
|
// The rail's width is the reader's to set: a deep tree wants room, a flat
|
|
1297
1302
|
// one wants the rows to have it. `udp-sidebar-layout` owns the seam and drag.
|
|
1298
|
-
h("udp-sidebar-layout", { class: "picker-layout", sidebarPosition: "end", collapsible: false, resizable: true, fill: true, sidebarWidth: "340px", minSidebarWidth: 260, maxSidebarWidth: 640 }, this.renderFilterRows(), h("udp-advanced-search-field-picker-tree", { slot: "sidebar", class: "field-picker", fields: this.fieldsArray, rootLabel: this.rootEntityLabel, depth: this.currentMaxDepth, showDepth: !
|
|
1303
|
+
h("udp-sidebar-layout", { class: "picker-layout", sidebarPosition: "end", collapsible: false, resizable: true, fill: true, sidebarWidth: "340px", minSidebarWidth: 260, maxSidebarWidth: 640 }, this.renderFilterRows(), h("udp-advanced-search-field-picker-tree", { slot: "sidebar", class: "field-picker", fields: this.fieldsArray, rootLabel: this.rootEntityLabel, depth: this.currentMaxDepth, showDepth: !this.depthFixed, onFieldPick: this.handleFieldPick, onDepthChange: this.handleDepthChange }))) : ([
|
|
1299
1304
|
this.renderFilterRows(),
|
|
1300
1305
|
showFieldPicker && (this.isExpanded || !isCollapsible) && (h("udp-advanced-search-field-picker", { class: "field-picker", fields: this.fieldsArray, rootLabel: this.rootEntityLabel, onFieldPick: this.handleFieldPick })),
|
|
1301
1306
|
])), showFooter && (h("div", { class: "advanced-filter-footer" }, this.renderActions())))));
|
|
@@ -73,6 +73,16 @@ const UdpAdvancedSearchFieldPicker = class {
|
|
|
73
73
|
};
|
|
74
74
|
UdpAdvancedSearchFieldPicker.style = fieldPickerCss();
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* The depth selector's options: 1–3, plus the current depth when a host set a
|
|
78
|
+
* deeper one — so the control always shows the depth the tree was built with,
|
|
79
|
+
* never an empty selection.
|
|
80
|
+
*/
|
|
81
|
+
const depthOptions = (depth) => Array.from({ length: Math.max(3, depth) }, (_, index) => ({
|
|
82
|
+
value: String(index + 1),
|
|
83
|
+
label: `Depth: ${index + 1}`,
|
|
84
|
+
}));
|
|
85
|
+
|
|
76
86
|
const fieldPickerTreeCss = () => `:host{display:block;min-height:0;min-width:0;box-sizing:border-box}.rail{display:flex;flex-direction:column;height:100%;min-height:0;background:var(--colorNeutralBackground1)}.rail-head{padding:var(--spacingVerticalM) var(--spacingHorizontalM) 0}.rail-title-row{display:flex;align-items:center;justify-content:space-between;gap:var(--spacingHorizontalS);margin-bottom:var(--spacingVerticalS)}.depth-select{width:100px;flex-shrink:0}.picker-search{display:block}.picker-body{padding:var(--spacingVerticalS) var(--spacingHorizontalXS);overflow-y:auto;flex:1 1 auto;min-height:0;box-sizing:border-box}.picker-status{display:block;padding-inline:var(--spacingHorizontalS);color:var(--colorNeutralForeground3)}.picker-tree{min-width:0}.result-group-label{display:block;padding:var(--spacingVerticalM) var(--spacingHorizontalM) var(--spacingVerticalXS);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.result-group:first-child .result-group-label{padding-top:var(--spacingVerticalXS)}.result-type{color:var(--colorNeutralForeground3);white-space:nowrap}.result-add{opacity:0}udp-fluent-list-item:hover .result-add,udp-fluent-list-item:focus-within .result-add{opacity:1}`;
|
|
77
87
|
|
|
78
88
|
/** Namespaced so an association route can never collide with a field's own path. */
|
|
@@ -187,21 +197,17 @@ const UdpAdvancedSearchFieldPickerTree = class {
|
|
|
187
197
|
})))));
|
|
188
198
|
}
|
|
189
199
|
render() {
|
|
190
|
-
var _a, _b;
|
|
200
|
+
var _a, _b, _c;
|
|
191
201
|
const needle = this.query.trim().toLowerCase();
|
|
192
202
|
const isSearching = needle.length > 0;
|
|
193
203
|
const rows = isSearching ? [] : this.buildRows((_a = this.fields) !== null && _a !== void 0 ? _a : [], '', undefined, []);
|
|
194
|
-
return (h("div", { key: '
|
|
195
|
-
{ value: '1', label: 'Depth: 1' },
|
|
196
|
-
{ value: '2', label: 'Depth: 2' },
|
|
197
|
-
{ value: '3', label: 'Depth: 3' },
|
|
198
|
-
], value: String((_b = this.depth) !== null && _b !== void 0 ? _b : 2), onValueChanged: (e) => {
|
|
204
|
+
return (h("div", { key: 'a2a0b02a17a269a48d2b155de5235010f195a7b2', class: "rail" }, h("div", { key: '205dbec6ab3e9889dccf97f0320460b6a6aae55a', class: "rail-head" }, h("div", { key: 'f1c9df3d3747d0381e07e6b5319c8d470ac46b29', class: "rail-title-row" }, h("udp-text", { key: '71ecb0a4eda863e600c30674457459fe63aab88d', variant: "body1Strong" }, "Fields"), this.showDepth && (h("div", { key: '4c1b8bea4f8257fce3c36ef9edeb509e64587484', class: "depth-select" }, h("udp-fluent-dropdown", { key: '187a8658a77e02f37b585f06d4b1e41f09165fd1', controlSize: "small", appearance: "filled-lighter", includeErrorPadding: false, clearable: false, options: depthOptions((_b = this.depth) !== null && _b !== void 0 ? _b : 2), value: String((_c = this.depth) !== null && _c !== void 0 ? _c : 2), onValueChanged: (e) => {
|
|
199
205
|
const detail = e.detail;
|
|
200
206
|
const value = typeof detail === 'string' ? detail : detail === null || detail === void 0 ? void 0 : detail.value;
|
|
201
207
|
const parsed = parseInt(value, 10);
|
|
202
208
|
if (!isNaN(parsed))
|
|
203
209
|
this.depthChange.emit(parsed);
|
|
204
|
-
} })))), h("udp-search-input", { key: '
|
|
210
|
+
} })))), h("udp-search-input", { key: 'b8e90390fb83e9db9382d45ce27929fd7db3d86d', class: "picker-search", value: this.query, placeholder: "Search fields", ariaLabel: "Search fields", includeErrorPadding: false, onValueChanged: (e) => { var _a; return (this.query = (_a = e.detail) !== null && _a !== void 0 ? _a : ''); } })), h("div", { key: '2ef9f1537865ab41536074ad535b464bf3f914b7', class: "picker-body" }, isSearching ? (this.renderSearchResults(needle)) : rows.length === 0 ? (h("udp-text", { variant: "caption1", class: "picker-status" }, "No fields available.")) : (h("udp-tree", { class: "picker-tree", treeItems: rows, itemContent: this.renderRowLabel, itemAside: this.renderRowAside, itemRowToggles: ROW_TOGGLES, interaction: "button", collapsible: true, size: "small", onItemClick: this.handleItemClick })))));
|
|
205
211
|
}
|
|
206
212
|
};
|
|
207
213
|
UdpAdvancedSearchFieldPickerTree.style = fieldPickerTreeCss();
|
|
@@ -362,7 +368,7 @@ const UdpAdvancedSearchFilterGroup = class {
|
|
|
362
368
|
}
|
|
363
369
|
}
|
|
364
370
|
render() {
|
|
365
|
-
var _a;
|
|
371
|
+
var _a, _b;
|
|
366
372
|
const groupInfo = this.filterData.filterGroups.find(g => g.groupId === this.groupId);
|
|
367
373
|
if (!groupInfo) {
|
|
368
374
|
return null;
|
|
@@ -382,11 +388,7 @@ const UdpAdvancedSearchFilterGroup = class {
|
|
|
382
388
|
marginRight: '12px',
|
|
383
389
|
width: '100px',
|
|
384
390
|
flexShrink: '0',
|
|
385
|
-
} }, h("udp-fluent-dropdown", { class: "depth-select", controlSize: 'small', options:
|
|
386
|
-
{ value: '1', label: 'Depth: 1' },
|
|
387
|
-
{ value: '2', label: 'Depth: 2' },
|
|
388
|
-
{ value: '3', label: 'Depth: 3' },
|
|
389
|
-
], value: String((_a = this.maxDepth) !== null && _a !== void 0 ? _a : 2), appearance: "filled-lighter", includeErrorPadding: false, clearable: false, onValueChanged: e => this.depthChange.emit(parseInt(this.getDropdownValue(e.detail), 10)) })))) : (h("div", { class: "actions" }, h("udp-fluent-icon-button", { iconName: "dismiss", appearance: "subtle", size: "small", ariaLabel: "Remove group", onClick: () => this.removeGroup.emit(this.groupId) })))), h("div", { class: "group-content" }, myFilters.map(filter => {
|
|
391
|
+
} }, h("udp-fluent-dropdown", { class: "depth-select", controlSize: 'small', options: depthOptions((_a = this.maxDepth) !== null && _a !== void 0 ? _a : 2), value: String((_b = this.maxDepth) !== null && _b !== void 0 ? _b : 2), appearance: "filled-lighter", includeErrorPadding: false, clearable: false, onValueChanged: e => this.depthChange.emit(parseInt(this.getDropdownValue(e.detail), 10)) })))) : (h("div", { class: "actions" }, h("udp-fluent-icon-button", { iconName: "dismiss", appearance: "subtle", size: "small", ariaLabel: "Remove group", onClick: () => this.removeGroup.emit(this.groupId) })))), h("div", { class: "group-content" }, myFilters.map(filter => {
|
|
390
392
|
var _a;
|
|
391
393
|
const selectedFieldObject = findNodeByPath(this.fields, filter.searchField);
|
|
392
394
|
const allowedOperators = getAllowedSearchOperators(selectedFieldObject, this.operators);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as i,h as s,H as e,a as o}from"./index-15aY63VA.js";import{L as r,a as n}from"./searchObject-DpUZkcYC.js";import{g as l}from"./entityUtilities-Bi7rt-yd.js";import{h,g as a,a as d}from"./udpOperatorHelper-CdVzLL2C.js";import{g as c,c as u,b as p,f}from"./catalogTree-CeoPZJ2J.js";import{e as v,g,c as m,f as b,j as x,E as y}from"./extraFields-C20hA6Tp.js";import"./makeApiCall-B-daVutk.js";import"axios";import"./configService-CehZzjhw.js";const w=t=>{if(!t||!t.filterGroups||0===t.filterGroups.length)return"";const i=s=>{const e=t.filterGroups.find((t=>t.groupId===s));if(!e)return"";const o=e.logicalSearchOperator===r.AND?"AND":"OR",n=[];return t.filterElements.filter((t=>t.groupId===s)).forEach((t=>{var i,s;const e="string"==typeof t.searchValue?`"${t.searchValue}"`:t.searchValue,o=h(null!==(s=null===(i=t.searchField)||void 0===i?void 0:i.split(".").pop())&&void 0!==s?s:"");n.push(`[${o}] ${a(t.searchOperator)} ${e}`)})),t.filterGroups.filter((t=>t.parentGroupId===s)).forEach((t=>{const s=i(t.groupId);s&&n.push(`(${s})`)})),n.join(` ${o} `)},s=t.filterGroups.find((t=>null===t.parentGroupId));return s?i(s.groupId):""};class F{constructor(t,i){this.scrollContainer=null,this.isDragStarted=!1,this.pendingItem=null,this.pendingLabel="",this.pendingSublabel="",this.sourceRowEl=null,this.startX=0,this.startY=0,this.currentState={isDragging:!1,dragItem:null,insertionPoint:null},this.sourceOriginalStyle="",this.draggedItemHeight=0,this.ghostOriginalTop=0,this.placeholder=null,this.fixedOffsetX=0,this.fixedOffsetY=0,this.slotInsetLeft=0,this.slotInsetRight=0,this.overlay=null,this.dropTargets=[],this.previousGapEls=[],this.lockedTarget=null,this.lockedPosition="before",this.autoScrollRAF=null,this.hostEl=t,this.callbacks=i,this.boundPointerDown=this.onPointerDown.bind(this),this.boundPointerMove=this.onPointerMove.bind(this),this.boundPointerUp=this.onPointerUp.bind(this),this.boundKeyDown=this.onKeyDown.bind(this),this.boundScroll=this.onScroll.bind(this),this.hostEl.addEventListener("pointerdown",this.boundPointerDown,!0)}destroy(){this.hostEl.removeEventListener("pointerdown",this.boundPointerDown,!0),this.cleanup()}setScrollContainer(t){this.scrollContainer=t}onPointerDown(t){if(0!==t.button)return;const i=t.composedPath(),s=i.find((t=>t instanceof HTMLElement&&t.hasAttribute("data-drag-handle")));if(!s)return;t.preventDefault();const e=s.dataset.dragType,o=s.dataset.dragId;if(!e||!o)return;const r=i.find((t=>t instanceof HTMLElement&&("filter"===e?t.classList.contains("filter-row"):t.classList.contains("group-box")&&!t.classList.contains("root-group"))));this.pendingItem={type:e,id:o},this.pendingLabel=s.dataset.dragLabel||("filter"===e?"Filter":"Group"),this.pendingSublabel=s.dataset.dragSublabel||"",this.sourceRowEl=r||null,this.startX=t.clientX,this.startY=t.clientY,this.isDragStarted=!1,document.addEventListener("pointermove",this.boundPointerMove),document.addEventListener("pointerup",this.boundPointerUp),document.addEventListener("keydown",this.boundKeyDown)}onPointerMove(t){const i=t.clientX-this.startX,s=t.clientY-this.startY;if(!this.isDragStarted){if(Math.sqrt(i*i+s*s)<5)return;this.beginDrag()}this.moveOverlay(t.clientX,t.clientY),this.updateInsertionPoint(t.clientY),this.handleAutoScroll(t.clientY)}onPointerUp(){this.isDragStarted&&this.currentState.insertionPoint&&this.currentState.dragItem&&this.callbacks.onDrop(this.currentState.dragItem,this.currentState.insertionPoint),this.cleanup()}onKeyDown(t){"Escape"===t.key&&this.cleanup()}beginDrag(){var t,i;if(this.isDragStarted=!0,this.fixedOffsetX=0,this.fixedOffsetY=0,this.sourceRowEl){const s=this.sourceRowEl.getBoundingClientRect();if(this.draggedItemHeight=s.height,this.sourceOriginalStyle=this.sourceRowEl.style.cssText,this.slotInsetLeft=0,this.slotInsetRight=0,"filter"===(null===(t=this.pendingItem)||void 0===t?void 0:t.type)){const t=this.sourceRowEl.querySelector(".field-select"),i=this.sourceRowEl.querySelector(".actions");t&&(this.slotInsetLeft=t.getBoundingClientRect().left-s.left);const e=null==i?void 0:i.previousElementSibling;e&&(this.slotInsetRight=s.right-e.getBoundingClientRect().right)}this.placeholder=document.createElement("div"),this.placeholder.style.height=`${s.height}px`,this.placeholder.style.pointerEvents="none",null===(i=this.sourceRowEl.parentNode)||void 0===i||i.insertBefore(this.placeholder,this.sourceRowEl.nextSibling),this.sourceRowEl.style.position="fixed",this.sourceRowEl.style.top=`${s.top}px`,this.sourceRowEl.style.left=`${s.left+this.slotInsetLeft}px`,this.sourceRowEl.style.width=s.width-this.slotInsetLeft-this.slotInsetRight+"px",this.sourceRowEl.style.height=`${s.height}px`,this.sourceRowEl.style.zIndex="10000",this.sourceRowEl.style.pointerEvents="none",this.sourceRowEl.style.boxSizing="border-box",this.sourceRowEl.classList.add("drag-slot");const e=this.sourceRowEl.getBoundingClientRect();this.fixedOffsetX=e.left-(s.left+this.slotInsetLeft),this.fixedOffsetY=e.top-s.top,0===this.fixedOffsetX&&0===this.fixedOffsetY||(this.sourceRowEl.style.top=s.top-this.fixedOffsetY+"px",this.sourceRowEl.style.left=s.left+this.slotInsetLeft-this.fixedOffsetX+"px"),this.ghostOriginalTop=s.top-this.fixedOffsetY,this.sourceRowEl.style.transition="top 80ms ease-out, left 80ms ease-out, width 80ms ease-out"}this.collectDropTargets(),this.createOverlay(),this.scrollContainer&&this.scrollContainer.addEventListener("scroll",this.boundScroll,{passive:!0}),document.body.style.cursor="grabbing",document.body.style.userSelect="none",this.currentState={isDragging:!0,dragItem:this.pendingItem,insertionPoint:null},this.callbacks.onStateChange(Object.assign({},this.currentState))}cleanup(){this.placeholder&&(this.placeholder.remove(),this.placeholder=null),this.sourceRowEl&&(this.sourceRowEl.style.cssText=this.sourceOriginalStyle,this.sourceRowEl.classList.remove("drag-slot"),this.sourceRowEl=null),this.overlay&&(this.overlay.remove(),this.overlay=null),this.clearGap(),null!==this.autoScrollRAF&&(cancelAnimationFrame(this.autoScrollRAF),this.autoScrollRAF=null),this.scrollContainer&&this.scrollContainer.removeEventListener("scroll",this.boundScroll),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("pointermove",this.boundPointerMove),document.removeEventListener("pointerup",this.boundPointerUp),document.removeEventListener("keydown",this.boundKeyDown),this.pendingItem=null,this.pendingLabel="",this.pendingSublabel="",this.isDragStarted=!1,this.dropTargets=[],this.draggedItemHeight=0,this.ghostOriginalTop=0,this.sourceOriginalStyle="",this.lockedTarget=null;const t=this.currentState.isDragging;this.currentState={isDragging:!1,dragItem:null,insertionPoint:null},t&&this.callbacks.onStateChange(Object.assign({},this.currentState))}createOverlay(){var t;this.overlay=document.createElement("div"),this.overlay.className="drag-overlay";const i=document.createElement("span");i.className="drag-overlay-grip",i.textContent="⠿";const s=document.createElement("div");s.className="drag-overlay-text";const e=document.createElement("span");if(e.className="drag-overlay-label",e.textContent=this.pendingLabel,s.appendChild(e),this.pendingSublabel){const t=document.createElement("span");t.className="drag-overlay-sub",t.textContent=this.pendingSublabel,s.appendChild(t)}this.overlay.append(i,s),null===(t=this.hostEl.shadowRoot)||void 0===t||t.appendChild(this.overlay)}moveOverlay(t,i){this.overlay&&(this.overlay.style.left=t+12-this.fixedOffsetX+"px",this.overlay.style.top=i-20-this.fixedOffsetY+"px")}positionGhost(t,i){if(!this.sourceRowEl)return;const s=this.getGapElement(t,i).getBoundingClientRect();let e;e="before"===i?s.top-this.draggedItemHeight:s.bottom;const o=this.getGhostReferenceRect(t,i);this.sourceRowEl.style.top=e-this.fixedOffsetY+"px",this.sourceRowEl.style.left=o.left+this.slotInsetLeft-this.fixedOffsetX+"px",this.sourceRowEl.style.width=o.width-this.slotInsetLeft-this.slotInsetRight+"px"}getGhostReferenceRect(t,i){if("group"===t.type&&"after"===i){const i=t.element.nextElementSibling;if(i){const t=Array.from(i.querySelectorAll(".filter-row, udp-advanced-search-filter-group"));for(const i of t)if(i!==this.sourceRowEl)return i.getBoundingClientRect();const s=i.querySelector(".add-new-container");if(s)return s.getBoundingClientRect()}}return t.element.getBoundingClientRect()}resetGhostPosition(){this.sourceRowEl&&(this.sourceRowEl.style.top=`${this.ghostOriginalTop}px`)}getGapElement(t,i){if("filter"===t.type)return t.element;if("after"===i)return t.element;const s=t.element.getRootNode();return s instanceof ShadowRoot&&s.host?s.host:t.element}applyGap(t,i){this.placeholder&&(this.placeholder.style.height="0px");const s=this.getGapElement(t,i);for(const t of this.previousGapEls)t!==s&&(t.style.marginTop="",t.style.marginBottom="");s.style.marginTop="",s.style.marginBottom="","before"===i?s.style.marginTop=`${this.draggedItemHeight}px`:s.style.marginBottom=`${this.draggedItemHeight}px`,this.previousGapEls=[s]}clearGap(){for(const t of this.previousGapEls)t.style.marginTop="",t.style.marginBottom="";this.previousGapEls=[],this.placeholder&&(this.placeholder.style.height=`${this.draggedItemHeight}px`)}collectDropTargets(){var t;this.dropTargets=[];const i=this.pendingItem,s=t=>{const e=t.shadowRoot;if(!e)return;e.querySelectorAll(".filter-row[data-filter-id]").forEach((t=>{const s=t.dataset.filterId;"filter"===(null==i?void 0:i.type)&&i.id===s||this.dropTargets.push({type:"filter",id:s,element:t,rect:t.getBoundingClientRect(),midY:0})}));const o=e.querySelector(".group-box[data-group-id]");if(o&&!o.classList.contains("root-group")){const t=o.dataset.groupId;if("group"!==(null==i?void 0:i.type)||i.id!==t){const i=o.querySelector(":scope > .group-header");i&&this.dropTargets.push({type:"group",id:t,element:i,rect:i.getBoundingClientRect(),midY:0})}}e.querySelectorAll("udp-advanced-search-filter-group").forEach((t=>s(t)))},e=null===(t=this.hostEl.shadowRoot)||void 0===t?void 0:t.querySelector("udp-advanced-search-filter-group");e&&s(e);for(const t of this.dropTargets)t.midY=t.rect.top+t.rect.height/2;this.dropTargets.sort(((t,i)=>t.rect.top-i.rect.top))}updateInsertionPoint(t){var i,s;if(0===this.dropTargets.length)return this.clearGap(),this.resetGhostPosition(),this.lockedTarget=null,void this.commitInsertionPoint(null);let e=null,o="before";for(const i of this.dropTargets){const s=i.element.getBoundingClientRect();if(t>=s.top&&t<=s.bottom){e=i,o=t<s.top+s.height/2?"before":"after";break}}if(!e){const r=null===(i=this.dropTargets[0])||void 0===i?void 0:i.element,n=null===(s=this.dropTargets[this.dropTargets.length-1])||void 0===s?void 0:s.element;if(r&&t<r.getBoundingClientRect().top)e=this.dropTargets[0],o="before";else{if(!(n&&t>n.getBoundingClientRect().bottom))return;e=this.dropTargets[this.dropTargets.length-1],o="after"}}if("before"===o){const t=this.dropTargets.indexOf(e);t>0&&(e=this.dropTargets[t-1],o="after")}if(e===this.lockedTarget&&o===this.lockedPosition)return;const r=this.currentState.dragItem||this.pendingItem;if(this.callbacks.isValidDrop&&r&&!this.callbacks.isValidDrop(r,e.type,e.id))return this.clearGap(),this.resetGhostPosition(),this.lockedTarget=null,void this.commitInsertionPoint(null);this.lockedTarget=e,this.lockedPosition=o,this.applyGap(e,o),this.positionGhost(e,o),this.commitInsertionPoint({position:o,targetId:e.id,targetType:e.type})}commitInsertionPoint(t){const i=this.currentState.insertionPoint;(null==i?void 0:i.position)===(null==t?void 0:t.position)&&(null==i?void 0:i.targetId)===(null==t?void 0:t.targetId)&&(null==i?void 0:i.targetType)===(null==t?void 0:t.targetType)||(this.currentState=Object.assign(Object.assign({},this.currentState),{insertionPoint:t}),this.callbacks.onStateChange(Object.assign({},this.currentState)))}handleAutoScroll(t){if(!this.scrollContainer)return;const i=this.scrollContainer.getBoundingClientRect(),s=t-i.top,e=i.bottom-t;let o=0;if(s>0&&s<50?o=-10*(1-s/50):e>0&&e<50&&(o=10*(1-e/50)),null!==this.autoScrollRAF&&(cancelAnimationFrame(this.autoScrollRAF),this.autoScrollRAF=null),0!==o){const t=()=>{this.scrollContainer&&(this.scrollContainer.scrollTop+=o,this.refreshDropTargetRects(),this.autoScrollRAF=requestAnimationFrame(t))};this.autoScrollRAF=requestAnimationFrame(t)}}onScroll(){this.refreshDropTargetRects()}refreshDropTargetRects(){for(const t of this.dropTargets)t.rect=t.element.getBoundingClientRect(),t.midY=t.rect.top+t.rect.height/2}}const k=class{constructor(s){t(this,s),this.filterSave=i(this,"filterSave",7),this.searchChange=i(this,"searchChange",7),this.validityChange=i(this,"validityChange",7),this.config={},this.maxDepth=2,this.showClearButton=!1,this.loading=!1,this.fieldsArray=[],this.extraFieldGroups=[],this.extraFieldsLoading=!1,this.extraFieldsRequestId=0,this.openAddMenuForGroupId=null,this.filterString="",this.isExpanded=!0,this.isFilterValid=!0,this.errorMessages=[],this.attentionErrors=[],this.rootEntityLabel="",this.nextGroupId=1,this.handleFieldPick=t=>{this.addFilterForPath(t.detail.path,t.detail.type)},this.handleSearch=()=>{this.isFilterValid&&this.filterSave?(this.filterSave.emit(this.currentFilterData),this.filterString=w(this.currentFilterData),this.config.collapsible&&this.toggleExpanded()):console.warn("Cannot run search: filter is invalid.")},this.handleClear=()=>{const t=this.getNormalizedData(Object.assign(Object.assign({},this.currentFilterData),{filterElements:[],filterGroups:[]}));this.currentFilterData=t,this.isFilterValid=!0,this.errorMessages=[],this.attentionErrors=[],this.searchChange.emit(t),this.validityChange.emit({isValid:!0,errors:[],attentionErrors:[]}),this.filterSave&&(this.filterSave.emit(t),this.filterString=w(t)),this.config.collapsible&&this.toggleExpanded()},this.toggleExpanded=()=>{this.isExpanded=!this.isExpanded,this.updateHostClasses()},this.handleToggleAddMenu=t=>{const i=t.detail;if(this.openAddMenuForGroupId=this.openAddMenuForGroupId===i?null:i,null!==this.openAddMenuForGroupId){const t=this.animContainerEl;t&&requestAnimationFrame((()=>{t.scrollTop=t.scrollHeight}))}},this.handleDragStateChange=()=>{},this.isValidDragDrop=(t,i,s)=>{if("group"===t.type&&"group"===i){const i=parseInt(t.id,10),e=parseInt(s,10);if(i===e)return!1;if(this.isDescendant(e,i,this.currentFilterData.filterGroups))return!1}if("group"===t.type&&"filter"===i){const i=parseInt(t.id,10),e=this.currentFilterData.filterElements.find((t=>t._id===s));if(e){const t=e.groupId;if(t===i||this.isDescendant(t,i,this.currentFilterData.filterGroups))return!1}}return!0},this.handleDragDrop=(t,i)=>{this.runUpdateCycle((s=>{"filter"===t.type?this.applyFilterDrop(s,t,i):"group"===t.type&&this.applyGroupDrop(s,t,i)}))},this.handleAddFilter=t=>{this.runUpdateCycle((i=>{var s,e;const o=null===(s=this.fieldsArray)||void 0===s?void 0:s[0],r=d(o,this.config.operators),n=(null===(e=null==r?void 0:r[0])||void 0===e?void 0:e.value)||"";i.filterElements.push({_id:`filter_${Math.random()}`,_type:null==o?void 0:o.type,groupId:t,searchField:null==o?void 0:o.name,searchOperator:n,searchValue:""})})),this.openAddMenuForGroupId=null},this.handleAddGroup=t=>{this.runUpdateCycle((i=>{i.filterGroups.push({groupId:this.nextGroupId++,parentGroupId:t,logicalSearchOperator:r.AND})})),this.openAddMenuForGroupId=null},this.handleRemoveFilter=t=>{this.runUpdateCycle((i=>{const s=i.filterElements.findIndex((i=>i._id===t));s>-1&&i.filterElements.splice(s,1)}))},this.handleRemoveGroup=t=>{this.runUpdateCycle((i=>{const s=t=>{const e=i.filterGroups.filter((i=>i.parentGroupId===t));let o=e.map((t=>t.groupId));return e.forEach((t=>{o=[...o,...s(t.groupId)]})),o},e=[t,...s(t)];i.filterGroups=i.filterGroups.filter((t=>!e.includes(t.groupId))),i.filterElements=i.filterElements.filter((t=>!e.includes(t.groupId)))}))},this.handleFilterChange=t=>{const{filterId:i,field:s,value:e,updates:o}=t.detail;this.runUpdateCycle((t=>{const r=t.filterElements.find((t=>t._id===i));r&&(o?Object.assign(r,o):(r[s]=e,"searchValue"===s&&(r._touched=!0)))}))},this.handleDepthChange=t=>{const i=t.detail;"number"==typeof i&&i!==this.currentMaxDepth&&(this.currentMaxDepth=i,this.buildFieldTree())},this.handleGroupChange=t=>{const{groupId:i,logicalSearchOperator:s}=t.detail;this.runUpdateCycle((t=>{const e=t.filterGroups.find((t=>t.groupId===i));e&&(e.logicalSearchOperator=s)}))}}buildFieldTree(){var t;if(this.entityName&&this.catalogObjectList){const i=l(this.entityName),s=i[0].toUpperCase()+i.slice(1);this.rootEntityLabel=s,this.fieldsArray=c(u(p(this.catalogObjectList,s,this.currentMaxDepth,this.associations),this.includeFields,this.excludeFields),[...this.extraFieldGroups,...null!==(t=this.virtualFields)&&void 0!==t?t:[]])}}async loadExtraFields(){var t,i,s,e,o;const r=++this.extraFieldsRequestId,n=null!==(i=null===(t=this.extraFields)||void 0===t?void 0:t.domainName)&&void 0!==i?i:this.entityName;if(!this.extraFields||!n)return this.extraFieldGroups.length&&(this.extraFieldGroups=[]),void(this.extraFieldsLoading=!1);const l=null!==(s=this.extraFields.prefix)&&void 0!==s?s:y;this.buildFieldTree();const h=[{path:"",domainName:n,definitions:this.extraFields.definitions,context:v(this.extraFields)}];for(const t of null!==(e=this.associations)&&void 0!==e?e:[]){const i=this.resolveAssociationPath(t),s=null!==(o=null==i?void 0:i.node.displayName)&&void 0!==o?o:null==i?void 0:i.node.name;i&&s&&h.push({path:i.path,domainName:s})}this.extraFieldsLoading=!0;try{const t=await Promise.all(h.map((async t=>{try{const i=t.context?await g(t.domainName,t.context):t.definitions?m(t.definitions):await b(t.domainName);return x(i,l,t.path)}catch(i){return console.error(`Failed to load extra-field definitions for ${t.domainName}:`,i),null}})));if(r!==this.extraFieldsRequestId)return;this.extraFieldGroups=t.filter((t=>null!==t))}finally{r===this.extraFieldsRequestId&&(this.extraFieldsLoading=!1)}}resolveAssociationPath(t){var i,s;let e=this.fieldsArray,o=null;const r=[];for(const n of t.split(".")){if(o=null!==(i=e.find((t=>t.name.toLowerCase()===n.toLowerCase())))&&void 0!==i?i:null,!o)return null;r.push(o.name),e=null!==(s=o.childFields)&&void 0!==s?s:[]}return o?{node:o,path:r.join(".")}:null}reloadExtraFields(){this.loadExtraFields()}rebuildFieldTree(){this.buildFieldTree(),this.currentFilterData&&(this.currentFilterData=this.getNormalizedData(this.currentFilterData))}syncMaxDepth(t){this.currentMaxDepth=t,this.buildFieldTree()}syncAssociations(){this.buildFieldTree()}syncInitialFilterData(t){this.currentFilterData=this.getNormalizedData(t),this.updateNextGroupId(this.currentFilterData)}componentWillLoad(){this.currentMaxDepth=this.maxDepth,this.buildFieldTree(),this.currentFilterData=this.getNormalizedData(this.initialFilterData),this.updateNextGroupId(this.currentFilterData),this.loadExtraFields()}componentDidLoad(){this.updateHostClasses(),this.dragManager=new F(this.el,{onStateChange:this.handleDragStateChange,onDrop:this.handleDragDrop,isValidDrop:this.isValidDragDrop}),this.animContainerEl&&this.dragManager.setScrollContainer(this.animContainerEl)}disconnectedCallback(){var t;null===(t=this.dragManager)||void 0===t||t.destroy()}async addFilterElement(t,i){this.addFilterForPath(t,i)}async submitSearch(){this.handleSearch()}async clearFilters(){this.handleClear()}addFilterForPath(t,i){var s,e,o;const r=new Set(["object","array"]),n=f(this.fieldsArray,t),l=null!==(e=null!==(s=null==n?void 0:n.type)&&void 0!==s?s:null==i?void 0:i.toLowerCase())&&void 0!==e?e:"string";if(r.has(l))return;const h=d(null!=n?n:{type:l},this.config.operators),a=(null===(o=null==h?void 0:h[0])||void 0===o?void 0:o.value)||"=",c=this.currentFilterData.filterGroups.find((t=>null===t.parentGroupId));this.runUpdateCycle((i=>{var s;i.filterElements.push({_id:`filter_${Math.random()}`,_type:l,groupId:null!==(s=null==c?void 0:c.groupId)&&void 0!==s?s:1,searchField:t,searchOperator:a,searchValue:"boolean"===l?"true":""})}))}updateHostClasses(){this.isExpanded?(this.el.classList.add("host-expanded"),this.el.classList.remove("host-collapsed")):(this.el.classList.add("host-collapsed"),this.el.classList.remove("host-expanded"),this.el.style.height=null)}updateNextGroupId(t){this.nextGroupId=t&&t.filterGroups.length>0?Math.max(...t.filterGroups.map((t=>t.groupId)))+1:2}verifyFilterState(t){const i=[],s=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;for(const s of t.filterGroups){if(null===s.parentGroupId)continue;const e=t.filterElements.some((t=>t.groupId===s.groupId)),o=t.filterGroups.some((t=>t.parentGroupId===s.groupId));e||o||i.push("A group has no filters. Add a filter or remove the group.")}return t.filterElements.forEach((t=>{var e,o;delete t._error;const r=null==t.searchField||""===t.searchField,l=!t.searchValue,a=t.searchOperator===n.NULL||t.searchOperator===n.NOT_NULL,d=h(null!==(o=null===(e=t.searchField)||void 0===e?void 0:e.split(".").pop())&&void 0!==o?o:"");if(r){const s="A filter is missing its field.";t._error=s,i.push(s)}else if(t.searchOperator===n.BETWEEN){const s=(t.searchValue||"").split(",");if(2!==s.length||!s[0]||!s[1]){const s=`"${d}" needs two values (from and to).`;t._error=s,i.push(s)}}else if(l&&!a){const s=`"${d}" needs a value.`;t._error=s,i.push(s)}else if("guid"===t._type&&!l&&!s.test(t.searchValue)){const s=`"${d}" needs a valid GUID.`;t._error=s,i.push(s)}})),{isValid:0===i.length,errors:i}}stampFilterElements(t){const i=new Set(t.map((t=>t._id)).filter(Boolean));return t.map(((t,s)=>{var e;const o=Object.assign({},t);if(!o._id){const t=`filter_ext_${null!==(e=o.groupId)&&void 0!==e?e:"root"}_${s}`;let r=t,n=1;for(;i.has(r);)r=`${t}_${n++}`;i.add(r),o._id=r}if(!o._type){const t=f(this.fieldsArray,o.searchField);(null==t?void 0:t.type)&&(o._type=t.type)}return o}))}getNormalizedData(t){var i,s,e;if(t&&(null===(i=t.filterGroups)||void 0===i?void 0:i.length)>0)return Object.assign(Object.assign({},t),{filterGroups:[...t.filterGroups],filterElements:this.stampFilterElements(null!==(s=t.filterElements)&&void 0!==s?s:[])});if(t&&(null===(e=t.filterElements)||void 0===e?void 0:e.length)>0){const i=1;return Object.assign(Object.assign({},t),{filterGroups:[{groupId:i,parentGroupId:null,logicalSearchOperator:t.logicalSearchOperator||r.AND}],filterElements:this.stampFilterElements(t.filterElements.map((t=>Object.assign(Object.assign({},t),{groupId:i}))))})}return Object.assign(Object.assign({},t),{logicalSearchOperator:r.AND,filterGroups:[{groupId:1,parentGroupId:null,logicalSearchOperator:r.AND}],filterElements:[]})}runUpdateCycle(t){const i=JSON.parse(JSON.stringify(this.currentFilterData));t(i),this.currentFilterData=i;const s=this.verifyFilterState(i);this.isFilterValid=s.isValid,this.errorMessages=s.errors,this.attentionErrors=i.filterElements.filter((t=>t._error&&t._touched)).map((t=>t._error)),this.searchChange.emit(i),this.validityChange.emit({isValid:this.isFilterValid,errors:this.errorMessages,attentionErrors:this.attentionErrors})}applyFilterDrop(t,i,s){const e=t.filterElements.find((t=>t._id===i.id));if(!e)return;const o=t.filterElements.indexOf(e);if(t.filterElements.splice(o,1),"filter"===s.targetType){const i=t.filterElements.find((t=>t._id===s.targetId));if(!i)return void t.filterElements.push(e);e.groupId=i.groupId;const o=t.filterElements.indexOf(i);t.filterElements.splice("before"===s.position?o:o+1,0,e)}else{const i=parseInt(s.targetId,10),o=t.filterGroups.find((t=>t.groupId===i));e.groupId="before"===s.position&&null!=(null==o?void 0:o.parentGroupId)?o.parentGroupId:i,t.filterElements.push(e)}}applyGroupDrop(t,i,s){const e=parseInt(i.id,10),o=t.filterGroups.find((t=>t.groupId===e));if(o)if("group"===s.targetType){const i=parseInt(s.targetId,10);if(this.isDescendant(i,e,t.filterGroups))return;if(e===i)return;const r=t.filterGroups.find((t=>t.groupId===i));if(!r)return;o.parentGroupId="before"===s.position?r.parentGroupId:i;const n=t.filterGroups.indexOf(o);t.filterGroups.splice(n,1);const l=t.filterGroups.indexOf(r);t.filterGroups.splice("before"===s.position?l:l+1,0,o)}else if("filter"===s.targetType){const i=t.filterElements.find((t=>t._id===s.targetId));i&&(o.parentGroupId=i.groupId)}}isDescendant(t,i,s){let e=s.find((i=>i.groupId===t));for(;e&&null!==e.parentGroupId;){if(e.parentGroupId===i)return!0;e=s.find((t=>t.groupId===e.parentGroupId))}return!1}renderFilterRows(){var t,i;const e=!0===this.config.collapsible,o=this.currentFilterData.filterGroups.find((t=>null===t.parentGroupId)),r=(null!==(i=null===(t=this.associations)||void 0===t?void 0:t.length)&&void 0!==i?i:0)>0;return s("div",{class:"anim-container",ref:t=>this.animContainerEl=t},s("div",{class:"content-wrapper"},(this.isExpanded||!e)&&o&&s("udp-advanced-search-filter-group",{key:o.groupId,groupId:o.groupId,filterData:this.currentFilterData,fields:this.fieldsArray,isRoot:!0,flat:!0===this.config.flat,operators:this.config.operators,freeFormFields:!0===this.config.freeFormFields,maxDepth:this.currentMaxDepth,showDepthSelector:!(r||!0===this.config.showFieldPicker&&"tree"===this.config.fieldPickerView),onAddFilter:t=>this.handleAddFilter(t.detail),onAddGroup:t=>this.handleAddGroup(t.detail),onRemoveFilter:t=>this.handleRemoveFilter(t.detail),onRemoveGroup:t=>this.handleRemoveGroup(t.detail),onFilterChange:this.handleFilterChange,onGroupChange:this.handleGroupChange,onDepthChange:this.handleDepthChange,openAddMenuForGroupId:this.openAddMenuForGroupId,onToggleAddMenu:this.handleToggleAddMenu})))}renderActions(){return[s("udp-fluent-button",{disabled:!this.isFilterValid,onClick:this.handleSearch,appearance:"primary"},"Search"),this.showClearButton&&s("udp-fluent-button",{appearance:"subtle",onClick:this.handleClear},"Clear"),!this.isFilterValid&&s("udp-text",{variant:"caption1",class:{"footer-status":!0,"is-attention":this.attentionErrors.length>0}},this.attentionErrors.length>1?`${this.attentionErrors.length} filters need attention`:1===this.attentionErrors.length?this.attentionErrors[0]:this.errorMessages.length>1?`${this.errorMessages.length} filters to complete`:"1 filter to complete")]}render(){var t,i;if(this.loading||this.extraFieldsLoading)return s(e,{class:{"is-loading":!0}},s("div",{class:"advanced-filter-loading"},s("udp-spinner",{size:"large"}),s("span",{class:"advanced-filter-loading-label"},"Loading filters…")));const o=!0===this.config.collapsible,r=!1!==this.config.resizable,n=!1!==this.config.showFooter,l=!0===this.config.showFieldPicker,h=l&&"tree"===this.config.fieldPickerView,a=(null!==(i=null===(t=this.associations)||void 0===t?void 0:t.length)&&void 0!==i?i:0)>0,d={"advanced-filter-container":!0,"is-expanded":this.isExpanded},c={};return this.isExpanded&&this.config.height&&(c.height=this.config.height),s(e,{style:c,class:{"is-resizable":r,"host-expanded":this.isExpanded,"host-collapsed":!this.isExpanded}},s("div",{class:d},o&&s("div",{class:"collapsed-view"},s("udp-fluent-text-input",{value:this.filterString,readonly:!0,appearance:"filled-darker",includeErrorPadding:!1,class:"string-display-input"}),s("udp-fluent-button",{class:"toggle-button",size:"small",appearance:"transparent",onClick:this.toggleExpanded},s("span",null,this.isExpanded?"Collapse":"Expand"),s("svg",{class:"toggle-icon",viewBox:"0 0 16 16",slot:"end"},s("path",{d:"M4 6L8 10L12 6",stroke:"currentColor","stroke-width":"2"})))),s("div",{class:{"filter-body":!0,"has-field-picker":l,"tree-picker":h}},!h||!this.isExpanded&&o?[this.renderFilterRows(),l&&(this.isExpanded||!o)&&s("udp-advanced-search-field-picker",{class:"field-picker",fields:this.fieldsArray,rootLabel:this.rootEntityLabel,onFieldPick:this.handleFieldPick})]:s("udp-sidebar-layout",{class:"picker-layout",sidebarPosition:"end",collapsible:!1,resizable:!0,fill:!0,sidebarWidth:"340px",minSidebarWidth:260,maxSidebarWidth:640},this.renderFilterRows(),s("udp-advanced-search-field-picker-tree",{slot:"sidebar",class:"field-picker",fields:this.fieldsArray,rootLabel:this.rootEntityLabel,depth:this.currentMaxDepth,showDepth:!a,onFieldPick:this.handleFieldPick,onDepthChange:this.handleDepthChange}))),n&&s("div",{class:"advanced-filter-footer"},this.renderActions())))}get el(){return o(this)}static get watchers(){return{extraFields:[{reloadExtraFields:0}],entityName:[{reloadExtraFields:0},{rebuildFieldTree:0}],associations:[{reloadExtraFields:0},{syncAssociations:0}],catalogObjectList:[{reloadExtraFields:0},{rebuildFieldTree:0}],extraFieldGroups:[{rebuildFieldTree:0}],includeFields:[{rebuildFieldTree:0}],excludeFields:[{rebuildFieldTree:0}],virtualFields:[{rebuildFieldTree:0}],maxDepth:[{syncMaxDepth:0}],initialFilterData:[{syncInitialFilterData:0}]}}};k.style=":host{display:flex;flex-direction:column;box-sizing:border-box;overflow:visible}.advanced-filter-loading{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;min-height:240px;width:100%}.advanced-filter-loading-label{color:var(--colorNeutralForeground3);font-size:var(--fontSizeBase300)}:host(.host-collapsed){resize:none;height:auto}:host(.host-expanded){overflow-y:auto}:host(.is-resizable.host-expanded){resize:vertical;min-height:180px;max-height:80vh;overflow:auto}.advanced-filter-container{display:flex;flex-direction:column;height:100%;width:100%;overflow:hidden}.collapsed-view{display:flex;align-items:center;gap:0.5rem;padding:var(--spacingVerticalS) var(--spacingHorizontalM);border-bottom:1px solid var(--colorNeutralStroke2)}.filter-body{display:flex;flex-direction:column;flex-grow:1;min-height:0;overflow:hidden}.anim-container{flex-grow:1;min-width:0;overflow-y:auto;overflow-x:auto;display:flex}.filter-body.has-field-picker{flex-direction:row;align-items:stretch;gap:var(--spacingHorizontalM)}.filter-body.has-field-picker .anim-container{flex:1 1 0;min-width:0;overflow-y:auto}.filter-body.has-field-picker .field-picker{flex:1 1 0;min-width:0}.filter-body.tree-picker{gap:0}.filter-body.tree-picker .picker-layout{flex:1 1 0;min-width:0;min-height:0}.filter-body.tree-picker .field-picker{height:100%}.filter-body.tree-picker .anim-container{background:var(--colorNeutralBackground2);padding:var(--spacingVerticalL) var(--spacingHorizontalL);min-height:100%;box-sizing:border-box}.content-wrapper{padding-bottom:15px;flex-grow:1}.advanced-filter-footer{display:flex;justify-content:flex-start;border-top:1px solid var(--colorNeutralStroke2);padding:var(--spacingVerticalS) var(--spacingHorizontalM);flex-shrink:0;gap:var(--spacingHorizontalS);align-items:center}.advanced-filter-footer .footer-status{color:var(--colorNeutralForeground3)}.advanced-filter-footer .footer-status.is-attention{color:var(--colorPaletteRedForeground1)}.string-display-input{width:100%}.search-button{opacity:0;transform:scale(0.95);pointer-events:none;margin-right:10px}.advanced-filter-container.is-expanded .anim-container{overflow-y:auto;min-height:130px}.advanced-filter-container.is-expanded .filter-body.has-field-picker .anim-container{min-height:0}.advanced-filter-container.is-expanded .collapsed-view{display:none}.advanced-filter-container.is-expanded .search-button{opacity:1;transform:scale(1);pointer-events:auto}.advanced-filter-container:not(.is-expanded) .anim-container{max-height:0;min-height:0;overflow:hidden}.advanced-filter-container:not(.is-expanded) .advanced-filter-footer{opacity:0;height:0;padding:0;border:none;pointer-events:none;overflow:hidden}.drag-overlay{position:fixed;pointer-events:none;z-index:10001;display:flex;align-items:center;gap:var(--spacingHorizontalS);background:var(--colorNeutralBackground1);border:1px solid var(--colorNeutralStroke2);border-radius:var(--borderRadiusMedium);box-shadow:var(--shadow16);padding:var(--spacingVerticalS) var(--spacingHorizontalM);max-width:260px;box-sizing:border-box}.drag-overlay-grip{flex-shrink:0;color:var(--colorNeutralForeground3);font-size:var(--fontSizeBase400);line-height:1;user-select:none}.drag-overlay-text{display:flex;flex-direction:column;min-width:0}.drag-overlay-label{font-size:var(--fontSizeBase300);line-height:var(--lineHeightBase300);font-weight:var(--fontWeightSemibold);color:var(--colorNeutralForeground1);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.drag-overlay-sub{font-size:var(--fontSizeBase200);line-height:var(--lineHeightBase200);color:var(--colorNeutralForeground3);white-space:nowrap}";export{k as udp_advanced_search_builder}
|
|
1
|
+
import{r as t,c as i,h as s,H as e,a as o}from"./index-15aY63VA.js";import{L as r,a as n}from"./searchObject-DpUZkcYC.js";import{g as l}from"./entityUtilities-Bi7rt-yd.js";import{h,g as a,a as d}from"./udpOperatorHelper-CdVzLL2C.js";import{g as c,c as u,b as p,f}from"./catalogTree-CeoPZJ2J.js";import{e as v,g,c as m,f as b,j as x,E as y}from"./extraFields-C20hA6Tp.js";import"./makeApiCall-B-daVutk.js";import"axios";import"./configService-CehZzjhw.js";const w=t=>{if(!t||!t.filterGroups||0===t.filterGroups.length)return"";const i=s=>{const e=t.filterGroups.find((t=>t.groupId===s));if(!e)return"";const o=e.logicalSearchOperator===r.AND?"AND":"OR",n=[];return t.filterElements.filter((t=>t.groupId===s)).forEach((t=>{var i,s;const e="string"==typeof t.searchValue?`"${t.searchValue}"`:t.searchValue,o=h(null!==(s=null===(i=t.searchField)||void 0===i?void 0:i.split(".").pop())&&void 0!==s?s:"");n.push(`[${o}] ${a(t.searchOperator)} ${e}`)})),t.filterGroups.filter((t=>t.parentGroupId===s)).forEach((t=>{const s=i(t.groupId);s&&n.push(`(${s})`)})),n.join(` ${o} `)},s=t.filterGroups.find((t=>null===t.parentGroupId));return s?i(s.groupId):""};class F{constructor(t,i){this.scrollContainer=null,this.isDragStarted=!1,this.pendingItem=null,this.pendingLabel="",this.pendingSublabel="",this.sourceRowEl=null,this.startX=0,this.startY=0,this.currentState={isDragging:!1,dragItem:null,insertionPoint:null},this.sourceOriginalStyle="",this.draggedItemHeight=0,this.ghostOriginalTop=0,this.placeholder=null,this.fixedOffsetX=0,this.fixedOffsetY=0,this.slotInsetLeft=0,this.slotInsetRight=0,this.overlay=null,this.dropTargets=[],this.previousGapEls=[],this.lockedTarget=null,this.lockedPosition="before",this.autoScrollRAF=null,this.hostEl=t,this.callbacks=i,this.boundPointerDown=this.onPointerDown.bind(this),this.boundPointerMove=this.onPointerMove.bind(this),this.boundPointerUp=this.onPointerUp.bind(this),this.boundKeyDown=this.onKeyDown.bind(this),this.boundScroll=this.onScroll.bind(this),this.hostEl.addEventListener("pointerdown",this.boundPointerDown,!0)}destroy(){this.hostEl.removeEventListener("pointerdown",this.boundPointerDown,!0),this.cleanup()}setScrollContainer(t){this.scrollContainer=t}onPointerDown(t){if(0!==t.button)return;const i=t.composedPath(),s=i.find((t=>t instanceof HTMLElement&&t.hasAttribute("data-drag-handle")));if(!s)return;t.preventDefault();const e=s.dataset.dragType,o=s.dataset.dragId;if(!e||!o)return;const r=i.find((t=>t instanceof HTMLElement&&("filter"===e?t.classList.contains("filter-row"):t.classList.contains("group-box")&&!t.classList.contains("root-group"))));this.pendingItem={type:e,id:o},this.pendingLabel=s.dataset.dragLabel||("filter"===e?"Filter":"Group"),this.pendingSublabel=s.dataset.dragSublabel||"",this.sourceRowEl=r||null,this.startX=t.clientX,this.startY=t.clientY,this.isDragStarted=!1,document.addEventListener("pointermove",this.boundPointerMove),document.addEventListener("pointerup",this.boundPointerUp),document.addEventListener("keydown",this.boundKeyDown)}onPointerMove(t){const i=t.clientX-this.startX,s=t.clientY-this.startY;if(!this.isDragStarted){if(Math.sqrt(i*i+s*s)<5)return;this.beginDrag()}this.moveOverlay(t.clientX,t.clientY),this.updateInsertionPoint(t.clientY),this.handleAutoScroll(t.clientY)}onPointerUp(){this.isDragStarted&&this.currentState.insertionPoint&&this.currentState.dragItem&&this.callbacks.onDrop(this.currentState.dragItem,this.currentState.insertionPoint),this.cleanup()}onKeyDown(t){"Escape"===t.key&&this.cleanup()}beginDrag(){var t,i;if(this.isDragStarted=!0,this.fixedOffsetX=0,this.fixedOffsetY=0,this.sourceRowEl){const s=this.sourceRowEl.getBoundingClientRect();if(this.draggedItemHeight=s.height,this.sourceOriginalStyle=this.sourceRowEl.style.cssText,this.slotInsetLeft=0,this.slotInsetRight=0,"filter"===(null===(t=this.pendingItem)||void 0===t?void 0:t.type)){const t=this.sourceRowEl.querySelector(".field-select"),i=this.sourceRowEl.querySelector(".actions");t&&(this.slotInsetLeft=t.getBoundingClientRect().left-s.left);const e=null==i?void 0:i.previousElementSibling;e&&(this.slotInsetRight=s.right-e.getBoundingClientRect().right)}this.placeholder=document.createElement("div"),this.placeholder.style.height=`${s.height}px`,this.placeholder.style.pointerEvents="none",null===(i=this.sourceRowEl.parentNode)||void 0===i||i.insertBefore(this.placeholder,this.sourceRowEl.nextSibling),this.sourceRowEl.style.position="fixed",this.sourceRowEl.style.top=`${s.top}px`,this.sourceRowEl.style.left=`${s.left+this.slotInsetLeft}px`,this.sourceRowEl.style.width=s.width-this.slotInsetLeft-this.slotInsetRight+"px",this.sourceRowEl.style.height=`${s.height}px`,this.sourceRowEl.style.zIndex="10000",this.sourceRowEl.style.pointerEvents="none",this.sourceRowEl.style.boxSizing="border-box",this.sourceRowEl.classList.add("drag-slot");const e=this.sourceRowEl.getBoundingClientRect();this.fixedOffsetX=e.left-(s.left+this.slotInsetLeft),this.fixedOffsetY=e.top-s.top,0===this.fixedOffsetX&&0===this.fixedOffsetY||(this.sourceRowEl.style.top=s.top-this.fixedOffsetY+"px",this.sourceRowEl.style.left=s.left+this.slotInsetLeft-this.fixedOffsetX+"px"),this.ghostOriginalTop=s.top-this.fixedOffsetY,this.sourceRowEl.style.transition="top 80ms ease-out, left 80ms ease-out, width 80ms ease-out"}this.collectDropTargets(),this.createOverlay(),this.scrollContainer&&this.scrollContainer.addEventListener("scroll",this.boundScroll,{passive:!0}),document.body.style.cursor="grabbing",document.body.style.userSelect="none",this.currentState={isDragging:!0,dragItem:this.pendingItem,insertionPoint:null},this.callbacks.onStateChange(Object.assign({},this.currentState))}cleanup(){this.placeholder&&(this.placeholder.remove(),this.placeholder=null),this.sourceRowEl&&(this.sourceRowEl.style.cssText=this.sourceOriginalStyle,this.sourceRowEl.classList.remove("drag-slot"),this.sourceRowEl=null),this.overlay&&(this.overlay.remove(),this.overlay=null),this.clearGap(),null!==this.autoScrollRAF&&(cancelAnimationFrame(this.autoScrollRAF),this.autoScrollRAF=null),this.scrollContainer&&this.scrollContainer.removeEventListener("scroll",this.boundScroll),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("pointermove",this.boundPointerMove),document.removeEventListener("pointerup",this.boundPointerUp),document.removeEventListener("keydown",this.boundKeyDown),this.pendingItem=null,this.pendingLabel="",this.pendingSublabel="",this.isDragStarted=!1,this.dropTargets=[],this.draggedItemHeight=0,this.ghostOriginalTop=0,this.sourceOriginalStyle="",this.lockedTarget=null;const t=this.currentState.isDragging;this.currentState={isDragging:!1,dragItem:null,insertionPoint:null},t&&this.callbacks.onStateChange(Object.assign({},this.currentState))}createOverlay(){var t;this.overlay=document.createElement("div"),this.overlay.className="drag-overlay";const i=document.createElement("span");i.className="drag-overlay-grip",i.textContent="⠿";const s=document.createElement("div");s.className="drag-overlay-text";const e=document.createElement("span");if(e.className="drag-overlay-label",e.textContent=this.pendingLabel,s.appendChild(e),this.pendingSublabel){const t=document.createElement("span");t.className="drag-overlay-sub",t.textContent=this.pendingSublabel,s.appendChild(t)}this.overlay.append(i,s),null===(t=this.hostEl.shadowRoot)||void 0===t||t.appendChild(this.overlay)}moveOverlay(t,i){this.overlay&&(this.overlay.style.left=t+12-this.fixedOffsetX+"px",this.overlay.style.top=i-20-this.fixedOffsetY+"px")}positionGhost(t,i){if(!this.sourceRowEl)return;const s=this.getGapElement(t,i).getBoundingClientRect();let e;e="before"===i?s.top-this.draggedItemHeight:s.bottom;const o=this.getGhostReferenceRect(t,i);this.sourceRowEl.style.top=e-this.fixedOffsetY+"px",this.sourceRowEl.style.left=o.left+this.slotInsetLeft-this.fixedOffsetX+"px",this.sourceRowEl.style.width=o.width-this.slotInsetLeft-this.slotInsetRight+"px"}getGhostReferenceRect(t,i){if("group"===t.type&&"after"===i){const i=t.element.nextElementSibling;if(i){const t=Array.from(i.querySelectorAll(".filter-row, udp-advanced-search-filter-group"));for(const i of t)if(i!==this.sourceRowEl)return i.getBoundingClientRect();const s=i.querySelector(".add-new-container");if(s)return s.getBoundingClientRect()}}return t.element.getBoundingClientRect()}resetGhostPosition(){this.sourceRowEl&&(this.sourceRowEl.style.top=`${this.ghostOriginalTop}px`)}getGapElement(t,i){if("filter"===t.type)return t.element;if("after"===i)return t.element;const s=t.element.getRootNode();return s instanceof ShadowRoot&&s.host?s.host:t.element}applyGap(t,i){this.placeholder&&(this.placeholder.style.height="0px");const s=this.getGapElement(t,i);for(const t of this.previousGapEls)t!==s&&(t.style.marginTop="",t.style.marginBottom="");s.style.marginTop="",s.style.marginBottom="","before"===i?s.style.marginTop=`${this.draggedItemHeight}px`:s.style.marginBottom=`${this.draggedItemHeight}px`,this.previousGapEls=[s]}clearGap(){for(const t of this.previousGapEls)t.style.marginTop="",t.style.marginBottom="";this.previousGapEls=[],this.placeholder&&(this.placeholder.style.height=`${this.draggedItemHeight}px`)}collectDropTargets(){var t;this.dropTargets=[];const i=this.pendingItem,s=t=>{const e=t.shadowRoot;if(!e)return;e.querySelectorAll(".filter-row[data-filter-id]").forEach((t=>{const s=t.dataset.filterId;"filter"===(null==i?void 0:i.type)&&i.id===s||this.dropTargets.push({type:"filter",id:s,element:t,rect:t.getBoundingClientRect(),midY:0})}));const o=e.querySelector(".group-box[data-group-id]");if(o&&!o.classList.contains("root-group")){const t=o.dataset.groupId;if("group"!==(null==i?void 0:i.type)||i.id!==t){const i=o.querySelector(":scope > .group-header");i&&this.dropTargets.push({type:"group",id:t,element:i,rect:i.getBoundingClientRect(),midY:0})}}e.querySelectorAll("udp-advanced-search-filter-group").forEach((t=>s(t)))},e=null===(t=this.hostEl.shadowRoot)||void 0===t?void 0:t.querySelector("udp-advanced-search-filter-group");e&&s(e);for(const t of this.dropTargets)t.midY=t.rect.top+t.rect.height/2;this.dropTargets.sort(((t,i)=>t.rect.top-i.rect.top))}updateInsertionPoint(t){var i,s;if(0===this.dropTargets.length)return this.clearGap(),this.resetGhostPosition(),this.lockedTarget=null,void this.commitInsertionPoint(null);let e=null,o="before";for(const i of this.dropTargets){const s=i.element.getBoundingClientRect();if(t>=s.top&&t<=s.bottom){e=i,o=t<s.top+s.height/2?"before":"after";break}}if(!e){const r=null===(i=this.dropTargets[0])||void 0===i?void 0:i.element,n=null===(s=this.dropTargets[this.dropTargets.length-1])||void 0===s?void 0:s.element;if(r&&t<r.getBoundingClientRect().top)e=this.dropTargets[0],o="before";else{if(!(n&&t>n.getBoundingClientRect().bottom))return;e=this.dropTargets[this.dropTargets.length-1],o="after"}}if("before"===o){const t=this.dropTargets.indexOf(e);t>0&&(e=this.dropTargets[t-1],o="after")}if(e===this.lockedTarget&&o===this.lockedPosition)return;const r=this.currentState.dragItem||this.pendingItem;if(this.callbacks.isValidDrop&&r&&!this.callbacks.isValidDrop(r,e.type,e.id))return this.clearGap(),this.resetGhostPosition(),this.lockedTarget=null,void this.commitInsertionPoint(null);this.lockedTarget=e,this.lockedPosition=o,this.applyGap(e,o),this.positionGhost(e,o),this.commitInsertionPoint({position:o,targetId:e.id,targetType:e.type})}commitInsertionPoint(t){const i=this.currentState.insertionPoint;(null==i?void 0:i.position)===(null==t?void 0:t.position)&&(null==i?void 0:i.targetId)===(null==t?void 0:t.targetId)&&(null==i?void 0:i.targetType)===(null==t?void 0:t.targetType)||(this.currentState=Object.assign(Object.assign({},this.currentState),{insertionPoint:t}),this.callbacks.onStateChange(Object.assign({},this.currentState)))}handleAutoScroll(t){if(!this.scrollContainer)return;const i=this.scrollContainer.getBoundingClientRect(),s=t-i.top,e=i.bottom-t;let o=0;if(s>0&&s<50?o=-10*(1-s/50):e>0&&e<50&&(o=10*(1-e/50)),null!==this.autoScrollRAF&&(cancelAnimationFrame(this.autoScrollRAF),this.autoScrollRAF=null),0!==o){const t=()=>{this.scrollContainer&&(this.scrollContainer.scrollTop+=o,this.refreshDropTargetRects(),this.autoScrollRAF=requestAnimationFrame(t))};this.autoScrollRAF=requestAnimationFrame(t)}}onScroll(){this.refreshDropTargetRects()}refreshDropTargetRects(){for(const t of this.dropTargets)t.rect=t.element.getBoundingClientRect(),t.midY=t.rect.top+t.rect.height/2}}const k=class{constructor(s){t(this,s),this.filterSave=i(this,"filterSave",7),this.searchChange=i(this,"searchChange",7),this.validityChange=i(this,"validityChange",7),this.config={},this.maxDepth=2,this.showClearButton=!1,this.loading=!1,this.fieldsArray=[],this.extraFieldGroups=[],this.extraFieldsLoading=!1,this.extraFieldsRequestId=0,this.openAddMenuForGroupId=null,this.filterString="",this.isExpanded=!0,this.isFilterValid=!0,this.errorMessages=[],this.attentionErrors=[],this.rootEntityLabel="",this.nextGroupId=1,this.handleFieldPick=t=>{this.addFilterForPath(t.detail.path,t.detail.type)},this.handleSearch=()=>{this.isFilterValid&&this.filterSave?(this.filterSave.emit(this.currentFilterData),this.filterString=w(this.currentFilterData),this.config.collapsible&&this.toggleExpanded()):console.warn("Cannot run search: filter is invalid.")},this.handleClear=()=>{const t=this.getNormalizedData(Object.assign(Object.assign({},this.currentFilterData),{filterElements:[],filterGroups:[]}));this.currentFilterData=t,this.isFilterValid=!0,this.errorMessages=[],this.attentionErrors=[],this.searchChange.emit(t),this.validityChange.emit({isValid:!0,errors:[],attentionErrors:[]}),this.filterSave&&(this.filterSave.emit(t),this.filterString=w(t)),this.config.collapsible&&this.toggleExpanded()},this.toggleExpanded=()=>{this.isExpanded=!this.isExpanded,this.updateHostClasses()},this.handleToggleAddMenu=t=>{const i=t.detail;if(this.openAddMenuForGroupId=this.openAddMenuForGroupId===i?null:i,null!==this.openAddMenuForGroupId){const t=this.animContainerEl;t&&requestAnimationFrame((()=>{t.scrollTop=t.scrollHeight}))}},this.handleDragStateChange=()=>{},this.isValidDragDrop=(t,i,s)=>{if("group"===t.type&&"group"===i){const i=parseInt(t.id,10),e=parseInt(s,10);if(i===e)return!1;if(this.isDescendant(e,i,this.currentFilterData.filterGroups))return!1}if("group"===t.type&&"filter"===i){const i=parseInt(t.id,10),e=this.currentFilterData.filterElements.find((t=>t._id===s));if(e){const t=e.groupId;if(t===i||this.isDescendant(t,i,this.currentFilterData.filterGroups))return!1}}return!0},this.handleDragDrop=(t,i)=>{this.runUpdateCycle((s=>{"filter"===t.type?this.applyFilterDrop(s,t,i):"group"===t.type&&this.applyGroupDrop(s,t,i)}))},this.handleAddFilter=t=>{this.runUpdateCycle((i=>{var s,e;const o=null===(s=this.fieldsArray)||void 0===s?void 0:s[0],r=d(o,this.config.operators),n=(null===(e=null==r?void 0:r[0])||void 0===e?void 0:e.value)||"";i.filterElements.push({_id:`filter_${Math.random()}`,_type:null==o?void 0:o.type,groupId:t,searchField:null==o?void 0:o.name,searchOperator:n,searchValue:""})})),this.openAddMenuForGroupId=null},this.handleAddGroup=t=>{this.runUpdateCycle((i=>{i.filterGroups.push({groupId:this.nextGroupId++,parentGroupId:t,logicalSearchOperator:r.AND})})),this.openAddMenuForGroupId=null},this.handleRemoveFilter=t=>{this.runUpdateCycle((i=>{const s=i.filterElements.findIndex((i=>i._id===t));s>-1&&i.filterElements.splice(s,1)}))},this.handleRemoveGroup=t=>{this.runUpdateCycle((i=>{const s=t=>{const e=i.filterGroups.filter((i=>i.parentGroupId===t));let o=e.map((t=>t.groupId));return e.forEach((t=>{o=[...o,...s(t.groupId)]})),o},e=[t,...s(t)];i.filterGroups=i.filterGroups.filter((t=>!e.includes(t.groupId))),i.filterElements=i.filterElements.filter((t=>!e.includes(t.groupId)))}))},this.handleFilterChange=t=>{const{filterId:i,field:s,value:e,updates:o}=t.detail;this.runUpdateCycle((t=>{const r=t.filterElements.find((t=>t._id===i));r&&(o?Object.assign(r,o):(r[s]=e,"searchValue"===s&&(r._touched=!0)))}))},this.handleDepthChange=t=>{const i=t.detail;"number"==typeof i&&i!==this.currentMaxDepth&&(this.currentMaxDepth=i,this.buildFieldTree())},this.handleGroupChange=t=>{const{groupId:i,logicalSearchOperator:s}=t.detail;this.runUpdateCycle((t=>{const e=t.filterGroups.find((t=>t.groupId===i));e&&(e.logicalSearchOperator=s)}))}}buildFieldTree(){var t;if(this.entityName&&this.catalogObjectList){const i=l(this.entityName),s=i[0].toUpperCase()+i.slice(1);this.rootEntityLabel=s,this.fieldsArray=c(u(p(this.catalogObjectList,s,this.currentMaxDepth,this.associations),this.includeFields,this.excludeFields),[...this.extraFieldGroups,...null!==(t=this.virtualFields)&&void 0!==t?t:[]])}}async loadExtraFields(){var t,i,s,e,o;const r=++this.extraFieldsRequestId,n=null!==(i=null===(t=this.extraFields)||void 0===t?void 0:t.domainName)&&void 0!==i?i:this.entityName;if(!this.extraFields||!n)return this.extraFieldGroups.length&&(this.extraFieldGroups=[]),void(this.extraFieldsLoading=!1);const l=null!==(s=this.extraFields.prefix)&&void 0!==s?s:y;this.buildFieldTree();const h=[{path:"",domainName:n,definitions:this.extraFields.definitions,context:v(this.extraFields)}];for(const t of null!==(e=this.associations)&&void 0!==e?e:[]){const i=this.resolveAssociationPath(t),s=null!==(o=null==i?void 0:i.node.displayName)&&void 0!==o?o:null==i?void 0:i.node.name;i&&s&&h.push({path:i.path,domainName:s})}this.extraFieldsLoading=!0;try{const t=await Promise.all(h.map((async t=>{try{const i=t.context?await g(t.domainName,t.context):t.definitions?m(t.definitions):await b(t.domainName);return x(i,l,t.path)}catch(i){return console.error(`Failed to load extra-field definitions for ${t.domainName}:`,i),null}})));if(r!==this.extraFieldsRequestId)return;this.extraFieldGroups=t.filter((t=>null!==t))}finally{r===this.extraFieldsRequestId&&(this.extraFieldsLoading=!1)}}resolveAssociationPath(t){var i,s;let e=this.fieldsArray,o=null;const r=[];for(const n of t.split(".")){if(o=null!==(i=e.find((t=>t.name.toLowerCase()===n.toLowerCase())))&&void 0!==i?i:null,!o)return null;r.push(o.name),e=null!==(s=o.childFields)&&void 0!==s?s:[]}return o?{node:o,path:r.join(".")}:null}reloadExtraFields(){this.loadExtraFields()}rebuildFieldTree(){this.buildFieldTree(),this.currentFilterData&&(this.currentFilterData=this.getNormalizedData(this.currentFilterData))}syncMaxDepth(t){this.currentMaxDepth=t,this.buildFieldTree()}syncAssociations(){this.buildFieldTree()}syncInitialFilterData(t){this.currentFilterData=this.getNormalizedData(t),this.updateNextGroupId(this.currentFilterData)}componentWillLoad(){this.currentMaxDepth=this.maxDepth,this.buildFieldTree(),this.currentFilterData=this.getNormalizedData(this.initialFilterData),this.updateNextGroupId(this.currentFilterData),this.loadExtraFields()}componentDidLoad(){this.updateHostClasses(),this.dragManager=new F(this.el,{onStateChange:this.handleDragStateChange,onDrop:this.handleDragDrop,isValidDrop:this.isValidDragDrop}),this.animContainerEl&&this.dragManager.setScrollContainer(this.animContainerEl)}disconnectedCallback(){var t;null===(t=this.dragManager)||void 0===t||t.destroy()}async addFilterElement(t,i){this.addFilterForPath(t,i)}async submitSearch(){this.handleSearch()}async clearFilters(){this.handleClear()}addFilterForPath(t,i){var s,e,o;const r=new Set(["object","array"]),n=f(this.fieldsArray,t),l=null!==(e=null!==(s=null==n?void 0:n.type)&&void 0!==s?s:null==i?void 0:i.toLowerCase())&&void 0!==e?e:"string";if(r.has(l))return;const h=d(null!=n?n:{type:l},this.config.operators),a=(null===(o=null==h?void 0:h[0])||void 0===o?void 0:o.value)||"=",c=this.currentFilterData.filterGroups.find((t=>null===t.parentGroupId));this.runUpdateCycle((i=>{var s;i.filterElements.push({_id:`filter_${Math.random()}`,_type:l,groupId:null!==(s=null==c?void 0:c.groupId)&&void 0!==s?s:1,searchField:t,searchOperator:a,searchValue:"boolean"===l?"true":""})}))}updateHostClasses(){this.isExpanded?(this.el.classList.add("host-expanded"),this.el.classList.remove("host-collapsed")):(this.el.classList.add("host-collapsed"),this.el.classList.remove("host-expanded"),this.el.style.height=null)}updateNextGroupId(t){this.nextGroupId=t&&t.filterGroups.length>0?Math.max(...t.filterGroups.map((t=>t.groupId)))+1:2}verifyFilterState(t){const i=[],s=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;for(const s of t.filterGroups){if(null===s.parentGroupId)continue;const e=t.filterElements.some((t=>t.groupId===s.groupId)),o=t.filterGroups.some((t=>t.parentGroupId===s.groupId));e||o||i.push("A group has no filters. Add a filter or remove the group.")}return t.filterElements.forEach((t=>{var e,o;delete t._error;const r=null==t.searchField||""===t.searchField,l=!t.searchValue,a=t.searchOperator===n.NULL||t.searchOperator===n.NOT_NULL,d=h(null!==(o=null===(e=t.searchField)||void 0===e?void 0:e.split(".").pop())&&void 0!==o?o:"");if(r){const s="A filter is missing its field.";t._error=s,i.push(s)}else if(t.searchOperator===n.BETWEEN){const s=(t.searchValue||"").split(",");if(2!==s.length||!s[0]||!s[1]){const s=`"${d}" needs two values (from and to).`;t._error=s,i.push(s)}}else if(l&&!a){const s=`"${d}" needs a value.`;t._error=s,i.push(s)}else if("guid"===t._type&&!l&&!s.test(t.searchValue)){const s=`"${d}" needs a valid GUID.`;t._error=s,i.push(s)}})),{isValid:0===i.length,errors:i}}stampFilterElements(t){const i=new Set(t.map((t=>t._id)).filter(Boolean));return t.map(((t,s)=>{var e;const o=Object.assign({},t);if(!o._id){const t=`filter_ext_${null!==(e=o.groupId)&&void 0!==e?e:"root"}_${s}`;let r=t,n=1;for(;i.has(r);)r=`${t}_${n++}`;i.add(r),o._id=r}if(!o._type){const t=f(this.fieldsArray,o.searchField);(null==t?void 0:t.type)&&(o._type=t.type)}return o}))}getNormalizedData(t){var i,s,e;if(t&&(null===(i=t.filterGroups)||void 0===i?void 0:i.length)>0)return Object.assign(Object.assign({},t),{filterGroups:[...t.filterGroups],filterElements:this.stampFilterElements(null!==(s=t.filterElements)&&void 0!==s?s:[])});if(t&&(null===(e=t.filterElements)||void 0===e?void 0:e.length)>0){const i=1;return Object.assign(Object.assign({},t),{filterGroups:[{groupId:i,parentGroupId:null,logicalSearchOperator:t.logicalSearchOperator||r.AND}],filterElements:this.stampFilterElements(t.filterElements.map((t=>Object.assign(Object.assign({},t),{groupId:i}))))})}return Object.assign(Object.assign({},t),{logicalSearchOperator:r.AND,filterGroups:[{groupId:1,parentGroupId:null,logicalSearchOperator:r.AND}],filterElements:[]})}runUpdateCycle(t){const i=JSON.parse(JSON.stringify(this.currentFilterData));t(i),this.currentFilterData=i;const s=this.verifyFilterState(i);this.isFilterValid=s.isValid,this.errorMessages=s.errors,this.attentionErrors=i.filterElements.filter((t=>t._error&&t._touched)).map((t=>t._error)),this.searchChange.emit(i),this.validityChange.emit({isValid:this.isFilterValid,errors:this.errorMessages,attentionErrors:this.attentionErrors})}applyFilterDrop(t,i,s){const e=t.filterElements.find((t=>t._id===i.id));if(!e)return;const o=t.filterElements.indexOf(e);if(t.filterElements.splice(o,1),"filter"===s.targetType){const i=t.filterElements.find((t=>t._id===s.targetId));if(!i)return void t.filterElements.push(e);e.groupId=i.groupId;const o=t.filterElements.indexOf(i);t.filterElements.splice("before"===s.position?o:o+1,0,e)}else{const i=parseInt(s.targetId,10),o=t.filterGroups.find((t=>t.groupId===i));e.groupId="before"===s.position&&null!=(null==o?void 0:o.parentGroupId)?o.parentGroupId:i,t.filterElements.push(e)}}applyGroupDrop(t,i,s){const e=parseInt(i.id,10),o=t.filterGroups.find((t=>t.groupId===e));if(o)if("group"===s.targetType){const i=parseInt(s.targetId,10);if(this.isDescendant(i,e,t.filterGroups))return;if(e===i)return;const r=t.filterGroups.find((t=>t.groupId===i));if(!r)return;o.parentGroupId="before"===s.position?r.parentGroupId:i;const n=t.filterGroups.indexOf(o);t.filterGroups.splice(n,1);const l=t.filterGroups.indexOf(r);t.filterGroups.splice("before"===s.position?l:l+1,0,o)}else if("filter"===s.targetType){const i=t.filterElements.find((t=>t._id===s.targetId));i&&(o.parentGroupId=i.groupId)}}isDescendant(t,i,s){let e=s.find((i=>i.groupId===t));for(;e&&null!==e.parentGroupId;){if(e.parentGroupId===i)return!0;e=s.find((t=>t.groupId===e.parentGroupId))}return!1}get depthFixed(){var t,i;return(null!==(i=null===(t=this.associations)||void 0===t?void 0:t.length)&&void 0!==i?i:0)>0||this.maxDepth<1}renderFilterRows(){const t=!0===this.config.collapsible,i=this.currentFilterData.filterGroups.find((t=>null===t.parentGroupId));return s("div",{class:"anim-container",ref:t=>this.animContainerEl=t},s("div",{class:"content-wrapper"},(this.isExpanded||!t)&&i&&s("udp-advanced-search-filter-group",{key:i.groupId,groupId:i.groupId,filterData:this.currentFilterData,fields:this.fieldsArray,isRoot:!0,flat:!0===this.config.flat,operators:this.config.operators,freeFormFields:!0===this.config.freeFormFields,maxDepth:this.currentMaxDepth,showDepthSelector:!(this.depthFixed||!0===this.config.showFieldPicker&&"tree"===this.config.fieldPickerView),onAddFilter:t=>this.handleAddFilter(t.detail),onAddGroup:t=>this.handleAddGroup(t.detail),onRemoveFilter:t=>this.handleRemoveFilter(t.detail),onRemoveGroup:t=>this.handleRemoveGroup(t.detail),onFilterChange:this.handleFilterChange,onGroupChange:this.handleGroupChange,onDepthChange:this.handleDepthChange,openAddMenuForGroupId:this.openAddMenuForGroupId,onToggleAddMenu:this.handleToggleAddMenu})))}renderActions(){return[s("udp-fluent-button",{disabled:!this.isFilterValid,onClick:this.handleSearch,appearance:"primary"},"Search"),this.showClearButton&&s("udp-fluent-button",{appearance:"subtle",onClick:this.handleClear},"Clear"),!this.isFilterValid&&s("udp-text",{variant:"caption1",class:{"footer-status":!0,"is-attention":this.attentionErrors.length>0}},this.attentionErrors.length>1?`${this.attentionErrors.length} filters need attention`:1===this.attentionErrors.length?this.attentionErrors[0]:this.errorMessages.length>1?`${this.errorMessages.length} filters to complete`:"1 filter to complete")]}render(){if(this.loading||this.extraFieldsLoading)return s(e,{class:{"is-loading":!0}},s("div",{class:"advanced-filter-loading"},s("udp-spinner",{size:"large"}),s("span",{class:"advanced-filter-loading-label"},"Loading filters…")));const t=!0===this.config.collapsible,i=!1!==this.config.resizable,o=!1!==this.config.showFooter,r=!0===this.config.showFieldPicker,n=r&&"tree"===this.config.fieldPickerView,l={"advanced-filter-container":!0,"is-expanded":this.isExpanded},h={};return this.isExpanded&&this.config.height&&(h.height=this.config.height),s(e,{style:h,class:{"is-resizable":i,"host-expanded":this.isExpanded,"host-collapsed":!this.isExpanded}},s("div",{class:l},t&&s("div",{class:"collapsed-view"},s("udp-fluent-text-input",{value:this.filterString,readonly:!0,appearance:"filled-darker",includeErrorPadding:!1,class:"string-display-input"}),s("udp-fluent-button",{class:"toggle-button",size:"small",appearance:"transparent",onClick:this.toggleExpanded},s("span",null,this.isExpanded?"Collapse":"Expand"),s("svg",{class:"toggle-icon",viewBox:"0 0 16 16",slot:"end"},s("path",{d:"M4 6L8 10L12 6",stroke:"currentColor","stroke-width":"2"})))),s("div",{class:{"filter-body":!0,"has-field-picker":r,"tree-picker":n}},!n||!this.isExpanded&&t?[this.renderFilterRows(),r&&(this.isExpanded||!t)&&s("udp-advanced-search-field-picker",{class:"field-picker",fields:this.fieldsArray,rootLabel:this.rootEntityLabel,onFieldPick:this.handleFieldPick})]:s("udp-sidebar-layout",{class:"picker-layout",sidebarPosition:"end",collapsible:!1,resizable:!0,fill:!0,sidebarWidth:"340px",minSidebarWidth:260,maxSidebarWidth:640},this.renderFilterRows(),s("udp-advanced-search-field-picker-tree",{slot:"sidebar",class:"field-picker",fields:this.fieldsArray,rootLabel:this.rootEntityLabel,depth:this.currentMaxDepth,showDepth:!this.depthFixed,onFieldPick:this.handleFieldPick,onDepthChange:this.handleDepthChange}))),o&&s("div",{class:"advanced-filter-footer"},this.renderActions())))}get el(){return o(this)}static get watchers(){return{extraFields:[{reloadExtraFields:0}],entityName:[{reloadExtraFields:0},{rebuildFieldTree:0}],associations:[{reloadExtraFields:0},{syncAssociations:0}],catalogObjectList:[{reloadExtraFields:0},{rebuildFieldTree:0}],extraFieldGroups:[{rebuildFieldTree:0}],includeFields:[{rebuildFieldTree:0}],excludeFields:[{rebuildFieldTree:0}],virtualFields:[{rebuildFieldTree:0}],maxDepth:[{syncMaxDepth:0}],initialFilterData:[{syncInitialFilterData:0}]}}};k.style=":host{display:flex;flex-direction:column;box-sizing:border-box;overflow:visible}.advanced-filter-loading{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;min-height:240px;width:100%}.advanced-filter-loading-label{color:var(--colorNeutralForeground3);font-size:var(--fontSizeBase300)}:host(.host-collapsed){resize:none;height:auto}:host(.host-expanded){overflow-y:auto}:host(.is-resizable.host-expanded){resize:vertical;min-height:180px;max-height:80vh;overflow:auto}.advanced-filter-container{display:flex;flex-direction:column;height:100%;width:100%;overflow:hidden}.collapsed-view{display:flex;align-items:center;gap:0.5rem;padding:var(--spacingVerticalS) var(--spacingHorizontalM);border-bottom:1px solid var(--colorNeutralStroke2)}.filter-body{display:flex;flex-direction:column;flex-grow:1;min-height:0;overflow:hidden}.anim-container{flex-grow:1;min-width:0;overflow-y:auto;overflow-x:auto;display:flex}.filter-body.has-field-picker{flex-direction:row;align-items:stretch;gap:var(--spacingHorizontalM)}.filter-body.has-field-picker .anim-container{flex:1 1 0;min-width:0;overflow-y:auto}.filter-body.has-field-picker .field-picker{flex:1 1 0;min-width:0}.filter-body.tree-picker{gap:0}.filter-body.tree-picker .picker-layout{flex:1 1 0;min-width:0;min-height:0}.filter-body.tree-picker .field-picker{height:100%}.filter-body.tree-picker .anim-container{background:var(--colorNeutralBackground2);padding:var(--spacingVerticalL) var(--spacingHorizontalL);min-height:100%;box-sizing:border-box}.content-wrapper{padding-bottom:15px;flex-grow:1}.advanced-filter-footer{display:flex;justify-content:flex-start;border-top:1px solid var(--colorNeutralStroke2);padding:var(--spacingVerticalS) var(--spacingHorizontalM);flex-shrink:0;gap:var(--spacingHorizontalS);align-items:center}.advanced-filter-footer .footer-status{color:var(--colorNeutralForeground3)}.advanced-filter-footer .footer-status.is-attention{color:var(--colorPaletteRedForeground1)}.string-display-input{width:100%}.search-button{opacity:0;transform:scale(0.95);pointer-events:none;margin-right:10px}.advanced-filter-container.is-expanded .anim-container{overflow-y:auto;min-height:130px}.advanced-filter-container.is-expanded .filter-body.has-field-picker .anim-container{min-height:0}.advanced-filter-container.is-expanded .collapsed-view{display:none}.advanced-filter-container.is-expanded .search-button{opacity:1;transform:scale(1);pointer-events:auto}.advanced-filter-container:not(.is-expanded) .anim-container{max-height:0;min-height:0;overflow:hidden}.advanced-filter-container:not(.is-expanded) .advanced-filter-footer{opacity:0;height:0;padding:0;border:none;pointer-events:none;overflow:hidden}.drag-overlay{position:fixed;pointer-events:none;z-index:10001;display:flex;align-items:center;gap:var(--spacingHorizontalS);background:var(--colorNeutralBackground1);border:1px solid var(--colorNeutralStroke2);border-radius:var(--borderRadiusMedium);box-shadow:var(--shadow16);padding:var(--spacingVerticalS) var(--spacingHorizontalM);max-width:260px;box-sizing:border-box}.drag-overlay-grip{flex-shrink:0;color:var(--colorNeutralForeground3);font-size:var(--fontSizeBase400);line-height:1;user-select:none}.drag-overlay-text{display:flex;flex-direction:column;min-width:0}.drag-overlay-label{font-size:var(--fontSizeBase300);line-height:var(--lineHeightBase300);font-weight:var(--fontWeightSemibold);color:var(--colorNeutralForeground1);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.drag-overlay-sub{font-size:var(--fontSizeBase200);line-height:var(--lineHeightBase200);color:var(--colorNeutralForeground3);white-space:nowrap}";export{k as udp_advanced_search_builder}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,c as a,h as t}from"./index-15aY63VA.js";import{h as i,i as l,a as r}from"./udpOperatorHelper-CdVzLL2C.js";import{a as n,L as o}from"./searchObject-DpUZkcYC.js";import{f as s}from"./catalogTree-CeoPZJ2J.js";const d=new Set(["object","array"]),u={default:"other",string:"text",datetime:"date"},c=class{constructor(t){e(this,t),this.fieldPick=a(this,"fieldPick",7),this.fields=[],this.query=""}buildGroups(){var e;const a=[],t=(e,i,l)=>{var r,n;const o=(null!=e?e:[]).filter((e=>{var a;return!(null===(a=e.childFields)||void 0===a?void 0:a.length)&&!d.has(e.type)})).map((e=>{var a;return{path:i?`${i}.${e.name}`:e.name,name:null!==(a=e.displayName)&&void 0!==a?a:e.name,type:e.type}}));if(o.length>0){const e=i.split(".").slice(0,-1).join(".");a.push({path:i,label:l,route:e||void 0,fields:o})}for(const a of null!=e?e:[])(null===(r=a.childFields)||void 0===r?void 0:r.length)&&t(a.childFields,i?`${i}.${a.name}`:a.name,null!==(n=a.displayName)&&void 0!==n?n:a.name)};return t(null!==(e=this.fields)&&void 0!==e?e:[],"",this.rootLabel||"Fields"),a}matchingGroups(){const e=this.buildGroups(),a=this.query.trim().toLowerCase();return a?e.map((e=>Object.assign(Object.assign({},e),{fields:e.fields.filter((e=>e.name.toLowerCase().includes(a)))}))).filter((e=>e.fields.length>0)):e}render(){const e=this.matchingGroups(),a=this.query.trim().length>0;return t("udp-fluent-card",{key:"590212e22e44bbcae2e22f6fff508aceeee1bbf2",class:"schema-card",label:"Schema",height:"100%",bodyPadding:!1},t("udp-search-input",{key:"6a21c49bd166b7935d07850f6f906ecc22f1d426",slot:"header-action",class:"picker-search",value:this.query,placeholder:"Search fields",ariaLabel:"Search fields",includeErrorPadding:!1,onValueChanged:e=>{var a;return this.query=null!==(a=e.detail)&&void 0!==a?a:""}}),t("div",{key:"b6ce300976511a427b22a0d1909bb88c5c0f2b00",class:"picker-body"},0===e.length?t("udp-text",{variant:"caption1",class:"picker-status"},a?"No fields match your search.":"No fields available."):t("udp-container-query-grid",{columns:{0:1,420:2},gaps:{0:"md"}},e.map((e=>t("udp-fluent-card",{key:e.path||"__root__",class:"group",appearance:"outline",label:e.label,subtitle:e.route,bodyPadding:!1,height:"100%"},t("div",{class:"field-scroll"},t("udp-list",{showDivider:!0},e.fields.map((e=>{var a;return t("udp-fluent-list-item",{key:e.path,value:e.path,label:e.name,size:"small",title:e.path},t("udp-text",{slot:"end",variant:"caption1",class:"field-type"},null!==(a=u[e.type])&&void 0!==a?a:e.type),t("udp-fluent-icon-button",{slot:"end",iconName:"add",appearance:"subtle",size:"small",ariaLabel:`Add filter for ${e.name}`,onClick:()=>this.fieldPick.emit({path:e.path,type:e.type})}))}))))))))))}};c.style=":host{display:block;min-height:0;min-width:0;box-sizing:border-box}.schema-card{min-width:0}.picker-body{padding:var(--spacingVerticalS) var(--spacingHorizontalM);overflow-y:auto;height:100%;box-sizing:border-box}.picker-search{flex:1 1 auto;min-width:0;max-width:240px}.picker-status{display:block;color:var(--colorNeutralForeground3)}.group{min-width:0}.field-scroll{flex:1 1 auto;min-height:0;max-height:var(--udp-field-picker-card-max-height, 320px);overflow-y:auto}.field-type{color:var(--colorNeutralForeground3);white-space:nowrap}";const p=e=>"entity"===e.kind,h=class{constructor(i){e(this,i),this.fieldPick=a(this,"fieldPick",7),this.depthChange=a(this,"depthChange",7),this.fields=[],this.showDepth=!1,this.query="",this.renderRowLabel=e=>t("span",{title:e.path},e.label),this.renderRowAside=e=>{var a;return"field"!==e.kind?null:t("udp-text",{variant:"caption1",style:{color:"var(--colorNeutralForeground3)"}},null!==(a=u[e.type])&&void 0!==a?a:e.type)},this.handleItemClick=e=>{const a=e.detail;"field"===(null==a?void 0:a.kind)&&this.fieldPick.emit({path:a.path,type:a.type})}}buildRows(e,a,t,r){var n,o;const s=[],u=[];for(const c of null!=e?e:[]){const e=a?`${a}.${c.name}`:c.name,p=i(null!==(n=c.displayName)&&void 0!==n?n:c.name);if(null===(o=c.childFields)||void 0===o?void 0:o.length){if(l(c.name))continue;const a=`entity:${e}`,i=this.buildRows(c.childFields,e,a,[...r,p]);if(0===i.length)continue;u.push({id:a,parentId:t,kind:"entity",label:p,path:e}),u.push(...i)}else d.has(c.type)||s.push({id:e,parentId:t,kind:"field",label:p,path:e,type:c.type,chain:r.length?r.join(" › "):void 0})}return[...u,...s]}matchingGroups(e){var a,t;const l=this.buildRows(null!==(a=this.fields)&&void 0!==a?a:[],"",void 0,[]).filter((a=>"field"===a.kind&&a.label.toLowerCase().includes(e))),r=new Map;for(const e of l){const a=null!==(t=e.chain)&&void 0!==t?t:"";r.has(a)||r.set(a,[]),r.get(a).push(e)}const n=i(this.rootLabel||"Fields");return[...r.entries()].sort((([e],[a])=>""===e?-1:""===a?1:0)).map((([e,a])=>({chain:""===e?n:e,rows:a})))}renderSearchResults(e){const a=this.matchingGroups(e);return 0===a.length?t("udp-text",{variant:"caption1",class:"picker-status"},"No fields match your search."):a.map((e=>t("div",{class:"result-group",key:e.chain},t("udp-text",{variant:"body1Strong",class:"result-group-label",title:e.chain},e.chain),t("udp-list",{interactive:!0},e.rows.map((e=>{var a;return t("udp-fluent-list-item",{key:e.id,value:e.path,label:e.label,size:"small",interactive:!0,title:e.path,onItemAction:()=>this.fieldPick.emit({path:e.path,type:e.type})},t("udp-text",{slot:"end",variant:"caption1",class:"result-type"},null!==(a=u[e.type])&&void 0!==a?a:e.type),t("udp-fluent-icon-button",{slot:"end",class:"result-add",iconName:"add",appearance:"subtle",size:"small",ariaLabel:`Add filter for ${e.label}`,onClick:()=>this.fieldPick.emit({path:e.path,type:e.type})}))}))))))}render(){var e,a;const i=this.query.trim().toLowerCase(),l=i.length>0,r=l?[]:this.buildRows(null!==(e=this.fields)&&void 0!==e?e:[],"",void 0,[]);return t("div",{key:"c3d0d74de7129e01cce75518b40e03d0889b5f84",class:"rail"},t("div",{key:"84ea521e8d7eda4a872c428e4fab4e265087b853",class:"rail-head"},t("div",{key:"1d9ebad80fda4b05c4c86e7ee74f71ce490c1caa",class:"rail-title-row"},t("udp-text",{key:"4dfd0aca47e989487438a8c475ba2fb7794e1c1d",variant:"body1Strong"},"Fields"),this.showDepth&&t("div",{key:"cbcddfd10b17245c08591321a81bcc052490e754",class:"depth-select"},t("udp-fluent-dropdown",{key:"ed2388413588a2799e9b3df011f9fd5412891ec7",controlSize:"small",appearance:"filled-lighter",includeErrorPadding:!1,clearable:!1,options:[{value:"1",label:"Depth: 1"},{value:"2",label:"Depth: 2"},{value:"3",label:"Depth: 3"}],value:String(null!==(a=this.depth)&&void 0!==a?a:2),onValueChanged:e=>{const a=e.detail,t=parseInt("string"==typeof a?a:null==a?void 0:a.value,10);isNaN(t)||this.depthChange.emit(t)}}))),t("udp-search-input",{key:"9544168ff86b118e7131a8ea6c7a907538b3b282",class:"picker-search",value:this.query,placeholder:"Search fields",ariaLabel:"Search fields",includeErrorPadding:!1,onValueChanged:e=>{var a;return this.query=null!==(a=e.detail)&&void 0!==a?a:""}})),t("div",{key:"9922560813021133e188df9cf1c3e5436b93cae5",class:"picker-body"},l?this.renderSearchResults(i):0===r.length?t("udp-text",{variant:"caption1",class:"picker-status"},"No fields available."):t("udp-tree",{class:"picker-tree",treeItems:r,itemContent:this.renderRowLabel,itemAside:this.renderRowAside,itemRowToggles:p,interaction:"button",collapsible:!0,size:"small",onItemClick:this.handleItemClick})))}};h.style=":host{display:block;min-height:0;min-width:0;box-sizing:border-box}.rail{display:flex;flex-direction:column;height:100%;min-height:0;background:var(--colorNeutralBackground1)}.rail-head{padding:var(--spacingVerticalM) var(--spacingHorizontalM) 0}.rail-title-row{display:flex;align-items:center;justify-content:space-between;gap:var(--spacingHorizontalS);margin-bottom:var(--spacingVerticalS)}.depth-select{width:100px;flex-shrink:0}.picker-search{display:block}.picker-body{padding:var(--spacingVerticalS) var(--spacingHorizontalXS);overflow-y:auto;flex:1 1 auto;min-height:0;box-sizing:border-box}.picker-status{display:block;padding-inline:var(--spacingHorizontalS);color:var(--colorNeutralForeground3)}.picker-tree{min-width:0}.result-group-label{display:block;padding:var(--spacingVerticalM) var(--spacingHorizontalM) var(--spacingVerticalXS);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.result-group:first-child .result-group-label{padding-top:var(--spacingVerticalXS)}.result-type{color:var(--colorNeutralForeground3);white-space:nowrap}.result-add{opacity:0}udp-fluent-list-item:hover .result-add,udp-fluent-list-item:focus-within .result-add{opacity:1}";const g=(e,a="",t="")=>{const r=[];return e.forEach((e=>{var n;const o=e.childFields&&e.childFields.length>0;if(o&&l(e.name))return;const s=a?`${a}.${e.name}`:e.name,d=i(null!==(n=e.displayName)&&void 0!==n?n:e.name),u=t?`${t} · ${d}`:d;r.push({value:s,label:u,disabled:o||void 0}),o&&r.push(...g(e.childFields,s,u))})),r},v=class{constructor(t){e(this,t),this.addFilter=a(this,"addFilter",7),this.addGroup=a(this,"addGroup",7),this.removeFilter=a(this,"removeFilter",7),this.removeGroup=a(this,"removeGroup",7),this.filterChange=a(this,"filterChange",7),this.groupChange=a(this,"groupChange",7),this.toggleAddMenu=a(this,"toggleAddMenu",7),this.depthChange=a(this,"depthChange",7),this.isRoot=!1,this.showDepthSelector=!0,this.flat=!1,this.freeFormFields=!1,this.handleValueChange=(e,a)=>{this.filterChange.emit({filterId:a._id,field:"searchValue",value:e})},this.handleBetweenValueChange=(e,a,t)=>{const i=(a.searchValue||",").split(",");i[t]=e,this.filterChange.emit({filterId:a._id,field:"searchValue",value:i.join(",")})}}countGroupConditions(e){const a=this.filterData.filterElements.filter((a=>a.groupId===e)).length;return this.filterData.filterGroups.filter((a=>a.parentGroupId===e)).reduce(((e,a)=>e+this.countGroupConditions(a.groupId)),a)}getDropdownValue(e){return"object"==typeof e&&null!==e?e.value:String(e)}handleFilterFieldChange(e,a){var t;const i=s(this.fields,a),l=r(i,this.operators);let n="";((null==i?void 0:i.type)||"").toLowerCase().includes("bool")&&(n=!0),this.filterChange.emit({filterId:e._id,updates:{searchField:a,_type:(null==i?void 0:i.type)||"string",searchValue:n}}),l.some((a=>a.value===e.searchOperator))||this.filterChange.emit({filterId:e._id,updates:{searchOperator:(null===(t=null==l?void 0:l[0])||void 0===t?void 0:t.value)||""}})}render(){var e;const a=this.filterData.filterGroups.find((e=>e.groupId===this.groupId));if(!a)return null;const l=this.filterData.filterElements.filter((e=>e.groupId===this.groupId)),d=this.filterData.filterGroups.filter((e=>e.parentGroupId===this.groupId)),u=this.isRoot?0:this.countGroupConditions(this.groupId);return t("div",{class:{"group-box":!0,"root-group":this.isRoot},"data-group-id":String(this.groupId),"data-parent-group-id":null!=a.parentGroupId?String(a.parentGroupId):void 0},t("div",{class:"group-header"},!this.isRoot&&t("span",{class:"drag-handle","data-drag-handle":"","data-drag-type":"group","data-drag-id":String(this.groupId),"data-drag-label":`Group (${a.logicalSearchOperator===o.AND?"all":"any"})`,"data-drag-sublabel":`${u} condition${1===u?"":"s"}`},"⠿"),t("span",{class:"match-text"},"Match"),this.flat?t("span",{class:"match-text"},"all"):t("udp-fluent-dropdown",{class:"logical-op",controlSize:"small",options:[{value:"1",label:"all"},{value:"2",label:"any"}],value:String(a.logicalSearchOperator),appearance:"filled-lighter",includeErrorPadding:!1,clearable:!1,onValueChanged:e=>this.groupChange.emit({groupId:this.groupId,logicalSearchOperator:parseInt(this.getDropdownValue(e.detail))})}),t("span",{class:"match-text"},"of the following"),this.isRoot?this.showDepthSelector&&t("div",{style:{marginLeft:"auto",marginRight:"12px",width:"100px",flexShrink:"0"}},t("udp-fluent-dropdown",{class:"depth-select",controlSize:"small",options:[{value:"1",label:"Depth: 1"},{value:"2",label:"Depth: 2"},{value:"3",label:"Depth: 3"}],value:String(null!==(e=this.maxDepth)&&void 0!==e?e:2),appearance:"filled-lighter",includeErrorPadding:!1,clearable:!1,onValueChanged:e=>this.depthChange.emit(parseInt(this.getDropdownValue(e.detail),10))})):t("div",{class:"actions"},t("udp-fluent-icon-button",{iconName:"dismiss",appearance:"subtle",size:"small",ariaLabel:"Remove group",onClick:()=>this.removeGroup.emit(this.groupId)}))),t("div",{class:"group-content"},l.map((e=>{var a;const l=s(this.fields,e.searchField),o=r(l,this.operators);return t("div",{class:"filter-item",key:e._id},t("div",{class:{"filter-row":!0,"is-invalid":!!e._error&&!!e._touched},"data-filter-id":e._id,"data-group-id":String(this.groupId)},t("span",{class:"drag-handle","data-drag-handle":"","data-drag-type":"filter","data-drag-id":e._id,"data-drag-label":l?i(null!==(a=l.displayName)&&void 0!==a?a:l.name):"Filter"},"⠿"),t("udp-autocomplete",{class:"field-select",options:g(this.fields),optionLabel:"label",optionValue:"value",optionDisabled:"disabled",value:e.searchField,freeForm:this.freeFormFields,placeholder:"Search fields...",clearable:!1,includeErrorPadding:!1,onValueChanged:a=>this.handleFilterFieldChange(e,this.getDropdownValue(a.detail))}),t("udp-fluent-dropdown",{class:"operator-select",options:o,value:e.searchOperator,includeErrorPadding:!1,clearable:!1,onValueChanged:a=>{const t=this.getDropdownValue(a.detail);this.filterChange.emit({filterId:e._id,updates:t===n.NULL||t===n.NOT_NULL||t===n.BETWEEN?{searchOperator:t,searchValue:""}:{searchOperator:t}})}}),((e,a,i,l)=>{const r=null!=l?l:e._type;if(e.searchOperator===n.BETWEEN){const[a,l]=(e.searchValue||",").split(",");return"date"===r?t("div",{class:"value-input between-input-container"},t("udp-date-input",{value:a,includeErrorPadding:!1,onValueChanged:a=>i(a.detail,e,0)}),t("span",null,"and"),t("udp-date-input",{value:l,includeErrorPadding:!1,onValueChanged:a=>i(a.detail,e,1)})):"datetime"===r?t("div",{class:"value-input between-input-container"},t("udp-date-time-input",{value:a,includeErrorPadding:!1,onValueChanged:a=>i(a.detail,e,0)}),t("span",null,"and"),t("udp-date-time-input",{value:l,includeErrorPadding:!1,onValueChanged:a=>i(a.detail,e,1)})):t("div",{class:"value-input between-input-container"},t("udp-fluent-text-input",{value:a,type:"number"===r?"number":"text",includeErrorPadding:!1,onValueChanged:a=>i(a.detail,e,0)}),t("span",null,"and"),t("udp-fluent-text-input",{value:l,type:"number"===r?"number":"text",includeErrorPadding:!1,onValueChanged:a=>i(a.detail,e,1)}))}if(e.searchOperator===n.IN)return t("udp-fluent-text-input",{placeholder:"value1, value2, ...",value:e.searchValue,includeErrorPadding:!1,class:"value-input",onValueChanged:t=>a(t.detail,e)});const o=e.searchOperator===n.NULL||e.searchOperator===n.NOT_NULL;switch(r){case"number":return t("udp-fluent-text-input",{placeholder:"Enter a number value...",type:"number",value:e.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:t=>a(t.detail,e)});case"boolean":return t("udp-fluent-dropdown",{options:[{value:"true",label:"True"},{value:"false",label:"False"}],value:String(e.searchValue),includeErrorPadding:!1,clearable:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:t=>{const i=t.detail;a("object"==typeof i?i.value:i,e)}});case"date":return t("udp-date-input",{value:e.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:t=>a(t.detail,e)});case"datetime":return t("udp-date-time-input",{value:e.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:t=>a(t.detail,e)});case"time":return t("udp-time-input",{value:e.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:t=>a(t.detail,e)});case"guid":return t("udp-fluent-text-input",{placeholder:"Enter a GUID value...",value:e.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:t=>a(t.detail,e)});default:return t("udp-fluent-text-input",{placeholder:"Enter a value...",value:e.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:t=>a(t.detail,e)})}})(e,this.handleValueChange,this.handleBetweenValueChange,null==l?void 0:l.type),t("div",{class:"actions"},t("udp-fluent-icon-button",{class:"row-remove",iconName:"dismiss",appearance:"subtle",size:"small",ariaLabel:"Remove filter",onClick:()=>this.removeFilter.emit(e._id)}))),e._error&&e._touched&&t("udp-text",{variant:"caption2",class:"row-error"},e._error))})),d.map((e=>t("udp-advanced-search-filter-group",{key:e.groupId,groupId:e.groupId,filterData:this.filterData,fields:this.fields,isRoot:!1,operators:this.operators,freeFormFields:this.freeFormFields,openAddMenuForGroupId:this.openAddMenuForGroupId,onAddFilter:e=>{e.stopPropagation(),this.addFilter.emit(e.detail)},onAddGroup:e=>{e.stopPropagation(),this.addGroup.emit(e.detail)},onRemoveFilter:e=>{e.stopPropagation(),this.removeFilter.emit(e.detail)},onRemoveGroup:e=>{e.stopPropagation(),this.removeGroup.emit(e.detail)},onFilterChange:e=>{e.stopPropagation(),this.filterChange.emit(e.detail)},onGroupChange:e=>{e.stopPropagation(),this.groupChange.emit(e.detail)},onToggleAddMenu:e=>{e.stopPropagation(),this.toggleAddMenu.emit(e.detail)}}))),t("div",{class:"add-new-container"},t("udp-fluent-button",{appearance:"transparent",size:"small",onClick:()=>this.addFilter.emit(this.groupId)},"+ Add filter"),!this.flat&&t("udp-fluent-button",{class:"add-group-button",appearance:"transparent",size:"small",onClick:()=>this.addGroup.emit(this.groupId)},"+ Add group"))))}};v.style=":host{display:block}.group-header{display:flex;align-items:center;gap:var(--spacingHorizontalS);padding-block:var(--spacingVerticalXS);position:relative}.match-text{color:var(--colorNeutralForeground2);font-size:var(--fontSizeBase300);flex-shrink:0}.logical-op{width:76px;flex-shrink:0}.group-content{display:flex;flex-direction:column;gap:var(--spacingVerticalS);border-left:2px solid var(--colorNeutralStroke1);padding-left:var(--spacingHorizontalXXL);margin-left:var(--spacingHorizontalXS)}.filter-item{display:flex;flex-direction:column;gap:var(--spacingVerticalXXS)}.filter-row{display:flex;align-items:center;gap:var(--spacingHorizontalS);position:relative;min-height:32px}.field-select{flex:1 1 240px;min-width:140px;max-width:300px}.operator-select{flex:0 0 120px}.value-input{flex:1 1 220px;min-width:170px;max-width:340px}.value-input.is-hidden{visibility:hidden}.between-input-container{display:flex;align-items:center;gap:var(--spacingHorizontalXS);flex:1 1 220px;min-width:260px;max-width:420px}.between-input-container udp-fluent-text-input,.between-input-container udp-date-input,.between-input-container udp-date-time-input,.between-input-container udp-time-input{flex:1;min-width:0}.between-input-container span{font-size:var(--fontSizeBase200);color:var(--colorNeutralForeground3);flex-shrink:0}.drag-handle{font-size:var(--fontSizeBase400);color:var(--colorNeutralForeground3);cursor:grab;flex-shrink:0;user-select:none;touch-action:none;opacity:0;transition:opacity 0.1s ease}.drag-handle:active{cursor:grabbing}.actions{display:flex;gap:var(--spacingHorizontalXXS);flex-shrink:0;opacity:0;transition:opacity 0.1s ease}.filter-row:hover .drag-handle,.filter-row:focus-within .drag-handle,.group-header:hover .drag-handle,.filter-row:hover .actions,.filter-row:focus-within .actions,.group-header:hover .actions,.group-header:focus-within .actions{opacity:1}.filter-row.drag-slot,.group-box.drag-slot{background:var(--colorNeutralBackground2);border:1px dashed var(--colorNeutralStroke2);border-radius:var(--borderRadiusMedium)}.drag-slot>*{visibility:hidden}.row-error{display:block;color:var(--colorPaletteRedForeground1);padding-left:calc(var(--spacingHorizontalL) + var(--spacingHorizontalS))}.is-invalid .value-input{--colorNeutralStroke1:var(--colorPaletteRedBorder2);--colorNeutralStrokeAccessible:var(--colorPaletteRedBorder2)}.add-new-container{display:flex;align-items:center;gap:var(--spacingHorizontalXS)}";export{c as udp_advanced_search_field_picker,h as udp_advanced_search_field_picker_tree,v as udp_advanced_search_filter_group}
|
|
1
|
+
import{r as e,c as a,h as t}from"./index-15aY63VA.js";import{h as i,i as r,a as l}from"./udpOperatorHelper-CdVzLL2C.js";import{a as n,L as o}from"./searchObject-DpUZkcYC.js";import{f as s}from"./catalogTree-CeoPZJ2J.js";const d=new Set(["object","array"]),u={default:"other",string:"text",datetime:"date"},c=class{constructor(t){e(this,t),this.fieldPick=a(this,"fieldPick",7),this.fields=[],this.query=""}buildGroups(){var e;const a=[],t=(e,i,r)=>{var l,n;const o=(null!=e?e:[]).filter((e=>{var a;return!(null===(a=e.childFields)||void 0===a?void 0:a.length)&&!d.has(e.type)})).map((e=>{var a;return{path:i?`${i}.${e.name}`:e.name,name:null!==(a=e.displayName)&&void 0!==a?a:e.name,type:e.type}}));if(o.length>0){const e=i.split(".").slice(0,-1).join(".");a.push({path:i,label:r,route:e||void 0,fields:o})}for(const a of null!=e?e:[])(null===(l=a.childFields)||void 0===l?void 0:l.length)&&t(a.childFields,i?`${i}.${a.name}`:a.name,null!==(n=a.displayName)&&void 0!==n?n:a.name)};return t(null!==(e=this.fields)&&void 0!==e?e:[],"",this.rootLabel||"Fields"),a}matchingGroups(){const e=this.buildGroups(),a=this.query.trim().toLowerCase();return a?e.map((e=>Object.assign(Object.assign({},e),{fields:e.fields.filter((e=>e.name.toLowerCase().includes(a)))}))).filter((e=>e.fields.length>0)):e}render(){const e=this.matchingGroups(),a=this.query.trim().length>0;return t("udp-fluent-card",{key:"590212e22e44bbcae2e22f6fff508aceeee1bbf2",class:"schema-card",label:"Schema",height:"100%",bodyPadding:!1},t("udp-search-input",{key:"6a21c49bd166b7935d07850f6f906ecc22f1d426",slot:"header-action",class:"picker-search",value:this.query,placeholder:"Search fields",ariaLabel:"Search fields",includeErrorPadding:!1,onValueChanged:e=>{var a;return this.query=null!==(a=e.detail)&&void 0!==a?a:""}}),t("div",{key:"b6ce300976511a427b22a0d1909bb88c5c0f2b00",class:"picker-body"},0===e.length?t("udp-text",{variant:"caption1",class:"picker-status"},a?"No fields match your search.":"No fields available."):t("udp-container-query-grid",{columns:{0:1,420:2},gaps:{0:"md"}},e.map((e=>t("udp-fluent-card",{key:e.path||"__root__",class:"group",appearance:"outline",label:e.label,subtitle:e.route,bodyPadding:!1,height:"100%"},t("div",{class:"field-scroll"},t("udp-list",{showDivider:!0},e.fields.map((e=>{var a;return t("udp-fluent-list-item",{key:e.path,value:e.path,label:e.name,size:"small",title:e.path},t("udp-text",{slot:"end",variant:"caption1",class:"field-type"},null!==(a=u[e.type])&&void 0!==a?a:e.type),t("udp-fluent-icon-button",{slot:"end",iconName:"add",appearance:"subtle",size:"small",ariaLabel:`Add filter for ${e.name}`,onClick:()=>this.fieldPick.emit({path:e.path,type:e.type})}))}))))))))))}};c.style=":host{display:block;min-height:0;min-width:0;box-sizing:border-box}.schema-card{min-width:0}.picker-body{padding:var(--spacingVerticalS) var(--spacingHorizontalM);overflow-y:auto;height:100%;box-sizing:border-box}.picker-search{flex:1 1 auto;min-width:0;max-width:240px}.picker-status{display:block;color:var(--colorNeutralForeground3)}.group{min-width:0}.field-scroll{flex:1 1 auto;min-height:0;max-height:var(--udp-field-picker-card-max-height, 320px);overflow-y:auto}.field-type{color:var(--colorNeutralForeground3);white-space:nowrap}";const p=e=>Array.from({length:Math.max(3,e)},((e,a)=>({value:String(a+1),label:`Depth: ${a+1}`}))),h=e=>"entity"===e.kind,g=class{constructor(i){e(this,i),this.fieldPick=a(this,"fieldPick",7),this.depthChange=a(this,"depthChange",7),this.fields=[],this.showDepth=!1,this.query="",this.renderRowLabel=e=>t("span",{title:e.path},e.label),this.renderRowAside=e=>{var a;return"field"!==e.kind?null:t("udp-text",{variant:"caption1",style:{color:"var(--colorNeutralForeground3)"}},null!==(a=u[e.type])&&void 0!==a?a:e.type)},this.handleItemClick=e=>{const a=e.detail;"field"===(null==a?void 0:a.kind)&&this.fieldPick.emit({path:a.path,type:a.type})}}buildRows(e,a,t,l){var n,o;const s=[],u=[];for(const c of null!=e?e:[]){const e=a?`${a}.${c.name}`:c.name,p=i(null!==(n=c.displayName)&&void 0!==n?n:c.name);if(null===(o=c.childFields)||void 0===o?void 0:o.length){if(r(c.name))continue;const a=`entity:${e}`,i=this.buildRows(c.childFields,e,a,[...l,p]);if(0===i.length)continue;u.push({id:a,parentId:t,kind:"entity",label:p,path:e}),u.push(...i)}else d.has(c.type)||s.push({id:e,parentId:t,kind:"field",label:p,path:e,type:c.type,chain:l.length?l.join(" › "):void 0})}return[...u,...s]}matchingGroups(e){var a,t;const r=this.buildRows(null!==(a=this.fields)&&void 0!==a?a:[],"",void 0,[]).filter((a=>"field"===a.kind&&a.label.toLowerCase().includes(e))),l=new Map;for(const e of r){const a=null!==(t=e.chain)&&void 0!==t?t:"";l.has(a)||l.set(a,[]),l.get(a).push(e)}const n=i(this.rootLabel||"Fields");return[...l.entries()].sort((([e],[a])=>""===e?-1:""===a?1:0)).map((([e,a])=>({chain:""===e?n:e,rows:a})))}renderSearchResults(e){const a=this.matchingGroups(e);return 0===a.length?t("udp-text",{variant:"caption1",class:"picker-status"},"No fields match your search."):a.map((e=>t("div",{class:"result-group",key:e.chain},t("udp-text",{variant:"body1Strong",class:"result-group-label",title:e.chain},e.chain),t("udp-list",{interactive:!0},e.rows.map((e=>{var a;return t("udp-fluent-list-item",{key:e.id,value:e.path,label:e.label,size:"small",interactive:!0,title:e.path,onItemAction:()=>this.fieldPick.emit({path:e.path,type:e.type})},t("udp-text",{slot:"end",variant:"caption1",class:"result-type"},null!==(a=u[e.type])&&void 0!==a?a:e.type),t("udp-fluent-icon-button",{slot:"end",class:"result-add",iconName:"add",appearance:"subtle",size:"small",ariaLabel:`Add filter for ${e.label}`,onClick:()=>this.fieldPick.emit({path:e.path,type:e.type})}))}))))))}render(){var e,a,i;const r=this.query.trim().toLowerCase(),l=r.length>0,n=l?[]:this.buildRows(null!==(e=this.fields)&&void 0!==e?e:[],"",void 0,[]);return t("div",{key:"a2a0b02a17a269a48d2b155de5235010f195a7b2",class:"rail"},t("div",{key:"205dbec6ab3e9889dccf97f0320460b6a6aae55a",class:"rail-head"},t("div",{key:"f1c9df3d3747d0381e07e6b5319c8d470ac46b29",class:"rail-title-row"},t("udp-text",{key:"71ecb0a4eda863e600c30674457459fe63aab88d",variant:"body1Strong"},"Fields"),this.showDepth&&t("div",{key:"4c1b8bea4f8257fce3c36ef9edeb509e64587484",class:"depth-select"},t("udp-fluent-dropdown",{key:"187a8658a77e02f37b585f06d4b1e41f09165fd1",controlSize:"small",appearance:"filled-lighter",includeErrorPadding:!1,clearable:!1,options:p(null!==(a=this.depth)&&void 0!==a?a:2),value:String(null!==(i=this.depth)&&void 0!==i?i:2),onValueChanged:e=>{const a=e.detail,t=parseInt("string"==typeof a?a:null==a?void 0:a.value,10);isNaN(t)||this.depthChange.emit(t)}}))),t("udp-search-input",{key:"b8e90390fb83e9db9382d45ce27929fd7db3d86d",class:"picker-search",value:this.query,placeholder:"Search fields",ariaLabel:"Search fields",includeErrorPadding:!1,onValueChanged:e=>{var a;return this.query=null!==(a=e.detail)&&void 0!==a?a:""}})),t("div",{key:"2ef9f1537865ab41536074ad535b464bf3f914b7",class:"picker-body"},l?this.renderSearchResults(r):0===n.length?t("udp-text",{variant:"caption1",class:"picker-status"},"No fields available."):t("udp-tree",{class:"picker-tree",treeItems:n,itemContent:this.renderRowLabel,itemAside:this.renderRowAside,itemRowToggles:h,interaction:"button",collapsible:!0,size:"small",onItemClick:this.handleItemClick})))}};g.style=":host{display:block;min-height:0;min-width:0;box-sizing:border-box}.rail{display:flex;flex-direction:column;height:100%;min-height:0;background:var(--colorNeutralBackground1)}.rail-head{padding:var(--spacingVerticalM) var(--spacingHorizontalM) 0}.rail-title-row{display:flex;align-items:center;justify-content:space-between;gap:var(--spacingHorizontalS);margin-bottom:var(--spacingVerticalS)}.depth-select{width:100px;flex-shrink:0}.picker-search{display:block}.picker-body{padding:var(--spacingVerticalS) var(--spacingHorizontalXS);overflow-y:auto;flex:1 1 auto;min-height:0;box-sizing:border-box}.picker-status{display:block;padding-inline:var(--spacingHorizontalS);color:var(--colorNeutralForeground3)}.picker-tree{min-width:0}.result-group-label{display:block;padding:var(--spacingVerticalM) var(--spacingHorizontalM) var(--spacingVerticalXS);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.result-group:first-child .result-group-label{padding-top:var(--spacingVerticalXS)}.result-type{color:var(--colorNeutralForeground3);white-space:nowrap}.result-add{opacity:0}udp-fluent-list-item:hover .result-add,udp-fluent-list-item:focus-within .result-add{opacity:1}";const v=(e,a="",t="")=>{const l=[];return e.forEach((e=>{var n;const o=e.childFields&&e.childFields.length>0;if(o&&r(e.name))return;const s=a?`${a}.${e.name}`:e.name,d=i(null!==(n=e.displayName)&&void 0!==n?n:e.name),u=t?`${t} · ${d}`:d;l.push({value:s,label:u,disabled:o||void 0}),o&&l.push(...v(e.childFields,s,u))})),l},f=class{constructor(t){e(this,t),this.addFilter=a(this,"addFilter",7),this.addGroup=a(this,"addGroup",7),this.removeFilter=a(this,"removeFilter",7),this.removeGroup=a(this,"removeGroup",7),this.filterChange=a(this,"filterChange",7),this.groupChange=a(this,"groupChange",7),this.toggleAddMenu=a(this,"toggleAddMenu",7),this.depthChange=a(this,"depthChange",7),this.isRoot=!1,this.showDepthSelector=!0,this.flat=!1,this.freeFormFields=!1,this.handleValueChange=(e,a)=>{this.filterChange.emit({filterId:a._id,field:"searchValue",value:e})},this.handleBetweenValueChange=(e,a,t)=>{const i=(a.searchValue||",").split(",");i[t]=e,this.filterChange.emit({filterId:a._id,field:"searchValue",value:i.join(",")})}}countGroupConditions(e){const a=this.filterData.filterElements.filter((a=>a.groupId===e)).length;return this.filterData.filterGroups.filter((a=>a.parentGroupId===e)).reduce(((e,a)=>e+this.countGroupConditions(a.groupId)),a)}getDropdownValue(e){return"object"==typeof e&&null!==e?e.value:String(e)}handleFilterFieldChange(e,a){var t;const i=s(this.fields,a),r=l(i,this.operators);let n="";((null==i?void 0:i.type)||"").toLowerCase().includes("bool")&&(n=!0),this.filterChange.emit({filterId:e._id,updates:{searchField:a,_type:(null==i?void 0:i.type)||"string",searchValue:n}}),r.some((a=>a.value===e.searchOperator))||this.filterChange.emit({filterId:e._id,updates:{searchOperator:(null===(t=null==r?void 0:r[0])||void 0===t?void 0:t.value)||""}})}render(){var e,a;const r=this.filterData.filterGroups.find((e=>e.groupId===this.groupId));if(!r)return null;const d=this.filterData.filterElements.filter((e=>e.groupId===this.groupId)),u=this.filterData.filterGroups.filter((e=>e.parentGroupId===this.groupId)),c=this.isRoot?0:this.countGroupConditions(this.groupId);return t("div",{class:{"group-box":!0,"root-group":this.isRoot},"data-group-id":String(this.groupId),"data-parent-group-id":null!=r.parentGroupId?String(r.parentGroupId):void 0},t("div",{class:"group-header"},!this.isRoot&&t("span",{class:"drag-handle","data-drag-handle":"","data-drag-type":"group","data-drag-id":String(this.groupId),"data-drag-label":`Group (${r.logicalSearchOperator===o.AND?"all":"any"})`,"data-drag-sublabel":`${c} condition${1===c?"":"s"}`},"⠿"),t("span",{class:"match-text"},"Match"),this.flat?t("span",{class:"match-text"},"all"):t("udp-fluent-dropdown",{class:"logical-op",controlSize:"small",options:[{value:"1",label:"all"},{value:"2",label:"any"}],value:String(r.logicalSearchOperator),appearance:"filled-lighter",includeErrorPadding:!1,clearable:!1,onValueChanged:e=>this.groupChange.emit({groupId:this.groupId,logicalSearchOperator:parseInt(this.getDropdownValue(e.detail))})}),t("span",{class:"match-text"},"of the following"),this.isRoot?this.showDepthSelector&&t("div",{style:{marginLeft:"auto",marginRight:"12px",width:"100px",flexShrink:"0"}},t("udp-fluent-dropdown",{class:"depth-select",controlSize:"small",options:p(null!==(e=this.maxDepth)&&void 0!==e?e:2),value:String(null!==(a=this.maxDepth)&&void 0!==a?a:2),appearance:"filled-lighter",includeErrorPadding:!1,clearable:!1,onValueChanged:e=>this.depthChange.emit(parseInt(this.getDropdownValue(e.detail),10))})):t("div",{class:"actions"},t("udp-fluent-icon-button",{iconName:"dismiss",appearance:"subtle",size:"small",ariaLabel:"Remove group",onClick:()=>this.removeGroup.emit(this.groupId)}))),t("div",{class:"group-content"},d.map((e=>{var a;const r=s(this.fields,e.searchField),o=l(r,this.operators);return t("div",{class:"filter-item",key:e._id},t("div",{class:{"filter-row":!0,"is-invalid":!!e._error&&!!e._touched},"data-filter-id":e._id,"data-group-id":String(this.groupId)},t("span",{class:"drag-handle","data-drag-handle":"","data-drag-type":"filter","data-drag-id":e._id,"data-drag-label":r?i(null!==(a=r.displayName)&&void 0!==a?a:r.name):"Filter"},"⠿"),t("udp-autocomplete",{class:"field-select",options:v(this.fields),optionLabel:"label",optionValue:"value",optionDisabled:"disabled",value:e.searchField,freeForm:this.freeFormFields,placeholder:"Search fields...",clearable:!1,includeErrorPadding:!1,onValueChanged:a=>this.handleFilterFieldChange(e,this.getDropdownValue(a.detail))}),t("udp-fluent-dropdown",{class:"operator-select",options:o,value:e.searchOperator,includeErrorPadding:!1,clearable:!1,onValueChanged:a=>{const t=this.getDropdownValue(a.detail);this.filterChange.emit({filterId:e._id,updates:t===n.NULL||t===n.NOT_NULL||t===n.BETWEEN?{searchOperator:t,searchValue:""}:{searchOperator:t}})}}),((e,a,i,r)=>{const l=null!=r?r:e._type;if(e.searchOperator===n.BETWEEN){const[a,r]=(e.searchValue||",").split(",");return"date"===l?t("div",{class:"value-input between-input-container"},t("udp-date-input",{value:a,includeErrorPadding:!1,onValueChanged:a=>i(a.detail,e,0)}),t("span",null,"and"),t("udp-date-input",{value:r,includeErrorPadding:!1,onValueChanged:a=>i(a.detail,e,1)})):"datetime"===l?t("div",{class:"value-input between-input-container"},t("udp-date-time-input",{value:a,includeErrorPadding:!1,onValueChanged:a=>i(a.detail,e,0)}),t("span",null,"and"),t("udp-date-time-input",{value:r,includeErrorPadding:!1,onValueChanged:a=>i(a.detail,e,1)})):t("div",{class:"value-input between-input-container"},t("udp-fluent-text-input",{value:a,type:"number"===l?"number":"text",includeErrorPadding:!1,onValueChanged:a=>i(a.detail,e,0)}),t("span",null,"and"),t("udp-fluent-text-input",{value:r,type:"number"===l?"number":"text",includeErrorPadding:!1,onValueChanged:a=>i(a.detail,e,1)}))}if(e.searchOperator===n.IN)return t("udp-fluent-text-input",{placeholder:"value1, value2, ...",value:e.searchValue,includeErrorPadding:!1,class:"value-input",onValueChanged:t=>a(t.detail,e)});const o=e.searchOperator===n.NULL||e.searchOperator===n.NOT_NULL;switch(l){case"number":return t("udp-fluent-text-input",{placeholder:"Enter a number value...",type:"number",value:e.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:t=>a(t.detail,e)});case"boolean":return t("udp-fluent-dropdown",{options:[{value:"true",label:"True"},{value:"false",label:"False"}],value:String(e.searchValue),includeErrorPadding:!1,clearable:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:t=>{const i=t.detail;a("object"==typeof i?i.value:i,e)}});case"date":return t("udp-date-input",{value:e.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:t=>a(t.detail,e)});case"datetime":return t("udp-date-time-input",{value:e.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:t=>a(t.detail,e)});case"time":return t("udp-time-input",{value:e.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:t=>a(t.detail,e)});case"guid":return t("udp-fluent-text-input",{placeholder:"Enter a GUID value...",value:e.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:t=>a(t.detail,e)});default:return t("udp-fluent-text-input",{placeholder:"Enter a value...",value:e.searchValue,includeErrorPadding:!1,class:{"value-input":!0,"is-hidden":o},onValueChanged:t=>a(t.detail,e)})}})(e,this.handleValueChange,this.handleBetweenValueChange,null==r?void 0:r.type),t("div",{class:"actions"},t("udp-fluent-icon-button",{class:"row-remove",iconName:"dismiss",appearance:"subtle",size:"small",ariaLabel:"Remove filter",onClick:()=>this.removeFilter.emit(e._id)}))),e._error&&e._touched&&t("udp-text",{variant:"caption2",class:"row-error"},e._error))})),u.map((e=>t("udp-advanced-search-filter-group",{key:e.groupId,groupId:e.groupId,filterData:this.filterData,fields:this.fields,isRoot:!1,operators:this.operators,freeFormFields:this.freeFormFields,openAddMenuForGroupId:this.openAddMenuForGroupId,onAddFilter:e=>{e.stopPropagation(),this.addFilter.emit(e.detail)},onAddGroup:e=>{e.stopPropagation(),this.addGroup.emit(e.detail)},onRemoveFilter:e=>{e.stopPropagation(),this.removeFilter.emit(e.detail)},onRemoveGroup:e=>{e.stopPropagation(),this.removeGroup.emit(e.detail)},onFilterChange:e=>{e.stopPropagation(),this.filterChange.emit(e.detail)},onGroupChange:e=>{e.stopPropagation(),this.groupChange.emit(e.detail)},onToggleAddMenu:e=>{e.stopPropagation(),this.toggleAddMenu.emit(e.detail)}}))),t("div",{class:"add-new-container"},t("udp-fluent-button",{appearance:"transparent",size:"small",onClick:()=>this.addFilter.emit(this.groupId)},"+ Add filter"),!this.flat&&t("udp-fluent-button",{class:"add-group-button",appearance:"transparent",size:"small",onClick:()=>this.addGroup.emit(this.groupId)},"+ Add group"))))}};f.style=":host{display:block}.group-header{display:flex;align-items:center;gap:var(--spacingHorizontalS);padding-block:var(--spacingVerticalXS);position:relative}.match-text{color:var(--colorNeutralForeground2);font-size:var(--fontSizeBase300);flex-shrink:0}.logical-op{width:76px;flex-shrink:0}.group-content{display:flex;flex-direction:column;gap:var(--spacingVerticalS);border-left:2px solid var(--colorNeutralStroke1);padding-left:var(--spacingHorizontalXXL);margin-left:var(--spacingHorizontalXS)}.filter-item{display:flex;flex-direction:column;gap:var(--spacingVerticalXXS)}.filter-row{display:flex;align-items:center;gap:var(--spacingHorizontalS);position:relative;min-height:32px}.field-select{flex:1 1 240px;min-width:140px;max-width:300px}.operator-select{flex:0 0 120px}.value-input{flex:1 1 220px;min-width:170px;max-width:340px}.value-input.is-hidden{visibility:hidden}.between-input-container{display:flex;align-items:center;gap:var(--spacingHorizontalXS);flex:1 1 220px;min-width:260px;max-width:420px}.between-input-container udp-fluent-text-input,.between-input-container udp-date-input,.between-input-container udp-date-time-input,.between-input-container udp-time-input{flex:1;min-width:0}.between-input-container span{font-size:var(--fontSizeBase200);color:var(--colorNeutralForeground3);flex-shrink:0}.drag-handle{font-size:var(--fontSizeBase400);color:var(--colorNeutralForeground3);cursor:grab;flex-shrink:0;user-select:none;touch-action:none;opacity:0;transition:opacity 0.1s ease}.drag-handle:active{cursor:grabbing}.actions{display:flex;gap:var(--spacingHorizontalXXS);flex-shrink:0;opacity:0;transition:opacity 0.1s ease}.filter-row:hover .drag-handle,.filter-row:focus-within .drag-handle,.group-header:hover .drag-handle,.filter-row:hover .actions,.filter-row:focus-within .actions,.group-header:hover .actions,.group-header:focus-within .actions{opacity:1}.filter-row.drag-slot,.group-box.drag-slot{background:var(--colorNeutralBackground2);border:1px dashed var(--colorNeutralStroke2);border-radius:var(--borderRadiusMedium)}.drag-slot>*{visibility:hidden}.row-error{display:block;color:var(--colorPaletteRedForeground1);padding-left:calc(var(--spacingHorizontalL) + var(--spacingHorizontalS))}.is-invalid .value-input{--colorNeutralStroke1:var(--colorPaletteRedBorder2);--colorNeutralStrokeAccessible:var(--colorPaletteRedBorder2)}.add-new-container{display:flex;align-items:center;gap:var(--spacingHorizontalXS)}";export{c as udp_advanced_search_field_picker,g as udp_advanced_search_field_picker_tree,f as udp_advanced_search_filter_group}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The depth selector's options: 1–3, plus the current depth when a host set a
|
|
3
|
+
* deeper one — so the control always shows the depth the tree was built with,
|
|
4
|
+
* never an empty selection.
|
|
5
|
+
*/
|
|
6
|
+
export declare const depthOptions: (depth: number) => {
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
}[];
|
|
@@ -25,6 +25,9 @@ export declare class UdpAdvancedSearchBuilder {
|
|
|
25
25
|
*
|
|
26
26
|
* Ignored when `associations` is set — an explicit association list implies its
|
|
27
27
|
* own depth, so the two never need to be reconciled.
|
|
28
|
+
*
|
|
29
|
+
* `0` pins the tree to the entity's own fields: like `associations`, the host
|
|
30
|
+
* owns the field list then, so no depth selector is shown.
|
|
28
31
|
*/
|
|
29
32
|
maxDepth: number;
|
|
30
33
|
/**
|
|
@@ -218,6 +221,11 @@ export declare class UdpAdvancedSearchBuilder {
|
|
|
218
221
|
private handleDepthChange;
|
|
219
222
|
private handleGroupChange;
|
|
220
223
|
private isDescendant;
|
|
224
|
+
/**
|
|
225
|
+
* The host fixed the field tree — an explicit association list, or depth 0 (own
|
|
226
|
+
* fields only) — so a depth selector would be a control with nothing to change.
|
|
227
|
+
*/
|
|
228
|
+
private get depthFixed();
|
|
221
229
|
private renderFilterRows;
|
|
222
230
|
/**
|
|
223
231
|
* Clear / Search, with a quiet status line explaining a disabled Search — validation
|
|
@@ -3315,7 +3315,7 @@ export namespace Components {
|
|
|
3315
3315
|
*/
|
|
3316
3316
|
"loading": boolean;
|
|
3317
3317
|
/**
|
|
3318
|
-
* The maximum depth to traverse when building the field tree. Ignored when `associations` is set — an explicit association list implies its own depth, so the two never need to be reconciled.
|
|
3318
|
+
* The maximum depth to traverse when building the field tree. Ignored when `associations` is set — an explicit association list implies its own depth, so the two never need to be reconciled. `0` pins the tree to the entity's own fields: like `associations`, the host owns the field list then, so no depth selector is shown.
|
|
3319
3319
|
* @default 2
|
|
3320
3320
|
*/
|
|
3321
3321
|
"maxDepth": number;
|
|
@@ -19605,7 +19605,7 @@ declare namespace LocalJSX {
|
|
|
19605
19605
|
*/
|
|
19606
19606
|
"loading"?: boolean;
|
|
19607
19607
|
/**
|
|
19608
|
-
* The maximum depth to traverse when building the field tree. Ignored when `associations` is set — an explicit association list implies its own depth, so the two never need to be reconciled.
|
|
19608
|
+
* The maximum depth to traverse when building the field tree. Ignored when `associations` is set — an explicit association list implies its own depth, so the two never need to be reconciled. `0` pins the tree to the entity's own fields: like `associations`, the host owns the field list then, so no depth selector is shown.
|
|
19609
19609
|
* @default 2
|
|
19610
19610
|
*/
|
|
19611
19611
|
"maxDepth"?: number;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const t=/^(lut|vw)_/i,e=new Set(["id","gl","url","gps"]),n=n=>{if(!n)return n;const r=n.replace(t,"").split(/[_\s]+/).flatMap((t=>t.split(/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/))).filter(Boolean).map((t=>e.has(t.toLowerCase())?t.toUpperCase():t.toLowerCase()));return 0===r.length?n:r.map(((t,e)=>0===e&&t===t.toLowerCase()?t[0].toUpperCase()+t.slice(1):t)).join(" ")},r=t=>t.includes("+");export{n as h,r as i}
|