@vertexvis/ui 0.1.0-canary.6 → 0.1.0-canary.8
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 +3 -3
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{result-list-1e592c3c.js → result-list-241ffe8d.js} +46 -2
- package/dist/cjs/search-bar-91cbcd07.js +421 -0
- package/dist/cjs/{text-field-0397fb34.js → text-field-bccbde1f.js} +1 -0
- 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-textfield.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/result-list/result-list.js +52 -5
- package/dist/collection/components/result-list/types.js +1 -0
- package/dist/collection/components/search-bar/dom.js +12 -0
- package/dist/collection/components/search-bar/lib.js +35 -15
- package/dist/collection/components/search-bar/search-bar.css +0 -16
- package/dist/collection/components/search-bar/search-bar.js +380 -324
- package/dist/collection/components/text-field/text-field.js +1 -0
- package/dist/collection/util/templates/element-pool.js +19 -1
- package/dist/components/components.css +1 -1
- package/dist/components/components.esm.js +1 -1
- package/dist/components/index.esm.js +1 -1
- package/dist/components/p-406e73da.entry.js +1 -0
- package/dist/components/p-43b1b3f9.js +1 -0
- package/dist/components/p-6b862967.js +1 -0
- package/dist/components/p-cfe369bf.entry.js +1 -0
- package/dist/components/p-db34f10c.js +1 -0
- package/dist/components/p-ee496965.entry.js +1 -0
- package/dist/esm/components.js +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{result-list-36cfb08a.js → result-list-16c6afbd.js} +46 -2
- package/dist/esm/search-bar-f12a3599.js +419 -0
- package/dist/esm/{text-field-e542da25.js → text-field-32ac877e.js} +1 -0
- package/dist/esm/vertex-result-list.entry.js +1 -1
- package/dist/esm/vertex-search-bar.entry.js +1 -1
- package/dist/esm/vertex-textfield.entry.js +1 -1
- package/dist/types/components/result-list/result-list.d.ts +6 -1
- package/dist/types/components/result-list/types.d.ts +4 -0
- package/dist/types/components/search-bar/dom.d.ts +3 -0
- package/dist/types/components/search-bar/lib.d.ts +24 -6
- package/dist/types/components/search-bar/search-bar.d.ts +124 -42
- package/dist/types/components.d.ts +81 -20
- 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-4224c2ad.js +0 -1
- package/dist/components/p-52739247.js +0 -1
- package/dist/components/p-ae6a3c46.entry.js +0 -1
- package/dist/components/p-bd11e7d1.js +0 -1
- package/dist/esm/search-bar-59cc151d.js +0 -288
|
@@ -1,290 +0,0 @@
|
|
|
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
|
-
const getWindowSelection = () => {
|
|
8
|
-
if (typeof window !== 'undefined') {
|
|
9
|
-
return window.getSelection();
|
|
10
|
-
}
|
|
11
|
-
return undefined;
|
|
12
|
-
};
|
|
13
|
-
const createDocumentRange = () => {
|
|
14
|
-
return document.createRange();
|
|
15
|
-
};
|
|
16
|
-
const isTextNode = (node) => {
|
|
17
|
-
return node instanceof Text;
|
|
18
|
-
};
|
|
19
|
-
const isHtmlElement = (target) => {
|
|
20
|
-
return target instanceof HTMLElement;
|
|
21
|
-
};
|
|
22
|
-
const isReplacedElement = (el) => {
|
|
23
|
-
return (el === null || el === void 0 ? void 0 : el.getAttribute('data-replaced')) === 'true';
|
|
24
|
-
};
|
|
25
|
-
const createTextNode = (text) => {
|
|
26
|
-
return new Text(text != null && text !== '' ? text : ' ');
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
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)}";
|
|
30
|
-
|
|
31
|
-
const SearchBar = class {
|
|
32
|
-
constructor(hostRef) {
|
|
33
|
-
index.registerInstance(this, hostRef);
|
|
34
|
-
this.triggerCharacterPressed = index.createEvent(this, "triggerCharacterPressed", 7);
|
|
35
|
-
this.valueChanged = index.createEvent(this, "valueChanged", 7);
|
|
36
|
-
this.inputFocus = index.createEvent(this, "inputFocus", 7);
|
|
37
|
-
this.inputBlur = index.createEvent(this, "inputBlur", 7);
|
|
38
|
-
this.resultsEnterPressed = index.createEvent(this, "resultsEnterPressed", 7);
|
|
39
|
-
this.handleKeyDown = (event) => {
|
|
40
|
-
if ((this.triggerCharacters.includes(event.key) ||
|
|
41
|
-
this.triggerCharacter === event.key) &&
|
|
42
|
-
this.triggerKey == null) {
|
|
43
|
-
this.triggerKey = event.key;
|
|
44
|
-
this.updateCursorPosition();
|
|
45
|
-
this.triggerCharacterPressed.emit('');
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
this.restartTriggerInput();
|
|
49
|
-
}
|
|
50
|
-
if (event.key === 'Backspace') {
|
|
51
|
-
const selection = getWindowSelection();
|
|
52
|
-
if (selection && (selection === null || selection === void 0 ? void 0 : selection.rangeCount) > 0) {
|
|
53
|
-
const range = selection.getRangeAt(0);
|
|
54
|
-
range.deleteContents();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
this.valueChanged.emit();
|
|
58
|
-
};
|
|
59
|
-
this.handleKeyUp = (event) => {
|
|
60
|
-
if (event.key === 'Backspace') {
|
|
61
|
-
this.updateTriggerState(this.getSelectionSubstring());
|
|
62
|
-
}
|
|
63
|
-
if (event.key === 'Enter') {
|
|
64
|
-
this.clearTriggerState();
|
|
65
|
-
}
|
|
66
|
-
this.valueChanged.emit();
|
|
67
|
-
};
|
|
68
|
-
this.updateTriggerValue = (data) => {
|
|
69
|
-
var _a, _b, _c, _d, _e;
|
|
70
|
-
if (this.triggerKey != null &&
|
|
71
|
-
this.triggerRange != null &&
|
|
72
|
-
this.triggerRange.startContainer === this.triggerRange.endContainer) {
|
|
73
|
-
const triggerRangeNode = this.triggerRange.startContainer;
|
|
74
|
-
if (isTextNode(triggerRangeNode)) {
|
|
75
|
-
const before = createTextNode((_a = triggerRangeNode.textContent) === null || _a === void 0 ? void 0 : _a.slice(0, this.triggerRange.startOffset - 1));
|
|
76
|
-
const after = createTextNode((_b = triggerRangeNode.textContent) === null || _b === void 0 ? void 0 : _b.slice(this.triggerRange.endOffset));
|
|
77
|
-
const replaced = this.createReplacedElement(data);
|
|
78
|
-
(_c = triggerRangeNode.parentElement) === null || _c === void 0 ? void 0 : _c.insertBefore(before, triggerRangeNode);
|
|
79
|
-
(_d = triggerRangeNode.parentElement) === null || _d === void 0 ? void 0 : _d.insertBefore(after, triggerRangeNode.nextSibling);
|
|
80
|
-
(_e = triggerRangeNode.parentElement) === null || _e === void 0 ? void 0 : _e.insertBefore(replaced, after);
|
|
81
|
-
triggerRangeNode.remove();
|
|
82
|
-
this.moveCursorToNodeEnd(after, true);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
this.triggerText = () => {
|
|
87
|
-
var _a, _b;
|
|
88
|
-
if (this.triggerKey != null &&
|
|
89
|
-
this.triggerRange != null &&
|
|
90
|
-
this.triggerRange.startContainer === this.triggerRange.endContainer) {
|
|
91
|
-
const triggerRangeNode = this.triggerRange.startContainer;
|
|
92
|
-
return ((_b = (_a = triggerRangeNode.textContent) === null || _a === void 0 ? void 0 : _a.slice(this.triggerRange.startOffset, this.triggerRange.endOffset)) !== null && _b !== void 0 ? _b : '');
|
|
93
|
-
}
|
|
94
|
-
return '';
|
|
95
|
-
};
|
|
96
|
-
this.restartTriggerInput = () => {
|
|
97
|
-
this.clearTriggerTimeout();
|
|
98
|
-
this.triggerTimeout = setTimeout(() => {
|
|
99
|
-
if (this.triggerRange != null && this.triggerKey != null) {
|
|
100
|
-
this.triggerCharacterPressed.emit(this.triggerText());
|
|
101
|
-
}
|
|
102
|
-
this.triggerTimeout = undefined;
|
|
103
|
-
}, this.debounce);
|
|
104
|
-
};
|
|
105
|
-
this.clearTriggerTimeout = () => {
|
|
106
|
-
if (this.triggerTimeout != null) {
|
|
107
|
-
clearTimeout(this.triggerTimeout);
|
|
108
|
-
this.triggerTimeout = undefined;
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
this.updateCursorPosition = () => {
|
|
112
|
-
var _a;
|
|
113
|
-
const selection = getWindowSelection();
|
|
114
|
-
if (selection != null && selection.rangeCount > 0) {
|
|
115
|
-
const cursorBounds = selection.getRangeAt(0).getBoundingClientRect();
|
|
116
|
-
const inputBounds = (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
117
|
-
const cursorBottom = cursorBounds.bottom || (inputBounds === null || inputBounds === void 0 ? void 0 : inputBounds.bottom) || 0;
|
|
118
|
-
const cursorTop = cursorBounds.top || (inputBounds === null || inputBounds === void 0 ? void 0 : inputBounds.top) || 0;
|
|
119
|
-
this.cursorPosition = {
|
|
120
|
-
x: cursorBounds.left || (inputBounds === null || inputBounds === void 0 ? void 0 : inputBounds.left) || 0,
|
|
121
|
-
y: this.placement.includes('top') ? cursorTop : cursorBottom,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
this.moveCursorToNodeEnd = (node, collapseToStart = false) => {
|
|
126
|
-
const selection = getWindowSelection();
|
|
127
|
-
if (selection != null) {
|
|
128
|
-
const range = createDocumentRange();
|
|
129
|
-
range.selectNodeContents(node);
|
|
130
|
-
range.collapse(collapseToStart);
|
|
131
|
-
selection.removeAllRanges();
|
|
132
|
-
selection.addRange(range);
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
this.updateInputCursorPosition = (target) => {
|
|
136
|
-
if (isHtmlElement(target)) {
|
|
137
|
-
const targetElement = isReplacedElement(target.parentElement)
|
|
138
|
-
? target.parentElement
|
|
139
|
-
: target;
|
|
140
|
-
if (isReplacedElement(targetElement)) {
|
|
141
|
-
this.insertAdjacentTextNode(targetElement);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
this.createReplacedElement = (data) => {
|
|
146
|
-
const template = this.hostEl.querySelector('template[slot="replaced"]');
|
|
147
|
-
if (template != null) {
|
|
148
|
-
const instance = templates.generateInstanceFromTemplate(template);
|
|
149
|
-
instance.bindings.bind(data);
|
|
150
|
-
instance.element.style.display = 'inline-block';
|
|
151
|
-
instance.element.contentEditable = 'false';
|
|
152
|
-
instance.element.setAttribute('data-replaced', 'true');
|
|
153
|
-
return instance.element;
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
throw new Error('Replaced template not defined.');
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
this.handleSelectionChange = () => {
|
|
160
|
-
this.updateTriggerState(this.getSelectionSubstring());
|
|
161
|
-
};
|
|
162
|
-
this.getSelectionSubstring = () => {
|
|
163
|
-
var _a;
|
|
164
|
-
const selection = getWindowSelection();
|
|
165
|
-
if (selection != null && selection.rangeCount > 0) {
|
|
166
|
-
const range = selection.getRangeAt(0);
|
|
167
|
-
this.updateTriggerRange();
|
|
168
|
-
if (range != null &&
|
|
169
|
-
range.startOffset === range.endOffset &&
|
|
170
|
-
isTextNode(range.startContainer) &&
|
|
171
|
-
range.startContainer.textContent != null &&
|
|
172
|
-
!isReplacedElement(range.startContainer.parentElement) &&
|
|
173
|
-
((_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.contains(range.startContainer))) {
|
|
174
|
-
return range.startContainer.textContent.slice(this.lastIndexOfBreakCharacter(range.startContainer.textContent.slice(0, range.startOffset)) + 1, range.startOffset);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return '';
|
|
178
|
-
};
|
|
179
|
-
this.insertAdjacentTextNode = (el) => {
|
|
180
|
-
el.insertAdjacentText('afterend', '');
|
|
181
|
-
if (el.nextSibling != null) {
|
|
182
|
-
this.moveCursorToNodeEnd(el.nextSibling);
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
this.updateTriggerState = (text) => {
|
|
186
|
-
const triggers = this.triggerCharacter != null
|
|
187
|
-
? [...this.triggerCharacters, this.triggerCharacter]
|
|
188
|
-
: this.triggerCharacters;
|
|
189
|
-
const trigger = triggers.find((tc) => text.includes(tc));
|
|
190
|
-
if (trigger != null) {
|
|
191
|
-
this.restartTriggerInput();
|
|
192
|
-
this.triggerKey = trigger;
|
|
193
|
-
this.updateTriggerRange();
|
|
194
|
-
if (this.cursorPosition == null) {
|
|
195
|
-
this.updateCursorPosition();
|
|
196
|
-
}
|
|
197
|
-
this.open = true;
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
this.clearTriggerState();
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
this.updateTriggerRange = () => {
|
|
204
|
-
var _a;
|
|
205
|
-
const selection = getWindowSelection();
|
|
206
|
-
if (selection != null && selection.rangeCount > 0) {
|
|
207
|
-
const range = selection.getRangeAt(0);
|
|
208
|
-
if (this.triggerKey != null) {
|
|
209
|
-
this.triggerRange = (_a = this.triggerRange) !== null && _a !== void 0 ? _a : range.cloneRange();
|
|
210
|
-
this.triggerRange.setEnd(range.endContainer, range.endOffset);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
this.clearTriggerState = () => {
|
|
215
|
-
this.triggerKey = undefined;
|
|
216
|
-
this.triggerRange = undefined;
|
|
217
|
-
this.cursorPosition = undefined;
|
|
218
|
-
this.open = false;
|
|
219
|
-
this.clearTriggerTimeout();
|
|
220
|
-
};
|
|
221
|
-
this.lastIndexOfBreakCharacter = (search) => {
|
|
222
|
-
const index = this.breakCharacters.reduce((index, bc) => {
|
|
223
|
-
const searchIndex = search
|
|
224
|
-
.replace(String.fromCharCode(160), ' ')
|
|
225
|
-
.lastIndexOf(bc);
|
|
226
|
-
return searchIndex > index ? searchIndex : index;
|
|
227
|
-
}, -1);
|
|
228
|
-
return index;
|
|
229
|
-
};
|
|
230
|
-
this.handleFocus = (ev) => {
|
|
231
|
-
this.inputFocus.emit(ev);
|
|
232
|
-
};
|
|
233
|
-
this.handleBlur = (ev) => {
|
|
234
|
-
this.open = false;
|
|
235
|
-
this.inputBlur.emit(ev);
|
|
236
|
-
};
|
|
237
|
-
this.handleInputPointerEvent = (ev) => {
|
|
238
|
-
if (ev.target != null) {
|
|
239
|
-
this.updateInputCursorPosition(ev.target);
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
this.handleResultPointerDown = (ev) => {
|
|
243
|
-
ev.preventDefault();
|
|
244
|
-
};
|
|
245
|
-
this.variant = 'standard';
|
|
246
|
-
this.resultItems = undefined;
|
|
247
|
-
this.triggerCharacters = [];
|
|
248
|
-
this.triggerCharacter = undefined;
|
|
249
|
-
this.breakCharacters = [' '];
|
|
250
|
-
this.debounce = 100;
|
|
251
|
-
this.placeholder = undefined;
|
|
252
|
-
this.placement = 'bottom-start';
|
|
253
|
-
this.cursorPosition = undefined;
|
|
254
|
-
this.open = false;
|
|
255
|
-
this.triggerKey = undefined;
|
|
256
|
-
this.triggerRange = undefined;
|
|
257
|
-
}
|
|
258
|
-
componentWillLoad() {
|
|
259
|
-
document.addEventListener('selectionchange', this.handleSelectionChange);
|
|
260
|
-
}
|
|
261
|
-
disconnectedCallback() {
|
|
262
|
-
document.removeEventListener('selectionchange', this.handleSelectionChange);
|
|
263
|
-
}
|
|
264
|
-
async replaceTriggeredValue(data) {
|
|
265
|
-
this.updateTriggerValue(data);
|
|
266
|
-
this.clearTriggerState();
|
|
267
|
-
this.valueChanged.emit();
|
|
268
|
-
}
|
|
269
|
-
async getEditableContent() {
|
|
270
|
-
var _a;
|
|
271
|
-
return (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.childNodes;
|
|
272
|
-
}
|
|
273
|
-
render() {
|
|
274
|
-
var _a;
|
|
275
|
-
const classes = index$1.classnames('wrapper', {
|
|
276
|
-
standard: this.variant === 'standard',
|
|
277
|
-
filled: this.variant === 'filled',
|
|
278
|
-
underlined: this.variant === 'underlined',
|
|
279
|
-
blank: this.variant === 'blank',
|
|
280
|
-
});
|
|
281
|
-
return (index.h(index.Host, null, index.h("div", { class: classes }, index.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 })), index.h("vertex-result-list", { position: this.cursorPosition, placement: this.placement, open: this.open &&
|
|
282
|
-
this.resultItems != null &&
|
|
283
|
-
this.resultItems.length > 0 &&
|
|
284
|
-
this.cursorPosition != null, items: (_a = this.resultItems) !== null && _a !== void 0 ? _a : [], onPointerDown: this.handleResultPointerDown, onEnterPressed: (event) => this.resultsEnterPressed.emit(event.detail) }, index.h("slot", { name: "results" })), index.h("slot", { name: "replaced" })));
|
|
285
|
-
}
|
|
286
|
-
get hostEl() { return index.getElement(this); }
|
|
287
|
-
};
|
|
288
|
-
SearchBar.style = searchBarCss;
|
|
289
|
-
|
|
290
|
-
exports.SearchBar = SearchBar;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{R as vertex_result_list}from"./p-52739247.js";import"./p-6834631c.js";import"./p-fe062eb0.js";import"./p-1356f525.js";import"./p-59032668.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{T as vertex_textfield}from"./p-bd11e7d1.js";import"./p-6834631c.js";import"./p-fe062eb0.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e,e as t,h as r,H as s,g as i}from"./p-6834631c.js";import{c as a}from"./p-fe062eb0.js";import{g as n}from"./p-1356f525.js";const o=()=>{if("undefined"!=typeof window)return window.getSelection()},l=e=>e instanceof Text,h=e=>"true"===(null==e?void 0:e.getAttribute("data-replaced")),c=e=>new Text(null!=e&&""!==e?e:" "),d=class{constructor(r){e(this,r),this.triggerCharacterPressed=t(this,"triggerCharacterPressed",7),this.valueChanged=t(this,"valueChanged",7),this.inputFocus=t(this,"inputFocus",7),this.inputBlur=t(this,"inputBlur",7),this.resultsEnterPressed=t(this,"resultsEnterPressed",7),this.handleKeyDown=e=>{if(!this.triggerCharacters.includes(e.key)&&this.triggerCharacter!==e.key||null!=this.triggerKey?this.restartTriggerInput():(this.triggerKey=e.key,this.updateCursorPosition(),this.triggerCharacterPressed.emit("")),"Backspace"===e.key){const e=o();e&&(null==e?void 0:e.rangeCount)>0&&e.getRangeAt(0).deleteContents()}this.valueChanged.emit()},this.handleKeyUp=e=>{"Backspace"===e.key&&this.updateTriggerState(this.getSelectionSubstring()),"Enter"===e.key&&this.clearTriggerState(),this.valueChanged.emit()},this.updateTriggerValue=e=>{var t,r,s,i,a;if(null!=this.triggerKey&&null!=this.triggerRange&&this.triggerRange.startContainer===this.triggerRange.endContainer){const n=this.triggerRange.startContainer;if(l(n)){const o=c(null===(t=n.textContent)||void 0===t?void 0:t.slice(0,this.triggerRange.startOffset-1)),l=c(null===(r=n.textContent)||void 0===r?void 0:r.slice(this.triggerRange.endOffset)),h=this.createReplacedElement(e);null===(s=n.parentElement)||void 0===s||s.insertBefore(o,n),null===(i=n.parentElement)||void 0===i||i.insertBefore(l,n.nextSibling),null===(a=n.parentElement)||void 0===a||a.insertBefore(h,l),n.remove(),this.moveCursorToNodeEnd(l,!0)}}},this.triggerText=()=>{var e,t;return null!=this.triggerKey&&null!=this.triggerRange&&this.triggerRange.startContainer===this.triggerRange.endContainer&&null!==(t=null===(e=this.triggerRange.startContainer.textContent)||void 0===e?void 0:e.slice(this.triggerRange.startOffset,this.triggerRange.endOffset))&&void 0!==t?t:""},this.restartTriggerInput=()=>{this.clearTriggerTimeout(),this.triggerTimeout=setTimeout((()=>{null!=this.triggerRange&&null!=this.triggerKey&&this.triggerCharacterPressed.emit(this.triggerText()),this.triggerTimeout=void 0}),this.debounce)},this.clearTriggerTimeout=()=>{null!=this.triggerTimeout&&(clearTimeout(this.triggerTimeout),this.triggerTimeout=void 0)},this.updateCursorPosition=()=>{var e;const t=o();if(null!=t&&t.rangeCount>0){const r=t.getRangeAt(0).getBoundingClientRect(),s=null===(e=this.contentEl)||void 0===e?void 0:e.getBoundingClientRect(),i=r.bottom||(null==s?void 0:s.bottom)||0,a=r.top||(null==s?void 0:s.top)||0;this.cursorPosition={x:r.left||(null==s?void 0:s.left)||0,y:this.placement.includes("top")?a:i}}},this.moveCursorToNodeEnd=(e,t=!1)=>{const r=o();if(null!=r){const s=document.createRange();s.selectNodeContents(e),s.collapse(t),r.removeAllRanges(),r.addRange(s)}},this.updateInputCursorPosition=e=>{if((e=>e instanceof HTMLElement)(e)){const t=h(e.parentElement)?e.parentElement:e;h(t)&&this.insertAdjacentTextNode(t)}},this.createReplacedElement=e=>{const t=this.hostEl.querySelector('template[slot="replaced"]');if(null!=t){const r=n(t);return r.bindings.bind(e),r.element.style.display="inline-block",r.element.contentEditable="false",r.element.setAttribute("data-replaced","true"),r.element}throw new Error("Replaced template not defined.")},this.handleSelectionChange=()=>{this.updateTriggerState(this.getSelectionSubstring())},this.getSelectionSubstring=()=>{var e;const t=o();if(null!=t&&t.rangeCount>0){const r=t.getRangeAt(0);if(this.updateTriggerRange(),null!=r&&r.startOffset===r.endOffset&&l(r.startContainer)&&null!=r.startContainer.textContent&&!h(r.startContainer.parentElement)&&(null===(e=this.contentEl)||void 0===e?void 0:e.contains(r.startContainer)))return r.startContainer.textContent.slice(this.lastIndexOfBreakCharacter(r.startContainer.textContent.slice(0,r.startOffset))+1,r.startOffset)}return""},this.insertAdjacentTextNode=e=>{e.insertAdjacentText("afterend",""),null!=e.nextSibling&&this.moveCursorToNodeEnd(e.nextSibling)},this.updateTriggerState=e=>{const t=(null!=this.triggerCharacter?[...this.triggerCharacters,this.triggerCharacter]:this.triggerCharacters).find((t=>e.includes(t)));null!=t?(this.restartTriggerInput(),this.triggerKey=t,this.updateTriggerRange(),null==this.cursorPosition&&this.updateCursorPosition(),this.open=!0):this.clearTriggerState()},this.updateTriggerRange=()=>{var e;const t=o();if(null!=t&&t.rangeCount>0){const r=t.getRangeAt(0);null!=this.triggerKey&&(this.triggerRange=null!==(e=this.triggerRange)&&void 0!==e?e:r.cloneRange(),this.triggerRange.setEnd(r.endContainer,r.endOffset))}},this.clearTriggerState=()=>{this.triggerKey=void 0,this.triggerRange=void 0,this.cursorPosition=void 0,this.open=!1,this.clearTriggerTimeout()},this.lastIndexOfBreakCharacter=e=>this.breakCharacters.reduce(((t,r)=>{const s=e.replace(String.fromCharCode(160)," ").lastIndexOf(r);return s>t?s:t}),-1),this.handleFocus=e=>{this.inputFocus.emit(e)},this.handleBlur=e=>{this.open=!1,this.inputBlur.emit(e)},this.handleInputPointerEvent=e=>{null!=e.target&&this.updateInputCursorPosition(e.target)},this.handleResultPointerDown=e=>{e.preventDefault()},this.variant="standard",this.resultItems=void 0,this.triggerCharacters=[],this.triggerCharacter=void 0,this.breakCharacters=[" "],this.debounce=100,this.placeholder=void 0,this.placement="bottom-start",this.cursorPosition=void 0,this.open=!1,this.triggerKey=void 0,this.triggerRange=void 0}componentWillLoad(){document.addEventListener("selectionchange",this.handleSelectionChange)}disconnectedCallback(){document.removeEventListener("selectionchange",this.handleSelectionChange)}async replaceTriggeredValue(e){this.updateTriggerValue(e),this.clearTriggerState(),this.valueChanged.emit()}async getEditableContent(){var e;return null===(e=this.contentEl)||void 0===e?void 0:e.childNodes}render(){var e;const t=a("wrapper",{standard:"standard"===this.variant,filled:"filled"===this.variant,underlined:"underlined"===this.variant,blank:"blank"===this.variant});return r(s,null,r("div",{class:t},r("span",{class:"content-input",ref:e=>this.contentEl=e,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})),r("vertex-result-list",{position:this.cursorPosition,placement:this.placement,open:this.open&&null!=this.resultItems&&this.resultItems.length>0&&null!=this.cursorPosition,items:null!==(e=this.resultItems)&&void 0!==e?e:[],onPointerDown:this.handleResultPointerDown,onEnterPressed:e=>this.resultsEnterPressed.emit(e.detail)},r("slot",{name:"results"})),r("slot",{name:"replaced"}))}get hostEl(){return i(this)}};d.style=".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)}";export{d as S}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,e as s,h as i,H as h,g as e}from"./p-6834631c.js";import{c as n}from"./p-fe062eb0.js";import{g as o}from"./p-1356f525.js";class l{constructor(t,s){this.container=t,this.elementFactory=s,this.instanceMap=new Map,this.elements=[]}swapHeadToTail(t){const s=this.elements.splice(0,t);return this.elements.splice(this.elements.length,0,...s),this.elements.concat()}swapTailToHead(t){const s=this.elements.splice(-t,t);return this.elements.splice(0,0,...s),this.elements.concat()}updateElements(t){const s=t-this.elements.length;if(s>0)for(let t=0;t<s;t++)this.createElement();else for(let t=0;t<-s;t++)this.deleteElement();return this.elements.concat()}updateData(t){this.elements.forEach(((s,i)=>{const h=this.instanceMap.get(s),e=t(i);null==h||h.bindings.bind(e)}))}updateElementFactory(t){this.elementFactory=t,this.updateElements(0)}iterateElements(t){this.elements.forEach(((s,i)=>{const h=this.instanceMap.get(s);if(null==h)throw new Error("Binding not found for element.");t(s,h.bindings,i)}))}createElement(){const t=this.elementFactory();return this.elements.push(t.element),this.instanceMap.set(t.element,t),this.container.append(t.element),t}deleteElement(){const t=this.elements.pop();null!=t&&(this.instanceMap.delete(t),t.remove())}}const r=(t,s,i)=>{null==t||t.scrollTo({top:null!=s&&null!=i?s*i:0})},a=class{constructor(i){t(this,i),this.enterPressed=s(this,"enterPressed",7),this.computeResultHeight=()=>{if(null==this.computedResultHeight){const t=this.hostEl.querySelector('*[slot="result"]');null!=t&&(this.resultHeight=t.clientHeight,this.computedResultHeight=t.clientHeight)}},this.ensureTemplateDefined=()=>{const t=this.hostEl.querySelector("template");if(null==t){const t=document.createElement("template");t.innerHTML='\n <div class="result">{{data.value}}</div>\n ',this.hostEl.appendChild(t),this.stateMap.resultTemplate=t}else this.stateMap.resultTemplate=t},this.createResultPool=()=>{this.stateMap.resultPool=new l(this.hostEl,(()=>this.createResultInstance()))},this.createResultInstance=()=>{if(null!=this.stateMap.resultTemplate){const t=o(this.stateMap.resultTemplate);return t.element.slot="result",t}throw new Error("Result template not defined.")},this.layoutResults=()=>{var t,s,i,h;const e=this.viewportEndIndex-this.viewportStartIndex+1,n=this.viewportStartIndex-this.lastStartIndex;this.lastStartIndex=this.viewportStartIndex,null===(t=this.stateMap.resultPool)||void 0===t||t.updateElements(e),n>0?null===(s=this.stateMap.resultPool)||void 0===s||s.swapHeadToTail(n):null===(i=this.stateMap.resultPool)||void 0===i||i.swapTailToHead(-n),null===(h=this.stateMap.resultPool)||void 0===h||h.iterateElements(((t,s,i)=>{const h=this.parsedResults[i+this.viewportStartIndex];null!=h&&(t.style.position="absolute",t.style.boxSizing="border-box",t.style.top=(this.viewportStartIndex+i)*this.resultHeight+"px",t.style.width="100%",t.setAttribute("is-focused",`${this.viewportStartIndex+i===this.lastFocusedIndex}`),s.bind(h))}))},this.handleScroll=t=>{this.scrollTop=t.target.scrollTop},this.handleKeyDown=t=>{this.open&&("ArrowUp"===t.key?(t.preventDefault(),this.lastFocusedIndex=Math.min(0,this.lastFocusedIndex-1),r(this.resultsScrollEl,this.lastFocusedIndex,this.resultHeight)):"ArrowDown"===t.key&&(t.preventDefault(),this.lastFocusedIndex=Math.min(this.lastFocusedIndex+1,this.items.length),r(this.resultsScrollEl,this.lastFocusedIndex,this.resultHeight)),"Enter"===t.key&&null!=this.lastFocusedIndex&&(t.preventDefault(),this.enterPressed.emit(this.items[this.lastFocusedIndex]),this.lastFocusedIndex=0,r(this.resultsScrollEl)))},this.items=[],this.itemsJson=void 0,this.viewportStartIndex=0,this.viewportEndIndex=0,this.resultHeight=32,this.overScanCount=25,this.placement="bottom-start",this.position=void 0,this.open=!1,this.listHeight=void 0,this.parsedResults=[],this.scrollTop=0,this.lastStartIndex=0,this.lastFocusedIndex=0,this.stateMap={}}handleResultsChanged(t){"string"==typeof t?this.parsedResults=JSON.parse(t):null!=t&&(this.parsedResults=t)}handleOpenChanged(){this.open||0===this.scrollTop||r(this.resultsScrollEl)}componentWillLoad(){var t;this.resizeObserver=new ResizeObserver((()=>{this.listHeight=void 0})),window.addEventListener("keydown",this.handleKeyDown),this.ensureTemplateDefined(),this.createResultPool(),this.handleResultsChanged(null!==(t=this.itemsJson)&&void 0!==t?t:this.items)}componentDidLoad(){this.resizeObserver.observe(this.hostEl)}componentWillRender(){this.computeViewportResults()}componentDidRender(){this.layoutResults(),this.computeResultHeight()}disconnectedCallback(){this.resizeObserver.disconnect(),window.removeEventListener("keydown",this.handleKeyDown)}render(){return i(h,null,i("div",{class:n("wrapper",{hidden:!this.open||null==this.computedResultHeight})},i("vertex-popover",{position:this.position,placement:this.placement,open:this.open,backdrop:!1},i("div",{class:"results-scroll",ref:t=>this.resultsScrollEl=t,onScroll:this.handleScroll},i("div",{class:"results",style:{height:this.parsedResults.length*this.resultHeight+"px"}},i("slot",null),i("slot",{name:"result"}))))))}computeViewportResults(){const t=this.getListHeight();if(null!=t&&this.resultHeight>0){const s=Math.ceil(t/this.resultHeight),i=Math.floor(this.scrollTop/this.resultHeight),h=i+s,e=Math.max(0,i-this.overScanCount),n=Math.min(this.parsedResults.length-1,h+this.overScanCount);this.viewportStartIndex=e,this.viewportEndIndex=n}}getListHeight(){return null==this.listHeight&&(this.listHeight=this.hostEl.clientHeight),this.listHeight}get hostEl(){return e(this)}static get watchers(){return{items:["handleResultsChanged"],open:["handleOpenChanged"]}}};a.style=":host{--max-height:300px;--width:500px;--box-shadow:0 2px 5px rgba(0, 0, 0, 0.5)}.hidden{visibility:hidden;position:fixed;pointer-events:none}.results{position:relative;height:100%}.results-scroll{overflow-y:auto;max-height:var(--max-height);width:var(--width);box-shadow:var(--box-shadow);background-color:white}";export{a as R}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{S as vertex_search_bar}from"./p-4224c2ad.js";import"./p-6834631c.js";import"./p-fe062eb0.js";import"./p-1356f525.js";import"./p-59032668.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,e as s,h as i,g as h}from"./p-6834631c.js";import{c as e}from"./p-fe062eb0.js";const l=class{constructor(i){t(this,i),this.inputFocus=s(this,"inputFocus",7),this.inputBlur=s(this,"inputBlur",7),this.inputInput=s(this,"inputInput",7),this.inputChange=s(this,"inputChange",7),this.textFieldKeyDown=s(this,"textFieldKeyDown",7),this.inputAutofill=s(this,"inputAutofill",7),this.handleFocus=t=>{this.inputFocus.emit(t)},this.handleBlur=t=>{this.inputBlur.emit(t)},this.handleKeyDown=t=>{"Enter"===t.key&&null!=this.nearbyForm?this.nearbyForm.dispatchEvent(new CustomEvent("submit",{bubbles:!0,cancelable:!0})):this.textFieldKeyDown.emit(t)},this.handleChanged=()=>{this.inputChange.emit({value:this.nativeInput.value})},this.handleInput=()=>{this.inputInput.emit({value:this.nativeInput.value})},this.type="text",this.name=void 0,this.variant="standard",this.fontSize="standard",this.multiline=!1,this.minRows=1,this.maxRows=void 0,this.placeholder=void 0,this.autoFocus=void 0,this.autoComplete=void 0,this.autoCorrect=void 0,this.value="",this.disabled=void 0,this.hasError=void 0}componentDidLoad(){var t;this.autoFocus&&(null===(t=this.nativeInput)||void 0===t||t.focus())}async updateInput(t){null!=this.nativeInput&&(this.nativeInput.value=t)}async blurInput(){var t;null===(t=this.nativeInput)||void 0===t||t.blur()}async getInputValue(){return this.nativeInput.value}async selectAll(){this.nativeInput.select()}render(){var t;const s=e("txt-wrapper",{"txt-standard":"standard"===this.variant,"txt-filled":"filled"===this.variant,"txt-underlined":"underlined"===this.variant,"txt-blank":"blank"===this.variant,"txt-size-standard":"standard"===this.fontSize,"txt-size-sm":"sm"===this.fontSize,"txt-size-md":"md"===this.fontSize,"txt-size-lg":"lg"===this.fontSize,"txt-size-xl":"xl"===this.fontSize,"txt-size-xxl":"xxl"===this.fontSize,disabled:this.disabled,"has-error":this.hasError}),h={class:"txt","data-testid":"text-field",name:this.name,ref:t=>{null!=t&&(this.nativeInput=t)},autoComplete:this.autoComplete,autoFocus:this.autoFocus,disabled:this.disabled,placeholder:this.placeholder,value:this.value||"",onFocus:this.handleFocus,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown,onInput:this.handleInput,onChange:this.handleChanged,onAnimationStart:t=>{["onAutoFillStart","onAutoFillCancel"].includes(t.animationName)&&this.inputAutofill.emit({value:this.nativeInput.value})}};return i("div",{class:s},i("div",{class:"txt-slot"},i("slot",{name:"left"})),this.multiline?i("vertex-auto-resize-textarea",{maxRows:this.maxRows,minRows:this.minRows,initialValue:(null===(t=this.value)||void 0===t?void 0:t.toString())||""},i("textarea",Object.assign({},h,{class:e(h.class,"txt-textarea",s),rows:this.minRows}))):i("input",Object.assign({},h,{type:this.type})),i("div",{class:"txt-slot"},i("slot",{name:"right"})))}connectedCallback(){null!=this.hostElement&&(this.nearbyForm=this.hostElement.closest("form"))}get hostElement(){return h(this)}};export{l as T}
|
|
@@ -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 };
|