@vertexvis/ui 0.1.0-testing.7 → 0.1.0
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/README.md +1 -1
- package/dist/cjs/{color-circle-picker-13396ec4.js → color-circle-picker-d0403f1c.js} +2 -2
- package/dist/cjs/color-picker-2a4820fa.js +46 -0
- package/dist/cjs/{color-circle-05be54bf.js → color-swatch-8aaf6c0b.js} +42 -17
- package/dist/cjs/components.cjs.js +1 -1
- package/dist/cjs/{dialog-88e2308a.js → dialog-34f1dd6e.js} +1 -1
- package/dist/cjs/dom-a2c535e3.js +17 -0
- package/dist/cjs/{icon-460fd0f5.js → icon-3b1349ea.js} +1 -1
- package/dist/cjs/{icon-button-786427d6.js → icon-button-19061994.js} +1 -1
- package/dist/cjs/{icon-helper-ba408f49.js → icon-helper-cb479ba1.js} +107 -0
- package/dist/cjs/index.cjs.js +18 -12
- package/dist/cjs/lib-1bd1e383.js +9 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{search-bar-1edc045f.js → search-bar-2e7ee35a.js} +177 -51
- package/dist/cjs/{select-5f8aecfe.js → select-2b2bdb97.js} +1 -1
- package/dist/cjs/{slider-13594e49.js → slider-7714cccb.js} +7 -1
- package/dist/cjs/tab-4335cd8f.js +26 -0
- package/dist/cjs/tabs-6f3e76e1.js +111 -0
- package/dist/cjs/{tooltip-e9f63631.js → tooltip-9d097c55.js} +2 -5
- package/dist/cjs/vertex-color-circle-picker.cjs.entry.js +1 -1
- package/dist/cjs/vertex-color-picker.cjs.entry.js +2 -1
- package/dist/cjs/vertex-color-swatch.cjs.entry.js +12 -0
- package/dist/cjs/vertex-dialog.cjs.entry.js +1 -1
- 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-search-bar.cjs.entry.js +1 -1
- package/dist/cjs/vertex-select.cjs.entry.js +1 -1
- package/dist/cjs/vertex-slider.cjs.entry.js +2 -1
- package/dist/cjs/{vertex-color-circle.cjs.entry.js → vertex-tab.cjs.entry.js} +3 -2
- package/dist/cjs/vertex-tabs.cjs.entry.js +12 -0
- package/dist/cjs/vertex-tooltip.cjs.entry.js +2 -1
- package/dist/collection/collection-manifest.json +5 -3
- package/dist/collection/components/color-circle-picker/color-circle-picker.js +8 -8
- package/dist/collection/components/color-picker/color-picker.css +95 -15
- package/dist/collection/components/color-picker/color-picker.js +57 -3
- package/dist/collection/components/color-swatch/color-swatch.css +43 -0
- package/dist/collection/components/{color-circle/color-circle.js → color-swatch/color-swatch.js} +96 -23
- package/dist/collection/components/color-swatch/lib.js +5 -0
- package/dist/collection/components/dialog/dialog.css +0 -1
- package/dist/collection/components/icon/icon-helper.js +51 -0
- package/dist/collection/components/icon/icon.js +1 -1
- package/dist/collection/components/icon/icons/arrow-left-circled.js +2 -0
- package/dist/collection/components/icon/icons/arrow-right-circled.js +2 -0
- package/dist/collection/components/icon/icons/camera-add.js +2 -0
- package/dist/collection/components/icon/icons/caution.js +2 -0
- package/dist/collection/components/icon/icons/columns-add.js +2 -0
- package/dist/collection/components/icon/icons/compare.js +2 -0
- package/dist/collection/components/icon/icons/compress.js +2 -0
- package/dist/collection/components/icon/icons/cube-stack.js +2 -0
- package/dist/collection/components/icon/icons/expand.js +2 -0
- package/dist/collection/components/icon/icons/file-folder.js +2 -0
- package/dist/collection/components/icon/icons/pin-text-square.js +2 -0
- package/dist/collection/components/icon/icons/plus-with-arrow.js +2 -0
- package/dist/collection/components/icon/icons/pmi.js +2 -0
- package/dist/collection/components/icon/icons/report.js +2 -0
- package/dist/collection/components/icon/icons/square-dot-outline.js +2 -0
- package/dist/collection/components/icon/icons/update.js +2 -0
- package/dist/collection/components/icon/icons/views.js +2 -0
- package/dist/collection/components/icon-button/icon-button.js +1 -1
- package/dist/collection/components/index.js +3 -1
- package/dist/collection/components/result-list/result-list.js +6 -3
- package/dist/collection/components/result-list/types.js +1 -0
- package/dist/collection/components/search-bar/dom.js +18 -1
- package/dist/collection/components/search-bar/lib.js +57 -4
- package/dist/collection/components/search-bar/search-bar.css +13 -2
- package/dist/collection/components/search-bar/search-bar.js +112 -51
- package/dist/collection/components/select/select.css +8 -0
- package/dist/collection/components/slider/slider.js +8 -2
- package/dist/collection/components/tab/tab.css +16 -0
- package/dist/collection/components/tab/tab.js +85 -0
- package/dist/collection/components/tab/util.js +3 -0
- package/dist/collection/components/tabs/tabs.css +67 -0
- package/dist/collection/components/tabs/tabs.js +159 -0
- package/dist/collection/types/icon.js +17 -0
- package/dist/collection/util/components/dom.js +3 -0
- 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-01d4be1d.entry.js +1 -0
- package/dist/components/{p-165aed7d.js → p-0d4a0d61.js} +1 -1
- package/dist/components/p-18ed73e9.js +1 -0
- package/dist/components/p-1d08dd79.entry.js +1 -0
- package/dist/components/p-2ae8175d.entry.js +1 -0
- package/dist/components/p-2b4aedaa.entry.js +1 -0
- package/dist/components/p-3438c441.js +1 -0
- package/dist/components/{p-912f6e24.js → p-4327deea.js} +1 -1
- package/dist/components/p-45848878.js +1 -0
- package/dist/components/p-48629bf1.js +1 -0
- package/dist/components/{p-103249b4.js → p-5384f198.js} +1 -1
- package/dist/components/p-655053df.js +1 -0
- package/dist/components/p-65f9817e.js +1 -0
- package/dist/components/p-6a49c365.entry.js +1 -0
- package/dist/components/p-6b6c2260.js +1 -0
- package/dist/components/p-6ff20817.js +1 -0
- package/dist/components/{p-ca52a423.js → p-7bd92281.js} +1 -1
- package/dist/components/p-8bbc344d.entry.js +1 -0
- package/dist/components/p-8d83dfff.entry.js +1 -0
- package/dist/components/p-96f55673.js +1 -0
- package/dist/components/{p-9374ef6c.js → p-b9dab446.js} +1 -1
- package/dist/components/p-c6841378.entry.js +1 -0
- package/dist/components/p-cbfc041e.entry.js +1 -0
- package/dist/components/p-d2d75bcf.entry.js +1 -0
- package/dist/components/p-d539f530.js +1 -0
- package/dist/components/p-decf635f.entry.js +1 -0
- package/dist/components/p-e35057b5.entry.js +1 -0
- package/dist/esm/{color-circle-picker-998a7e9c.js → color-circle-picker-35ad3b3e.js} +2 -2
- package/dist/esm/color-picker-1d67effe.js +44 -0
- package/dist/esm/{color-circle-842f3321.js → color-swatch-0e62d13d.js} +42 -17
- package/dist/esm/components.js +1 -1
- package/dist/esm/{dialog-e3f49527.js → dialog-1cef715c.js} +1 -1
- package/dist/esm/dom-9d0f7bf4.js +13 -0
- package/dist/esm/{icon-d37150b4.js → icon-bf8df898.js} +1 -1
- package/dist/esm/{icon-button-aad3c0e7.js → icon-button-a4bdeabc.js} +1 -1
- package/dist/esm/{icon-helper-83f10f73.js → icon-helper-94d45002.js} +107 -0
- package/dist/esm/index.js +15 -11
- package/dist/esm/lib-73fbca8b.js +7 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{search-bar-cb59da12.js → search-bar-8d18626e.js} +177 -51
- package/dist/esm/{select-d4e135b7.js → select-78aeff96.js} +1 -1
- package/dist/esm/{slider-dcdb388f.js → slider-3d8545e3.js} +8 -2
- package/dist/esm/tab-c76332b0.js +24 -0
- package/dist/esm/tabs-e9f6dcbe.js +109 -0
- package/dist/esm/{tooltip-933da261.js → tooltip-db8ebd41.js} +1 -4
- package/dist/esm/vertex-color-circle-picker.entry.js +1 -1
- package/dist/esm/vertex-color-picker.entry.js +2 -1
- package/dist/esm/vertex-color-swatch.entry.js +4 -0
- package/dist/esm/vertex-dialog.entry.js +1 -1
- package/dist/esm/vertex-icon-button.entry.js +2 -2
- package/dist/esm/vertex-icon.entry.js +2 -2
- package/dist/esm/vertex-search-bar.entry.js +1 -1
- package/dist/esm/vertex-select.entry.js +1 -1
- package/dist/esm/vertex-slider.entry.js +2 -1
- package/dist/esm/vertex-tab.entry.js +3 -0
- package/dist/esm/vertex-tabs.entry.js +4 -0
- package/dist/esm/vertex-tooltip.entry.js +2 -1
- package/dist/types/components/color-circle-picker/color-circle-picker.d.ts +7 -7
- package/dist/types/components/color-picker/color-picker.d.ts +19 -0
- package/dist/types/components/{color-circle/color-circle.d.ts → color-swatch/color-swatch.d.ts} +23 -5
- package/dist/types/components/color-swatch/lib.d.ts +1 -0
- package/dist/types/components/icon/icons/arrow-left-circled.d.ts +3 -0
- package/dist/types/components/icon/icons/arrow-right-circled.d.ts +3 -0
- package/dist/types/components/icon/icons/camera-add.d.ts +3 -0
- package/dist/types/components/icon/icons/caution.d.ts +3 -0
- package/dist/types/components/icon/icons/columns-add.d.ts +3 -0
- package/dist/types/components/icon/icons/compare.d.ts +3 -0
- package/dist/types/components/icon/icons/compress.d.ts +3 -0
- package/dist/types/components/icon/icons/cube-stack.d.ts +3 -0
- package/dist/types/components/icon/icons/expand.d.ts +3 -0
- package/dist/types/components/icon/icons/file-folder.d.ts +3 -0
- package/dist/types/components/icon/icons/pin-text-square.d.ts +3 -0
- package/dist/types/components/icon/icons/plus-with-arrow.d.ts +3 -0
- package/dist/types/components/icon/icons/pmi.d.ts +3 -0
- package/dist/types/components/icon/icons/report.d.ts +3 -0
- package/dist/types/components/icon/icons/square-dot-outline.d.ts +3 -0
- package/dist/types/components/icon/icons/update.d.ts +3 -0
- package/dist/types/components/icon/icons/views.d.ts +3 -0
- package/dist/types/components/index.d.ts +3 -1
- package/dist/types/components/result-list/result-list.d.ts +1 -4
- package/dist/types/components/result-list/types.d.ts +4 -0
- package/dist/types/components/search-bar/dom.d.ts +6 -1
- package/dist/types/components/search-bar/lib.d.ts +22 -3
- package/dist/types/components/search-bar/search-bar.d.ts +18 -2
- package/dist/types/components/slider/slider.d.ts +1 -0
- package/dist/types/components/tab/tab.d.ts +11 -0
- package/dist/types/components/tab/util.d.ts +1 -0
- package/dist/types/components/tabs/tabs.d.ts +23 -0
- package/dist/types/components.d.ts +168 -83
- package/dist/types/types/icon.d.ts +17 -0
- package/dist/types/util/components/dom.d.ts +1 -0
- package/package.json +2 -2
- package/dist/cjs/color-picker-876ace00.js +0 -37
- package/dist/collection/components/color-circle/color-circle.css +0 -18
- package/dist/components/p-03dbb28c.js +0 -1
- package/dist/components/p-0b1cdc8a.entry.js +0 -1
- package/dist/components/p-0f8b9ede.entry.js +0 -1
- package/dist/components/p-16719272.entry.js +0 -1
- package/dist/components/p-20a74d5d.entry.js +0 -1
- package/dist/components/p-35e7ab78.entry.js +0 -1
- package/dist/components/p-759f1655.js +0 -1
- package/dist/components/p-7cfb3736.entry.js +0 -1
- package/dist/components/p-7dba2574.entry.js +0 -1
- package/dist/components/p-7f42b27b.entry.js +0 -1
- package/dist/components/p-7f64b251.entry.js +0 -1
- package/dist/components/p-8434602f.js +0 -1
- package/dist/components/p-92930f2a.js +0 -1
- package/dist/components/p-cd6ddb10.js +0 -1
- package/dist/components/p-d9b9aebe.js +0 -1
- package/dist/components/p-f71fc166.entry.js +0 -1
- package/dist/esm/color-picker-2e3b51fa.js +0 -35
- package/dist/esm/vertex-color-circle.entry.js +0 -2
|
@@ -53,11 +53,23 @@ const getWindowSelection = () => {
|
|
|
53
53
|
}
|
|
54
54
|
return undefined;
|
|
55
55
|
};
|
|
56
|
+
const nodeHasChildNodes = (node) => {
|
|
57
|
+
return node.hasChildNodes();
|
|
58
|
+
};
|
|
56
59
|
const createDocumentRange = () => {
|
|
57
60
|
return document.createRange();
|
|
58
61
|
};
|
|
59
62
|
const createTextNode = (text) => {
|
|
60
|
-
return new Text(text
|
|
63
|
+
return new Text(text);
|
|
64
|
+
};
|
|
65
|
+
const createBreak = () => {
|
|
66
|
+
return document.createElement('br');
|
|
67
|
+
};
|
|
68
|
+
const isHtmlElement = (node) => {
|
|
69
|
+
return node instanceof HTMLElement;
|
|
70
|
+
};
|
|
71
|
+
const isBrElement = (node) => {
|
|
72
|
+
return node instanceof HTMLBRElement;
|
|
61
73
|
};
|
|
62
74
|
|
|
63
75
|
const createResultUri = (result) => {
|
|
@@ -69,16 +81,69 @@ const createSearchResultReplacement = (result, before, after) => {
|
|
|
69
81
|
before: createTextNode(before),
|
|
70
82
|
beforeSpace: createTextNode(createHairSpace()),
|
|
71
83
|
result: createTextNode(urn),
|
|
72
|
-
afterSpace: after != null
|
|
84
|
+
afterSpace: after != null
|
|
85
|
+
? createTextNode(createNoBreakSpace())
|
|
86
|
+
: createTextNode(createHairSpace()),
|
|
73
87
|
after: after != null ? createTextNode(after) : undefined,
|
|
74
88
|
};
|
|
75
89
|
};
|
|
76
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Newline characters and spaces are represented slightly differently within a
|
|
92
|
+
* content editable element between browsers. This method standardizes the
|
|
93
|
+
* representation of those characters to avoid having to write branching logic
|
|
94
|
+
* to support each individual browser.
|
|
95
|
+
*/
|
|
96
|
+
const standardizeNewlinesAndSpaces = (node) => {
|
|
97
|
+
const content = node.textContent;
|
|
98
|
+
if (content === '\n') {
|
|
99
|
+
return [createBreak()];
|
|
100
|
+
}
|
|
101
|
+
else if (content != null && content.includes('\n')) {
|
|
102
|
+
const split = content.split('\n');
|
|
103
|
+
return split.reduce((res, substr, i) => {
|
|
104
|
+
const previous = split[i - 1];
|
|
105
|
+
// Ignore the empty string if the prior element was converted
|
|
106
|
+
// to a breaking element to prevent duplication of newlines.
|
|
107
|
+
if (substr === '' && previous !== '') {
|
|
108
|
+
return res;
|
|
109
|
+
}
|
|
110
|
+
return [
|
|
111
|
+
...res,
|
|
112
|
+
// Standard spaces are not always respected with in `Text`
|
|
113
|
+
// elements when appended to a contenteditable element. This
|
|
114
|
+
// conversion preserves that spacing.
|
|
115
|
+
createTextNode(substr.replace(/ /g, createNoBreakSpace())),
|
|
116
|
+
createBreak(),
|
|
117
|
+
];
|
|
118
|
+
}, []);
|
|
119
|
+
}
|
|
120
|
+
return [node];
|
|
121
|
+
};
|
|
122
|
+
const getNodesForSearchResultReplacement = (replacement, isBreaking = false) => {
|
|
77
123
|
const keys = Object.keys(replacement);
|
|
78
|
-
|
|
124
|
+
const replacementElements = keys
|
|
79
125
|
.map((key) => replacement[key])
|
|
80
126
|
.filter((node) => node != null);
|
|
127
|
+
// If the element is intended to replace a breaking element such
|
|
128
|
+
// as a `<div>` wrapper, a newline is required alongside the standard
|
|
129
|
+
// replacement elements.
|
|
130
|
+
if (isBreaking) {
|
|
131
|
+
return [createTextNode('\n'), ...replacementElements];
|
|
132
|
+
}
|
|
133
|
+
return replacementElements;
|
|
81
134
|
};
|
|
135
|
+
/**
|
|
136
|
+
* We leverage a couple unique spaces to represent mentions, allowing for
|
|
137
|
+
* correct cursor movement when using arrow keys. As these characters are
|
|
138
|
+
* purely for functional behavior of the input, `trimNonstandardSpaces`
|
|
139
|
+
* will remove them so the input is suitable for emitting.
|
|
140
|
+
*
|
|
141
|
+
* U+200A is a "Hair Space" which acts as a space, but is not visually
|
|
142
|
+
* represented as one.
|
|
143
|
+
*
|
|
144
|
+
* U+00A0 is a "No-Break Space" which is commonly added by browsers
|
|
145
|
+
* when interacting with a contenteditable element.
|
|
146
|
+
*/
|
|
82
147
|
const trimNonstandardSpaces = (text) => {
|
|
83
148
|
return text.replace(/[\u200A]/g, '').replace(/[\u00A0]/g, ' ');
|
|
84
149
|
};
|
|
@@ -89,7 +154,7 @@ const createNoBreakSpace = () => {
|
|
|
89
154
|
return String.fromCharCode(160);
|
|
90
155
|
};
|
|
91
156
|
|
|
92
|
-
const searchBarCss = ".wrapper.sc-vertex-search-bar{display:flex;border:1px solid var(--vertex-ui-
|
|
157
|
+
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)}";
|
|
93
158
|
|
|
94
159
|
const SearchBar = class {
|
|
95
160
|
constructor(hostRef) {
|
|
@@ -100,42 +165,73 @@ const SearchBar = class {
|
|
|
100
165
|
this.inputFocus = createEvent(this, "inputFocus", 7);
|
|
101
166
|
this.inputBlur = createEvent(this, "inputBlur", 7);
|
|
102
167
|
this.rawElements = [];
|
|
168
|
+
this.attemptReplaceElement = (child, other, replacement, isBreaking = false) => {
|
|
169
|
+
// In the case that the child we're evaluating has its own children
|
|
170
|
+
// (often a wrapper `<div>`), we want to evaluate whether any of its
|
|
171
|
+
// children is the target to replace.
|
|
172
|
+
if (nodeHasChildNodes(child) &&
|
|
173
|
+
Array.from(child.childNodes).some((c) => nodeHasChildNodes(c) || this.isIdenticalElement(c, other))) {
|
|
174
|
+
return Array.from(child.childNodes).reduce((res, c) => [
|
|
175
|
+
...res,
|
|
176
|
+
...this.attemptReplaceElement(c, other, replacement,
|
|
177
|
+
// If the element we're evaluating is a wrapper, we want to
|
|
178
|
+
// consider it a breaking element and add a newline to the
|
|
179
|
+
// replaced element only if the previous node is a `Text` node.
|
|
180
|
+
!isHtmlElement(child.previousSibling)),
|
|
181
|
+
], []);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
return this.isIdenticalElement(child, other)
|
|
185
|
+
? getNodesForSearchResultReplacement(replacement, isBreaking)
|
|
186
|
+
: [child];
|
|
187
|
+
}
|
|
188
|
+
};
|
|
103
189
|
this.isIdenticalElement = (child, other) => {
|
|
104
190
|
return (child === this.triggeredElement ||
|
|
105
191
|
this.getTextContent(child) === this.getTextContent(other));
|
|
106
192
|
};
|
|
107
193
|
this.getTextContent = (node) => {
|
|
108
194
|
var _a;
|
|
109
|
-
if (node
|
|
195
|
+
if (isHtmlElement(node)) {
|
|
110
196
|
return node.innerText;
|
|
111
197
|
}
|
|
112
198
|
return (_a = node.textContent) !== null && _a !== void 0 ? _a : '';
|
|
113
199
|
};
|
|
200
|
+
/**
|
|
201
|
+
* Inspects the cursor position for the following conditions:
|
|
202
|
+
*
|
|
203
|
+
* 1. The cursor has moved to text that contains a valid string
|
|
204
|
+
* and trigger character, indicating we need to dispatch a
|
|
205
|
+
* `searchChanged` event and display the results.
|
|
206
|
+
*
|
|
207
|
+
* 2. The cursor has moved within text that contains a valid string
|
|
208
|
+
* and trigger character, indicating we need to dispatch a
|
|
209
|
+
* `searchChanged` event to update the currently displayed results.
|
|
210
|
+
*
|
|
211
|
+
* 3. The cursor has moved to text that does not contain a valid
|
|
212
|
+
* string and trigger character, indicating we need to hide any
|
|
213
|
+
* displayed search results.
|
|
214
|
+
*/
|
|
114
215
|
this.handleCursorPositionUpdate = () => {
|
|
115
|
-
var _a, _b
|
|
216
|
+
var _a, _b;
|
|
116
217
|
const windowRange = (_a = getWindowSelection()) === null || _a === void 0 ? void 0 : _a.getRangeAt(0);
|
|
117
218
|
if (windowRange != null) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
125
|
-
}
|
|
219
|
+
const triggerText = this.readTriggerValue((_b = windowRange.commonAncestorContainer.textContent) !== null && _b !== void 0 ? _b : '', windowRange.startOffset);
|
|
220
|
+
if (!this.hasTriggered && triggerText != null) {
|
|
221
|
+
this.hasTriggered = true;
|
|
222
|
+
this.triggeredRange = windowRange;
|
|
223
|
+
this.triggeredElement = windowRange.commonAncestorContainer;
|
|
224
|
+
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
126
225
|
}
|
|
127
|
-
else if (this.hasTriggered) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.triggeredRange = undefined;
|
|
137
|
-
this.triggeredElement = undefined;
|
|
138
|
-
}
|
|
226
|
+
else if (this.hasTriggered && triggerText != null) {
|
|
227
|
+
this.triggeredRange = windowRange;
|
|
228
|
+
this.triggeredElement = windowRange.commonAncestorContainer;
|
|
229
|
+
this.searchChanged.emit(triggerText.replace(this.triggerCharacter, ''));
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
this.hasTriggered = false;
|
|
233
|
+
this.triggeredRange = undefined;
|
|
234
|
+
this.triggeredElement = undefined;
|
|
139
235
|
}
|
|
140
236
|
}
|
|
141
237
|
this.cursorPosition = this.getCursorPosition();
|
|
@@ -173,21 +269,54 @@ const SearchBar = class {
|
|
|
173
269
|
selection.addRange(range);
|
|
174
270
|
}
|
|
175
271
|
};
|
|
176
|
-
this.getContentAsString = () => {
|
|
177
|
-
if (
|
|
178
|
-
|
|
272
|
+
this.getContentAsString = (element) => {
|
|
273
|
+
if (element != null) {
|
|
274
|
+
const res = trimNonstandardSpaces(Array.from(element.childNodes).reduce((res, n) => {
|
|
179
275
|
var _a;
|
|
180
|
-
|
|
181
|
-
|
|
276
|
+
const previousSiblingIsBlock = n.previousSibling == null || isHtmlElement(n.previousSibling);
|
|
277
|
+
if (isHtmlElement(n) && n.getAttribute('data-replaced') === 'true') {
|
|
278
|
+
/**
|
|
279
|
+
* If an element has been replaced visually, append the original
|
|
280
|
+
* value prior to being replaced.
|
|
281
|
+
*/
|
|
182
282
|
return `${res}${n.getAttribute('data-original')}`;
|
|
183
283
|
}
|
|
184
|
-
else if (n
|
|
185
|
-
|
|
284
|
+
else if (isHtmlElement(n) && n.childElementCount > 0) {
|
|
285
|
+
/**
|
|
286
|
+
* If an element is a wrapper, we want to treat it as a block element,
|
|
287
|
+
* ensuring newlines before and after the content.
|
|
288
|
+
* Additionally, we want to evaluate each of its children independently.
|
|
289
|
+
* Some browsers will conditionally wrap content in additional wrapper
|
|
290
|
+
* elements we need to unravel.
|
|
291
|
+
*/
|
|
292
|
+
return `${res}${previousSiblingIsBlock ? '' : '\n'}${this.getContentAsString(n)}`;
|
|
293
|
+
}
|
|
294
|
+
else if (isBrElement(n)) {
|
|
295
|
+
/**
|
|
296
|
+
* If an element is a `<br>` element, we want to simply represent
|
|
297
|
+
* it as a newline in the returned string.
|
|
298
|
+
*/
|
|
299
|
+
return `${res}\n`;
|
|
300
|
+
}
|
|
301
|
+
else if (isHtmlElement(n)) {
|
|
302
|
+
/**
|
|
303
|
+
* If an element is a wrapper, we want to treat it as a block element,
|
|
304
|
+
* ensuring newlines before and after the content.
|
|
305
|
+
* If the prior element is also to be treated as a block format, we
|
|
306
|
+
* will omit the newline before the content to avoid duplicating the
|
|
307
|
+
* behavior.
|
|
308
|
+
*/
|
|
309
|
+
return `${res}${previousSiblingIsBlock ? '' : '\n'}${n.innerText}\n`;
|
|
186
310
|
}
|
|
187
311
|
else {
|
|
312
|
+
/**
|
|
313
|
+
* If a node is simply a `Text` node, we just want to append the text
|
|
314
|
+
* if defined.
|
|
315
|
+
*/
|
|
188
316
|
return `${res}${(_a = n.textContent) !== null && _a !== void 0 ? _a : ''}`;
|
|
189
317
|
}
|
|
190
318
|
}, ''));
|
|
319
|
+
return res;
|
|
191
320
|
}
|
|
192
321
|
return '';
|
|
193
322
|
};
|
|
@@ -218,7 +347,7 @@ const SearchBar = class {
|
|
|
218
347
|
this.placeholder = undefined;
|
|
219
348
|
this.replacements = [];
|
|
220
349
|
this.replacementUriType = 'user';
|
|
221
|
-
this.cursorPosition =
|
|
350
|
+
this.cursorPosition = undefined;
|
|
222
351
|
this.displayedElements = [];
|
|
223
352
|
this.hasTriggered = false;
|
|
224
353
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
@@ -263,12 +392,13 @@ const SearchBar = class {
|
|
|
263
392
|
replacement.before,
|
|
264
393
|
replacement.beforeSpace,
|
|
265
394
|
replacement.result,
|
|
395
|
+
replacement.afterSpace,
|
|
266
396
|
];
|
|
267
397
|
}
|
|
268
398
|
return res;
|
|
269
399
|
}, [])
|
|
270
400
|
: [];
|
|
271
|
-
this.rawElements = [...parts, createTextNode(nextSubstr)];
|
|
401
|
+
this.rawElements = [...parts, createTextNode(nextSubstr)].reduce((res, p) => [...res, ...standardizeNewlinesAndSpaces(p)], []);
|
|
272
402
|
this.updateContent(this.replacements);
|
|
273
403
|
}
|
|
274
404
|
}
|
|
@@ -276,9 +406,8 @@ const SearchBar = class {
|
|
|
276
406
|
if (this.contentEl != null && !fastDeepEqual(newValue, oldValue)) {
|
|
277
407
|
this.contentEl.innerHTML = '';
|
|
278
408
|
this.displayedElements = this.rawElements.map((el) => {
|
|
279
|
-
const raw = el
|
|
409
|
+
const raw = isHtmlElement(el) ? el.innerText : el.textContent;
|
|
280
410
|
const replacement = this.replacements.find((r) => raw === null || raw === void 0 ? void 0 : raw.includes(createResultUri(r)));
|
|
281
|
-
console.log(raw);
|
|
282
411
|
if (raw != null && replacement != null) {
|
|
283
412
|
const replacementElement = this.createReplacedElement(raw, replacement);
|
|
284
413
|
return replacementElement;
|
|
@@ -292,7 +421,7 @@ const SearchBar = class {
|
|
|
292
421
|
if (this.lastReplacedSpace != null) {
|
|
293
422
|
this.moveCursorToNodeEnd(this.lastReplacedSpace);
|
|
294
423
|
}
|
|
295
|
-
this.inputChanged.emit(this.getContentAsString());
|
|
424
|
+
this.inputChanged.emit(this.getContentAsString(this.contentEl));
|
|
296
425
|
}
|
|
297
426
|
}
|
|
298
427
|
render() {
|
|
@@ -304,7 +433,7 @@ const SearchBar = class {
|
|
|
304
433
|
blank: this.variant === 'blank',
|
|
305
434
|
disabled: this.disabled,
|
|
306
435
|
});
|
|
307
|
-
return (h(Host, null, h("div", { class: classes }, 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.
|
|
436
|
+
return (h(Host, null, h("div", { class: classes }, 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.handleKeyUp, onClick: this.handleCursorPositionUpdate, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur })), h("vertex-result-list", { position: this.cursorPosition, placement: this.placement, open: this.hasTriggered &&
|
|
308
437
|
this.resultItems != null &&
|
|
309
438
|
this.resultItems.length > 0, items: (_a = this.resultItems) !== null && _a !== void 0 ? _a : [], onEnterPressed: this.handleResultClick, onResultClick: this.handleResultClick }, h("slot", { name: "results" })), h("slot", { name: "replaced" })));
|
|
310
439
|
}
|
|
@@ -320,13 +449,13 @@ const SearchBar = class {
|
|
|
320
449
|
this.cursorPosition = this.getCursorPosition();
|
|
321
450
|
}
|
|
322
451
|
async handleInput() {
|
|
323
|
-
this.inputChanged.emit(this.getContentAsString());
|
|
452
|
+
this.inputChanged.emit(this.getContentAsString(this.contentEl));
|
|
324
453
|
}
|
|
325
454
|
handleClick() {
|
|
326
455
|
this.handleCursorPositionUpdate();
|
|
327
456
|
}
|
|
328
457
|
handleWindowClick(event) {
|
|
329
|
-
if (event.target
|
|
458
|
+
if (isHtmlElement(event.target) &&
|
|
330
459
|
event.target.getAttribute('data-replaced') === 'true' &&
|
|
331
460
|
event.target.nextSibling != null) {
|
|
332
461
|
this.moveCursorToNodeEnd(event.target.nextSibling, true);
|
|
@@ -343,7 +472,7 @@ const SearchBar = class {
|
|
|
343
472
|
var _a;
|
|
344
473
|
const triggeredRange = this.triggeredRange;
|
|
345
474
|
const triggeredElement = this.triggeredElement;
|
|
346
|
-
const value = triggeredElement
|
|
475
|
+
const value = isHtmlElement(triggeredElement)
|
|
347
476
|
? triggeredElement.innerText
|
|
348
477
|
: triggeredElement === null || triggeredElement === void 0 ? void 0 : triggeredElement.textContent;
|
|
349
478
|
if (this.contentEl != null &&
|
|
@@ -357,20 +486,17 @@ const SearchBar = class {
|
|
|
357
486
|
const replacement = createSearchResultReplacement(event.detail, before, after);
|
|
358
487
|
this.lastReplacedSpace = replacement.afterSpace;
|
|
359
488
|
this.rawElements = Array.from(this.contentEl.childNodes).reduce((re, e) => {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
else {
|
|
365
|
-
return [...re, e];
|
|
366
|
-
}
|
|
489
|
+
return [
|
|
490
|
+
...re,
|
|
491
|
+
...this.attemptReplaceElement(e, triggeredElement, replacement),
|
|
492
|
+
];
|
|
367
493
|
}, []);
|
|
368
494
|
this.hasTriggered = false;
|
|
495
|
+
this.resultReplaced.emit(event.detail);
|
|
369
496
|
this.replacements = [
|
|
370
497
|
...this.replacements.filter((r) => r.id !== event.detail.id),
|
|
371
498
|
event.detail,
|
|
372
499
|
];
|
|
373
|
-
this.resultReplaced.emit(event.detail);
|
|
374
500
|
}
|
|
375
501
|
}
|
|
376
502
|
getCursorPosition() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as registerInstance, e as createEvent, h, c as readTask, g as getElement } from './index-72f28b71.js';
|
|
2
2
|
import { c as classnames } from './index-9c609209.js';
|
|
3
3
|
|
|
4
|
-
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}";
|
|
4
|
+
const selectCss = ":host{--select-width:100%;--select-option-white-space:normal;--max-dropdown-height:80vh}.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%);max-height:var(--max-dropdown-height);overflow-y:auto}.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}";
|
|
5
5
|
|
|
6
6
|
const GET_BOUNDS_DEBOUNCE_THRESHOLD = 200;
|
|
7
7
|
const Select = class {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { r as registerInstance, e as createEvent, h } from './index-72f28b71.js';
|
|
1
|
+
import { r as registerInstance, e as createEvent, h, g as getElement } from './index-72f28b71.js';
|
|
2
2
|
import { c as classnames } from './index-9c609209.js';
|
|
3
|
+
import { b as blurElement } from './dom-9d0f7bf4.js';
|
|
3
4
|
|
|
4
5
|
const sliderCss = ":host{display:flex;--vertex-slider-track-color:var(--vertex-ui-neutral-400);--vertex-slider-thumb-color:var(--vertex-ui-blue-700)}:host([size=\"sm\"]){height:12px}:host([size=\"md\"]){height:14px}:host([size=\"lg\"]){height:16px}.input{-webkit-appearance:none;width:100%;height:100%;background:transparent;margin:0}.input:not(.disabled){cursor:pointer}.input.sm{height:12px}.input.md{height:14px}.input.lg{height:16px}.input.disabled{opacity:0.5}.tooltip{width:100%}.input::-webkit-slider-runnable-track{width:100%;height:2px;cursor:default;background:var(--vertex-slider-track-color);border-radius:1px}.input::-moz-range-track{width:100%;height:2px;cursor:default;background:var(--vertex-slider-track-color);border-radius:1px}.input::-ms-track{width:100%;height:2px;cursor:default;background:var(--vertex-slider-track-color);border-radius:1px}.input:not(.disabled)::-webkit-slider-runnable-track{cursor:pointer}.input:not(.disabled)::-moz-range-track{cursor:pointer}.input:not(.disabled)::-ms-track{cursor:pointer}.input.sm::-webkit-slider-thumb{height:12px;width:12px;margin-top:-5px}.input.sm::-moz-range-thumb{height:12px;width:12px;margin-top:-5px}.input.sm::-ms-thumb{height:12px;width:12px;margin-top:-5px}.input.md::-webkit-slider-thumb{height:14px;width:14px;margin-top:-6px}.input.md::-moz-range-thumb{height:14px;width:14px;margin-top:-6px}.input.md::-ms-thumb{height:14px;width:14px;margin-top:-6px}.input.lg::-webkit-slider-thumb{height:16px;width:16px;margin-top:-7px}.input.lg::-moz-range-thumb{height:16px;width:16px;margin-top:-7px}.input.lg::-ms-thumb{height:16px;width:16px;margin-top:-7px}.input::-webkit-slider-thumb{-webkit-appearance:none;border-radius:50%;background:var(--vertex-slider-thumb-color);border:none;cursor:default}.input::-moz-range-thumb{-webkit-appearance:none;border-radius:50%;background:var(--vertex-slider-thumb-color);border:none;cursor:default}.input::-ms-thumb{-webkit-appearance:none;border-radius:50%;background:var(--vertex-slider-thumb-color);border:none;cursor:default}.input:not(.disabled)::-webkit-slider-thumb{cursor:grab}.input:not(.disabled)::-moz-range-thumb{cursor:grab}.input:not(.disabled)::-ms-thumb{cursor:grab}.input::-webkit-slider-thumb:active{cursor:grabbing;box-shadow:0 1px 2px var(--vertex-ui-black)}.input::-moz-range-thumb:active{cursor:grabbing;box-shadow:0 1px 2px var(--vertex-ui-black)}.input::-ms-thumb:active{cursor:grabbing;box-shadow:0 1px 2px var(--vertex-ui-black)}";
|
|
5
6
|
|
|
@@ -25,11 +26,16 @@ const Slider = class {
|
|
|
25
26
|
this.disabled = false;
|
|
26
27
|
}
|
|
27
28
|
render() {
|
|
28
|
-
return (h("vertex-tooltip", { disabled: this.valueLabelDisplay === 'off', content: `${this.value}`, placement: 'top', class: "tooltip" }, h("input", { class: classnames('input', { disabled: this.disabled }, this.size), type: "range", disabled: this.disabled, min: this.min, max: this.max, step: this.step, value: this.value, onChange: this.handleChange, onInput: this.handleInput
|
|
29
|
+
return (h("vertex-tooltip", { disabled: this.valueLabelDisplay === 'off', content: `${this.value}`, placement: 'top', class: "tooltip" }, h("input", { class: classnames('input', { disabled: this.disabled }, this.size), type: "range", disabled: this.disabled, min: this.min, max: this.max, step: this.step, value: this.value, onChange: this.handleChange, onInput: this.handleInput, onPointerUp: () => {
|
|
30
|
+
// Blur the slider on pointerup to prevent an issue where pressing
|
|
31
|
+
// any key on the keyboard would result in a focus state.
|
|
32
|
+
blurElement(this.hostEl);
|
|
33
|
+
} })));
|
|
29
34
|
}
|
|
30
35
|
updateValueFromEvent(event) {
|
|
31
36
|
this.value = event.target.valueAsNumber;
|
|
32
37
|
}
|
|
38
|
+
get hostEl() { return getElement(this); }
|
|
33
39
|
};
|
|
34
40
|
Slider.style = sliderCss;
|
|
35
41
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { r as registerInstance, e as createEvent, h, H as Host } from './index-72f28b71.js';
|
|
2
|
+
import { c as classnames } from './index-9c609209.js';
|
|
3
|
+
|
|
4
|
+
const tabCss = ":host{position:relative;width:100%;height:100%}.content{display:none;height:0px}.content.active{display:flex;width:100%;height:100%}";
|
|
5
|
+
|
|
6
|
+
const Tab = class {
|
|
7
|
+
constructor(hostRef) {
|
|
8
|
+
registerInstance(this, hostRef);
|
|
9
|
+
this.tabClick = createEvent(this, "tabClick", 7);
|
|
10
|
+
this.handleClick = () => {
|
|
11
|
+
this.tabClick.emit(this.label);
|
|
12
|
+
};
|
|
13
|
+
this.label = undefined;
|
|
14
|
+
this.active = false;
|
|
15
|
+
}
|
|
16
|
+
render() {
|
|
17
|
+
return (h(Host, null, h("div", { class: classnames('content', {
|
|
18
|
+
active: this.active,
|
|
19
|
+
}) }, h("slot", null))));
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
Tab.style = tabCss;
|
|
23
|
+
|
|
24
|
+
export { Tab as T };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { r as registerInstance, e as createEvent, h, H as Host, g as getElement } from './index-72f28b71.js';
|
|
2
|
+
import { c as classnames } from './index-9c609209.js';
|
|
3
|
+
import { r as readDOM, g as getBoundingClientRect } from './dom-9d0f7bf4.js';
|
|
4
|
+
|
|
5
|
+
function isTabElement(element) {
|
|
6
|
+
return element.tagName === 'VERTEX-TAB';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const tabsCss = "button{border:none;background-color:transparent;font-family:var(--vertex-ui-font-family);font-size:0.875rem;padding:0}:host{display:flex;position:relative;width:100%;height:100%}.wrapper{display:flex;flex-direction:column;position:relative;height:100%;width:100%}.labels{display:flex;position:relative;border-bottom:solid 1px var(--vertex-ui-neutral-300)}.indicator{position:absolute;bottom:0;height:3px;background-color:var(--vertex-ui-blue-700);transition:left 0.2s ease-in-out}.label{position:relative;cursor:pointer;color:var(--vertex-ui-neutral-700);white-space:nowrap;font-family:var(--vertex-ui-font-family);font-size:var(--vertex-ui-text-md);padding:0.75rem 1.25rem}.label:not(.active):hover{color:var(--vertex-ui-neutral-800)}.label.active{color:var(--vertex-ui-blue-700);font-weight:var(--vertex-ui-font-weight-bold)}.hidden-label-text{font-weight:bold;visibility:hidden;height:0px}.tab-content{display:flex;height:5%;flex-grow:1}";
|
|
10
|
+
|
|
11
|
+
const Tabs = class {
|
|
12
|
+
constructor(hostRef) {
|
|
13
|
+
registerInstance(this, hostRef);
|
|
14
|
+
this.selectedTabChanged = createEvent(this, "selectedTabChanged", 7);
|
|
15
|
+
this.indicatorInitialized = false;
|
|
16
|
+
this.handleLabelClick = (label) => {
|
|
17
|
+
if (this.active != null) {
|
|
18
|
+
this.updateActiveOnTab(this.active, false);
|
|
19
|
+
}
|
|
20
|
+
this.active = label;
|
|
21
|
+
this.updateActiveOnTab(this.active, true);
|
|
22
|
+
this.selectedTabChanged.emit(label);
|
|
23
|
+
};
|
|
24
|
+
this.updateActiveOnTab = (label, active) => {
|
|
25
|
+
const activeTab = this.findTabByLabel(label);
|
|
26
|
+
if (activeTab != null) {
|
|
27
|
+
activeTab.active = active;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
this.findTabByLabel = (label) => {
|
|
31
|
+
var _a;
|
|
32
|
+
const slotEl = ((_a = this.hostEl.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot:not([name])')) || undefined;
|
|
33
|
+
const slotAssignedElements = slotEl === null || slotEl === void 0 ? void 0 : slotEl.assignedElements();
|
|
34
|
+
const slotChildren = slotAssignedElements != null && slotAssignedElements.length > 0
|
|
35
|
+
? Array.from(slotAssignedElements[0].children)
|
|
36
|
+
: undefined;
|
|
37
|
+
return slotChildren != null
|
|
38
|
+
? slotChildren.filter(isTabElement).find((el) => el.label === label)
|
|
39
|
+
: undefined;
|
|
40
|
+
};
|
|
41
|
+
this.updateTabLabels = () => {
|
|
42
|
+
var _a;
|
|
43
|
+
const slotEl = ((_a = this.hostEl.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot:not([name])')) || undefined;
|
|
44
|
+
const slotAssignedElements = slotEl === null || slotEl === void 0 ? void 0 : slotEl.assignedElements();
|
|
45
|
+
const slotChildren = slotAssignedElements != null && slotAssignedElements.length > 0
|
|
46
|
+
? Array.from(slotAssignedElements[0].children)
|
|
47
|
+
: undefined;
|
|
48
|
+
this.labels =
|
|
49
|
+
slotChildren != null
|
|
50
|
+
? slotChildren.filter(isTabElement).map((t) => t.label)
|
|
51
|
+
: [];
|
|
52
|
+
};
|
|
53
|
+
this.active = undefined;
|
|
54
|
+
this.labels = [];
|
|
55
|
+
this.activeBounds = undefined;
|
|
56
|
+
this.activeButtonEl = undefined;
|
|
57
|
+
}
|
|
58
|
+
componentWillLoad() {
|
|
59
|
+
this.updateTabLabels();
|
|
60
|
+
}
|
|
61
|
+
componentDidLoad() {
|
|
62
|
+
if (this.active != null) {
|
|
63
|
+
this.updateActiveOnTab(this.active, true);
|
|
64
|
+
}
|
|
65
|
+
this.indicatorInitialized = false;
|
|
66
|
+
this.handleActiveButtonChange();
|
|
67
|
+
}
|
|
68
|
+
componentDidUpdate() {
|
|
69
|
+
// Place the indicator if it hasn't been initialized yet
|
|
70
|
+
if (!this.indicatorInitialized) {
|
|
71
|
+
this.handleActiveButtonChange();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
handleActiveButtonChange() {
|
|
75
|
+
const button = this.activeButtonEl;
|
|
76
|
+
if (button != null) {
|
|
77
|
+
readDOM(() => {
|
|
78
|
+
const hostElBounds = getBoundingClientRect(this.hostEl);
|
|
79
|
+
const activeBounds = getBoundingClientRect(button);
|
|
80
|
+
this.activeBounds = {
|
|
81
|
+
x: activeBounds.x - hostElBounds.x,
|
|
82
|
+
width: activeBounds.width,
|
|
83
|
+
};
|
|
84
|
+
if (this.activeBounds.width !== 0) {
|
|
85
|
+
this.indicatorInitialized = true;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
render() {
|
|
91
|
+
return (h(Host, null, h("div", { class: "wrapper" }, h("div", { class: "labels" }, this.labels.map((label) => (h("button", { class: classnames('label', {
|
|
92
|
+
active: this.active === label,
|
|
93
|
+
}), "data-label": label, ref: (el) => {
|
|
94
|
+
if (this.active === label) {
|
|
95
|
+
this.activeButtonEl = el;
|
|
96
|
+
}
|
|
97
|
+
}, onClick: () => this.handleLabelClick(label) }, label, h("div", { class: "hidden-label-text" }, label)))), h("slot", { name: "label-header" }), this.activeBounds && (h("div", { class: "indicator", style: {
|
|
98
|
+
left: `${this.activeBounds.x}px`,
|
|
99
|
+
width: `${this.activeBounds.width}px`,
|
|
100
|
+
} }))), h("div", { class: "tab-content" }, h("slot", { onSlotchange: this.updateTabLabels })))));
|
|
101
|
+
}
|
|
102
|
+
get hostEl() { return getElement(this); }
|
|
103
|
+
static get watchers() { return {
|
|
104
|
+
"activeButtonEl": ["handleActiveButtonChange"]
|
|
105
|
+
}; }
|
|
106
|
+
};
|
|
107
|
+
Tabs.style = tabsCss;
|
|
108
|
+
|
|
109
|
+
export { Tabs as T };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { r as registerInstance, h, H as Host, g as getElement } from './index-72f28b71.js';
|
|
2
2
|
import { _ as __extends, a as __read } from './tslib.es6-99cd0de8.js';
|
|
3
3
|
import { c as classnames } from './index-9c609209.js';
|
|
4
|
+
import { g as getBoundingClientRect } from './dom-9d0f7bf4.js';
|
|
4
5
|
import { a as getSlottedContent } from './slots-fbb5afb3.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -2050,10 +2051,6 @@ var uuid = /*#__PURE__*/Object.freeze({
|
|
|
2050
2051
|
toMsbLsb: toMsbLsb
|
|
2051
2052
|
});
|
|
2052
2053
|
|
|
2053
|
-
function getBoundingClientRect(el) {
|
|
2054
|
-
return el.getBoundingClientRect();
|
|
2055
|
-
}
|
|
2056
|
-
|
|
2057
2054
|
const tooltipCss = ":host{--tooltip-width:auto;--tooltip-white-space:normal;display:flex}.popover{width:100%;height:100%}.target{display:flex;width:100%;height:100%}.content-hidden{display:none}.tooltip{display:flex;justify-content:center;text-align:center;width:var(--tooltip-width);font-family:var(--vertex-ui-font-family);font-size:var(--vertex-ui-text-xxs);background-color:var(--vertex-ui-neutral-700);color:var(--vertex-ui-white);padding:0.25rem 0.5rem;border-radius:4px;pointer-events:none;white-space:var(--tooltip-white-space);user-select:none}.tooltip.hidden{display:none}";
|
|
2058
2055
|
|
|
2059
2056
|
const TOOLTIP_OPEN_DELAY = 500;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { I as vertex_icon_button } from './icon-button-
|
|
1
|
+
export { I as vertex_icon_button } from './icon-button-a4bdeabc.js';
|
|
2
2
|
import './index-72f28b71.js';
|
|
3
3
|
import './index-9c609209.js';
|
|
4
|
-
import './icon-helper-
|
|
4
|
+
import './icon-helper-94d45002.js';
|