@db-ux/react-core-components 4.4.0 → 4.4.1-floating-components-066d296
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
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @db-ux/react-core-components
|
|
2
2
|
|
|
3
|
+
## 4.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: issue with tailwind not reflecting adaptive color changes with `[data-color="xxx"]` - [see commit 936638d](https://github.com/db-ux-design-system/core-web/commit/936638d672bbb6c0f8a0ecf77bf41fafa0e31656)
|
|
8
|
+
|
|
9
|
+
- DBCustomSelect: Prevent floating label from flickering during initial render - [see commit e5ceff8](https://github.com/db-ux-design-system/core-web/commit/e5ceff861534186cf86d1f5f0a876e04aeac9e41)
|
|
10
|
+
|
|
3
11
|
## 4.4.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -26,7 +26,7 @@ function DBPopoverFn(props, component) {
|
|
|
26
26
|
const article = _ref.current.querySelector("article");
|
|
27
27
|
if (article) {
|
|
28
28
|
// This is a workaround for angular
|
|
29
|
-
utilsDelay(() => {
|
|
29
|
+
void utilsDelay(() => {
|
|
30
30
|
var _a;
|
|
31
31
|
handleFixedPopover(article, _ref.current, (_a = props.placement) !== null && _a !== void 0 ? _a : "bottom");
|
|
32
32
|
}, 1);
|
|
@@ -36,7 +36,7 @@ function DBTooltipFn(props, component) {
|
|
|
36
36
|
return;
|
|
37
37
|
if (_ref.current) {
|
|
38
38
|
// This is a workaround for angular
|
|
39
|
-
utilsDelay(() => {
|
|
39
|
+
void utilsDelay(() => {
|
|
40
40
|
var _a;
|
|
41
41
|
// Due to race conditions we need to check for _ref again
|
|
42
42
|
if (_ref.current) {
|
|
@@ -70,6 +70,7 @@ function DBTooltipFn(props, component) {
|
|
|
70
70
|
if (_ref.current && initialized && _id) {
|
|
71
71
|
const parent = getParent();
|
|
72
72
|
if (parent) {
|
|
73
|
+
handleAutoPlacement(parent);
|
|
73
74
|
["mouseenter", "focusin"].forEach((event) => {
|
|
74
75
|
parent.addEventListener(event, () => handleEnter(parent));
|
|
75
76
|
});
|
|
@@ -228,10 +228,54 @@ export const getFloatingProps = (element, parent, placement) => {
|
|
|
228
228
|
innerHeight
|
|
229
229
|
};
|
|
230
230
|
};
|
|
231
|
+
const MAX_ANCESTOR_DEPTH = 10;
|
|
232
|
+
const ancestorCache = new WeakMap();
|
|
233
|
+
const getAncestorHasCorrectedPlacement = (element) => {
|
|
234
|
+
if (ancestorCache.has(element)) {
|
|
235
|
+
return ancestorCache.get(element);
|
|
236
|
+
}
|
|
237
|
+
let current = element.parentElement;
|
|
238
|
+
let anchor = 0;
|
|
239
|
+
while (current && anchor < MAX_ANCESTOR_DEPTH) {
|
|
240
|
+
if (current.dataset['correctedPlacement']) {
|
|
241
|
+
ancestorCache.set(element, current);
|
|
242
|
+
return current;
|
|
243
|
+
}
|
|
244
|
+
current = current.parentElement;
|
|
245
|
+
anchor += 1;
|
|
246
|
+
}
|
|
247
|
+
ancestorCache.set(element, null);
|
|
248
|
+
return null;
|
|
249
|
+
};
|
|
231
250
|
export const handleFixedPopover = (element, parent, placement) => {
|
|
232
|
-
var _a;
|
|
233
|
-
const
|
|
234
|
-
const
|
|
251
|
+
var _a, _b;
|
|
252
|
+
const parentComputedStyles = getComputedStyle(parent);
|
|
253
|
+
const parentHasFloatingPosition = ['absolute', 'fixed'].includes(parentComputedStyles.position);
|
|
254
|
+
const ancestorWithCorrectedPlacement = getAncestorHasCorrectedPlacement(element);
|
|
255
|
+
const noFloatingAncestor = !ancestorWithCorrectedPlacement && !parentHasFloatingPosition;
|
|
256
|
+
const distance = (_b = (_a = getComputedStyle(element)) === null || _a === void 0 ? void 0 : _a.getPropertyValue('--db-popover-distance')) !== null && _b !== void 0 ? _b : '0px';
|
|
257
|
+
let { top, height, width, childHeight, childWidth, right, left, bottom, correctedPlacement, innerWidth, innerHeight } = getFloatingProps(element, parent, placement);
|
|
258
|
+
if (ancestorWithCorrectedPlacement) {
|
|
259
|
+
const ancestorRect = ancestorWithCorrectedPlacement.getBoundingClientRect();
|
|
260
|
+
left = Math.abs(left - ancestorRect.left);
|
|
261
|
+
right = (width + Math.abs(right - ancestorRect.right)) * 1.5; // We add a transform -50% later
|
|
262
|
+
top = Math.abs(top - ancestorRect.top);
|
|
263
|
+
bottom = (height + Math.abs(bottom - ancestorRect.bottom)) * 1.5; // We add a transform -50% later
|
|
264
|
+
}
|
|
265
|
+
if (parentHasFloatingPosition) {
|
|
266
|
+
/*
|
|
267
|
+
* If we have a floating element inside an element with position:absolute/fixed
|
|
268
|
+
* we need to calculate with relative values
|
|
269
|
+
* */
|
|
270
|
+
left = 0;
|
|
271
|
+
right = width;
|
|
272
|
+
top = 0;
|
|
273
|
+
bottom = height;
|
|
274
|
+
if (['auto', 'inherit', '0'].includes(parentComputedStyles.zIndex)) {
|
|
275
|
+
// We need the default zIndex for floating elements on the parent
|
|
276
|
+
parent.style.zIndex = '1';
|
|
277
|
+
}
|
|
278
|
+
}
|
|
235
279
|
// Tooltip arrow position
|
|
236
280
|
if (childWidth > width && (correctedPlacement.startsWith('bottom') || correctedPlacement.startsWith('top'))) {
|
|
237
281
|
const diff = width / 2 / childWidth * 100;
|
|
@@ -241,6 +285,9 @@ export const handleFixedPopover = (element, parent, placement) => {
|
|
|
241
285
|
else if (correctedPlacement.endsWith('end')) {
|
|
242
286
|
element.style.setProperty('--db-tooltip-arrow-inline-start', `${100 - diff}%`);
|
|
243
287
|
}
|
|
288
|
+
else {
|
|
289
|
+
element.style.setProperty('--db-tooltip-arrow-inline-start', `50%`);
|
|
290
|
+
}
|
|
244
291
|
}
|
|
245
292
|
if (childHeight > height && (correctedPlacement.startsWith('left') || correctedPlacement.startsWith('bottom'))) {
|
|
246
293
|
const diff = height / 2 / childHeight * 100;
|
|
@@ -250,6 +297,9 @@ export const handleFixedPopover = (element, parent, placement) => {
|
|
|
250
297
|
else if (correctedPlacement.endsWith('end')) {
|
|
251
298
|
element.style.setProperty('--db-tooltip-arrow-block-start', `${100 - diff}%`);
|
|
252
299
|
}
|
|
300
|
+
else {
|
|
301
|
+
element.style.setProperty('--db-tooltip-arrow-block-start', `50%`);
|
|
302
|
+
}
|
|
253
303
|
}
|
|
254
304
|
// Popover position
|
|
255
305
|
if (correctedPlacement === 'right' || correctedPlacement === 'left') {
|
|
@@ -259,11 +309,11 @@ export const handleFixedPopover = (element, parent, placement) => {
|
|
|
259
309
|
else if (correctedPlacement === 'right-start' || correctedPlacement === 'left-start') {
|
|
260
310
|
const end = top + childHeight;
|
|
261
311
|
element.style.insetBlockStart = `${top}px`;
|
|
262
|
-
element.style.insetBlockEnd = `${end > innerHeight ? innerHeight : end}px`;
|
|
312
|
+
element.style.insetBlockEnd = `${!parentHasFloatingPosition && end > innerHeight ? innerHeight : end}px`;
|
|
263
313
|
}
|
|
264
314
|
else if (correctedPlacement === 'right-end' || correctedPlacement === 'left-end') {
|
|
265
315
|
const start = bottom - childHeight;
|
|
266
|
-
element.style.insetBlockStart = `${start < 0 ? 0 : start}px`;
|
|
316
|
+
element.style.insetBlockStart = `${!parentHasFloatingPosition && start < 0 ? 0 : start}px`;
|
|
267
317
|
element.style.insetBlockEnd = `${bottom}px`;
|
|
268
318
|
}
|
|
269
319
|
else if (correctedPlacement === 'top' || correctedPlacement === 'bottom') {
|
|
@@ -273,32 +323,32 @@ export const handleFixedPopover = (element, parent, placement) => {
|
|
|
273
323
|
else if (correctedPlacement === 'top-start' || correctedPlacement === 'bottom-start') {
|
|
274
324
|
const end = left + childWidth;
|
|
275
325
|
element.style.insetInlineStart = `${left}px`;
|
|
276
|
-
element.style.insetInlineEnd = `${end > innerWidth ? innerWidth : end}px`;
|
|
326
|
+
element.style.insetInlineEnd = `${!parentHasFloatingPosition && end > innerWidth ? innerWidth : end}px`;
|
|
277
327
|
}
|
|
278
328
|
else if (correctedPlacement === 'top-end' || correctedPlacement === 'bottom-end') {
|
|
279
|
-
const start =
|
|
280
|
-
element.style.insetInlineStart = `${
|
|
281
|
-
element.style.insetInlineEnd = `${
|
|
329
|
+
const start = right - childWidth;
|
|
330
|
+
element.style.insetInlineStart = `${!parentHasFloatingPosition && start < 0 ? 0 : start}px`;
|
|
331
|
+
element.style.insetInlineEnd = `${right}px`;
|
|
282
332
|
}
|
|
283
333
|
if (correctedPlacement === null || correctedPlacement === void 0 ? void 0 : correctedPlacement.startsWith('right')) {
|
|
284
334
|
const end = right + childWidth;
|
|
285
335
|
element.style.insetInlineStart = `calc(${right}px + ${distance})`;
|
|
286
|
-
element.style.insetInlineEnd = `calc(${end > innerWidth ? innerWidth : end}px + ${distance})`;
|
|
336
|
+
element.style.insetInlineEnd = `calc(${noFloatingAncestor && end > innerWidth ? innerWidth : end}px + ${distance})`;
|
|
287
337
|
}
|
|
288
338
|
else if (correctedPlacement === null || correctedPlacement === void 0 ? void 0 : correctedPlacement.startsWith('left')) {
|
|
289
339
|
const start = left - childWidth;
|
|
290
|
-
element.style.insetInlineStart = `calc(${start < 0 ? 0 : start}px - ${distance})`;
|
|
340
|
+
element.style.insetInlineStart = `calc(${noFloatingAncestor && start < 0 ? 0 : start}px - ${distance})`;
|
|
291
341
|
element.style.insetInlineEnd = `calc(${right}px - ${distance})`;
|
|
292
342
|
}
|
|
293
343
|
else if (correctedPlacement === null || correctedPlacement === void 0 ? void 0 : correctedPlacement.startsWith('top')) {
|
|
294
344
|
const start = top - childHeight;
|
|
295
|
-
element.style.insetBlockStart = `calc(${start < 0 ? 0 : start}px - ${distance})`;
|
|
296
|
-
element.style.insetBlockEnd = `calc(${bottom}px - ${distance})`;
|
|
345
|
+
element.style.insetBlockStart = `calc(${noFloatingAncestor && start < 0 ? 0 : start}px - ${distance})`;
|
|
346
|
+
element.style.insetBlockEnd = `calc(${parentHasFloatingPosition ? start : bottom}px - ${distance})`;
|
|
297
347
|
}
|
|
298
348
|
else if (correctedPlacement === null || correctedPlacement === void 0 ? void 0 : correctedPlacement.startsWith('bottom')) {
|
|
299
349
|
const end = bottom + childHeight;
|
|
300
|
-
element.style.insetBlockStart = `calc(${bottom}px + ${distance})`;
|
|
301
|
-
element.style.insetBlockEnd = `calc(${end > innerHeight ? innerHeight : end}px + ${distance})`;
|
|
350
|
+
element.style.insetBlockStart = `calc(${parentHasFloatingPosition ? end : bottom}px + ${distance})`;
|
|
351
|
+
element.style.insetBlockEnd = `calc(${noFloatingAncestor && end > innerHeight ? innerHeight : end}px + ${distance})`;
|
|
302
352
|
}
|
|
303
353
|
element.style.position = 'fixed';
|
|
304
354
|
element.dataset['correctedPlacement'] = correctedPlacement;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@db-ux/react-core-components",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.1-floating-components-066d296",
|
|
4
4
|
"description": "React components for @db-ux/core-components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@playwright/experimental-ct-react": "1.57.0",
|
|
34
|
-
"@types/react": "19.2.
|
|
35
|
-
"react": "19.2.
|
|
36
|
-
"react-dom": "19.2.
|
|
34
|
+
"@types/react": "19.2.10",
|
|
35
|
+
"react": "19.2.4",
|
|
36
|
+
"react-dom": "19.2.4"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"sideEffects": false,
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@db-ux/core-components": "4.4.
|
|
45
|
-
"@db-ux/core-foundations": "4.4.
|
|
44
|
+
"@db-ux/core-components": "4.4.1-floating-components-066d296",
|
|
45
|
+
"@db-ux/core-foundations": "4.4.1-floating-components-066d296"
|
|
46
46
|
}
|
|
47
47
|
}
|