@vertexvis/ui 0.1.0-canary.6 → 0.1.0-canary.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/cjs/components.cjs.js +1 -1
  2. package/dist/cjs/index.cjs.js +3 -3
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{result-list-1e592c3c.js → result-list-241ffe8d.js} +46 -2
  5. package/dist/cjs/search-bar-91cbcd07.js +421 -0
  6. package/dist/cjs/{text-field-0397fb34.js → text-field-bccbde1f.js} +1 -0
  7. package/dist/cjs/vertex-result-list.cjs.entry.js +1 -1
  8. package/dist/cjs/vertex-search-bar.cjs.entry.js +1 -1
  9. package/dist/cjs/vertex-textfield.cjs.entry.js +1 -1
  10. package/dist/collection/collection-manifest.json +1 -1
  11. package/dist/collection/components/result-list/result-list.js +52 -5
  12. package/dist/collection/components/result-list/types.js +1 -0
  13. package/dist/collection/components/search-bar/dom.js +12 -0
  14. package/dist/collection/components/search-bar/lib.js +35 -15
  15. package/dist/collection/components/search-bar/search-bar.css +0 -16
  16. package/dist/collection/components/search-bar/search-bar.js +380 -324
  17. package/dist/collection/components/text-field/text-field.js +1 -0
  18. package/dist/collection/util/templates/element-pool.js +19 -1
  19. package/dist/components/components.css +1 -1
  20. package/dist/components/components.esm.js +1 -1
  21. package/dist/components/index.esm.js +1 -1
  22. package/dist/components/p-406e73da.entry.js +1 -0
  23. package/dist/components/p-43b1b3f9.js +1 -0
  24. package/dist/components/p-6b862967.js +1 -0
  25. package/dist/components/p-cfe369bf.entry.js +1 -0
  26. package/dist/components/p-db34f10c.js +1 -0
  27. package/dist/components/p-ee496965.entry.js +1 -0
  28. package/dist/esm/components.js +1 -1
  29. package/dist/esm/index.js +3 -3
  30. package/dist/esm/loader.js +1 -1
  31. package/dist/esm/{result-list-36cfb08a.js → result-list-16c6afbd.js} +46 -2
  32. package/dist/esm/search-bar-f12a3599.js +419 -0
  33. package/dist/esm/{text-field-e542da25.js → text-field-32ac877e.js} +1 -0
  34. package/dist/esm/vertex-result-list.entry.js +1 -1
  35. package/dist/esm/vertex-search-bar.entry.js +1 -1
  36. package/dist/esm/vertex-textfield.entry.js +1 -1
  37. package/dist/types/components/result-list/result-list.d.ts +6 -1
  38. package/dist/types/components/result-list/types.d.ts +4 -0
  39. package/dist/types/components/search-bar/dom.d.ts +3 -0
  40. package/dist/types/components/search-bar/lib.d.ts +24 -6
  41. package/dist/types/components/search-bar/search-bar.d.ts +124 -42
  42. package/dist/types/components.d.ts +81 -20
  43. package/dist/types/util/templates/element-pool.d.ts +10 -1
  44. package/package.json +4 -3
  45. package/dist/cjs/search-bar-bb40cfa7.js +0 -290
  46. package/dist/components/p-19318fee.entry.js +0 -1
  47. package/dist/components/p-209db2ba.entry.js +0 -1
  48. package/dist/components/p-4224c2ad.js +0 -1
  49. package/dist/components/p-52739247.js +0 -1
  50. package/dist/components/p-ae6a3c46.entry.js +0 -1
  51. package/dist/components/p-bd11e7d1.js +0 -1
  52. package/dist/esm/search-bar-59cc151d.js +0 -288
@@ -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',
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const resultList = require('./result-list-1e592c3c.js');
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-bb40cfa7.js');
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');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const textField = require('./text-field-0397fb34.js');
5
+ const textField = require('./text-field-bccbde1f.js');
6
6
  require('./index-6a92256c.js');
7
7
  require('./index-e1b40fa6.js');
8
8
 
@@ -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
  ],
@@ -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": "local"
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": "{ [x: string]: unknown; }",
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": "local"
429
+ "location": "import",
430
+ "path": "./types"
384
431
  }
385
432
  }
386
433
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ export const getWindowSelection = () => {
2
+ if (typeof window !== 'undefined') {
3
+ return window.getSelection();
4
+ }
5
+ return undefined;
6
+ };
7
+ export const createDocumentRange = () => {
8
+ return document.createRange();
9
+ };
10
+ export const createTextNode = (text) => {
11
+ return new Text(text);
12
+ };
@@ -1,21 +1,41 @@
1
- export const getWindowSelection = () => {
2
- if (typeof window !== 'undefined') {
3
- return window.getSelection();
4
- }
5
- return undefined;
1
+ import { createTextNode } from './dom';
2
+ export const createResultUri = (result) => {
3
+ return `${result.type}:${result.id}`;
6
4
  };
7
- export const createDocumentRange = () => {
8
- return document.createRange();
5
+ export const createSearchResultReplacement = (result, before, after) => {
6
+ const urn = createResultUri(result);
7
+ return {
8
+ before: createTextNode(before),
9
+ beforeSpace: createTextNode(createHairSpace()),
10
+ result: createTextNode(urn),
11
+ afterSpace: after != null ? createTextNode(createNoBreakSpace()) : undefined,
12
+ after: after != null ? createTextNode(after) : undefined,
13
+ };
9
14
  };
10
- export const isTextNode = (node) => {
11
- return node instanceof Text;
15
+ export const getNodesForSearchResultReplacement = (replacement) => {
16
+ const keys = Object.keys(replacement);
17
+ return keys
18
+ .map((key) => replacement[key])
19
+ .filter((node) => node != null);
12
20
  };
13
- export const isHtmlElement = (target) => {
14
- return target instanceof HTMLElement;
21
+ /**
22
+ * We leverage a couple unique spaces to represent mentions, allowing for
23
+ * correct cursor movement when using arrow keys. As these characters are
24
+ * purely for functional behavior of the input, `trimNonstandardSpaces`
25
+ * will remove them so the input is suitable for emitting.
26
+ *
27
+ * U+200A is a "Hair Space" which acts as a space, but is not visually
28
+ * represented as one.
29
+ *
30
+ * U+00A0 is a "No-Break Space" which is commonly added by browsers
31
+ * when interacting with a contenteditable element.
32
+ */
33
+ export const trimNonstandardSpaces = (text) => {
34
+ return text.replace(/[\u200A]/g, '').replace(/[\u00A0]/g, ' ');
15
35
  };
16
- export const isReplacedElement = (el) => {
17
- return (el === null || el === void 0 ? void 0 : el.getAttribute('data-replaced')) === 'true';
36
+ const createHairSpace = () => {
37
+ return String.fromCharCode(8202);
18
38
  };
19
- export const createTextNode = (text) => {
20
- return new Text(text != null && text !== '' ? text : ' ');
39
+ const createNoBreakSpace = () => {
40
+ return String.fromCharCode(160);
21
41
  };
@@ -11,15 +11,6 @@
11
11
  line-height: 1.4;
12
12
  }
13
13
 
14
- .test-mention {
15
- display: inline-block;
16
- color: blue;
17
- }
18
-
19
- .hidden {
20
- visibility: hidden;
21
- }
22
-
23
14
  .content-input {
24
15
  width: 100%;
25
16
  box-sizing: border-box;
@@ -33,13 +24,6 @@
33
24
  white-space: pre-line;
34
25
  }
35
26
 
36
- .textarea {
37
- overflow: hidden;
38
- outline: none;
39
- box-shadow: none;
40
- resize: none;
41
- }
42
-
43
27
  .content-input:focus {
44
28
  outline: none;
45
29
  }