@ultraviolet/ui 1.26.0 → 1.26.2
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/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import react__default, { ReactNode, ComponentProps, ButtonHTMLAttributes, AriaRole, MouseEventHandler, JSX, MouseEvent, InputHTMLAttributes, HTMLAttributeAnchorTarget, AnchorHTMLAttributes, ReactElement, Ref, RefObject, KeyboardEventHandler, HTMLAttributes, CSSProperties, ChangeEventHandler, FocusEventHandler, ForwardRefExoticComponent, ForwardedRef, ElementType, TextareaHTMLAttributes } from 'react';
|
|
2
|
+
import react__default, { ReactNode, ComponentProps, ButtonHTMLAttributes, AriaRole, MouseEventHandler, JSX, MouseEvent, InputHTMLAttributes, FocusEvent, HTMLAttributeAnchorTarget, AnchorHTMLAttributes, ReactElement, Ref, RefObject, KeyboardEventHandler, HTMLAttributes, CSSProperties, ChangeEventHandler, FocusEventHandler, ForwardRefExoticComponent, ForwardedRef, ElementType, TextareaHTMLAttributes } from 'react';
|
|
3
3
|
import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
|
|
4
4
|
import * as _emotion_styled from '@emotion/styled';
|
|
5
5
|
import * as _emotion_react from '@emotion/react';
|
|
@@ -1382,8 +1382,16 @@ type CopyButtonProps = {
|
|
|
1382
1382
|
*/
|
|
1383
1383
|
declare const CopyButton: ({ size, value, copyText, copiedText, sentiment, noBorder, className, "data-testid": dataTestId, }: CopyButtonProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
1384
1384
|
|
|
1385
|
-
type DateInputProps = Pick<ReactDatePickerProps<string, boolean>, '
|
|
1385
|
+
type DateInputProps = Pick<ReactDatePickerProps<string, boolean>, 'locale' | 'onChange'> & {
|
|
1386
|
+
autoFocus?: boolean;
|
|
1387
|
+
disabled?: boolean;
|
|
1388
|
+
maxDate?: Date | null;
|
|
1389
|
+
minDate?: Date | null;
|
|
1390
|
+
name?: string;
|
|
1391
|
+
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
1392
|
+
onFocus?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
1386
1393
|
error?: string;
|
|
1394
|
+
required?: boolean;
|
|
1387
1395
|
format?: (value?: Date | string) => string | undefined;
|
|
1388
1396
|
/**
|
|
1389
1397
|
* Label of the field
|
|
@@ -28,49 +28,44 @@ const StyledBeforeScroll = /*#__PURE__*/_styled("span", {
|
|
|
28
28
|
}, "\n );cursor:w-resize;z-index:auto;");
|
|
29
29
|
const StyledScrollableWrapper = /*#__PURE__*/_styled("div", {
|
|
30
30
|
target: "e1id70w02"
|
|
31
|
-
})("overflow-x:scroll;overflow-y:hidden;white-space:nowrap;display:flex;padding:", _ref3 => {
|
|
31
|
+
})("overflow-x:scroll;overflow-y:hidden;white-space:nowrap;display:flex;padding:0 100px;gap:", _ref3 => {
|
|
32
32
|
let {
|
|
33
33
|
theme
|
|
34
34
|
} = _ref3;
|
|
35
35
|
return theme.space['2'];
|
|
36
|
-
}, " 100px;gap:", _ref4 => {
|
|
37
|
-
let {
|
|
38
|
-
theme
|
|
39
|
-
} = _ref4;
|
|
40
|
-
return theme.space['2'];
|
|
41
36
|
}, ";");
|
|
42
37
|
const StyledAfterScroll = /*#__PURE__*/_styled("span", {
|
|
43
38
|
target: "e1id70w01"
|
|
44
|
-
})("position:absolute;bottom:0;right:0;width:100px;height:100%;content:'';cursor:e-resize;z-index:auto;background:linear-gradient(\n -90deg,\n ",
|
|
39
|
+
})("position:absolute;bottom:0;right:0;width:100px;height:100%;content:'';cursor:e-resize;z-index:auto;background:linear-gradient(\n -90deg,\n ", _ref4 => {
|
|
45
40
|
let {
|
|
46
41
|
theme
|
|
47
|
-
} =
|
|
42
|
+
} = _ref4;
|
|
48
43
|
return theme.colors.neutral.background;
|
|
49
|
-
}, ",\n ",
|
|
44
|
+
}, ",\n ", _ref5 => {
|
|
50
45
|
let {
|
|
51
46
|
theme
|
|
52
|
-
} =
|
|
47
|
+
} = _ref5;
|
|
53
48
|
return theme.colors.neutral.background;
|
|
54
49
|
}, "ff\n );");
|
|
55
50
|
const StyledBorderWrapper = /*#__PURE__*/_styled('div', {
|
|
56
51
|
shouldForwardProp: prop => !['width'].includes(prop),
|
|
57
52
|
target: "e1id70w00"
|
|
58
|
-
})("display:flex;align-items:stretch;width:",
|
|
53
|
+
})("display:flex;align-items:stretch;width:", _ref6 => {
|
|
59
54
|
let {
|
|
60
55
|
width
|
|
61
|
-
} =
|
|
56
|
+
} = _ref6;
|
|
62
57
|
return width;
|
|
63
|
-
}, ";max-width:",
|
|
58
|
+
}, ";max-width:", _ref7 => {
|
|
64
59
|
let {
|
|
65
60
|
width
|
|
66
|
-
} =
|
|
61
|
+
} = _ref7;
|
|
67
62
|
return width;
|
|
68
63
|
}, ";overflow-wrap:break-word;white-space:normal;height:auto;cursor:grab;flex-shrink:0;");
|
|
69
|
-
const CarouselItem =
|
|
64
|
+
const CarouselItem = _ref8 => {
|
|
70
65
|
let {
|
|
71
66
|
children,
|
|
72
67
|
width = '240px'
|
|
73
|
-
} =
|
|
68
|
+
} = _ref8;
|
|
74
69
|
return jsx(StyledBorderWrapper, {
|
|
75
70
|
width: width,
|
|
76
71
|
draggable: "true",
|
|
@@ -80,12 +75,12 @@ const CarouselItem = _ref9 => {
|
|
|
80
75
|
/**
|
|
81
76
|
* Carousel component allows you to scroll horizontally through a list of items.
|
|
82
77
|
*/
|
|
83
|
-
const Carousel =
|
|
78
|
+
const Carousel = _ref9 => {
|
|
84
79
|
let {
|
|
85
80
|
children,
|
|
86
81
|
className,
|
|
87
82
|
'data-testid': dataTestId = 'scrollbar'
|
|
88
|
-
} =
|
|
83
|
+
} = _ref9;
|
|
89
84
|
const scrollRef = useRef(null);
|
|
90
85
|
let intervalLeft;
|
|
91
86
|
let intervalRight;
|
|
@@ -18,6 +18,7 @@ const computePlacement = _ref => {
|
|
|
18
18
|
childrenStructuredRef,
|
|
19
19
|
popupStructuredRef,
|
|
20
20
|
offsetParentRect,
|
|
21
|
+
offsetParent,
|
|
21
22
|
popupPortalTarget
|
|
22
23
|
} = _ref;
|
|
23
24
|
const {
|
|
@@ -30,9 +31,10 @@ const computePlacement = _ref => {
|
|
|
30
31
|
left: parentLeft,
|
|
31
32
|
right: parentRight
|
|
32
33
|
} = offsetParentRect;
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
34
|
+
const isPopupPortalTargetBody = popupPortalTarget === document.body || offsetParent === document.body;
|
|
35
|
+
const overloadedChildrenLeft = isPopupPortalTargetBody ? childrenLeft : childrenLeft - parentLeft;
|
|
36
|
+
const overloadedChildrenTop = isPopupPortalTargetBody ? childrenTop : childrenTop - parentTop;
|
|
37
|
+
const overloadedChildrenRight = isPopupPortalTargetBody ? childrenRight : childrenRight - parentRight;
|
|
36
38
|
const {
|
|
37
39
|
width: popupWidth,
|
|
38
40
|
height: popupHeight
|
|
@@ -48,6 +50,35 @@ const computePlacement = _ref => {
|
|
|
48
50
|
}
|
|
49
51
|
return 'top';
|
|
50
52
|
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* This function will check if the offset parent is usable for popup positioning
|
|
56
|
+
* If not it will loop and search for a compatible parent until document.body is reached
|
|
57
|
+
*/
|
|
58
|
+
const findOffsetParent = element => {
|
|
59
|
+
const offsetParent = element?.current?.offsetParent;
|
|
60
|
+
|
|
61
|
+
// We need to check if offsetParent is a table cell or a table because they are not suitable for positioning
|
|
62
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
|
|
63
|
+
if (offsetParent && !['TH', 'TD', 'TABLE'].includes(offsetParent.tagName)) {
|
|
64
|
+
return offsetParent;
|
|
65
|
+
}
|
|
66
|
+
let currentElement = element?.current;
|
|
67
|
+
while (currentElement && currentElement.tagName !== 'BODY') {
|
|
68
|
+
const {
|
|
69
|
+
position
|
|
70
|
+
} = window.getComputedStyle(currentElement);
|
|
71
|
+
|
|
72
|
+
// Check if the current element is a potential offset parent
|
|
73
|
+
if (position !== 'static') {
|
|
74
|
+
return currentElement;
|
|
75
|
+
}
|
|
76
|
+
currentElement = currentElement.parentElement;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// If no suitable offset parent is found, return the body element
|
|
80
|
+
return document.body;
|
|
81
|
+
};
|
|
51
82
|
/**
|
|
52
83
|
* This function will compute the positions of popup and arrow based on children position and popup size
|
|
53
84
|
*/
|
|
@@ -58,18 +89,20 @@ const computePositions = _ref2 => {
|
|
|
58
89
|
popupRef,
|
|
59
90
|
popupPortalTarget
|
|
60
91
|
} = _ref2;
|
|
61
|
-
const
|
|
62
|
-
const
|
|
92
|
+
const childrenRect = childrenRef.current.getBoundingClientRect();
|
|
93
|
+
const offsetParent = findOffsetParent(childrenRef);
|
|
94
|
+
const offsetParentRect = offsetParent?.getBoundingClientRect() ?? {
|
|
63
95
|
top: 0,
|
|
64
96
|
left: 0,
|
|
65
97
|
right: 0
|
|
66
98
|
};
|
|
67
99
|
const popupStructuredRef = popupRef.current.getBoundingClientRect();
|
|
68
100
|
const placementBasedOnWindowSize = placement === 'auto' ? computePlacement({
|
|
69
|
-
childrenStructuredRef,
|
|
101
|
+
childrenStructuredRef: childrenRect,
|
|
70
102
|
popupStructuredRef,
|
|
71
|
-
offsetParentRect
|
|
72
|
-
popupPortalTarget
|
|
103
|
+
offsetParentRect,
|
|
104
|
+
popupPortalTarget,
|
|
105
|
+
offsetParent
|
|
73
106
|
}) : placement;
|
|
74
107
|
const {
|
|
75
108
|
top: childrenTop,
|
|
@@ -77,7 +110,7 @@ const computePositions = _ref2 => {
|
|
|
77
110
|
right: childrenRight,
|
|
78
111
|
width: childrenWidth,
|
|
79
112
|
height: childrenHeight
|
|
80
|
-
} =
|
|
113
|
+
} = childrenRect;
|
|
81
114
|
const {
|
|
82
115
|
top: parentTop,
|
|
83
116
|
left: parentLeft,
|
|
@@ -88,13 +121,16 @@ const computePositions = _ref2 => {
|
|
|
88
121
|
height: popupHeight
|
|
89
122
|
} = popupStructuredRef;
|
|
90
123
|
|
|
124
|
+
// offSetParent is the closest positioned ancestor. If the element is not positioned, the nearest table cell or root element is used.
|
|
125
|
+
const isPopupPortalTargetBody = popupPortalTarget === document.body || offsetParent === document.body;
|
|
126
|
+
|
|
91
127
|
// It will get how much scroll is done on the page to compute the position of the popup
|
|
92
|
-
const scrollTopValue =
|
|
128
|
+
const scrollTopValue = isPopupPortalTargetBody ? document.documentElement.scrollTop : offsetParent.scrollTop;
|
|
93
129
|
|
|
94
130
|
// We need to compute the position of the popup based on the parent element in the case the popup is not in the body
|
|
95
|
-
const overloadedChildrenLeft =
|
|
96
|
-
const overloadedChildrenTop =
|
|
97
|
-
const overloadedChildrenRight =
|
|
131
|
+
const overloadedChildrenLeft = isPopupPortalTargetBody ? childrenLeft : childrenLeft - parentLeft;
|
|
132
|
+
const overloadedChildrenTop = isPopupPortalTargetBody ? childrenTop : childrenTop - parentTop;
|
|
133
|
+
const overloadedChildrenRight = isPopupPortalTargetBody ? childrenRight : childrenRight + childrenWidth + ARROW_WIDTH + SPACE - parentRight / 2;
|
|
98
134
|
switch (placementBasedOnWindowSize) {
|
|
99
135
|
case 'bottom':
|
|
100
136
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultraviolet/ui",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.2",
|
|
4
4
|
"description": "Ultraviolet UI",
|
|
5
5
|
"homepage": "https://github.com/scaleway/ultraviolet#readme",
|
|
6
6
|
"repository": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"deepmerge": "4.3.1",
|
|
63
63
|
"react-datepicker": "4.21.0",
|
|
64
64
|
"react-flatten-children": "1.1.2",
|
|
65
|
-
"react-select": "5.
|
|
65
|
+
"react-select": "5.8.0",
|
|
66
66
|
"react-toastify": "9.1.3",
|
|
67
67
|
"react-use-clipboard": "1.0.9",
|
|
68
68
|
"reakit": "1.3.11",
|