@vertexvis/ui 0.1.0-testing.4 → 0.1.0-testing.5

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 (82) hide show
  1. package/dist/cjs/components.cjs.js +1 -1
  2. package/dist/cjs/index.cjs.js +6 -6
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{popover-d9ec8e10.js → popover-942209b8.js} +23 -1
  5. package/dist/cjs/{result-list-1e592c3c.js → result-list-241ffe8d.js} +46 -2
  6. package/dist/cjs/search-bar-a321b3e1.js +353 -0
  7. package/dist/cjs/{select-0eb7203f.js → select-5f8aecfe.js} +27 -4
  8. package/dist/cjs/{text-field-0397fb34.js → text-field-bccbde1f.js} +1 -0
  9. package/dist/cjs/{tooltip-02e24a48.js → tooltip-e9f63631.js} +58 -19
  10. package/dist/cjs/vertex-popover.cjs.entry.js +1 -1
  11. package/dist/cjs/vertex-result-list.cjs.entry.js +1 -1
  12. package/dist/cjs/vertex-search-bar.cjs.entry.js +1 -1
  13. package/dist/cjs/vertex-select.cjs.entry.js +1 -1
  14. package/dist/cjs/vertex-textfield.cjs.entry.js +1 -1
  15. package/dist/cjs/vertex-tooltip.cjs.entry.js +1 -1
  16. package/dist/collection/components/menu/menu.js +1 -1
  17. package/dist/collection/components/popover/popover.js +51 -0
  18. package/dist/collection/components/result-list/result-list.js +47 -3
  19. package/dist/collection/components/search-bar/dom.js +12 -0
  20. package/dist/collection/components/search-bar/lib.js +23 -15
  21. package/dist/collection/components/search-bar/search-bar.css +2 -29
  22. package/dist/collection/components/search-bar/search-bar.js +352 -326
  23. package/dist/collection/components/select/select.css +16 -0
  24. package/dist/collection/components/select/select.js +49 -2
  25. package/dist/collection/components/text-field/text-field.js +1 -0
  26. package/dist/collection/components/tooltip/tooltip.css +0 -4
  27. package/dist/collection/components/tooltip/tooltip.js +62 -18
  28. package/dist/collection/util/templates/element-pool.js +19 -1
  29. package/dist/components/components.css +1 -1
  30. package/dist/components/components.esm.js +1 -1
  31. package/dist/components/index.esm.js +1 -1
  32. package/dist/components/p-0b1cdc8a.entry.js +1 -0
  33. package/dist/components/p-406e73da.entry.js +1 -0
  34. package/dist/components/p-43b1b3f9.js +1 -0
  35. package/dist/components/p-606596de.entry.js +1 -0
  36. package/dist/components/p-6b862967.js +1 -0
  37. package/dist/components/p-7cfb3736.entry.js +1 -0
  38. package/dist/components/p-912f6e24.js +1 -0
  39. package/dist/components/p-92930f2a.js +1 -0
  40. package/dist/components/p-c2706288.js +1 -0
  41. package/dist/components/p-c4518377.entry.js +1 -0
  42. package/dist/components/p-ee496965.entry.js +1 -0
  43. package/dist/components/p-f064f911.js +1 -0
  44. package/dist/esm/components.js +1 -1
  45. package/dist/esm/index.js +6 -6
  46. package/dist/esm/loader.js +1 -1
  47. package/dist/esm/{popover-67c88e4b.js → popover-6e806354.js} +23 -1
  48. package/dist/esm/{result-list-36cfb08a.js → result-list-16c6afbd.js} +46 -2
  49. package/dist/esm/search-bar-6fad2f2e.js +351 -0
  50. package/dist/esm/{select-75ed5653.js → select-d4e135b7.js} +27 -4
  51. package/dist/esm/{text-field-e542da25.js → text-field-32ac877e.js} +1 -0
  52. package/dist/esm/{tooltip-b4d2a889.js → tooltip-933da261.js} +58 -19
  53. package/dist/esm/vertex-popover.entry.js +1 -1
  54. package/dist/esm/vertex-result-list.entry.js +1 -1
  55. package/dist/esm/vertex-search-bar.entry.js +1 -1
  56. package/dist/esm/vertex-select.entry.js +1 -1
  57. package/dist/esm/vertex-textfield.entry.js +1 -1
  58. package/dist/esm/vertex-tooltip.entry.js +1 -1
  59. package/dist/types/components/popover/popover.d.ts +7 -0
  60. package/dist/types/components/result-list/result-list.d.ts +9 -1
  61. package/dist/types/components/search-bar/dom.d.ts +3 -0
  62. package/dist/types/components/search-bar/lib.d.ts +12 -6
  63. package/dist/types/components/search-bar/search-bar.d.ts +98 -41
  64. package/dist/types/components/select/select.d.ts +8 -0
  65. package/dist/types/components/tooltip/tooltip.d.ts +7 -0
  66. package/dist/types/components.d.ts +81 -16
  67. package/dist/types/util/templates/element-pool.d.ts +10 -1
  68. package/package.json +2 -2
  69. package/dist/cjs/search-bar-bb40cfa7.js +0 -290
  70. package/dist/components/p-19318fee.entry.js +0 -1
  71. package/dist/components/p-209db2ba.entry.js +0 -1
  72. package/dist/components/p-2bb3b235.js +0 -1
  73. package/dist/components/p-4224c2ad.js +0 -1
  74. package/dist/components/p-52739247.js +0 -1
  75. package/dist/components/p-552c128f.js +0 -1
  76. package/dist/components/p-6505cdb3.js +0 -1
  77. package/dist/components/p-ae6a3c46.entry.js +0 -1
  78. package/dist/components/p-bd11e7d1.js +0 -1
  79. package/dist/components/p-c8dd68a1.entry.js +0 -1
  80. package/dist/components/p-e576818b.entry.js +0 -1
  81. package/dist/components/p-ebabee40.entry.js +0 -1
  82. package/dist/esm/search-bar-59cc151d.js +0 -288
@@ -182,7 +182,7 @@ export class Menu {
182
182
  "mutable": false,
183
183
  "complexType": {
184
184
  "original": "Partial<Popover>",
185
- "resolved": "undefined | ({ open?: boolean | undefined; placement?: Placement | undefined; position?: string | Point | undefined; anchorBounds?: Pick<DOMRect, \"height\" | \"width\" | \"x\" | \"y\"> | undefined; backdrop?: boolean | undefined; animated?: boolean | undefined; anchorSelector?: string | undefined; boundarySelector?: string | undefined; resizeBehavior?: PopoverResizeBehavior | undefined; overflowBehavior?: { rootBoundary?: RootBoundary | undefined; elementContext?: ElementContext | undefined; altBoundary?: boolean | undefined; padding?: Padding | undefined; boundary?: Boundary | undefined; } | undefined; flipBehavior?: { rootBoundary?: RootBoundary | undefined; elementContext?: ElementContext | undefined; altBoundary?: boolean | undefined; padding?: Padding | undefined; crossAxis?: boolean | undefined; mainAxis?: boolean | undefined; fallbackPlacements?: Placement[] | undefined; fallbackStrategy?: \"bestFit\" | \"initialPlacement\" | undefined; fallbackAxisSideDirection?: \"none\" | \"start\" | \"end\" | undefined; flipAlignment?: boolean | undefined; boundary?: Boundary | undefined; } | undefined; offsetBehavior?: OffsetOptions | undefined; updateOnResize?: boolean | undefined; dismissed?: EventEmitter<void> | undefined; connectedCallback?: (() => void) | undefined; componentDidUpdate?: (() => void) | undefined; componentDidLoad?: (() => void) | undefined; disconnectedCallback?: (() => void) | undefined; updatePosition?: ((position?: string | Point | undefined) => void) | undefined; updatePlacement?: (() => void) | undefined; updateOpened?: ((open?: boolean | undefined) => void) | undefined; updateAnimated?: (() => void) | undefined; updateMiddleware?: (() => void) | undefined; setWindow?: ((partialWindow: Pick<Window, \"innerHeight\" | \"innerWidth\">) => void) | undefined; render?: (() => IntrinsicElements) | undefined; })",
185
+ "resolved": "undefined | ({ open?: boolean | undefined; placement?: Placement | undefined; position?: string | Point | undefined; anchorBounds?: Pick<DOMRect, \"height\" | \"width\" | \"x\" | \"y\"> | undefined; backdrop?: boolean | undefined; animated?: boolean | undefined; anchorSelector?: string | undefined; boundarySelector?: string | undefined; resizeBehavior?: PopoverResizeBehavior | undefined; overflowBehavior?: { rootBoundary?: RootBoundary | undefined; elementContext?: ElementContext | undefined; altBoundary?: boolean | undefined; padding?: Padding | undefined; boundary?: Boundary | undefined; } | undefined; flipBehavior?: { rootBoundary?: RootBoundary | undefined; elementContext?: ElementContext | undefined; altBoundary?: boolean | undefined; padding?: Padding | undefined; crossAxis?: boolean | undefined; mainAxis?: boolean | undefined; fallbackPlacements?: Placement[] | undefined; fallbackStrategy?: \"bestFit\" | \"initialPlacement\" | undefined; fallbackAxisSideDirection?: \"none\" | \"start\" | \"end\" | undefined; flipAlignment?: boolean | undefined; boundary?: Boundary | undefined; } | undefined; offsetBehavior?: OffsetOptions | undefined; updateOnResize?: boolean | undefined; dismissed?: EventEmitter<void> | undefined; resizeObserverFactory?: ((cb: (entries: ResizeObserverEntry[]) => void) => ResizeObserver) | undefined; connectedCallback?: (() => void) | undefined; componentDidUpdate?: (() => void) | undefined; componentDidLoad?: (() => void) | undefined; disconnectedCallback?: (() => void) | undefined; updatePosition?: ((position?: string | Point | undefined) => void) | undefined; updatePlacement?: (() => void) | undefined; updateOpened?: ((open?: boolean | undefined) => void) | undefined; updateAnimated?: (() => void) | undefined; updateMiddleware?: (() => void) | undefined; updateResizeObserver?: (() => void) | undefined; setWindow?: ((partialWindow: Pick<Window, \"innerHeight\" | \"innerWidth\">) => void) | undefined; render?: (() => IntrinsicElements) | undefined; })",
186
186
  "references": {
187
187
  "Partial": {
188
188
  "location": "global"
@@ -24,13 +24,17 @@ export class Popover {
24
24
  this.updateOnResize = false;
25
25
  this.opened = false;
26
26
  this.computedPlacement = this.placement;
27
+ this.resizeObserverFactory = (cb) => new ResizeObserver(cb);
27
28
  this.updateListener = this.updateListener.bind(this);
28
29
  this.handlePositionUpdate = this.handlePositionUpdate.bind(this);
29
30
  this.handleResize = this.handleResize.bind(this);
31
+ this.handleMiddlewareChange = this.handleMiddlewareChange.bind(this);
30
32
  this.setWindow = this.setWindow.bind(this);
33
+ this.updateResizeObserver = this.updateResizeObserver.bind(this);
31
34
  }
32
35
  connectedCallback() {
33
36
  this.updatePosition(this.position);
37
+ this.updateResizeObserver();
34
38
  }
35
39
  componentDidUpdate() {
36
40
  if (this.shouldUpdatePosition) {
@@ -52,12 +56,14 @@ export class Popover {
52
56
  }
53
57
  }
54
58
  disconnectedCallback() {
59
+ var _a;
55
60
  this.viewportWidth = undefined;
56
61
  this.viewportHeight = undefined;
57
62
  this.opened = false;
58
63
  if (this.resizeBehavior === 'dynamic') {
59
64
  window.removeEventListener('resize', this.handleResize);
60
65
  }
66
+ (_a = this.boundaryResizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
61
67
  }
62
68
  updatePosition(position) {
63
69
  if (position != null) {
@@ -81,6 +87,16 @@ export class Popover {
81
87
  updateMiddleware() {
82
88
  this.handleMiddlewareChange();
83
89
  }
90
+ updateResizeObserver() {
91
+ const observer = this.getOrCreateResizeObserver();
92
+ observer.disconnect();
93
+ if (this.boundarySelector != null) {
94
+ const element = document.querySelector(this.boundarySelector);
95
+ if (element != null) {
96
+ observer.observe(element);
97
+ }
98
+ }
99
+ }
84
100
  /**
85
101
  * @private Used for internals or testing.
86
102
  */
@@ -186,6 +202,12 @@ export class Popover {
186
202
  this.viewportWidth = this.partialWindow.innerWidth;
187
203
  this.viewportHeight = this.partialWindow.innerHeight;
188
204
  }
205
+ getOrCreateResizeObserver() {
206
+ if (this.boundaryResizeObserver == null) {
207
+ this.boundaryResizeObserver = this.resizeObserverFactory(this.handleMiddlewareChange);
208
+ }
209
+ return this.boundaryResizeObserver;
210
+ }
189
211
  getTransformClass() {
190
212
  if (this.animated) {
191
213
  switch (this.computedPlacement) {
@@ -485,6 +507,32 @@ export class Popover {
485
507
  "attribute": "update-on-resize",
486
508
  "reflect": false,
487
509
  "defaultValue": "false"
510
+ },
511
+ "resizeObserverFactory": {
512
+ "type": "unknown",
513
+ "mutable": false,
514
+ "complexType": {
515
+ "original": "(\n cb: (entries: ResizeObserverEntry[]) => void\n ) => ResizeObserver",
516
+ "resolved": "(cb: (entries: ResizeObserverEntry[]) => void) => ResizeObserver",
517
+ "references": {
518
+ "ResizeObserverEntry": {
519
+ "location": "global"
520
+ },
521
+ "ResizeObserver": {
522
+ "location": "global"
523
+ }
524
+ }
525
+ },
526
+ "required": false,
527
+ "optional": false,
528
+ "docs": {
529
+ "tags": [{
530
+ "name": "internal",
531
+ "text": undefined
532
+ }],
533
+ "text": ""
534
+ },
535
+ "defaultValue": "(cb) => new ResizeObserver(cb)"
488
536
  }
489
537
  };
490
538
  }
@@ -538,6 +586,9 @@ export class Popover {
538
586
  }, {
539
587
  "propName": "offsetBehavior",
540
588
  "methodName": "updateMiddleware"
589
+ }, {
590
+ "propName": "boundarySelector",
591
+ "methodName": "updateResizeObserver"
541
592
  }];
542
593
  }
543
594
  }
@@ -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) {
@@ -377,7 +402,26 @@ export class ResultList {
377
402
  },
378
403
  "complexType": {
379
404
  "original": "Result",
380
- "resolved": "{ [x: string]: unknown; }",
405
+ "resolved": "{ id: string; type: string; } & Record<string, unknown>",
406
+ "references": {
407
+ "Result": {
408
+ "location": "local"
409
+ }
410
+ }
411
+ }
412
+ }, {
413
+ "method": "resultClick",
414
+ "name": "resultClick",
415
+ "bubbles": true,
416
+ "cancelable": true,
417
+ "composed": true,
418
+ "docs": {
419
+ "tags": [],
420
+ "text": ""
421
+ },
422
+ "complexType": {
423
+ "original": "Result",
424
+ "resolved": "{ id: string; type: string; } & Record<string, unknown>",
381
425
  "references": {
382
426
  "Result": {
383
427
  "location": "local"
@@ -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 != null && text !== '' ? text : ' ');
12
+ };
@@ -1,21 +1,29 @@
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 createResultUrn = (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 = createResultUrn(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
+ export const trimNonstandardSpaces = (text) => {
22
+ return text.replace(/[\u200A]/g, '').replace(/[\u00A0]/g, ' ');
15
23
  };
16
- export const isReplacedElement = (el) => {
17
- return (el === null || el === void 0 ? void 0 : el.getAttribute('data-replaced')) === 'true';
24
+ const createHairSpace = () => {
25
+ return String.fromCharCode(8202);
18
26
  };
19
- export const createTextNode = (text) => {
20
- return new Text(text != null && text !== '' ? text : ' ');
27
+ const createNoBreakSpace = () => {
28
+ return String.fromCharCode(160);
21
29
  };
@@ -1,23 +1,7 @@
1
1
  .wrapper {
2
2
  display: flex;
3
- align-items: center;
4
- width: 100%;
5
- box-sizing: border-box;
6
- background: none;
7
- border: 1px solid transparent;
8
- border-radius: 4px;
9
- font-family: var(--vertex-ui-font-family);
10
- font-size: 0.875rem;
11
- line-height: 1.4;
12
- }
13
-
14
- .test-mention {
15
- display: inline-block;
16
- color: blue;
17
- }
18
-
19
- .hidden {
20
- visibility: hidden;
3
+ border: 1px solid var(--vertex-ui-neutral-600);
4
+ border-radius: 0.5rem;
21
5
  }
22
6
 
23
7
  .content-input {
@@ -33,17 +17,6 @@
33
17
  white-space: pre-line;
34
18
  }
35
19
 
36
- .textarea {
37
- overflow: hidden;
38
- outline: none;
39
- box-shadow: none;
40
- resize: none;
41
- }
42
-
43
- .content-input:focus {
44
- outline: none;
45
- }
46
-
47
20
  /* standard */
48
21
  .standard {
49
22
  border-color: var(--vertex-ui-neutral-400);