@vertexvis/ui 0.1.0-testing.7 → 0.1.0-testing.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/index.cjs.js +1 -1
- package/dist/cjs/{search-bar-1edc045f.js → search-bar-91cbcd07.js} +47 -27
- package/dist/cjs/vertex-search-bar.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/result-list/result-list.js +6 -3
- package/dist/collection/components/result-list/types.js +1 -0
- package/dist/collection/components/search-bar/dom.js +1 -1
- package/dist/collection/components/search-bar/lib.js +12 -0
- package/dist/collection/components/search-bar/search-bar.css +13 -2
- package/dist/collection/components/search-bar/search-bar.js +36 -28
- package/dist/components/components.esm.js +1 -1
- package/dist/components/index.esm.js +1 -1
- package/dist/components/p-cfe369bf.entry.js +1 -0
- package/dist/components/p-db34f10c.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/{search-bar-cb59da12.js → search-bar-f12a3599.js} +47 -27
- package/dist/esm/vertex-search-bar.entry.js +1 -1
- package/dist/types/components/result-list/result-list.d.ts +1 -4
- package/dist/types/components/result-list/types.d.ts +4 -0
- package/dist/types/components/search-bar/dom.d.ts +1 -1
- package/dist/types/components/search-bar/lib.d.ts +13 -1
- package/dist/types/components/search-bar/search-bar.d.ts +17 -2
- package/dist/types/components.d.ts +6 -7
- package/package.json +2 -2
- package/dist/components/p-759f1655.js +0 -1
- package/dist/components/p-7f42b27b.entry.js +0 -1
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -32,7 +32,7 @@ const radio = require('./radio-bff991d2.js');
|
|
|
32
32
|
const radioGroup = require('./radio-group-d628f631.js');
|
|
33
33
|
const resizable = require('./resizable-e4248256.js');
|
|
34
34
|
const resultList = require('./result-list-241ffe8d.js');
|
|
35
|
-
const searchBar = require('./search-bar-
|
|
35
|
+
const searchBar = require('./search-bar-91cbcd07.js');
|
|
36
36
|
const select = require('./select-5f8aecfe.js');
|
|
37
37
|
const slider = require('./slider-13594e49.js');
|
|
38
38
|
const spinner = require('./spinner-bb990a42.js');
|
|
@@ -59,7 +59,7 @@ const createDocumentRange = () => {
|
|
|
59
59
|
return document.createRange();
|
|
60
60
|
};
|
|
61
61
|
const createTextNode = (text) => {
|
|
62
|
-
return new Text(text
|
|
62
|
+
return new Text(text);
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
const createResultUri = (result) => {
|
|
@@ -81,6 +81,18 @@ const getNodesForSearchResultReplacement = (replacement) => {
|
|
|
81
81
|
.map((key) => replacement[key])
|
|
82
82
|
.filter((node) => node != null);
|
|
83
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* We leverage a couple unique spaces to represent mentions, allowing for
|
|
86
|
+
* correct cursor movement when using arrow keys. As these characters are
|
|
87
|
+
* purely for functional behavior of the input, `trimNonstandardSpaces`
|
|
88
|
+
* will remove them so the input is suitable for emitting.
|
|
89
|
+
*
|
|
90
|
+
* U+200A is a "Hair Space" which acts as a space, but is not visually
|
|
91
|
+
* represented as one.
|
|
92
|
+
*
|
|
93
|
+
* U+00A0 is a "No-Break Space" which is commonly added by browsers
|
|
94
|
+
* when interacting with a contenteditable element.
|
|
95
|
+
*/
|
|
84
96
|
const trimNonstandardSpaces = (text) => {
|
|
85
97
|
return text.replace(/[\u200A]/g, '').replace(/[\u00A0]/g, ' ');
|
|
86
98
|
};
|
|
@@ -91,7 +103,7 @@ const createNoBreakSpace = () => {
|
|
|
91
103
|
return String.fromCharCode(160);
|
|
92
104
|
};
|
|
93
105
|
|
|
94
|
-
const searchBarCss = ".wrapper.sc-vertex-search-bar{display:flex;border:1px solid var(--vertex-ui-
|
|
106
|
+
const searchBarCss = ".wrapper.sc-vertex-search-bar{display:flex;align-items:center;width:100%;box-sizing:border-box;background:none;border:1px solid transparent;border-radius:4px;font-family:var(--vertex-ui-font-family);font-size:0.875rem;line-height:1.4}.content-input.sc-vertex-search-bar{width:100%;box-sizing:border-box;padding:6px 0.5em 7px;border:1px solid transparent;background:none;font-family:var(--vertex-ui-font-family);font-weight:var(--vertex-ui-font-weight-base);font-size:0.875rem;line-height:1.4;white-space:pre-line}.content-input.sc-vertex-search-bar:focus{outline:none}.standard.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-400);color:var(--vertex-ui-neutral-800)}.standard.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-500)}.standard.sc-vertex-search-bar:hover:not(.disabled),.standard.sc-vertex-search-bar:focus{border-color:var(--vertex-ui-neutral-500)}.standard.disabled.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-200)}.standard.disabled.sc-vertex-search-bar,.standard.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.blank.sc-vertex-search-bar{color:var(--vertex-ui-neutral-800)}.blank.sc-vertex-search-bar:not(:hover) .content-input.sc-vertex-search-bar:focus{border-color:var(--vertex-ui-neutral-400);border-radius:4px}.blank.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-500)}.blank.sc-vertex-search-bar:hover:not(.disabled) .content-input.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-400);border-radius:4px}.blank.disabled.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-200)}.blank.disabled.sc-vertex-search-bar,.blank.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.filled.sc-vertex-search-bar{background-color:var(--vertex-ui-neutral-200);border-color:var(--vertex-ui-neutral-200);color:var(--vertex-ui-neutral-800)}.filled.disabled.sc-vertex-search-bar,.filled.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.filled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-700)}.filled.sc-vertex-search-bar:hover:not(.disabled),.filled.sc-vertex-search-bar:focus{border-bottom-color:var(--vertex-ui-blue-600)}.filled.disabled.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-100)}.filled.disabled.sc-vertex-search-bar,.filled.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.underlined.sc-vertex-search-bar{background-color:var(--vertex-ui-white);border-color:var(--vertex-ui-white) var(--vertex-ui-white) var(--vertex-ui-neutral-400) var(--vertex-ui-white);color:var(--vertex-ui-neutral-800)}.underlined.disabled.sc-vertex-search-bar,.underlined.disabled.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.underlined.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-700)}.underlined.sc-vertex-search-bar:hover:not(.disabled),.underlined.sc-vertex-search-bar:focus{background-color:var(--vertex-ui-neutral-200);border-color:var(--vertex-ui-neutral-200);border-bottom-color:var(--vertex-ui-blue-600)}.underlined.disabled.sc-vertex-search-bar{border-bottom-color:var(--vertex-ui-neutral-200)}.underlined.disabled.sc-vertex-search-bar,.underlined.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.underlined.has-error.sc-vertex-search-bar{border-bottom-color:var(--vertex-ui-red-600)}";
|
|
95
107
|
|
|
96
108
|
const SearchBar = class {
|
|
97
109
|
constructor(hostRef) {
|
|
@@ -113,31 +125,41 @@ const SearchBar = class {
|
|
|
113
125
|
}
|
|
114
126
|
return (_a = node.textContent) !== null && _a !== void 0 ? _a : '';
|
|
115
127
|
};
|
|
128
|
+
/**
|
|
129
|
+
* Inspects the cursor position for the following conditions:
|
|
130
|
+
*
|
|
131
|
+
* 1. The cursor has moved to text that contains a valid string
|
|
132
|
+
* and trigger character, indicating we need to dispatch a
|
|
133
|
+
* `searchChanged` event and display the results.
|
|
134
|
+
*
|
|
135
|
+
* 2. The cursor has moved within text that contains a valid string
|
|
136
|
+
* and trigger character, indicating we need to dispatch a
|
|
137
|
+
* `searchChanged` event to update the currently displayed results.
|
|
138
|
+
*
|
|
139
|
+
* 3. The cursor has moved to text that does not contain a valid
|
|
140
|
+
* string and trigger character, indicating we need to hide any
|
|
141
|
+
* displayed search results.
|
|
142
|
+
*/
|
|
116
143
|
this.handleCursorPositionUpdate = () => {
|
|
117
|
-
var _a, _b
|
|
144
|
+
var _a, _b;
|
|
118
145
|
const windowRange = (_a = getWindowSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0);
|
|
119
146
|
if (windowRange != null) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
127
|
-
}
|
|
147
|
+
const triggerText = this.readTriggerValue((_b = windowRange.commonAncestorContainer.textContent) !== null && _b !== void 0 ? _b : '', windowRange.startOffset);
|
|
148
|
+
if (!this.hasTriggered && triggerText != null) {
|
|
149
|
+
this.hasTriggered = true;
|
|
150
|
+
this.triggeredRange = windowRange;
|
|
151
|
+
this.triggeredElement = windowRange.commonAncestorContainer;
|
|
152
|
+
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
128
153
|
}
|
|
129
|
-
else if (this.hasTriggered) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
this.triggeredRange = undefined;
|
|
139
|
-
this.triggeredElement = undefined;
|
|
140
|
-
}
|
|
154
|
+
else if (this.hasTriggered && triggerText != null) {
|
|
155
|
+
this.triggeredRange = windowRange;
|
|
156
|
+
this.triggeredElement = windowRange.commonAncestorContainer;
|
|
157
|
+
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
this.hasTriggered = false;
|
|
161
|
+
this.triggeredRange = undefined;
|
|
162
|
+
this.triggeredElement = undefined;
|
|
141
163
|
}
|
|
142
164
|
}
|
|
143
165
|
this.cursorPosition = this.getCursorPosition();
|
|
@@ -220,7 +242,7 @@ const SearchBar = class {
|
|
|
220
242
|
this.placeholder = undefined;
|
|
221
243
|
this.replacements = [];
|
|
222
244
|
this.replacementUriType = 'user';
|
|
223
|
-
this.cursorPosition =
|
|
245
|
+
this.cursorPosition = undefined;
|
|
224
246
|
this.displayedElements = [];
|
|
225
247
|
this.hasTriggered = false;
|
|
226
248
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
@@ -280,7 +302,6 @@ const SearchBar = class {
|
|
|
280
302
|
this.displayedElements = this.rawElements.map((el) => {
|
|
281
303
|
const raw = el instanceof HTMLElement ? el.innerText : el.textContent;
|
|
282
304
|
const replacement = this.replacements.find((r) => raw === null || raw === void 0 ? void 0 : raw.includes(createResultUri(r)));
|
|
283
|
-
console.log(raw);
|
|
284
305
|
if (raw != null && replacement != null) {
|
|
285
306
|
const replacementElement = this.createReplacedElement(raw, replacement);
|
|
286
307
|
return replacementElement;
|
|
@@ -359,7 +380,6 @@ const SearchBar = class {
|
|
|
359
380
|
const replacement = createSearchResultReplacement(event.detail, before, after);
|
|
360
381
|
this.lastReplacedSpace = replacement.afterSpace;
|
|
361
382
|
this.rawElements = Array.from(this.contentEl.childNodes).reduce((re, e) => {
|
|
362
|
-
// TODO: see if we can do anything about the collapse to single line in safari
|
|
363
383
|
if (this.isIdenticalElement(e, triggeredElement)) {
|
|
364
384
|
return [...re, ...getNodesForSearchResultReplacement(replacement)];
|
|
365
385
|
}
|
|
@@ -368,11 +388,11 @@ const SearchBar = class {
|
|
|
368
388
|
}
|
|
369
389
|
}, []);
|
|
370
390
|
this.hasTriggered = false;
|
|
391
|
+
this.resultReplaced.emit(event.detail);
|
|
371
392
|
this.replacements = [
|
|
372
393
|
...this.replacements.filter((r) => r.id !== event.detail.id),
|
|
373
394
|
event.detail,
|
|
374
395
|
];
|
|
375
|
-
this.resultReplaced.emit(event.detail);
|
|
376
396
|
}
|
|
377
397
|
}
|
|
378
398
|
getCursorPosition() {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const searchBar = require('./search-bar-
|
|
5
|
+
const searchBar = require('./search-bar-91cbcd07.js');
|
|
6
6
|
require('./index-6a92256c.js');
|
|
7
7
|
require('./index-e1b40fa6.js');
|
|
8
8
|
require('./templates-e7b3ffbb.js');
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"./components/icon-button/icon-button.js",
|
|
13
13
|
"./components/radio/radio.js",
|
|
14
14
|
"./components/resizable/resizable.js",
|
|
15
|
-
"./components/result-list/result-list.js",
|
|
16
15
|
"./components/search-bar/search-bar.js",
|
|
17
16
|
"./components/slider/slider.js",
|
|
18
17
|
"./components/spinner/spinner.js",
|
|
@@ -36,6 +35,7 @@
|
|
|
36
35
|
"./components/menu-divider/menu-divider.js",
|
|
37
36
|
"./components/menu-item/menu-item.js",
|
|
38
37
|
"./components/radio-group/radio-group.js",
|
|
38
|
+
"./components/result-list/result-list.js",
|
|
39
39
|
"./components/select/select.js",
|
|
40
40
|
"./components/tooltip/tooltip.js"
|
|
41
41
|
],
|
|
@@ -213,7 +213,8 @@ export class ResultList {
|
|
|
213
213
|
"resolved": "Result[]",
|
|
214
214
|
"references": {
|
|
215
215
|
"Result": {
|
|
216
|
-
"location": "
|
|
216
|
+
"location": "import",
|
|
217
|
+
"path": "./types"
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
220
|
},
|
|
@@ -405,7 +406,8 @@ export class ResultList {
|
|
|
405
406
|
"resolved": "{ id: string; type: string; } & Record<string, unknown>",
|
|
406
407
|
"references": {
|
|
407
408
|
"Result": {
|
|
408
|
-
"location": "
|
|
409
|
+
"location": "import",
|
|
410
|
+
"path": "./types"
|
|
409
411
|
}
|
|
410
412
|
}
|
|
411
413
|
}
|
|
@@ -424,7 +426,8 @@ export class ResultList {
|
|
|
424
426
|
"resolved": "{ id: string; type: string; } & Record<string, unknown>",
|
|
425
427
|
"references": {
|
|
426
428
|
"Result": {
|
|
427
|
-
"location": "
|
|
429
|
+
"location": "import",
|
|
430
|
+
"path": "./types"
|
|
428
431
|
}
|
|
429
432
|
}
|
|
430
433
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -18,6 +18,18 @@ export const getNodesForSearchResultReplacement = (replacement) => {
|
|
|
18
18
|
.map((key) => replacement[key])
|
|
19
19
|
.filter((node) => node != null);
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* We leverage a couple unique spaces to represent mentions, allowing for
|
|
23
|
+
* correct cursor movement when using arrow keys. As these characters are
|
|
24
|
+
* purely for functional behavior of the input, `trimNonstandardSpaces`
|
|
25
|
+
* will remove them so the input is suitable for emitting.
|
|
26
|
+
*
|
|
27
|
+
* U+200A is a "Hair Space" which acts as a space, but is not visually
|
|
28
|
+
* represented as one.
|
|
29
|
+
*
|
|
30
|
+
* U+00A0 is a "No-Break Space" which is commonly added by browsers
|
|
31
|
+
* when interacting with a contenteditable element.
|
|
32
|
+
*/
|
|
21
33
|
export const trimNonstandardSpaces = (text) => {
|
|
22
34
|
return text.replace(/[\u200A]/g, '').replace(/[\u00A0]/g, ' ');
|
|
23
35
|
};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
.wrapper {
|
|
2
2
|
display: flex;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
align-items: center;
|
|
4
|
+
width: 100%;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
background: none;
|
|
7
|
+
border: 1px solid transparent;
|
|
8
|
+
border-radius: 4px;
|
|
9
|
+
font-family: var(--vertex-ui-font-family);
|
|
10
|
+
font-size: 0.875rem;
|
|
11
|
+
line-height: 1.4;
|
|
5
12
|
}
|
|
6
13
|
|
|
7
14
|
.content-input {
|
|
@@ -17,6 +24,10 @@
|
|
|
17
24
|
white-space: pre-line;
|
|
18
25
|
}
|
|
19
26
|
|
|
27
|
+
.content-input:focus {
|
|
28
|
+
outline: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
20
31
|
/* standard */
|
|
21
32
|
.standard {
|
|
22
33
|
border-color: var(--vertex-ui-neutral-400);
|
|
@@ -18,31 +18,41 @@ export class SearchBar {
|
|
|
18
18
|
}
|
|
19
19
|
return (_a = node.textContent) !== null && _a !== void 0 ? _a : '';
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Inspects the cursor position for the following conditions:
|
|
23
|
+
*
|
|
24
|
+
* 1. The cursor has moved to text that contains a valid string
|
|
25
|
+
* and trigger character, indicating we need to dispatch a
|
|
26
|
+
* `searchChanged` event and display the results.
|
|
27
|
+
*
|
|
28
|
+
* 2. The cursor has moved within text that contains a valid string
|
|
29
|
+
* and trigger character, indicating we need to dispatch a
|
|
30
|
+
* `searchChanged` event to update the currently displayed results.
|
|
31
|
+
*
|
|
32
|
+
* 3. The cursor has moved to text that does not contain a valid
|
|
33
|
+
* string and trigger character, indicating we need to hide any
|
|
34
|
+
* displayed search results.
|
|
35
|
+
*/
|
|
21
36
|
this.handleCursorPositionUpdate = () => {
|
|
22
|
-
var _a, _b
|
|
37
|
+
var _a, _b;
|
|
23
38
|
const windowRange = (_a = getWindowSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0);
|
|
24
39
|
if (windowRange != null) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
32
|
-
}
|
|
40
|
+
const triggerText = this.readTriggerValue((_b = windowRange.commonAncestorContainer.textContent) !== null && _b !== void 0 ? _b : '', windowRange.startOffset);
|
|
41
|
+
if (!this.hasTriggered && triggerText != null) {
|
|
42
|
+
this.hasTriggered = true;
|
|
43
|
+
this.triggeredRange = windowRange;
|
|
44
|
+
this.triggeredElement = windowRange.commonAncestorContainer;
|
|
45
|
+
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
33
46
|
}
|
|
34
|
-
else if (this.hasTriggered) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.triggeredRange = undefined;
|
|
44
|
-
this.triggeredElement = undefined;
|
|
45
|
-
}
|
|
47
|
+
else if (this.hasTriggered && triggerText != null) {
|
|
48
|
+
this.triggeredRange = windowRange;
|
|
49
|
+
this.triggeredElement = windowRange.commonAncestorContainer;
|
|
50
|
+
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.hasTriggered = false;
|
|
54
|
+
this.triggeredRange = undefined;
|
|
55
|
+
this.triggeredElement = undefined;
|
|
46
56
|
}
|
|
47
57
|
}
|
|
48
58
|
this.cursorPosition = this.getCursorPosition();
|
|
@@ -125,7 +135,7 @@ export class SearchBar {
|
|
|
125
135
|
this.placeholder = undefined;
|
|
126
136
|
this.replacements = [];
|
|
127
137
|
this.replacementUriType = 'user';
|
|
128
|
-
this.cursorPosition =
|
|
138
|
+
this.cursorPosition = undefined;
|
|
129
139
|
this.displayedElements = [];
|
|
130
140
|
this.hasTriggered = false;
|
|
131
141
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
@@ -185,7 +195,6 @@ export class SearchBar {
|
|
|
185
195
|
this.displayedElements = this.rawElements.map((el) => {
|
|
186
196
|
const raw = el instanceof HTMLElement ? el.innerText : el.textContent;
|
|
187
197
|
const replacement = this.replacements.find((r) => raw === null || raw === void 0 ? void 0 : raw.includes(createResultUri(r)));
|
|
188
|
-
console.log(raw);
|
|
189
198
|
if (raw != null && replacement != null) {
|
|
190
199
|
const replacementElement = this.createReplacedElement(raw, replacement);
|
|
191
200
|
return replacementElement;
|
|
@@ -264,7 +273,6 @@ export class SearchBar {
|
|
|
264
273
|
const replacement = createSearchResultReplacement(event.detail, before, after);
|
|
265
274
|
this.lastReplacedSpace = replacement.afterSpace;
|
|
266
275
|
this.rawElements = Array.from(this.contentEl.childNodes).reduce((re, e) => {
|
|
267
|
-
// TODO: see if we can do anything about the collapse to single line in safari
|
|
268
276
|
if (this.isIdenticalElement(e, triggeredElement)) {
|
|
269
277
|
return [...re, ...getNodesForSearchResultReplacement(replacement)];
|
|
270
278
|
}
|
|
@@ -273,11 +281,11 @@ export class SearchBar {
|
|
|
273
281
|
}
|
|
274
282
|
}, []);
|
|
275
283
|
this.hasTriggered = false;
|
|
284
|
+
this.resultReplaced.emit(event.detail);
|
|
276
285
|
this.replacements = [
|
|
277
286
|
...this.replacements.filter((r) => r.id !== event.detail.id),
|
|
278
287
|
event.detail,
|
|
279
288
|
];
|
|
280
|
-
this.resultReplaced.emit(event.detail);
|
|
281
289
|
}
|
|
282
290
|
}
|
|
283
291
|
getCursorPosition() {
|
|
@@ -392,7 +400,7 @@ export class SearchBar {
|
|
|
392
400
|
"references": {
|
|
393
401
|
"Result": {
|
|
394
402
|
"location": "import",
|
|
395
|
-
"path": "../result-list/
|
|
403
|
+
"path": "../result-list/types"
|
|
396
404
|
}
|
|
397
405
|
}
|
|
398
406
|
},
|
|
@@ -472,7 +480,7 @@ export class SearchBar {
|
|
|
472
480
|
"references": {
|
|
473
481
|
"Result": {
|
|
474
482
|
"location": "import",
|
|
475
|
-
"path": "../result-list/
|
|
483
|
+
"path": "../result-list/types"
|
|
476
484
|
}
|
|
477
485
|
}
|
|
478
486
|
},
|
|
@@ -558,7 +566,7 @@ export class SearchBar {
|
|
|
558
566
|
"references": {
|
|
559
567
|
"Result": {
|
|
560
568
|
"location": "import",
|
|
561
|
-
"path": "../result-list/
|
|
569
|
+
"path": "../result-list/types"
|
|
562
570
|
}
|
|
563
571
|
}
|
|
564
572
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,N as t,w as a,p as o,a as r,b as i}from"./p-6834631c.js";export{s as setNonce}from"./p-6834631c.js";(()=>{const i=Array.from(e.querySelectorAll("script")).find((e=>new RegExp(`/${t}(\\.esm)?\\.js($|\\?|#)`).test(e.src)||e.getAttribute("data-stencil-namespace")===t)),n={};return n.resourcesUrl=new URL(".",new URL(i.getAttribute("data-resources-url")||i.src,a.location.href)).href,((o,i)=>{const n=`__sc_import_${t.replace(/\s|-/g,"_")}`;try{a[n]=new Function("w",`return import(w);//${Math.random()}`)}catch(t){const l=new Map;a[n]=t=>{var c;const s=new URL(t,o).href;let p=l.get(s);if(!p){const t=e.createElement("script");t.type="module",t.crossOrigin=i.crossOrigin,t.src=URL.createObjectURL(new Blob([`import * as m from '${s}'; window.${n}.m = m;`],{type:"application/javascript"}));const o=null!==(c=r.t)&&void 0!==c?c:function(e){var t,a,o;return null!==(o=null===(a=null===(t=e.head)||void 0===t?void 0:t.querySelector('meta[name="csp-nonce"]'))||void 0===a?void 0:a.getAttribute("content"))&&void 0!==o?o:void 0}(e);null!=o&&t.setAttribute("nonce",o),p=new Promise((e=>{t.onload=()=>{e(a[n].m),t.remove()}})),l.set(s,p),e.head.appendChild(t)}return p}}})(n.resourcesUrl,i),a.customElements?o(n):__sc_import_components("./p-c3ec6642.js").then((()=>n))})().then((e=>i([["p-24c72960",[[6,"vertex-click-to-edit-textfield",{placeholder:[1],fontSize:[1,"font-size"],disabled:[516],multiline:[4],minRows:[2,"min-rows"],maxRows:[2,"max-rows"],value:[1032],autoFocus:[4,"auto-focus"],editing:[1540],hasError:[4,"has-error"]}]]],["p-226e83a6",[[1,"vertex-collapsible",{label:[1],open:[1540]}]]],["p-41ced35c",[[1,"vertex-context-menu",{targetSelector:[1,"target-selector"],animated:[4],position:[32],open:[32]}]]],["p-0f8b9ede",[[1,"vertex-dialog",{open:[1540],fullscreen:[4],resizable:[4],width:[32],height:[32],minWidth:[32],minHeight:[32],maxWidth:[32],maxHeight:[32],isResizing:[32]},[[4,"keydown","keyDownListener"]]]]],["p-e7336466",[[1,"vertex-draggable-popover",{position:[1],boundarySelector:[1,"boundary-selector"],boundaryPadding:[2,"boundary-padding"],anchorPosition:[32],lastPosition:[32],dragging:[32]}]]],["p-e3d0c2d1",[[1,"vertex-dropdown-menu",{animated:[4],placement:[1],open:[32]}]]],["p-fe7e7a74",[[1,"vertex-help-tooltip",{animated:[4],placement:[1],open:[32]}]]],["p-
|
|
1
|
+
import{d as e,N as t,w as a,p as o,a as r,b as i}from"./p-6834631c.js";export{s as setNonce}from"./p-6834631c.js";(()=>{const i=Array.from(e.querySelectorAll("script")).find((e=>new RegExp(`/${t}(\\.esm)?\\.js($|\\?|#)`).test(e.src)||e.getAttribute("data-stencil-namespace")===t)),n={};return n.resourcesUrl=new URL(".",new URL(i.getAttribute("data-resources-url")||i.src,a.location.href)).href,((o,i)=>{const n=`__sc_import_${t.replace(/\s|-/g,"_")}`;try{a[n]=new Function("w",`return import(w);//${Math.random()}`)}catch(t){const l=new Map;a[n]=t=>{var c;const s=new URL(t,o).href;let p=l.get(s);if(!p){const t=e.createElement("script");t.type="module",t.crossOrigin=i.crossOrigin,t.src=URL.createObjectURL(new Blob([`import * as m from '${s}'; window.${n}.m = m;`],{type:"application/javascript"}));const o=null!==(c=r.t)&&void 0!==c?c:function(e){var t,a,o;return null!==(o=null===(a=null===(t=e.head)||void 0===t?void 0:t.querySelector('meta[name="csp-nonce"]'))||void 0===a?void 0:a.getAttribute("content"))&&void 0!==o?o:void 0}(e);null!=o&&t.setAttribute("nonce",o),p=new Promise((e=>{t.onload=()=>{e(a[n].m),t.remove()}})),l.set(s,p),e.head.appendChild(t)}return p}}})(n.resourcesUrl,i),a.customElements?o(n):__sc_import_components("./p-c3ec6642.js").then((()=>n))})().then((e=>i([["p-24c72960",[[6,"vertex-click-to-edit-textfield",{placeholder:[1],fontSize:[1,"font-size"],disabled:[516],multiline:[4],minRows:[2,"min-rows"],maxRows:[2,"max-rows"],value:[1032],autoFocus:[4,"auto-focus"],editing:[1540],hasError:[4,"has-error"]}]]],["p-226e83a6",[[1,"vertex-collapsible",{label:[1],open:[1540]}]]],["p-41ced35c",[[1,"vertex-context-menu",{targetSelector:[1,"target-selector"],animated:[4],position:[32],open:[32]}]]],["p-0f8b9ede",[[1,"vertex-dialog",{open:[1540],fullscreen:[4],resizable:[4],width:[32],height:[32],minWidth:[32],minHeight:[32],maxWidth:[32],maxHeight:[32],isResizing:[32]},[[4,"keydown","keyDownListener"]]]]],["p-e7336466",[[1,"vertex-draggable-popover",{position:[1],boundarySelector:[1,"boundary-selector"],boundaryPadding:[2,"boundary-padding"],anchorPosition:[32],lastPosition:[32],dragging:[32]}]]],["p-e3d0c2d1",[[1,"vertex-dropdown-menu",{animated:[4],placement:[1],open:[32]}]]],["p-fe7e7a74",[[1,"vertex-help-tooltip",{animated:[4],placement:[1],open:[32]}]]],["p-cfe369bf",[[6,"vertex-search-bar",{variant:[1],disabled:[4],triggerCharacter:[1,"trigger-character"],breakCharacters:[16],resultItems:[16],placement:[1],value:[1],placeholder:[1],replacements:[1040],replacementUriType:[1,"replacement-uri-type"],cursorPosition:[32],displayedElements:[32],hasTriggered:[32]}]]],["p-7cfb3736",[[1,"vertex-select",{value:[513],placeholder:[513],disabled:[516],animated:[4],hideSelected:[4,"hide-selected"],resizeObserverFactory:[16],open:[32],position:[32],displayValue:[32]}]]],["p-16719272",[[1,"vertex-slider",{min:[2],max:[2],valueLabelDisplay:[1,"value-label-display"],step:[8],size:[1],value:[1026],disabled:[4]}]]],["p-756c9977",[[1,"vertex-toast",{content:[1],placement:[1],duration:[2],animated:[4],open:[4],type:[1],isOpen:[32]}]]],["p-7f64b251",[[1,"vertex-color-circle-picker",{colors:[1],supplementalColors:[1,"supplemental-colors"],theme:[513],lightenPercentage:[2,"lighten-percentage"],darkenPercentage:[2,"darken-percentage"],selected:[1537],direction:[1]}]]],["p-35e7ab78",[[1,"vertex-color-picker",{value:[1537],disabled:[4]}]]],["p-53515813",[[1,"vertex-toggle",{variant:[1],disabled:[4],checked:[1540]}]]],["p-bca6275a",[[1,"vertex-avatar",{firstName:[1,"first-name"],lastName:[1,"last-name"],value:[1],active:[4],variant:[1]}]]],["p-91123ff6",[[1,"vertex-avatar-group"]]],["p-0b4406fa",[[1,"vertex-badge",{badgeText:[1,"badge-text"],badgeColor:[1,"badge-color"]}]]],["p-fca52578",[[1,"vertex-button",{type:[1],color:[1],variant:[1],size:[1],expand:[1],href:[1],target:[1],disabled:[516]}]]],["p-6d4f055b",[[1,"vertex-card",{mode:[1]}]]],["p-211c1186",[[1,"vertex-card-group",{selected:[516],hovered:[516],expanded:[516]}]]],["p-d7c0c287",[[1,"vertex-chip",{variant:[1],color:[1]}]]],["p-a2018217",[[1,"vertex-logo-loading"]]],["p-cc2e3192",[[1,"vertex-menu-divider"]]],["p-573b8ec6",[[1,"vertex-menu-item",{disabled:[516]}]]],["p-33400eed",[[2,"vertex-radio",{disabled:[516],value:[513],label:[513],name:[513],checked:[516]}]]],["p-8b85ea4a",[[1,"vertex-radio-group",{name:[513],value:[1537]}]]],["p-ea4a2f74",[[1,"vertex-resizable",{horizontalDirection:[1,"horizontal-direction"],verticalDirection:[1,"vertical-direction"],initialHorizontalScale:[2,"initial-horizontal-scale"],initialVerticalScale:[2,"initial-vertical-scale"],initializeWithOffset:[4,"initialize-with-offset"],parentSelector:[1,"parent-selector"],verticalSiblingSelector:[1,"vertical-sibling-selector"],horizontalSiblingSelector:[1,"horizontal-sibling-selector"],contentSelector:[1,"content-selector"],position:[1],dimensionsComputed:[1540,"dimensions-computed"],width:[32],minWidth:[32],maxWidth:[32],height:[32],minHeight:[32],maxHeight:[32],left:[32],top:[32],hoveredLocation:[32],dragStartLocation:[32],updateDimensions:[64]}]]],["p-69375605",[[1,"vertex-spinner",{color:[1],size:[1]}]]],["p-80c989fa",[[1,"vertex-expandable",{expanded:[1540],expanding:[1540],collapsing:[1540],controlled:[516],expandType:[513,"expand-type"],animated:[4],contentScrollHeight:[32]}]]],["p-ee496965",[[1,"vertex-result-list",{items:[16],itemsJson:[1,"items"],viewportStartIndex:[1026,"viewport-start-index"],viewportEndIndex:[1026,"viewport-end-index"],resultHeight:[1026,"result-height"],overScanCount:[2,"over-scan-count"],placement:[1],position:[1],open:[4],listHeight:[32],parsedResults:[32],scrollTop:[32],lastStartIndex:[32],lastFocusedIndex:[32],stateMap:[32]}]]],["p-406e73da",[[6,"vertex-textfield",{type:[1],name:[1],variant:[1],fontSize:[1,"font-size"],multiline:[4],minRows:[2,"min-rows"],maxRows:[2,"max-rows"],placeholder:[1],autoFocus:[4,"auto-focus"],autoComplete:[1,"auto-complete"],autoCorrect:[1,"auto-correct"],value:[1032],disabled:[516],hasError:[4,"has-error"],updateInput:[64],blurInput:[64],getInputValue:[64],selectAll:[64]}]]],["p-0b1cdc8a",[[1,"vertex-tooltip",{content:[1],disabled:[4],placement:[1],delay:[2],animated:[4],open:[32]}]]],["p-20a74d5d",[[1,"vertex-color-circle",{color:[513],supplementalColor:[513,"supplemental-color"],theme:[513],lightenPercentage:[2,"lighten-percentage"],darkenPercentage:[2,"darken-percentage"],lightened:[1537],darkened:[1537]}]]],["p-9c384f6c",[[1,"vertex-auto-resize-textarea",{textareaSelector:[1,"textarea-selector"],initialValue:[1,"initial-value"],minRows:[514,"min-rows"],maxRows:[514,"max-rows"],textValue:[32]}]]],["p-0517ca62",[[1,"vertex-menu",{animated:[4],open:[1540],placement:[1],fallbackPlacements:[16],backdrop:[4],position:[1040],popoverProps:[16]}]]],["p-f71fc166",[[1,"vertex-icon-button",{iconName:[1,"icon-name"],disabled:[516],variant:[1],iconColor:[1,"icon-color"],iconSize:[1,"icon-size"]}]]],["p-7dba2574",[[1,"vertex-icon",{name:[1],size:[1]}]]],["p-606596de",[[1,"vertex-popover",{open:[1540],placement:[1],position:[1025],anchorBounds:[16],backdrop:[4],animated:[4],anchorSelector:[1,"anchor-selector"],boundarySelector:[1,"boundary-selector"],resizeBehavior:[1,"resize-behavior"],overflowBehavior:[16],flipBehavior:[16],offsetBehavior:[2,"offset-behavior"],updateOnResize:[4,"update-on-resize"],resizeObserverFactory:[16],opened:[32],computedPlacement:[32]}]]]],e)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{A as AutoResizeTextArea}from"./p-bec53c3a.js";export{A as Avatar}from"./p-c2c076f1.js";export{A as AvatarGroup}from"./p-81cb4da4.js";export{B as Badge}from"./p-29d7697f.js";export{B as Button}from"./p-64e8b92c.js";export{C as Card}from"./p-a3c04bbd.js";export{C as CardGroup}from"./p-ff4a1c3a.js";export{C as Chip}from"./p-a6614625.js";export{C as ClickToEditTextField}from"./p-0e628c05.js";export{C as Collapsible}from"./p-8fe0084d.js";export{C as ColorCircle}from"./p-d9b9aebe.js";export{C as ColorCirclePicker}from"./p-9374ef6c.js";export{C as ColorPicker}from"./p-8434602f.js";export{C as ContextMenu}from"./p-f2bc7ec5.js";export{D as Dialog}from"./p-165aed7d.js";export{D as DraggablePopover}from"./p-41a7564c.js";export{D as DropdownMenu}from"./p-39133bc7.js";export{E as Expandable}from"./p-6a640a2c.js";export{H as HelpTooltip}from"./p-2cff3285.js";export{I as Icon}from"./p-ca52a423.js";export{I as IconButton}from"./p-103249b4.js";export{L as LogoLoading}from"./p-817bf6ff.js";export{M as Menu}from"./p-7b75e004.js";export{M as MenuDivider}from"./p-c939fa4e.js";export{M as MenuItem}from"./p-988058f9.js";export{P as Popover}from"./p-c2706288.js";export{R as Radio}from"./p-36c853c4.js";export{R as RadioGroup}from"./p-f693e6f8.js";export{R as Resizable}from"./p-6ec189d2.js";export{R as ResultList}from"./p-6b862967.js";export{S as SearchBar}from"./p-
|
|
1
|
+
export{A as AutoResizeTextArea}from"./p-bec53c3a.js";export{A as Avatar}from"./p-c2c076f1.js";export{A as AvatarGroup}from"./p-81cb4da4.js";export{B as Badge}from"./p-29d7697f.js";export{B as Button}from"./p-64e8b92c.js";export{C as Card}from"./p-a3c04bbd.js";export{C as CardGroup}from"./p-ff4a1c3a.js";export{C as Chip}from"./p-a6614625.js";export{C as ClickToEditTextField}from"./p-0e628c05.js";export{C as Collapsible}from"./p-8fe0084d.js";export{C as ColorCircle}from"./p-d9b9aebe.js";export{C as ColorCirclePicker}from"./p-9374ef6c.js";export{C as ColorPicker}from"./p-8434602f.js";export{C as ContextMenu}from"./p-f2bc7ec5.js";export{D as Dialog}from"./p-165aed7d.js";export{D as DraggablePopover}from"./p-41a7564c.js";export{D as DropdownMenu}from"./p-39133bc7.js";export{E as Expandable}from"./p-6a640a2c.js";export{H as HelpTooltip}from"./p-2cff3285.js";export{I as Icon}from"./p-ca52a423.js";export{I as IconButton}from"./p-103249b4.js";export{L as LogoLoading}from"./p-817bf6ff.js";export{M as Menu}from"./p-7b75e004.js";export{M as MenuDivider}from"./p-c939fa4e.js";export{M as MenuItem}from"./p-988058f9.js";export{P as Popover}from"./p-c2706288.js";export{R as Radio}from"./p-36c853c4.js";export{R as RadioGroup}from"./p-f693e6f8.js";export{R as Resizable}from"./p-6ec189d2.js";export{R as ResultList}from"./p-6b862967.js";export{S as SearchBar}from"./p-db34f10c.js";export{S as Select}from"./p-912f6e24.js";export{S as Slider}from"./p-cd6ddb10.js";export{S as Spinner}from"./p-09ba50c3.js";export{T as TextField}from"./p-43b1b3f9.js";export{T as Toast}from"./p-3dd08a0f.js";export{T as Toggle}from"./p-59fb829f.js";export{T as Tooltip}from"./p-92930f2a.js";import"./p-6834631c.js";import"./p-b2c7b113.js";import"./p-fe062eb0.js";import"./p-03dbb28c.js";import"./p-1356f525.js";import"./p-59032668.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{S as vertex_search_bar}from"./p-db34f10c.js";import"./p-6834631c.js";import"./p-fe062eb0.js";import"./p-1356f525.js";import"./p-59032668.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,e as t,h as r,H as i,g as s}from"./p-6834631c.js";import{c as a}from"./p-fe062eb0.js";import{g as n}from"./p-1356f525.js";var l=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var i,s,a;if(Array.isArray(t)){if((i=t.length)!=r.length)return!1;for(s=i;0!=s--;)if(!e(t[s],r[s]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((i=(a=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(s=i;0!=s--;)if(!Object.prototype.hasOwnProperty.call(r,a[s]))return!1;for(s=i;0!=s--;){var n=a[s];if(!e(t[n],r[n]))return!1}return!0}return t!=t&&r!=r};const o=()=>{if("undefined"!=typeof window)return window.getSelection()},h=e=>new Text(e),c=e=>`${e.type}:${e.id}`,d=(e,t,r)=>{const i=c(e);return{before:h(t),beforeSpace:h(v()),result:h(i),afterSpace:null!=r?h(b()):void 0,after:null!=r?h(r):void 0}},u=e=>Object.keys(e).map((t=>e[t])).filter((e=>null!=e)),v=()=>String.fromCharCode(8202),b=()=>String.fromCharCode(160),x=class{constructor(r){e(this,r),this.searchChanged=t(this,"searchChanged",7),this.inputChanged=t(this,"inputChanged",7),this.resultReplaced=t(this,"resultReplaced",7),this.inputFocus=t(this,"inputFocus",7),this.inputBlur=t(this,"inputBlur",7),this.rawElements=[],this.isIdenticalElement=(e,t)=>e===this.triggeredElement||this.getTextContent(e)===this.getTextContent(t),this.getTextContent=e=>{var t;return e instanceof HTMLElement?e.innerText:null!==(t=e.textContent)&&void 0!==t?t:""},this.handleCursorPositionUpdate=()=>{var e,t;const r=null===(e=o())||void 0===e?void 0:e.getRangeAt(0);if(null!=r){const e=this.readTriggerValue(null!==(t=r.commonAncestorContainer.textContent)&&void 0!==t?t:"",r.startOffset);this.hasTriggered||null==e?this.hasTriggered&&null!=e?(this.triggeredRange=r,this.triggeredElement=r.commonAncestorContainer,this.searchChanged.emit(e.replace(this.triggerCharacter,""))):(this.hasTriggered=!1,this.triggeredRange=void 0,this.triggeredElement=void 0):(this.hasTriggered=!0,this.triggeredRange=r,this.triggeredElement=r.commonAncestorContainer,this.searchChanged.emit(e.replace(this.triggerCharacter,"")))}this.cursorPosition=this.getCursorPosition()},this.readTriggerValue=(e,t)=>{const r=e.replace(String.fromCharCode(160)," "),i=r.substring(0,t),s=r.substring(t),a=`${i.includes(this.triggerCharacter)?i.substring(i.lastIndexOf(this.triggerCharacter)):""}${s.substring(0,this.firstIndexOfBreakCharacter(s))}`;return a.includes(this.triggerCharacter)&&!this.includesBreakCharacter(a)?a:void 0},this.includesBreakCharacter=e=>this.breakCharacters.some((t=>e.includes(t))),this.firstIndexOfBreakCharacter=e=>{const t=this.breakCharacters.map((t=>e.indexOf(t))).filter((e=>e>=0));return t.length>0?Math.min(...t):e.length},this.moveCursorToNodeEnd=(e,t=!1)=>{const r=o();if(null!=r){const i=document.createRange();i.selectNodeContents(e),i.collapse(t),r.removeAllRanges(),r.addRange(i)}},this.getContentAsString=()=>null!=this.contentEl?Array.from(this.contentEl.childNodes).reduce(((e,t)=>{var r;return t instanceof HTMLElement&&"true"===t.getAttribute("data-replaced")?`${e}${t.getAttribute("data-original")}`:t instanceof HTMLElement?`${e}${t.innerText}`:`${e}${null!==(r=t.textContent)&&void 0!==r?r:""}`}),"").replace(/[\u200A]/g,"").replace(/[\u00A0]/g," "):"",this.createReplacedElement=(e,t)=>{const r=this.hostEl.querySelector('template[slot="replaced"]');if(null!=r){const i=n(r);return i.bindings.bind(t),i.element.id=t.id,i.element.style.display="inline-block",i.element.contentEditable="false",i.element.tabIndex=-1,i.element.setAttribute("data-replaced","true"),i.element.setAttribute("data-original",e),i.element}throw new Error("Replaced template not defined.")},this.variant="standard",this.disabled=!1,this.triggerCharacter="@",this.breakCharacters=[" ","\n"],this.resultItems=void 0,this.placement="bottom-start",this.value=void 0,this.placeholder=void 0,this.replacements=[],this.replacementUriType="user",this.cursorPosition=void 0,this.displayedElements=[],this.hasTriggered=!1,this.handleKeyDown=this.handleKeyDown.bind(this),this.handleKeyUp=this.handleKeyUp.bind(this),this.handleResultClick=this.handleResultClick.bind(this),this.handleClick=this.handleClick.bind(this),this.handleWindowClick=this.handleWindowClick.bind(this),this.handleInput=this.handleInput.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleCursorPositionUpdate=this.handleCursorPositionUpdate.bind(this),this.updateContent=this.updateContent.bind(this),this.replaceContent=this.replaceContent.bind(this)}componentDidLoad(){this.replaceContent(this.value)}connectedCallback(){window.addEventListener("click",this.handleWindowClick)}disconnectedCallback(){window.removeEventListener("click",this.handleWindowClick)}replaceContent(e,t){if(null!=e&&e!==t){const t=e.match(new RegExp(`${this.replacementUriType}:[0-9a-z-]{36}`,"g")),r=this.replacements.reduce(((e,t)=>Object.assign(Object.assign({},e),{[c(t)]:t})),{});let i=e;const s=null!=t?null==t?void 0:t.reduce(((e,t)=>{if(null!=r[t]){const s=c(r[t]),a=i.indexOf(s),n=i.substring(0,a),l=i.substring(a+s.length),o=d(r[t],n);return i=l,[...e,o.before,o.beforeSpace,o.result]}return e}),[]):[];this.rawElements=[...s,h(i)],this.updateContent(this.replacements)}}updateContent(e,t){null==this.contentEl||l(e,t)||(this.contentEl.innerHTML="",this.displayedElements=this.rawElements.map((e=>{const t=e instanceof HTMLElement?e.innerText:e.textContent,r=this.replacements.find((e=>null==t?void 0:t.includes(c(e))));return null!=t&&null!=r?this.createReplacedElement(t,r):e})),this.displayedElements.forEach((e=>{var t;null===(t=this.contentEl)||void 0===t||t.appendChild("string"==typeof e?h(e):e)})),null!=this.lastReplacedSpace&&this.moveCursorToNodeEnd(this.lastReplacedSpace),this.inputChanged.emit(this.getContentAsString()))}render(){var e;const t=a("wrapper",{standard:"standard"===this.variant,filled:"filled"===this.variant,underlined:"underlined"===this.variant,blank:"blank"===this.variant,disabled:this.disabled});return r(i,null,r("div",{class:t},r("span",{class:"content-input",role:"textbox",contentEditable:"true","aria-multiline":"true","data-placeholder":this.placeholder,ref:e=>this.contentEl=e,onKeyDown:this.handleKeyDown,onKeyUp:this.handleCursorPositionUpdate,onClick:this.handleCursorPositionUpdate,onInput:this.handleInput,onFocus:this.handleFocus,onBlur:this.handleBlur})),r("vertex-result-list",{position:this.cursorPosition,placement:this.placement,open:this.hasTriggered&&null!=this.resultItems&&this.resultItems.length>0,items:null!==(e=this.resultItems)&&void 0!==e?e:[],onEnterPressed:this.handleResultClick,onResultClick:this.handleResultClick},r("slot",{name:"results"})),r("slot",{name:"replaced"}))}handleKeyDown(e){this.hasTriggered&&this.breakCharacters.includes(e.key)&&(this.hasTriggered=!1,this.triggeredRange=void 0,this.triggeredElement=void 0)}handleKeyUp(e){this.handleCursorPositionUpdate(),this.cursorPosition=this.getCursorPosition()}async handleInput(){this.inputChanged.emit(this.getContentAsString())}handleClick(){this.handleCursorPositionUpdate()}handleWindowClick(e){e.target instanceof HTMLElement&&"true"===e.target.getAttribute("data-replaced")&&null!=e.target.nextSibling&&this.moveCursorToNodeEnd(e.target.nextSibling,!0)}handleFocus(e){this.inputFocus.emit(e)}handleBlur(e){this.hasTriggered=!1,this.inputBlur.emit(e)}handleResultClick(e){var t;const r=this.triggeredRange,i=this.triggeredElement,s=i instanceof HTMLElement?i.innerText:null==i?void 0:i.textContent;if(null!=this.contentEl&&null!=r&&null!=i&&null!=s){const a=null!==(t=this.readTriggerValue(s,r.startOffset))&&void 0!==t?t:"",n=s.split(a),l=d(e.detail,n[0],n[1]);this.lastReplacedSpace=l.afterSpace,this.rawElements=Array.from(this.contentEl.childNodes).reduce(((e,t)=>this.isIdenticalElement(t,i)?[...e,...u(l)]:[...e,t]),[]),this.hasTriggered=!1,this.resultReplaced.emit(e.detail),this.replacements=[...this.replacements.filter((t=>t.id!==e.detail.id)),e.detail]}}getCursorPosition(){var e;const t=o();if(null!=t&&t.rangeCount>0){const r=t.getRangeAt(0).getBoundingClientRect(),i=null===(e=this.contentEl)||void 0===e?void 0:e.getBoundingClientRect(),s=r.bottom||(null==i?void 0:i.bottom)||0,a=r.top||(null==i?void 0:i.top)||0;return{x:r.left||(null==i?void 0:i.left)||0,y:this.placement.includes("top")?a:s}}throw new Error("Unable to retrieve window selection.")}get hostEl(){return s(this)}static get watchers(){return{value:["replaceContent"],replacements:["updateContent"]}}};x.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}.content-input.sc-vertex-search-bar{width:100%;box-sizing:border-box;padding:6px 0.5em 7px;border:1px solid transparent;background:none;font-family:var(--vertex-ui-font-family);font-weight:var(--vertex-ui-font-weight-base);font-size:0.875rem;line-height:1.4;white-space:pre-line}.content-input.sc-vertex-search-bar:focus{outline:none}.standard.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-400);color:var(--vertex-ui-neutral-800)}.standard.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-500)}.standard.sc-vertex-search-bar:hover:not(.disabled),.standard.sc-vertex-search-bar:focus{border-color:var(--vertex-ui-neutral-500)}.standard.disabled.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-200)}.standard.disabled.sc-vertex-search-bar,.standard.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.blank.sc-vertex-search-bar{color:var(--vertex-ui-neutral-800)}.blank.sc-vertex-search-bar:not(:hover) .content-input.sc-vertex-search-bar:focus{border-color:var(--vertex-ui-neutral-400);border-radius:4px}.blank.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-500)}.blank.sc-vertex-search-bar:hover:not(.disabled) .content-input.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-400);border-radius:4px}.blank.disabled.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-200)}.blank.disabled.sc-vertex-search-bar,.blank.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.filled.sc-vertex-search-bar{background-color:var(--vertex-ui-neutral-200);border-color:var(--vertex-ui-neutral-200);color:var(--vertex-ui-neutral-800)}.filled.disabled.sc-vertex-search-bar,.filled.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.filled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-700)}.filled.sc-vertex-search-bar:hover:not(.disabled),.filled.sc-vertex-search-bar:focus{border-bottom-color:var(--vertex-ui-blue-600)}.filled.disabled.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-100)}.filled.disabled.sc-vertex-search-bar,.filled.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.underlined.sc-vertex-search-bar{background-color:var(--vertex-ui-white);border-color:var(--vertex-ui-white) var(--vertex-ui-white) var(--vertex-ui-neutral-400) var(--vertex-ui-white);color:var(--vertex-ui-neutral-800)}.underlined.disabled.sc-vertex-search-bar,.underlined.disabled.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.underlined.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-700)}.underlined.sc-vertex-search-bar:hover:not(.disabled),.underlined.sc-vertex-search-bar:focus{background-color:var(--vertex-ui-neutral-200);border-color:var(--vertex-ui-neutral-200);border-bottom-color:var(--vertex-ui-blue-600)}.underlined.disabled.sc-vertex-search-bar{border-bottom-color:var(--vertex-ui-neutral-200)}.underlined.disabled.sc-vertex-search-bar,.underlined.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.underlined.has-error.sc-vertex-search-bar{border-bottom-color:var(--vertex-ui-red-600)}";export{x as S}
|
package/dist/esm/index.js
CHANGED
|
@@ -28,7 +28,7 @@ export { R as Radio } from './radio-39c11ba4.js';
|
|
|
28
28
|
export { R as RadioGroup } from './radio-group-7c35d2f0.js';
|
|
29
29
|
export { R as Resizable } from './resizable-a147709b.js';
|
|
30
30
|
export { R as ResultList } from './result-list-16c6afbd.js';
|
|
31
|
-
export { S as SearchBar } from './search-bar-
|
|
31
|
+
export { S as SearchBar } from './search-bar-f12a3599.js';
|
|
32
32
|
export { S as Select } from './select-d4e135b7.js';
|
|
33
33
|
export { S as Slider } from './slider-dcdb388f.js';
|
|
34
34
|
export { S as Spinner } from './spinner-afccea51.js';
|
|
@@ -57,7 +57,7 @@ const createDocumentRange = () => {
|
|
|
57
57
|
return document.createRange();
|
|
58
58
|
};
|
|
59
59
|
const createTextNode = (text) => {
|
|
60
|
-
return new Text(text
|
|
60
|
+
return new Text(text);
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
const createResultUri = (result) => {
|
|
@@ -79,6 +79,18 @@ const getNodesForSearchResultReplacement = (replacement) => {
|
|
|
79
79
|
.map((key) => replacement[key])
|
|
80
80
|
.filter((node) => node != null);
|
|
81
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* We leverage a couple unique spaces to represent mentions, allowing for
|
|
84
|
+
* correct cursor movement when using arrow keys. As these characters are
|
|
85
|
+
* purely for functional behavior of the input, `trimNonstandardSpaces`
|
|
86
|
+
* will remove them so the input is suitable for emitting.
|
|
87
|
+
*
|
|
88
|
+
* U+200A is a "Hair Space" which acts as a space, but is not visually
|
|
89
|
+
* represented as one.
|
|
90
|
+
*
|
|
91
|
+
* U+00A0 is a "No-Break Space" which is commonly added by browsers
|
|
92
|
+
* when interacting with a contenteditable element.
|
|
93
|
+
*/
|
|
82
94
|
const trimNonstandardSpaces = (text) => {
|
|
83
95
|
return text.replace(/[\u200A]/g, '').replace(/[\u00A0]/g, ' ');
|
|
84
96
|
};
|
|
@@ -89,7 +101,7 @@ const createNoBreakSpace = () => {
|
|
|
89
101
|
return String.fromCharCode(160);
|
|
90
102
|
};
|
|
91
103
|
|
|
92
|
-
const searchBarCss = ".wrapper.sc-vertex-search-bar{display:flex;border:1px solid var(--vertex-ui-
|
|
104
|
+
const searchBarCss = ".wrapper.sc-vertex-search-bar{display:flex;align-items:center;width:100%;box-sizing:border-box;background:none;border:1px solid transparent;border-radius:4px;font-family:var(--vertex-ui-font-family);font-size:0.875rem;line-height:1.4}.content-input.sc-vertex-search-bar{width:100%;box-sizing:border-box;padding:6px 0.5em 7px;border:1px solid transparent;background:none;font-family:var(--vertex-ui-font-family);font-weight:var(--vertex-ui-font-weight-base);font-size:0.875rem;line-height:1.4;white-space:pre-line}.content-input.sc-vertex-search-bar:focus{outline:none}.standard.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-400);color:var(--vertex-ui-neutral-800)}.standard.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-500)}.standard.sc-vertex-search-bar:hover:not(.disabled),.standard.sc-vertex-search-bar:focus{border-color:var(--vertex-ui-neutral-500)}.standard.disabled.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-200)}.standard.disabled.sc-vertex-search-bar,.standard.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.blank.sc-vertex-search-bar{color:var(--vertex-ui-neutral-800)}.blank.sc-vertex-search-bar:not(:hover) .content-input.sc-vertex-search-bar:focus{border-color:var(--vertex-ui-neutral-400);border-radius:4px}.blank.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-500)}.blank.sc-vertex-search-bar:hover:not(.disabled) .content-input.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-400);border-radius:4px}.blank.disabled.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-200)}.blank.disabled.sc-vertex-search-bar,.blank.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.filled.sc-vertex-search-bar{background-color:var(--vertex-ui-neutral-200);border-color:var(--vertex-ui-neutral-200);color:var(--vertex-ui-neutral-800)}.filled.disabled.sc-vertex-search-bar,.filled.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.filled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-700)}.filled.sc-vertex-search-bar:hover:not(.disabled),.filled.sc-vertex-search-bar:focus{border-bottom-color:var(--vertex-ui-blue-600)}.filled.disabled.sc-vertex-search-bar{border-color:var(--vertex-ui-neutral-100)}.filled.disabled.sc-vertex-search-bar,.filled.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.underlined.sc-vertex-search-bar{background-color:var(--vertex-ui-white);border-color:var(--vertex-ui-white) var(--vertex-ui-white) var(--vertex-ui-neutral-400) var(--vertex-ui-white);color:var(--vertex-ui-neutral-800)}.underlined.disabled.sc-vertex-search-bar,.underlined.disabled.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.underlined.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-700)}.underlined.sc-vertex-search-bar:hover:not(.disabled),.underlined.sc-vertex-search-bar:focus{background-color:var(--vertex-ui-neutral-200);border-color:var(--vertex-ui-neutral-200);border-bottom-color:var(--vertex-ui-blue-600)}.underlined.disabled.sc-vertex-search-bar{border-bottom-color:var(--vertex-ui-neutral-200)}.underlined.disabled.sc-vertex-search-bar,.underlined.disabled.sc-vertex-search-bar .content-input.sc-vertex-search-bar:empty::before{content:attr(data-placeholder);color:var(--vertex-ui-neutral-400)}.underlined.has-error.sc-vertex-search-bar{border-bottom-color:var(--vertex-ui-red-600)}";
|
|
93
105
|
|
|
94
106
|
const SearchBar = class {
|
|
95
107
|
constructor(hostRef) {
|
|
@@ -111,31 +123,41 @@ const SearchBar = class {
|
|
|
111
123
|
}
|
|
112
124
|
return (_a = node.textContent) !== null && _a !== void 0 ? _a : '';
|
|
113
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* Inspects the cursor position for the following conditions:
|
|
128
|
+
*
|
|
129
|
+
* 1. The cursor has moved to text that contains a valid string
|
|
130
|
+
* and trigger character, indicating we need to dispatch a
|
|
131
|
+
* `searchChanged` event and display the results.
|
|
132
|
+
*
|
|
133
|
+
* 2. The cursor has moved within text that contains a valid string
|
|
134
|
+
* and trigger character, indicating we need to dispatch a
|
|
135
|
+
* `searchChanged` event to update the currently displayed results.
|
|
136
|
+
*
|
|
137
|
+
* 3. The cursor has moved to text that does not contain a valid
|
|
138
|
+
* string and trigger character, indicating we need to hide any
|
|
139
|
+
* displayed search results.
|
|
140
|
+
*/
|
|
114
141
|
this.handleCursorPositionUpdate = () => {
|
|
115
|
-
var _a, _b
|
|
142
|
+
var _a, _b;
|
|
116
143
|
const windowRange = (_a = getWindowSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0);
|
|
117
144
|
if (windowRange != null) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
125
|
-
}
|
|
145
|
+
const triggerText = this.readTriggerValue((_b = windowRange.commonAncestorContainer.textContent) !== null && _b !== void 0 ? _b : '', windowRange.startOffset);
|
|
146
|
+
if (!this.hasTriggered && triggerText != null) {
|
|
147
|
+
this.hasTriggered = true;
|
|
148
|
+
this.triggeredRange = windowRange;
|
|
149
|
+
this.triggeredElement = windowRange.commonAncestorContainer;
|
|
150
|
+
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
126
151
|
}
|
|
127
|
-
else if (this.hasTriggered) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.triggeredRange = undefined;
|
|
137
|
-
this.triggeredElement = undefined;
|
|
138
|
-
}
|
|
152
|
+
else if (this.hasTriggered && triggerText != null) {
|
|
153
|
+
this.triggeredRange = windowRange;
|
|
154
|
+
this.triggeredElement = windowRange.commonAncestorContainer;
|
|
155
|
+
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
this.hasTriggered = false;
|
|
159
|
+
this.triggeredRange = undefined;
|
|
160
|
+
this.triggeredElement = undefined;
|
|
139
161
|
}
|
|
140
162
|
}
|
|
141
163
|
this.cursorPosition = this.getCursorPosition();
|
|
@@ -218,7 +240,7 @@ const SearchBar = class {
|
|
|
218
240
|
this.placeholder = undefined;
|
|
219
241
|
this.replacements = [];
|
|
220
242
|
this.replacementUriType = 'user';
|
|
221
|
-
this.cursorPosition =
|
|
243
|
+
this.cursorPosition = undefined;
|
|
222
244
|
this.displayedElements = [];
|
|
223
245
|
this.hasTriggered = false;
|
|
224
246
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
@@ -278,7 +300,6 @@ const SearchBar = class {
|
|
|
278
300
|
this.displayedElements = this.rawElements.map((el) => {
|
|
279
301
|
const raw = el instanceof HTMLElement ? el.innerText : el.textContent;
|
|
280
302
|
const replacement = this.replacements.find((r) => raw === null || raw === void 0 ? void 0 : raw.includes(createResultUri(r)));
|
|
281
|
-
console.log(raw);
|
|
282
303
|
if (raw != null && replacement != null) {
|
|
283
304
|
const replacementElement = this.createReplacedElement(raw, replacement);
|
|
284
305
|
return replacementElement;
|
|
@@ -357,7 +378,6 @@ const SearchBar = class {
|
|
|
357
378
|
const replacement = createSearchResultReplacement(event.detail, before, after);
|
|
358
379
|
this.lastReplacedSpace = replacement.afterSpace;
|
|
359
380
|
this.rawElements = Array.from(this.contentEl.childNodes).reduce((re, e) => {
|
|
360
|
-
// TODO: see if we can do anything about the collapse to single line in safari
|
|
361
381
|
if (this.isIdenticalElement(e, triggeredElement)) {
|
|
362
382
|
return [...re, ...getNodesForSearchResultReplacement(replacement)];
|
|
363
383
|
}
|
|
@@ -366,11 +386,11 @@ const SearchBar = class {
|
|
|
366
386
|
}
|
|
367
387
|
}, []);
|
|
368
388
|
this.hasTriggered = false;
|
|
389
|
+
this.resultReplaced.emit(event.detail);
|
|
369
390
|
this.replacements = [
|
|
370
391
|
...this.replacements.filter((r) => r.id !== event.detail.id),
|
|
371
392
|
event.detail,
|
|
372
393
|
];
|
|
373
|
-
this.resultReplaced.emit(event.detail);
|
|
374
394
|
}
|
|
375
395
|
}
|
|
376
396
|
getCursorPosition() {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { EventEmitter, h } from '../../stencil-public-runtime';
|
|
2
2
|
import { Point } from '../../types/point';
|
|
3
3
|
import { PopoverPlacement } from '../popover/popover';
|
|
4
|
-
|
|
5
|
-
id: string;
|
|
6
|
-
type: string;
|
|
7
|
-
} & Record<string, unknown>;
|
|
4
|
+
import { Result } from './types';
|
|
8
5
|
export declare class ResultList {
|
|
9
6
|
items: Result[];
|
|
10
7
|
itemsJson?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Result } from '../result-list/
|
|
1
|
+
import { Result } from '../result-list/types';
|
|
2
2
|
export interface SearchResultReplacement {
|
|
3
3
|
before: Text;
|
|
4
4
|
beforeSpace: Text;
|
|
@@ -9,4 +9,16 @@ export interface SearchResultReplacement {
|
|
|
9
9
|
export declare const createResultUri: (result: Result) => string;
|
|
10
10
|
export declare const createSearchResultReplacement: (result: Result, before: string, after?: string) => SearchResultReplacement;
|
|
11
11
|
export declare const getNodesForSearchResultReplacement: (replacement: SearchResultReplacement) => Text[];
|
|
12
|
+
/**
|
|
13
|
+
* We leverage a couple unique spaces to represent mentions, allowing for
|
|
14
|
+
* correct cursor movement when using arrow keys. As these characters are
|
|
15
|
+
* purely for functional behavior of the input, `trimNonstandardSpaces`
|
|
16
|
+
* will remove them so the input is suitable for emitting.
|
|
17
|
+
*
|
|
18
|
+
* U+200A is a "Hair Space" which acts as a space, but is not visually
|
|
19
|
+
* represented as one.
|
|
20
|
+
*
|
|
21
|
+
* U+00A0 is a "No-Break Space" which is commonly added by browsers
|
|
22
|
+
* when interacting with a contenteditable element.
|
|
23
|
+
*/
|
|
12
24
|
export declare const trimNonstandardSpaces: (text: string) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter, h } from '../../stencil-public-runtime';
|
|
2
2
|
import { PopoverPlacement } from '../popover/popover';
|
|
3
|
-
import { Result } from '../result-list/
|
|
3
|
+
import { Result } from '../result-list/types';
|
|
4
4
|
export type SearchBarVariant = 'standard' | 'filled' | 'underlined' | 'blank';
|
|
5
5
|
export declare class SearchBar {
|
|
6
6
|
/**
|
|
@@ -98,7 +98,7 @@ export declare class SearchBar {
|
|
|
98
98
|
*/
|
|
99
99
|
inputBlur: EventEmitter<FocusEvent>;
|
|
100
100
|
private hostEl;
|
|
101
|
-
private cursorPosition
|
|
101
|
+
private cursorPosition?;
|
|
102
102
|
private displayedElements;
|
|
103
103
|
private hasTriggered;
|
|
104
104
|
private contentEl?;
|
|
@@ -124,6 +124,21 @@ export declare class SearchBar {
|
|
|
124
124
|
private isIdenticalElement;
|
|
125
125
|
private getTextContent;
|
|
126
126
|
private getCursorPosition;
|
|
127
|
+
/**
|
|
128
|
+
* Inspects the cursor position for the following conditions:
|
|
129
|
+
*
|
|
130
|
+
* 1. The cursor has moved to text that contains a valid string
|
|
131
|
+
* and trigger character, indicating we need to dispatch a
|
|
132
|
+
* `searchChanged` event and display the results.
|
|
133
|
+
*
|
|
134
|
+
* 2. The cursor has moved within text that contains a valid string
|
|
135
|
+
* and trigger character, indicating we need to dispatch a
|
|
136
|
+
* `searchChanged` event to update the currently displayed results.
|
|
137
|
+
*
|
|
138
|
+
* 3. The cursor has moved to text that does not contain a valid
|
|
139
|
+
* string and trigger character, indicating we need to hide any
|
|
140
|
+
* displayed search results.
|
|
141
|
+
*/
|
|
127
142
|
private handleCursorPositionUpdate;
|
|
128
143
|
private readTriggerValue;
|
|
129
144
|
private includesBreakCharacter;
|
|
@@ -21,9 +21,8 @@ import { PopoverPlacement as PopoverPlacement1, PopoverResizeBehavior } from "./
|
|
|
21
21
|
import { DetectOverflowOptions, FlipOptions, OffsetOptions } from "@floating-ui/dom";
|
|
22
22
|
import { RadioChangeEventDetail } from "./components/radio/radio";
|
|
23
23
|
import { HorizontalDragDirection, ResizableBoundsUpdate, ResizeEventDetails, VerticalDragDirection } from "./components/resizable/resizable";
|
|
24
|
-
import { Result } from "./components/result-list/
|
|
24
|
+
import { Result } from "./components/result-list/types";
|
|
25
25
|
import { SearchBarVariant } from "./components/search-bar/search-bar";
|
|
26
|
-
import { Result as Result1 } from "./components/result-list/result-list";
|
|
27
26
|
import { LabelDisplay, SliderChangeEventDetails, SliderSize } from "./components/slider/slider";
|
|
28
27
|
import { SpinnerColor, SpinnerSize } from "./components/spinner/spinner";
|
|
29
28
|
import { InputChangeEventDetail as InputChangeEventDetail1, TextFieldAutocomplete, TextFieldType, TextFieldVariant, TextSize as TextSize1 } from "./components/text-field/text-field";
|
|
@@ -596,11 +595,11 @@ export namespace Components {
|
|
|
596
595
|
/**
|
|
597
596
|
* Replaced result values. This will be used in combination with the value of `value` to display existing replaced values. This value will be automatically updated as `Result`s are clicked within this search bar's `<vertex-result-list>`.
|
|
598
597
|
*/
|
|
599
|
-
"replacements":
|
|
598
|
+
"replacements": Result[];
|
|
600
599
|
/**
|
|
601
600
|
* The items to display in this search bar's `<vertex-result-list>`. This can be used alongside the `searchChanged` event to query for results to display.
|
|
602
601
|
*/
|
|
603
|
-
"resultItems"?:
|
|
602
|
+
"resultItems"?: Result[];
|
|
604
603
|
/**
|
|
605
604
|
* The character indicating that we should trigger a search. When this character is encountered, the text following it (omitting `breakCharacters`) will be emitted as a `searchChanged` event.
|
|
606
605
|
*/
|
|
@@ -1828,7 +1827,7 @@ declare namespace LocalJSX {
|
|
|
1828
1827
|
/**
|
|
1829
1828
|
* Emitted when a result has been selected to replace the trigger text. Includes the ID of the `Result` selected.
|
|
1830
1829
|
*/
|
|
1831
|
-
"onResultReplaced"?: (event: VertexSearchBarCustomEvent<
|
|
1830
|
+
"onResultReplaced"?: (event: VertexSearchBarCustomEvent<Result>) => void;
|
|
1832
1831
|
/**
|
|
1833
1832
|
* Emitted when the value of the current search triggered by the specified `triggerCharacter` has changed.
|
|
1834
1833
|
*/
|
|
@@ -1849,11 +1848,11 @@ declare namespace LocalJSX {
|
|
|
1849
1848
|
/**
|
|
1850
1849
|
* Replaced result values. This will be used in combination with the value of `value` to display existing replaced values. This value will be automatically updated as `Result`s are clicked within this search bar's `<vertex-result-list>`.
|
|
1851
1850
|
*/
|
|
1852
|
-
"replacements"?:
|
|
1851
|
+
"replacements"?: Result[];
|
|
1853
1852
|
/**
|
|
1854
1853
|
* The items to display in this search bar's `<vertex-result-list>`. This can be used alongside the `searchChanged` event to query for results to display.
|
|
1855
1854
|
*/
|
|
1856
|
-
"resultItems"?:
|
|
1855
|
+
"resultItems"?: Result[];
|
|
1857
1856
|
/**
|
|
1858
1857
|
* The character indicating that we should trigger a search. When this character is encountered, the text following it (omitting `breakCharacters`) will be emitted as a `searchChanged` event.
|
|
1859
1858
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vertexvis/ui",
|
|
3
|
-
"version": "0.1.0-testing.
|
|
3
|
+
"version": "0.1.0-testing.8",
|
|
4
4
|
"description": "The Vertex UI component library.",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"@vertexvis/utils": "^0.21.0",
|
|
88
88
|
"fast-deep-equal": "^3.1.3"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "70ed9ad971675b703df592cab5794568512ff4f8"
|
|
91
91
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e,e as t,h as r,H as i,g as s}from"./p-6834631c.js";import{c as a}from"./p-fe062eb0.js";import{g as n}from"./p-1356f525.js";var l=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var i,s,a;if(Array.isArray(t)){if((i=t.length)!=r.length)return!1;for(s=i;0!=s--;)if(!e(t[s],r[s]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((i=(a=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(s=i;0!=s--;)if(!Object.prototype.hasOwnProperty.call(r,a[s]))return!1;for(s=i;0!=s--;){var n=a[s];if(!e(t[n],r[n]))return!1}return!0}return t!=t&&r!=r};const o=()=>{if("undefined"!=typeof window)return window.getSelection()},h=e=>new Text(null!=e&&""!==e?e:" "),c=e=>`${e.type}:${e.id}`,d=(e,t,r)=>{const i=c(e);return{before:h(t),beforeSpace:h(v()),result:h(i),afterSpace:null!=r?h(b()):void 0,after:null!=r?h(r):void 0}},u=e=>Object.keys(e).map((t=>e[t])).filter((e=>null!=e)),v=()=>String.fromCharCode(8202),b=()=>String.fromCharCode(160),x=class{constructor(r){e(this,r),this.searchChanged=t(this,"searchChanged",7),this.inputChanged=t(this,"inputChanged",7),this.resultReplaced=t(this,"resultReplaced",7),this.inputFocus=t(this,"inputFocus",7),this.inputBlur=t(this,"inputBlur",7),this.rawElements=[],this.isIdenticalElement=(e,t)=>e===this.triggeredElement||this.getTextContent(e)===this.getTextContent(t),this.getTextContent=e=>{var t;return e instanceof HTMLElement?e.innerText:null!==(t=e.textContent)&&void 0!==t?t:""},this.handleCursorPositionUpdate=()=>{var e,t,r;const i=null===(e=o())||void 0===e?void 0:e.getRangeAt(0);if(null!=i)if(this.hasTriggered){if(this.hasTriggered){const e=this.readTriggerValue(null!==(r=i.commonAncestorContainer.textContent)&&void 0!==r?r:"",i.startOffset);null!=e?(this.triggeredRange=i,this.triggeredElement=i.commonAncestorContainer,this.searchChanged.emit(e.replace(this.triggerCharacter,""))):(this.hasTriggered=!1,this.triggeredRange=void 0,this.triggeredElement=void 0)}}else{const e=this.readTriggerValue(null!==(t=i.commonAncestorContainer.textContent)&&void 0!==t?t:"",i.startOffset);null!=e&&(this.hasTriggered=!0,this.triggeredRange=i,this.triggeredElement=i.commonAncestorContainer,this.searchChanged.emit(e.replace(this.triggerCharacter,"")))}this.cursorPosition=this.getCursorPosition()},this.readTriggerValue=(e,t)=>{const r=e.replace(String.fromCharCode(160)," "),i=r.substring(0,t),s=r.substring(t),a=`${i.includes(this.triggerCharacter)?i.substring(i.lastIndexOf(this.triggerCharacter)):""}${s.substring(0,this.firstIndexOfBreakCharacter(s))}`;return a.includes(this.triggerCharacter)&&!this.includesBreakCharacter(a)?a:void 0},this.includesBreakCharacter=e=>this.breakCharacters.some((t=>e.includes(t))),this.firstIndexOfBreakCharacter=e=>{const t=this.breakCharacters.map((t=>e.indexOf(t))).filter((e=>e>=0));return t.length>0?Math.min(...t):e.length},this.moveCursorToNodeEnd=(e,t=!1)=>{const r=o();if(null!=r){const i=document.createRange();i.selectNodeContents(e),i.collapse(t),r.removeAllRanges(),r.addRange(i)}},this.getContentAsString=()=>null!=this.contentEl?Array.from(this.contentEl.childNodes).reduce(((e,t)=>{var r;return t instanceof HTMLElement&&"true"===t.getAttribute("data-replaced")?`${e}${t.getAttribute("data-original")}`:t instanceof HTMLElement?`${e}${t.innerText}`:`${e}${null!==(r=t.textContent)&&void 0!==r?r:""}`}),"").replace(/[\u200A]/g,"").replace(/[\u00A0]/g," "):"",this.createReplacedElement=(e,t)=>{const r=this.hostEl.querySelector('template[slot="replaced"]');if(null!=r){const i=n(r);return i.bindings.bind(t),i.element.id=t.id,i.element.style.display="inline-block",i.element.contentEditable="false",i.element.tabIndex=-1,i.element.setAttribute("data-replaced","true"),i.element.setAttribute("data-original",e),i.element}throw new Error("Replaced template not defined.")},this.variant="standard",this.disabled=!1,this.triggerCharacter="@",this.breakCharacters=[" ","\n"],this.resultItems=void 0,this.placement="bottom-start",this.value=void 0,this.placeholder=void 0,this.replacements=[],this.replacementUriType="user",this.cursorPosition={x:0,y:0},this.displayedElements=[],this.hasTriggered=!1,this.handleKeyDown=this.handleKeyDown.bind(this),this.handleKeyUp=this.handleKeyUp.bind(this),this.handleResultClick=this.handleResultClick.bind(this),this.handleClick=this.handleClick.bind(this),this.handleWindowClick=this.handleWindowClick.bind(this),this.handleInput=this.handleInput.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleCursorPositionUpdate=this.handleCursorPositionUpdate.bind(this),this.updateContent=this.updateContent.bind(this),this.replaceContent=this.replaceContent.bind(this)}componentDidLoad(){this.replaceContent(this.value)}connectedCallback(){window.addEventListener("click",this.handleWindowClick)}disconnectedCallback(){window.removeEventListener("click",this.handleWindowClick)}replaceContent(e,t){if(null!=e&&e!==t){const t=e.match(new RegExp(`${this.replacementUriType}:[0-9a-z-]{36}`,"g")),r=this.replacements.reduce(((e,t)=>Object.assign(Object.assign({},e),{[c(t)]:t})),{});let i=e;const s=null!=t?null==t?void 0:t.reduce(((e,t)=>{if(null!=r[t]){const s=c(r[t]),a=i.indexOf(s),n=i.substring(0,a),l=i.substring(a+s.length),o=d(r[t],n);return i=l,[...e,o.before,o.beforeSpace,o.result]}return e}),[]):[];this.rawElements=[...s,h(i)],this.updateContent(this.replacements)}}updateContent(e,t){null==this.contentEl||l(e,t)||(this.contentEl.innerHTML="",this.displayedElements=this.rawElements.map((e=>{const t=e instanceof HTMLElement?e.innerText:e.textContent,r=this.replacements.find((e=>null==t?void 0:t.includes(c(e))));return console.log(t),null!=t&&null!=r?this.createReplacedElement(t,r):e})),this.displayedElements.forEach((e=>{var t;null===(t=this.contentEl)||void 0===t||t.appendChild("string"==typeof e?h(e):e)})),null!=this.lastReplacedSpace&&this.moveCursorToNodeEnd(this.lastReplacedSpace),this.inputChanged.emit(this.getContentAsString()))}render(){var e;const t=a("wrapper",{standard:"standard"===this.variant,filled:"filled"===this.variant,underlined:"underlined"===this.variant,blank:"blank"===this.variant,disabled:this.disabled});return r(i,null,r("div",{class:t},r("span",{class:"content-input",role:"textbox",contentEditable:"true","aria-multiline":"true","data-placeholder":this.placeholder,ref:e=>this.contentEl=e,onKeyDown:this.handleKeyDown,onKeyUp:this.handleCursorPositionUpdate,onClick:this.handleCursorPositionUpdate,onInput:this.handleInput,onFocus:this.handleFocus,onBlur:this.handleBlur})),r("vertex-result-list",{position:this.cursorPosition,placement:this.placement,open:this.hasTriggered&&null!=this.resultItems&&this.resultItems.length>0,items:null!==(e=this.resultItems)&&void 0!==e?e:[],onEnterPressed:this.handleResultClick,onResultClick:this.handleResultClick},r("slot",{name:"results"})),r("slot",{name:"replaced"}))}handleKeyDown(e){this.hasTriggered&&this.breakCharacters.includes(e.key)&&(this.hasTriggered=!1,this.triggeredRange=void 0,this.triggeredElement=void 0)}handleKeyUp(e){this.handleCursorPositionUpdate(),this.cursorPosition=this.getCursorPosition()}async handleInput(){this.inputChanged.emit(this.getContentAsString())}handleClick(){this.handleCursorPositionUpdate()}handleWindowClick(e){e.target instanceof HTMLElement&&"true"===e.target.getAttribute("data-replaced")&&null!=e.target.nextSibling&&this.moveCursorToNodeEnd(e.target.nextSibling,!0)}handleFocus(e){this.inputFocus.emit(e)}handleBlur(e){this.hasTriggered=!1,this.inputBlur.emit(e)}handleResultClick(e){var t;const r=this.triggeredRange,i=this.triggeredElement,s=i instanceof HTMLElement?i.innerText:null==i?void 0:i.textContent;if(null!=this.contentEl&&null!=r&&null!=i&&null!=s){const a=null!==(t=this.readTriggerValue(s,r.startOffset))&&void 0!==t?t:"",n=s.split(a),l=d(e.detail,n[0],n[1]);this.lastReplacedSpace=l.afterSpace,this.rawElements=Array.from(this.contentEl.childNodes).reduce(((e,t)=>this.isIdenticalElement(t,i)?[...e,...u(l)]:[...e,t]),[]),this.hasTriggered=!1,this.replacements=[...this.replacements.filter((t=>t.id!==e.detail.id)),e.detail],this.resultReplaced.emit(e.detail)}}getCursorPosition(){var e;const t=o();if(null!=t&&t.rangeCount>0){const r=t.getRangeAt(0).getBoundingClientRect(),i=null===(e=this.contentEl)||void 0===e?void 0:e.getBoundingClientRect(),s=r.bottom||(null==i?void 0:i.bottom)||0,a=r.top||(null==i?void 0:i.top)||0;return{x:r.left||(null==i?void 0:i.left)||0,y:this.placement.includes("top")?a:s}}throw new Error("Unable to retrieve window selection.")}get hostEl(){return s(this)}static get watchers(){return{value:["replaceContent"],replacements:["updateContent"]}}};x.style=".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)}";export{x as S}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{S as vertex_search_bar}from"./p-759f1655.js";import"./p-6834631c.js";import"./p-fe062eb0.js";import"./p-1356f525.js";import"./p-59032668.js";
|