@genesislcap/grid-pro 14.405.0 → 14.406.0-workspaces.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom-elements.json +1844 -1027
- package/dist/dts/grid-components.d.ts +9 -0
- package/dist/dts/grid-components.d.ts.map +1 -1
- package/dist/dts/index.d.ts +1 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/multicolumn-dropdown/index.d.ts +4 -0
- package/dist/dts/multicolumn-dropdown/index.d.ts.map +1 -0
- package/dist/dts/multicolumn-dropdown/multicolumn-dropdown.d.ts +487 -0
- package/dist/dts/multicolumn-dropdown/multicolumn-dropdown.d.ts.map +1 -0
- package/dist/dts/multicolumn-dropdown/multicolumn-dropdown.styles.d.ts +12 -0
- package/dist/dts/multicolumn-dropdown/multicolumn-dropdown.styles.d.ts.map +1 -0
- package/dist/dts/multicolumn-dropdown/multicolumn-dropdown.template.d.ts +14 -0
- package/dist/dts/multicolumn-dropdown/multicolumn-dropdown.template.d.ts.map +1 -0
- package/dist/esm/grid-components.js +2 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/multicolumn-dropdown/index.js +3 -0
- package/dist/esm/multicolumn-dropdown/multicolumn-dropdown.js +380 -0
- package/dist/esm/multicolumn-dropdown/multicolumn-dropdown.styles.js +148 -0
- package/dist/esm/multicolumn-dropdown/multicolumn-dropdown.template.js +75 -0
- package/dist/grid-pro.api.json +1597 -115
- package/dist/grid-pro.d.ts +523 -0
- package/docs/api/grid-pro.display_none_class.md +13 -0
- package/docs/api/grid-pro.dropdownwidthvar.md +13 -0
- package/docs/api/grid-pro.foundationgridcomponents.md +9 -0
- package/docs/api/grid-pro.foundationmulticolumndropdown.md +66 -0
- package/docs/api/grid-pro.getmulticolumndropdowntemplate.md +56 -0
- package/docs/api/grid-pro.md +99 -0
- package/docs/api/grid-pro.multicolumndropdown.basecriteria.md +13 -0
- package/docs/api/grid-pro.multicolumndropdown.changehandler.md +50 -0
- package/docs/api/grid-pro.multicolumndropdown.columndefinitions.md +13 -0
- package/docs/api/grid-pro.multicolumndropdown.columndefinitionschanged.md +15 -0
- package/docs/api/grid-pro.multicolumndropdown.connect.md +15 -0
- package/docs/api/grid-pro.multicolumndropdown.connectedcallback.md +15 -0
- package/docs/api/grid-pro.multicolumndropdown.defaultslottednodes.md +11 -0
- package/docs/api/grid-pro.multicolumndropdown.disabled.md +13 -0
- package/docs/api/grid-pro.multicolumndropdown.disconnectedcallback.md +15 -0
- package/docs/api/grid-pro.multicolumndropdown.displayvalue.md +13 -0
- package/docs/api/grid-pro.multicolumndropdown.dropdownplacement.md +13 -0
- package/docs/api/grid-pro.multicolumndropdown.dropdownwidth.md +13 -0
- package/docs/api/grid-pro.multicolumndropdown.dropdownwidthchanged.md +15 -0
- package/docs/api/grid-pro.multicolumndropdown.filtersearch.md +13 -0
- package/docs/api/grid-pro.multicolumndropdown.filtersearchchanged.md +15 -0
- package/docs/api/grid-pro.multicolumndropdown.grid.md +11 -0
- package/docs/api/grid-pro.multicolumndropdown.hassearchkey.md +11 -0
- package/docs/api/grid-pro.multicolumndropdown.hasslottedcontent.md +11 -0
- package/docs/api/grid-pro.multicolumndropdown.labelkey.md +13 -0
- package/docs/api/grid-pro.multicolumndropdown.md +580 -0
- package/docs/api/grid-pro.multicolumndropdown.open.md +13 -0
- package/docs/api/grid-pro.multicolumndropdown.openchanged.md +15 -0
- package/docs/api/grid-pro.multicolumndropdown.optionselement.md +11 -0
- package/docs/api/grid-pro.multicolumndropdown.request.md +13 -0
- package/docs/api/grid-pro.multicolumndropdown.requestchanged.md +15 -0
- package/docs/api/grid-pro.multicolumndropdown.requestsupportsadvancedsearch.md +18 -0
- package/docs/api/grid-pro.multicolumndropdown.resourcename.md +13 -0
- package/docs/api/grid-pro.multicolumndropdown.searchkey.md +13 -0
- package/docs/api/grid-pro.multicolumndropdown.selectedrow.md +13 -0
- package/docs/api/grid-pro.multicolumndropdown.toggle.md +15 -0
- package/docs/api/grid-pro.multicolumndropdown.value.md +13 -0
- package/docs/api/grid-pro.multicolumndropdown.valuekey.md +13 -0
- package/docs/api/grid-pro.multicolumndropdownstyles.md +13 -0
- package/docs/api/grid-pro.multicolumndropdowntemplate.md +13 -0
- package/docs/api/grid-pro.optionsclass.md +13 -0
- package/docs/api/grid-pro.wasclickoutsideelement.md +66 -0
- package/docs/api-report.md.api.md +95 -0
- package/package.json +14 -13
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { __awaiter, __decorate } from "tslib";
|
|
2
|
+
import { Connect } from '@genesislcap/foundation-comms';
|
|
3
|
+
import { CriteriaBuilder, ExpressionBuilder, Join, Serialisers, } from '@genesislcap/foundation-criteria';
|
|
4
|
+
import { LifecycleMixin, stringArrayConverter } from '@genesislcap/foundation-utils';
|
|
5
|
+
import { attr, DOM, Observable, observable, volatile } from '@microsoft/fast-element';
|
|
6
|
+
import { FoundationElement } from '@microsoft/fast-foundation';
|
|
7
|
+
import debounce from 'lodash.debounce';
|
|
8
|
+
import { dropdownWidthVar, multicolumnDropdownStyles } from './multicolumn-dropdown.styles';
|
|
9
|
+
import { multicolumnDropdownTemplate } from './multicolumn-dropdown.template';
|
|
10
|
+
const DEBOUNCE_WAIT_MS = 300;
|
|
11
|
+
const DEFAULT_COL_DEF = {
|
|
12
|
+
menuTabs: ['filterMenuTab', 'generalMenuTab', 'columnsMenuTab'],
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Checks if the given mouse event occurred outside the target element.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export const wasClickOutsideElement = (event, target) => !event.composedPath().includes(target);
|
|
19
|
+
/**
|
|
20
|
+
* Builds an equality criteria string for value lookup using foundation-criteria.
|
|
21
|
+
* Properly escapes values for Groovy expressions.
|
|
22
|
+
*/
|
|
23
|
+
function buildEqualityCriteria(field, value) {
|
|
24
|
+
const expr = new ExpressionBuilder()
|
|
25
|
+
.withField(field)
|
|
26
|
+
.withValue(value !== null && value !== void 0 ? value : '')
|
|
27
|
+
.withSerialiser(Serialisers.EQ)
|
|
28
|
+
.withGroup('default')
|
|
29
|
+
.build();
|
|
30
|
+
return expr.serialiser(expr);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Fetches a single object from a resource by matching a value key.
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
function getObjectFromResource(connect, resourceName, valueKey, value) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
var _a;
|
|
39
|
+
try {
|
|
40
|
+
const criteriaMatch = buildEqualityCriteria(valueKey, value);
|
|
41
|
+
const message = yield connect.request(resourceName, {
|
|
42
|
+
DETAILS: { CRITERIA_MATCH: criteriaMatch },
|
|
43
|
+
});
|
|
44
|
+
if (((_a = message.REPLY) === null || _a === void 0 ? void 0 : _a.length) === 1) {
|
|
45
|
+
return message.REPLY[0];
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error(`Failed to retrieve object from the ${resourceName} resource: ${error instanceof Error ? error.message : String(error)}`);
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @beta
|
|
57
|
+
* A dropdown component that displays its options in a multi-column AG Grid.
|
|
58
|
+
* Search triggers a reqrep and displays the results in the grid dropdown.
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
* @tagname %%prefix%%-multicolumn-dropdown
|
|
62
|
+
*/
|
|
63
|
+
export class MulticolumnDropdown extends LifecycleMixin(FoundationElement) {
|
|
64
|
+
constructor() {
|
|
65
|
+
super(...arguments);
|
|
66
|
+
/**
|
|
67
|
+
* Tells whether a given request supports lookup by Groovy Expressions.
|
|
68
|
+
*
|
|
69
|
+
* @remarks Only set this to TRUE for GPAL ReqReps when you want to search on multiple fields.
|
|
70
|
+
* Custom ReqReps don't support groovy expressions for criteria match.
|
|
71
|
+
*/
|
|
72
|
+
this.requestSupportsAdvancedSearch = false;
|
|
73
|
+
this.defaultSlottedNodes = [];
|
|
74
|
+
this.getAndSetRowsDebounce = debounce(() => this.getAndSetRows(), DEBOUNCE_WAIT_MS);
|
|
75
|
+
this.handleClickOutside = (event) => {
|
|
76
|
+
if (wasClickOutsideElement(event, this)) {
|
|
77
|
+
this.open = false;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** The connect service - uses DI by default, but can be manually set for dynamic element creation */
|
|
82
|
+
get connect() {
|
|
83
|
+
var _a;
|
|
84
|
+
return (_a = this.connectOverride) !== null && _a !== void 0 ? _a : this._connectDI;
|
|
85
|
+
}
|
|
86
|
+
set connect(value) {
|
|
87
|
+
this.connectOverride = value;
|
|
88
|
+
}
|
|
89
|
+
get value() {
|
|
90
|
+
Observable.track(this, 'value');
|
|
91
|
+
return this._value;
|
|
92
|
+
}
|
|
93
|
+
set value(value) {
|
|
94
|
+
if (value === this._value)
|
|
95
|
+
return;
|
|
96
|
+
if (!value) {
|
|
97
|
+
this.selectedRow = undefined;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
getObjectFromResource(this.connect, this.resourceName, this.valueKey, value).then((object) => {
|
|
101
|
+
if (this.value === value) {
|
|
102
|
+
this.selectedRow = object;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
this.emitValue(value);
|
|
107
|
+
}
|
|
108
|
+
/** Value to display in the form field */
|
|
109
|
+
get displayValue() {
|
|
110
|
+
return ((this.selectedRow && this.labelKey && this.selectedRow[this.labelKey]) || this.value || '');
|
|
111
|
+
}
|
|
112
|
+
get hasSearchKey() {
|
|
113
|
+
return !!this.searchKey && this.searchKey.length > 0;
|
|
114
|
+
}
|
|
115
|
+
get hasSlottedContent() {
|
|
116
|
+
if (!this.defaultSlottedNodes || this.defaultSlottedNodes.length === 0) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return this.defaultSlottedNodes.some((node) => {
|
|
120
|
+
var _a;
|
|
121
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
125
|
+
return ((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim().length) > 0;
|
|
126
|
+
}
|
|
127
|
+
return false;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
connectedCallback() {
|
|
131
|
+
var _a;
|
|
132
|
+
super.connectedCallback();
|
|
133
|
+
if ((_a = this.optionsElement) === null || _a === void 0 ? void 0 : _a.style) {
|
|
134
|
+
this.dropdownWidthChanged();
|
|
135
|
+
}
|
|
136
|
+
this.open = false;
|
|
137
|
+
this.filterSearch = '';
|
|
138
|
+
if (this.grid) {
|
|
139
|
+
this.grid.gridOptions = {
|
|
140
|
+
defaultColDef: DEFAULT_COL_DEF,
|
|
141
|
+
onRowClicked: (event) => {
|
|
142
|
+
this.selectedRow = event.data;
|
|
143
|
+
this.emitValue(event.data[this.valueKey]);
|
|
144
|
+
this.toggle();
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Sets row data on the grid in a version-safe way.
|
|
151
|
+
* AG Grid v32+ removed `setRowData` in favour of `updateGridOptions`.
|
|
152
|
+
*/
|
|
153
|
+
setGridRowData(rows) {
|
|
154
|
+
var _a;
|
|
155
|
+
const api = (_a = this.grid) === null || _a === void 0 ? void 0 : _a.gridApi;
|
|
156
|
+
if (!api)
|
|
157
|
+
return;
|
|
158
|
+
if (typeof api.updateGridOptions === 'function') {
|
|
159
|
+
api.updateGridOptions({ rowData: rows });
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
api.setRowData(rows);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Sets column defs on the grid in a version-safe way.
|
|
167
|
+
* AG Grid v32+ removed `setColumnDefs` in favour of `updateGridOptions`.
|
|
168
|
+
*/
|
|
169
|
+
setGridColumnDefs(colDefs) {
|
|
170
|
+
var _a;
|
|
171
|
+
const api = (_a = this.grid) === null || _a === void 0 ? void 0 : _a.gridApi;
|
|
172
|
+
if (!api)
|
|
173
|
+
return;
|
|
174
|
+
if (typeof api.updateGridOptions === 'function') {
|
|
175
|
+
api.updateGridOptions({ columnDefs: colDefs });
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
api.setColumnDefs(colDefs);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Emits 'change' and 'input' events so that the `sync` directive and forms work correctly.
|
|
183
|
+
*/
|
|
184
|
+
emitValue(value) {
|
|
185
|
+
this._value = value;
|
|
186
|
+
this.$emit('change', value);
|
|
187
|
+
this.$emit('input', value);
|
|
188
|
+
Observable.notify(this, 'value');
|
|
189
|
+
}
|
|
190
|
+
toggle() {
|
|
191
|
+
this.open = !this.open;
|
|
192
|
+
}
|
|
193
|
+
getAndSetRows() {
|
|
194
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
+
var _a, _b;
|
|
196
|
+
if (!((_a = this.grid) === null || _a === void 0 ? void 0 : _a.gridApi))
|
|
197
|
+
return;
|
|
198
|
+
const request = (this.lastRequest = {});
|
|
199
|
+
const requestParams = this.request ? { REQUEST: Object.assign({}, this.request) } : {};
|
|
200
|
+
const searchKey = Array.isArray(this.searchKey) && this.searchKey.length === 1
|
|
201
|
+
? this.searchKey[0]
|
|
202
|
+
: this.searchKey;
|
|
203
|
+
let criteriaMatch;
|
|
204
|
+
if (searchKey && this.filterSearch) {
|
|
205
|
+
if (!this.requestSupportsAdvancedSearch) {
|
|
206
|
+
if (Array.isArray(searchKey))
|
|
207
|
+
throw Error('MulticolumnDropdown: Unable to search multiple keys via request; if the request is a GPAL ReqRep, set requestSupportsAdvancedSearch to true');
|
|
208
|
+
requestParams.REQUEST = Object.assign(Object.assign({}, requestParams.REQUEST), { [searchKey]: `*${this.filterSearch}*` });
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
const searchKeys = Array.isArray(searchKey) ? searchKey : [searchKey];
|
|
212
|
+
const searchExpressions = searchKeys.map((sk) => {
|
|
213
|
+
var _a;
|
|
214
|
+
return new ExpressionBuilder()
|
|
215
|
+
.withField(sk)
|
|
216
|
+
.withValue((_a = this.filterSearch) !== null && _a !== void 0 ? _a : '')
|
|
217
|
+
.withSerialiser(Serialisers.containsIgnoreCase)
|
|
218
|
+
.withGroup('default')
|
|
219
|
+
.build();
|
|
220
|
+
});
|
|
221
|
+
const searchBuilder = new CriteriaBuilder();
|
|
222
|
+
searchBuilder.Or(searchExpressions, { join: Join.Or() });
|
|
223
|
+
criteriaMatch = searchBuilder.build();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const trimmedBaseCriteria = (_b = this.baseCriteria) === null || _b === void 0 ? void 0 : _b.trim();
|
|
227
|
+
if (trimmedBaseCriteria && criteriaMatch) {
|
|
228
|
+
criteriaMatch = `(${criteriaMatch}) && (${trimmedBaseCriteria})`;
|
|
229
|
+
}
|
|
230
|
+
else if (trimmedBaseCriteria) {
|
|
231
|
+
criteriaMatch = trimmedBaseCriteria;
|
|
232
|
+
}
|
|
233
|
+
if (criteriaMatch) {
|
|
234
|
+
requestParams.DETAILS = { CRITERIA_MATCH: criteriaMatch };
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
const message = yield this.connect.request(this.resourceName, requestParams);
|
|
238
|
+
if (request !== this.lastRequest)
|
|
239
|
+
return;
|
|
240
|
+
const rows = (message === null || message === void 0 ? void 0 : message.REPLY) || [];
|
|
241
|
+
this.setGridRowData(rows);
|
|
242
|
+
if (rows.length > 0) {
|
|
243
|
+
this.grid.gridApi.hideOverlay();
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
this.grid.gridApi.showNoRowsOverlay();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
console.error(`Failed to retrieve rows from the ${this.resourceName} resource: ${error instanceof Error ? error.message : String(error)}`);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
filterSearchChanged() {
|
|
255
|
+
var _a, _b;
|
|
256
|
+
if (!this.open)
|
|
257
|
+
return;
|
|
258
|
+
(_b = (_a = this.grid) === null || _a === void 0 ? void 0 : _a.gridApi) === null || _b === void 0 ? void 0 : _b.showLoadingOverlay();
|
|
259
|
+
this.getAndSetRowsDebounce();
|
|
260
|
+
}
|
|
261
|
+
requestChanged() {
|
|
262
|
+
var _a, _b;
|
|
263
|
+
if (!this.open)
|
|
264
|
+
return;
|
|
265
|
+
(_b = (_a = this.grid) === null || _a === void 0 ? void 0 : _a.gridApi) === null || _b === void 0 ? void 0 : _b.showLoadingOverlay();
|
|
266
|
+
this.getAndSetRows();
|
|
267
|
+
}
|
|
268
|
+
columnDefinitionsChanged() {
|
|
269
|
+
this.setGridColumnDefs(this.columnDefinitions);
|
|
270
|
+
}
|
|
271
|
+
openChanged() {
|
|
272
|
+
var _a, _b;
|
|
273
|
+
if (this.open) {
|
|
274
|
+
document.addEventListener('mousedown', this.handleClickOutside);
|
|
275
|
+
if ((_a = this.grid) === null || _a === void 0 ? void 0 : _a.gridApi) {
|
|
276
|
+
this.grid.gridApi.showLoadingOverlay();
|
|
277
|
+
this.getAndSetRows();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
document.removeEventListener('mousedown', this.handleClickOutside);
|
|
282
|
+
this.filterSearch = '';
|
|
283
|
+
if ((_b = this.grid) === null || _b === void 0 ? void 0 : _b.gridApi) {
|
|
284
|
+
this.setGridRowData([]);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
dropdownWidthChanged() {
|
|
289
|
+
var _a, _b;
|
|
290
|
+
(_b = (_a = this.optionsElement) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.setProperty(dropdownWidthVar, this.dropdownWidth > 0 ? `${this.dropdownWidth}px` : 'inherit');
|
|
291
|
+
}
|
|
292
|
+
disconnectedCallback() {
|
|
293
|
+
document.removeEventListener('mousedown', this.handleClickOutside);
|
|
294
|
+
super.disconnectedCallback();
|
|
295
|
+
const shouldRunDisconnect = this.shouldRunDisconnect;
|
|
296
|
+
DOM.queueUpdate(() => {
|
|
297
|
+
var _a;
|
|
298
|
+
if (!shouldRunDisconnect)
|
|
299
|
+
return;
|
|
300
|
+
if ((_a = this.grid) === null || _a === void 0 ? void 0 : _a.gridApi) {
|
|
301
|
+
this.setGridRowData([]);
|
|
302
|
+
}
|
|
303
|
+
this.selectedRow = undefined;
|
|
304
|
+
this._value = undefined;
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
changeHandler(event) {
|
|
308
|
+
event.preventDefault();
|
|
309
|
+
event.stopImmediatePropagation();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
__decorate([
|
|
313
|
+
Connect
|
|
314
|
+
], MulticolumnDropdown.prototype, "_connectDI", void 0);
|
|
315
|
+
__decorate([
|
|
316
|
+
attr({ mode: 'boolean' })
|
|
317
|
+
], MulticolumnDropdown.prototype, "disabled", void 0);
|
|
318
|
+
__decorate([
|
|
319
|
+
attr({ attribute: 'resource-name' })
|
|
320
|
+
], MulticolumnDropdown.prototype, "resourceName", void 0);
|
|
321
|
+
__decorate([
|
|
322
|
+
attr({ attribute: 'search-key', converter: stringArrayConverter })
|
|
323
|
+
], MulticolumnDropdown.prototype, "searchKey", void 0);
|
|
324
|
+
__decorate([
|
|
325
|
+
attr({ attribute: 'advanced-search-req', mode: 'boolean' })
|
|
326
|
+
], MulticolumnDropdown.prototype, "requestSupportsAdvancedSearch", void 0);
|
|
327
|
+
__decorate([
|
|
328
|
+
attr({ attribute: 'value-key' })
|
|
329
|
+
], MulticolumnDropdown.prototype, "valueKey", void 0);
|
|
330
|
+
__decorate([
|
|
331
|
+
attr({ attribute: 'label-key' })
|
|
332
|
+
], MulticolumnDropdown.prototype, "labelKey", void 0);
|
|
333
|
+
__decorate([
|
|
334
|
+
attr({ attribute: 'dropdown-placement' })
|
|
335
|
+
], MulticolumnDropdown.prototype, "dropdownPlacement", void 0);
|
|
336
|
+
__decorate([
|
|
337
|
+
attr
|
|
338
|
+
], MulticolumnDropdown.prototype, "dropdownWidth", void 0);
|
|
339
|
+
__decorate([
|
|
340
|
+
observable
|
|
341
|
+
], MulticolumnDropdown.prototype, "request", void 0);
|
|
342
|
+
__decorate([
|
|
343
|
+
observable
|
|
344
|
+
], MulticolumnDropdown.prototype, "columnDefinitions", void 0);
|
|
345
|
+
__decorate([
|
|
346
|
+
observable
|
|
347
|
+
], MulticolumnDropdown.prototype, "baseCriteria", void 0);
|
|
348
|
+
__decorate([
|
|
349
|
+
observable
|
|
350
|
+
], MulticolumnDropdown.prototype, "defaultSlottedNodes", void 0);
|
|
351
|
+
__decorate([
|
|
352
|
+
observable
|
|
353
|
+
], MulticolumnDropdown.prototype, "filterSearch", void 0);
|
|
354
|
+
__decorate([
|
|
355
|
+
observable
|
|
356
|
+
], MulticolumnDropdown.prototype, "open", void 0);
|
|
357
|
+
__decorate([
|
|
358
|
+
observable
|
|
359
|
+
], MulticolumnDropdown.prototype, "selectedRow", void 0);
|
|
360
|
+
__decorate([
|
|
361
|
+
volatile
|
|
362
|
+
], MulticolumnDropdown.prototype, "displayValue", null);
|
|
363
|
+
__decorate([
|
|
364
|
+
volatile
|
|
365
|
+
], MulticolumnDropdown.prototype, "hasSearchKey", null);
|
|
366
|
+
__decorate([
|
|
367
|
+
volatile
|
|
368
|
+
], MulticolumnDropdown.prototype, "hasSlottedContent", null);
|
|
369
|
+
/**
|
|
370
|
+
* A function that returns a Multicolumn Dropdown registration for configuring the component with a DesignSystem.
|
|
371
|
+
*
|
|
372
|
+
* @public
|
|
373
|
+
* @remarks
|
|
374
|
+
* HTML Element: \<foundation-multicolumn-dropdown\>
|
|
375
|
+
*/
|
|
376
|
+
export const foundationMulticolumnDropdown = MulticolumnDropdown.compose({
|
|
377
|
+
baseName: 'multicolumn-dropdown',
|
|
378
|
+
template: multicolumnDropdownTemplate,
|
|
379
|
+
styles: multicolumnDropdownStyles,
|
|
380
|
+
});
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { css } from '@microsoft/fast-element';
|
|
2
|
+
/** The CSS variable to use for specifying the dropdown's width */
|
|
3
|
+
export const dropdownWidthVar = '--dropdown-width';
|
|
4
|
+
/** The CSS class to use for the options element's class in the dropdown */
|
|
5
|
+
export const optionsClass = 'options';
|
|
6
|
+
/** Class name used to hide elements with display:none */
|
|
7
|
+
export const DISPLAY_NONE_CLASS = 'dnone';
|
|
8
|
+
/**
|
|
9
|
+
* Multicolumn Dropdown styles.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export const multicolumnDropdownStyles = css `
|
|
13
|
+
label {
|
|
14
|
+
color: var(--neutral-foreground-hint, rgb(135 155 166));
|
|
15
|
+
font-style: normal;
|
|
16
|
+
margin: calc(var(--design-unit) * 2px) 0;
|
|
17
|
+
display: block;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
font-size: var(--type-ramp-base-font-size);
|
|
20
|
+
line-height: var(--type-ramp-base-line-height);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.${DISPLAY_NONE_CLASS} {
|
|
24
|
+
display: none !important;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.root {
|
|
28
|
+
position: relative;
|
|
29
|
+
width: inherit;
|
|
30
|
+
min-width: 250px;
|
|
31
|
+
${dropdownWidthVar}: 350px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.control {
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
position: relative;
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
width: 100%;
|
|
40
|
+
border-radius: calc(var(--control-corner-radius) * 1px);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#display-field {
|
|
44
|
+
width: 100%;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
color: inherit;
|
|
47
|
+
min-height: 40px;
|
|
48
|
+
padding-left: calc(var(--design-unit) * 2.25px);
|
|
49
|
+
padding-right: 52px;
|
|
50
|
+
border-width: 0;
|
|
51
|
+
background: var(--neutral-fill-input-rest);
|
|
52
|
+
border-radius: calc(var(--control-corner-radius) * 1px);
|
|
53
|
+
text-overflow: ellipsis;
|
|
54
|
+
font-size: var(--type-ramp-base-font-size);
|
|
55
|
+
font-family: var(--body-font);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#display-field[disabled] {
|
|
59
|
+
cursor: not-allowed;
|
|
60
|
+
opacity: var(--disabled-opacity);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#display-field:focus {
|
|
64
|
+
outline: 1px solid var(--accent-fill-rest);
|
|
65
|
+
background: var(--neutral-fill-input-rest);
|
|
66
|
+
border-style: none;
|
|
67
|
+
box-shadow: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#display-field:hover:not(:focus):not([disabled]) {
|
|
71
|
+
outline: 1px solid var(--neutral-stroke-hover, rgb(231 232 232));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
button {
|
|
75
|
+
pointer-events: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#arrow-icon {
|
|
79
|
+
display: inline-block;
|
|
80
|
+
width: 16px;
|
|
81
|
+
color: currentColor;
|
|
82
|
+
position: absolute;
|
|
83
|
+
left: calc(100% - 26px);
|
|
84
|
+
padding: 0;
|
|
85
|
+
cursor: pointer;
|
|
86
|
+
transform: rotate(0deg);
|
|
87
|
+
transition: transform 0.2s linear 0s;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
#arrow-icon.flipped {
|
|
91
|
+
transform: rotate(180deg);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.cross-icon {
|
|
95
|
+
display: inline-block;
|
|
96
|
+
width: 12px;
|
|
97
|
+
color: currentColor;
|
|
98
|
+
position: absolute;
|
|
99
|
+
left: calc(100% - 46px);
|
|
100
|
+
padding: 0;
|
|
101
|
+
cursor: pointer;
|
|
102
|
+
visibility: hidden;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.cross-icon:hover {
|
|
106
|
+
color: var(--error-color);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.disabled-icon {
|
|
110
|
+
pointer-events: none;
|
|
111
|
+
opacity: var(--disabled-opacity);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.${optionsClass} {
|
|
115
|
+
min-width: 100%;
|
|
116
|
+
width: var(${dropdownWidthVar});
|
|
117
|
+
display: flex;
|
|
118
|
+
flex-direction: column;
|
|
119
|
+
position: absolute;
|
|
120
|
+
height: max-content;
|
|
121
|
+
overflow-y: hidden;
|
|
122
|
+
margin: 5px 0;
|
|
123
|
+
background: var(--neutral-fill-input-rest);
|
|
124
|
+
visibility: hidden;
|
|
125
|
+
z-index: 999;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.dropdown-above {
|
|
129
|
+
bottom: 100%;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.dropdown-left {
|
|
133
|
+
right: 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.grid-container {
|
|
137
|
+
height: 300px;
|
|
138
|
+
width: 100%;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#filter-search {
|
|
142
|
+
padding: 5px;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.visible {
|
|
146
|
+
visibility: visible;
|
|
147
|
+
}
|
|
148
|
+
`;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { sync } from '@genesislcap/foundation-utils';
|
|
2
|
+
import { html, ref, slotted } from '@microsoft/fast-element';
|
|
3
|
+
import { classNames } from '@microsoft/fast-web-utilities';
|
|
4
|
+
import { gridProColumns } from '../column';
|
|
5
|
+
import { DISPLAY_NONE_CLASS, optionsClass } from './multicolumn-dropdown.styles';
|
|
6
|
+
/**
|
|
7
|
+
* Get a Design System prefixed Multicolumn Dropdown template.
|
|
8
|
+
* @param designSystem - The design system prefix to use. Defaults to 'foundation'.
|
|
9
|
+
* @returns A Multicolumn Dropdown component template prefixed with the correct design system.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export const getMulticolumnDropdownTemplate = (designSystem = 'foundation') => html `
|
|
13
|
+
<label
|
|
14
|
+
part="label"
|
|
15
|
+
for="control"
|
|
16
|
+
class="label ${(x) => { var _a, _b; return (_b = classNames([DISPLAY_NONE_CLASS, !((_a = x.hasSlottedContent) !== null && _a !== void 0 ? _a : false)])) !== null && _b !== void 0 ? _b : ''; }}"
|
|
17
|
+
>
|
|
18
|
+
<slot
|
|
19
|
+
${slotted({
|
|
20
|
+
property: 'defaultSlottedNodes',
|
|
21
|
+
})}
|
|
22
|
+
></slot>
|
|
23
|
+
</label>
|
|
24
|
+
<div class="root" part="root">
|
|
25
|
+
<div class="control" part="control">
|
|
26
|
+
<${designSystem}-icon
|
|
27
|
+
id="arrow-icon"
|
|
28
|
+
name="chevron-down"
|
|
29
|
+
class="${(x) => classNames(['flipped', x.open], ['disabled-icon', x.disabled])}"
|
|
30
|
+
@click=${(x) => !x.disabled && x.toggle()}
|
|
31
|
+
></${designSystem}-icon>
|
|
32
|
+
<${designSystem}-icon
|
|
33
|
+
name="xmark"
|
|
34
|
+
class="cross-icon ${(x) => classNames(['visible', !!x.value], ['disabled-icon', x.disabled])}"
|
|
35
|
+
@click=${(x) => !x.disabled && (x.value = undefined)}
|
|
36
|
+
></${designSystem}-icon>
|
|
37
|
+
<input
|
|
38
|
+
readonly
|
|
39
|
+
type="text"
|
|
40
|
+
id="display-field"
|
|
41
|
+
part="display-field"
|
|
42
|
+
?disabled=${(x) => x.disabled}
|
|
43
|
+
:value="${(x) => x.displayValue}"
|
|
44
|
+
@click=${(x) => x.toggle()}
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
<div
|
|
48
|
+
${ref('optionsElement')}
|
|
49
|
+
class="${(x) => {
|
|
50
|
+
var _a, _b, _c, _d;
|
|
51
|
+
return classNames(optionsClass, ['visible', x.open], ['dropdown-above', (_b = (_a = x.dropdownPlacement) === null || _a === void 0 ? void 0 : _a.startsWith('top')) !== null && _b !== void 0 ? _b : false], ['dropdown-left', (_d = (_c = x.dropdownPlacement) === null || _c === void 0 ? void 0 : _c.endsWith('left')) !== null && _d !== void 0 ? _d : false]);
|
|
52
|
+
}}"
|
|
53
|
+
>
|
|
54
|
+
<${designSystem}-text-field
|
|
55
|
+
id="filter-search"
|
|
56
|
+
part="filter-search"
|
|
57
|
+
placeholder="Search..."
|
|
58
|
+
:value=${sync((x) => x.filterSearch, 'string', 'input')}
|
|
59
|
+
?hidden=${(x) => !x.hasSearchKey}
|
|
60
|
+
@change=${(x, c) => x.changeHandler(c.event)}
|
|
61
|
+
></${designSystem}-text-field>
|
|
62
|
+
<div class="grid-container" part="grid">
|
|
63
|
+
<${designSystem}-grid-pro
|
|
64
|
+
${ref('grid')}
|
|
65
|
+
only-template-col-defs
|
|
66
|
+
>${gridProColumns((x) => x.columnDefinitions)}</${designSystem}-grid-pro>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
`;
|
|
71
|
+
/**
|
|
72
|
+
* The default Multicolumn Dropdown template using the 'foundation' design system prefix.
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
export const multicolumnDropdownTemplate = getMulticolumnDropdownTemplate();
|