@gitlab/ui 79.1.1 → 79.2.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/CHANGELOG.md +12 -0
- package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +9 -6
- package/dist/components/base/new_dropdowns/constants.js +2 -2
- package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +17 -8
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/tokens/css/tokens.css +1 -1
- package/dist/tokens/css/tokens.dark.css +1 -1
- package/dist/tokens/js/tokens.dark.js +1 -1
- package/dist/tokens/js/tokens.js +1 -1
- package/dist/tokens/scss/_tokens.dark.scss +1 -1
- package/dist/tokens/scss/_tokens.scss +1 -1
- package/dist/utils/utils.js +19 -1
- package/package.json +1 -1
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.spec.js +31 -26
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.vue +16 -6
- package/src/components/base/new_dropdowns/constants.js +1 -1
- package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.scss +15 -1
- package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.spec.js +51 -45
- package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.stories.js +8 -0
- package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.vue +52 -28
- package/src/utils/utils.js +18 -0
- package/src/utils/utils.spec.js +52 -0
package/src/utils/utils.spec.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
isElementTabbable,
|
|
4
4
|
focusFirstFocusableElement,
|
|
5
5
|
stopEvent,
|
|
6
|
+
getHorizontalBoundingClientRect,
|
|
6
7
|
} from './utils';
|
|
7
8
|
|
|
8
9
|
describe('isElementFocusable', () => {
|
|
@@ -153,4 +154,55 @@ describe('stopEvent', () => {
|
|
|
153
154
|
expect(event.stopPropagation).not.toHaveBeenCalled();
|
|
154
155
|
expect(event.stopImmediatePropagation).toHaveBeenCalledTimes(1);
|
|
155
156
|
});
|
|
157
|
+
|
|
158
|
+
describe('getHorizontalBoundingClientRect', () => {
|
|
159
|
+
describe('when there is a reference element', () => {
|
|
160
|
+
let mainElement;
|
|
161
|
+
|
|
162
|
+
const [
|
|
163
|
+
MAIN_LEFT_BOUNDARY,
|
|
164
|
+
MAIN_WIDTH,
|
|
165
|
+
MAIN_TOP_BOUNDARY,
|
|
166
|
+
MAIN_HEIGHT,
|
|
167
|
+
DOCUMENT_TOP_BOUNDARY,
|
|
168
|
+
DOCUMENT_HEIGHT,
|
|
169
|
+
] = [10, 20, 30, 40, 0, 50];
|
|
170
|
+
|
|
171
|
+
beforeEach(() => {
|
|
172
|
+
mainElement = document.createElement('main');
|
|
173
|
+
jest.spyOn(mainElement, 'getBoundingClientRect').mockImplementation(() => {
|
|
174
|
+
return {
|
|
175
|
+
x: MAIN_LEFT_BOUNDARY,
|
|
176
|
+
width: MAIN_WIDTH,
|
|
177
|
+
y: MAIN_TOP_BOUNDARY,
|
|
178
|
+
height: MAIN_HEIGHT,
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
Object.defineProperty(document.documentElement, 'clientHeight', {
|
|
182
|
+
get() {
|
|
183
|
+
return DOCUMENT_HEIGHT;
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
afterEach(() => {
|
|
189
|
+
mainElement = null;
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it("returns the element's horizontal boundaries and the document's vertical boundaries", () => {
|
|
193
|
+
expect(getHorizontalBoundingClientRect(mainElement)).toEqual({
|
|
194
|
+
x: MAIN_LEFT_BOUNDARY,
|
|
195
|
+
width: MAIN_WIDTH,
|
|
196
|
+
y: DOCUMENT_TOP_BOUNDARY,
|
|
197
|
+
height: DOCUMENT_HEIGHT,
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
describe('when there is no reference element', () => {
|
|
203
|
+
it('returns `null`', () => {
|
|
204
|
+
expect(getHorizontalBoundingClientRect(null)).toEqual(null);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
});
|
|
156
208
|
});
|