@vertexvis/ui 0.1.0-canary.2 → 0.1.0-canary.21
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/{color-circle-picker-13396ec4.js → color-circle-picker-a8f9a80a.js} +1 -1
- package/dist/cjs/color-picker-2a4820fa.js +46 -0
- package/dist/cjs/{color-circle-05be54bf.js → color-swatch-8aaf6c0b.js} +42 -17
- package/dist/cjs/components.cjs.js +1 -1
- package/dist/cjs/{dialog-88e2308a.js → dialog-34f1dd6e.js} +1 -1
- package/dist/cjs/dom-b6c5fbf4.js +13 -0
- package/dist/cjs/{icon-button-786427d6.js → icon-button-2256a63a.js} +1 -1
- package/dist/cjs/{icon-460fd0f5.js → icon-c3ab7a57.js} +1 -1
- package/dist/cjs/{icon-helper-ba408f49.js → icon-helper-35893713.js} +60 -0
- package/dist/cjs/index.cjs.js +20 -14
- package/dist/cjs/lib-1bd1e383.js +9 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{popover-d9ec8e10.js → popover-942209b8.js} +23 -1
- package/dist/cjs/{result-list-1e592c3c.js → result-list-241ffe8d.js} +46 -2
- package/dist/cjs/search-bar-2e7ee35a.js +527 -0
- package/dist/cjs/{select-0eb7203f.js → select-2b2bdb97.js} +27 -4
- package/dist/cjs/tab-4335cd8f.js +26 -0
- package/dist/cjs/tabs-ece62a01.js +111 -0
- package/dist/cjs/{text-field-0397fb34.js → text-field-bccbde1f.js} +1 -0
- package/dist/cjs/{tooltip-80a7b722.js → tooltip-9ac797a0.js} +59 -23
- package/dist/cjs/vertex-color-circle-picker.cjs.entry.js +1 -1
- package/dist/cjs/vertex-color-picker.cjs.entry.js +2 -1
- package/dist/cjs/vertex-color-swatch.cjs.entry.js +12 -0
- package/dist/cjs/vertex-dialog.cjs.entry.js +1 -1
- package/dist/cjs/vertex-icon-button.cjs.entry.js +2 -2
- package/dist/cjs/vertex-icon.cjs.entry.js +2 -2
- package/dist/cjs/vertex-popover.cjs.entry.js +1 -1
- package/dist/cjs/vertex-result-list.cjs.entry.js +1 -1
- package/dist/cjs/vertex-search-bar.cjs.entry.js +1 -1
- package/dist/cjs/vertex-select.cjs.entry.js +1 -1
- package/dist/cjs/{vertex-color-circle.cjs.entry.js → vertex-tab.cjs.entry.js} +3 -2
- package/dist/cjs/vertex-tabs.cjs.entry.js +12 -0
- package/dist/cjs/vertex-textfield.cjs.entry.js +1 -1
- package/dist/cjs/vertex-tooltip.cjs.entry.js +2 -1
- package/dist/collection/collection-manifest.json +5 -3
- package/dist/collection/components/color-circle-picker/color-circle-picker.js +7 -7
- package/dist/collection/components/color-picker/color-picker.css +95 -15
- package/dist/collection/components/color-picker/color-picker.js +57 -3
- package/dist/collection/components/color-swatch/color-swatch.css +43 -0
- package/dist/collection/components/{color-circle/color-circle.js → color-swatch/color-swatch.js} +96 -23
- package/dist/collection/components/color-swatch/lib.js +5 -0
- package/dist/collection/components/dialog/dialog.css +0 -1
- package/dist/collection/components/icon/icon-helper.js +33 -0
- package/dist/collection/components/icon/icon.js +1 -1
- package/dist/collection/components/icon/icons/caution.js +2 -0
- package/dist/collection/components/icon/icons/compare.js +2 -0
- package/dist/collection/components/icon/icons/compress.js +2 -0
- package/dist/collection/components/icon/icons/cube-stack.js +2 -0
- package/dist/collection/components/icon/icons/expand.js +2 -0
- package/dist/collection/components/icon/icons/pin-text-square.js +2 -0
- package/dist/collection/components/icon/icons/plus-with-arrow.js +2 -0
- package/dist/collection/components/icon/icons/pmi.js +2 -0
- package/dist/collection/components/icon/icons/square-dot-outline.js +2 -0
- package/dist/collection/components/icon/icons/update.js +2 -0
- package/dist/collection/components/icon/icons/views.js +2 -0
- package/dist/collection/components/icon-button/icon-button.js +1 -1
- package/dist/collection/components/index.js +3 -1
- package/dist/collection/components/menu/menu.js +1 -1
- package/dist/collection/components/popover/popover.js +51 -0
- package/dist/collection/components/result-list/result-list.js +52 -5
- package/dist/collection/components/result-list/types.js +1 -0
- package/dist/collection/components/search-bar/dom.js +29 -0
- package/dist/collection/components/search-bar/lib.js +76 -15
- package/dist/collection/components/search-bar/search-bar.css +0 -16
- package/dist/collection/components/search-bar/search-bar.js +429 -320
- package/dist/collection/components/select/select.css +24 -0
- package/dist/collection/components/select/select.js +49 -2
- package/dist/collection/components/tab/tab.css +16 -0
- package/dist/collection/components/tab/tab.js +85 -0
- package/dist/collection/components/tab/util.js +3 -0
- package/dist/collection/components/tabs/tabs.css +67 -0
- package/dist/collection/components/tabs/tabs.js +159 -0
- package/dist/collection/components/text-field/text-field.js +1 -0
- package/dist/collection/components/tooltip/tooltip.js +62 -18
- package/dist/collection/types/icon.js +11 -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-036a0be0.js +1 -0
- package/dist/components/{p-165aed7d.js → p-0d4a0d61.js} +1 -1
- package/dist/components/{p-9374ef6c.js → p-1367d3af.js} +1 -1
- package/dist/components/{p-103249b4.js → p-1971ed0b.js} +1 -1
- package/dist/components/p-1d08dd79.entry.js +1 -0
- package/dist/components/p-2ae8175d.entry.js +1 -0
- package/dist/components/p-2b4aedaa.entry.js +1 -0
- package/dist/components/p-3438c441.js +1 -0
- package/dist/components/p-3dd7a75f.entry.js +1 -0
- package/dist/components/p-406e73da.entry.js +1 -0
- package/dist/components/p-4327deea.js +1 -0
- package/dist/components/p-43b1b3f9.js +1 -0
- package/dist/components/p-49db6547.entry.js +1 -0
- package/dist/components/p-606596de.entry.js +1 -0
- package/dist/components/{p-ca52a423.js → p-63b48634.js} +1 -1
- package/dist/components/p-655053df.js +1 -0
- package/dist/components/p-69496858.js +1 -0
- package/dist/components/p-6a49c365.entry.js +1 -0
- package/dist/components/p-6b6c2260.js +1 -0
- package/dist/components/p-6b862967.js +1 -0
- package/dist/components/p-76b961b8.js +1 -0
- package/dist/components/p-8bbc344d.entry.js +1 -0
- package/dist/components/p-96f55673.js +1 -0
- package/dist/components/p-a0eac69c.entry.js +1 -0
- package/dist/components/p-bc2fbd68.entry.js +1 -0
- package/dist/components/p-c2706288.js +1 -0
- package/dist/components/p-d3fd9ca3.entry.js +1 -0
- package/dist/components/p-d539f530.js +1 -0
- package/dist/components/p-e35057b5.entry.js +1 -0
- package/dist/components/p-ee496965.entry.js +1 -0
- package/dist/components/p-ff7c70b9.js +1 -0
- package/dist/esm/{color-circle-picker-998a7e9c.js → color-circle-picker-e2a2cfb5.js} +1 -1
- package/dist/esm/color-picker-1d67effe.js +44 -0
- package/dist/esm/{color-circle-842f3321.js → color-swatch-0e62d13d.js} +42 -17
- package/dist/esm/components.js +1 -1
- package/dist/esm/{dialog-e3f49527.js → dialog-1cef715c.js} +1 -1
- package/dist/esm/dom-613e2677.js +10 -0
- package/dist/esm/{icon-d37150b4.js → icon-55b22de7.js} +1 -1
- package/dist/esm/{icon-button-aad3c0e7.js → icon-button-e6c72aec.js} +1 -1
- package/dist/esm/{icon-helper-83f10f73.js → icon-helper-67de1067.js} +60 -0
- package/dist/esm/index.js +17 -13
- package/dist/esm/lib-73fbca8b.js +7 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{popover-67c88e4b.js → popover-6e806354.js} +23 -1
- package/dist/esm/{result-list-36cfb08a.js → result-list-16c6afbd.js} +46 -2
- package/dist/esm/search-bar-8d18626e.js +525 -0
- package/dist/esm/{select-75ed5653.js → select-78aeff96.js} +27 -4
- package/dist/esm/tab-c76332b0.js +24 -0
- package/dist/esm/tabs-8e5353ba.js +109 -0
- package/dist/esm/{text-field-e542da25.js → text-field-32ac877e.js} +1 -0
- package/dist/esm/{tooltip-97c1b3ec.js → tooltip-29278ea4.js} +58 -22
- package/dist/esm/vertex-color-circle-picker.entry.js +1 -1
- package/dist/esm/vertex-color-picker.entry.js +2 -1
- package/dist/esm/vertex-color-swatch.entry.js +4 -0
- package/dist/esm/vertex-dialog.entry.js +1 -1
- package/dist/esm/vertex-icon-button.entry.js +2 -2
- package/dist/esm/vertex-icon.entry.js +2 -2
- package/dist/esm/vertex-popover.entry.js +1 -1
- package/dist/esm/vertex-result-list.entry.js +1 -1
- package/dist/esm/vertex-search-bar.entry.js +1 -1
- package/dist/esm/vertex-select.entry.js +1 -1
- package/dist/esm/vertex-tab.entry.js +3 -0
- package/dist/esm/vertex-tabs.entry.js +4 -0
- package/dist/esm/vertex-textfield.entry.js +1 -1
- package/dist/esm/vertex-tooltip.entry.js +2 -1
- package/dist/types/components/color-circle-picker/color-circle-picker.d.ts +7 -7
- package/dist/types/components/color-picker/color-picker.d.ts +19 -0
- package/dist/types/components/{color-circle/color-circle.d.ts → color-swatch/color-swatch.d.ts} +23 -5
- package/dist/types/components/color-swatch/lib.d.ts +1 -0
- package/dist/types/components/icon/icons/caution.d.ts +3 -0
- package/dist/types/components/icon/icons/compare.d.ts +3 -0
- package/dist/types/components/icon/icons/compress.d.ts +3 -0
- package/dist/types/components/icon/icons/cube-stack.d.ts +3 -0
- package/dist/types/components/icon/icons/expand.d.ts +3 -0
- package/dist/types/components/icon/icons/pin-text-square.d.ts +3 -0
- package/dist/types/components/icon/icons/plus-with-arrow.d.ts +3 -0
- package/dist/types/components/icon/icons/pmi.d.ts +3 -0
- package/dist/types/components/icon/icons/square-dot-outline.d.ts +3 -0
- package/dist/types/components/icon/icons/update.d.ts +3 -0
- package/dist/types/components/icon/icons/views.d.ts +3 -0
- package/dist/types/components/index.d.ts +3 -1
- package/dist/types/components/popover/popover.d.ts +7 -0
- 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 +8 -0
- package/dist/types/components/search-bar/lib.d.ts +31 -6
- package/dist/types/components/search-bar/search-bar.d.ts +125 -42
- package/dist/types/components/select/select.d.ts +8 -0
- package/dist/types/components/tab/tab.d.ts +11 -0
- package/dist/types/components/tab/util.d.ts +1 -0
- package/dist/types/components/tabs/tabs.d.ts +23 -0
- package/dist/types/components/tooltip/tooltip.d.ts +7 -0
- package/dist/types/components.d.ts +254 -96
- package/dist/types/types/icon.d.ts +11 -0
- package/dist/types/util/templates/element-pool.d.ts +10 -1
- package/package.json +4 -3
- package/dist/cjs/color-picker-876ace00.js +0 -37
- package/dist/cjs/search-bar-bb40cfa7.js +0 -290
- package/dist/collection/components/color-circle/color-circle.css +0 -18
- package/dist/components/p-03dbb28c.js +0 -1
- package/dist/components/p-0f8b9ede.entry.js +0 -1
- package/dist/components/p-19318fee.entry.js +0 -1
- package/dist/components/p-1d6cb015.entry.js +0 -1
- package/dist/components/p-209db2ba.entry.js +0 -1
- package/dist/components/p-20a74d5d.entry.js +0 -1
- package/dist/components/p-35e7ab78.entry.js +0 -1
- package/dist/components/p-4224c2ad.js +0 -1
- package/dist/components/p-52739247.js +0 -1
- package/dist/components/p-552c128f.js +0 -1
- package/dist/components/p-6505cdb3.js +0 -1
- package/dist/components/p-7dba2574.entry.js +0 -1
- package/dist/components/p-7f64b251.entry.js +0 -1
- package/dist/components/p-8434602f.js +0 -1
- package/dist/components/p-ae6a3c46.entry.js +0 -1
- package/dist/components/p-bd11e7d1.js +0 -1
- package/dist/components/p-d9b9aebe.js +0 -1
- package/dist/components/p-e576818b.entry.js +0 -1
- package/dist/components/p-ebabee40.entry.js +0 -1
- package/dist/components/p-f49a7ffd.js +0 -1
- package/dist/components/p-f71fc166.entry.js +0 -1
- package/dist/esm/color-picker-2e3b51fa.js +0 -35
- package/dist/esm/search-bar-59cc151d.js +0 -288
- package/dist/esm/vertex-color-circle.entry.js +0 -2
|
@@ -1,94 +1,105 @@
|
|
|
1
1
|
import { h, Host, } from '@stencil/core';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
+
import deepEqual from 'fast-deep-equal';
|
|
3
4
|
import { generateInstanceFromTemplate } from '../../util/templates/templates';
|
|
4
|
-
import { createDocumentRange, createTextNode, getWindowSelection,
|
|
5
|
+
import { createDocumentRange, createTextNode, getWindowSelection, isBrElement, isHtmlElement, nodeHasChildNodes, } from './dom';
|
|
6
|
+
import { createResultUri, createSearchResultReplacement, getNodesForSearchResultReplacement, standardizeNewlinesAndSpaces, trimNonstandardSpaces, } from './lib';
|
|
5
7
|
export class SearchBar {
|
|
6
8
|
constructor() {
|
|
7
|
-
this.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
this.rawElements = [];
|
|
10
|
+
this.attemptReplaceElement = (child, other, replacement, isBreaking = false) => {
|
|
11
|
+
// In the case that the child we're evaluating has its own children
|
|
12
|
+
// (often a wrapper `<div>`), we want to evaluate whether any of its
|
|
13
|
+
// children is the target to replace.
|
|
14
|
+
if (nodeHasChildNodes(child) &&
|
|
15
|
+
Array.from(child.childNodes).some((c) => nodeHasChildNodes(c) || this.isIdenticalElement(c, other))) {
|
|
16
|
+
return Array.from(child.childNodes).reduce((res, c) => [
|
|
17
|
+
...res,
|
|
18
|
+
...this.attemptReplaceElement(c, other, replacement,
|
|
19
|
+
// If the element we're evaluating is a wrapper, we want to
|
|
20
|
+
// consider it a breaking element and add a newline to the
|
|
21
|
+
// replaced element only if the previous node is a `Text` node.
|
|
22
|
+
!isHtmlElement(child.previousSibling)),
|
|
23
|
+
], []);
|
|
14
24
|
}
|
|
15
25
|
else {
|
|
16
|
-
this.
|
|
26
|
+
return this.isIdenticalElement(child, other)
|
|
27
|
+
? getNodesForSearchResultReplacement(replacement, isBreaking)
|
|
28
|
+
: [child];
|
|
17
29
|
}
|
|
18
|
-
if (event.key === 'Backspace') {
|
|
19
|
-
const selection = getWindowSelection();
|
|
20
|
-
if (selection && (selection === null || selection === void 0 ? void 0 : selection.rangeCount) > 0) {
|
|
21
|
-
const range = selection.getRangeAt(0);
|
|
22
|
-
range.deleteContents();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
this.valueChanged.emit();
|
|
26
30
|
};
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
this.
|
|
30
|
-
}
|
|
31
|
-
if (event.key === 'Enter') {
|
|
32
|
-
this.clearTriggerState();
|
|
33
|
-
}
|
|
34
|
-
this.valueChanged.emit();
|
|
31
|
+
this.isIdenticalElement = (child, other) => {
|
|
32
|
+
return (child === this.triggeredElement ||
|
|
33
|
+
this.getTextContent(child) === this.getTextContent(other));
|
|
35
34
|
};
|
|
36
|
-
this.
|
|
37
|
-
var _a
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
this.triggerRange.startContainer === this.triggerRange.endContainer) {
|
|
41
|
-
const triggerRangeNode = this.triggerRange.startContainer;
|
|
42
|
-
if (isTextNode(triggerRangeNode)) {
|
|
43
|
-
const before = createTextNode((_a = triggerRangeNode.textContent) === null || _a === void 0 ? void 0 : _a.slice(0, this.triggerRange.startOffset - 1));
|
|
44
|
-
const after = createTextNode((_b = triggerRangeNode.textContent) === null || _b === void 0 ? void 0 : _b.slice(this.triggerRange.endOffset));
|
|
45
|
-
const replaced = this.createReplacedElement(data);
|
|
46
|
-
(_c = triggerRangeNode.parentElement) === null || _c === void 0 ? void 0 : _c.insertBefore(before, triggerRangeNode);
|
|
47
|
-
(_d = triggerRangeNode.parentElement) === null || _d === void 0 ? void 0 : _d.insertBefore(after, triggerRangeNode.nextSibling);
|
|
48
|
-
(_e = triggerRangeNode.parentElement) === null || _e === void 0 ? void 0 : _e.insertBefore(replaced, after);
|
|
49
|
-
triggerRangeNode.remove();
|
|
50
|
-
this.moveCursorToNodeEnd(after, true);
|
|
51
|
-
}
|
|
35
|
+
this.getTextContent = (node) => {
|
|
36
|
+
var _a;
|
|
37
|
+
if (isHtmlElement(node)) {
|
|
38
|
+
return node.innerText;
|
|
52
39
|
}
|
|
40
|
+
return (_a = node.textContent) !== null && _a !== void 0 ? _a : '';
|
|
53
41
|
};
|
|
54
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Inspects the cursor position for the following conditions:
|
|
44
|
+
*
|
|
45
|
+
* 1. The cursor has moved to text that contains a valid string
|
|
46
|
+
* and trigger character, indicating we need to dispatch a
|
|
47
|
+
* `searchChanged` event and display the results.
|
|
48
|
+
*
|
|
49
|
+
* 2. The cursor has moved within text that contains a valid string
|
|
50
|
+
* and trigger character, indicating we need to dispatch a
|
|
51
|
+
* `searchChanged` event to update the currently displayed results.
|
|
52
|
+
*
|
|
53
|
+
* 3. The cursor has moved to text that does not contain a valid
|
|
54
|
+
* string and trigger character, indicating we need to hide any
|
|
55
|
+
* displayed search results.
|
|
56
|
+
*/
|
|
57
|
+
this.handleCursorPositionUpdate = () => {
|
|
55
58
|
var _a, _b;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
const windowRange = (_a = getWindowSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0);
|
|
60
|
+
if (windowRange != null) {
|
|
61
|
+
const triggerText = this.readTriggerValue((_b = windowRange.commonAncestorContainer.textContent) !== null && _b !== void 0 ? _b : '', windowRange.startOffset);
|
|
62
|
+
if (!this.hasTriggered && triggerText != null) {
|
|
63
|
+
this.hasTriggered = true;
|
|
64
|
+
this.triggeredRange = windowRange;
|
|
65
|
+
this.triggeredElement = windowRange.commonAncestorContainer;
|
|
66
|
+
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
67
|
+
}
|
|
68
|
+
else if (this.hasTriggered && triggerText != null) {
|
|
69
|
+
this.triggeredRange = windowRange;
|
|
70
|
+
this.triggeredElement = windowRange.commonAncestorContainer;
|
|
71
|
+
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this.hasTriggered = false;
|
|
75
|
+
this.triggeredRange = undefined;
|
|
76
|
+
this.triggeredElement = undefined;
|
|
77
|
+
}
|
|
61
78
|
}
|
|
62
|
-
|
|
79
|
+
this.cursorPosition = this.getCursorPosition();
|
|
63
80
|
};
|
|
64
|
-
this.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
this.readTriggerValue = (value, fromIndex) => {
|
|
82
|
+
const adjustedValue = value.replace(String.fromCharCode(160), ' ');
|
|
83
|
+
const beforeSubstr = adjustedValue.substring(0, fromIndex);
|
|
84
|
+
const afterSubstr = adjustedValue.substring(fromIndex);
|
|
85
|
+
const adjustedBeforeSubstr = beforeSubstr.includes(this.triggerCharacter)
|
|
86
|
+
? beforeSubstr.substring(beforeSubstr.lastIndexOf(this.triggerCharacter))
|
|
87
|
+
: '';
|
|
88
|
+
const adjustedAfterSubstr = afterSubstr.substring(0, this.firstIndexOfBreakCharacter(afterSubstr));
|
|
89
|
+
const result = `${adjustedBeforeSubstr}${adjustedAfterSubstr}`;
|
|
90
|
+
return result.includes(this.triggerCharacter) &&
|
|
91
|
+
!this.includesBreakCharacter(result)
|
|
92
|
+
? result
|
|
93
|
+
: undefined;
|
|
72
94
|
};
|
|
73
|
-
this.
|
|
74
|
-
|
|
75
|
-
clearTimeout(this.triggerTimeout);
|
|
76
|
-
this.triggerTimeout = undefined;
|
|
77
|
-
}
|
|
95
|
+
this.includesBreakCharacter = (value) => {
|
|
96
|
+
return this.breakCharacters.some((bc) => value.includes(bc));
|
|
78
97
|
};
|
|
79
|
-
this.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const inputBounds = (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
85
|
-
const cursorBottom = cursorBounds.bottom || (inputBounds === null || inputBounds === void 0 ? void 0 : inputBounds.bottom) || 0;
|
|
86
|
-
const cursorTop = cursorBounds.top || (inputBounds === null || inputBounds === void 0 ? void 0 : inputBounds.top) || 0;
|
|
87
|
-
this.cursorPosition = {
|
|
88
|
-
x: cursorBounds.left || (inputBounds === null || inputBounds === void 0 ? void 0 : inputBounds.left) || 0,
|
|
89
|
-
y: this.placement.includes('top') ? cursorTop : cursorBottom,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
98
|
+
this.firstIndexOfBreakCharacter = (value) => {
|
|
99
|
+
const indices = this.breakCharacters
|
|
100
|
+
.map((bc) => value.indexOf(bc))
|
|
101
|
+
.filter((i) => i >= 0);
|
|
102
|
+
return indices.length > 0 ? Math.min(...indices) : value.length;
|
|
92
103
|
};
|
|
93
104
|
this.moveCursorToNodeEnd = (node, collapseToStart = false) => {
|
|
94
105
|
const selection = getWindowSelection();
|
|
@@ -100,143 +111,160 @@ export class SearchBar {
|
|
|
100
111
|
selection.addRange(range);
|
|
101
112
|
}
|
|
102
113
|
};
|
|
103
|
-
this.
|
|
104
|
-
if (
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
this.getContentAsString = (element) => {
|
|
115
|
+
if (element != null) {
|
|
116
|
+
const res = trimNonstandardSpaces(Array.from(element.childNodes).reduce((res, n) => {
|
|
117
|
+
var _a;
|
|
118
|
+
const previousSiblingIsBlock = n.previousSibling == null || isHtmlElement(n.previousSibling);
|
|
119
|
+
if (isHtmlElement(n) && n.getAttribute('data-replaced') === 'true') {
|
|
120
|
+
/**
|
|
121
|
+
* If an element has been replaced visually, append the original
|
|
122
|
+
* value prior to being replaced.
|
|
123
|
+
*/
|
|
124
|
+
return `${res}${n.getAttribute('data-original')}`;
|
|
125
|
+
}
|
|
126
|
+
else if (isHtmlElement(n) && n.childElementCount > 0) {
|
|
127
|
+
/**
|
|
128
|
+
* If an element is a wrapper, we want to treat it as a block element,
|
|
129
|
+
* ensuring newlines before and after the content.
|
|
130
|
+
* Additionally, we want to evaluate each of its children independently.
|
|
131
|
+
* Some browsers will conditionally wrap content in additional wrapper
|
|
132
|
+
* elements we need to unravel.
|
|
133
|
+
*/
|
|
134
|
+
return `${res}${previousSiblingIsBlock ? '' : '\n'}${this.getContentAsString(n)}`;
|
|
135
|
+
}
|
|
136
|
+
else if (isBrElement(n)) {
|
|
137
|
+
/**
|
|
138
|
+
* If an element is a `<br>` element, we want to simply represent
|
|
139
|
+
* it as a newline in the returned string.
|
|
140
|
+
*/
|
|
141
|
+
return `${res}\n`;
|
|
142
|
+
}
|
|
143
|
+
else if (isHtmlElement(n)) {
|
|
144
|
+
/**
|
|
145
|
+
* If an element is a wrapper, we want to treat it as a block element,
|
|
146
|
+
* ensuring newlines before and after the content.
|
|
147
|
+
* If the prior element is also to be treated as a block format, we
|
|
148
|
+
* will omit the newline before the content to avoid duplicating the
|
|
149
|
+
* behavior.
|
|
150
|
+
*/
|
|
151
|
+
return `${res}${previousSiblingIsBlock ? '' : '\n'}${n.innerText}\n`;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
/**
|
|
155
|
+
* If a node is simply a `Text` node, we just want to append the text
|
|
156
|
+
* if defined.
|
|
157
|
+
*/
|
|
158
|
+
return `${res}${(_a = n.textContent) !== null && _a !== void 0 ? _a : ''}`;
|
|
159
|
+
}
|
|
160
|
+
}, ''));
|
|
161
|
+
return res;
|
|
111
162
|
}
|
|
163
|
+
return '';
|
|
112
164
|
};
|
|
113
|
-
this.createReplacedElement = (data) => {
|
|
165
|
+
this.createReplacedElement = (original, data) => {
|
|
114
166
|
const template = this.hostEl.querySelector('template[slot="replaced"]');
|
|
115
167
|
if (template != null) {
|
|
116
168
|
const instance = generateInstanceFromTemplate(template);
|
|
117
169
|
instance.bindings.bind(data);
|
|
170
|
+
instance.element.id = data.id;
|
|
118
171
|
instance.element.style.display = 'inline-block';
|
|
119
172
|
instance.element.contentEditable = 'false';
|
|
173
|
+
instance.element.tabIndex = -1;
|
|
120
174
|
instance.element.setAttribute('data-replaced', 'true');
|
|
175
|
+
instance.element.setAttribute('data-original', original);
|
|
121
176
|
return instance.element;
|
|
122
177
|
}
|
|
123
178
|
else {
|
|
124
179
|
throw new Error('Replaced template not defined.');
|
|
125
180
|
}
|
|
126
181
|
};
|
|
127
|
-
this.handleSelectionChange = () => {
|
|
128
|
-
this.updateTriggerState(this.getSelectionSubstring());
|
|
129
|
-
};
|
|
130
|
-
this.getSelectionSubstring = () => {
|
|
131
|
-
var _a;
|
|
132
|
-
const selection = getWindowSelection();
|
|
133
|
-
if (selection != null && selection.rangeCount > 0) {
|
|
134
|
-
const range = selection.getRangeAt(0);
|
|
135
|
-
this.updateTriggerRange();
|
|
136
|
-
if (range != null &&
|
|
137
|
-
range.startOffset === range.endOffset &&
|
|
138
|
-
isTextNode(range.startContainer) &&
|
|
139
|
-
range.startContainer.textContent != null &&
|
|
140
|
-
!isReplacedElement(range.startContainer.parentElement) &&
|
|
141
|
-
((_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.contains(range.startContainer))) {
|
|
142
|
-
return range.startContainer.textContent.slice(this.lastIndexOfBreakCharacter(range.startContainer.textContent.slice(0, range.startOffset)) + 1, range.startOffset);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return '';
|
|
146
|
-
};
|
|
147
|
-
this.insertAdjacentTextNode = (el) => {
|
|
148
|
-
el.insertAdjacentText('afterend', '');
|
|
149
|
-
if (el.nextSibling != null) {
|
|
150
|
-
this.moveCursorToNodeEnd(el.nextSibling);
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
this.updateTriggerState = (text) => {
|
|
154
|
-
const triggers = this.triggerCharacter != null
|
|
155
|
-
? [...this.triggerCharacters, this.triggerCharacter]
|
|
156
|
-
: this.triggerCharacters;
|
|
157
|
-
const trigger = triggers.find((tc) => text.includes(tc));
|
|
158
|
-
if (trigger != null) {
|
|
159
|
-
this.restartTriggerInput();
|
|
160
|
-
this.triggerKey = trigger;
|
|
161
|
-
this.updateTriggerRange();
|
|
162
|
-
if (this.cursorPosition == null) {
|
|
163
|
-
this.updateCursorPosition();
|
|
164
|
-
}
|
|
165
|
-
this.open = true;
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
this.clearTriggerState();
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
this.updateTriggerRange = () => {
|
|
172
|
-
var _a;
|
|
173
|
-
const selection = getWindowSelection();
|
|
174
|
-
if (selection != null && selection.rangeCount > 0) {
|
|
175
|
-
const range = selection.getRangeAt(0);
|
|
176
|
-
if (this.triggerKey != null) {
|
|
177
|
-
this.triggerRange = (_a = this.triggerRange) !== null && _a !== void 0 ? _a : range.cloneRange();
|
|
178
|
-
this.triggerRange.setEnd(range.endContainer, range.endOffset);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
this.clearTriggerState = () => {
|
|
183
|
-
this.triggerKey = undefined;
|
|
184
|
-
this.triggerRange = undefined;
|
|
185
|
-
this.cursorPosition = undefined;
|
|
186
|
-
this.open = false;
|
|
187
|
-
this.clearTriggerTimeout();
|
|
188
|
-
};
|
|
189
|
-
this.lastIndexOfBreakCharacter = (search) => {
|
|
190
|
-
const index = this.breakCharacters.reduce((index, bc) => {
|
|
191
|
-
const searchIndex = search
|
|
192
|
-
.replace(String.fromCharCode(160), ' ')
|
|
193
|
-
.lastIndexOf(bc);
|
|
194
|
-
return searchIndex > index ? searchIndex : index;
|
|
195
|
-
}, -1);
|
|
196
|
-
return index;
|
|
197
|
-
};
|
|
198
|
-
this.handleFocus = (ev) => {
|
|
199
|
-
this.inputFocus.emit(ev);
|
|
200
|
-
};
|
|
201
|
-
this.handleBlur = (ev) => {
|
|
202
|
-
this.open = false;
|
|
203
|
-
this.inputBlur.emit(ev);
|
|
204
|
-
};
|
|
205
|
-
this.handleInputPointerEvent = (ev) => {
|
|
206
|
-
if (ev.target != null) {
|
|
207
|
-
this.updateInputCursorPosition(ev.target);
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
this.handleResultPointerDown = (ev) => {
|
|
211
|
-
ev.preventDefault();
|
|
212
|
-
};
|
|
213
182
|
this.variant = 'standard';
|
|
183
|
+
this.disabled = false;
|
|
184
|
+
this.triggerCharacter = '@';
|
|
185
|
+
this.breakCharacters = [' ', '\n'];
|
|
214
186
|
this.resultItems = undefined;
|
|
215
|
-
this.triggerCharacters = [];
|
|
216
|
-
this.triggerCharacter = undefined;
|
|
217
|
-
this.breakCharacters = [' '];
|
|
218
|
-
this.debounce = 100;
|
|
219
|
-
this.placeholder = undefined;
|
|
220
187
|
this.placement = 'bottom-start';
|
|
188
|
+
this.value = undefined;
|
|
189
|
+
this.placeholder = undefined;
|
|
190
|
+
this.replacements = [];
|
|
191
|
+
this.replacementUriType = 'user';
|
|
221
192
|
this.cursorPosition = undefined;
|
|
222
|
-
this.
|
|
223
|
-
this.
|
|
224
|
-
this.
|
|
193
|
+
this.displayedElements = [];
|
|
194
|
+
this.hasTriggered = false;
|
|
195
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
196
|
+
this.handleKeyUp = this.handleKeyUp.bind(this);
|
|
197
|
+
this.handleResultClick = this.handleResultClick.bind(this);
|
|
198
|
+
this.handleClick = this.handleClick.bind(this);
|
|
199
|
+
this.handleWindowClick = this.handleWindowClick.bind(this);
|
|
200
|
+
this.handleInput = this.handleInput.bind(this);
|
|
201
|
+
this.handleBlur = this.handleBlur.bind(this);
|
|
202
|
+
this.handleFocus = this.handleFocus.bind(this);
|
|
203
|
+
this.handleCursorPositionUpdate =
|
|
204
|
+
this.handleCursorPositionUpdate.bind(this);
|
|
205
|
+
this.updateContent = this.updateContent.bind(this);
|
|
206
|
+
this.replaceContent = this.replaceContent.bind(this);
|
|
207
|
+
}
|
|
208
|
+
componentDidLoad() {
|
|
209
|
+
this.replaceContent(this.value);
|
|
225
210
|
}
|
|
226
|
-
|
|
227
|
-
|
|
211
|
+
connectedCallback() {
|
|
212
|
+
window.addEventListener('click', this.handleWindowClick);
|
|
228
213
|
}
|
|
229
214
|
disconnectedCallback() {
|
|
230
|
-
|
|
215
|
+
window.removeEventListener('click', this.handleWindowClick);
|
|
231
216
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
217
|
+
replaceContent(newValue, oldValue) {
|
|
218
|
+
if (newValue != null && newValue !== oldValue) {
|
|
219
|
+
const pattern = `${this.replacementUriType}:[0-9a-z-]{36}`;
|
|
220
|
+
const matches = newValue.match(new RegExp(pattern, 'g'));
|
|
221
|
+
const replacementsMap = this.replacements.reduce((map, r) => (Object.assign(Object.assign({}, map), { [createResultUri(r)]: r })), {});
|
|
222
|
+
let nextSubstr = newValue;
|
|
223
|
+
const parts = matches != null
|
|
224
|
+
? matches === null || matches === void 0 ? void 0 : matches.reduce((res, m) => {
|
|
225
|
+
if (replacementsMap[m] != null) {
|
|
226
|
+
const urn = createResultUri(replacementsMap[m]);
|
|
227
|
+
const index = nextSubstr.indexOf(urn);
|
|
228
|
+
const before = nextSubstr.substring(0, index);
|
|
229
|
+
const after = nextSubstr.substring(index + urn.length);
|
|
230
|
+
const replacement = createSearchResultReplacement(replacementsMap[m], before);
|
|
231
|
+
nextSubstr = after;
|
|
232
|
+
return [
|
|
233
|
+
...res,
|
|
234
|
+
replacement.before,
|
|
235
|
+
replacement.beforeSpace,
|
|
236
|
+
replacement.result,
|
|
237
|
+
replacement.afterSpace,
|
|
238
|
+
];
|
|
239
|
+
}
|
|
240
|
+
return res;
|
|
241
|
+
}, [])
|
|
242
|
+
: [];
|
|
243
|
+
this.rawElements = [...parts, createTextNode(nextSubstr)].reduce((res, p) => [...res, ...standardizeNewlinesAndSpaces(p)], []);
|
|
244
|
+
this.updateContent(this.replacements);
|
|
245
|
+
}
|
|
236
246
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
247
|
+
updateContent(newValue, oldValue) {
|
|
248
|
+
if (this.contentEl != null && !deepEqual(newValue, oldValue)) {
|
|
249
|
+
this.contentEl.innerHTML = '';
|
|
250
|
+
this.displayedElements = this.rawElements.map((el) => {
|
|
251
|
+
const raw = isHtmlElement(el) ? el.innerText : el.textContent;
|
|
252
|
+
const replacement = this.replacements.find((r) => raw === null || raw === void 0 ? void 0 : raw.includes(createResultUri(r)));
|
|
253
|
+
if (raw != null && replacement != null) {
|
|
254
|
+
const replacementElement = this.createReplacedElement(raw, replacement);
|
|
255
|
+
return replacementElement;
|
|
256
|
+
}
|
|
257
|
+
return el;
|
|
258
|
+
});
|
|
259
|
+
this.displayedElements.forEach((el) => {
|
|
260
|
+
var _a;
|
|
261
|
+
(_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.appendChild(typeof el === 'string' ? createTextNode(el) : el);
|
|
262
|
+
});
|
|
263
|
+
if (this.lastReplacedSpace != null) {
|
|
264
|
+
this.moveCursorToNodeEnd(this.lastReplacedSpace);
|
|
265
|
+
}
|
|
266
|
+
this.inputChanged.emit(this.getContentAsString(this.contentEl));
|
|
267
|
+
}
|
|
240
268
|
}
|
|
241
269
|
render() {
|
|
242
270
|
var _a;
|
|
@@ -245,11 +273,88 @@ export class SearchBar {
|
|
|
245
273
|
filled: this.variant === 'filled',
|
|
246
274
|
underlined: this.variant === 'underlined',
|
|
247
275
|
blank: this.variant === 'blank',
|
|
276
|
+
disabled: this.disabled,
|
|
248
277
|
});
|
|
249
|
-
return (h(Host, null, h("div", { class: classes }, h("span", { class: "content-input",
|
|
278
|
+
return (h(Host, null, h("div", { class: classes }, h("span", { class: "content-input", role: "textbox", contentEditable: "true", "aria-multiline": "true", "data-placeholder": this.placeholder, ref: (el) => (this.contentEl = el), onKeyDown: this.handleKeyDown, onKeyUp: this.handleKeyUp, onClick: this.handleCursorPositionUpdate, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur })), h("vertex-result-list", { position: this.cursorPosition, placement: this.placement, open: this.hasTriggered &&
|
|
250
279
|
this.resultItems != null &&
|
|
251
|
-
this.resultItems.length > 0 &&
|
|
252
|
-
|
|
280
|
+
this.resultItems.length > 0, items: (_a = this.resultItems) !== null && _a !== void 0 ? _a : [], onEnterPressed: this.handleResultClick, onResultClick: this.handleResultClick }, h("slot", { name: "results" })), h("slot", { name: "replaced" })));
|
|
281
|
+
}
|
|
282
|
+
handleKeyDown(event) {
|
|
283
|
+
if (this.hasTriggered && this.breakCharacters.includes(event.key)) {
|
|
284
|
+
this.hasTriggered = false;
|
|
285
|
+
this.triggeredRange = undefined;
|
|
286
|
+
this.triggeredElement = undefined;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
handleKeyUp(event) {
|
|
290
|
+
this.handleCursorPositionUpdate();
|
|
291
|
+
this.cursorPosition = this.getCursorPosition();
|
|
292
|
+
}
|
|
293
|
+
async handleInput() {
|
|
294
|
+
this.inputChanged.emit(this.getContentAsString(this.contentEl));
|
|
295
|
+
}
|
|
296
|
+
handleClick() {
|
|
297
|
+
this.handleCursorPositionUpdate();
|
|
298
|
+
}
|
|
299
|
+
handleWindowClick(event) {
|
|
300
|
+
if (isHtmlElement(event.target) &&
|
|
301
|
+
event.target.getAttribute('data-replaced') === 'true' &&
|
|
302
|
+
event.target.nextSibling != null) {
|
|
303
|
+
this.moveCursorToNodeEnd(event.target.nextSibling, true);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
handleFocus(event) {
|
|
307
|
+
this.inputFocus.emit(event);
|
|
308
|
+
}
|
|
309
|
+
handleBlur(event) {
|
|
310
|
+
this.hasTriggered = false;
|
|
311
|
+
this.inputBlur.emit(event);
|
|
312
|
+
}
|
|
313
|
+
handleResultClick(event) {
|
|
314
|
+
var _a;
|
|
315
|
+
const triggeredRange = this.triggeredRange;
|
|
316
|
+
const triggeredElement = this.triggeredElement;
|
|
317
|
+
const value = isHtmlElement(triggeredElement)
|
|
318
|
+
? triggeredElement.innerText
|
|
319
|
+
: triggeredElement === null || triggeredElement === void 0 ? void 0 : triggeredElement.textContent;
|
|
320
|
+
if (this.contentEl != null &&
|
|
321
|
+
triggeredRange != null &&
|
|
322
|
+
triggeredElement != null &&
|
|
323
|
+
value != null) {
|
|
324
|
+
const triggeredValue = (_a = this.readTriggerValue(value, triggeredRange.startOffset)) !== null && _a !== void 0 ? _a : '';
|
|
325
|
+
const split = value.split(triggeredValue);
|
|
326
|
+
const before = split[0];
|
|
327
|
+
const after = split[1];
|
|
328
|
+
const replacement = createSearchResultReplacement(event.detail, before, after);
|
|
329
|
+
this.lastReplacedSpace = replacement.afterSpace;
|
|
330
|
+
this.rawElements = Array.from(this.contentEl.childNodes).reduce((re, e) => {
|
|
331
|
+
return [
|
|
332
|
+
...re,
|
|
333
|
+
...this.attemptReplaceElement(e, triggeredElement, replacement),
|
|
334
|
+
];
|
|
335
|
+
}, []);
|
|
336
|
+
this.hasTriggered = false;
|
|
337
|
+
this.resultReplaced.emit(event.detail);
|
|
338
|
+
this.replacements = [
|
|
339
|
+
...this.replacements.filter((r) => r.id !== event.detail.id),
|
|
340
|
+
event.detail,
|
|
341
|
+
];
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
getCursorPosition() {
|
|
345
|
+
var _a;
|
|
346
|
+
const selection = getWindowSelection();
|
|
347
|
+
if (selection != null && selection.rangeCount > 0) {
|
|
348
|
+
const cursorBounds = selection.getRangeAt(0).getBoundingClientRect();
|
|
349
|
+
const contentBounds = (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
350
|
+
const cursorBottom = cursorBounds.bottom || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.bottom) || 0;
|
|
351
|
+
const cursorTop = cursorBounds.top || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.top) || 0;
|
|
352
|
+
return {
|
|
353
|
+
x: cursorBounds.left || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.left) || 0,
|
|
354
|
+
y: this.placement.includes('top') ? cursorTop : cursorBottom,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
throw new Error('Unable to retrieve window selection.');
|
|
253
358
|
}
|
|
254
359
|
static get is() { return "vertex-search-bar"; }
|
|
255
360
|
static get encapsulation() { return "scoped"; }
|
|
@@ -281,64 +386,47 @@ export class SearchBar {
|
|
|
281
386
|
"optional": false,
|
|
282
387
|
"docs": {
|
|
283
388
|
"tags": [],
|
|
284
|
-
"text": ""
|
|
389
|
+
"text": "The search bar variant to display.\n\nPossible options are:\n- 'standard' (default)\n- 'filled'\n- 'underlined'\n- 'blank"
|
|
285
390
|
},
|
|
286
391
|
"attribute": "variant",
|
|
287
392
|
"reflect": false,
|
|
288
393
|
"defaultValue": "'standard'"
|
|
289
394
|
},
|
|
290
|
-
"
|
|
291
|
-
"type": "
|
|
395
|
+
"disabled": {
|
|
396
|
+
"type": "boolean",
|
|
292
397
|
"mutable": false,
|
|
293
398
|
"complexType": {
|
|
294
|
-
"original": "
|
|
295
|
-
"resolved": "
|
|
296
|
-
"references": {
|
|
297
|
-
"Result": {
|
|
298
|
-
"location": "import",
|
|
299
|
-
"path": "../result-list/result-list"
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
"required": false,
|
|
304
|
-
"optional": true,
|
|
305
|
-
"docs": {
|
|
306
|
-
"tags": [],
|
|
307
|
-
"text": ""
|
|
308
|
-
}
|
|
309
|
-
},
|
|
310
|
-
"triggerCharacters": {
|
|
311
|
-
"type": "unknown",
|
|
312
|
-
"mutable": false,
|
|
313
|
-
"complexType": {
|
|
314
|
-
"original": "string[]",
|
|
315
|
-
"resolved": "string[]",
|
|
399
|
+
"original": "boolean",
|
|
400
|
+
"resolved": "boolean",
|
|
316
401
|
"references": {}
|
|
317
402
|
},
|
|
318
403
|
"required": false,
|
|
319
404
|
"optional": false,
|
|
320
405
|
"docs": {
|
|
321
406
|
"tags": [],
|
|
322
|
-
"text": ""
|
|
407
|
+
"text": "Whether this search bar is disabled."
|
|
323
408
|
},
|
|
324
|
-
"
|
|
409
|
+
"attribute": "disabled",
|
|
410
|
+
"reflect": false,
|
|
411
|
+
"defaultValue": "false"
|
|
325
412
|
},
|
|
326
413
|
"triggerCharacter": {
|
|
327
414
|
"type": "string",
|
|
328
415
|
"mutable": false,
|
|
329
416
|
"complexType": {
|
|
330
417
|
"original": "string",
|
|
331
|
-
"resolved": "string
|
|
418
|
+
"resolved": "string",
|
|
332
419
|
"references": {}
|
|
333
420
|
},
|
|
334
421
|
"required": false,
|
|
335
|
-
"optional":
|
|
422
|
+
"optional": false,
|
|
336
423
|
"docs": {
|
|
337
424
|
"tags": [],
|
|
338
|
-
"text": ""
|
|
425
|
+
"text": "The character indicating that we should trigger a search.\n\nWhen this character is encountered, the text following it\n(omitting `breakCharacters`) will be emitted as a `searchChanged`\nevent."
|
|
339
426
|
},
|
|
340
427
|
"attribute": "trigger-character",
|
|
341
|
-
"reflect": false
|
|
428
|
+
"reflect": false,
|
|
429
|
+
"defaultValue": "'@'"
|
|
342
430
|
},
|
|
343
431
|
"breakCharacters": {
|
|
344
432
|
"type": "unknown",
|
|
@@ -352,29 +440,57 @@ export class SearchBar {
|
|
|
352
440
|
"optional": false,
|
|
353
441
|
"docs": {
|
|
354
442
|
"tags": [],
|
|
355
|
-
"text": ""
|
|
443
|
+
"text": "Characters that should trigger a \"break\" of the search. If\na value in this list is encountered when trying to parse back\nto the `triggerCharacter`, this will hide the result list."
|
|
356
444
|
},
|
|
357
|
-
"defaultValue": "[' ']"
|
|
445
|
+
"defaultValue": "[' ', '\\n']"
|
|
358
446
|
},
|
|
359
|
-
"
|
|
360
|
-
"type": "
|
|
447
|
+
"resultItems": {
|
|
448
|
+
"type": "unknown",
|
|
361
449
|
"mutable": false,
|
|
362
450
|
"complexType": {
|
|
363
|
-
"original": "
|
|
364
|
-
"resolved": "
|
|
365
|
-
"references": {
|
|
451
|
+
"original": "Result[]",
|
|
452
|
+
"resolved": "Result[] | undefined",
|
|
453
|
+
"references": {
|
|
454
|
+
"Result": {
|
|
455
|
+
"location": "import",
|
|
456
|
+
"path": "../result-list/types"
|
|
457
|
+
}
|
|
458
|
+
}
|
|
366
459
|
},
|
|
367
460
|
"required": false,
|
|
368
|
-
"optional":
|
|
461
|
+
"optional": true,
|
|
369
462
|
"docs": {
|
|
370
463
|
"tags": [],
|
|
371
|
-
"text": ""
|
|
464
|
+
"text": "The items to display in this search bar's `<vertex-result-list>`.\n\nThis can be used alongside the `searchChanged` event to query for\nresults to display."
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
"placement": {
|
|
468
|
+
"type": "string",
|
|
469
|
+
"mutable": false,
|
|
470
|
+
"complexType": {
|
|
471
|
+
"original": "PopoverPlacement",
|
|
472
|
+
"resolved": "\"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
|
|
473
|
+
"references": {
|
|
474
|
+
"PopoverPlacement": {
|
|
475
|
+
"location": "import",
|
|
476
|
+
"path": "../popover/popover"
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
"required": false,
|
|
481
|
+
"optional": false,
|
|
482
|
+
"docs": {
|
|
483
|
+
"tags": [{
|
|
484
|
+
"name": "see",
|
|
485
|
+
"text": " (PopoverPlacement)"
|
|
486
|
+
}],
|
|
487
|
+
"text": "The placement of the result list for this search bar.\n\nCorresponds to the value for the underlying <vertex-popover>\nplacement value."
|
|
372
488
|
},
|
|
373
|
-
"attribute": "
|
|
489
|
+
"attribute": "placement",
|
|
374
490
|
"reflect": false,
|
|
375
|
-
"defaultValue": "
|
|
491
|
+
"defaultValue": "'bottom-start'"
|
|
376
492
|
},
|
|
377
|
-
"
|
|
493
|
+
"value": {
|
|
378
494
|
"type": "string",
|
|
379
495
|
"mutable": false,
|
|
380
496
|
"complexType": {
|
|
@@ -386,21 +502,38 @@ export class SearchBar {
|
|
|
386
502
|
"optional": true,
|
|
387
503
|
"docs": {
|
|
388
504
|
"tags": [],
|
|
389
|
-
"text": "
|
|
505
|
+
"text": "The initial value of this search bar. This will be used in\ncombination with the value of `replacements` to display existing\nreplaced values."
|
|
390
506
|
},
|
|
391
|
-
"attribute": "
|
|
507
|
+
"attribute": "value",
|
|
392
508
|
"reflect": false
|
|
393
509
|
},
|
|
394
|
-
"
|
|
510
|
+
"placeholder": {
|
|
395
511
|
"type": "string",
|
|
396
512
|
"mutable": false,
|
|
397
513
|
"complexType": {
|
|
398
|
-
"original": "
|
|
399
|
-
"resolved": "
|
|
514
|
+
"original": "string",
|
|
515
|
+
"resolved": "string | undefined",
|
|
516
|
+
"references": {}
|
|
517
|
+
},
|
|
518
|
+
"required": false,
|
|
519
|
+
"optional": true,
|
|
520
|
+
"docs": {
|
|
521
|
+
"tags": [],
|
|
522
|
+
"text": "A placeholder to display when no text has been entered."
|
|
523
|
+
},
|
|
524
|
+
"attribute": "placeholder",
|
|
525
|
+
"reflect": false
|
|
526
|
+
},
|
|
527
|
+
"replacements": {
|
|
528
|
+
"type": "unknown",
|
|
529
|
+
"mutable": true,
|
|
530
|
+
"complexType": {
|
|
531
|
+
"original": "Result[]",
|
|
532
|
+
"resolved": "Result[]",
|
|
400
533
|
"references": {
|
|
401
|
-
"
|
|
534
|
+
"Result": {
|
|
402
535
|
"location": "import",
|
|
403
|
-
"path": "../
|
|
536
|
+
"path": "../result-list/types"
|
|
404
537
|
}
|
|
405
538
|
}
|
|
406
539
|
},
|
|
@@ -408,32 +541,47 @@ export class SearchBar {
|
|
|
408
541
|
"optional": false,
|
|
409
542
|
"docs": {
|
|
410
543
|
"tags": [],
|
|
411
|
-
"text": ""
|
|
544
|
+
"text": "Replaced result values. This will be used in combination with the\nvalue of `value` to display existing replaced values.\n\nThis value will be automatically updated as `Result`s are clicked\nwithin this search bar's `<vertex-result-list>`."
|
|
412
545
|
},
|
|
413
|
-
"
|
|
546
|
+
"defaultValue": "[]"
|
|
547
|
+
},
|
|
548
|
+
"replacementUriType": {
|
|
549
|
+
"type": "string",
|
|
550
|
+
"mutable": false,
|
|
551
|
+
"complexType": {
|
|
552
|
+
"original": "string",
|
|
553
|
+
"resolved": "string",
|
|
554
|
+
"references": {}
|
|
555
|
+
},
|
|
556
|
+
"required": false,
|
|
557
|
+
"optional": false,
|
|
558
|
+
"docs": {
|
|
559
|
+
"tags": [],
|
|
560
|
+
"text": "The URI type of the values to replace. When `replacements` are\nevaluated, this value will be used as the scheme portion of the\nURI to detect matches.\n\nDefaults to `user`, and will match URIs composed with the `user`\nscheme and a UUID. E.g.\n`user:00000000-0000-0000-0000-000000000000`"
|
|
561
|
+
},
|
|
562
|
+
"attribute": "replacement-uri-type",
|
|
414
563
|
"reflect": false,
|
|
415
|
-
"defaultValue": "'
|
|
564
|
+
"defaultValue": "'user'"
|
|
416
565
|
}
|
|
417
566
|
};
|
|
418
567
|
}
|
|
419
568
|
static get states() {
|
|
420
569
|
return {
|
|
421
570
|
"cursorPosition": {},
|
|
422
|
-
"
|
|
423
|
-
"
|
|
424
|
-
"triggerRange": {}
|
|
571
|
+
"displayedElements": {},
|
|
572
|
+
"hasTriggered": {}
|
|
425
573
|
};
|
|
426
574
|
}
|
|
427
575
|
static get events() {
|
|
428
576
|
return [{
|
|
429
|
-
"method": "
|
|
430
|
-
"name": "
|
|
577
|
+
"method": "searchChanged",
|
|
578
|
+
"name": "searchChanged",
|
|
431
579
|
"bubbles": true,
|
|
432
580
|
"cancelable": true,
|
|
433
581
|
"composed": true,
|
|
434
582
|
"docs": {
|
|
435
583
|
"tags": [],
|
|
436
|
-
"text": ""
|
|
584
|
+
"text": "Emitted when the value of the current search triggered by\nthe specified `triggerCharacter` has changed."
|
|
437
585
|
},
|
|
438
586
|
"complexType": {
|
|
439
587
|
"original": "string",
|
|
@@ -441,48 +589,49 @@ export class SearchBar {
|
|
|
441
589
|
"references": {}
|
|
442
590
|
}
|
|
443
591
|
}, {
|
|
444
|
-
"method": "
|
|
445
|
-
"name": "
|
|
592
|
+
"method": "inputChanged",
|
|
593
|
+
"name": "inputChanged",
|
|
446
594
|
"bubbles": true,
|
|
447
595
|
"cancelable": true,
|
|
448
596
|
"composed": true,
|
|
449
597
|
"docs": {
|
|
450
598
|
"tags": [],
|
|
451
|
-
"text": "Emitted when the value has changed."
|
|
599
|
+
"text": "Emitted when the value of the input has changed."
|
|
452
600
|
},
|
|
453
601
|
"complexType": {
|
|
454
|
-
"original": "
|
|
455
|
-
"resolved": "
|
|
602
|
+
"original": "string",
|
|
603
|
+
"resolved": "string",
|
|
456
604
|
"references": {}
|
|
457
605
|
}
|
|
458
606
|
}, {
|
|
459
|
-
"method": "
|
|
460
|
-
"name": "
|
|
607
|
+
"method": "resultReplaced",
|
|
608
|
+
"name": "resultReplaced",
|
|
461
609
|
"bubbles": true,
|
|
462
610
|
"cancelable": true,
|
|
463
611
|
"composed": true,
|
|
464
612
|
"docs": {
|
|
465
613
|
"tags": [],
|
|
466
|
-
"text": "Emitted when
|
|
614
|
+
"text": "Emitted when a result has been selected to replace the trigger text.\n\nIncludes the ID of the `Result` selected."
|
|
467
615
|
},
|
|
468
616
|
"complexType": {
|
|
469
|
-
"original": "
|
|
470
|
-
"resolved": "
|
|
617
|
+
"original": "Result",
|
|
618
|
+
"resolved": "{ id: string; type: string; } & Record<string, unknown>",
|
|
471
619
|
"references": {
|
|
472
|
-
"
|
|
473
|
-
"location": "
|
|
620
|
+
"Result": {
|
|
621
|
+
"location": "import",
|
|
622
|
+
"path": "../result-list/types"
|
|
474
623
|
}
|
|
475
624
|
}
|
|
476
625
|
}
|
|
477
626
|
}, {
|
|
478
|
-
"method": "
|
|
479
|
-
"name": "
|
|
627
|
+
"method": "inputFocus",
|
|
628
|
+
"name": "inputFocus",
|
|
480
629
|
"bubbles": true,
|
|
481
630
|
"cancelable": true,
|
|
482
631
|
"composed": true,
|
|
483
632
|
"docs": {
|
|
484
633
|
"tags": [],
|
|
485
|
-
"text": "Emitted when input
|
|
634
|
+
"text": "Emitted when the input is focused."
|
|
486
635
|
},
|
|
487
636
|
"complexType": {
|
|
488
637
|
"original": "FocusEvent",
|
|
@@ -494,74 +643,34 @@ export class SearchBar {
|
|
|
494
643
|
}
|
|
495
644
|
}
|
|
496
645
|
}, {
|
|
497
|
-
"method": "
|
|
498
|
-
"name": "
|
|
646
|
+
"method": "inputBlur",
|
|
647
|
+
"name": "inputBlur",
|
|
499
648
|
"bubbles": true,
|
|
500
649
|
"cancelable": true,
|
|
501
650
|
"composed": true,
|
|
502
651
|
"docs": {
|
|
503
652
|
"tags": [],
|
|
504
|
-
"text": "Emitted when
|
|
653
|
+
"text": "Emitted when the input is blurred."
|
|
505
654
|
},
|
|
506
655
|
"complexType": {
|
|
507
|
-
"original": "
|
|
508
|
-
"resolved": "
|
|
656
|
+
"original": "FocusEvent",
|
|
657
|
+
"resolved": "FocusEvent",
|
|
509
658
|
"references": {
|
|
510
|
-
"
|
|
511
|
-
"location": "
|
|
512
|
-
"path": "../result-list/result-list"
|
|
659
|
+
"FocusEvent": {
|
|
660
|
+
"location": "global"
|
|
513
661
|
}
|
|
514
662
|
}
|
|
515
663
|
}
|
|
516
664
|
}];
|
|
517
665
|
}
|
|
518
|
-
static get methods() {
|
|
519
|
-
return {
|
|
520
|
-
"replaceTriggeredValue": {
|
|
521
|
-
"complexType": {
|
|
522
|
-
"signature": "(data: Record<string, unknown>) => Promise<void>",
|
|
523
|
-
"parameters": [{
|
|
524
|
-
"tags": [],
|
|
525
|
-
"text": ""
|
|
526
|
-
}],
|
|
527
|
-
"references": {
|
|
528
|
-
"Promise": {
|
|
529
|
-
"location": "global"
|
|
530
|
-
},
|
|
531
|
-
"Record": {
|
|
532
|
-
"location": "global"
|
|
533
|
-
}
|
|
534
|
-
},
|
|
535
|
-
"return": "Promise<void>"
|
|
536
|
-
},
|
|
537
|
-
"docs": {
|
|
538
|
-
"text": "",
|
|
539
|
-
"tags": []
|
|
540
|
-
}
|
|
541
|
-
},
|
|
542
|
-
"getEditableContent": {
|
|
543
|
-
"complexType": {
|
|
544
|
-
"signature": "() => Promise<NodeListOf<ChildNode> | undefined>",
|
|
545
|
-
"parameters": [],
|
|
546
|
-
"references": {
|
|
547
|
-
"Promise": {
|
|
548
|
-
"location": "global"
|
|
549
|
-
},
|
|
550
|
-
"NodeListOf": {
|
|
551
|
-
"location": "global"
|
|
552
|
-
},
|
|
553
|
-
"ChildNode": {
|
|
554
|
-
"location": "global"
|
|
555
|
-
}
|
|
556
|
-
},
|
|
557
|
-
"return": "Promise<NodeListOf<ChildNode> | undefined>"
|
|
558
|
-
},
|
|
559
|
-
"docs": {
|
|
560
|
-
"text": "",
|
|
561
|
-
"tags": []
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
666
|
static get elementRef() { return "hostEl"; }
|
|
667
|
+
static get watchers() {
|
|
668
|
+
return [{
|
|
669
|
+
"propName": "value",
|
|
670
|
+
"methodName": "replaceContent"
|
|
671
|
+
}, {
|
|
672
|
+
"propName": "replacements",
|
|
673
|
+
"methodName": "updateContent"
|
|
674
|
+
}];
|
|
675
|
+
}
|
|
567
676
|
}
|