@heartlandone/vega 1.3.0 → 1.3.3
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/dist/cjs/{app-globals-3109659d.js → app-globals-d0304093.js} +1 -1
- package/dist/cjs/{featureFlagController-0fbc9f6a.js → featureFlagController-619c8f22.js} +5 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/vega-button_20.cjs.entry.js +19 -7
- package/dist/cjs/vega.cjs.js +2 -2
- package/dist/collection/components/vega-table/vega-table.js +4 -1
- package/dist/collection/helpers/feature-control/featureFlagsMap.js +5 -0
- package/dist/collection/helpers/ui/test/elementAppender.test.js +22 -10
- package/dist/collection/utils/position.js +15 -6
- package/dist/collection/utils/test/position.test.js +241 -6
- package/dist/esm/{app-globals-88f422e9.js → app-globals-0bb1611b.js} +1 -1
- package/dist/esm/{featureFlagController-2a73d90d.js → featureFlagController-c4da7f0a.js} +5 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/vega-button_20.entry.js +19 -7
- package/dist/esm/vega.js +2 -2
- package/dist/types/components/vega-table/vega-table.d.ts +1 -0
- package/dist/types/helpers/feature-control/featureFlag.d.ts +3 -1
- package/dist/types/helpers/feature-control/featureFlagsMap.d.ts +2 -2
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/p-02a780a5.entry.js +13 -0
- package/dist/vega/p-30f3757b.js +1 -0
- package/dist/vega/p-c65f8d29.js +1 -0
- package/dist/vega/storybook.css +1 -0
- package/dist/vega/vega.css +1 -1
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +4 -4
- package/readme.md +10 -4
- package/style/vega.css +1 -1
- package/style/vega_min.css +1 -1
- package/dist/vega/p-111f9dfa.js +0 -1
- package/dist/vega/p-5a051919.entry.js +0 -13
- package/dist/vega/p-a42002da.js +0 -1
|
@@ -9,6 +9,11 @@ const FeatureFlagsMap = {
|
|
|
9
9
|
createdTimestamp: 1660330561422,
|
|
10
10
|
createdAtVersion: '1.2.0',
|
|
11
11
|
},
|
|
12
|
+
'POSITION.FIX_TARGET_POSITION_WHEN_PARENT_IS_RELATIVE': {
|
|
13
|
+
description: `Feature flag to enable the new calculate of target position. this change is suitable the case which target have relative parent`,
|
|
14
|
+
createdTimestamp: 1660800418146,
|
|
15
|
+
createdAtVersion: '1.3.0',
|
|
16
|
+
},
|
|
12
17
|
};
|
|
13
18
|
const FeatureFlagsMap$1 = Object.freeze(FeatureFlagsMap);
|
|
14
19
|
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -7,7 +7,7 @@ const log = require('./log-7b0974fb.js');
|
|
|
7
7
|
const typeGuard = require('./typeGuard-162ede83.js');
|
|
8
8
|
const icons = require('./icons-ab5c5f17.js');
|
|
9
9
|
const ui = require('./ui-2ae913d5.js');
|
|
10
|
-
const featureFlagController = require('./featureFlagController-
|
|
10
|
+
const featureFlagController = require('./featureFlagController-619c8f22.js');
|
|
11
11
|
require('./number-2eb7b8f3.js');
|
|
12
12
|
|
|
13
13
|
/* This file is generated by vega-design 2.0.60 */
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-2e8b771c.js');
|
|
6
|
-
const appGlobals = require('./app-globals-
|
|
7
|
-
require('./featureFlagController-
|
|
6
|
+
const appGlobals = require('./app-globals-d0304093.js');
|
|
7
|
+
require('./featureFlagController-619c8f22.js');
|
|
8
8
|
|
|
9
9
|
/*
|
|
10
10
|
Stencil Client Patch Esm v2.14.0 | MIT Licensed | https://stenciljs.com
|
|
@@ -12,6 +12,7 @@ const log = require('./log-7b0974fb.js');
|
|
|
12
12
|
const array = require('./array-414f6d01.js');
|
|
13
13
|
const ui = require('./ui-2ae913d5.js');
|
|
14
14
|
const typeGuard = require('./typeGuard-162ede83.js');
|
|
15
|
+
const featureFlagController = require('./featureFlagController-619c8f22.js');
|
|
15
16
|
const misc = require('./misc-649f158c.js');
|
|
16
17
|
const icons = require('./icons-ab5c5f17.js');
|
|
17
18
|
const subject = require('./subject-fdccaa01.js');
|
|
@@ -1586,7 +1587,7 @@ const getPositionBox = (container, element, target, placement, translocation = {
|
|
|
1586
1587
|
log.LogUtility.warn(`Calculate position should make container as 'position: relative', otherwise the result might not be accurate.`);
|
|
1587
1588
|
}
|
|
1588
1589
|
const placements = getPlacements(placement);
|
|
1589
|
-
const targetBox = getTargetPositionBox(target);
|
|
1590
|
+
const targetBox = getTargetPositionBox(target, container);
|
|
1590
1591
|
const elementBox = getElementPositionBox(element);
|
|
1591
1592
|
const containerBox = getContainerPositionBox(container);
|
|
1592
1593
|
const suitablePlacement = getSuitablePlacement(containerBox, elementBox, targetBox, placements, element);
|
|
@@ -1746,18 +1747,26 @@ function hasEnoughSpace(containerBox, placement, targetBox, elementBox) {
|
|
|
1746
1747
|
}
|
|
1747
1748
|
}
|
|
1748
1749
|
/**
|
|
1749
|
-
* It returns an
|
|
1750
|
+
* It returns the position of an element relative to its container and also includes the scroll height of container.
|
|
1750
1751
|
*
|
|
1751
|
-
* @param {HTMLElement} target -
|
|
1752
|
+
* @param {HTMLElement} target - The element that you want to position.
|
|
1753
|
+
* @param {HTMLElement} container - The container element that the target element is inside of.
|
|
1752
1754
|
* @returns {ElementPositionBox} An object with the properties width, height, top, and left.
|
|
1753
1755
|
*/
|
|
1754
|
-
function getTargetPositionBox(target) {
|
|
1756
|
+
function getTargetPositionBox(target, container) {
|
|
1757
|
+
const containerRect = container.getBoundingClientRect();
|
|
1755
1758
|
const targetRect = target.getBoundingClientRect();
|
|
1759
|
+
let targetTop = target.offsetTop;
|
|
1760
|
+
let targetLeft = target.offsetLeft;
|
|
1761
|
+
if (featureFlagController.FeatureFlag.isEnabled('POSITION.FIX_TARGET_POSITION_WHEN_PARENT_IS_RELATIVE')) {
|
|
1762
|
+
targetTop = targetRect.top - containerRect.top + container.scrollTop;
|
|
1763
|
+
targetLeft = targetRect.left - containerRect.left + container.scrollLeft;
|
|
1764
|
+
}
|
|
1756
1765
|
return {
|
|
1757
1766
|
width: targetRect.width,
|
|
1758
1767
|
height: targetRect.height,
|
|
1759
|
-
top:
|
|
1760
|
-
left:
|
|
1768
|
+
top: targetTop,
|
|
1769
|
+
left: targetLeft,
|
|
1761
1770
|
};
|
|
1762
1771
|
}
|
|
1763
1772
|
/**
|
|
@@ -5393,7 +5402,7 @@ let VegaTable = class {
|
|
|
5393
5402
|
this.renderRowSelection = (item) => {
|
|
5394
5403
|
return (index.h("td", { class: "vega-table-selection-column" }, index.h("div", { class: "vega-table-checkbox-wrapper" }, index.h("vega-checkbox", { size: "small", checked: this.isChecked(item.key),
|
|
5395
5404
|
/* eslint-disable-next-line react/jsx-no-bind */
|
|
5396
|
-
onVegaChange: (e) => this.handleRowSelect(e.detail, item) }))));
|
|
5405
|
+
onVegaChange: (e) => this.handleRowSelect(e.detail, item), onClick: this.stopRowSelectionPropagation }))));
|
|
5397
5406
|
};
|
|
5398
5407
|
this.renderSelectionHeader = () => {
|
|
5399
5408
|
const checkAllDisabled = this.currentData.length === 0;
|
|
@@ -5585,6 +5594,9 @@ let VegaTable = class {
|
|
|
5585
5594
|
this.handleRowClick = (record, index) => {
|
|
5586
5595
|
this.vegaRowClick.emit({ record: record, index: index });
|
|
5587
5596
|
};
|
|
5597
|
+
this.stopRowSelectionPropagation = (e) => {
|
|
5598
|
+
e.stopPropagation();
|
|
5599
|
+
};
|
|
5588
5600
|
}
|
|
5589
5601
|
watchCurrentData(currentData) {
|
|
5590
5602
|
this.syncUpSelectedKeySetWithCurrentData(currentData);
|
package/dist/cjs/vega.cjs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const index = require('./index-2e8b771c.js');
|
|
4
|
-
const appGlobals = require('./app-globals-
|
|
5
|
-
require('./featureFlagController-
|
|
4
|
+
const appGlobals = require('./app-globals-d0304093.js');
|
|
5
|
+
require('./featureFlagController-619c8f22.js');
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
Stencil Client Patch Browser v2.14.0 | MIT Licensed | https://stenciljs.com
|
|
@@ -131,7 +131,7 @@ export class VegaTable {
|
|
|
131
131
|
h("div", { class: "vega-table-checkbox-wrapper" },
|
|
132
132
|
h("vega-checkbox", { size: "small", checked: this.isChecked(item.key),
|
|
133
133
|
/* eslint-disable-next-line react/jsx-no-bind */
|
|
134
|
-
onVegaChange: (e) => this.handleRowSelect(e.detail, item) }))));
|
|
134
|
+
onVegaChange: (e) => this.handleRowSelect(e.detail, item), onClick: this.stopRowSelectionPropagation }))));
|
|
135
135
|
};
|
|
136
136
|
this.renderSelectionHeader = () => {
|
|
137
137
|
const checkAllDisabled = this.currentData.length === 0;
|
|
@@ -324,6 +324,9 @@ export class VegaTable {
|
|
|
324
324
|
this.handleRowClick = (record, index) => {
|
|
325
325
|
this.vegaRowClick.emit({ record: record, index: index });
|
|
326
326
|
};
|
|
327
|
+
this.stopRowSelectionPropagation = (e) => {
|
|
328
|
+
e.stopPropagation();
|
|
329
|
+
};
|
|
327
330
|
}
|
|
328
331
|
watchCurrentData(currentData) {
|
|
329
332
|
this.syncUpSelectedKeySetWithCurrentData(currentData);
|
|
@@ -7,5 +7,10 @@ const FeatureFlagsMap = {
|
|
|
7
7
|
createdTimestamp: 1660330561422,
|
|
8
8
|
createdAtVersion: '1.2.0',
|
|
9
9
|
},
|
|
10
|
+
'POSITION.FIX_TARGET_POSITION_WHEN_PARENT_IS_RELATIVE': {
|
|
11
|
+
description: `Feature flag to enable the new calculate of target position. this change is suitable the case which target have relative parent`,
|
|
12
|
+
createdTimestamp: 1660800418146,
|
|
13
|
+
createdAtVersion: '1.3.0',
|
|
14
|
+
},
|
|
10
15
|
};
|
|
11
16
|
export default Object.freeze(FeatureFlagsMap);
|
|
@@ -8,10 +8,16 @@ test('return result as expect when call show', () => {
|
|
|
8
8
|
document.body.innerHTML = innerHTML;
|
|
9
9
|
const element = document.querySelector('.dropdown');
|
|
10
10
|
const target = document.querySelector('.test-host');
|
|
11
|
-
Object.assign(document.body, {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
Object.assign(document.body, {
|
|
12
|
+
scrollHeight: 500,
|
|
13
|
+
scrollWidth: 500,
|
|
14
|
+
scrollTop: 0,
|
|
15
|
+
scrollLeft: 0,
|
|
16
|
+
});
|
|
17
|
+
Object.assign(target, {
|
|
18
|
+
offsetTop: 0,
|
|
19
|
+
offsetLeft: 0,
|
|
20
|
+
});
|
|
15
21
|
const drop = new ElementAppender(target, element);
|
|
16
22
|
drop.show({ placement: ['bottom', 'top'] });
|
|
17
23
|
expect(document.body).toEqualHtml(`
|
|
@@ -21,9 +27,9 @@ test('return result as expect when call show', () => {
|
|
|
21
27
|
spyOn(target, 'getBoundingClientRect').and.returnValue({
|
|
22
28
|
width: 120,
|
|
23
29
|
height: 0,
|
|
30
|
+
top: 120,
|
|
31
|
+
left: 0,
|
|
24
32
|
});
|
|
25
|
-
Object.assign(target, { offsetTop: 120 });
|
|
26
|
-
Object.assign(target, { offsetLeft: 0 });
|
|
27
33
|
drop.show({
|
|
28
34
|
size: 200,
|
|
29
35
|
translocation: { X: 20, Y: 20 },
|
|
@@ -51,10 +57,16 @@ test('return result as expect when call hide', () => {
|
|
|
51
57
|
const element = document.querySelector('.dropdown');
|
|
52
58
|
const target = document.querySelector('.test-host');
|
|
53
59
|
const drop = new ElementAppender(target, element);
|
|
54
|
-
Object.assign(target, {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
Object.assign(target, {
|
|
61
|
+
offsetTop: 0,
|
|
62
|
+
offsetLeft: 0,
|
|
63
|
+
});
|
|
64
|
+
Object.assign(document.body, {
|
|
65
|
+
scrollHeight: 500,
|
|
66
|
+
scrollWidth: 500,
|
|
67
|
+
scrollTop: 0,
|
|
68
|
+
scrollLeft: 0,
|
|
69
|
+
});
|
|
58
70
|
drop.show({
|
|
59
71
|
placement: ['bottom', 'top'],
|
|
60
72
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LogUtility } from './log';
|
|
2
2
|
import { Placements } from '../constants/ui';
|
|
3
3
|
import { isTranslocationType } from '../types/typeGuard';
|
|
4
|
+
import { FeatureFlag } from '../helpers/publicApi';
|
|
4
5
|
/**
|
|
5
6
|
* Get the position of the element in the container according to the target element and the placement
|
|
6
7
|
* If give a translocation, it will apply the translocation to the result.
|
|
@@ -22,7 +23,7 @@ export const getPositionBox = (container, element, target, placement, translocat
|
|
|
22
23
|
LogUtility.warn(`Calculate position should make container as 'position: relative', otherwise the result might not be accurate.`);
|
|
23
24
|
}
|
|
24
25
|
const placements = getPlacements(placement);
|
|
25
|
-
const targetBox = getTargetPositionBox(target);
|
|
26
|
+
const targetBox = getTargetPositionBox(target, container);
|
|
26
27
|
const elementBox = getElementPositionBox(element);
|
|
27
28
|
const containerBox = getContainerPositionBox(container);
|
|
28
29
|
const suitablePlacement = getSuitablePlacement(containerBox, elementBox, targetBox, placements, element);
|
|
@@ -182,18 +183,26 @@ function hasEnoughSpace(containerBox, placement, targetBox, elementBox) {
|
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
185
|
/**
|
|
185
|
-
* It returns an
|
|
186
|
+
* It returns the position of an element relative to its container and also includes the scroll height of container.
|
|
186
187
|
*
|
|
187
|
-
* @param {HTMLElement} target -
|
|
188
|
+
* @param {HTMLElement} target - The element that you want to position.
|
|
189
|
+
* @param {HTMLElement} container - The container element that the target element is inside of.
|
|
188
190
|
* @returns {ElementPositionBox} An object with the properties width, height, top, and left.
|
|
189
191
|
*/
|
|
190
|
-
function getTargetPositionBox(target) {
|
|
192
|
+
function getTargetPositionBox(target, container) {
|
|
193
|
+
const containerRect = container.getBoundingClientRect();
|
|
191
194
|
const targetRect = target.getBoundingClientRect();
|
|
195
|
+
let targetTop = target.offsetTop;
|
|
196
|
+
let targetLeft = target.offsetLeft;
|
|
197
|
+
if (FeatureFlag.isEnabled('POSITION.FIX_TARGET_POSITION_WHEN_PARENT_IS_RELATIVE')) {
|
|
198
|
+
targetTop = targetRect.top - containerRect.top + container.scrollTop;
|
|
199
|
+
targetLeft = targetRect.left - containerRect.left + container.scrollLeft;
|
|
200
|
+
}
|
|
192
201
|
return {
|
|
193
202
|
width: targetRect.width,
|
|
194
203
|
height: targetRect.height,
|
|
195
|
-
top:
|
|
196
|
-
left:
|
|
204
|
+
top: targetTop,
|
|
205
|
+
left: targetLeft,
|
|
197
206
|
};
|
|
198
207
|
}
|
|
199
208
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FeatureFlag } from '../../helpers/feature-control/featureFlagController';
|
|
1
2
|
import { getPositionBox } from '../../utils/position';
|
|
2
3
|
describe('getPositionBox', () => {
|
|
3
4
|
const innerHTML = `
|
|
@@ -37,8 +38,6 @@ describe('getPositionBox', () => {
|
|
|
37
38
|
describe('directions', () => {
|
|
38
39
|
beforeEach(() => {
|
|
39
40
|
container.style.position = 'relative';
|
|
40
|
-
Object.assign(target, { offsetTop: 100 });
|
|
41
|
-
Object.assign(target, { offsetLeft: 100 });
|
|
42
41
|
spyOn(window, 'getComputedStyle').and.returnValue({ position: 'relative' });
|
|
43
42
|
});
|
|
44
43
|
test('return result as expected when with array placement', () => {
|
|
@@ -46,6 +45,8 @@ describe('getPositionBox', () => {
|
|
|
46
45
|
mockElementReturn(target, 'getBoundingClientRect', {
|
|
47
46
|
width: 100,
|
|
48
47
|
height: 100,
|
|
48
|
+
top: 100,
|
|
49
|
+
left: 100,
|
|
49
50
|
});
|
|
50
51
|
const positionBox = getPositionBox(container, element, target, [
|
|
51
52
|
'left',
|
|
@@ -59,6 +60,8 @@ describe('getPositionBox', () => {
|
|
|
59
60
|
mockElementReturn(target, 'getBoundingClientRect', {
|
|
60
61
|
width: 100,
|
|
61
62
|
height: 100,
|
|
63
|
+
top: 100,
|
|
64
|
+
left: 100,
|
|
62
65
|
});
|
|
63
66
|
const positionBox = getPositionBox(container, element, target);
|
|
64
67
|
expect(positionBox).toEqual({ top: 50, left: 100, placement: 'top' });
|
|
@@ -68,6 +71,8 @@ describe('getPositionBox', () => {
|
|
|
68
71
|
mockElementReturn(target, 'getBoundingClientRect', {
|
|
69
72
|
width: 100,
|
|
70
73
|
height: 100,
|
|
74
|
+
top: 100,
|
|
75
|
+
left: 100,
|
|
71
76
|
});
|
|
72
77
|
let positionBox;
|
|
73
78
|
positionBox = getPositionBox(container, element, target, 'left');
|
|
@@ -84,6 +89,8 @@ describe('getPositionBox', () => {
|
|
|
84
89
|
mockElementReturn(target, 'getBoundingClientRect', {
|
|
85
90
|
width: 100,
|
|
86
91
|
height: 100,
|
|
92
|
+
top: 80,
|
|
93
|
+
left: 80,
|
|
87
94
|
});
|
|
88
95
|
let positionBox;
|
|
89
96
|
container.scrollTop = 20;
|
|
@@ -102,6 +109,8 @@ describe('getPositionBox', () => {
|
|
|
102
109
|
mockElementReturn(target, 'getBoundingClientRect', {
|
|
103
110
|
width: 100,
|
|
104
111
|
height: 100,
|
|
112
|
+
top: 100,
|
|
113
|
+
left: 100,
|
|
105
114
|
});
|
|
106
115
|
const positionBox = getPositionBox(container, element, target, 'top');
|
|
107
116
|
expect(positionBox).toEqual({ top: 100, left: 50, placement: 'left' });
|
|
@@ -111,6 +120,8 @@ describe('getPositionBox', () => {
|
|
|
111
120
|
mockElementReturn(target, 'getBoundingClientRect', {
|
|
112
121
|
width: 100,
|
|
113
122
|
height: 100,
|
|
123
|
+
top: 100,
|
|
124
|
+
left: 100,
|
|
114
125
|
});
|
|
115
126
|
const positionBox = getPositionBox(container, element, target, 'top');
|
|
116
127
|
expect(positionBox).toEqual({ top: 200, left: 100, placement: 'bottom' });
|
|
@@ -120,6 +131,8 @@ describe('getPositionBox', () => {
|
|
|
120
131
|
mockElementReturn(target, 'getBoundingClientRect', {
|
|
121
132
|
width: 100,
|
|
122
133
|
height: 300,
|
|
134
|
+
top: 100,
|
|
135
|
+
left: 100,
|
|
123
136
|
});
|
|
124
137
|
const positionBox = getPositionBox(container, element, target, 'top');
|
|
125
138
|
expect(positionBox).toEqual({ top: 100, left: 200, placement: 'right' });
|
|
@@ -131,9 +144,9 @@ describe('getPositionBox', () => {
|
|
|
131
144
|
mockElementReturn(target, 'getBoundingClientRect', {
|
|
132
145
|
width: 200,
|
|
133
146
|
height: 200,
|
|
147
|
+
top: 200,
|
|
148
|
+
left: 200,
|
|
134
149
|
});
|
|
135
|
-
Object.assign(target, { offsetTop: 200 });
|
|
136
|
-
Object.assign(target, { offsetLeft: 200 });
|
|
137
150
|
const positionBox = getPositionBox(container, element, target, [
|
|
138
151
|
'bottom',
|
|
139
152
|
'top',
|
|
@@ -149,6 +162,8 @@ describe('getPositionBox', () => {
|
|
|
149
162
|
mockElementReturn(target, 'getBoundingClientRect', {
|
|
150
163
|
width: 1024,
|
|
151
164
|
height: 1024,
|
|
165
|
+
top: 100,
|
|
166
|
+
left: 100,
|
|
152
167
|
});
|
|
153
168
|
Object.assign(target, { offsetTop: 0 });
|
|
154
169
|
Object.assign(target, { offsetLeft: 0 });
|
|
@@ -163,9 +178,9 @@ describe('getPositionBox', () => {
|
|
|
163
178
|
mockElementReturn(target, 'getBoundingClientRect', {
|
|
164
179
|
width: 100,
|
|
165
180
|
height: 100,
|
|
181
|
+
top: 100,
|
|
182
|
+
left: 100,
|
|
166
183
|
});
|
|
167
|
-
Object.assign(target, { offsetTop: 100 });
|
|
168
|
-
Object.assign(target, { offsetLeft: 100 });
|
|
169
184
|
});
|
|
170
185
|
test('return result as expected when container not scrolled', () => {
|
|
171
186
|
const positionBox = getPositionBox(container, element, target, 'top', {
|
|
@@ -184,6 +199,226 @@ describe('getPositionBox', () => {
|
|
|
184
199
|
});
|
|
185
200
|
expect(positionBox2).toEqual({ top: 200, left: -60, placement: 'left' });
|
|
186
201
|
});
|
|
202
|
+
test('return result as expected when container scrolled', () => {
|
|
203
|
+
container.scrollTop = 20;
|
|
204
|
+
container.scrollLeft = 20;
|
|
205
|
+
const positionBox = getPositionBox(container, element, target, 'top', {
|
|
206
|
+
X: 100,
|
|
207
|
+
Y: 100,
|
|
208
|
+
});
|
|
209
|
+
expect(positionBox).toEqual({ top: -40, left: 220, placement: 'top' });
|
|
210
|
+
const positionBox1 = getPositionBox(container, element, target, 'right', {
|
|
211
|
+
X: 100,
|
|
212
|
+
Y: 100,
|
|
213
|
+
});
|
|
214
|
+
expect(positionBox1).toEqual({ top: 220, left: 320, placement: 'right' });
|
|
215
|
+
});
|
|
216
|
+
test('return result as expected when translocation set', () => {
|
|
217
|
+
const positionBox1 = getPositionBox(container, element, target, 'bottom', {
|
|
218
|
+
X: 'start',
|
|
219
|
+
Y: 'start',
|
|
220
|
+
});
|
|
221
|
+
expect(positionBox1).toEqual({ top: 200, left: 100, placement: 'bottom' });
|
|
222
|
+
const positionBox2 = getPositionBox(container, element, target, 'bottom', {
|
|
223
|
+
X: 'center',
|
|
224
|
+
Y: 'center',
|
|
225
|
+
});
|
|
226
|
+
expect(positionBox2).toEqual({ top: 200, left: 120, placement: 'bottom' });
|
|
227
|
+
const positionBox3 = getPositionBox(container, element, target, 'bottom', {
|
|
228
|
+
X: 'end',
|
|
229
|
+
Y: 'end',
|
|
230
|
+
});
|
|
231
|
+
expect(positionBox3).toEqual({ top: 200, left: 140, placement: 'bottom' });
|
|
232
|
+
const positionBox4 = getPositionBox(container, element, target, 'top', {
|
|
233
|
+
X: 'start',
|
|
234
|
+
Y: 'start',
|
|
235
|
+
});
|
|
236
|
+
expect(positionBox4).toEqual({ top: 40, left: 100, placement: 'top' });
|
|
237
|
+
const positionBox5 = getPositionBox(container, element, target, 'top', {
|
|
238
|
+
X: 'center',
|
|
239
|
+
Y: 'center',
|
|
240
|
+
});
|
|
241
|
+
expect(positionBox5).toEqual({ top: 40, left: 120, placement: 'top' });
|
|
242
|
+
const positionBox6 = getPositionBox(container, element, target, 'top', {
|
|
243
|
+
X: 'end',
|
|
244
|
+
Y: 'end',
|
|
245
|
+
});
|
|
246
|
+
expect(positionBox6).toEqual({ top: 40, left: 140, placement: 'top' });
|
|
247
|
+
const positionBox7 = getPositionBox(container, element, target, 'left', {
|
|
248
|
+
X: 'start',
|
|
249
|
+
Y: 'start',
|
|
250
|
+
});
|
|
251
|
+
expect(positionBox7).toEqual({ top: 100, left: 40, placement: 'left' });
|
|
252
|
+
const positionBox8 = getPositionBox(container, element, target, 'left', {
|
|
253
|
+
X: 'center',
|
|
254
|
+
Y: 'center',
|
|
255
|
+
});
|
|
256
|
+
expect(positionBox8).toEqual({ top: 120, left: 40, placement: 'left' });
|
|
257
|
+
const positionBox9 = getPositionBox(container, element, target, 'left', {
|
|
258
|
+
X: 'end',
|
|
259
|
+
Y: 'end',
|
|
260
|
+
});
|
|
261
|
+
expect(positionBox9).toEqual({ top: 140, left: 40, placement: 'left' });
|
|
262
|
+
const positionBox10 = getPositionBox(container, element, target, 'right', {
|
|
263
|
+
X: 'start',
|
|
264
|
+
Y: 'start',
|
|
265
|
+
});
|
|
266
|
+
expect(positionBox10).toEqual({ top: 100, left: 200, placement: 'right' });
|
|
267
|
+
const positionBox11 = getPositionBox(container, element, target, 'right', {
|
|
268
|
+
X: 'center',
|
|
269
|
+
Y: 'center',
|
|
270
|
+
});
|
|
271
|
+
expect(positionBox11).toEqual({ top: 120, left: 200, placement: 'right' });
|
|
272
|
+
const positionBox12 = getPositionBox(container, element, target, 'right', {
|
|
273
|
+
X: 'end',
|
|
274
|
+
Y: 'end',
|
|
275
|
+
});
|
|
276
|
+
expect(positionBox12).toEqual({ top: 140, left: 200, placement: 'right' });
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
// POSITION.FIX_TARGET_POSITION_WHEN_PARENT_IS_RELATIVE
|
|
280
|
+
describe("return result as expected when disabled feature flag 'POSITION.FIX_TARGET_POSITION_WHEN_PARENT_IS_RELATIVE'", () => {
|
|
281
|
+
beforeAll(() => {
|
|
282
|
+
FeatureFlag.disable('POSITION.FIX_TARGET_POSITION_WHEN_PARENT_IS_RELATIVE');
|
|
283
|
+
});
|
|
284
|
+
beforeEach(() => {
|
|
285
|
+
container.style.position = 'relative';
|
|
286
|
+
Object.assign(target, { offsetTop: 100 });
|
|
287
|
+
Object.assign(target, { offsetLeft: 100 });
|
|
288
|
+
spyOn(window, 'getComputedStyle').and.returnValue({ position: 'relative' });
|
|
289
|
+
});
|
|
290
|
+
test('return result as expected when with array placement', () => {
|
|
291
|
+
mockElementReturn(element, 'getBoundingClientRect', { width: 50, height: 50 });
|
|
292
|
+
mockElementReturn(target, 'getBoundingClientRect', {
|
|
293
|
+
width: 100,
|
|
294
|
+
height: 100,
|
|
295
|
+
});
|
|
296
|
+
const positionBox = getPositionBox(container, element, target, [
|
|
297
|
+
'left',
|
|
298
|
+
'bottom',
|
|
299
|
+
'right',
|
|
300
|
+
]);
|
|
301
|
+
expect(positionBox).toEqual({ top: 100, left: 50, placement: 'left' });
|
|
302
|
+
});
|
|
303
|
+
test('return result as expected when without placement', () => {
|
|
304
|
+
mockElementReturn(element, 'getBoundingClientRect', { width: 50, height: 50 });
|
|
305
|
+
mockElementReturn(target, 'getBoundingClientRect', {
|
|
306
|
+
width: 100,
|
|
307
|
+
height: 100,
|
|
308
|
+
});
|
|
309
|
+
const positionBox = getPositionBox(container, element, target);
|
|
310
|
+
expect(positionBox).toEqual({ top: 50, left: 100, placement: 'top' });
|
|
311
|
+
});
|
|
312
|
+
test('return result as expected when with single placement', () => {
|
|
313
|
+
mockElementReturn(element, 'getBoundingClientRect', { width: 50, height: 50 });
|
|
314
|
+
mockElementReturn(target, 'getBoundingClientRect', {
|
|
315
|
+
width: 100,
|
|
316
|
+
height: 100,
|
|
317
|
+
});
|
|
318
|
+
let positionBox;
|
|
319
|
+
positionBox = getPositionBox(container, element, target, 'left');
|
|
320
|
+
expect(positionBox).toEqual({ top: 100, left: 50, placement: 'left' });
|
|
321
|
+
positionBox = getPositionBox(container, element, target, 'top');
|
|
322
|
+
expect(positionBox).toEqual({ top: 50, left: 100, placement: 'top' });
|
|
323
|
+
positionBox = getPositionBox(container, element, target, 'right');
|
|
324
|
+
expect(positionBox).toEqual({ top: 100, left: 200, placement: 'right' });
|
|
325
|
+
positionBox = getPositionBox(container, element, target, 'bottom');
|
|
326
|
+
expect(positionBox).toEqual({ top: 200, left: 100, placement: 'bottom' });
|
|
327
|
+
});
|
|
328
|
+
test('return result as expected when container scroll', () => {
|
|
329
|
+
mockElementReturn(element, 'getBoundingClientRect', { width: 50, height: 50 });
|
|
330
|
+
mockElementReturn(target, 'getBoundingClientRect', {
|
|
331
|
+
width: 100,
|
|
332
|
+
height: 100,
|
|
333
|
+
});
|
|
334
|
+
let positionBox;
|
|
335
|
+
container.scrollTop = 20;
|
|
336
|
+
container.scrollLeft = 20;
|
|
337
|
+
positionBox = getPositionBox(container, element, target, 'left');
|
|
338
|
+
expect(positionBox).toEqual({ top: 100, left: 50, placement: 'left' });
|
|
339
|
+
positionBox = getPositionBox(container, element, target, 'top');
|
|
340
|
+
expect(positionBox).toEqual({ top: 50, left: 100, placement: 'top' });
|
|
341
|
+
positionBox = getPositionBox(container, element, target, 'right');
|
|
342
|
+
expect(positionBox).toEqual({ top: 100, left: 200, placement: 'right' });
|
|
343
|
+
positionBox = getPositionBox(container, element, target, 'bottom');
|
|
344
|
+
expect(positionBox).toEqual({ top: 200, left: 100, placement: 'bottom' });
|
|
345
|
+
});
|
|
346
|
+
test('return result as expected when top have not enough placement', () => {
|
|
347
|
+
mockElementReturn(element, 'getBoundingClientRect', { width: 50, height: 120 });
|
|
348
|
+
mockElementReturn(target, 'getBoundingClientRect', {
|
|
349
|
+
width: 100,
|
|
350
|
+
height: 100,
|
|
351
|
+
});
|
|
352
|
+
const positionBox = getPositionBox(container, element, target, 'top');
|
|
353
|
+
expect(positionBox).toEqual({ top: 100, left: 50, placement: 'left' });
|
|
354
|
+
});
|
|
355
|
+
test('return result as expected when top and left have not enough placement', () => {
|
|
356
|
+
mockElementReturn(element, 'getBoundingClientRect', { width: 120, height: 120 });
|
|
357
|
+
mockElementReturn(target, 'getBoundingClientRect', {
|
|
358
|
+
width: 100,
|
|
359
|
+
height: 100,
|
|
360
|
+
});
|
|
361
|
+
const positionBox = getPositionBox(container, element, target, 'top');
|
|
362
|
+
expect(positionBox).toEqual({ top: 200, left: 100, placement: 'bottom' });
|
|
363
|
+
});
|
|
364
|
+
test('return result as expected when top, left and bottom have not enough placement', () => {
|
|
365
|
+
mockElementReturn(element, 'getBoundingClientRect', { width: 120, height: 120 });
|
|
366
|
+
mockElementReturn(target, 'getBoundingClientRect', {
|
|
367
|
+
width: 100,
|
|
368
|
+
height: 300,
|
|
369
|
+
});
|
|
370
|
+
Object.assign(container, { scrollHeight: 500 });
|
|
371
|
+
Object.assign(container, { scrollWidth: 500 });
|
|
372
|
+
const positionBox = getPositionBox(container, element, target, 'top');
|
|
373
|
+
expect(positionBox).toEqual({ top: 100, left: 200, placement: 'right' });
|
|
374
|
+
});
|
|
375
|
+
test('return result as expected when container scrollHeight/scrollWidth is big than body scrollHeight/scrollWidth', () => {
|
|
376
|
+
Object.assign(container, { scrollHeight: 530 });
|
|
377
|
+
Object.assign(container, { scrollWidth: 530 });
|
|
378
|
+
mockElementReturn(element, 'getBoundingClientRect', { width: 120, height: 120 });
|
|
379
|
+
mockElementReturn(target, 'getBoundingClientRect', {
|
|
380
|
+
width: 200,
|
|
381
|
+
height: 200,
|
|
382
|
+
});
|
|
383
|
+
Object.assign(target, { offsetTop: 200 });
|
|
384
|
+
Object.assign(target, { offsetLeft: 200 });
|
|
385
|
+
const positionBox = getPositionBox(container, element, target, [
|
|
386
|
+
'bottom',
|
|
387
|
+
'top',
|
|
388
|
+
]);
|
|
389
|
+
expect(positionBox).toEqual({ top: 400, left: 200, placement: 'bottom' });
|
|
390
|
+
const positionBox1 = getPositionBox(container, element, target, [
|
|
391
|
+
'right',
|
|
392
|
+
'left',
|
|
393
|
+
]);
|
|
394
|
+
expect(positionBox1).toEqual({ top: 200, left: 400, placement: 'right' });
|
|
395
|
+
});
|
|
396
|
+
test('return result as expected when without enough placement', () => {
|
|
397
|
+
mockElementReturn(target, 'getBoundingClientRect', {
|
|
398
|
+
width: 1024,
|
|
399
|
+
height: 1024,
|
|
400
|
+
});
|
|
401
|
+
Object.assign(target, { offsetTop: 0 });
|
|
402
|
+
Object.assign(target, { offsetLeft: 0 });
|
|
403
|
+
console.warn = jest.fn();
|
|
404
|
+
getPositionBox(container, target, element);
|
|
405
|
+
expect(console.warn).toBeCalled();
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
// POSITION.FIX_TARGET_POSITION_WHEN_PARENT_IS_RELATIVE
|
|
409
|
+
describe("return result as expected when disabled feature flag 'POSITION.FIX_TARGET_POSITION_WHEN_PARENT_IS_RELATIVE'", () => {
|
|
410
|
+
beforeAll(() => {
|
|
411
|
+
FeatureFlag.disable('POSITION.FIX_TARGET_POSITION_WHEN_PARENT_IS_RELATIVE');
|
|
412
|
+
});
|
|
413
|
+
beforeAll(() => {
|
|
414
|
+
mockElementReturn(element, 'getBoundingClientRect', { width: 60, height: 60 });
|
|
415
|
+
mockElementReturn(target, 'getBoundingClientRect', {
|
|
416
|
+
width: 100,
|
|
417
|
+
height: 100,
|
|
418
|
+
});
|
|
419
|
+
Object.assign(target, { offsetTop: 100 });
|
|
420
|
+
Object.assign(target, { offsetLeft: 100 });
|
|
421
|
+
});
|
|
187
422
|
test('return result as expected when container scrolled', () => {
|
|
188
423
|
container.scrollTop = 20;
|
|
189
424
|
container.scrollLeft = 20;
|
|
@@ -7,6 +7,11 @@ const FeatureFlagsMap = {
|
|
|
7
7
|
createdTimestamp: 1660330561422,
|
|
8
8
|
createdAtVersion: '1.2.0',
|
|
9
9
|
},
|
|
10
|
+
'POSITION.FIX_TARGET_POSITION_WHEN_PARENT_IS_RELATIVE': {
|
|
11
|
+
description: `Feature flag to enable the new calculate of target position. this change is suitable the case which target have relative parent`,
|
|
12
|
+
createdTimestamp: 1660800418146,
|
|
13
|
+
createdAtVersion: '1.3.0',
|
|
14
|
+
},
|
|
10
15
|
};
|
|
11
16
|
const FeatureFlagsMap$1 = Object.freeze(FeatureFlagsMap);
|
|
12
17
|
|
package/dist/esm/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { L as LogUtility } from './log-374f2d69.js';
|
|
|
3
3
|
export { b as BackgroundColors, c as BorderColors, B as BorderRadius, a as Breakpoints, C as Colors, S as Shadows, d as Spacing, T as TextColors } from './typeGuard-edb77afc.js';
|
|
4
4
|
export { I as Icons, g as getIconFromToken } from './icons-08b1359e.js';
|
|
5
5
|
export { B as BreakpointKeys } from './ui-7e43c621.js';
|
|
6
|
-
export { F as FeatureFlag } from './featureFlagController-
|
|
6
|
+
export { F as FeatureFlag } from './featureFlagController-c4da7f0a.js';
|
|
7
7
|
import './number-930a4cd6.js';
|
|
8
8
|
|
|
9
9
|
/* This file is generated by vega-design 2.0.60 */
|
package/dist/esm/loader.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { p as promiseResolve, b as bootstrapLazy } from './index-35aa4542.js';
|
|
2
|
-
import { g as globalScripts } from './app-globals-
|
|
3
|
-
import './featureFlagController-
|
|
2
|
+
import { g as globalScripts } from './app-globals-0bb1611b.js';
|
|
3
|
+
import './featureFlagController-c4da7f0a.js';
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
Stencil Client Patch Esm v2.14.0 | MIT Licensed | https://stenciljs.com
|