@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.
Files changed (67) hide show
  1. package/dist/cjs/components.cjs.js +1 -1
  2. package/dist/cjs/{icon-460fd0f5.js → icon-21deee4d.js} +1 -1
  3. package/dist/cjs/{icon-button-786427d6.js → icon-button-b7ed3b48.js} +1 -1
  4. package/dist/cjs/{icon-helper-ba408f49.js → icon-helper-31ee6ce0.js} +5 -0
  5. package/dist/cjs/index.cjs.js +5 -5
  6. package/dist/cjs/loader.cjs.js +1 -1
  7. package/dist/cjs/{result-list-1e592c3c.js → result-list-241ffe8d.js} +46 -2
  8. package/dist/cjs/search-bar-91cbcd07.js +421 -0
  9. package/dist/cjs/vertex-icon-button.cjs.entry.js +2 -2
  10. package/dist/cjs/vertex-icon.cjs.entry.js +2 -2
  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/collection/collection-manifest.json +1 -1
  14. package/dist/collection/components/icon/icon-helper.js +3 -0
  15. package/dist/collection/components/icon/icon.js +1 -1
  16. package/dist/collection/components/icon/icons/compare.js +2 -0
  17. package/dist/collection/components/icon-button/icon-button.js +1 -1
  18. package/dist/collection/components/result-list/result-list.js +52 -5
  19. package/dist/collection/components/result-list/types.js +1 -0
  20. package/dist/collection/components/search-bar/dom.js +12 -0
  21. package/dist/collection/components/search-bar/lib.js +35 -15
  22. package/dist/collection/components/search-bar/search-bar.css +0 -16
  23. package/dist/collection/components/search-bar/search-bar.js +380 -324
  24. package/dist/collection/types/icon.js +1 -0
  25. package/dist/collection/util/templates/element-pool.js +19 -1
  26. package/dist/components/components.esm.js +1 -1
  27. package/dist/components/index.esm.js +1 -1
  28. package/dist/components/p-1c7dc57e.js +1 -0
  29. package/dist/components/p-646ac7e7.entry.js +1 -0
  30. package/dist/components/p-6b862967.js +1 -0
  31. package/dist/components/p-cfe369bf.entry.js +1 -0
  32. package/dist/components/{p-103249b4.js → p-daabd39c.js} +1 -1
  33. package/dist/components/p-db34f10c.js +1 -0
  34. package/dist/components/p-ee496965.entry.js +1 -0
  35. package/dist/components/p-f03fe304.entry.js +1 -0
  36. package/dist/components/{p-ca52a423.js → p-fe0f0f64.js} +1 -1
  37. package/dist/esm/components.js +1 -1
  38. package/dist/esm/{icon-d37150b4.js → icon-8b8d7617.js} +1 -1
  39. package/dist/esm/{icon-button-aad3c0e7.js → icon-button-192f2555.js} +1 -1
  40. package/dist/esm/{icon-helper-83f10f73.js → icon-helper-a6be8de9.js} +5 -0
  41. package/dist/esm/index.js +5 -5
  42. package/dist/esm/loader.js +1 -1
  43. package/dist/esm/{result-list-36cfb08a.js → result-list-16c6afbd.js} +46 -2
  44. package/dist/esm/search-bar-f12a3599.js +419 -0
  45. package/dist/esm/vertex-icon-button.entry.js +2 -2
  46. package/dist/esm/vertex-icon.entry.js +2 -2
  47. package/dist/esm/vertex-result-list.entry.js +1 -1
  48. package/dist/esm/vertex-search-bar.entry.js +1 -1
  49. package/dist/types/components/icon/icons/compare.d.ts +3 -0
  50. package/dist/types/components/result-list/result-list.d.ts +6 -1
  51. package/dist/types/components/result-list/types.d.ts +4 -0
  52. package/dist/types/components/search-bar/dom.d.ts +3 -0
  53. package/dist/types/components/search-bar/lib.d.ts +24 -6
  54. package/dist/types/components/search-bar/search-bar.d.ts +124 -42
  55. package/dist/types/components.d.ts +81 -20
  56. package/dist/types/types/icon.d.ts +1 -0
  57. package/dist/types/util/templates/element-pool.d.ts +10 -1
  58. package/package.json +4 -3
  59. package/dist/cjs/search-bar-bb40cfa7.js +0 -290
  60. package/dist/components/p-03dbb28c.js +0 -1
  61. package/dist/components/p-19318fee.entry.js +0 -1
  62. package/dist/components/p-4224c2ad.js +0 -1
  63. package/dist/components/p-52739247.js +0 -1
  64. package/dist/components/p-7dba2574.entry.js +0 -1
  65. package/dist/components/p-ae6a3c46.entry.js +0 -1
  66. package/dist/components/p-f71fc166.entry.js +0 -1
  67. package/dist/esm/search-bar-59cc151d.js +0 -288
@@ -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
  }