@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.
Files changed (82) hide show
  1. package/dist/cjs/components.cjs.js +1 -1
  2. package/dist/cjs/index.cjs.js +6 -6
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{popover-d9ec8e10.js → popover-942209b8.js} +23 -1
  5. package/dist/cjs/{result-list-1e592c3c.js → result-list-241ffe8d.js} +46 -2
  6. package/dist/cjs/search-bar-e101ba43.js +398 -0
  7. package/dist/cjs/{select-0eb7203f.js → select-5f8aecfe.js} +27 -4
  8. package/dist/cjs/{text-field-0397fb34.js → text-field-bccbde1f.js} +1 -0
  9. package/dist/cjs/{tooltip-02e24a48.js → tooltip-e9f63631.js} +58 -19
  10. package/dist/cjs/vertex-popover.cjs.entry.js +1 -1
  11. package/dist/cjs/vertex-result-list.cjs.entry.js +1 -1
  12. package/dist/cjs/vertex-search-bar.cjs.entry.js +1 -1
  13. package/dist/cjs/vertex-select.cjs.entry.js +1 -1
  14. package/dist/cjs/vertex-textfield.cjs.entry.js +1 -1
  15. package/dist/cjs/vertex-tooltip.cjs.entry.js +1 -1
  16. package/dist/collection/components/menu/menu.js +1 -1
  17. package/dist/collection/components/popover/popover.js +51 -0
  18. package/dist/collection/components/result-list/result-list.js +47 -3
  19. package/dist/collection/components/search-bar/dom.js +12 -0
  20. package/dist/collection/components/search-bar/lib.js +23 -15
  21. package/dist/collection/components/search-bar/search-bar.css +2 -29
  22. package/dist/collection/components/search-bar/search-bar.js +353 -326
  23. package/dist/collection/components/select/select.css +16 -0
  24. package/dist/collection/components/select/select.js +49 -2
  25. package/dist/collection/components/text-field/text-field.js +1 -0
  26. package/dist/collection/components/tooltip/tooltip.css +0 -4
  27. package/dist/collection/components/tooltip/tooltip.js +62 -18
  28. package/dist/collection/util/templates/element-pool.js +19 -1
  29. package/dist/components/components.css +1 -1
  30. package/dist/components/components.esm.js +1 -1
  31. package/dist/components/index.esm.js +1 -1
  32. package/dist/components/p-0b1cdc8a.entry.js +1 -0
  33. package/dist/components/p-406e73da.entry.js +1 -0
  34. package/dist/components/p-43b1b3f9.js +1 -0
  35. package/dist/components/p-606596de.entry.js +1 -0
  36. package/dist/components/p-6b862967.js +1 -0
  37. package/dist/components/p-7cfb3736.entry.js +1 -0
  38. package/dist/components/p-8393b6a7.js +1 -0
  39. package/dist/components/p-912f6e24.js +1 -0
  40. package/dist/components/p-92930f2a.js +1 -0
  41. package/dist/components/p-c2706288.js +1 -0
  42. package/dist/components/p-ee496965.entry.js +1 -0
  43. package/dist/components/p-f51fef1d.entry.js +1 -0
  44. package/dist/esm/components.js +1 -1
  45. package/dist/esm/index.js +6 -6
  46. package/dist/esm/loader.js +1 -1
  47. package/dist/esm/{popover-67c88e4b.js → popover-6e806354.js} +23 -1
  48. package/dist/esm/{result-list-36cfb08a.js → result-list-16c6afbd.js} +46 -2
  49. package/dist/esm/search-bar-12d91ad5.js +396 -0
  50. package/dist/esm/{select-75ed5653.js → select-d4e135b7.js} +27 -4
  51. package/dist/esm/{text-field-e542da25.js → text-field-32ac877e.js} +1 -0
  52. package/dist/esm/{tooltip-b4d2a889.js → tooltip-933da261.js} +58 -19
  53. package/dist/esm/vertex-popover.entry.js +1 -1
  54. package/dist/esm/vertex-result-list.entry.js +1 -1
  55. package/dist/esm/vertex-search-bar.entry.js +1 -1
  56. package/dist/esm/vertex-select.entry.js +1 -1
  57. package/dist/esm/vertex-textfield.entry.js +1 -1
  58. package/dist/esm/vertex-tooltip.entry.js +1 -1
  59. package/dist/types/components/popover/popover.d.ts +7 -0
  60. package/dist/types/components/result-list/result-list.d.ts +9 -1
  61. package/dist/types/components/search-bar/dom.d.ts +3 -0
  62. package/dist/types/components/search-bar/lib.d.ts +12 -6
  63. package/dist/types/components/search-bar/search-bar.d.ts +98 -41
  64. package/dist/types/components/select/select.d.ts +8 -0
  65. package/dist/types/components/tooltip/tooltip.d.ts +7 -0
  66. package/dist/types/components.d.ts +81 -16
  67. package/dist/types/util/templates/element-pool.d.ts +10 -1
  68. package/package.json +4 -3
  69. package/dist/cjs/search-bar-bb40cfa7.js +0 -290
  70. package/dist/components/p-19318fee.entry.js +0 -1
  71. package/dist/components/p-209db2ba.entry.js +0 -1
  72. package/dist/components/p-2bb3b235.js +0 -1
  73. package/dist/components/p-4224c2ad.js +0 -1
  74. package/dist/components/p-52739247.js +0 -1
  75. package/dist/components/p-552c128f.js +0 -1
  76. package/dist/components/p-6505cdb3.js +0 -1
  77. package/dist/components/p-ae6a3c46.entry.js +0 -1
  78. package/dist/components/p-bd11e7d1.js +0 -1
  79. package/dist/components/p-c8dd68a1.entry.js +0 -1
  80. package/dist/components/p-e576818b.entry.js +0 -1
  81. package/dist/components/p-ebabee40.entry.js +0 -1
  82. package/dist/esm/search-bar-59cc151d.js +0 -288
@@ -0,0 +1,398 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-6a92256c.js');
4
+ const index$1 = require('./index-e1b40fa6.js');
5
+ const templates = require('./templates-e7b3ffbb.js');
6
+
7
+ // do not edit .js files directly - edit src/index.jst
8
+
9
+
10
+
11
+ var fastDeepEqual = function equal(a, b) {
12
+ if (a === b) return true;
13
+
14
+ if (a && b && typeof a == 'object' && typeof b == 'object') {
15
+ if (a.constructor !== b.constructor) return false;
16
+
17
+ var length, i, keys;
18
+ if (Array.isArray(a)) {
19
+ length = a.length;
20
+ if (length != b.length) return false;
21
+ for (i = length; i-- !== 0;)
22
+ if (!equal(a[i], b[i])) return false;
23
+ return true;
24
+ }
25
+
26
+
27
+
28
+ if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
29
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
30
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
31
+
32
+ keys = Object.keys(a);
33
+ length = keys.length;
34
+ if (length !== Object.keys(b).length) return false;
35
+
36
+ for (i = length; i-- !== 0;)
37
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
38
+
39
+ for (i = length; i-- !== 0;) {
40
+ var key = keys[i];
41
+
42
+ if (!equal(a[key], b[key])) return false;
43
+ }
44
+
45
+ return true;
46
+ }
47
+
48
+ // true if both NaN, false otherwise
49
+ return a!==a && b!==b;
50
+ };
51
+
52
+ const getWindowSelection = () => {
53
+ if (typeof window !== 'undefined') {
54
+ return window.getSelection();
55
+ }
56
+ return undefined;
57
+ };
58
+ const createDocumentRange = () => {
59
+ return document.createRange();
60
+ };
61
+ const createTextNode = (text) => {
62
+ return new Text(text != null && text !== '' ? text : ' ');
63
+ };
64
+
65
+ const createResultUrn = (result) => {
66
+ return `${result.type}:${result.id}`;
67
+ };
68
+ const createSearchResultReplacement = (result, before, after) => {
69
+ const urn = createResultUrn(result);
70
+ return {
71
+ before: createTextNode(before),
72
+ beforeSpace: createTextNode(createHairSpace()),
73
+ result: createTextNode(urn),
74
+ afterSpace: after != null ? createTextNode(createNoBreakSpace()) : undefined,
75
+ after: after != null ? createTextNode(after) : undefined,
76
+ };
77
+ };
78
+ const getNodesForSearchResultReplacement = (replacement) => {
79
+ const keys = Object.keys(replacement);
80
+ return keys
81
+ .map((key) => replacement[key])
82
+ .filter((node) => node != null);
83
+ };
84
+ const trimNonstandardSpaces = (text) => {
85
+ return text.replace(/[\u200A]/g, '').replace(/[\u00A0]/g, ' ');
86
+ };
87
+ const createHairSpace = () => {
88
+ return String.fromCharCode(8202);
89
+ };
90
+ const createNoBreakSpace = () => {
91
+ return String.fromCharCode(160);
92
+ };
93
+
94
+ 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)}";
95
+
96
+ const SearchBar = class {
97
+ constructor(hostRef) {
98
+ index.registerInstance(this, hostRef);
99
+ this.searchChanged = index.createEvent(this, "searchChanged", 7);
100
+ this.inputChanged = index.createEvent(this, "inputChanged", 7);
101
+ this.resultReplaced = index.createEvent(this, "resultReplaced", 7);
102
+ this.inputFocus = index.createEvent(this, "inputFocus", 7);
103
+ this.inputBlur = index.createEvent(this, "inputBlur", 7);
104
+ this.rawElements = [];
105
+ this.isIdenticalElement = (child, other) => {
106
+ return (child === this.triggeredElement ||
107
+ this.getTextContent(child) === this.getTextContent(other));
108
+ };
109
+ this.getTextContent = (node) => {
110
+ var _a;
111
+ if (node instanceof HTMLElement) {
112
+ return node.innerText;
113
+ }
114
+ return (_a = node.textContent) !== null && _a !== void 0 ? _a : '';
115
+ };
116
+ this.handleCursorPositionUpdate = () => {
117
+ var _a, _b, _c;
118
+ const windowRange = (_a = getWindowSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0);
119
+ if (windowRange != null) {
120
+ if (!this.hasTriggered) {
121
+ const triggerText = this.readTriggerValue((_b = windowRange.commonAncestorContainer.textContent) !== null && _b !== void 0 ? _b : '', windowRange.startOffset);
122
+ if (triggerText != null) {
123
+ this.hasTriggered = true;
124
+ this.triggeredRange = windowRange;
125
+ this.triggeredElement = windowRange.commonAncestorContainer;
126
+ this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
127
+ }
128
+ }
129
+ else if (this.hasTriggered) {
130
+ const triggerText = this.readTriggerValue((_c = windowRange.commonAncestorContainer.textContent) !== null && _c !== void 0 ? _c : '', windowRange.startOffset);
131
+ if (triggerText != null) {
132
+ this.triggeredRange = windowRange;
133
+ this.triggeredElement = windowRange.commonAncestorContainer;
134
+ this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
135
+ }
136
+ else {
137
+ this.hasTriggered = false;
138
+ this.triggeredRange = undefined;
139
+ this.triggeredElement = undefined;
140
+ }
141
+ }
142
+ }
143
+ this.cursorPosition = this.getCursorPosition();
144
+ };
145
+ this.readTriggerValue = (value, fromIndex) => {
146
+ const adjustedValue = value.replace(String.fromCharCode(160), ' ');
147
+ const beforeSubstr = adjustedValue.substring(0, fromIndex);
148
+ const afterSubstr = adjustedValue.substring(fromIndex);
149
+ const adjustedBeforeSubstr = beforeSubstr.includes(this.triggerCharacter)
150
+ ? beforeSubstr.substring(beforeSubstr.lastIndexOf(this.triggerCharacter))
151
+ : '';
152
+ const adjustedAfterSubstr = afterSubstr.substring(0, this.firstIndexOfBreakCharacter(afterSubstr));
153
+ const result = `${adjustedBeforeSubstr}${adjustedAfterSubstr}`;
154
+ return result.includes(this.triggerCharacter) &&
155
+ !this.includesBreakCharacter(result)
156
+ ? result
157
+ : undefined;
158
+ };
159
+ this.includesBreakCharacter = (value) => {
160
+ return this.breakCharacters.some((bc) => value.includes(bc));
161
+ };
162
+ this.firstIndexOfBreakCharacter = (value) => {
163
+ const indices = this.breakCharacters
164
+ .map((bc) => value.indexOf(bc))
165
+ .filter((i) => i >= 0);
166
+ return indices.length > 0 ? Math.min(...indices) : value.length;
167
+ };
168
+ this.moveCursorToNodeEnd = (node, collapseToStart = false) => {
169
+ const selection = getWindowSelection();
170
+ if (selection != null) {
171
+ const range = createDocumentRange();
172
+ range.selectNodeContents(node);
173
+ range.collapse(collapseToStart);
174
+ selection.removeAllRanges();
175
+ selection.addRange(range);
176
+ }
177
+ };
178
+ this.getContentAsString = () => {
179
+ if (this.contentEl != null) {
180
+ return trimNonstandardSpaces(Array.from(this.contentEl.childNodes).reduce((res, n) => {
181
+ var _a;
182
+ if (n instanceof HTMLElement &&
183
+ n.getAttribute('data-replaced') === 'true') {
184
+ return `${res}${n.getAttribute('data-original')}`;
185
+ }
186
+ else if (n instanceof HTMLElement) {
187
+ return `${res}${n.innerText}`;
188
+ }
189
+ else {
190
+ return `${res}${(_a = n.textContent) !== null && _a !== void 0 ? _a : ''}`;
191
+ }
192
+ }, ''));
193
+ }
194
+ return '';
195
+ };
196
+ this.createReplacedElement = (original, data) => {
197
+ const template = this.hostEl.querySelector('template[slot="replaced"]');
198
+ if (template != null) {
199
+ const instance = templates.generateInstanceFromTemplate(template);
200
+ instance.bindings.bind(data);
201
+ instance.element.id = data.id;
202
+ instance.element.style.display = 'inline-block';
203
+ instance.element.contentEditable = 'false';
204
+ instance.element.tabIndex = -1;
205
+ instance.element.setAttribute('data-replaced', 'true');
206
+ instance.element.setAttribute('data-original', original);
207
+ return instance.element;
208
+ }
209
+ else {
210
+ throw new Error('Replaced template not defined.');
211
+ }
212
+ };
213
+ this.variant = 'standard';
214
+ this.disabled = false;
215
+ this.triggerCharacter = '@';
216
+ this.breakCharacters = [' ', '\n'];
217
+ this.resultItems = undefined;
218
+ this.placement = 'bottom-start';
219
+ this.value = undefined;
220
+ this.placeholder = undefined;
221
+ this.replacements = [];
222
+ this.cursorPosition = { x: 0, y: 0 };
223
+ this.displayedElements = [];
224
+ this.hasTriggered = false;
225
+ this.handleKeyDown = this.handleKeyDown.bind(this);
226
+ this.handleKeyUp = this.handleKeyUp.bind(this);
227
+ this.handleResultClick = this.handleResultClick.bind(this);
228
+ this.handleClick = this.handleClick.bind(this);
229
+ this.handleWindowClick = this.handleWindowClick.bind(this);
230
+ this.handleInput = this.handleInput.bind(this);
231
+ this.handleBlur = this.handleBlur.bind(this);
232
+ this.handleFocus = this.handleFocus.bind(this);
233
+ this.handleCursorPositionUpdate =
234
+ this.handleCursorPositionUpdate.bind(this);
235
+ this.updateContent = this.updateContent.bind(this);
236
+ this.replaceContent = this.replaceContent.bind(this);
237
+ }
238
+ componentDidLoad() {
239
+ this.replaceContent(this.value);
240
+ }
241
+ connectedCallback() {
242
+ window.addEventListener('click', this.handleWindowClick);
243
+ }
244
+ disconnectedCallback() {
245
+ window.removeEventListener('click', this.handleWindowClick);
246
+ }
247
+ replaceContent(newValue, oldValue) {
248
+ if (newValue != null && newValue !== oldValue) {
249
+ const matches = newValue.match(/[a-z]*:[0-9a-z-]{36}/g);
250
+ const replacementsMap = this.replacements.reduce((map, r) => (Object.assign(Object.assign({}, map), { [createResultUrn(r)]: r })), {});
251
+ let nextSubstr = newValue;
252
+ const parts = matches != null
253
+ ? matches === null || matches === void 0 ? void 0 : matches.reduce((res, m) => {
254
+ if (replacementsMap[m] != null) {
255
+ const urn = createResultUrn(replacementsMap[m]);
256
+ const index = nextSubstr.indexOf(urn);
257
+ const before = nextSubstr.substring(0, index);
258
+ const after = nextSubstr.substring(index + urn.length);
259
+ const replacement = createSearchResultReplacement(replacementsMap[m], before);
260
+ nextSubstr = after;
261
+ return [
262
+ ...res,
263
+ replacement.before,
264
+ replacement.beforeSpace,
265
+ replacement.result,
266
+ ];
267
+ }
268
+ return res;
269
+ }, [])
270
+ : [];
271
+ this.rawElements = [...parts, createTextNode(nextSubstr)];
272
+ this.updateContent(this.replacements);
273
+ }
274
+ }
275
+ updateContent(newValue, oldValue) {
276
+ if (this.contentEl != null && !fastDeepEqual(newValue, oldValue)) {
277
+ this.contentEl.innerHTML = '';
278
+ this.displayedElements = this.rawElements.map((el) => {
279
+ const raw = el instanceof HTMLElement ? el.innerText : el.textContent;
280
+ const replacement = this.replacements.find((r) => raw === null || raw === void 0 ? void 0 : raw.includes(r.id));
281
+ if (raw != null && replacement != null) {
282
+ const replacementElement = this.createReplacedElement(raw, replacement);
283
+ return replacementElement;
284
+ }
285
+ return el;
286
+ });
287
+ this.displayedElements.forEach((el) => {
288
+ var _a;
289
+ (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.appendChild(typeof el === 'string' ? createTextNode(el) : el);
290
+ });
291
+ if (this.lastReplacedSpace != null) {
292
+ this.moveCursorToNodeEnd(this.lastReplacedSpace);
293
+ }
294
+ this.inputChanged.emit(this.getContentAsString());
295
+ }
296
+ }
297
+ render() {
298
+ var _a;
299
+ const classes = index$1.classnames('wrapper', {
300
+ standard: this.variant === 'standard',
301
+ filled: this.variant === 'filled',
302
+ underlined: this.variant === 'underlined',
303
+ blank: this.variant === 'blank',
304
+ disabled: this.disabled,
305
+ });
306
+ return (index.h(index.Host, null, index.h("div", { class: classes }, index.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 })), index.h("vertex-result-list", { position: this.cursorPosition, placement: this.placement, open: this.hasTriggered &&
307
+ this.resultItems != null &&
308
+ this.resultItems.length > 0, items: (_a = this.resultItems) !== null && _a !== void 0 ? _a : [], onEnterPressed: this.handleResultClick, onResultClick: this.handleResultClick }, index.h("slot", { name: "results" })), index.h("slot", { name: "replaced" })));
309
+ }
310
+ handleKeyDown(event) {
311
+ if (this.hasTriggered && this.breakCharacters.includes(event.key)) {
312
+ this.hasTriggered = false;
313
+ this.triggeredRange = undefined;
314
+ this.triggeredElement = undefined;
315
+ }
316
+ }
317
+ handleKeyUp(event) {
318
+ this.handleCursorPositionUpdate();
319
+ this.cursorPosition = this.getCursorPosition();
320
+ }
321
+ async handleInput() {
322
+ this.inputChanged.emit(this.getContentAsString());
323
+ }
324
+ handleClick() {
325
+ this.handleCursorPositionUpdate();
326
+ }
327
+ handleWindowClick(event) {
328
+ if (event.target instanceof HTMLElement &&
329
+ event.target.getAttribute('data-replaced') === 'true' &&
330
+ event.target.nextSibling != null) {
331
+ this.moveCursorToNodeEnd(event.target.nextSibling, true);
332
+ }
333
+ }
334
+ handleFocus(event) {
335
+ this.inputFocus.emit(event);
336
+ }
337
+ handleBlur(event) {
338
+ this.hasTriggered = false;
339
+ this.inputBlur.emit(event);
340
+ }
341
+ handleResultClick(event) {
342
+ var _a;
343
+ const triggeredRange = this.triggeredRange;
344
+ const triggeredElement = this.triggeredElement;
345
+ const value = triggeredElement instanceof HTMLElement
346
+ ? triggeredElement.innerText
347
+ : triggeredElement === null || triggeredElement === void 0 ? void 0 : triggeredElement.textContent;
348
+ if (this.contentEl != null &&
349
+ triggeredRange != null &&
350
+ triggeredElement != null &&
351
+ value != null) {
352
+ const triggeredValue = (_a = this.readTriggerValue(value, triggeredRange.startOffset)) !== null && _a !== void 0 ? _a : '';
353
+ const split = value.split(triggeredValue);
354
+ const before = split[0];
355
+ const after = split[1];
356
+ const replacement = createSearchResultReplacement(event.detail, before, after);
357
+ this.lastReplacedSpace = replacement.afterSpace;
358
+ this.rawElements = Array.from(this.contentEl.childNodes).reduce((re, e) => {
359
+ // TODO: see if we can do anything about the collapse to single line in safari
360
+ if (this.isIdenticalElement(e, triggeredElement)) {
361
+ return [...re, ...getNodesForSearchResultReplacement(replacement)];
362
+ }
363
+ else {
364
+ return [...re, e];
365
+ }
366
+ }, []);
367
+ this.hasTriggered = false;
368
+ this.replacements = [
369
+ ...this.replacements.filter((r) => r.id !== event.detail.id),
370
+ event.detail,
371
+ ];
372
+ this.resultReplaced.emit(event.detail);
373
+ }
374
+ }
375
+ getCursorPosition() {
376
+ var _a;
377
+ const selection = getWindowSelection();
378
+ if (selection != null && selection.rangeCount > 0) {
379
+ const cursorBounds = selection.getRangeAt(0).getBoundingClientRect();
380
+ const contentBounds = (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
381
+ const cursorBottom = cursorBounds.bottom || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.bottom) || 0;
382
+ const cursorTop = cursorBounds.top || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.top) || 0;
383
+ return {
384
+ x: cursorBounds.left || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.left) || 0,
385
+ y: this.placement.includes('top') ? cursorTop : cursorBottom,
386
+ };
387
+ }
388
+ throw new Error('Unable to retrieve window selection.');
389
+ }
390
+ get hostEl() { return index.getElement(this); }
391
+ static get watchers() { return {
392
+ "value": ["replaceContent"],
393
+ "replacements": ["updateContent"]
394
+ }; }
395
+ };
396
+ SearchBar.style = searchBarCss;
397
+
398
+ exports.SearchBar = SearchBar;
@@ -3,7 +3,7 @@
3
3
  const index = require('./index-6a92256c.js');
4
4
  const index$1 = require('./index-e1b40fa6.js');
5
5
 
6
- const selectCss = ":host{--select-width:100%}.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}.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)}vertex-popover{--transform-origin:top left;--open-animation-name:open-scale-y;--close-animation-name:close-scale-y}";
6
+ 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}";
7
7
 
8
8
  const GET_BOUNDS_DEBOUNCE_THRESHOLD = 200;
9
9
  const Select = class {
@@ -16,6 +16,7 @@ const Select = class {
16
16
  this.placeholder = 'Select an option...';
17
17
  this.disabled = false;
18
18
  this.animated = true;
19
+ this.hideSelected = true;
19
20
  this.open = false;
20
21
  this.position = undefined;
21
22
  this.displayValue = undefined;
@@ -35,6 +36,9 @@ const Select = class {
35
36
  if (this.value != null) {
36
37
  this.handleUpdateValue(this.value);
37
38
  }
39
+ else {
40
+ this.handleUpdateDisplayValue();
41
+ }
38
42
  }
39
43
  connectedCallback() {
40
44
  window.addEventListener('resize', this.getBounds);
@@ -52,6 +56,13 @@ const Select = class {
52
56
  }
53
57
  this.controlled = value != null;
54
58
  }
59
+ handleUpdateDisplayValue() {
60
+ var _a;
61
+ this.clearSelectedOptionFlag();
62
+ if (this.hideSelected) {
63
+ (_a = this.getSelectedOption()) === null || _a === void 0 ? void 0 : _a.setAttribute('data-selected', 'true');
64
+ }
65
+ }
55
66
  render() {
56
67
  return (index.h("div", { class: index$1.classnames('root', {
57
68
  disabled: this.disabled,
@@ -60,7 +71,7 @@ const Select = class {
60
71
  }, onClick: !this.open && !this.disabled ? this.handleOpen : undefined }, index.h("div", { class: index$1.classnames('target', {
61
72
  hidden: this.open,
62
73
  disabled: this.disabled,
63
- }) }, this.displayValue || this.placeholder, index.h("div", { class: "icon" }, index.h("vertex-icon", { name: "chevron-down", size: "sm" }))), index.h("vertex-popover", { position: this.position, open: this.open, animated: this.animated, resizeBehavior: "fixed", onDismissed: this.handleDismiss }, index.h("div", { class: index$1.classnames('options', {
74
+ }) }, index.h("div", { class: "text" }, this.displayValue || this.placeholder), index.h("div", { class: "icon" }, index.h("vertex-icon", { name: "chevron-down", size: "sm" }))), index.h("vertex-popover", { position: this.position, open: this.open, animated: this.animated, resizeBehavior: "fixed", onDismissed: this.handleDismiss }, index.h("div", { class: index$1.classnames('options', {
64
75
  hidden: !this.open,
65
76
  visible: this.open,
66
77
  animated: this.animated,
@@ -68,7 +79,7 @@ const Select = class {
68
79
  minWidth: this.width != null ? `${this.width}px` : 'var(--select-width)',
69
80
  } }, index.h("div", { class: index$1.classnames('selected-option', {
70
81
  disabled: this.disabled,
71
- }), onClick: this.handleDismiss }, this.displayValue || this.placeholder, index.h("div", { class: "icon" }, index.h("vertex-icon", { name: "chevron-down", size: "sm" }))), index.h("slot", null)))));
82
+ }), onClick: this.handleDismiss }, index.h("div", { class: "text" }, this.displayValue || this.placeholder), index.h("div", { class: "icon" }, index.h("vertex-icon", { name: "chevron-down", size: "sm" }))), index.h("slot", null)))));
72
83
  }
73
84
  handleOpen() {
74
85
  var _a, _b;
@@ -107,6 +118,15 @@ const Select = class {
107
118
  this.removeListeners.forEach((l) => l());
108
119
  this.removeListeners = [];
109
120
  }
121
+ clearSelectedOptionFlag() {
122
+ var _a, _b;
123
+ (_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'));
124
+ }
125
+ getSelectedOption() {
126
+ var _a, _b, _c;
127
+ const value = (_a = this.displayValue) !== null && _a !== void 0 ? _a : this.placeholder;
128
+ 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);
129
+ }
110
130
  getBounds() {
111
131
  if (this.getBoundsTimeout != null) {
112
132
  clearTimeout(this.getBoundsTimeout);
@@ -130,7 +150,10 @@ const Select = class {
130
150
  }
131
151
  get hostElement() { return index.getElement(this); }
132
152
  static get watchers() { return {
133
- "value": ["handleUpdateValue"]
153
+ "value": ["handleUpdateValue"],
154
+ "displayValue": ["handleUpdateDisplayValue"],
155
+ "hideSelected": ["handleUpdateDisplayValue"],
156
+ "placeholder": ["handleUpdateDisplayValue"]
134
157
  }; }
135
158
  };
136
159
  Select.style = selectCss;
@@ -81,6 +81,7 @@ const TextField = class {
81
81
  render() {
82
82
  var _a;
83
83
  const classes = index$1.classnames('txt-wrapper', {
84
+ 'txt-wrapper-border': !this.multiline,
84
85
  'txt-standard': this.variant === 'standard',
85
86
  'txt-filled': this.variant === 'filled',
86
87
  'txt-underlined': this.variant === 'underlined',
@@ -2056,12 +2056,13 @@ function getBoundingClientRect(el) {
2056
2056
  return el.getBoundingClientRect();
2057
2057
  }
2058
2058
 
2059
- 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}.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}";
2059
+ 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}";
2060
2060
 
2061
2061
  const TOOLTIP_OPEN_DELAY = 500;
2062
2062
  const Tooltip = class {
2063
2063
  constructor(hostRef) {
2064
2064
  index.registerInstance(this, hostRef);
2065
+ this.pointerEntered = false;
2065
2066
  this.content = undefined;
2066
2067
  this.disabled = undefined;
2067
2068
  this.placement = 'bottom';
@@ -2070,32 +2071,40 @@ const Tooltip = class {
2070
2071
  this.open = false;
2071
2072
  this.handlePointerEnter = this.handlePointerEnter.bind(this);
2072
2073
  this.handlePointerLeave = this.handlePointerLeave.bind(this);
2074
+ this.handleContentChange = this.handleContentChange.bind(this);
2075
+ this.handleDisabledChange = this.handleDisabledChange.bind(this);
2073
2076
  this.tooltipId = `vertex-tooltip-${uuid.create()}`;
2074
2077
  }
2075
2078
  disconnectedCallback() {
2076
2079
  this.removeElement();
2077
2080
  this.clearOpenTimeout();
2081
+ this.pointerEntered = false;
2082
+ }
2083
+ handleContentChange() {
2084
+ if (this.internalContentElement != null) {
2085
+ this.updateContentElementChildren(this.internalContentElement);
2086
+ }
2087
+ }
2088
+ handleDisabledChange() {
2089
+ if (this.internalContentElement != null) {
2090
+ this.updateContentElementClass(this.internalContentElement);
2091
+ }
2092
+ if (!this.disabled && this.pointerEntered) {
2093
+ this.handlePointerEnter();
2094
+ }
2078
2095
  }
2079
2096
  render() {
2080
2097
  return (index.h(index.Host, null, index.h("div", { class: "target", ref: (el) => {
2081
2098
  this.targetElement = el;
2082
2099
  }, onPointerEnter: this.handlePointerEnter, onPointerLeave: this.handlePointerLeave }, index.h("slot", null)), index.h("div", { class: "content-hidden", ref: (el) => {
2083
2100
  this.contentElement = el;
2084
- } }, index.h("slot", { name: "content" }))));
2101
+ } }, index.h("slot", { name: "content", onSlotchange: this.handleContentChange }))));
2085
2102
  }
2086
2103
  addElement() {
2087
- var _a;
2088
2104
  if (this.targetElement != null) {
2089
2105
  const popover = this.createPopoverElement(this.targetElement);
2090
2106
  const content = this.createContentElement();
2091
- this.displayedSlottedContent =
2092
- (_a = slots.getSlottedContent(this.contentElement)) !== null && _a !== void 0 ? _a : this.displayedSlottedContent;
2093
- if (this.content != null) {
2094
- content.innerText = this.content;
2095
- }
2096
- else if (this.displayedSlottedContent != null) {
2097
- content.appendChild(this.displayedSlottedContent);
2098
- }
2107
+ this.updateContentElementChildren(content);
2099
2108
  popover.appendChild(content);
2100
2109
  this.hostElement.ownerDocument.body.appendChild(popover);
2101
2110
  }
@@ -2105,6 +2114,7 @@ const Tooltip = class {
2105
2114
  if (popover != null) {
2106
2115
  popover.remove();
2107
2116
  }
2117
+ this.internalContentElement = undefined;
2108
2118
  }
2109
2119
  createPopoverElement(anchorElement) {
2110
2120
  const popover = this.hostElement.ownerDocument.createElement('vertex-popover');
@@ -2119,25 +2129,50 @@ const Tooltip = class {
2119
2129
  return popover;
2120
2130
  }
2121
2131
  createContentElement() {
2122
- const content = this.hostElement.ownerDocument.createElement('div');
2123
- content.setAttribute('class', index$1.classnames('vertex-tooltip-content', {
2132
+ this.internalContentElement =
2133
+ this.hostElement.ownerDocument.createElement('div');
2134
+ this.internalContentElement.setAttribute('class', index$1.classnames('vertex-tooltip-content', {
2135
+ hidden: !this.open || this.disabled,
2136
+ }));
2137
+ return this.internalContentElement;
2138
+ }
2139
+ updateContentElementClass(element) {
2140
+ element.setAttribute('class', index$1.classnames('vertex-tooltip-content', {
2124
2141
  hidden: !this.open || this.disabled,
2125
2142
  }));
2126
- return content;
2143
+ }
2144
+ updateContentElementChildren(element) {
2145
+ var _a;
2146
+ this.displayedSlottedContent =
2147
+ (_a = slots.getSlottedContent(this.contentElement)) !== null && _a !== void 0 ? _a : this.displayedSlottedContent;
2148
+ if (this.content != null) {
2149
+ element.innerText = this.content;
2150
+ }
2151
+ else if (this.displayedSlottedContent != null) {
2152
+ element.appendChild(this.displayedSlottedContent);
2153
+ }
2127
2154
  }
2128
2155
  handlePointerEnter() {
2129
2156
  if (this.openTimeout == null && !this.disabled) {
2130
- this.openTimeout = setTimeout(() => {
2131
- this.open = true;
2132
- this.openTimeout = undefined;
2133
- this.addElement();
2134
- }, this.delay);
2157
+ this.createOpenTimeout();
2158
+ }
2159
+ else if (this.openTimeout == null) {
2160
+ this.pointerEntered = true;
2135
2161
  }
2136
2162
  }
2137
2163
  handlePointerLeave() {
2138
2164
  this.clearOpenTimeout();
2139
2165
  this.removeElement();
2140
2166
  this.open = false;
2167
+ this.pointerEntered = false;
2168
+ }
2169
+ createOpenTimeout() {
2170
+ this.openTimeout = setTimeout(() => {
2171
+ this.open = true;
2172
+ this.openTimeout = undefined;
2173
+ this.addElement();
2174
+ }, this.delay);
2175
+ this.pointerEntered = false;
2141
2176
  }
2142
2177
  clearOpenTimeout() {
2143
2178
  if (this.openTimeout != null) {
@@ -2146,6 +2181,10 @@ const Tooltip = class {
2146
2181
  }
2147
2182
  }
2148
2183
  get hostElement() { return index.getElement(this); }
2184
+ static get watchers() { return {
2185
+ "content": ["handleContentChange"],
2186
+ "disabled": ["handleDisabledChange"]
2187
+ }; }
2149
2188
  };
2150
2189
  Tooltip.style = tooltipCss;
2151
2190
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const popover = require('./popover-d9ec8e10.js');
5
+ const popover = require('./popover-942209b8.js');
6
6
  require('./index-6a92256c.js');
7
7
  require('./index-e1b40fa6.js');
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const resultList = require('./result-list-1e592c3c.js');
5
+ const resultList = require('./result-list-241ffe8d.js');
6
6
  require('./index-6a92256c.js');
7
7
  require('./index-e1b40fa6.js');
8
8
  require('./templates-e7b3ffbb.js');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const searchBar = require('./search-bar-bb40cfa7.js');
5
+ const searchBar = require('./search-bar-e101ba43.js');
6
6
  require('./index-6a92256c.js');
7
7
  require('./index-e1b40fa6.js');
8
8
  require('./templates-e7b3ffbb.js');