@vertexvis/ui 0.1.0-canary.1 → 0.1.0-canary.10
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/badge-d39ac1fc.js +23 -0
- package/dist/cjs/components.cjs.js +1 -1
- package/dist/cjs/{icon-53d62a46.js → icon-2508f168.js} +1 -1
- package/dist/cjs/icon-button-72c19ebc.js +43 -0
- package/dist/cjs/{icon-helper-caf2699e.js → icon-helper-07d63296.js} +12 -0
- package/dist/cjs/index.cjs.js +11 -9
- 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-91cbcd07.js +421 -0
- package/dist/cjs/{select-0eb7203f.js → select-5f8aecfe.js} +27 -4
- package/dist/cjs/{text-field-0397fb34.js → text-field-bccbde1f.js} +1 -0
- package/dist/cjs/{tooltip-80a7b722.js → tooltip-e9f63631.js} +57 -18
- package/dist/cjs/vertex-badge.cjs.entry.js +11 -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-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-textfield.cjs.entry.js +1 -1
- package/dist/cjs/vertex-tooltip.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/badge/badge.css +18 -0
- package/dist/collection/components/badge/badge.js +69 -0
- package/dist/collection/components/icon/icon-helper.js +6 -0
- package/dist/collection/components/icon/icon.js +1 -1
- package/dist/collection/components/icon/icons/comment-filled.js +2 -0
- package/dist/collection/components/icon/icons/compare.js +2 -0
- package/dist/collection/components/icon-button/icon-button.css +16 -1
- package/dist/collection/components/icon-button/icon-button.js +2 -2
- package/dist/collection/components/index.js +1 -0
- 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 +12 -0
- package/dist/collection/components/search-bar/lib.js +35 -15
- package/dist/collection/components/search-bar/search-bar.css +0 -16
- package/dist/collection/components/search-bar/search-bar.js +380 -324
- package/dist/collection/components/select/select.css +16 -0
- package/dist/collection/components/select/select.js +49 -2
- 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 +2 -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-09c16263.js +1 -0
- package/dist/components/p-0b1cdc8a.entry.js +1 -0
- package/dist/components/p-0b4406fa.entry.js +1 -0
- package/dist/components/{p-17b97932.js → p-265e2358.js} +1 -1
- package/dist/components/p-29d7697f.js +1 -0
- package/dist/components/p-2a6a8da4.entry.js +1 -0
- package/dist/components/p-406e73da.entry.js +1 -0
- package/dist/components/p-429cea3e.js +1 -0
- package/dist/components/p-43b1b3f9.js +1 -0
- package/dist/components/p-606596de.entry.js +1 -0
- package/dist/components/p-6b862967.js +1 -0
- package/dist/components/p-7cfb3736.entry.js +1 -0
- package/dist/components/p-912f6e24.js +1 -0
- package/dist/components/p-92930f2a.js +1 -0
- package/dist/components/p-c2706288.js +1 -0
- package/dist/components/p-c588db04.entry.js +1 -0
- package/dist/components/p-cfe369bf.entry.js +1 -0
- package/dist/components/p-db34f10c.js +1 -0
- package/dist/components/p-ee496965.entry.js +1 -0
- package/dist/esm/badge-6d27ca92.js +21 -0
- package/dist/esm/components.js +1 -1
- package/dist/esm/{icon-2630793d.js → icon-24b0a152.js} +1 -1
- package/dist/esm/icon-button-a7a40f3d.js +41 -0
- package/dist/esm/{icon-helper-10a99d95.js → icon-helper-3cc82749.js} +12 -0
- package/dist/esm/index.js +10 -9
- 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-f12a3599.js +419 -0
- package/dist/esm/{select-75ed5653.js → select-d4e135b7.js} +27 -4
- package/dist/esm/{text-field-e542da25.js → text-field-32ac877e.js} +1 -0
- package/dist/esm/{tooltip-97c1b3ec.js → tooltip-933da261.js} +57 -18
- package/dist/esm/vertex-badge.entry.js +3 -0
- 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-textfield.entry.js +1 -1
- package/dist/esm/vertex-tooltip.entry.js +1 -1
- package/dist/types/components/badge/badge.d.ts +14 -0
- package/dist/types/components/icon/icons/comment-filled.d.ts +3 -0
- package/dist/types/components/icon/icons/compare.d.ts +3 -0
- package/dist/types/components/index.d.ts +1 -0
- 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 +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/select/select.d.ts +8 -0
- package/dist/types/components/tooltip/tooltip.d.ts +7 -0
- package/dist/types/components.d.ts +122 -20
- package/dist/types/types/icon.d.ts +2 -0
- package/dist/types/util/templates/element-pool.d.ts +10 -1
- package/package.json +4 -3
- package/dist/cjs/icon-button-f868bf06.js +0 -43
- package/dist/cjs/search-bar-bb40cfa7.js +0 -290
- 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-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-79fd6fb6.entry.js +0 -1
- package/dist/components/p-94168b92.js +0 -1
- package/dist/components/p-ae6a3c46.entry.js +0 -1
- package/dist/components/p-bd11e7d1.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-ee8b96b2.js +0 -1
- package/dist/components/p-f49a7ffd.js +0 -1
- package/dist/components/p-f900d0f4.entry.js +0 -1
- package/dist/esm/icon-button-25edf617.js +0 -41
- 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;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const index = require('./index-6a92256c.js');
|
|
4
4
|
const index$1 = require('./index-e1b40fa6.js');
|
|
5
5
|
|
|
6
|
-
const selectCss = ":host{--select-width:100
|
|
6
|
+
const selectCss = ":host{--select-width:100%;--select-option-white-space:normal}.root{display:inline-block;color:var(--vertex-ui-neutral-700);width:var(--select-width);font-family:var(--vertex-ui-font-family);font-size:var(--vertex-ui-text-base);overflow:hidden;user-select:none}.root:not(.disabled):hover{color:var(--vertex-ui-neutral-800)}.root.disabled{color:var(--vertex-ui-neutral-400)}.target,.selected-option{background-color:var(--vertex-ui-neutral-200);width:100%;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;padding:0.375rem 0.75rem 0.375rem 0.75rem}.target.hidden{box-shadow:0px 2px 4px -1px rgb(0 0 0 / 20%),\n 0px 4px 5px 0px rgb(0 0 0 / 14%), 0px 1px 10px 0px rgb(0 0 0 / 12%)}.selected-option.disabled,.target.disabled{background-color:var(--vertex-ui-neutral-100);cursor:default}.target{border-radius:4px}.text{white-space:var(--select-option-white-space);overflow:hidden;text-overflow:ellipsis}.icon{padding-left:1rem;margin-left:auto}.options{position:relative;cursor:pointer;background-color:var(--vertex-ui-white);border-radius:4px;padding:0.25rem 0;top:-0.25rem;box-shadow:0px 2px 4px -1px rgb(0 0 0 / 20%),\n 0px 4px 5px 0px rgb(0 0 0 / 14%), 0px 1px 10px 0px rgb(0 0 0 / 12%)}.options.animated{transition:opacity 0.1s ease-in 0.05s;opacity:0}.options.hidden{background-color:transparent}.options.visible{opacity:1}.options>*,.options>slot::slotted(*){padding:0.375rem 0.75rem 0.375rem 0.75rem}.options.hidden>*,.options.hidden>slot::slotted(*){opacity:0}.options>slot::slotted(:hover){background-color:var(--vertex-ui-neutral-200)}.options>slot::slotted([data-selected=\"true\"]){display:none}vertex-popover{--transform-origin:top left;--open-animation-name:open-scale-y;--close-animation-name:close-scale-y}";
|
|
7
7
|
|
|
8
8
|
const GET_BOUNDS_DEBOUNCE_THRESHOLD = 200;
|
|
9
9
|
const Select = class {
|
|
@@ -16,6 +16,7 @@ const Select = class {
|
|
|
16
16
|
this.placeholder = 'Select an option...';
|
|
17
17
|
this.disabled = false;
|
|
18
18
|
this.animated = true;
|
|
19
|
+
this.hideSelected = true;
|
|
19
20
|
this.open = false;
|
|
20
21
|
this.position = undefined;
|
|
21
22
|
this.displayValue = undefined;
|
|
@@ -35,6 +36,9 @@ const Select = class {
|
|
|
35
36
|
if (this.value != null) {
|
|
36
37
|
this.handleUpdateValue(this.value);
|
|
37
38
|
}
|
|
39
|
+
else {
|
|
40
|
+
this.handleUpdateDisplayValue();
|
|
41
|
+
}
|
|
38
42
|
}
|
|
39
43
|
connectedCallback() {
|
|
40
44
|
window.addEventListener('resize', this.getBounds);
|
|
@@ -52,6 +56,13 @@ const Select = class {
|
|
|
52
56
|
}
|
|
53
57
|
this.controlled = value != null;
|
|
54
58
|
}
|
|
59
|
+
handleUpdateDisplayValue() {
|
|
60
|
+
var _a;
|
|
61
|
+
this.clearSelectedOptionFlag();
|
|
62
|
+
if (this.hideSelected) {
|
|
63
|
+
(_a = this.getSelectedOption()) === null || _a === void 0 ? void 0 : _a.setAttribute('data-selected', 'true');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
55
66
|
render() {
|
|
56
67
|
return (index.h("div", { class: index$1.classnames('root', {
|
|
57
68
|
disabled: this.disabled,
|
|
@@ -60,7 +71,7 @@ const Select = class {
|
|
|
60
71
|
}, onClick: !this.open && !this.disabled ? this.handleOpen : undefined }, index.h("div", { class: index$1.classnames('target', {
|
|
61
72
|
hidden: this.open,
|
|
62
73
|
disabled: this.disabled,
|
|
63
|
-
}) }, this.displayValue || this.placeholder, index.h("div", { class: "icon" }, index.h("vertex-icon", { name: "chevron-down", size: "sm" }))), index.h("vertex-popover", { position: this.position, open: this.open, animated: this.animated, resizeBehavior: "fixed", onDismissed: this.handleDismiss }, index.h("div", { class: index$1.classnames('options', {
|
|
74
|
+
}) }, index.h("div", { class: "text" }, this.displayValue || this.placeholder), index.h("div", { class: "icon" }, index.h("vertex-icon", { name: "chevron-down", size: "sm" }))), index.h("vertex-popover", { position: this.position, open: this.open, animated: this.animated, resizeBehavior: "fixed", onDismissed: this.handleDismiss }, index.h("div", { class: index$1.classnames('options', {
|
|
64
75
|
hidden: !this.open,
|
|
65
76
|
visible: this.open,
|
|
66
77
|
animated: this.animated,
|
|
@@ -68,7 +79,7 @@ const Select = class {
|
|
|
68
79
|
minWidth: this.width != null ? `${this.width}px` : 'var(--select-width)',
|
|
69
80
|
} }, index.h("div", { class: index$1.classnames('selected-option', {
|
|
70
81
|
disabled: this.disabled,
|
|
71
|
-
}), onClick: this.handleDismiss }, this.displayValue || this.placeholder, index.h("div", { class: "icon" }, index.h("vertex-icon", { name: "chevron-down", size: "sm" }))), index.h("slot", null)))));
|
|
82
|
+
}), onClick: this.handleDismiss }, index.h("div", { class: "text" }, this.displayValue || this.placeholder), index.h("div", { class: "icon" }, index.h("vertex-icon", { name: "chevron-down", size: "sm" }))), index.h("slot", null)))));
|
|
72
83
|
}
|
|
73
84
|
handleOpen() {
|
|
74
85
|
var _a, _b;
|
|
@@ -107,6 +118,15 @@ const Select = class {
|
|
|
107
118
|
this.removeListeners.forEach((l) => l());
|
|
108
119
|
this.removeListeners = [];
|
|
109
120
|
}
|
|
121
|
+
clearSelectedOptionFlag() {
|
|
122
|
+
var _a, _b;
|
|
123
|
+
(_b = (_a = this.slotElement) === null || _a === void 0 ? void 0 : _a.assignedElements) === null || _b === void 0 ? void 0 : _b.call(_a).forEach((e) => e.removeAttribute('data-selected'));
|
|
124
|
+
}
|
|
125
|
+
getSelectedOption() {
|
|
126
|
+
var _a, _b, _c;
|
|
127
|
+
const value = (_a = this.displayValue) !== null && _a !== void 0 ? _a : this.placeholder;
|
|
128
|
+
return (_c = (_b = this.slotElement) === null || _b === void 0 ? void 0 : _b.assignedElements) === null || _c === void 0 ? void 0 : _c.call(_b).find((e) => e.getAttribute('data-value') === value || e.innerHTML === value);
|
|
129
|
+
}
|
|
110
130
|
getBounds() {
|
|
111
131
|
if (this.getBoundsTimeout != null) {
|
|
112
132
|
clearTimeout(this.getBoundsTimeout);
|
|
@@ -130,7 +150,10 @@ const Select = class {
|
|
|
130
150
|
}
|
|
131
151
|
get hostElement() { return index.getElement(this); }
|
|
132
152
|
static get watchers() { return {
|
|
133
|
-
"value": ["handleUpdateValue"]
|
|
153
|
+
"value": ["handleUpdateValue"],
|
|
154
|
+
"displayValue": ["handleUpdateDisplayValue"],
|
|
155
|
+
"hideSelected": ["handleUpdateDisplayValue"],
|
|
156
|
+
"placeholder": ["handleUpdateDisplayValue"]
|
|
134
157
|
}; }
|
|
135
158
|
};
|
|
136
159
|
Select.style = selectCss;
|
|
@@ -81,6 +81,7 @@ const TextField = class {
|
|
|
81
81
|
render() {
|
|
82
82
|
var _a;
|
|
83
83
|
const classes = index$1.classnames('txt-wrapper', {
|
|
84
|
+
'txt-wrapper-border': !this.multiline,
|
|
84
85
|
'txt-standard': this.variant === 'standard',
|
|
85
86
|
'txt-filled': this.variant === 'filled',
|
|
86
87
|
'txt-underlined': this.variant === 'underlined',
|
|
@@ -2062,6 +2062,7 @@ const TOOLTIP_OPEN_DELAY = 500;
|
|
|
2062
2062
|
const Tooltip = class {
|
|
2063
2063
|
constructor(hostRef) {
|
|
2064
2064
|
index.registerInstance(this, hostRef);
|
|
2065
|
+
this.pointerEntered = false;
|
|
2065
2066
|
this.content = undefined;
|
|
2066
2067
|
this.disabled = undefined;
|
|
2067
2068
|
this.placement = 'bottom';
|
|
@@ -2070,32 +2071,40 @@ const Tooltip = class {
|
|
|
2070
2071
|
this.open = false;
|
|
2071
2072
|
this.handlePointerEnter = this.handlePointerEnter.bind(this);
|
|
2072
2073
|
this.handlePointerLeave = this.handlePointerLeave.bind(this);
|
|
2074
|
+
this.handleContentChange = this.handleContentChange.bind(this);
|
|
2075
|
+
this.handleDisabledChange = this.handleDisabledChange.bind(this);
|
|
2073
2076
|
this.tooltipId = `vertex-tooltip-${uuid.create()}`;
|
|
2074
2077
|
}
|
|
2075
2078
|
disconnectedCallback() {
|
|
2076
2079
|
this.removeElement();
|
|
2077
2080
|
this.clearOpenTimeout();
|
|
2081
|
+
this.pointerEntered = false;
|
|
2082
|
+
}
|
|
2083
|
+
handleContentChange() {
|
|
2084
|
+
if (this.internalContentElement != null) {
|
|
2085
|
+
this.updateContentElementChildren(this.internalContentElement);
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
handleDisabledChange() {
|
|
2089
|
+
if (this.internalContentElement != null) {
|
|
2090
|
+
this.updateContentElementClass(this.internalContentElement);
|
|
2091
|
+
}
|
|
2092
|
+
if (!this.disabled && this.pointerEntered) {
|
|
2093
|
+
this.handlePointerEnter();
|
|
2094
|
+
}
|
|
2078
2095
|
}
|
|
2079
2096
|
render() {
|
|
2080
2097
|
return (index.h(index.Host, null, index.h("div", { class: "target", ref: (el) => {
|
|
2081
2098
|
this.targetElement = el;
|
|
2082
2099
|
}, onPointerEnter: this.handlePointerEnter, onPointerLeave: this.handlePointerLeave }, index.h("slot", null)), index.h("div", { class: "content-hidden", ref: (el) => {
|
|
2083
2100
|
this.contentElement = el;
|
|
2084
|
-
} }, index.h("slot", { name: "content" }))));
|
|
2101
|
+
} }, index.h("slot", { name: "content", onSlotchange: this.handleContentChange }))));
|
|
2085
2102
|
}
|
|
2086
2103
|
addElement() {
|
|
2087
|
-
var _a;
|
|
2088
2104
|
if (this.targetElement != null) {
|
|
2089
2105
|
const popover = this.createPopoverElement(this.targetElement);
|
|
2090
2106
|
const content = this.createContentElement();
|
|
2091
|
-
this.
|
|
2092
|
-
(_a = slots.getSlottedContent(this.contentElement)) !== null && _a !== void 0 ? _a : this.displayedSlottedContent;
|
|
2093
|
-
if (this.content != null) {
|
|
2094
|
-
content.innerText = this.content;
|
|
2095
|
-
}
|
|
2096
|
-
else if (this.displayedSlottedContent != null) {
|
|
2097
|
-
content.appendChild(this.displayedSlottedContent);
|
|
2098
|
-
}
|
|
2107
|
+
this.updateContentElementChildren(content);
|
|
2099
2108
|
popover.appendChild(content);
|
|
2100
2109
|
this.hostElement.ownerDocument.body.appendChild(popover);
|
|
2101
2110
|
}
|
|
@@ -2105,6 +2114,7 @@ const Tooltip = class {
|
|
|
2105
2114
|
if (popover != null) {
|
|
2106
2115
|
popover.remove();
|
|
2107
2116
|
}
|
|
2117
|
+
this.internalContentElement = undefined;
|
|
2108
2118
|
}
|
|
2109
2119
|
createPopoverElement(anchorElement) {
|
|
2110
2120
|
const popover = this.hostElement.ownerDocument.createElement('vertex-popover');
|
|
@@ -2119,25 +2129,50 @@ const Tooltip = class {
|
|
|
2119
2129
|
return popover;
|
|
2120
2130
|
}
|
|
2121
2131
|
createContentElement() {
|
|
2122
|
-
|
|
2123
|
-
|
|
2132
|
+
this.internalContentElement =
|
|
2133
|
+
this.hostElement.ownerDocument.createElement('div');
|
|
2134
|
+
this.internalContentElement.setAttribute('class', index$1.classnames('vertex-tooltip-content', {
|
|
2135
|
+
hidden: !this.open || this.disabled,
|
|
2136
|
+
}));
|
|
2137
|
+
return this.internalContentElement;
|
|
2138
|
+
}
|
|
2139
|
+
updateContentElementClass(element) {
|
|
2140
|
+
element.setAttribute('class', index$1.classnames('vertex-tooltip-content', {
|
|
2124
2141
|
hidden: !this.open || this.disabled,
|
|
2125
2142
|
}));
|
|
2126
|
-
|
|
2143
|
+
}
|
|
2144
|
+
updateContentElementChildren(element) {
|
|
2145
|
+
var _a;
|
|
2146
|
+
this.displayedSlottedContent =
|
|
2147
|
+
(_a = slots.getSlottedContent(this.contentElement)) !== null && _a !== void 0 ? _a : this.displayedSlottedContent;
|
|
2148
|
+
if (this.content != null) {
|
|
2149
|
+
element.innerText = this.content;
|
|
2150
|
+
}
|
|
2151
|
+
else if (this.displayedSlottedContent != null) {
|
|
2152
|
+
element.appendChild(this.displayedSlottedContent);
|
|
2153
|
+
}
|
|
2127
2154
|
}
|
|
2128
2155
|
handlePointerEnter() {
|
|
2129
2156
|
if (this.openTimeout == null && !this.disabled) {
|
|
2130
|
-
this.
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
}, this.delay);
|
|
2157
|
+
this.createOpenTimeout();
|
|
2158
|
+
}
|
|
2159
|
+
else if (this.openTimeout == null) {
|
|
2160
|
+
this.pointerEntered = true;
|
|
2135
2161
|
}
|
|
2136
2162
|
}
|
|
2137
2163
|
handlePointerLeave() {
|
|
2138
2164
|
this.clearOpenTimeout();
|
|
2139
2165
|
this.removeElement();
|
|
2140
2166
|
this.open = false;
|
|
2167
|
+
this.pointerEntered = false;
|
|
2168
|
+
}
|
|
2169
|
+
createOpenTimeout() {
|
|
2170
|
+
this.openTimeout = setTimeout(() => {
|
|
2171
|
+
this.open = true;
|
|
2172
|
+
this.openTimeout = undefined;
|
|
2173
|
+
this.addElement();
|
|
2174
|
+
}, this.delay);
|
|
2175
|
+
this.pointerEntered = false;
|
|
2141
2176
|
}
|
|
2142
2177
|
clearOpenTimeout() {
|
|
2143
2178
|
if (this.openTimeout != null) {
|
|
@@ -2146,6 +2181,10 @@ const Tooltip = class {
|
|
|
2146
2181
|
}
|
|
2147
2182
|
}
|
|
2148
2183
|
get hostElement() { return index.getElement(this); }
|
|
2184
|
+
static get watchers() { return {
|
|
2185
|
+
"content": ["handleContentChange"],
|
|
2186
|
+
"disabled": ["handleDisabledChange"]
|
|
2187
|
+
}; }
|
|
2149
2188
|
};
|
|
2150
2189
|
Tooltip.style = tooltipCss;
|
|
2151
2190
|
|