@vertexvis/ui 0.1.0-testing.4 → 0.1.0-testing.6
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/components.cjs.js +1 -1
- package/dist/cjs/index.cjs.js +6 -6
- 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-e101ba43.js +398 -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-02e24a48.js → tooltip-e9f63631.js} +58 -19
- 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/components/menu/menu.js +1 -1
- package/dist/collection/components/popover/popover.js +51 -0
- package/dist/collection/components/result-list/result-list.js +47 -3
- package/dist/collection/components/search-bar/dom.js +12 -0
- package/dist/collection/components/search-bar/lib.js +23 -15
- package/dist/collection/components/search-bar/search-bar.css +2 -29
- package/dist/collection/components/search-bar/search-bar.js +353 -326
- 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.css +0 -4
- package/dist/collection/components/tooltip/tooltip.js +62 -18
- 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-0b1cdc8a.entry.js +1 -0
- package/dist/components/p-406e73da.entry.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-8393b6a7.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-ee496965.entry.js +1 -0
- package/dist/components/p-f51fef1d.entry.js +1 -0
- package/dist/esm/components.js +1 -1
- package/dist/esm/index.js +6 -6
- 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-12d91ad5.js +396 -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-b4d2a889.js → tooltip-933da261.js} +58 -19
- 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/popover/popover.d.ts +7 -0
- package/dist/types/components/result-list/result-list.d.ts +9 -1
- package/dist/types/components/search-bar/dom.d.ts +3 -0
- package/dist/types/components/search-bar/lib.d.ts +12 -6
- package/dist/types/components/search-bar/search-bar.d.ts +98 -41
- 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 +81 -16
- package/dist/types/util/templates/element-pool.d.ts +10 -1
- package/package.json +4 -3
- package/dist/cjs/search-bar-bb40cfa7.js +0 -290
- package/dist/components/p-19318fee.entry.js +0 -1
- package/dist/components/p-209db2ba.entry.js +0 -1
- package/dist/components/p-2bb3b235.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-ae6a3c46.entry.js +0 -1
- package/dist/components/p-bd11e7d1.js +0 -1
- package/dist/components/p-c8dd68a1.entry.js +0 -1
- package/dist/components/p-e576818b.entry.js +0 -1
- package/dist/components/p-ebabee40.entry.js +0 -1
- package/dist/esm/search-bar-59cc151d.js +0 -288
|
@@ -0,0 +1,396 @@
|
|
|
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 != null && text !== '' ? text : ' ');
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const createResultUrn = (result) => {
|
|
64
|
+
return `${result.type}:${result.id}`;
|
|
65
|
+
};
|
|
66
|
+
const createSearchResultReplacement = (result, before, after) => {
|
|
67
|
+
const urn = createResultUrn(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
|
+
const trimNonstandardSpaces = (text) => {
|
|
83
|
+
return text.replace(/[\u200A]/g, '').replace(/[\u00A0]/g, ' ');
|
|
84
|
+
};
|
|
85
|
+
const createHairSpace = () => {
|
|
86
|
+
return String.fromCharCode(8202);
|
|
87
|
+
};
|
|
88
|
+
const createNoBreakSpace = () => {
|
|
89
|
+
return String.fromCharCode(160);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const searchBarCss = ".wrapper.sc-vertex-search-bar{display:flex;border:1px solid var(--vertex-ui-neutral-600);border-radius:0.5rem}.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}.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)}";
|
|
93
|
+
|
|
94
|
+
const SearchBar = class {
|
|
95
|
+
constructor(hostRef) {
|
|
96
|
+
registerInstance(this, hostRef);
|
|
97
|
+
this.searchChanged = createEvent(this, "searchChanged", 7);
|
|
98
|
+
this.inputChanged = createEvent(this, "inputChanged", 7);
|
|
99
|
+
this.resultReplaced = createEvent(this, "resultReplaced", 7);
|
|
100
|
+
this.inputFocus = createEvent(this, "inputFocus", 7);
|
|
101
|
+
this.inputBlur = createEvent(this, "inputBlur", 7);
|
|
102
|
+
this.rawElements = [];
|
|
103
|
+
this.isIdenticalElement = (child, other) => {
|
|
104
|
+
return (child === this.triggeredElement ||
|
|
105
|
+
this.getTextContent(child) === this.getTextContent(other));
|
|
106
|
+
};
|
|
107
|
+
this.getTextContent = (node) => {
|
|
108
|
+
var _a;
|
|
109
|
+
if (node instanceof HTMLElement) {
|
|
110
|
+
return node.innerText;
|
|
111
|
+
}
|
|
112
|
+
return (_a = node.textContent) !== null && _a !== void 0 ? _a : '';
|
|
113
|
+
};
|
|
114
|
+
this.handleCursorPositionUpdate = () => {
|
|
115
|
+
var _a, _b, _c;
|
|
116
|
+
const windowRange = (_a = getWindowSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0);
|
|
117
|
+
if (windowRange != null) {
|
|
118
|
+
if (!this.hasTriggered) {
|
|
119
|
+
const triggerText = this.readTriggerValue((_b = windowRange.commonAncestorContainer.textContent) !== null && _b !== void 0 ? _b : '', windowRange.startOffset);
|
|
120
|
+
if (triggerText != null) {
|
|
121
|
+
this.hasTriggered = true;
|
|
122
|
+
this.triggeredRange = windowRange;
|
|
123
|
+
this.triggeredElement = windowRange.commonAncestorContainer;
|
|
124
|
+
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else if (this.hasTriggered) {
|
|
128
|
+
const triggerText = this.readTriggerValue((_c = windowRange.commonAncestorContainer.textContent) !== null && _c !== void 0 ? _c : '', windowRange.startOffset);
|
|
129
|
+
if (triggerText != null) {
|
|
130
|
+
this.triggeredRange = windowRange;
|
|
131
|
+
this.triggeredElement = windowRange.commonAncestorContainer;
|
|
132
|
+
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this.hasTriggered = false;
|
|
136
|
+
this.triggeredRange = undefined;
|
|
137
|
+
this.triggeredElement = undefined;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
this.cursorPosition = this.getCursorPosition();
|
|
142
|
+
};
|
|
143
|
+
this.readTriggerValue = (value, fromIndex) => {
|
|
144
|
+
const adjustedValue = value.replace(String.fromCharCode(160), ' ');
|
|
145
|
+
const beforeSubstr = adjustedValue.substring(0, fromIndex);
|
|
146
|
+
const afterSubstr = adjustedValue.substring(fromIndex);
|
|
147
|
+
const adjustedBeforeSubstr = beforeSubstr.includes(this.triggerCharacter)
|
|
148
|
+
? beforeSubstr.substring(beforeSubstr.lastIndexOf(this.triggerCharacter))
|
|
149
|
+
: '';
|
|
150
|
+
const adjustedAfterSubstr = afterSubstr.substring(0, this.firstIndexOfBreakCharacter(afterSubstr));
|
|
151
|
+
const result = `${adjustedBeforeSubstr}${adjustedAfterSubstr}`;
|
|
152
|
+
return result.includes(this.triggerCharacter) &&
|
|
153
|
+
!this.includesBreakCharacter(result)
|
|
154
|
+
? result
|
|
155
|
+
: undefined;
|
|
156
|
+
};
|
|
157
|
+
this.includesBreakCharacter = (value) => {
|
|
158
|
+
return this.breakCharacters.some((bc) => value.includes(bc));
|
|
159
|
+
};
|
|
160
|
+
this.firstIndexOfBreakCharacter = (value) => {
|
|
161
|
+
const indices = this.breakCharacters
|
|
162
|
+
.map((bc) => value.indexOf(bc))
|
|
163
|
+
.filter((i) => i >= 0);
|
|
164
|
+
return indices.length > 0 ? Math.min(...indices) : value.length;
|
|
165
|
+
};
|
|
166
|
+
this.moveCursorToNodeEnd = (node, collapseToStart = false) => {
|
|
167
|
+
const selection = getWindowSelection();
|
|
168
|
+
if (selection != null) {
|
|
169
|
+
const range = createDocumentRange();
|
|
170
|
+
range.selectNodeContents(node);
|
|
171
|
+
range.collapse(collapseToStart);
|
|
172
|
+
selection.removeAllRanges();
|
|
173
|
+
selection.addRange(range);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
this.getContentAsString = () => {
|
|
177
|
+
if (this.contentEl != null) {
|
|
178
|
+
return trimNonstandardSpaces(Array.from(this.contentEl.childNodes).reduce((res, n) => {
|
|
179
|
+
var _a;
|
|
180
|
+
if (n instanceof HTMLElement &&
|
|
181
|
+
n.getAttribute('data-replaced') === 'true') {
|
|
182
|
+
return `${res}${n.getAttribute('data-original')}`;
|
|
183
|
+
}
|
|
184
|
+
else if (n instanceof HTMLElement) {
|
|
185
|
+
return `${res}${n.innerText}`;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
return `${res}${(_a = n.textContent) !== null && _a !== void 0 ? _a : ''}`;
|
|
189
|
+
}
|
|
190
|
+
}, ''));
|
|
191
|
+
}
|
|
192
|
+
return '';
|
|
193
|
+
};
|
|
194
|
+
this.createReplacedElement = (original, data) => {
|
|
195
|
+
const template = this.hostEl.querySelector('template[slot="replaced"]');
|
|
196
|
+
if (template != null) {
|
|
197
|
+
const instance = generateInstanceFromTemplate(template);
|
|
198
|
+
instance.bindings.bind(data);
|
|
199
|
+
instance.element.id = data.id;
|
|
200
|
+
instance.element.style.display = 'inline-block';
|
|
201
|
+
instance.element.contentEditable = 'false';
|
|
202
|
+
instance.element.tabIndex = -1;
|
|
203
|
+
instance.element.setAttribute('data-replaced', 'true');
|
|
204
|
+
instance.element.setAttribute('data-original', original);
|
|
205
|
+
return instance.element;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
throw new Error('Replaced template not defined.');
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
this.variant = 'standard';
|
|
212
|
+
this.disabled = false;
|
|
213
|
+
this.triggerCharacter = '@';
|
|
214
|
+
this.breakCharacters = [' ', '\n'];
|
|
215
|
+
this.resultItems = undefined;
|
|
216
|
+
this.placement = 'bottom-start';
|
|
217
|
+
this.value = undefined;
|
|
218
|
+
this.placeholder = undefined;
|
|
219
|
+
this.replacements = [];
|
|
220
|
+
this.cursorPosition = { x: 0, y: 0 };
|
|
221
|
+
this.displayedElements = [];
|
|
222
|
+
this.hasTriggered = false;
|
|
223
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
224
|
+
this.handleKeyUp = this.handleKeyUp.bind(this);
|
|
225
|
+
this.handleResultClick = this.handleResultClick.bind(this);
|
|
226
|
+
this.handleClick = this.handleClick.bind(this);
|
|
227
|
+
this.handleWindowClick = this.handleWindowClick.bind(this);
|
|
228
|
+
this.handleInput = this.handleInput.bind(this);
|
|
229
|
+
this.handleBlur = this.handleBlur.bind(this);
|
|
230
|
+
this.handleFocus = this.handleFocus.bind(this);
|
|
231
|
+
this.handleCursorPositionUpdate =
|
|
232
|
+
this.handleCursorPositionUpdate.bind(this);
|
|
233
|
+
this.updateContent = this.updateContent.bind(this);
|
|
234
|
+
this.replaceContent = this.replaceContent.bind(this);
|
|
235
|
+
}
|
|
236
|
+
componentDidLoad() {
|
|
237
|
+
this.replaceContent(this.value);
|
|
238
|
+
}
|
|
239
|
+
connectedCallback() {
|
|
240
|
+
window.addEventListener('click', this.handleWindowClick);
|
|
241
|
+
}
|
|
242
|
+
disconnectedCallback() {
|
|
243
|
+
window.removeEventListener('click', this.handleWindowClick);
|
|
244
|
+
}
|
|
245
|
+
replaceContent(newValue, oldValue) {
|
|
246
|
+
if (newValue != null && newValue !== oldValue) {
|
|
247
|
+
const matches = newValue.match(/[a-z]*:[0-9a-z-]{36}/g);
|
|
248
|
+
const replacementsMap = this.replacements.reduce((map, r) => (Object.assign(Object.assign({}, map), { [createResultUrn(r)]: r })), {});
|
|
249
|
+
let nextSubstr = newValue;
|
|
250
|
+
const parts = matches != null
|
|
251
|
+
? matches === null || matches === void 0 ? void 0 : matches.reduce((res, m) => {
|
|
252
|
+
if (replacementsMap[m] != null) {
|
|
253
|
+
const urn = createResultUrn(replacementsMap[m]);
|
|
254
|
+
const index = nextSubstr.indexOf(urn);
|
|
255
|
+
const before = nextSubstr.substring(0, index);
|
|
256
|
+
const after = nextSubstr.substring(index + urn.length);
|
|
257
|
+
const replacement = createSearchResultReplacement(replacementsMap[m], before);
|
|
258
|
+
nextSubstr = after;
|
|
259
|
+
return [
|
|
260
|
+
...res,
|
|
261
|
+
replacement.before,
|
|
262
|
+
replacement.beforeSpace,
|
|
263
|
+
replacement.result,
|
|
264
|
+
];
|
|
265
|
+
}
|
|
266
|
+
return res;
|
|
267
|
+
}, [])
|
|
268
|
+
: [];
|
|
269
|
+
this.rawElements = [...parts, createTextNode(nextSubstr)];
|
|
270
|
+
this.updateContent(this.replacements);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
updateContent(newValue, oldValue) {
|
|
274
|
+
if (this.contentEl != null && !fastDeepEqual(newValue, oldValue)) {
|
|
275
|
+
this.contentEl.innerHTML = '';
|
|
276
|
+
this.displayedElements = this.rawElements.map((el) => {
|
|
277
|
+
const raw = el instanceof HTMLElement ? el.innerText : el.textContent;
|
|
278
|
+
const replacement = this.replacements.find((r) => raw === null || raw === void 0 ? void 0 : raw.includes(r.id));
|
|
279
|
+
if (raw != null && replacement != null) {
|
|
280
|
+
const replacementElement = this.createReplacedElement(raw, replacement);
|
|
281
|
+
return replacementElement;
|
|
282
|
+
}
|
|
283
|
+
return el;
|
|
284
|
+
});
|
|
285
|
+
this.displayedElements.forEach((el) => {
|
|
286
|
+
var _a;
|
|
287
|
+
(_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.appendChild(typeof el === 'string' ? createTextNode(el) : el);
|
|
288
|
+
});
|
|
289
|
+
if (this.lastReplacedSpace != null) {
|
|
290
|
+
this.moveCursorToNodeEnd(this.lastReplacedSpace);
|
|
291
|
+
}
|
|
292
|
+
this.inputChanged.emit(this.getContentAsString());
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
render() {
|
|
296
|
+
var _a;
|
|
297
|
+
const classes = classnames('wrapper', {
|
|
298
|
+
standard: this.variant === 'standard',
|
|
299
|
+
filled: this.variant === 'filled',
|
|
300
|
+
underlined: this.variant === 'underlined',
|
|
301
|
+
blank: this.variant === 'blank',
|
|
302
|
+
disabled: this.disabled,
|
|
303
|
+
});
|
|
304
|
+
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 &&
|
|
305
|
+
this.resultItems != null &&
|
|
306
|
+
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" })));
|
|
307
|
+
}
|
|
308
|
+
handleKeyDown(event) {
|
|
309
|
+
if (this.hasTriggered && this.breakCharacters.includes(event.key)) {
|
|
310
|
+
this.hasTriggered = false;
|
|
311
|
+
this.triggeredRange = undefined;
|
|
312
|
+
this.triggeredElement = undefined;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
handleKeyUp(event) {
|
|
316
|
+
this.handleCursorPositionUpdate();
|
|
317
|
+
this.cursorPosition = this.getCursorPosition();
|
|
318
|
+
}
|
|
319
|
+
async handleInput() {
|
|
320
|
+
this.inputChanged.emit(this.getContentAsString());
|
|
321
|
+
}
|
|
322
|
+
handleClick() {
|
|
323
|
+
this.handleCursorPositionUpdate();
|
|
324
|
+
}
|
|
325
|
+
handleWindowClick(event) {
|
|
326
|
+
if (event.target instanceof HTMLElement &&
|
|
327
|
+
event.target.getAttribute('data-replaced') === 'true' &&
|
|
328
|
+
event.target.nextSibling != null) {
|
|
329
|
+
this.moveCursorToNodeEnd(event.target.nextSibling, true);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
handleFocus(event) {
|
|
333
|
+
this.inputFocus.emit(event);
|
|
334
|
+
}
|
|
335
|
+
handleBlur(event) {
|
|
336
|
+
this.hasTriggered = false;
|
|
337
|
+
this.inputBlur.emit(event);
|
|
338
|
+
}
|
|
339
|
+
handleResultClick(event) {
|
|
340
|
+
var _a;
|
|
341
|
+
const triggeredRange = this.triggeredRange;
|
|
342
|
+
const triggeredElement = this.triggeredElement;
|
|
343
|
+
const value = triggeredElement instanceof HTMLElement
|
|
344
|
+
? triggeredElement.innerText
|
|
345
|
+
: triggeredElement === null || triggeredElement === void 0 ? void 0 : triggeredElement.textContent;
|
|
346
|
+
if (this.contentEl != null &&
|
|
347
|
+
triggeredRange != null &&
|
|
348
|
+
triggeredElement != null &&
|
|
349
|
+
value != null) {
|
|
350
|
+
const triggeredValue = (_a = this.readTriggerValue(value, triggeredRange.startOffset)) !== null && _a !== void 0 ? _a : '';
|
|
351
|
+
const split = value.split(triggeredValue);
|
|
352
|
+
const before = split[0];
|
|
353
|
+
const after = split[1];
|
|
354
|
+
const replacement = createSearchResultReplacement(event.detail, before, after);
|
|
355
|
+
this.lastReplacedSpace = replacement.afterSpace;
|
|
356
|
+
this.rawElements = Array.from(this.contentEl.childNodes).reduce((re, e) => {
|
|
357
|
+
// TODO: see if we can do anything about the collapse to single line in safari
|
|
358
|
+
if (this.isIdenticalElement(e, triggeredElement)) {
|
|
359
|
+
return [...re, ...getNodesForSearchResultReplacement(replacement)];
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
return [...re, e];
|
|
363
|
+
}
|
|
364
|
+
}, []);
|
|
365
|
+
this.hasTriggered = false;
|
|
366
|
+
this.replacements = [
|
|
367
|
+
...this.replacements.filter((r) => r.id !== event.detail.id),
|
|
368
|
+
event.detail,
|
|
369
|
+
];
|
|
370
|
+
this.resultReplaced.emit(event.detail);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
getCursorPosition() {
|
|
374
|
+
var _a;
|
|
375
|
+
const selection = getWindowSelection();
|
|
376
|
+
if (selection != null && selection.rangeCount > 0) {
|
|
377
|
+
const cursorBounds = selection.getRangeAt(0).getBoundingClientRect();
|
|
378
|
+
const contentBounds = (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
379
|
+
const cursorBottom = cursorBounds.bottom || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.bottom) || 0;
|
|
380
|
+
const cursorTop = cursorBounds.top || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.top) || 0;
|
|
381
|
+
return {
|
|
382
|
+
x: cursorBounds.left || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.left) || 0,
|
|
383
|
+
y: this.placement.includes('top') ? cursorTop : cursorBottom,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
throw new Error('Unable to retrieve window selection.');
|
|
387
|
+
}
|
|
388
|
+
get hostEl() { return getElement(this); }
|
|
389
|
+
static get watchers() { return {
|
|
390
|
+
"value": ["replaceContent"],
|
|
391
|
+
"replacements": ["updateContent"]
|
|
392
|
+
}; }
|
|
393
|
+
};
|
|
394
|
+
SearchBar.style = searchBarCss;
|
|
395
|
+
|
|
396
|
+
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',
|
|
@@ -2054,12 +2054,13 @@ function getBoundingClientRect(el) {
|
|
|
2054
2054
|
return el.getBoundingClientRect();
|
|
2055
2055
|
}
|
|
2056
2056
|
|
|
2057
|
-
const tooltipCss = ":host{--tooltip-width:auto;--tooltip-white-space:normal;display:flex}.popover{width:100%;height:100%}.target{display:flex;width:100%;height:100%}.content-hidden{display:none}.
|
|
2057
|
+
const tooltipCss = ":host{--tooltip-width:auto;--tooltip-white-space:normal;display:flex}.popover{width:100%;height:100%}.target{display:flex;width:100%;height:100%}.content-hidden{display:none}.tooltip{display:flex;justify-content:center;text-align:center;width:var(--tooltip-width);font-family:var(--vertex-ui-font-family);font-size:var(--vertex-ui-text-xxs);background-color:var(--vertex-ui-neutral-700);color:var(--vertex-ui-white);padding:0.25rem 0.5rem;border-radius:4px;pointer-events:none;white-space:var(--tooltip-white-space);user-select:none}.tooltip.hidden{display:none}";
|
|
2058
2058
|
|
|
2059
2059
|
const TOOLTIP_OPEN_DELAY = 500;
|
|
2060
2060
|
const Tooltip = class {
|
|
2061
2061
|
constructor(hostRef) {
|
|
2062
2062
|
registerInstance(this, hostRef);
|
|
2063
|
+
this.pointerEntered = false;
|
|
2063
2064
|
this.content = undefined;
|
|
2064
2065
|
this.disabled = undefined;
|
|
2065
2066
|
this.placement = 'bottom';
|
|
@@ -2068,32 +2069,40 @@ const Tooltip = class {
|
|
|
2068
2069
|
this.open = false;
|
|
2069
2070
|
this.handlePointerEnter = this.handlePointerEnter.bind(this);
|
|
2070
2071
|
this.handlePointerLeave = this.handlePointerLeave.bind(this);
|
|
2072
|
+
this.handleContentChange = this.handleContentChange.bind(this);
|
|
2073
|
+
this.handleDisabledChange = this.handleDisabledChange.bind(this);
|
|
2071
2074
|
this.tooltipId = `vertex-tooltip-${uuid.create()}`;
|
|
2072
2075
|
}
|
|
2073
2076
|
disconnectedCallback() {
|
|
2074
2077
|
this.removeElement();
|
|
2075
2078
|
this.clearOpenTimeout();
|
|
2079
|
+
this.pointerEntered = false;
|
|
2080
|
+
}
|
|
2081
|
+
handleContentChange() {
|
|
2082
|
+
if (this.internalContentElement != null) {
|
|
2083
|
+
this.updateContentElementChildren(this.internalContentElement);
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
handleDisabledChange() {
|
|
2087
|
+
if (this.internalContentElement != null) {
|
|
2088
|
+
this.updateContentElementClass(this.internalContentElement);
|
|
2089
|
+
}
|
|
2090
|
+
if (!this.disabled && this.pointerEntered) {
|
|
2091
|
+
this.handlePointerEnter();
|
|
2092
|
+
}
|
|
2076
2093
|
}
|
|
2077
2094
|
render() {
|
|
2078
2095
|
return (h(Host, null, h("div", { class: "target", ref: (el) => {
|
|
2079
2096
|
this.targetElement = el;
|
|
2080
2097
|
}, onPointerEnter: this.handlePointerEnter, onPointerLeave: this.handlePointerLeave }, h("slot", null)), h("div", { class: "content-hidden", ref: (el) => {
|
|
2081
2098
|
this.contentElement = el;
|
|
2082
|
-
} }, h("slot", { name: "content" }))));
|
|
2099
|
+
} }, h("slot", { name: "content", onSlotchange: this.handleContentChange }))));
|
|
2083
2100
|
}
|
|
2084
2101
|
addElement() {
|
|
2085
|
-
var _a;
|
|
2086
2102
|
if (this.targetElement != null) {
|
|
2087
2103
|
const popover = this.createPopoverElement(this.targetElement);
|
|
2088
2104
|
const content = this.createContentElement();
|
|
2089
|
-
this.
|
|
2090
|
-
(_a = getSlottedContent(this.contentElement)) !== null && _a !== void 0 ? _a : this.displayedSlottedContent;
|
|
2091
|
-
if (this.content != null) {
|
|
2092
|
-
content.innerText = this.content;
|
|
2093
|
-
}
|
|
2094
|
-
else if (this.displayedSlottedContent != null) {
|
|
2095
|
-
content.appendChild(this.displayedSlottedContent);
|
|
2096
|
-
}
|
|
2105
|
+
this.updateContentElementChildren(content);
|
|
2097
2106
|
popover.appendChild(content);
|
|
2098
2107
|
this.hostElement.ownerDocument.body.appendChild(popover);
|
|
2099
2108
|
}
|
|
@@ -2103,6 +2112,7 @@ const Tooltip = class {
|
|
|
2103
2112
|
if (popover != null) {
|
|
2104
2113
|
popover.remove();
|
|
2105
2114
|
}
|
|
2115
|
+
this.internalContentElement = undefined;
|
|
2106
2116
|
}
|
|
2107
2117
|
createPopoverElement(anchorElement) {
|
|
2108
2118
|
const popover = this.hostElement.ownerDocument.createElement('vertex-popover');
|
|
@@ -2117,25 +2127,50 @@ const Tooltip = class {
|
|
|
2117
2127
|
return popover;
|
|
2118
2128
|
}
|
|
2119
2129
|
createContentElement() {
|
|
2120
|
-
|
|
2121
|
-
|
|
2130
|
+
this.internalContentElement =
|
|
2131
|
+
this.hostElement.ownerDocument.createElement('div');
|
|
2132
|
+
this.internalContentElement.setAttribute('class', classnames('vertex-tooltip-content', {
|
|
2133
|
+
hidden: !this.open || this.disabled,
|
|
2134
|
+
}));
|
|
2135
|
+
return this.internalContentElement;
|
|
2136
|
+
}
|
|
2137
|
+
updateContentElementClass(element) {
|
|
2138
|
+
element.setAttribute('class', classnames('vertex-tooltip-content', {
|
|
2122
2139
|
hidden: !this.open || this.disabled,
|
|
2123
2140
|
}));
|
|
2124
|
-
|
|
2141
|
+
}
|
|
2142
|
+
updateContentElementChildren(element) {
|
|
2143
|
+
var _a;
|
|
2144
|
+
this.displayedSlottedContent =
|
|
2145
|
+
(_a = getSlottedContent(this.contentElement)) !== null && _a !== void 0 ? _a : this.displayedSlottedContent;
|
|
2146
|
+
if (this.content != null) {
|
|
2147
|
+
element.innerText = this.content;
|
|
2148
|
+
}
|
|
2149
|
+
else if (this.displayedSlottedContent != null) {
|
|
2150
|
+
element.appendChild(this.displayedSlottedContent);
|
|
2151
|
+
}
|
|
2125
2152
|
}
|
|
2126
2153
|
handlePointerEnter() {
|
|
2127
2154
|
if (this.openTimeout == null && !this.disabled) {
|
|
2128
|
-
this.
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
}, this.delay);
|
|
2155
|
+
this.createOpenTimeout();
|
|
2156
|
+
}
|
|
2157
|
+
else if (this.openTimeout == null) {
|
|
2158
|
+
this.pointerEntered = true;
|
|
2133
2159
|
}
|
|
2134
2160
|
}
|
|
2135
2161
|
handlePointerLeave() {
|
|
2136
2162
|
this.clearOpenTimeout();
|
|
2137
2163
|
this.removeElement();
|
|
2138
2164
|
this.open = false;
|
|
2165
|
+
this.pointerEntered = false;
|
|
2166
|
+
}
|
|
2167
|
+
createOpenTimeout() {
|
|
2168
|
+
this.openTimeout = setTimeout(() => {
|
|
2169
|
+
this.open = true;
|
|
2170
|
+
this.openTimeout = undefined;
|
|
2171
|
+
this.addElement();
|
|
2172
|
+
}, this.delay);
|
|
2173
|
+
this.pointerEntered = false;
|
|
2139
2174
|
}
|
|
2140
2175
|
clearOpenTimeout() {
|
|
2141
2176
|
if (this.openTimeout != null) {
|
|
@@ -2144,6 +2179,10 @@ const Tooltip = class {
|
|
|
2144
2179
|
}
|
|
2145
2180
|
}
|
|
2146
2181
|
get hostElement() { return getElement(this); }
|
|
2182
|
+
static get watchers() { return {
|
|
2183
|
+
"content": ["handleContentChange"],
|
|
2184
|
+
"disabled": ["handleDisabledChange"]
|
|
2185
|
+
}; }
|
|
2147
2186
|
};
|
|
2148
2187
|
Tooltip.style = tooltipCss;
|
|
2149
2188
|
|