@vertexvis/ui 0.1.0-canary.7 → 0.1.0-canary.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components.cjs.js +1 -1
- package/dist/cjs/{icon-460fd0f5.js → icon-21deee4d.js} +1 -1
- package/dist/cjs/{icon-button-786427d6.js → icon-button-b7ed3b48.js} +1 -1
- package/dist/cjs/{icon-helper-ba408f49.js → icon-helper-31ee6ce0.js} +5 -0
- package/dist/cjs/index.cjs.js +5 -5
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{result-list-1e592c3c.js → result-list-241ffe8d.js} +46 -2
- package/dist/cjs/search-bar-91cbcd07.js +421 -0
- package/dist/cjs/vertex-icon-button.cjs.entry.js +2 -2
- package/dist/cjs/vertex-icon.cjs.entry.js +2 -2
- package/dist/cjs/vertex-result-list.cjs.entry.js +1 -1
- package/dist/cjs/vertex-search-bar.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/icon/icon-helper.js +3 -0
- package/dist/collection/components/icon/icon.js +1 -1
- package/dist/collection/components/icon/icons/compare.js +2 -0
- package/dist/collection/components/icon-button/icon-button.js +1 -1
- package/dist/collection/components/result-list/result-list.js +52 -5
- package/dist/collection/components/result-list/types.js +1 -0
- package/dist/collection/components/search-bar/dom.js +12 -0
- package/dist/collection/components/search-bar/lib.js +35 -15
- package/dist/collection/components/search-bar/search-bar.css +0 -16
- package/dist/collection/components/search-bar/search-bar.js +380 -324
- package/dist/collection/types/icon.js +1 -0
- package/dist/collection/util/templates/element-pool.js +19 -1
- package/dist/components/components.esm.js +1 -1
- package/dist/components/index.esm.js +1 -1
- package/dist/components/p-1c7dc57e.js +1 -0
- package/dist/components/p-646ac7e7.entry.js +1 -0
- package/dist/components/p-6b862967.js +1 -0
- package/dist/components/p-cfe369bf.entry.js +1 -0
- package/dist/components/{p-103249b4.js → p-daabd39c.js} +1 -1
- package/dist/components/p-db34f10c.js +1 -0
- package/dist/components/p-ee496965.entry.js +1 -0
- package/dist/components/p-f03fe304.entry.js +1 -0
- package/dist/components/{p-ca52a423.js → p-fe0f0f64.js} +1 -1
- package/dist/esm/components.js +1 -1
- package/dist/esm/{icon-d37150b4.js → icon-8b8d7617.js} +1 -1
- package/dist/esm/{icon-button-aad3c0e7.js → icon-button-192f2555.js} +1 -1
- package/dist/esm/{icon-helper-83f10f73.js → icon-helper-a6be8de9.js} +5 -0
- package/dist/esm/index.js +5 -5
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{result-list-36cfb08a.js → result-list-16c6afbd.js} +46 -2
- package/dist/esm/search-bar-f12a3599.js +419 -0
- package/dist/esm/vertex-icon-button.entry.js +2 -2
- package/dist/esm/vertex-icon.entry.js +2 -2
- package/dist/esm/vertex-result-list.entry.js +1 -1
- package/dist/esm/vertex-search-bar.entry.js +1 -1
- package/dist/types/components/icon/icons/compare.d.ts +3 -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 +3 -0
- package/dist/types/components/search-bar/lib.d.ts +24 -6
- package/dist/types/components/search-bar/search-bar.d.ts +124 -42
- package/dist/types/components.d.ts +81 -20
- package/dist/types/types/icon.d.ts +1 -0
- package/dist/types/util/templates/element-pool.d.ts +10 -1
- package/package.json +4 -3
- package/dist/cjs/search-bar-bb40cfa7.js +0 -290
- package/dist/components/p-03dbb28c.js +0 -1
- package/dist/components/p-19318fee.entry.js +0 -1
- package/dist/components/p-4224c2ad.js +0 -1
- package/dist/components/p-52739247.js +0 -1
- package/dist/components/p-7dba2574.entry.js +0 -1
- package/dist/components/p-ae6a3c46.entry.js +0 -1
- package/dist/components/p-f71fc166.entry.js +0 -1
- package/dist/esm/search-bar-59cc151d.js +0 -288
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index-6a92256c.js');
|
|
4
|
+
const index$1 = require('./index-e1b40fa6.js');
|
|
5
|
+
const templates = require('./templates-e7b3ffbb.js');
|
|
6
|
+
|
|
7
|
+
// do not edit .js files directly - edit src/index.jst
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var fastDeepEqual = function equal(a, b) {
|
|
12
|
+
if (a === b) return true;
|
|
13
|
+
|
|
14
|
+
if (a && b && typeof a == 'object' && typeof b == 'object') {
|
|
15
|
+
if (a.constructor !== b.constructor) return false;
|
|
16
|
+
|
|
17
|
+
var length, i, keys;
|
|
18
|
+
if (Array.isArray(a)) {
|
|
19
|
+
length = a.length;
|
|
20
|
+
if (length != b.length) return false;
|
|
21
|
+
for (i = length; i-- !== 0;)
|
|
22
|
+
if (!equal(a[i], b[i])) return false;
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
29
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
30
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
31
|
+
|
|
32
|
+
keys = Object.keys(a);
|
|
33
|
+
length = keys.length;
|
|
34
|
+
if (length !== Object.keys(b).length) return false;
|
|
35
|
+
|
|
36
|
+
for (i = length; i-- !== 0;)
|
|
37
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
38
|
+
|
|
39
|
+
for (i = length; i-- !== 0;) {
|
|
40
|
+
var key = keys[i];
|
|
41
|
+
|
|
42
|
+
if (!equal(a[key], b[key])) return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// true if both NaN, false otherwise
|
|
49
|
+
return a!==a && b!==b;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const getWindowSelection = () => {
|
|
53
|
+
if (typeof window !== 'undefined') {
|
|
54
|
+
return window.getSelection();
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
};
|
|
58
|
+
const createDocumentRange = () => {
|
|
59
|
+
return document.createRange();
|
|
60
|
+
};
|
|
61
|
+
const createTextNode = (text) => {
|
|
62
|
+
return new Text(text);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const createResultUri = (result) => {
|
|
66
|
+
return `${result.type}:${result.id}`;
|
|
67
|
+
};
|
|
68
|
+
const createSearchResultReplacement = (result, before, after) => {
|
|
69
|
+
const urn = createResultUri(result);
|
|
70
|
+
return {
|
|
71
|
+
before: createTextNode(before),
|
|
72
|
+
beforeSpace: createTextNode(createHairSpace()),
|
|
73
|
+
result: createTextNode(urn),
|
|
74
|
+
afterSpace: after != null ? createTextNode(createNoBreakSpace()) : undefined,
|
|
75
|
+
after: after != null ? createTextNode(after) : undefined,
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
const getNodesForSearchResultReplacement = (replacement) => {
|
|
79
|
+
const keys = Object.keys(replacement);
|
|
80
|
+
return keys
|
|
81
|
+
.map((key) => replacement[key])
|
|
82
|
+
.filter((node) => node != null);
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
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
|
+
*/
|
|
96
|
+
const trimNonstandardSpaces = (text) => {
|
|
97
|
+
return text.replace(/[\u200A]/g, '').replace(/[\u00A0]/g, ' ');
|
|
98
|
+
};
|
|
99
|
+
const createHairSpace = () => {
|
|
100
|
+
return String.fromCharCode(8202);
|
|
101
|
+
};
|
|
102
|
+
const createNoBreakSpace = () => {
|
|
103
|
+
return String.fromCharCode(160);
|
|
104
|
+
};
|
|
105
|
+
|
|
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)}";
|
|
107
|
+
|
|
108
|
+
const SearchBar = class {
|
|
109
|
+
constructor(hostRef) {
|
|
110
|
+
index.registerInstance(this, hostRef);
|
|
111
|
+
this.searchChanged = index.createEvent(this, "searchChanged", 7);
|
|
112
|
+
this.inputChanged = index.createEvent(this, "inputChanged", 7);
|
|
113
|
+
this.resultReplaced = index.createEvent(this, "resultReplaced", 7);
|
|
114
|
+
this.inputFocus = index.createEvent(this, "inputFocus", 7);
|
|
115
|
+
this.inputBlur = index.createEvent(this, "inputBlur", 7);
|
|
116
|
+
this.rawElements = [];
|
|
117
|
+
this.isIdenticalElement = (child, other) => {
|
|
118
|
+
return (child === this.triggeredElement ||
|
|
119
|
+
this.getTextContent(child) === this.getTextContent(other));
|
|
120
|
+
};
|
|
121
|
+
this.getTextContent = (node) => {
|
|
122
|
+
var _a;
|
|
123
|
+
if (node instanceof HTMLElement) {
|
|
124
|
+
return node.innerText;
|
|
125
|
+
}
|
|
126
|
+
return (_a = node.textContent) !== null && _a !== void 0 ? _a : '';
|
|
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
|
+
*/
|
|
143
|
+
this.handleCursorPositionUpdate = () => {
|
|
144
|
+
var _a, _b;
|
|
145
|
+
const windowRange = (_a = getWindowSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0);
|
|
146
|
+
if (windowRange != null) {
|
|
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, ''));
|
|
153
|
+
}
|
|
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;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
this.cursorPosition = this.getCursorPosition();
|
|
166
|
+
};
|
|
167
|
+
this.readTriggerValue = (value, fromIndex) => {
|
|
168
|
+
const adjustedValue = value.replace(String.fromCharCode(160), ' ');
|
|
169
|
+
const beforeSubstr = adjustedValue.substring(0, fromIndex);
|
|
170
|
+
const afterSubstr = adjustedValue.substring(fromIndex);
|
|
171
|
+
const adjustedBeforeSubstr = beforeSubstr.includes(this.triggerCharacter)
|
|
172
|
+
? beforeSubstr.substring(beforeSubstr.lastIndexOf(this.triggerCharacter))
|
|
173
|
+
: '';
|
|
174
|
+
const adjustedAfterSubstr = afterSubstr.substring(0, this.firstIndexOfBreakCharacter(afterSubstr));
|
|
175
|
+
const result = `${adjustedBeforeSubstr}${adjustedAfterSubstr}`;
|
|
176
|
+
return result.includes(this.triggerCharacter) &&
|
|
177
|
+
!this.includesBreakCharacter(result)
|
|
178
|
+
? result
|
|
179
|
+
: undefined;
|
|
180
|
+
};
|
|
181
|
+
this.includesBreakCharacter = (value) => {
|
|
182
|
+
return this.breakCharacters.some((bc) => value.includes(bc));
|
|
183
|
+
};
|
|
184
|
+
this.firstIndexOfBreakCharacter = (value) => {
|
|
185
|
+
const indices = this.breakCharacters
|
|
186
|
+
.map((bc) => value.indexOf(bc))
|
|
187
|
+
.filter((i) => i >= 0);
|
|
188
|
+
return indices.length > 0 ? Math.min(...indices) : value.length;
|
|
189
|
+
};
|
|
190
|
+
this.moveCursorToNodeEnd = (node, collapseToStart = false) => {
|
|
191
|
+
const selection = getWindowSelection();
|
|
192
|
+
if (selection != null) {
|
|
193
|
+
const range = createDocumentRange();
|
|
194
|
+
range.selectNodeContents(node);
|
|
195
|
+
range.collapse(collapseToStart);
|
|
196
|
+
selection.removeAllRanges();
|
|
197
|
+
selection.addRange(range);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
this.getContentAsString = () => {
|
|
201
|
+
if (this.contentEl != null) {
|
|
202
|
+
return trimNonstandardSpaces(Array.from(this.contentEl.childNodes).reduce((res, n) => {
|
|
203
|
+
var _a;
|
|
204
|
+
if (n instanceof HTMLElement &&
|
|
205
|
+
n.getAttribute('data-replaced') === 'true') {
|
|
206
|
+
return `${res}${n.getAttribute('data-original')}`;
|
|
207
|
+
}
|
|
208
|
+
else if (n instanceof HTMLElement) {
|
|
209
|
+
return `${res}${n.innerText}`;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
return `${res}${(_a = n.textContent) !== null && _a !== void 0 ? _a : ''}`;
|
|
213
|
+
}
|
|
214
|
+
}, ''));
|
|
215
|
+
}
|
|
216
|
+
return '';
|
|
217
|
+
};
|
|
218
|
+
this.createReplacedElement = (original, data) => {
|
|
219
|
+
const template = this.hostEl.querySelector('template[slot="replaced"]');
|
|
220
|
+
if (template != null) {
|
|
221
|
+
const instance = templates.generateInstanceFromTemplate(template);
|
|
222
|
+
instance.bindings.bind(data);
|
|
223
|
+
instance.element.id = data.id;
|
|
224
|
+
instance.element.style.display = 'inline-block';
|
|
225
|
+
instance.element.contentEditable = 'false';
|
|
226
|
+
instance.element.tabIndex = -1;
|
|
227
|
+
instance.element.setAttribute('data-replaced', 'true');
|
|
228
|
+
instance.element.setAttribute('data-original', original);
|
|
229
|
+
return instance.element;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
throw new Error('Replaced template not defined.');
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
this.variant = 'standard';
|
|
236
|
+
this.disabled = false;
|
|
237
|
+
this.triggerCharacter = '@';
|
|
238
|
+
this.breakCharacters = [' ', '\n'];
|
|
239
|
+
this.resultItems = undefined;
|
|
240
|
+
this.placement = 'bottom-start';
|
|
241
|
+
this.value = undefined;
|
|
242
|
+
this.placeholder = undefined;
|
|
243
|
+
this.replacements = [];
|
|
244
|
+
this.replacementUriType = 'user';
|
|
245
|
+
this.cursorPosition = undefined;
|
|
246
|
+
this.displayedElements = [];
|
|
247
|
+
this.hasTriggered = false;
|
|
248
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
249
|
+
this.handleKeyUp = this.handleKeyUp.bind(this);
|
|
250
|
+
this.handleResultClick = this.handleResultClick.bind(this);
|
|
251
|
+
this.handleClick = this.handleClick.bind(this);
|
|
252
|
+
this.handleWindowClick = this.handleWindowClick.bind(this);
|
|
253
|
+
this.handleInput = this.handleInput.bind(this);
|
|
254
|
+
this.handleBlur = this.handleBlur.bind(this);
|
|
255
|
+
this.handleFocus = this.handleFocus.bind(this);
|
|
256
|
+
this.handleCursorPositionUpdate =
|
|
257
|
+
this.handleCursorPositionUpdate.bind(this);
|
|
258
|
+
this.updateContent = this.updateContent.bind(this);
|
|
259
|
+
this.replaceContent = this.replaceContent.bind(this);
|
|
260
|
+
}
|
|
261
|
+
componentDidLoad() {
|
|
262
|
+
this.replaceContent(this.value);
|
|
263
|
+
}
|
|
264
|
+
connectedCallback() {
|
|
265
|
+
window.addEventListener('click', this.handleWindowClick);
|
|
266
|
+
}
|
|
267
|
+
disconnectedCallback() {
|
|
268
|
+
window.removeEventListener('click', this.handleWindowClick);
|
|
269
|
+
}
|
|
270
|
+
replaceContent(newValue, oldValue) {
|
|
271
|
+
if (newValue != null && newValue !== oldValue) {
|
|
272
|
+
const pattern = `${this.replacementUriType}:[0-9a-z-]{36}`;
|
|
273
|
+
const matches = newValue.match(new RegExp(pattern, 'g'));
|
|
274
|
+
const replacementsMap = this.replacements.reduce((map, r) => (Object.assign(Object.assign({}, map), { [createResultUri(r)]: r })), {});
|
|
275
|
+
let nextSubstr = newValue;
|
|
276
|
+
const parts = matches != null
|
|
277
|
+
? matches === null || matches === void 0 ? void 0 : matches.reduce((res, m) => {
|
|
278
|
+
if (replacementsMap[m] != null) {
|
|
279
|
+
const urn = createResultUri(replacementsMap[m]);
|
|
280
|
+
const index = nextSubstr.indexOf(urn);
|
|
281
|
+
const before = nextSubstr.substring(0, index);
|
|
282
|
+
const after = nextSubstr.substring(index + urn.length);
|
|
283
|
+
const replacement = createSearchResultReplacement(replacementsMap[m], before);
|
|
284
|
+
nextSubstr = after;
|
|
285
|
+
return [
|
|
286
|
+
...res,
|
|
287
|
+
replacement.before,
|
|
288
|
+
replacement.beforeSpace,
|
|
289
|
+
replacement.result,
|
|
290
|
+
];
|
|
291
|
+
}
|
|
292
|
+
return res;
|
|
293
|
+
}, [])
|
|
294
|
+
: [];
|
|
295
|
+
this.rawElements = [...parts, createTextNode(nextSubstr)];
|
|
296
|
+
this.updateContent(this.replacements);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
updateContent(newValue, oldValue) {
|
|
300
|
+
if (this.contentEl != null && !fastDeepEqual(newValue, oldValue)) {
|
|
301
|
+
this.contentEl.innerHTML = '';
|
|
302
|
+
this.displayedElements = this.rawElements.map((el) => {
|
|
303
|
+
const raw = el instanceof HTMLElement ? el.innerText : el.textContent;
|
|
304
|
+
const replacement = this.replacements.find((r) => raw === null || raw === void 0 ? void 0 : raw.includes(createResultUri(r)));
|
|
305
|
+
if (raw != null && replacement != null) {
|
|
306
|
+
const replacementElement = this.createReplacedElement(raw, replacement);
|
|
307
|
+
return replacementElement;
|
|
308
|
+
}
|
|
309
|
+
return el;
|
|
310
|
+
});
|
|
311
|
+
this.displayedElements.forEach((el) => {
|
|
312
|
+
var _a;
|
|
313
|
+
(_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.appendChild(typeof el === 'string' ? createTextNode(el) : el);
|
|
314
|
+
});
|
|
315
|
+
if (this.lastReplacedSpace != null) {
|
|
316
|
+
this.moveCursorToNodeEnd(this.lastReplacedSpace);
|
|
317
|
+
}
|
|
318
|
+
this.inputChanged.emit(this.getContentAsString());
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
render() {
|
|
322
|
+
var _a;
|
|
323
|
+
const classes = index$1.classnames('wrapper', {
|
|
324
|
+
standard: this.variant === 'standard',
|
|
325
|
+
filled: this.variant === 'filled',
|
|
326
|
+
underlined: this.variant === 'underlined',
|
|
327
|
+
blank: this.variant === 'blank',
|
|
328
|
+
disabled: this.disabled,
|
|
329
|
+
});
|
|
330
|
+
return (index.h(index.Host, null, index.h("div", { class: classes }, index.h("span", { class: "content-input", role: "textbox", contentEditable: "true", "aria-multiline": "true", "data-placeholder": this.placeholder, ref: (el) => (this.contentEl = el), onKeyDown: this.handleKeyDown, onKeyUp: this.handleCursorPositionUpdate, onClick: this.handleCursorPositionUpdate, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur })), index.h("vertex-result-list", { position: this.cursorPosition, placement: this.placement, open: this.hasTriggered &&
|
|
331
|
+
this.resultItems != null &&
|
|
332
|
+
this.resultItems.length > 0, items: (_a = this.resultItems) !== null && _a !== void 0 ? _a : [], onEnterPressed: this.handleResultClick, onResultClick: this.handleResultClick }, index.h("slot", { name: "results" })), index.h("slot", { name: "replaced" })));
|
|
333
|
+
}
|
|
334
|
+
handleKeyDown(event) {
|
|
335
|
+
if (this.hasTriggered && this.breakCharacters.includes(event.key)) {
|
|
336
|
+
this.hasTriggered = false;
|
|
337
|
+
this.triggeredRange = undefined;
|
|
338
|
+
this.triggeredElement = undefined;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
handleKeyUp(event) {
|
|
342
|
+
this.handleCursorPositionUpdate();
|
|
343
|
+
this.cursorPosition = this.getCursorPosition();
|
|
344
|
+
}
|
|
345
|
+
async handleInput() {
|
|
346
|
+
this.inputChanged.emit(this.getContentAsString());
|
|
347
|
+
}
|
|
348
|
+
handleClick() {
|
|
349
|
+
this.handleCursorPositionUpdate();
|
|
350
|
+
}
|
|
351
|
+
handleWindowClick(event) {
|
|
352
|
+
if (event.target instanceof HTMLElement &&
|
|
353
|
+
event.target.getAttribute('data-replaced') === 'true' &&
|
|
354
|
+
event.target.nextSibling != null) {
|
|
355
|
+
this.moveCursorToNodeEnd(event.target.nextSibling, true);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
handleFocus(event) {
|
|
359
|
+
this.inputFocus.emit(event);
|
|
360
|
+
}
|
|
361
|
+
handleBlur(event) {
|
|
362
|
+
this.hasTriggered = false;
|
|
363
|
+
this.inputBlur.emit(event);
|
|
364
|
+
}
|
|
365
|
+
handleResultClick(event) {
|
|
366
|
+
var _a;
|
|
367
|
+
const triggeredRange = this.triggeredRange;
|
|
368
|
+
const triggeredElement = this.triggeredElement;
|
|
369
|
+
const value = triggeredElement instanceof HTMLElement
|
|
370
|
+
? triggeredElement.innerText
|
|
371
|
+
: triggeredElement === null || triggeredElement === void 0 ? void 0 : triggeredElement.textContent;
|
|
372
|
+
if (this.contentEl != null &&
|
|
373
|
+
triggeredRange != null &&
|
|
374
|
+
triggeredElement != null &&
|
|
375
|
+
value != null) {
|
|
376
|
+
const triggeredValue = (_a = this.readTriggerValue(value, triggeredRange.startOffset)) !== null && _a !== void 0 ? _a : '';
|
|
377
|
+
const split = value.split(triggeredValue);
|
|
378
|
+
const before = split[0];
|
|
379
|
+
const after = split[1];
|
|
380
|
+
const replacement = createSearchResultReplacement(event.detail, before, after);
|
|
381
|
+
this.lastReplacedSpace = replacement.afterSpace;
|
|
382
|
+
this.rawElements = Array.from(this.contentEl.childNodes).reduce((re, e) => {
|
|
383
|
+
if (this.isIdenticalElement(e, triggeredElement)) {
|
|
384
|
+
return [...re, ...getNodesForSearchResultReplacement(replacement)];
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
return [...re, e];
|
|
388
|
+
}
|
|
389
|
+
}, []);
|
|
390
|
+
this.hasTriggered = false;
|
|
391
|
+
this.resultReplaced.emit(event.detail);
|
|
392
|
+
this.replacements = [
|
|
393
|
+
...this.replacements.filter((r) => r.id !== event.detail.id),
|
|
394
|
+
event.detail,
|
|
395
|
+
];
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
getCursorPosition() {
|
|
399
|
+
var _a;
|
|
400
|
+
const selection = getWindowSelection();
|
|
401
|
+
if (selection != null && selection.rangeCount > 0) {
|
|
402
|
+
const cursorBounds = selection.getRangeAt(0).getBoundingClientRect();
|
|
403
|
+
const contentBounds = (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
404
|
+
const cursorBottom = cursorBounds.bottom || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.bottom) || 0;
|
|
405
|
+
const cursorTop = cursorBounds.top || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.top) || 0;
|
|
406
|
+
return {
|
|
407
|
+
x: cursorBounds.left || (contentBounds === null || contentBounds === void 0 ? void 0 : contentBounds.left) || 0,
|
|
408
|
+
y: this.placement.includes('top') ? cursorTop : cursorBottom,
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
throw new Error('Unable to retrieve window selection.');
|
|
412
|
+
}
|
|
413
|
+
get hostEl() { return index.getElement(this); }
|
|
414
|
+
static get watchers() { return {
|
|
415
|
+
"value": ["replaceContent"],
|
|
416
|
+
"replacements": ["updateContent"]
|
|
417
|
+
}; }
|
|
418
|
+
};
|
|
419
|
+
SearchBar.style = searchBarCss;
|
|
420
|
+
|
|
421
|
+
exports.SearchBar = SearchBar;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const iconButton = require('./icon-button-
|
|
5
|
+
const iconButton = require('./icon-button-b7ed3b48.js');
|
|
6
6
|
require('./index-6a92256c.js');
|
|
7
7
|
require('./index-e1b40fa6.js');
|
|
8
|
-
require('./icon-helper-
|
|
8
|
+
require('./icon-helper-31ee6ce0.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const icon = require('./icon-
|
|
5
|
+
const icon = require('./icon-21deee4d.js');
|
|
6
6
|
require('./index-6a92256c.js');
|
|
7
7
|
require('./index-e1b40fa6.js');
|
|
8
|
-
require('./icon-helper-
|
|
8
|
+
require('./icon-helper-31ee6ce0.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const resultList = require('./result-list-
|
|
5
|
+
const resultList = require('./result-list-241ffe8d.js');
|
|
6
6
|
require('./index-6a92256c.js');
|
|
7
7
|
require('./index-e1b40fa6.js');
|
|
8
8
|
require('./templates-e7b3ffbb.js');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const searchBar = require('./search-bar-
|
|
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
|
],
|
|
@@ -41,6 +41,7 @@ import { CommentFilled } from './icons/comment-filled';
|
|
|
41
41
|
import { CommentReopen } from './icons/comment-reopen';
|
|
42
42
|
import { CommentResolve } from './icons/comment-resolve';
|
|
43
43
|
import { CommentShow } from './icons/comment-show';
|
|
44
|
+
import { Compare } from './icons/compare';
|
|
44
45
|
import { Copy } from './icons/copy';
|
|
45
46
|
import { CrossSection } from './icons/cross-section';
|
|
46
47
|
import { CubeOrthographic } from './icons/cube-orthographic';
|
|
@@ -192,6 +193,8 @@ export function getSvg(name) {
|
|
|
192
193
|
return h(CommentResolve, null);
|
|
193
194
|
case 'comment-show':
|
|
194
195
|
return h(CommentShow, null);
|
|
196
|
+
case 'compare':
|
|
197
|
+
return h(Compare, null);
|
|
195
198
|
case 'copy':
|
|
196
199
|
return h(Copy, null);
|
|
197
200
|
case 'cross-section':
|
|
@@ -33,7 +33,7 @@ export class Icon {
|
|
|
33
33
|
"mutable": false,
|
|
34
34
|
"complexType": {
|
|
35
35
|
"original": "IconName",
|
|
36
|
-
"resolved": "\"help\" | \"open\" | \"info\" | \"copy\" | \"menu\" | \"ellipse\" | \"line\" | \"download\" | \"rotate\" | \"close\" | \"flip\" | \"reset\" | \"resize\" | \"search\" | \"caret-down\" | \"caret-up\" | \"adjustments\" | \"align-to-global\" | \"align-to-part\" | \"align-to-surface\" | \"align-view-to-plane\" | \"annotation\" | \"arrow-filled\" | \"arrow-line-left\" | \"arrow-line-right\" | \"arrow-partial\" | \"arrow-triangle-left\" | \"arrow-triangle-right\" | \"arrow-up-circled\" | \"attachment\" | \"axis-x\" | \"axis-y\" | \"axis-z\" | \"back\" | \"box-cursor\" | \"box-select\" | \"camera\" | \"caret-left\" | \"check\" | \"check-circle\" | \"caret-right\" | \"chevron-down\" | \"chevron-left\" | \"chevron-right\" | \"chevron-up\" | \"circle-outline\" | \"close-circle-fill\" | \"close-circle\" | \"collapse-all\" | \"columns\" | \"comment-add\" | \"comment-filled\" | \"comment-reopen\" | \"comment-resolve\" | \"comment-show\" | \"cross-section\" | \"cube-orthographic\" | \"cube-perspective\" | \"delete\" | \"drag-indicator\" | \"error-circle\" | \"expand-all\" | \"export\" | \"file\" | \"file-pdf\" | \"fit-all\" | \"fit-selected\" | \"folder-plus\" | \"forward\" | \"gear\" | \"invert\" | \"line-dot-left\" | \"line-dot-right\" | \"line-hash-left\" | \"line-hash-right\" | \"locate\" | \"markup\" | \"notification\" | \"open-window\" | \"pan\" | \"pencil\" | \"person-height\" | \"person-run\" | \"person-short\" | \"person-tall\" | \"person-walk\" | \"pin-fill\" | \"pin-line\" | \"pin-text\" | \"pin-text-fill\" | \"plus\" | \"precise-measurement\" | \"rabbit\" | \"ruler\" | \"show-only-nearby\" | \"snapshots\" | \"star\" | \"tape-measure\" | \"teleport-and-align\" | \"teleport-toward\" | \"teleport\" | \"turtle\" | \"version-history\" | \"visibility-hidden\" | \"visibility-partial\" | \"visibility-visible\" | \"zoom\"",
|
|
36
|
+
"resolved": "\"compare\" | \"help\" | \"open\" | \"info\" | \"copy\" | \"menu\" | \"ellipse\" | \"line\" | \"download\" | \"rotate\" | \"close\" | \"flip\" | \"reset\" | \"resize\" | \"search\" | \"caret-down\" | \"caret-up\" | \"adjustments\" | \"align-to-global\" | \"align-to-part\" | \"align-to-surface\" | \"align-view-to-plane\" | \"annotation\" | \"arrow-filled\" | \"arrow-line-left\" | \"arrow-line-right\" | \"arrow-partial\" | \"arrow-triangle-left\" | \"arrow-triangle-right\" | \"arrow-up-circled\" | \"attachment\" | \"axis-x\" | \"axis-y\" | \"axis-z\" | \"back\" | \"box-cursor\" | \"box-select\" | \"camera\" | \"caret-left\" | \"check\" | \"check-circle\" | \"caret-right\" | \"chevron-down\" | \"chevron-left\" | \"chevron-right\" | \"chevron-up\" | \"circle-outline\" | \"close-circle-fill\" | \"close-circle\" | \"collapse-all\" | \"columns\" | \"comment-add\" | \"comment-filled\" | \"comment-reopen\" | \"comment-resolve\" | \"comment-show\" | \"cross-section\" | \"cube-orthographic\" | \"cube-perspective\" | \"delete\" | \"drag-indicator\" | \"error-circle\" | \"expand-all\" | \"export\" | \"file\" | \"file-pdf\" | \"fit-all\" | \"fit-selected\" | \"folder-plus\" | \"forward\" | \"gear\" | \"invert\" | \"line-dot-left\" | \"line-dot-right\" | \"line-hash-left\" | \"line-hash-right\" | \"locate\" | \"markup\" | \"notification\" | \"open-window\" | \"pan\" | \"pencil\" | \"person-height\" | \"person-run\" | \"person-short\" | \"person-tall\" | \"person-walk\" | \"pin-fill\" | \"pin-line\" | \"pin-text\" | \"pin-text-fill\" | \"plus\" | \"precise-measurement\" | \"rabbit\" | \"ruler\" | \"show-only-nearby\" | \"snapshots\" | \"star\" | \"tape-measure\" | \"teleport-and-align\" | \"teleport-toward\" | \"teleport\" | \"turtle\" | \"version-history\" | \"visibility-hidden\" | \"visibility-partial\" | \"visibility-visible\" | \"zoom\"",
|
|
37
37
|
"references": {
|
|
38
38
|
"IconName": {
|
|
39
39
|
"location": "import",
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
export const Compare = () => (h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", "data-testid": "compare" }, h("path", { d: "M13.68 3.34c-.21-.21-.48-.32-.79-.32H8.98v.99h3.56c.11 0 .2.04.29.13.09.09.13.19.13.29v7.56L8.99 6.96V13h3.9c.32 0 .58-.11.79-.32.21-.21.32-.48.32-.79V4.13c0-.32-.11-.58-.32-.79ZM7.48 1c-.28 0-.5.22-.5.5v1.49H3.11c-.32 0-.58.11-.79.32-.21.21-.32.48-.32.79v7.79c0 .32.11.58.32.79.21.21.48.32.79.32h3.87v1.5c0 .28.22.5.5.5s.5-.22.5-.5v-13c0-.28-.22-.5-.5-.5Zm-.49 11h-4l4-5.03V12Z" })));
|
|
@@ -50,7 +50,7 @@ export class IconButton {
|
|
|
50
50
|
"mutable": false,
|
|
51
51
|
"complexType": {
|
|
52
52
|
"original": "IconName",
|
|
53
|
-
"resolved": "\"help\" | \"open\" | \"info\" | \"copy\" | \"menu\" | \"ellipse\" | \"line\" | \"download\" | \"rotate\" | \"close\" | \"flip\" | \"reset\" | \"resize\" | \"search\" | \"caret-down\" | \"caret-up\" | \"adjustments\" | \"align-to-global\" | \"align-to-part\" | \"align-to-surface\" | \"align-view-to-plane\" | \"annotation\" | \"arrow-filled\" | \"arrow-line-left\" | \"arrow-line-right\" | \"arrow-partial\" | \"arrow-triangle-left\" | \"arrow-triangle-right\" | \"arrow-up-circled\" | \"attachment\" | \"axis-x\" | \"axis-y\" | \"axis-z\" | \"back\" | \"box-cursor\" | \"box-select\" | \"camera\" | \"caret-left\" | \"check\" | \"check-circle\" | \"caret-right\" | \"chevron-down\" | \"chevron-left\" | \"chevron-right\" | \"chevron-up\" | \"circle-outline\" | \"close-circle-fill\" | \"close-circle\" | \"collapse-all\" | \"columns\" | \"comment-add\" | \"comment-filled\" | \"comment-reopen\" | \"comment-resolve\" | \"comment-show\" | \"cross-section\" | \"cube-orthographic\" | \"cube-perspective\" | \"delete\" | \"drag-indicator\" | \"error-circle\" | \"expand-all\" | \"export\" | \"file\" | \"file-pdf\" | \"fit-all\" | \"fit-selected\" | \"folder-plus\" | \"forward\" | \"gear\" | \"invert\" | \"line-dot-left\" | \"line-dot-right\" | \"line-hash-left\" | \"line-hash-right\" | \"locate\" | \"markup\" | \"notification\" | \"open-window\" | \"pan\" | \"pencil\" | \"person-height\" | \"person-run\" | \"person-short\" | \"person-tall\" | \"person-walk\" | \"pin-fill\" | \"pin-line\" | \"pin-text\" | \"pin-text-fill\" | \"plus\" | \"precise-measurement\" | \"rabbit\" | \"ruler\" | \"show-only-nearby\" | \"snapshots\" | \"star\" | \"tape-measure\" | \"teleport-and-align\" | \"teleport-toward\" | \"teleport\" | \"turtle\" | \"version-history\" | \"visibility-hidden\" | \"visibility-partial\" | \"visibility-visible\" | \"zoom\"",
|
|
53
|
+
"resolved": "\"compare\" | \"help\" | \"open\" | \"info\" | \"copy\" | \"menu\" | \"ellipse\" | \"line\" | \"download\" | \"rotate\" | \"close\" | \"flip\" | \"reset\" | \"resize\" | \"search\" | \"caret-down\" | \"caret-up\" | \"adjustments\" | \"align-to-global\" | \"align-to-part\" | \"align-to-surface\" | \"align-view-to-plane\" | \"annotation\" | \"arrow-filled\" | \"arrow-line-left\" | \"arrow-line-right\" | \"arrow-partial\" | \"arrow-triangle-left\" | \"arrow-triangle-right\" | \"arrow-up-circled\" | \"attachment\" | \"axis-x\" | \"axis-y\" | \"axis-z\" | \"back\" | \"box-cursor\" | \"box-select\" | \"camera\" | \"caret-left\" | \"check\" | \"check-circle\" | \"caret-right\" | \"chevron-down\" | \"chevron-left\" | \"chevron-right\" | \"chevron-up\" | \"circle-outline\" | \"close-circle-fill\" | \"close-circle\" | \"collapse-all\" | \"columns\" | \"comment-add\" | \"comment-filled\" | \"comment-reopen\" | \"comment-resolve\" | \"comment-show\" | \"cross-section\" | \"cube-orthographic\" | \"cube-perspective\" | \"delete\" | \"drag-indicator\" | \"error-circle\" | \"expand-all\" | \"export\" | \"file\" | \"file-pdf\" | \"fit-all\" | \"fit-selected\" | \"folder-plus\" | \"forward\" | \"gear\" | \"invert\" | \"line-dot-left\" | \"line-dot-right\" | \"line-hash-left\" | \"line-hash-right\" | \"locate\" | \"markup\" | \"notification\" | \"open-window\" | \"pan\" | \"pencil\" | \"person-height\" | \"person-run\" | \"person-short\" | \"person-tall\" | \"person-walk\" | \"pin-fill\" | \"pin-line\" | \"pin-text\" | \"pin-text-fill\" | \"plus\" | \"precise-measurement\" | \"rabbit\" | \"ruler\" | \"show-only-nearby\" | \"snapshots\" | \"star\" | \"tape-measure\" | \"teleport-and-align\" | \"teleport-toward\" | \"teleport\" | \"turtle\" | \"version-history\" | \"visibility-hidden\" | \"visibility-partial\" | \"visibility-visible\" | \"zoom\"",
|
|
54
54
|
"references": {
|
|
55
55
|
"IconName": {
|
|
56
56
|
"location": "import",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { h, Host, } from '@stencil/core';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import { ElementPool } from '../../util/templates/element-pool';
|
|
3
|
+
import { ElementPool, } from '../../util/templates/element-pool';
|
|
4
4
|
import { generateInstanceFromTemplate, } from '../../util/templates/templates';
|
|
5
5
|
import { getResultListHeight, scrollToResult } from './lib';
|
|
6
6
|
export class ResultList {
|
|
@@ -29,7 +29,7 @@ export class ResultList {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
this.createResultPool = () => {
|
|
32
|
-
this.stateMap.resultPool = new ElementPool(this.hostEl, () => this.createResultInstance());
|
|
32
|
+
this.stateMap.resultPool = new ElementPool(this.hostEl, () => this.createResultInstance(), () => this.createResultHandlers());
|
|
33
33
|
};
|
|
34
34
|
this.createResultInstance = () => {
|
|
35
35
|
if (this.stateMap.resultTemplate != null) {
|
|
@@ -41,6 +41,18 @@ export class ResultList {
|
|
|
41
41
|
throw new Error('Result template not defined.');
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
+
this.createResultHandlers = () => {
|
|
45
|
+
return [
|
|
46
|
+
{
|
|
47
|
+
type: 'pointerdown',
|
|
48
|
+
handler: this.handlePointerDown,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'click',
|
|
52
|
+
handler: this.handleResultClick,
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
};
|
|
44
56
|
this.layoutResults = () => {
|
|
45
57
|
var _a, _b, _c, _d;
|
|
46
58
|
const visibleRowCount = this.viewportEndIndex - this.viewportStartIndex + 1;
|
|
@@ -61,6 +73,7 @@ export class ResultList {
|
|
|
61
73
|
el.style.top = `${(this.viewportStartIndex + index) * this.resultHeight}px`;
|
|
62
74
|
el.style.width = '100%';
|
|
63
75
|
el.setAttribute('is-focused', `${this.viewportStartIndex + index === this.lastFocusedIndex}`);
|
|
76
|
+
el.setAttribute('data-result-id', result.id);
|
|
64
77
|
binding.bind(result);
|
|
65
78
|
}
|
|
66
79
|
});
|
|
@@ -103,6 +116,8 @@ export class ResultList {
|
|
|
103
116
|
this.lastStartIndex = 0;
|
|
104
117
|
this.lastFocusedIndex = 0;
|
|
105
118
|
this.stateMap = {};
|
|
119
|
+
this.handleResultClick = this.handleResultClick.bind(this);
|
|
120
|
+
this.handlePointerDown = this.handlePointerDown.bind(this);
|
|
106
121
|
}
|
|
107
122
|
handleResultsChanged(results) {
|
|
108
123
|
if (typeof results === 'string') {
|
|
@@ -148,6 +163,16 @@ export class ResultList {
|
|
|
148
163
|
height: `${this.parsedResults.length * this.resultHeight}px`,
|
|
149
164
|
} }, h("slot", null), h("slot", { name: "result" })))))));
|
|
150
165
|
}
|
|
166
|
+
handlePointerDown(event) {
|
|
167
|
+
event.preventDefault();
|
|
168
|
+
}
|
|
169
|
+
handleResultClick(event) {
|
|
170
|
+
const closestIdElement = event.target.closest('[data-result-id]');
|
|
171
|
+
const result = this.parsedResults.find((r) => r.id === (closestIdElement === null || closestIdElement === void 0 ? void 0 : closestIdElement.getAttribute('data-result-id')));
|
|
172
|
+
if (result != null) {
|
|
173
|
+
this.resultClick.emit(result);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
151
176
|
computeViewportResults() {
|
|
152
177
|
const viewportHeight = this.getListHeight();
|
|
153
178
|
if (viewportHeight != null && this.resultHeight > 0) {
|
|
@@ -188,7 +213,8 @@ export class ResultList {
|
|
|
188
213
|
"resolved": "Result[]",
|
|
189
214
|
"references": {
|
|
190
215
|
"Result": {
|
|
191
|
-
"location": "
|
|
216
|
+
"location": "import",
|
|
217
|
+
"path": "./types"
|
|
192
218
|
}
|
|
193
219
|
}
|
|
194
220
|
},
|
|
@@ -377,10 +403,31 @@ export class ResultList {
|
|
|
377
403
|
},
|
|
378
404
|
"complexType": {
|
|
379
405
|
"original": "Result",
|
|
380
|
-
"resolved": "{
|
|
406
|
+
"resolved": "{ id: string; type: string; } & Record<string, unknown>",
|
|
407
|
+
"references": {
|
|
408
|
+
"Result": {
|
|
409
|
+
"location": "import",
|
|
410
|
+
"path": "./types"
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}, {
|
|
415
|
+
"method": "resultClick",
|
|
416
|
+
"name": "resultClick",
|
|
417
|
+
"bubbles": true,
|
|
418
|
+
"cancelable": true,
|
|
419
|
+
"composed": true,
|
|
420
|
+
"docs": {
|
|
421
|
+
"tags": [],
|
|
422
|
+
"text": ""
|
|
423
|
+
},
|
|
424
|
+
"complexType": {
|
|
425
|
+
"original": "Result",
|
|
426
|
+
"resolved": "{ id: string; type: string; } & Record<string, unknown>",
|
|
381
427
|
"references": {
|
|
382
428
|
"Result": {
|
|
383
|
-
"location": "
|
|
429
|
+
"location": "import",
|
|
430
|
+
"path": "./types"
|
|
384
431
|
}
|
|
385
432
|
}
|
|
386
433
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|