orcs-design-system 2.1.12 → 2.1.14
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.
|
@@ -336,7 +336,7 @@ export var keepInViewExample = function keepInViewExample() {
|
|
|
336
336
|
}, "Remove")), /*#__PURE__*/React.createElement(ActionsMenu, {
|
|
337
337
|
menuTopPosition: "30px",
|
|
338
338
|
menuLeftPosition: "0",
|
|
339
|
-
menuWidth: "
|
|
339
|
+
menuWidth: "200px",
|
|
340
340
|
customTriggerComponent: /*#__PURE__*/React.createElement(Button, {
|
|
341
341
|
variant: "ghost",
|
|
342
342
|
type: "button",
|
|
@@ -94,7 +94,7 @@ export var ActionsMenuItem = styled(function (props) {
|
|
|
94
94
|
}).withConfig({
|
|
95
95
|
displayName: "ActionsMenu__ActionsMenuItem",
|
|
96
96
|
componentId: "yvbni2-5"
|
|
97
|
-
})(["white-space:nowrap;display:block;width:100%;text-align:left;cursor:pointer;margin:0;padding:8px;appearance:none;background-color:", ";border:none;border-bottom:solid 1px ", ";border-radius:0;color:", ";font-size:", ";line-height:", ";font-family:", ";font-weight:", ";text-decoration:none;transition:", ";&:hover,&:focus{outline:0;background-color:", ";}&:first-child{border-radius:", " ", " 0 0;}&:last-child{border:0;border-radius:0 0 ", " ", ";}"], function (props) {
|
|
97
|
+
})(["white-space:nowrap;display:block;width:100%;text-align:left;cursor:pointer;margin:0;padding:8px;appearance:none;background-color:", ";border:none;border-bottom:solid 1px ", ";border-radius:0;color:", ";font-size:", ";line-height:", ";font-family:", ";font-weight:", ";text-decoration:none;transition:", ";&:hover,&:focus{outline:0;background-color:", ";}&:first-child{border-radius:", " ", " 0 0;}&:last-child{border:0;border-radius:0 0 ", " ", ";}&:only-child{border-radius:", ";}"], function (props) {
|
|
98
98
|
return props.selected ? themeGet("colors.successDark")(props) : "transparent";
|
|
99
99
|
}, function (props) {
|
|
100
100
|
return themeGet("colors.greyDarkest")(props);
|
|
@@ -120,6 +120,8 @@ export var ActionsMenuItem = styled(function (props) {
|
|
|
120
120
|
return themeGet("radii.2")(props);
|
|
121
121
|
}, function (props) {
|
|
122
122
|
return themeGet("radii.2")(props);
|
|
123
|
+
}, function (props) {
|
|
124
|
+
return themeGet("radii.2")(props);
|
|
123
125
|
});
|
|
124
126
|
export var ActionsMenuBody = function ActionsMenuBody(_ref) {
|
|
125
127
|
var theme = _ref.theme,
|
|
@@ -163,13 +165,14 @@ export var ActionsMenuBody = function ActionsMenuBody(_ref) {
|
|
|
163
165
|
|
|
164
166
|
var _useKeepInView = useKeepInView({
|
|
165
167
|
direction: direction,
|
|
166
|
-
callback: setMenuPosition
|
|
167
|
-
shown: true
|
|
168
|
+
callback: setMenuPosition
|
|
168
169
|
}),
|
|
169
|
-
_useKeepInView2 = _slicedToArray(_useKeepInView,
|
|
170
|
-
ref = _useKeepInView2[0]
|
|
170
|
+
_useKeepInView2 = _slicedToArray(_useKeepInView, 2),
|
|
171
|
+
ref = _useKeepInView2[0],
|
|
172
|
+
setIsShown = _useKeepInView2[1];
|
|
171
173
|
|
|
172
174
|
var onToggleInView = function onToggleInView(e) {
|
|
175
|
+
setIsShown(!toggleState);
|
|
173
176
|
onToggle(e);
|
|
174
177
|
};
|
|
175
178
|
|
package/es/hooks/keepInView.js
CHANGED
|
@@ -20,6 +20,16 @@ export var oppositeDirection = function oppositeDirection(direction) {
|
|
|
20
20
|
if (!direction || !directions[direction]) return "left";
|
|
21
21
|
return directions[direction];
|
|
22
22
|
};
|
|
23
|
+
|
|
24
|
+
var isWithinRootBounds = function isWithinRootBounds(intersectionObserverEntry) {
|
|
25
|
+
var rootBounds = intersectionObserverEntry.rootBounds;
|
|
26
|
+
var intersectionRect = intersectionObserverEntry.intersectionRect;
|
|
27
|
+
var topDiff = intersectionRect.top - rootBounds.top;
|
|
28
|
+
var leftDiff = intersectionRect.left - rootBounds.left;
|
|
29
|
+
var bottomDiff = intersectionRect.bottom - rootBounds.bottom;
|
|
30
|
+
var rightDiff = intersectionRect.right - rootBounds.right;
|
|
31
|
+
return topDiff > 0 && leftDiff > 0 && bottomDiff < -100 && rightDiff < -100;
|
|
32
|
+
};
|
|
23
33
|
/**
|
|
24
34
|
* This hook keeps track of the in view status of a component that has a direction setting, like a Popover or ActionsMenu.
|
|
25
35
|
*
|
|
@@ -39,6 +49,7 @@ export var oppositeDirection = function oppositeDirection(direction) {
|
|
|
39
49
|
*
|
|
40
50
|
*/
|
|
41
51
|
|
|
52
|
+
|
|
42
53
|
export var useKeepInView = function useKeepInView(_ref) {
|
|
43
54
|
var direction = _ref.direction,
|
|
44
55
|
_ref$shown = _ref.shown,
|
|
@@ -64,14 +75,17 @@ export var useKeepInView = function useKeepInView(_ref) {
|
|
|
64
75
|
|
|
65
76
|
var _useInView = useInView(inViewOptions),
|
|
66
77
|
ref = _useInView.ref,
|
|
67
|
-
inView = _useInView.inView
|
|
78
|
+
inView = _useInView.inView,
|
|
79
|
+
entry = _useInView.entry;
|
|
68
80
|
|
|
69
81
|
useEffect(function () {
|
|
70
82
|
if (!inView && isShown) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
83
|
+
if (isWithinRootBounds(entry)) {
|
|
84
|
+
var newDirection = oppositeDirection(lastDirection.direction);
|
|
85
|
+
callback(newDirection);
|
|
86
|
+
lastDirection.direction = newDirection;
|
|
87
|
+
}
|
|
74
88
|
}
|
|
75
|
-
}, [inView,
|
|
89
|
+
}, [inView, entry, isShown, callback, lastDirection]);
|
|
76
90
|
return [ref, setIsShown];
|
|
77
91
|
};
|