@vertexvis/ui 0.1.0-canary.1 → 0.1.0-canary.10
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/badge-d39ac1fc.js +23 -0
- package/dist/cjs/components.cjs.js +1 -1
- package/dist/cjs/{icon-53d62a46.js → icon-2508f168.js} +1 -1
- package/dist/cjs/icon-button-72c19ebc.js +43 -0
- package/dist/cjs/{icon-helper-caf2699e.js → icon-helper-07d63296.js} +12 -0
- package/dist/cjs/index.cjs.js +11 -9
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{popover-d9ec8e10.js → popover-942209b8.js} +23 -1
- package/dist/cjs/{result-list-1e592c3c.js → result-list-241ffe8d.js} +46 -2
- package/dist/cjs/search-bar-91cbcd07.js +421 -0
- package/dist/cjs/{select-0eb7203f.js → select-5f8aecfe.js} +27 -4
- package/dist/cjs/{text-field-0397fb34.js → text-field-bccbde1f.js} +1 -0
- package/dist/cjs/{tooltip-80a7b722.js → tooltip-e9f63631.js} +57 -18
- package/dist/cjs/vertex-badge.cjs.entry.js +11 -0
- package/dist/cjs/vertex-icon-button.cjs.entry.js +2 -2
- package/dist/cjs/vertex-icon.cjs.entry.js +2 -2
- package/dist/cjs/vertex-popover.cjs.entry.js +1 -1
- package/dist/cjs/vertex-result-list.cjs.entry.js +1 -1
- package/dist/cjs/vertex-search-bar.cjs.entry.js +1 -1
- package/dist/cjs/vertex-select.cjs.entry.js +1 -1
- package/dist/cjs/vertex-textfield.cjs.entry.js +1 -1
- package/dist/cjs/vertex-tooltip.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/badge/badge.css +18 -0
- package/dist/collection/components/badge/badge.js +69 -0
- package/dist/collection/components/icon/icon-helper.js +6 -0
- package/dist/collection/components/icon/icon.js +1 -1
- package/dist/collection/components/icon/icons/comment-filled.js +2 -0
- package/dist/collection/components/icon/icons/compare.js +2 -0
- package/dist/collection/components/icon-button/icon-button.css +16 -1
- package/dist/collection/components/icon-button/icon-button.js +2 -2
- package/dist/collection/components/index.js +1 -0
- package/dist/collection/components/menu/menu.js +1 -1
- package/dist/collection/components/popover/popover.js +51 -0
- package/dist/collection/components/result-list/result-list.js +52 -5
- package/dist/collection/components/result-list/types.js +1 -0
- package/dist/collection/components/search-bar/dom.js +12 -0
- package/dist/collection/components/search-bar/lib.js +35 -15
- package/dist/collection/components/search-bar/search-bar.css +0 -16
- package/dist/collection/components/search-bar/search-bar.js +380 -324
- package/dist/collection/components/select/select.css +16 -0
- package/dist/collection/components/select/select.js +49 -2
- package/dist/collection/components/text-field/text-field.js +1 -0
- package/dist/collection/components/tooltip/tooltip.js +62 -18
- package/dist/collection/types/icon.js +2 -0
- package/dist/collection/util/templates/element-pool.js +19 -1
- package/dist/components/components.css +1 -1
- package/dist/components/components.esm.js +1 -1
- package/dist/components/index.esm.js +1 -1
- package/dist/components/p-09c16263.js +1 -0
- package/dist/components/p-0b1cdc8a.entry.js +1 -0
- package/dist/components/p-0b4406fa.entry.js +1 -0
- package/dist/components/{p-17b97932.js → p-265e2358.js} +1 -1
- package/dist/components/p-29d7697f.js +1 -0
- package/dist/components/p-2a6a8da4.entry.js +1 -0
- package/dist/components/p-406e73da.entry.js +1 -0
- package/dist/components/p-429cea3e.js +1 -0
- package/dist/components/p-43b1b3f9.js +1 -0
- package/dist/components/p-606596de.entry.js +1 -0
- package/dist/components/p-6b862967.js +1 -0
- package/dist/components/p-7cfb3736.entry.js +1 -0
- package/dist/components/p-912f6e24.js +1 -0
- package/dist/components/p-92930f2a.js +1 -0
- package/dist/components/p-c2706288.js +1 -0
- package/dist/components/p-c588db04.entry.js +1 -0
- package/dist/components/p-cfe369bf.entry.js +1 -0
- package/dist/components/p-db34f10c.js +1 -0
- package/dist/components/p-ee496965.entry.js +1 -0
- package/dist/esm/badge-6d27ca92.js +21 -0
- package/dist/esm/components.js +1 -1
- package/dist/esm/{icon-2630793d.js → icon-24b0a152.js} +1 -1
- package/dist/esm/icon-button-a7a40f3d.js +41 -0
- package/dist/esm/{icon-helper-10a99d95.js → icon-helper-3cc82749.js} +12 -0
- package/dist/esm/index.js +10 -9
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{popover-67c88e4b.js → popover-6e806354.js} +23 -1
- package/dist/esm/{result-list-36cfb08a.js → result-list-16c6afbd.js} +46 -2
- package/dist/esm/search-bar-f12a3599.js +419 -0
- package/dist/esm/{select-75ed5653.js → select-d4e135b7.js} +27 -4
- package/dist/esm/{text-field-e542da25.js → text-field-32ac877e.js} +1 -0
- package/dist/esm/{tooltip-97c1b3ec.js → tooltip-933da261.js} +57 -18
- package/dist/esm/vertex-badge.entry.js +3 -0
- package/dist/esm/vertex-icon-button.entry.js +2 -2
- package/dist/esm/vertex-icon.entry.js +2 -2
- package/dist/esm/vertex-popover.entry.js +1 -1
- package/dist/esm/vertex-result-list.entry.js +1 -1
- package/dist/esm/vertex-search-bar.entry.js +1 -1
- package/dist/esm/vertex-select.entry.js +1 -1
- package/dist/esm/vertex-textfield.entry.js +1 -1
- package/dist/esm/vertex-tooltip.entry.js +1 -1
- package/dist/types/components/badge/badge.d.ts +14 -0
- package/dist/types/components/icon/icons/comment-filled.d.ts +3 -0
- package/dist/types/components/icon/icons/compare.d.ts +3 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/popover/popover.d.ts +7 -0
- package/dist/types/components/result-list/result-list.d.ts +6 -1
- package/dist/types/components/result-list/types.d.ts +4 -0
- package/dist/types/components/search-bar/dom.d.ts +3 -0
- package/dist/types/components/search-bar/lib.d.ts +24 -6
- package/dist/types/components/search-bar/search-bar.d.ts +124 -42
- package/dist/types/components/select/select.d.ts +8 -0
- package/dist/types/components/tooltip/tooltip.d.ts +7 -0
- package/dist/types/components.d.ts +122 -20
- package/dist/types/types/icon.d.ts +2 -0
- package/dist/types/util/templates/element-pool.d.ts +10 -1
- package/package.json +4 -3
- package/dist/cjs/icon-button-f868bf06.js +0 -43
- package/dist/cjs/search-bar-bb40cfa7.js +0 -290
- package/dist/components/p-19318fee.entry.js +0 -1
- package/dist/components/p-1d6cb015.entry.js +0 -1
- package/dist/components/p-209db2ba.entry.js +0 -1
- package/dist/components/p-4224c2ad.js +0 -1
- package/dist/components/p-52739247.js +0 -1
- package/dist/components/p-552c128f.js +0 -1
- package/dist/components/p-6505cdb3.js +0 -1
- package/dist/components/p-79fd6fb6.entry.js +0 -1
- package/dist/components/p-94168b92.js +0 -1
- package/dist/components/p-ae6a3c46.entry.js +0 -1
- package/dist/components/p-bd11e7d1.js +0 -1
- package/dist/components/p-e576818b.entry.js +0 -1
- package/dist/components/p-ebabee40.entry.js +0 -1
- package/dist/components/p-ee8b96b2.js +0 -1
- package/dist/components/p-f49a7ffd.js +0 -1
- package/dist/components/p-f900d0f4.entry.js +0 -1
- package/dist/esm/icon-button-25edf617.js +0 -41
- package/dist/esm/search-bar-59cc151d.js +0 -288
|
@@ -3,10 +3,12 @@ import { c as classnames } from './index-9c609209.js';
|
|
|
3
3
|
import { g as generateInstanceFromTemplate } from './templates-797420bf.js';
|
|
4
4
|
|
|
5
5
|
class ElementPool {
|
|
6
|
-
constructor(container, elementFactory) {
|
|
6
|
+
constructor(container, elementFactory, eventHandlerFactory) {
|
|
7
7
|
this.container = container;
|
|
8
8
|
this.elementFactory = elementFactory;
|
|
9
|
+
this.eventHandlerFactory = eventHandlerFactory;
|
|
9
10
|
this.instanceMap = new Map();
|
|
11
|
+
this.handlerMap = new Map();
|
|
10
12
|
this.elements = [];
|
|
11
13
|
}
|
|
12
14
|
swapHeadToTail(count) {
|
|
@@ -58,15 +60,31 @@ class ElementPool {
|
|
|
58
60
|
this.elements.push(instance.element);
|
|
59
61
|
this.instanceMap.set(instance.element, instance);
|
|
60
62
|
this.container.append(instance.element);
|
|
63
|
+
this.addEventListeners(instance.element);
|
|
61
64
|
return instance;
|
|
62
65
|
}
|
|
66
|
+
addEventListeners(element) {
|
|
67
|
+
var _a;
|
|
68
|
+
const handlers = (_a = this.eventHandlerFactory) === null || _a === void 0 ? void 0 : _a.call(this, element);
|
|
69
|
+
handlers === null || handlers === void 0 ? void 0 : handlers.forEach((d) => {
|
|
70
|
+
element.addEventListener(d.type, d.handler);
|
|
71
|
+
});
|
|
72
|
+
this.handlerMap.set(element, handlers !== null && handlers !== void 0 ? handlers : []);
|
|
73
|
+
}
|
|
63
74
|
deleteElement() {
|
|
64
75
|
const element = this.elements.pop();
|
|
65
76
|
if (element != null) {
|
|
66
77
|
this.instanceMap.delete(element);
|
|
67
78
|
element.remove();
|
|
79
|
+
this.removeEventListeners(element);
|
|
68
80
|
}
|
|
69
81
|
}
|
|
82
|
+
removeEventListeners(element) {
|
|
83
|
+
var _a;
|
|
84
|
+
(_a = this.handlerMap.get(element)) === null || _a === void 0 ? void 0 : _a.forEach((d) => {
|
|
85
|
+
element.removeEventListener(d.type, d.handler);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
70
88
|
}
|
|
71
89
|
|
|
72
90
|
const getResultListHeight = (el) => {
|
|
@@ -86,6 +104,7 @@ const ResultList = class {
|
|
|
86
104
|
constructor(hostRef) {
|
|
87
105
|
registerInstance(this, hostRef);
|
|
88
106
|
this.enterPressed = createEvent(this, "enterPressed", 7);
|
|
107
|
+
this.resultClick = createEvent(this, "resultClick", 7);
|
|
89
108
|
this.computeResultHeight = () => {
|
|
90
109
|
if (this.computedResultHeight == null) {
|
|
91
110
|
const result = this.hostEl.querySelector('*[slot="result"]');
|
|
@@ -110,7 +129,7 @@ const ResultList = class {
|
|
|
110
129
|
}
|
|
111
130
|
};
|
|
112
131
|
this.createResultPool = () => {
|
|
113
|
-
this.stateMap.resultPool = new ElementPool(this.hostEl, () => this.createResultInstance());
|
|
132
|
+
this.stateMap.resultPool = new ElementPool(this.hostEl, () => this.createResultInstance(), () => this.createResultHandlers());
|
|
114
133
|
};
|
|
115
134
|
this.createResultInstance = () => {
|
|
116
135
|
if (this.stateMap.resultTemplate != null) {
|
|
@@ -122,6 +141,18 @@ const ResultList = class {
|
|
|
122
141
|
throw new Error('Result template not defined.');
|
|
123
142
|
}
|
|
124
143
|
};
|
|
144
|
+
this.createResultHandlers = () => {
|
|
145
|
+
return [
|
|
146
|
+
{
|
|
147
|
+
type: 'pointerdown',
|
|
148
|
+
handler: this.handlePointerDown,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
type: 'click',
|
|
152
|
+
handler: this.handleResultClick,
|
|
153
|
+
},
|
|
154
|
+
];
|
|
155
|
+
};
|
|
125
156
|
this.layoutResults = () => {
|
|
126
157
|
var _a, _b, _c, _d;
|
|
127
158
|
const visibleRowCount = this.viewportEndIndex - this.viewportStartIndex + 1;
|
|
@@ -142,6 +173,7 @@ const ResultList = class {
|
|
|
142
173
|
el.style.top = `${(this.viewportStartIndex + index) * this.resultHeight}px`;
|
|
143
174
|
el.style.width = '100%';
|
|
144
175
|
el.setAttribute('is-focused', `${this.viewportStartIndex + index === this.lastFocusedIndex}`);
|
|
176
|
+
el.setAttribute('data-result-id', result.id);
|
|
145
177
|
binding.bind(result);
|
|
146
178
|
}
|
|
147
179
|
});
|
|
@@ -184,6 +216,8 @@ const ResultList = class {
|
|
|
184
216
|
this.lastStartIndex = 0;
|
|
185
217
|
this.lastFocusedIndex = 0;
|
|
186
218
|
this.stateMap = {};
|
|
219
|
+
this.handleResultClick = this.handleResultClick.bind(this);
|
|
220
|
+
this.handlePointerDown = this.handlePointerDown.bind(this);
|
|
187
221
|
}
|
|
188
222
|
handleResultsChanged(results) {
|
|
189
223
|
if (typeof results === 'string') {
|
|
@@ -229,6 +263,16 @@ const ResultList = class {
|
|
|
229
263
|
height: `${this.parsedResults.length * this.resultHeight}px`,
|
|
230
264
|
} }, h("slot", null), h("slot", { name: "result" })))))));
|
|
231
265
|
}
|
|
266
|
+
handlePointerDown(event) {
|
|
267
|
+
event.preventDefault();
|
|
268
|
+
}
|
|
269
|
+
handleResultClick(event) {
|
|
270
|
+
const closestIdElement = event.target.closest('[data-result-id]');
|
|
271
|
+
const result = this.parsedResults.find((r) => r.id === (closestIdElement === null || closestIdElement === void 0 ? void 0 : closestIdElement.getAttribute('data-result-id')));
|
|
272
|
+
if (result != null) {
|
|
273
|
+
this.resultClick.emit(result);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
232
276
|
computeViewportResults() {
|
|
233
277
|
const viewportHeight = this.getListHeight();
|
|
234
278
|
if (viewportHeight != null && this.resultHeight > 0) {
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import { r as registerInstance, e as createEvent, h, H as Host, g as getElement } from './index-72f28b71.js';
|
|
2
|
+
import { c as classnames } from './index-9c609209.js';
|
|
3
|
+
import { g as generateInstanceFromTemplate } from './templates-797420bf.js';
|
|
4
|
+
|
|
5
|
+
// do not edit .js files directly - edit src/index.jst
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var fastDeepEqual = function equal(a, b) {
|
|
10
|
+
if (a === b) return true;
|
|
11
|
+
|
|
12
|
+
if (a && b && typeof a == 'object' && typeof b == 'object') {
|
|
13
|
+
if (a.constructor !== b.constructor) return false;
|
|
14
|
+
|
|
15
|
+
var length, i, keys;
|
|
16
|
+
if (Array.isArray(a)) {
|
|
17
|
+
length = a.length;
|
|
18
|
+
if (length != b.length) return false;
|
|
19
|
+
for (i = length; i-- !== 0;)
|
|
20
|
+
if (!equal(a[i], b[i])) return false;
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
27
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
28
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
29
|
+
|
|
30
|
+
keys = Object.keys(a);
|
|
31
|
+
length = keys.length;
|
|
32
|
+
if (length !== Object.keys(b).length) return false;
|
|
33
|
+
|
|
34
|
+
for (i = length; i-- !== 0;)
|
|
35
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
36
|
+
|
|
37
|
+
for (i = length; i-- !== 0;) {
|
|
38
|
+
var key = keys[i];
|
|
39
|
+
|
|
40
|
+
if (!equal(a[key], b[key])) return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// true if both NaN, false otherwise
|
|
47
|
+
return a!==a && b!==b;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const getWindowSelection = () => {
|
|
51
|
+
if (typeof window !== 'undefined') {
|
|
52
|
+
return window.getSelection();
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
};
|
|
56
|
+
const createDocumentRange = () => {
|
|
57
|
+
return document.createRange();
|
|
58
|
+
};
|
|
59
|
+
const createTextNode = (text) => {
|
|
60
|
+
return new Text(text);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const createResultUri = (result) => {
|
|
64
|
+
return `${result.type}:${result.id}`;
|
|
65
|
+
};
|
|
66
|
+
const createSearchResultReplacement = (result, before, after) => {
|
|
67
|
+
const urn = createResultUri(result);
|
|
68
|
+
return {
|
|
69
|
+
before: createTextNode(before),
|
|
70
|
+
beforeSpace: createTextNode(createHairSpace()),
|
|
71
|
+
result: createTextNode(urn),
|
|
72
|
+
afterSpace: after != null ? createTextNode(createNoBreakSpace()) : undefined,
|
|
73
|
+
after: after != null ? createTextNode(after) : undefined,
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
const getNodesForSearchResultReplacement = (replacement) => {
|
|
77
|
+
const keys = Object.keys(replacement);
|
|
78
|
+
return keys
|
|
79
|
+
.map((key) => replacement[key])
|
|
80
|
+
.filter((node) => node != null);
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* We leverage a couple unique spaces to represent mentions, allowing for
|
|
84
|
+
* correct cursor movement when using arrow keys. As these characters are
|
|
85
|
+
* purely for functional behavior of the input, `trimNonstandardSpaces`
|
|
86
|
+
* will remove them so the input is suitable for emitting.
|
|
87
|
+
*
|
|
88
|
+
* U+200A is a "Hair Space" which acts as a space, but is not visually
|
|
89
|
+
* represented as one.
|
|
90
|
+
*
|
|
91
|
+
* U+00A0 is a "No-Break Space" which is commonly added by browsers
|
|
92
|
+
* when interacting with a contenteditable element.
|
|
93
|
+
*/
|
|
94
|
+
const trimNonstandardSpaces = (text) => {
|
|
95
|
+
return text.replace(/[\u200A]/g, '').replace(/[\u00A0]/g, ' ');
|
|
96
|
+
};
|
|
97
|
+
const createHairSpace = () => {
|
|
98
|
+
return String.fromCharCode(8202);
|
|
99
|
+
};
|
|
100
|
+
const createNoBreakSpace = () => {
|
|
101
|
+
return String.fromCharCode(160);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const searchBarCss = ".wrapper.sc-vertex-search-bar{display:flex;align-items:center;width:100%;box-sizing:border-box;background:none;border:1px solid transparent;border-radius:4px;font-family:var(--vertex-ui-font-family);font-size:0.875rem;line-height:1.4}.content-input.sc-vertex-search-bar{width:100%;box-sizing:border-box;padding:6px 0.5em 7px;border:1px solid transparent;background:none;font-family:var(--vertex-ui-font-family);font-weight:var(--vertex-ui-font-weight-base);font-size:0.875rem;line-height:1.4;white-space:pre-line}.content-input.sc-vertex-search-bar:focus{outline:none}.standard.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-400);color:var(--vertex-ui-neutral-800)}.standard.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-500)}.standard.sc-vertex-search-bar:hover:not(.disabled),.standard.sc-vertex-search-bar:focus{border-color:var(--vertex-ui-neutral-500)}.standard.disabled.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-200)}.standard.disabled.sc-vertex-search-bar,.standard.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.blank.sc-vertex-search-bar{color:var(--vertex-ui-neutral-800)}.blank.sc-vertex-search-bar:not(:hover) .content-input.sc-vertex-search-bar:focus{border-color:var(--vertex-ui-neutral-400);border-radius:4px}.blank.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-500)}.blank.sc-vertex-search-bar:hover:not(.disabled) .content-input.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-400);border-radius:4px}.blank.disabled.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-200)}.blank.disabled.sc-vertex-search-bar,.blank.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.filled.sc-vertex-search-bar{background-color:var(--vertex-ui-neutral-200);border-color:var(--vertex-ui-neutral-200);color:var(--vertex-ui-neutral-800)}.filled.disabled.sc-vertex-search-bar,.filled.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.filled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-700)}.filled.sc-vertex-search-bar:hover:not(.disabled),.filled.sc-vertex-search-bar:focus{border-bottom-color:var(--vertex-ui-blue-600)}.filled.disabled.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-100)}.filled.disabled.sc-vertex-search-bar,.filled.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.underlined.sc-vertex-search-bar{background-color:var(--vertex-ui-white);border-color:var(--vertex-ui-white) var(--vertex-ui-white) var(--vertex-ui-neutral-400) var(--vertex-ui-white);color:var(--vertex-ui-neutral-800)}.underlined.disabled.sc-vertex-search-bar,.underlined.disabled.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.underlined.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-700)}.underlined.sc-vertex-search-bar:hover:not(.disabled),.underlined.sc-vertex-search-bar:focus{background-color:var(--vertex-ui-neutral-200);border-color:var(--vertex-ui-neutral-200);border-bottom-color:var(--vertex-ui-blue-600)}.underlined.disabled.sc-vertex-search-bar{border-bottom-color:var(--vertex-ui-neutral-200)}.underlined.disabled.sc-vertex-search-bar,.underlined.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.underlined.has-error.sc-vertex-search-bar{border-bottom-color:var(--vertex-ui-red-600)}";
|
|
105
|
+
|
|
106
|
+
const SearchBar = class {
|
|
107
|
+
constructor(hostRef) {
|
|
108
|
+
registerInstance(this, hostRef);
|
|
109
|
+
this.searchChanged = createEvent(this, "searchChanged", 7);
|
|
110
|
+
this.inputChanged = createEvent(this, "inputChanged", 7);
|
|
111
|
+
this.resultReplaced = createEvent(this, "resultReplaced", 7);
|
|
112
|
+
this.inputFocus = createEvent(this, "inputFocus", 7);
|
|
113
|
+
this.inputBlur = createEvent(this, "inputBlur", 7);
|
|
114
|
+
this.rawElements = [];
|
|
115
|
+
this.isIdenticalElement = (child, other) => {
|
|
116
|
+
return (child === this.triggeredElement ||
|
|
117
|
+
this.getTextContent(child) === this.getTextContent(other));
|
|
118
|
+
};
|
|
119
|
+
this.getTextContent = (node) => {
|
|
120
|
+
var _a;
|
|
121
|
+
if (node instanceof HTMLElement) {
|
|
122
|
+
return node.innerText;
|
|
123
|
+
}
|
|
124
|
+
return (_a = node.textContent) !== null && _a !== void 0 ? _a : '';
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Inspects the cursor position for the following conditions:
|
|
128
|
+
*
|
|
129
|
+
* 1. The cursor has moved to text that contains a valid string
|
|
130
|
+
* and trigger character, indicating we need to dispatch a
|
|
131
|
+
* `searchChanged` event and display the results.
|
|
132
|
+
*
|
|
133
|
+
* 2. The cursor has moved within text that contains a valid string
|
|
134
|
+
* and trigger character, indicating we need to dispatch a
|
|
135
|
+
* `searchChanged` event to update the currently displayed results.
|
|
136
|
+
*
|
|
137
|
+
* 3. The cursor has moved to text that does not contain a valid
|
|
138
|
+
* string and trigger character, indicating we need to hide any
|
|
139
|
+
* displayed search results.
|
|
140
|
+
*/
|
|
141
|
+
this.handleCursorPositionUpdate = () => {
|
|
142
|
+
var _a, _b;
|
|
143
|
+
const windowRange = (_a = getWindowSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0);
|
|
144
|
+
if (windowRange != null) {
|
|
145
|
+
const triggerText = this.readTriggerValue((_b = windowRange.commonAncestorContainer.textContent) !== null && _b !== void 0 ? _b : '', windowRange.startOffset);
|
|
146
|
+
if (!this.hasTriggered && triggerText != null) {
|
|
147
|
+
this.hasTriggered = true;
|
|
148
|
+
this.triggeredRange = windowRange;
|
|
149
|
+
this.triggeredElement = windowRange.commonAncestorContainer;
|
|
150
|
+
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
151
|
+
}
|
|
152
|
+
else if (this.hasTriggered && triggerText != null) {
|
|
153
|
+
this.triggeredRange = windowRange;
|
|
154
|
+
this.triggeredElement = windowRange.commonAncestorContainer;
|
|
155
|
+
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
this.hasTriggered = false;
|
|
159
|
+
this.triggeredRange = undefined;
|
|
160
|
+
this.triggeredElement = undefined;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
this.cursorPosition = this.getCursorPosition();
|
|
164
|
+
};
|
|
165
|
+
this.readTriggerValue = (value, fromIndex) => {
|
|
166
|
+
const adjustedValue = value.replace(String.fromCharCode(160), ' ');
|
|
167
|
+
const beforeSubstr = adjustedValue.substring(0, fromIndex);
|
|
168
|
+
const afterSubstr = adjustedValue.substring(fromIndex);
|
|
169
|
+
const adjustedBeforeSubstr = beforeSubstr.includes(this.triggerCharacter)
|
|
170
|
+
? beforeSubstr.substring(beforeSubstr.lastIndexOf(this.triggerCharacter))
|
|
171
|
+
: '';
|
|
172
|
+
const adjustedAfterSubstr = afterSubstr.substring(0, this.firstIndexOfBreakCharacter(afterSubstr));
|
|
173
|
+
const result = `${adjustedBeforeSubstr}${adjustedAfterSubstr}`;
|
|
174
|
+
return result.includes(this.triggerCharacter) &&
|
|
175
|
+
!this.includesBreakCharacter(result)
|
|
176
|
+
? result
|
|
177
|
+
: undefined;
|
|
178
|
+
};
|
|
179
|
+
this.includesBreakCharacter = (value) => {
|
|
180
|
+
return this.breakCharacters.some((bc) => value.includes(bc));
|
|
181
|
+
};
|
|
182
|
+
this.firstIndexOfBreakCharacter = (value) => {
|
|
183
|
+
const indices = this.breakCharacters
|
|
184
|
+
.map((bc) => value.indexOf(bc))
|
|
185
|
+
.filter((i) => i >= 0);
|
|
186
|
+
return indices.length > 0 ? Math.min(...indices) : value.length;
|
|
187
|
+
};
|
|
188
|
+
this.moveCursorToNodeEnd = (node, collapseToStart = false) => {
|
|
189
|
+
const selection = getWindowSelection();
|
|
190
|
+
if (selection != null) {
|
|
191
|
+
const range = createDocumentRange();
|
|
192
|
+
range.selectNodeContents(node);
|
|
193
|
+
range.collapse(collapseToStart);
|
|
194
|
+
selection.removeAllRanges();
|
|
195
|
+
selection.addRange(range);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
this.getContentAsString = () => {
|
|
199
|
+
if (this.contentEl != null) {
|
|
200
|
+
return trimNonstandardSpaces(Array.from(this.contentEl.childNodes).reduce((res, n) => {
|
|
201
|
+
var _a;
|
|
202
|
+
if (n instanceof HTMLElement &&
|
|
203
|
+
n.getAttribute('data-replaced') === 'true') {
|
|
204
|
+
return `${res}${n.getAttribute('data-original')}`;
|
|
205
|
+
}
|
|
206
|
+
else if (n instanceof HTMLElement) {
|
|
207
|
+
return `${res}${n.innerText}`;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
return `${res}${(_a = n.textContent) !== null && _a !== void 0 ? _a : ''}`;
|
|
211
|
+
}
|
|
212
|
+
}, ''));
|
|
213
|
+
}
|
|
214
|
+
return '';
|
|
215
|
+
};
|
|
216
|
+
this.createReplacedElement = (original, data) => {
|
|
217
|
+
const template = this.hostEl.querySelector('template[slot="replaced"]');
|
|
218
|
+
if (template != null) {
|
|
219
|
+
const instance = generateInstanceFromTemplate(template);
|
|
220
|
+
instance.bindings.bind(data);
|
|
221
|
+
instance.element.id = data.id;
|
|
222
|
+
instance.element.style.display = 'inline-block';
|
|
223
|
+
instance.element.contentEditable = 'false';
|
|
224
|
+
instance.element.tabIndex = -1;
|
|
225
|
+
instance.element.setAttribute('data-replaced', 'true');
|
|
226
|
+
instance.element.setAttribute('data-original', original);
|
|
227
|
+
return instance.element;
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
throw new Error('Replaced template not defined.');
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
this.variant = 'standard';
|
|
234
|
+
this.disabled = false;
|
|
235
|
+
this.triggerCharacter = '@';
|
|
236
|
+
this.breakCharacters = [' ', '\n'];
|
|
237
|
+
this.resultItems = undefined;
|
|
238
|
+
this.placement = 'bottom-start';
|
|
239
|
+
this.value = undefined;
|
|
240
|
+
this.placeholder = undefined;
|
|
241
|
+
this.replacements = [];
|
|
242
|
+
this.replacementUriType = 'user';
|
|
243
|
+
this.cursorPosition = undefined;
|
|
244
|
+
this.displayedElements = [];
|
|
245
|
+
this.hasTriggered = false;
|
|
246
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
247
|
+
this.handleKeyUp = this.handleKeyUp.bind(this);
|
|
248
|
+
this.handleResultClick = this.handleResultClick.bind(this);
|
|
249
|
+
this.handleClick = this.handleClick.bind(this);
|
|
250
|
+
this.handleWindowClick = this.handleWindowClick.bind(this);
|
|
251
|
+
this.handleInput = this.handleInput.bind(this);
|
|
252
|
+
this.handleBlur = this.handleBlur.bind(this);
|
|
253
|
+
this.handleFocus = this.handleFocus.bind(this);
|
|
254
|
+
this.handleCursorPositionUpdate =
|
|
255
|
+
this.handleCursorPositionUpdate.bind(this);
|
|
256
|
+
this.updateContent = this.updateContent.bind(this);
|
|
257
|
+
this.replaceContent = this.replaceContent.bind(this);
|
|
258
|
+
}
|
|
259
|
+
componentDidLoad() {
|
|
260
|
+
this.replaceContent(this.value);
|
|
261
|
+
}
|
|
262
|
+
connectedCallback() {
|
|
263
|
+
window.addEventListener('click', this.handleWindowClick);
|
|
264
|
+
}
|
|
265
|
+
disconnectedCallback() {
|
|
266
|
+
window.removeEventListener('click', this.handleWindowClick);
|
|
267
|
+
}
|
|
268
|
+
replaceContent(newValue, oldValue) {
|
|
269
|
+
if (newValue != null && newValue !== oldValue) {
|
|
270
|
+
const pattern = `${this.replacementUriType}:[0-9a-z-]{36}`;
|
|
271
|
+
const matches = newValue.match(new RegExp(pattern, 'g'));
|
|
272
|
+
const replacementsMap = this.replacements.reduce((map, r) => (Object.assign(Object.assign({}, map), { [createResultUri(r)]: r })), {});
|
|
273
|
+
let nextSubstr = newValue;
|
|
274
|
+
const parts = matches != null
|
|
275
|
+
? matches === null || matches === void 0 ? void 0 : matches.reduce((res, m) => {
|
|
276
|
+
if (replacementsMap[m] != null) {
|
|
277
|
+
const urn = createResultUri(replacementsMap[m]);
|
|
278
|
+
const index = nextSubstr.indexOf(urn);
|
|
279
|
+
const before = nextSubstr.substring(0, index);
|
|
280
|
+
const after = nextSubstr.substring(index + urn.length);
|
|
281
|
+
const replacement = createSearchResultReplacement(replacementsMap[m], before);
|
|
282
|
+
nextSubstr = after;
|
|
283
|
+
return [
|
|
284
|
+
...res,
|
|
285
|
+
replacement.before,
|
|
286
|
+
replacement.beforeSpace,
|
|
287
|
+
replacement.result,
|
|
288
|
+
];
|
|
289
|
+
}
|
|
290
|
+
return res;
|
|
291
|
+
}, [])
|
|
292
|
+
: [];
|
|
293
|
+
this.rawElements = [...parts, createTextNode(nextSubstr)];
|
|
294
|
+
this.updateContent(this.replacements);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
updateContent(newValue, oldValue) {
|
|
298
|
+
if (this.contentEl != null && !fastDeepEqual(newValue, oldValue)) {
|
|
299
|
+
this.contentEl.innerHTML = '';
|
|
300
|
+
this.displayedElements = this.rawElements.map((el) => {
|
|
301
|
+
const raw = el instanceof HTMLElement ? el.innerText : el.textContent;
|
|
302
|
+
const replacement = this.replacements.find((r) => raw === null || raw === void 0 ? void 0 : raw.includes(createResultUri(r)));
|
|
303
|
+
if (raw != null && replacement != null) {
|
|
304
|
+
const replacementElement = this.createReplacedElement(raw, replacement);
|
|
305
|
+
return replacementElement;
|
|
306
|
+
}
|
|
307
|
+
return el;
|
|
308
|
+
});
|
|
309
|
+
this.displayedElements.forEach((el) => {
|
|
310
|
+
var _a;
|
|
311
|
+
(_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.appendChild(typeof el === 'string' ? createTextNode(el) : el);
|
|
312
|
+
});
|
|
313
|
+
if (this.lastReplacedSpace != null) {
|
|
314
|
+
this.moveCursorToNodeEnd(this.lastReplacedSpace);
|
|
315
|
+
}
|
|
316
|
+
this.inputChanged.emit(this.getContentAsString());
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
render() {
|
|
320
|
+
var _a;
|
|
321
|
+
const classes = classnames('wrapper', {
|
|
322
|
+
standard: this.variant === 'standard',
|
|
323
|
+
filled: this.variant === 'filled',
|
|
324
|
+
underlined: this.variant === 'underlined',
|
|
325
|
+
blank: this.variant === 'blank',
|
|
326
|
+
disabled: this.disabled,
|
|
327
|
+
});
|
|
328
|
+
return (h(Host, null, h("div", { class: classes }, h("span", { class: "content-input", role: "textbox", contentEditable: "true", "aria-multiline": "true", "data-placeholder": this.placeholder, ref: (el) => (this.contentEl = el), onKeyDown: this.handleKeyDown, onKeyUp: this.handleCursorPositionUpdate, onClick: this.handleCursorPositionUpdate, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur })), h("vertex-result-list", { position: this.cursorPosition, placement: this.placement, open: this.hasTriggered &&
|
|
329
|
+
this.resultItems != null &&
|
|
330
|
+
this.resultItems.length > 0, items: (_a = this.resultItems) !== null && _a !== void 0 ? _a : [], onEnterPressed: this.handleResultClick, onResultClick: this.handleResultClick }, h("slot", { name: "results" })), h("slot", { name: "replaced" })));
|
|
331
|
+
}
|
|
332
|
+
handleKeyDown(event) {
|
|
333
|
+
if (this.hasTriggered && this.breakCharacters.includes(event.key)) {
|
|
334
|
+
this.hasTriggered = false;
|
|
335
|
+
this.triggeredRange = undefined;
|
|
336
|
+
this.triggeredElement = undefined;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
handleKeyUp(event) {
|
|
340
|
+
this.handleCursorPositionUpdate();
|
|
341
|
+
this.cursorPosition = this.getCursorPosition();
|
|
342
|
+
}
|
|
343
|
+
async handleInput() {
|
|
344
|
+
this.inputChanged.emit(this.getContentAsString());
|
|
345
|
+
}
|
|
346
|
+
handleClick() {
|
|
347
|
+
this.handleCursorPositionUpdate();
|
|
348
|
+
}
|
|
349
|
+
handleWindowClick(event) {
|
|
350
|
+
if (event.target instanceof HTMLElement &&
|
|
351
|
+
event.target.getAttribute('data-replaced') === 'true' &&
|
|
352
|
+
event.target.nextSibling != null) {
|
|
353
|
+
this.moveCursorToNodeEnd(event.target.nextSibling, true);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
handleFocus(event) {
|
|
357
|
+
this.inputFocus.emit(event);
|
|
358
|
+
}
|
|
359
|
+
handleBlur(event) {
|
|
360
|
+
this.hasTriggered = false;
|
|
361
|
+
this.inputBlur.emit(event);
|
|
362
|
+
}
|
|
363
|
+
handleResultClick(event) {
|
|
364
|
+
var _a;
|
|
365
|
+
const triggeredRange = this.triggeredRange;
|
|
366
|
+
const triggeredElement = this.triggeredElement;
|
|
367
|
+
const value = triggeredElement instanceof HTMLElement
|
|
368
|
+
? triggeredElement.innerText
|
|
369
|
+
: triggeredElement === null || triggeredElement === void 0 ? void 0 : triggeredElement.textContent;
|
|
370
|
+
if (this.contentEl != null &&
|
|
371
|
+
triggeredRange != null &&
|
|
372
|
+
triggeredElement != null &&
|
|
373
|
+
value != null) {
|
|
374
|
+
const triggeredValue = (_a = this.readTriggerValue(value, triggeredRange.startOffset)) !== null && _a !== void 0 ? _a : '';
|
|
375
|
+
const split = value.split(triggeredValue);
|
|
376
|
+
const before = split[0];
|
|
377
|
+
const after = split[1];
|
|
378
|
+
const replacement = createSearchResultReplacement(event.detail, before, after);
|
|
379
|
+
this.lastReplacedSpace = replacement.afterSpace;
|
|
380
|
+
this.rawElements = Array.from(this.contentEl.childNodes).reduce((re, e) => {
|
|
381
|
+
if (this.isIdenticalElement(e, triggeredElement)) {
|
|
382
|
+
return [...re, ...getNodesForSearchResultReplacement(replacement)];
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
return [...re, e];
|
|
386
|
+
}
|
|
387
|
+
}, []);
|
|
388
|
+
this.hasTriggered = false;
|
|
389
|
+
this.resultReplaced.emit(event.detail);
|
|
390
|
+
this.replacements = [
|
|
391
|
+
...this.replacements.filter((r) => r.id !== event.detail.id),
|
|
392
|
+
event.detail,
|
|
393
|
+
];
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
getCursorPosition() {
|
|
397
|
+
var _a;
|
|
398
|
+
const selection = getWindowSelection();
|
|
399
|
+
if (selection != null && selection.rangeCount > 0) {
|
|
400
|
+
const cursorBounds = selection.getRangeAt(0).getBoundingClientRect();
|
|
401
|
+
const contentBounds = (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
402
|
+
const cursorBottom = cursorBounds.bottom || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.bottom) || 0;
|
|
403
|
+
const cursorTop = cursorBounds.top || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.top) || 0;
|
|
404
|
+
return {
|
|
405
|
+
x: cursorBounds.left || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.left) || 0,
|
|
406
|
+
y: this.placement.includes('top') ? cursorTop : cursorBottom,
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
throw new Error('Unable to retrieve window selection.');
|
|
410
|
+
}
|
|
411
|
+
get hostEl() { return getElement(this); }
|
|
412
|
+
static get watchers() { return {
|
|
413
|
+
"value": ["replaceContent"],
|
|
414
|
+
"replacements": ["updateContent"]
|
|
415
|
+
}; }
|
|
416
|
+
};
|
|
417
|
+
SearchBar.style = searchBarCss;
|
|
418
|
+
|
|
419
|
+
export { SearchBar as S };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as registerInstance, e as createEvent, h, c as readTask, g as getElement } from './index-72f28b71.js';
|
|
2
2
|
import { c as classnames } from './index-9c609209.js';
|
|
3
3
|
|
|
4
|
-
const selectCss = ":host{--select-width:100
|
|
4
|
+
const selectCss = ":host{--select-width:100%;--select-option-white-space:normal}.root{display:inline-block;color:var(--vertex-ui-neutral-700);width:var(--select-width);font-family:var(--vertex-ui-font-family);font-size:var(--vertex-ui-text-base);overflow:hidden;user-select:none}.root:not(.disabled):hover{color:var(--vertex-ui-neutral-800)}.root.disabled{color:var(--vertex-ui-neutral-400)}.target,.selected-option{background-color:var(--vertex-ui-neutral-200);width:100%;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;padding:0.375rem 0.75rem 0.375rem 0.75rem}.target.hidden{box-shadow:0px 2px 4px -1px rgb(0 0 0 / 20%),\n 0px 4px 5px 0px rgb(0 0 0 / 14%), 0px 1px 10px 0px rgb(0 0 0 / 12%)}.selected-option.disabled,.target.disabled{background-color:var(--vertex-ui-neutral-100);cursor:default}.target{border-radius:4px}.text{white-space:var(--select-option-white-space);overflow:hidden;text-overflow:ellipsis}.icon{padding-left:1rem;margin-left:auto}.options{position:relative;cursor:pointer;background-color:var(--vertex-ui-white);border-radius:4px;padding:0.25rem 0;top:-0.25rem;box-shadow:0px 2px 4px -1px rgb(0 0 0 / 20%),\n 0px 4px 5px 0px rgb(0 0 0 / 14%), 0px 1px 10px 0px rgb(0 0 0 / 12%)}.options.animated{transition:opacity 0.1s ease-in 0.05s;opacity:0}.options.hidden{background-color:transparent}.options.visible{opacity:1}.options>*,.options>slot::slotted(*){padding:0.375rem 0.75rem 0.375rem 0.75rem}.options.hidden>*,.options.hidden>slot::slotted(*){opacity:0}.options>slot::slotted(:hover){background-color:var(--vertex-ui-neutral-200)}.options>slot::slotted([data-selected=\"true\"]){display:none}vertex-popover{--transform-origin:top left;--open-animation-name:open-scale-y;--close-animation-name:close-scale-y}";
|
|
5
5
|
|
|
6
6
|
const GET_BOUNDS_DEBOUNCE_THRESHOLD = 200;
|
|
7
7
|
const Select = class {
|
|
@@ -14,6 +14,7 @@ const Select = class {
|
|
|
14
14
|
this.placeholder = 'Select an option...';
|
|
15
15
|
this.disabled = false;
|
|
16
16
|
this.animated = true;
|
|
17
|
+
this.hideSelected = true;
|
|
17
18
|
this.open = false;
|
|
18
19
|
this.position = undefined;
|
|
19
20
|
this.displayValue = undefined;
|
|
@@ -33,6 +34,9 @@ const Select = class {
|
|
|
33
34
|
if (this.value != null) {
|
|
34
35
|
this.handleUpdateValue(this.value);
|
|
35
36
|
}
|
|
37
|
+
else {
|
|
38
|
+
this.handleUpdateDisplayValue();
|
|
39
|
+
}
|
|
36
40
|
}
|
|
37
41
|
connectedCallback() {
|
|
38
42
|
window.addEventListener('resize', this.getBounds);
|
|
@@ -50,6 +54,13 @@ const Select = class {
|
|
|
50
54
|
}
|
|
51
55
|
this.controlled = value != null;
|
|
52
56
|
}
|
|
57
|
+
handleUpdateDisplayValue() {
|
|
58
|
+
var _a;
|
|
59
|
+
this.clearSelectedOptionFlag();
|
|
60
|
+
if (this.hideSelected) {
|
|
61
|
+
(_a = this.getSelectedOption()) === null || _a === void 0 ? void 0 : _a.setAttribute('data-selected', 'true');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
53
64
|
render() {
|
|
54
65
|
return (h("div", { class: classnames('root', {
|
|
55
66
|
disabled: this.disabled,
|
|
@@ -58,7 +69,7 @@ const Select = class {
|
|
|
58
69
|
}, onClick: !this.open && !this.disabled ? this.handleOpen : undefined }, h("div", { class: classnames('target', {
|
|
59
70
|
hidden: this.open,
|
|
60
71
|
disabled: this.disabled,
|
|
61
|
-
}) }, this.displayValue || this.placeholder, h("div", { class: "icon" }, h("vertex-icon", { name: "chevron-down", size: "sm" }))), h("vertex-popover", { position: this.position, open: this.open, animated: this.animated, resizeBehavior: "fixed", onDismissed: this.handleDismiss }, h("div", { class: classnames('options', {
|
|
72
|
+
}) }, h("div", { class: "text" }, this.displayValue || this.placeholder), h("div", { class: "icon" }, h("vertex-icon", { name: "chevron-down", size: "sm" }))), h("vertex-popover", { position: this.position, open: this.open, animated: this.animated, resizeBehavior: "fixed", onDismissed: this.handleDismiss }, h("div", { class: classnames('options', {
|
|
62
73
|
hidden: !this.open,
|
|
63
74
|
visible: this.open,
|
|
64
75
|
animated: this.animated,
|
|
@@ -66,7 +77,7 @@ const Select = class {
|
|
|
66
77
|
minWidth: this.width != null ? `${this.width}px` : 'var(--select-width)',
|
|
67
78
|
} }, h("div", { class: classnames('selected-option', {
|
|
68
79
|
disabled: this.disabled,
|
|
69
|
-
}), onClick: this.handleDismiss }, this.displayValue || this.placeholder, h("div", { class: "icon" }, h("vertex-icon", { name: "chevron-down", size: "sm" }))), h("slot", null)))));
|
|
80
|
+
}), onClick: this.handleDismiss }, h("div", { class: "text" }, this.displayValue || this.placeholder), h("div", { class: "icon" }, h("vertex-icon", { name: "chevron-down", size: "sm" }))), h("slot", null)))));
|
|
70
81
|
}
|
|
71
82
|
handleOpen() {
|
|
72
83
|
var _a, _b;
|
|
@@ -105,6 +116,15 @@ const Select = class {
|
|
|
105
116
|
this.removeListeners.forEach((l) => l());
|
|
106
117
|
this.removeListeners = [];
|
|
107
118
|
}
|
|
119
|
+
clearSelectedOptionFlag() {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
(_b = (_a = this.slotElement) === null || _a === void 0 ? void 0 : _a.assignedElements) === null || _b === void 0 ? void 0 : _b.call(_a).forEach((e) => e.removeAttribute('data-selected'));
|
|
122
|
+
}
|
|
123
|
+
getSelectedOption() {
|
|
124
|
+
var _a, _b, _c;
|
|
125
|
+
const value = (_a = this.displayValue) !== null && _a !== void 0 ? _a : this.placeholder;
|
|
126
|
+
return (_c = (_b = this.slotElement) === null || _b === void 0 ? void 0 : _b.assignedElements) === null || _c === void 0 ? void 0 : _c.call(_b).find((e) => e.getAttribute('data-value') === value || e.innerHTML === value);
|
|
127
|
+
}
|
|
108
128
|
getBounds() {
|
|
109
129
|
if (this.getBoundsTimeout != null) {
|
|
110
130
|
clearTimeout(this.getBoundsTimeout);
|
|
@@ -128,7 +148,10 @@ const Select = class {
|
|
|
128
148
|
}
|
|
129
149
|
get hostElement() { return getElement(this); }
|
|
130
150
|
static get watchers() { return {
|
|
131
|
-
"value": ["handleUpdateValue"]
|
|
151
|
+
"value": ["handleUpdateValue"],
|
|
152
|
+
"displayValue": ["handleUpdateDisplayValue"],
|
|
153
|
+
"hideSelected": ["handleUpdateDisplayValue"],
|
|
154
|
+
"placeholder": ["handleUpdateDisplayValue"]
|
|
132
155
|
}; }
|
|
133
156
|
};
|
|
134
157
|
Select.style = selectCss;
|
|
@@ -79,6 +79,7 @@ const TextField = class {
|
|
|
79
79
|
render() {
|
|
80
80
|
var _a;
|
|
81
81
|
const classes = classnames('txt-wrapper', {
|
|
82
|
+
'txt-wrapper-border': !this.multiline,
|
|
82
83
|
'txt-standard': this.variant === 'standard',
|
|
83
84
|
'txt-filled': this.variant === 'filled',
|
|
84
85
|
'txt-underlined': this.variant === 'underlined',
|