@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
@@ -1,288 +0,0 @@
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
- const getWindowSelection = () => {
6
- if (typeof window !== 'undefined') {
7
- return window.getSelection();
8
- }
9
- return undefined;
10
- };
11
- const createDocumentRange = () => {
12
- return document.createRange();
13
- };
14
- const isTextNode = (node) => {
15
- return node instanceof Text;
16
- };
17
- const isHtmlElement = (target) => {
18
- return target instanceof HTMLElement;
19
- };
20
- const isReplacedElement = (el) => {
21
- return (el === null || el === void 0 ? void 0 : el.getAttribute('data-replaced')) === 'true';
22
- };
23
- const createTextNode = (text) => {
24
- return new Text(text != null && text !== '' ? text : ' ');
25
- };
26
-
27
- 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}.test-mention.sc-vertex-search-bar{display:inline-block;color:blue}.hidden.sc-vertex-search-bar{visibility:hidden}.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}.textarea.sc-vertex-search-bar{overflow:hidden;outline:none;box-shadow:none;resize:none}.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)}";
28
-
29
- const SearchBar = class {
30
- constructor(hostRef) {
31
- registerInstance(this, hostRef);
32
- this.triggerCharacterPressed = createEvent(this, "triggerCharacterPressed", 7);
33
- this.valueChanged = createEvent(this, "valueChanged", 7);
34
- this.inputFocus = createEvent(this, "inputFocus", 7);
35
- this.inputBlur = createEvent(this, "inputBlur", 7);
36
- this.resultsEnterPressed = createEvent(this, "resultsEnterPressed", 7);
37
- this.handleKeyDown = (event) => {
38
- if ((this.triggerCharacters.includes(event.key) ||
39
- this.triggerCharacter === event.key) &&
40
- this.triggerKey == null) {
41
- this.triggerKey = event.key;
42
- this.updateCursorPosition();
43
- this.triggerCharacterPressed.emit('');
44
- }
45
- else {
46
- this.restartTriggerInput();
47
- }
48
- if (event.key === 'Backspace') {
49
- const selection = getWindowSelection();
50
- if (selection && (selection === null || selection === void 0 ? void 0 : selection.rangeCount) > 0) {
51
- const range = selection.getRangeAt(0);
52
- range.deleteContents();
53
- }
54
- }
55
- this.valueChanged.emit();
56
- };
57
- this.handleKeyUp = (event) => {
58
- if (event.key === 'Backspace') {
59
- this.updateTriggerState(this.getSelectionSubstring());
60
- }
61
- if (event.key === 'Enter') {
62
- this.clearTriggerState();
63
- }
64
- this.valueChanged.emit();
65
- };
66
- this.updateTriggerValue = (data) => {
67
- var _a, _b, _c, _d, _e;
68
- if (this.triggerKey != null &&
69
- this.triggerRange != null &&
70
- this.triggerRange.startContainer === this.triggerRange.endContainer) {
71
- const triggerRangeNode = this.triggerRange.startContainer;
72
- if (isTextNode(triggerRangeNode)) {
73
- const before = createTextNode((_a = triggerRangeNode.textContent) === null || _a === void 0 ? void 0 : _a.slice(0, this.triggerRange.startOffset - 1));
74
- const after = createTextNode((_b = triggerRangeNode.textContent) === null || _b === void 0 ? void 0 : _b.slice(this.triggerRange.endOffset));
75
- const replaced = this.createReplacedElement(data);
76
- (_c = triggerRangeNode.parentElement) === null || _c === void 0 ? void 0 : _c.insertBefore(before, triggerRangeNode);
77
- (_d = triggerRangeNode.parentElement) === null || _d === void 0 ? void 0 : _d.insertBefore(after, triggerRangeNode.nextSibling);
78
- (_e = triggerRangeNode.parentElement) === null || _e === void 0 ? void 0 : _e.insertBefore(replaced, after);
79
- triggerRangeNode.remove();
80
- this.moveCursorToNodeEnd(after, true);
81
- }
82
- }
83
- };
84
- this.triggerText = () => {
85
- var _a, _b;
86
- if (this.triggerKey != null &&
87
- this.triggerRange != null &&
88
- this.triggerRange.startContainer === this.triggerRange.endContainer) {
89
- const triggerRangeNode = this.triggerRange.startContainer;
90
- return ((_b = (_a = triggerRangeNode.textContent) === null || _a === void 0 ? void 0 : _a.slice(this.triggerRange.startOffset, this.triggerRange.endOffset)) !== null && _b !== void 0 ? _b : '');
91
- }
92
- return '';
93
- };
94
- this.restartTriggerInput = () => {
95
- this.clearTriggerTimeout();
96
- this.triggerTimeout = setTimeout(() => {
97
- if (this.triggerRange != null && this.triggerKey != null) {
98
- this.triggerCharacterPressed.emit(this.triggerText());
99
- }
100
- this.triggerTimeout = undefined;
101
- }, this.debounce);
102
- };
103
- this.clearTriggerTimeout = () => {
104
- if (this.triggerTimeout != null) {
105
- clearTimeout(this.triggerTimeout);
106
- this.triggerTimeout = undefined;
107
- }
108
- };
109
- this.updateCursorPosition = () => {
110
- var _a;
111
- const selection = getWindowSelection();
112
- if (selection != null && selection.rangeCount > 0) {
113
- const cursorBounds = selection.getRangeAt(0).getBoundingClientRect();
114
- const inputBounds = (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
115
- const cursorBottom = cursorBounds.bottom || (inputBounds === null || inputBounds === void 0 ? void 0 : inputBounds.bottom) || 0;
116
- const cursorTop = cursorBounds.top || (inputBounds === null || inputBounds === void 0 ? void 0 : inputBounds.top) || 0;
117
- this.cursorPosition = {
118
- x: cursorBounds.left || (inputBounds === null || inputBounds === void 0 ? void 0 : inputBounds.left) || 0,
119
- y: this.placement.includes('top') ? cursorTop : cursorBottom,
120
- };
121
- }
122
- };
123
- this.moveCursorToNodeEnd = (node, collapseToStart = false) => {
124
- const selection = getWindowSelection();
125
- if (selection != null) {
126
- const range = createDocumentRange();
127
- range.selectNodeContents(node);
128
- range.collapse(collapseToStart);
129
- selection.removeAllRanges();
130
- selection.addRange(range);
131
- }
132
- };
133
- this.updateInputCursorPosition = (target) => {
134
- if (isHtmlElement(target)) {
135
- const targetElement = isReplacedElement(target.parentElement)
136
- ? target.parentElement
137
- : target;
138
- if (isReplacedElement(targetElement)) {
139
- this.insertAdjacentTextNode(targetElement);
140
- }
141
- }
142
- };
143
- this.createReplacedElement = (data) => {
144
- const template = this.hostEl.querySelector('template[slot="replaced"]');
145
- if (template != null) {
146
- const instance = generateInstanceFromTemplate(template);
147
- instance.bindings.bind(data);
148
- instance.element.style.display = 'inline-block';
149
- instance.element.contentEditable = 'false';
150
- instance.element.setAttribute('data-replaced', 'true');
151
- return instance.element;
152
- }
153
- else {
154
- throw new Error('Replaced template not defined.');
155
- }
156
- };
157
- this.handleSelectionChange = () => {
158
- this.updateTriggerState(this.getSelectionSubstring());
159
- };
160
- this.getSelectionSubstring = () => {
161
- var _a;
162
- const selection = getWindowSelection();
163
- if (selection != null && selection.rangeCount > 0) {
164
- const range = selection.getRangeAt(0);
165
- this.updateTriggerRange();
166
- if (range != null &&
167
- range.startOffset === range.endOffset &&
168
- isTextNode(range.startContainer) &&
169
- range.startContainer.textContent != null &&
170
- !isReplacedElement(range.startContainer.parentElement) &&
171
- ((_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.contains(range.startContainer))) {
172
- return range.startContainer.textContent.slice(this.lastIndexOfBreakCharacter(range.startContainer.textContent.slice(0, range.startOffset)) + 1, range.startOffset);
173
- }
174
- }
175
- return '';
176
- };
177
- this.insertAdjacentTextNode = (el) => {
178
- el.insertAdjacentText('afterend', '');
179
- if (el.nextSibling != null) {
180
- this.moveCursorToNodeEnd(el.nextSibling);
181
- }
182
- };
183
- this.updateTriggerState = (text) => {
184
- const triggers = this.triggerCharacter != null
185
- ? [...this.triggerCharacters, this.triggerCharacter]
186
- : this.triggerCharacters;
187
- const trigger = triggers.find((tc) => text.includes(tc));
188
- if (trigger != null) {
189
- this.restartTriggerInput();
190
- this.triggerKey = trigger;
191
- this.updateTriggerRange();
192
- if (this.cursorPosition == null) {
193
- this.updateCursorPosition();
194
- }
195
- this.open = true;
196
- }
197
- else {
198
- this.clearTriggerState();
199
- }
200
- };
201
- this.updateTriggerRange = () => {
202
- var _a;
203
- const selection = getWindowSelection();
204
- if (selection != null && selection.rangeCount > 0) {
205
- const range = selection.getRangeAt(0);
206
- if (this.triggerKey != null) {
207
- this.triggerRange = (_a = this.triggerRange) !== null && _a !== void 0 ? _a : range.cloneRange();
208
- this.triggerRange.setEnd(range.endContainer, range.endOffset);
209
- }
210
- }
211
- };
212
- this.clearTriggerState = () => {
213
- this.triggerKey = undefined;
214
- this.triggerRange = undefined;
215
- this.cursorPosition = undefined;
216
- this.open = false;
217
- this.clearTriggerTimeout();
218
- };
219
- this.lastIndexOfBreakCharacter = (search) => {
220
- const index = this.breakCharacters.reduce((index, bc) => {
221
- const searchIndex = search
222
- .replace(String.fromCharCode(160), ' ')
223
- .lastIndexOf(bc);
224
- return searchIndex > index ? searchIndex : index;
225
- }, -1);
226
- return index;
227
- };
228
- this.handleFocus = (ev) => {
229
- this.inputFocus.emit(ev);
230
- };
231
- this.handleBlur = (ev) => {
232
- this.open = false;
233
- this.inputBlur.emit(ev);
234
- };
235
- this.handleInputPointerEvent = (ev) => {
236
- if (ev.target != null) {
237
- this.updateInputCursorPosition(ev.target);
238
- }
239
- };
240
- this.handleResultPointerDown = (ev) => {
241
- ev.preventDefault();
242
- };
243
- this.variant = 'standard';
244
- this.resultItems = undefined;
245
- this.triggerCharacters = [];
246
- this.triggerCharacter = undefined;
247
- this.breakCharacters = [' '];
248
- this.debounce = 100;
249
- this.placeholder = undefined;
250
- this.placement = 'bottom-start';
251
- this.cursorPosition = undefined;
252
- this.open = false;
253
- this.triggerKey = undefined;
254
- this.triggerRange = undefined;
255
- }
256
- componentWillLoad() {
257
- document.addEventListener('selectionchange', this.handleSelectionChange);
258
- }
259
- disconnectedCallback() {
260
- document.removeEventListener('selectionchange', this.handleSelectionChange);
261
- }
262
- async replaceTriggeredValue(data) {
263
- this.updateTriggerValue(data);
264
- this.clearTriggerState();
265
- this.valueChanged.emit();
266
- }
267
- async getEditableContent() {
268
- var _a;
269
- return (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.childNodes;
270
- }
271
- render() {
272
- var _a;
273
- const classes = classnames('wrapper', {
274
- standard: this.variant === 'standard',
275
- filled: this.variant === 'filled',
276
- underlined: this.variant === 'underlined',
277
- blank: this.variant === 'blank',
278
- });
279
- return (h(Host, null, h("div", { class: classes }, h("span", { class: "content-input", ref: (ref) => (this.contentEl = ref), role: "textbox", contenteditable: "true", "aria-multiline": "true", "data-placeholder": this.placeholder, onKeyDown: this.handleKeyDown, onKeyUp: this.handleKeyUp, onBlur: this.handleBlur, onFocus: this.handleFocus, onPointerDown: this.handleInputPointerEvent, onPointerUp: this.handleInputPointerEvent })), h("vertex-result-list", { position: this.cursorPosition, placement: this.placement, open: this.open &&
280
- this.resultItems != null &&
281
- this.resultItems.length > 0 &&
282
- this.cursorPosition != null, items: (_a = this.resultItems) !== null && _a !== void 0 ? _a : [], onPointerDown: this.handleResultPointerDown, onEnterPressed: (event) => this.resultsEnterPressed.emit(event.detail) }, h("slot", { name: "results" })), h("slot", { name: "replaced" })));
283
- }
284
- get hostEl() { return getElement(this); }
285
- };
286
- SearchBar.style = searchBarCss;
287
-
288
- export { SearchBar as S };