@sprinklrjs/spaceweb 14.14.2 → 14.14.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/asyncSelect/hooks/useAsyncSelect.d.ts +3 -3
- package/asyncSelect/hooks/useGroupedAsyncSelect.d.ts +3 -3
- package/baseui/layer/tether.js +6 -3
- package/baseui/layer/types.d.ts +5 -0
- package/baseui/layer/utils.d.ts +25 -0
- package/baseui/layer/utils.js +74 -1
- package/baseui/popover/popover.js +61 -13
- package/baseui/popover/stateful-container.js +2 -1
- package/baseui/popover/styled-components.js +5 -0
- package/baseui/popover/types.d.ts +7 -0
- package/esm/asyncSelect/hooks/useAsyncSelect.d.ts +3 -3
- package/esm/asyncSelect/hooks/useGroupedAsyncSelect.d.ts +3 -3
- package/esm/baseui/layer/tether.js +7 -4
- package/esm/baseui/layer/types.d.ts +5 -0
- package/esm/baseui/layer/utils.d.ts +25 -0
- package/esm/baseui/layer/utils.js +71 -0
- package/esm/baseui/popover/popover.js +61 -13
- package/esm/baseui/popover/stateful-container.js +2 -1
- package/esm/baseui/popover/styled-components.js +5 -0
- package/esm/baseui/popover/types.d.ts +7 -0
- package/esm/popover/popover.js +2 -2
- package/esm/tooltip/disabled-tooltip-container.d.ts +1 -0
- package/esm/tooltip/stateful-tooltip-container.d.ts +1 -0
- package/esm/tooltip/stateful-tooltip.d.ts +1 -0
- package/package.json +2 -2
- package/popover/popover.js +2 -2
- package/tooltip/disabled-tooltip-container.d.ts +1 -0
- package/tooltip/stateful-tooltip-container.d.ts +1 -0
- package/tooltip/stateful-tooltip.d.ts +1 -0
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -112,6 +112,8 @@ export type PopperDataObject = {
|
|
|
112
112
|
popper: PopperOffset;
|
|
113
113
|
};
|
|
114
114
|
placement: string;
|
|
115
|
+
/** Set by popper.js `hide` modifier when the reference element is out of bounds. */
|
|
116
|
+
hide?: boolean;
|
|
115
117
|
};
|
|
116
118
|
export type PopperOptions = {
|
|
117
119
|
placement: string;
|
|
@@ -146,6 +148,9 @@ export type TetherProps = {
|
|
|
146
148
|
repositionOnResize?: boolean;
|
|
147
149
|
/** When true, Popper.js uses fixed positioning math (must match CSS `position: fixed` on the popper). */
|
|
148
150
|
positionFixed?: boolean;
|
|
151
|
+
/** When true, popper's `hide` modifier checks whether the anchor is clipped by any of its scroll parents
|
|
152
|
+
or the viewport, and reports it as `data.hide` in `onPopperUpdate`. */
|
|
153
|
+
hideWhenTargetClipped?: boolean;
|
|
149
154
|
};
|
|
150
155
|
export type TetherState = {
|
|
151
156
|
isMounted: boolean;
|
|
@@ -4,3 +4,28 @@ export declare function toPopperPlacement(placement: TetherPlacement): string;
|
|
|
4
4
|
* Takes the offset passed from popper.js and normalizes it
|
|
5
5
|
*/
|
|
6
6
|
export declare function parsePopperOffset(offset: PopperOffset): NormalizedOffset;
|
|
7
|
+
/**
|
|
8
|
+
* Returns true when no part of the reference is visible after clipping it by every
|
|
9
|
+
* scroll parent (nested scroll containers) and the viewport.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isReferenceClipped(reference: Element, scrollParents?: Array<Element | Window>): boolean;
|
|
12
|
+
type HideModifierData = {
|
|
13
|
+
hide?: boolean;
|
|
14
|
+
instance: {
|
|
15
|
+
reference: Element;
|
|
16
|
+
scheduleUpdate: () => void;
|
|
17
|
+
state: {
|
|
18
|
+
scrollParents?: Array<Element | Window>;
|
|
19
|
+
};
|
|
20
|
+
options?: {
|
|
21
|
+
eventsEnabled?: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Replacement for popper.js v1 `hide` modifier. The default one only checks the `preventOverflow`
|
|
27
|
+
* boundary (viewport by default), this one checks all clipping parents.
|
|
28
|
+
* Popper re-runs modifiers on scroll of any registered parent, including parents with overflow hidden.
|
|
29
|
+
*/
|
|
30
|
+
export declare function hideWhenReferenceClipped<T extends HideModifierData>(data: T): T;
|
|
31
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
1
2
|
export function toPopperPlacement(placement) {
|
|
2
3
|
return placement.replace(/(Top|Left)$/, '-start').replace(/(Right|Bottom)$/, '-end');
|
|
3
4
|
}
|
|
@@ -10,3 +11,73 @@ export function parsePopperOffset(offset) {
|
|
|
10
11
|
left: Math.floor(offset.left || 0),
|
|
11
12
|
};
|
|
12
13
|
}
|
|
14
|
+
// Visible (padding-box) area of a scroll parent, excluding borders and scrollbars
|
|
15
|
+
function getClipRect(scrollParent) {
|
|
16
|
+
if ('document' in scrollParent) {
|
|
17
|
+
var _a = scrollParent.document.documentElement, clientWidth = _a.clientWidth, clientHeight = _a.clientHeight;
|
|
18
|
+
return { top: 0, left: 0, bottom: clientHeight, right: clientWidth };
|
|
19
|
+
}
|
|
20
|
+
var _b = scrollParent.getBoundingClientRect(), top = _b.top, left = _b.left;
|
|
21
|
+
var clipTop = top + scrollParent.clientTop;
|
|
22
|
+
var clipLeft = left + scrollParent.clientLeft;
|
|
23
|
+
return {
|
|
24
|
+
top: clipTop,
|
|
25
|
+
left: clipLeft,
|
|
26
|
+
bottom: clipTop + scrollParent.clientHeight,
|
|
27
|
+
right: clipLeft + scrollParent.clientWidth,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function getClippingParents(reference) {
|
|
31
|
+
var _a;
|
|
32
|
+
var clippingParents = [];
|
|
33
|
+
var ownerWindow = (_a = reference.ownerDocument.defaultView) !== null && _a !== void 0 ? _a : window;
|
|
34
|
+
var parent = reference.parentElement;
|
|
35
|
+
while (parent) {
|
|
36
|
+
var _b = ownerWindow.getComputedStyle(parent), overflow = _b.overflow, overflowX = _b.overflowX, overflowY = _b.overflowY;
|
|
37
|
+
if (/(auto|scroll|overlay|hidden|clip)/.test("".concat(overflow, " ").concat(overflowX, " ").concat(overflowY))) {
|
|
38
|
+
clippingParents.push(parent);
|
|
39
|
+
}
|
|
40
|
+
parent = parent.parentElement;
|
|
41
|
+
}
|
|
42
|
+
return clippingParents;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns true when no part of the reference is visible after clipping it by every
|
|
46
|
+
* scroll parent (nested scroll containers) and the viewport.
|
|
47
|
+
*/
|
|
48
|
+
export function isReferenceClipped(reference, scrollParents) {
|
|
49
|
+
var _a;
|
|
50
|
+
if (scrollParents === void 0) { scrollParents = []; }
|
|
51
|
+
var _b = reference.getBoundingClientRect(), top = _b.top, left = _b.left, bottom = _b.bottom, right = _b.right;
|
|
52
|
+
var viewport = (_a = reference.ownerDocument.defaultView) !== null && _a !== void 0 ? _a : window;
|
|
53
|
+
// viewport is always a clipping boundary, even when popper event listeners are disabled
|
|
54
|
+
__spreadArray(__spreadArray([], __read(scrollParents), false), [viewport], false).forEach(function (scrollParent) {
|
|
55
|
+
var clip = getClipRect(scrollParent);
|
|
56
|
+
top = Math.max(top, clip.top);
|
|
57
|
+
left = Math.max(left, clip.left);
|
|
58
|
+
bottom = Math.min(bottom, clip.bottom);
|
|
59
|
+
right = Math.min(right, clip.right);
|
|
60
|
+
});
|
|
61
|
+
// strict comparison so zero-sized references (e.g. collapsed text anchors) are not treated as clipped
|
|
62
|
+
return bottom < top || right < left;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Replacement for popper.js v1 `hide` modifier. The default one only checks the `preventOverflow`
|
|
66
|
+
* boundary (viewport by default), this one checks all clipping parents.
|
|
67
|
+
* Popper re-runs modifiers on scroll of any registered parent, including parents with overflow hidden.
|
|
68
|
+
*/
|
|
69
|
+
export function hideWhenReferenceClipped(data) {
|
|
70
|
+
var _a;
|
|
71
|
+
var _b = data.instance, reference = _b.reference, scheduleUpdate = _b.scheduleUpdate, state = _b.state, options = _b.options;
|
|
72
|
+
var scrollParents = (_a = state.scrollParents) !== null && _a !== void 0 ? _a : (state.scrollParents = []);
|
|
73
|
+
if ((options === null || options === void 0 ? void 0 : options.eventsEnabled) !== false) {
|
|
74
|
+
getClippingParents(reference).forEach(function (parent) {
|
|
75
|
+
if (!scrollParents.includes(parent)) {
|
|
76
|
+
scrollParents.push(parent);
|
|
77
|
+
parent.addEventListener('scroll', scheduleUpdate, { passive: true });
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
data.hide = isReferenceClipped(reference, scrollParents);
|
|
82
|
+
return data;
|
|
83
|
+
}
|
|
@@ -31,6 +31,7 @@ function getDefaultState(props) {
|
|
|
31
31
|
isLayerMounted: false,
|
|
32
32
|
autoFocusAfterPositioning: false,
|
|
33
33
|
contentHost: null,
|
|
34
|
+
isTargetClipped: false,
|
|
34
35
|
};
|
|
35
36
|
}
|
|
36
37
|
var PopoverInner = /** @class */ (function (_super) {
|
|
@@ -40,13 +41,23 @@ var PopoverInner = /** @class */ (function (_super) {
|
|
|
40
41
|
_this.anchorRef = React.createRef();
|
|
41
42
|
_this.popperRef = React.createRef();
|
|
42
43
|
_this.arrowRef = React.createRef();
|
|
44
|
+
_this.focusedBeforeTargetClipped = null;
|
|
45
|
+
_this.focusMovedWhileTargetClipped = false;
|
|
43
46
|
/**
|
|
44
47
|
* Yes our "Stateless" popover still has state. This is private state that
|
|
45
48
|
* customers shouldn't have to manage themselves, such as positioning and
|
|
46
49
|
* other internal flags for managing animation states.
|
|
47
50
|
*/
|
|
48
|
-
// @ts-ignore
|
|
51
|
+
// @ts-ignore -- Popover types are a mess
|
|
49
52
|
_this.state = getDefaultState(_this.props);
|
|
53
|
+
_this.onFocusInWhileTargetClipped = function (event) {
|
|
54
|
+
if (event.target !== document.body && event.target !== document.documentElement) {
|
|
55
|
+
_this.focusMovedWhileTargetClipped = true;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
_this.onMouseDownWhileTargetClipped = function () {
|
|
59
|
+
_this.focusMovedWhileTargetClipped = true;
|
|
60
|
+
};
|
|
50
61
|
_this.animateIn = function () {
|
|
51
62
|
if (_this.props.isOpen) {
|
|
52
63
|
_this.setState({ isAnimating: true });
|
|
@@ -60,8 +71,9 @@ var PopoverInner = /** @class */ (function (_super) {
|
|
|
60
71
|
_this.setState({
|
|
61
72
|
isAnimating: false,
|
|
62
73
|
// Reset to ideal placement specified in props
|
|
63
|
-
// @ts-ignore
|
|
74
|
+
// @ts-ignore -- Popover types are a mess
|
|
64
75
|
placement: _this.props.placement,
|
|
76
|
+
isTargetClipped: false,
|
|
65
77
|
});
|
|
66
78
|
}, _this.props.animateOutTime || ANIMATE_OUT_TIME);
|
|
67
79
|
}
|
|
@@ -97,10 +109,11 @@ var PopoverInner = /** @class */ (function (_super) {
|
|
|
97
109
|
_this.onPopperUpdate = function (normalizedOffsets, data) {
|
|
98
110
|
var placement = fromPopperPlacement(data.placement) || PLACEMENT.top;
|
|
99
111
|
_this.setState({
|
|
100
|
-
// @ts-ignore
|
|
112
|
+
// @ts-ignore -- Popover types are a mess
|
|
101
113
|
arrowOffset: normalizedOffsets.arrow,
|
|
102
114
|
popoverOffset: normalizedOffsets.popper,
|
|
103
115
|
placement: placement,
|
|
116
|
+
isTargetClipped: Boolean(_this.props.hideWhenTargetClipped && data.hide),
|
|
104
117
|
});
|
|
105
118
|
// Now that element has been positioned, we can animate it in
|
|
106
119
|
_this.animateInTimer = setTimeout(_this.animateIn, ANIMATE_IN_TIME);
|
|
@@ -159,6 +172,9 @@ var PopoverInner = /** @class */ (function (_super) {
|
|
|
159
172
|
if (prevProps.placement !== this.props.placement) {
|
|
160
173
|
this.setState({ placement: (_a = this.props.placement) !== null && _a !== void 0 ? _a : PLACEMENT.auto });
|
|
161
174
|
}
|
|
175
|
+
if (prevState.isTargetClipped !== this.state.isTargetClipped) {
|
|
176
|
+
this.onTargetClippedChange();
|
|
177
|
+
}
|
|
162
178
|
if (__DEV__) {
|
|
163
179
|
if (!this.anchorRef.current) {
|
|
164
180
|
// eslint-disable-next-line no-console -- logging error in dev mode
|
|
@@ -184,6 +200,40 @@ var PopoverInner = /** @class */ (function (_super) {
|
|
|
184
200
|
};
|
|
185
201
|
PopoverInner.prototype.componentWillUnmount = function () {
|
|
186
202
|
this.clearTimers();
|
|
203
|
+
this.stopTrackingFocusWhileTargetClipped();
|
|
204
|
+
};
|
|
205
|
+
PopoverInner.prototype.stopTrackingFocusWhileTargetClipped = function () {
|
|
206
|
+
document.removeEventListener('focusin', this.onFocusInWhileTargetClipped);
|
|
207
|
+
document.removeEventListener('mousedown', this.onMouseDownWhileTargetClipped);
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Browsers blur the focused element when it becomes `visibility: hidden`.
|
|
211
|
+
* Restore that focus when the popover is shown again, unless the user has moved focus elsewhere meanwhile.
|
|
212
|
+
*/
|
|
213
|
+
PopoverInner.prototype.onTargetClippedChange = function () {
|
|
214
|
+
var activeElement = document.activeElement;
|
|
215
|
+
if (this.state.isTargetClipped) {
|
|
216
|
+
var popper = this.popperRef.current;
|
|
217
|
+
this.focusedBeforeTargetClipped =
|
|
218
|
+
popper && activeElement && popper.contains(activeElement) ? activeElement : null;
|
|
219
|
+
this.focusMovedWhileTargetClipped = false;
|
|
220
|
+
if (this.focusedBeforeTargetClipped) {
|
|
221
|
+
document.addEventListener('focusin', this.onFocusInWhileTargetClipped);
|
|
222
|
+
document.addEventListener('mousedown', this.onMouseDownWhileTargetClipped);
|
|
223
|
+
}
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
var elementToFocus = this.focusedBeforeTargetClipped;
|
|
227
|
+
var shouldRestoreFocus = this.props.isOpen &&
|
|
228
|
+
!this.focusMovedWhileTargetClipped &&
|
|
229
|
+
(elementToFocus === null || elementToFocus === void 0 ? void 0 : elementToFocus.isConnected) &&
|
|
230
|
+
(!activeElement || activeElement === document.body || activeElement === document.documentElement);
|
|
231
|
+
this.stopTrackingFocusWhileTargetClipped();
|
|
232
|
+
this.focusedBeforeTargetClipped = null;
|
|
233
|
+
this.focusMovedWhileTargetClipped = false;
|
|
234
|
+
if (shouldRestoreFocus && elementToFocus) {
|
|
235
|
+
elementToFocus.focus({ preventScroll: true });
|
|
236
|
+
}
|
|
187
237
|
};
|
|
188
238
|
PopoverInner.prototype.clearTimers = function () {
|
|
189
239
|
[
|
|
@@ -268,14 +318,13 @@ var PopoverInner = /** @class */ (function (_super) {
|
|
|
268
318
|
return anchorProps;
|
|
269
319
|
};
|
|
270
320
|
PopoverInner.prototype.getPopoverBodyProps = function () {
|
|
321
|
+
var _a;
|
|
271
322
|
var bodyProps = {};
|
|
272
|
-
var popoverId = this.getPopoverIdAttr();
|
|
323
|
+
var popoverId = (_a = this.getPopoverIdAttr()) !== null && _a !== void 0 ? _a : undefined;
|
|
273
324
|
if (this.isAccessibilityTypeMenu()) {
|
|
274
|
-
// @ts-ignore
|
|
275
325
|
bodyProps.id = popoverId;
|
|
276
326
|
}
|
|
277
327
|
else if (this.isAccessibilityTypeTooltip()) {
|
|
278
|
-
// @ts-ignore
|
|
279
328
|
bodyProps.id = popoverId;
|
|
280
329
|
bodyProps.role = 'tooltip';
|
|
281
330
|
}
|
|
@@ -287,12 +336,11 @@ var PopoverInner = /** @class */ (function (_super) {
|
|
|
287
336
|
};
|
|
288
337
|
PopoverInner.prototype.getSharedProps = function () {
|
|
289
338
|
var _a = this.props, isOpen = _a.isOpen, showArrow = _a.showArrow, _b = _a.popoverMargin, popoverMargin = _b === void 0 ? POPOVER_MARGIN : _b, _c = _a.positionFixed, positionFixed = _c === void 0 ? false : _c;
|
|
290
|
-
var _d = this.state, isAnimating = _d.isAnimating, arrowOffset = _d.arrowOffset, popoverOffset = _d.popoverOffset, placement = _d.placement;
|
|
339
|
+
var _d = this.state, isAnimating = _d.isAnimating, arrowOffset = _d.arrowOffset, popoverOffset = _d.popoverOffset, placement = _d.placement, isTargetClipped = _d.isTargetClipped;
|
|
291
340
|
return {
|
|
292
341
|
$showArrow: !!showArrow,
|
|
293
342
|
$arrowOffset: arrowOffset,
|
|
294
343
|
$popoverOffset: popoverOffset,
|
|
295
|
-
// @ts-ignore
|
|
296
344
|
$placement: placement,
|
|
297
345
|
$isAnimating: isAnimating,
|
|
298
346
|
$animationDuration: this.props.animateOutTime || ANIMATE_OUT_TIME,
|
|
@@ -300,6 +348,7 @@ var PopoverInner = /** @class */ (function (_super) {
|
|
|
300
348
|
$popoverMargin: popoverMargin,
|
|
301
349
|
$isHoverTrigger: this.isHoverTrigger(),
|
|
302
350
|
$positionFixed: positionFixed,
|
|
351
|
+
$isTargetClipped: isTargetClipped,
|
|
303
352
|
};
|
|
304
353
|
};
|
|
305
354
|
PopoverInner.prototype.getAnchorFromChildren = function () {
|
|
@@ -324,7 +373,7 @@ var PopoverInner = /** @class */ (function (_super) {
|
|
|
324
373
|
return React.cloneElement(anchor, anchorProps);
|
|
325
374
|
}
|
|
326
375
|
return (
|
|
327
|
-
// @ts-
|
|
376
|
+
// @ts-expect-error - there's a null in anchorProps.id
|
|
328
377
|
_jsx(Box, __assign({ "$as": "span" }, anchorProps, { children: anchor }), "popover-anchor"));
|
|
329
378
|
};
|
|
330
379
|
PopoverInner.prototype.renderPopover = function (renderedContent) {
|
|
@@ -368,7 +417,7 @@ var PopoverInner = /** @class */ (function (_super) {
|
|
|
368
417
|
// and have it replaced with the TetherBehavior props overrides
|
|
369
418
|
popperOptions: __assign(__assign({}, defaultPopperOptions), this.props.popperOptions), onPopperUpdate: this.onPopperUpdate,
|
|
370
419
|
// Placement is passed via props instead of state and used only for Popper.js configuration
|
|
371
|
-
placement: this.props.placement, repositionOnResize: this.props.repositionOnResize, positionFixed: this.props.positionFixed }, { children: this.props.focusLock && this.props.accessibilityType !== ACCESSIBILITY_TYPE.tooltip ? (_jsx(FocusLock, __assign({ disabled: !this.props.focusLock, noFocusGuards: false,
|
|
420
|
+
placement: this.props.placement, repositionOnResize: this.props.repositionOnResize, positionFixed: this.props.positionFixed, hideWhenTargetClipped: this.props.hideWhenTargetClipped }, { children: this.props.focusLock && this.props.accessibilityType !== ACCESSIBILITY_TYPE.tooltip ? (_jsx(FocusLock, __assign({ disabled: !this.props.focusLock, noFocusGuards: false,
|
|
372
421
|
// see popover-focus-loop.scenario.js for why hover cannot return focus
|
|
373
422
|
returnFocus: !this.isHoverTrigger() && this.props.returnFocus, autoFocus: this.state.autoFocusAfterPositioning,
|
|
374
423
|
// Allow focus to escape when UI is within an iframe
|
|
@@ -387,9 +436,8 @@ var PopoverInner = /** @class */ (function (_super) {
|
|
|
387
436
|
var Popover = function (props) {
|
|
388
437
|
var innerRef = props.innerRef;
|
|
389
438
|
var gID = useUID();
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
ref: innerRef }, props)));
|
|
439
|
+
// @ts-expect-error - ref type mismatch
|
|
440
|
+
return _jsx(PopoverInner, __assign({ id: props.id || gID, ref: innerRef }, props));
|
|
393
441
|
};
|
|
394
442
|
Popover.defaultProps = defaultProps;
|
|
395
443
|
export default Popover;
|
|
@@ -117,7 +117,7 @@ var StatefulContainer = /** @class */ (function (_super) {
|
|
|
117
117
|
};
|
|
118
118
|
StatefulContainer.prototype.render = function () {
|
|
119
119
|
var _this = this;
|
|
120
|
-
var _a = this.props, accessibilityType = _a.accessibilityType, autoFocus = _a.autoFocus, animateOutTime = _a.animateOutTime, dismissOnClickOutside = _a.dismissOnClickOutside, focusLock = _a.focusLock, ignoreBoundary = _a.ignoreBoundary, mountNode = _a.mountNode, onBlur = _a.onBlur, onClick = _a.onClick, onFocus = _a.onFocus, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave, onMouseEnterDelay = _a.onMouseEnterDelay, onMouseLeaveDelay = _a.onMouseLeaveDelay, overrides = _a.overrides, placement = _a.placement, popperOptions = _a.popperOptions, renderAll = _a.renderAll, returnFocus = _a.returnFocus, showArrow = _a.showArrow, triggerType = _a.triggerType, popoverMargin = _a.popoverMargin, focusOptions = _a.focusOptions, repositionOnResize = _a.repositionOnResize, positionFixed = _a.positionFixed;
|
|
120
|
+
var _a = this.props, accessibilityType = _a.accessibilityType, autoFocus = _a.autoFocus, animateOutTime = _a.animateOutTime, dismissOnClickOutside = _a.dismissOnClickOutside, focusLock = _a.focusLock, ignoreBoundary = _a.ignoreBoundary, mountNode = _a.mountNode, onBlur = _a.onBlur, onClick = _a.onClick, onFocus = _a.onFocus, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave, onMouseEnterDelay = _a.onMouseEnterDelay, onMouseLeaveDelay = _a.onMouseLeaveDelay, overrides = _a.overrides, placement = _a.placement, popperOptions = _a.popperOptions, renderAll = _a.renderAll, returnFocus = _a.returnFocus, showArrow = _a.showArrow, triggerType = _a.triggerType, popoverMargin = _a.popoverMargin, focusOptions = _a.focusOptions, repositionOnResize = _a.repositionOnResize, positionFixed = _a.positionFixed, hideWhenTargetClipped = _a.hideWhenTargetClipped;
|
|
121
121
|
var popoverProps = {
|
|
122
122
|
accessibilityType: accessibilityType,
|
|
123
123
|
animateOutTime: animateOutTime,
|
|
@@ -158,6 +158,7 @@ var StatefulContainer = /** @class */ (function (_super) {
|
|
|
158
158
|
focusOptions: focusOptions,
|
|
159
159
|
repositionOnResize: repositionOnResize,
|
|
160
160
|
positionFixed: positionFixed,
|
|
161
|
+
hideWhenTargetClipped: hideWhenTargetClipped,
|
|
161
162
|
};
|
|
162
163
|
popoverProps.onEsc = this.onEsc;
|
|
163
164
|
if (dismissOnClickOutside) {
|
|
@@ -30,6 +30,7 @@ export var popoverBodyStyle = function (_, props) {
|
|
|
30
30
|
opposite = 'block-end';
|
|
31
31
|
var marginStyles = {};
|
|
32
32
|
if (opposite) {
|
|
33
|
+
// eslint-disable-next-line @sprinklrjs/hds-no-dynamic-classes -- all of these have been explicitly handled
|
|
33
34
|
var property = "--sw-margin-".concat(opposite);
|
|
34
35
|
marginStyles[property] = "".concat(($showArrow ? ARROW_SIZE : 0) + $popoverMargin, "px");
|
|
35
36
|
}
|
|
@@ -46,6 +47,7 @@ export var Body = styled('div', 'absolute top-0 left-[--sw-left-directional] tra
|
|
|
46
47
|
if (opposite === 'bottom')
|
|
47
48
|
opposite = 'block-end';
|
|
48
49
|
// only one of the ml-[--sw-margin-left] mr-[--sw-margin-right] mt-[--sw-margin-block-start] mb-[--sw-margin-block-end] class should be applied
|
|
50
|
+
// eslint-disable-next-line @sprinklrjs/hds-no-dynamic-classes -- all of these have been explicitly handled
|
|
49
51
|
return _opposite ? "m".concat(_opposite[0], "-[--sw-margin-").concat(opposite, "]") : '';
|
|
50
52
|
}, function (_, _a) {
|
|
51
53
|
var $isOpen = _a.$isOpen;
|
|
@@ -59,6 +61,9 @@ export var Body = styled('div', 'absolute top-0 left-[--sw-left-directional] tra
|
|
|
59
61
|
}, function (_, _a) {
|
|
60
62
|
var $positionFixed = _a.$positionFixed;
|
|
61
63
|
return ($positionFixed ? 'transform-none fixed top-[--sw-top]' : '');
|
|
64
|
+
}, function (_, _a) {
|
|
65
|
+
var $isTargetClipped = _a.$isTargetClipped;
|
|
66
|
+
return ($isTargetClipped ? 'invisible pointer-events-none' : '');
|
|
62
67
|
});
|
|
63
68
|
Body.displayName = 'Body';
|
|
64
69
|
export var Arrow = styled('div', 'h-[--sw-height] w-[--sw-width] absolute forced-colors:border-1');
|
|
@@ -84,6 +84,10 @@ export type BasePopoverProps = {
|
|
|
84
84
|
repositionOnResize?: boolean;
|
|
85
85
|
/** Uses the position, left and top properties instead of transform to adjust the popover **/
|
|
86
86
|
positionFixed?: boolean;
|
|
87
|
+
/** Hides (without unmounting) the popover while its target is fully clipped by any scroll container
|
|
88
|
+
* or the viewport, and shows it again once the target scrolls back into view.
|
|
89
|
+
*/
|
|
90
|
+
hideWhenTargetClipped?: boolean;
|
|
87
91
|
};
|
|
88
92
|
export type PopoverProps = BasePopoverProps & {
|
|
89
93
|
/** Content that should trigger the popover to be shown (also acts as the anchor against
|
|
@@ -138,6 +142,7 @@ export type PopoverPrivateState = {
|
|
|
138
142
|
isMounted: boolean;
|
|
139
143
|
autoFocusAfterPositioning: boolean;
|
|
140
144
|
contentHost: HTMLElement | null;
|
|
145
|
+
isTargetClipped: boolean;
|
|
141
146
|
};
|
|
142
147
|
export type ArrowStylePropsArg = {
|
|
143
148
|
$arrowOffset: Offset;
|
|
@@ -152,6 +157,8 @@ export type BodyStylePropsArg = {
|
|
|
152
157
|
$placement: TetherPlacement;
|
|
153
158
|
$showArrow: boolean;
|
|
154
159
|
$popoverMargin: number;
|
|
160
|
+
$positionFixed: boolean;
|
|
161
|
+
$isTargetClipped: boolean;
|
|
155
162
|
};
|
|
156
163
|
export type InnerStylePropsArg = {};
|
|
157
164
|
export type SharedStylePropsArg = {} & ArrowStylePropsArg & BodyStylePropsArg;
|
package/esm/popover/popover.js
CHANGED
|
@@ -17,7 +17,7 @@ import { getPopperOptions } from './utils';
|
|
|
17
17
|
// @ts-ignore -- displayName is not typed in BasePopover
|
|
18
18
|
BasePopover.displayName = 'BaseUIPopover';
|
|
19
19
|
var Popover = React.forwardRef(function (_a, ref) {
|
|
20
|
-
var overrides = _a.overrides, children = _a.children, _b = _a.placement, placement = _b === void 0 ? 'auto' : _b, accessibilityType = _a.accessibilityType, _c = _a.triggerType, triggerType = _c === void 0 ? 'click' : _c, _d = _a.showArrow, showArrow = _d === void 0 ? false : _d, targetElement = _a.targetElement, isOpen = _a.isOpen, _e = _a.focusLock, focusLock = _e === void 0 ? false : _e, _f = _a.returnFocus, returnFocus = _f === void 0 ? triggerType === 'click' : _f, popperOptions = _a.popperOptions, ignoreBoundary = _a.ignoreBoundary, _g = _a.viewportAsBoundary, viewportAsBoundary = _g === void 0 ? true : _g, restProps = __rest(_a, ["overrides", "children", "placement", "accessibilityType", "triggerType", "showArrow", "targetElement", "isOpen", "focusLock", "returnFocus", "popperOptions", "ignoreBoundary", "viewportAsBoundary"]);
|
|
20
|
+
var overrides = _a.overrides, children = _a.children, _b = _a.placement, placement = _b === void 0 ? 'auto' : _b, accessibilityType = _a.accessibilityType, _c = _a.triggerType, triggerType = _c === void 0 ? 'click' : _c, _d = _a.showArrow, showArrow = _d === void 0 ? false : _d, targetElement = _a.targetElement, isOpen = _a.isOpen, _e = _a.focusLock, focusLock = _e === void 0 ? false : _e, _f = _a.returnFocus, returnFocus = _f === void 0 ? triggerType === 'click' : _f, popperOptions = _a.popperOptions, ignoreBoundary = _a.ignoreBoundary, _g = _a.viewportAsBoundary, viewportAsBoundary = _g === void 0 ? true : _g, hideWhenTargetClipped = _a.hideWhenTargetClipped, restProps = __rest(_a, ["overrides", "children", "placement", "accessibilityType", "triggerType", "showArrow", "targetElement", "isOpen", "focusLock", "returnFocus", "popperOptions", "ignoreBoundary", "viewportAsBoundary", "hideWhenTargetClipped"]);
|
|
21
21
|
var _h = useStyle(), isRTL = _h.isRTL, theme = _h.theme;
|
|
22
22
|
var focusLockProps = useFocusLock({ returnFocus: returnFocus, focusLock: focusLock });
|
|
23
23
|
var _j = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.ArrowTriangle, StyledArrowTriangle), 2), ArrowTriangle = _j[0], arrowTriangleProps = _j[1];
|
|
@@ -57,7 +57,7 @@ var Popover = React.forwardRef(function (_a, ref) {
|
|
|
57
57
|
}
|
|
58
58
|
var id = useUniqueId();
|
|
59
59
|
var mergedPopperOptions = useMemo(function () { return (__assign(__assign({}, getPopperOptions({ ignoreBoundary: ignoreBoundary, viewportAsBoundary: viewportAsBoundary })), popperOptions)); }, [popperOptions, ignoreBoundary, viewportAsBoundary]);
|
|
60
|
-
return (_jsx(Layer, __assign({ zIndex: Z_INDEX.POPOVER }, layerProps, { children: _jsx(BasePopover, __assign({ id: id }, restProps, mappedProps, { showArrow: showArrow, isOpen: isOpen, overrides: _overrides, innerRef: combinedRef }, focusLockProps, { popperOptions: mergedPopperOptions }, { children: _jsx(PopoverChildEnhancer, __assign({ targetElement: targetElement }, { children: childNode }), "CheckCompliance<Popover>") })) })));
|
|
60
|
+
return (_jsx(Layer, __assign({ zIndex: Z_INDEX.POPOVER }, layerProps, { children: _jsx(BasePopover, __assign({ id: id }, restProps, mappedProps, { showArrow: showArrow, isOpen: isOpen, overrides: _overrides, innerRef: combinedRef }, focusLockProps, { hideWhenTargetClipped: hideWhenTargetClipped, popperOptions: mergedPopperOptions }, { children: _jsx(PopoverChildEnhancer, __assign({ targetElement: targetElement }, { children: childNode }), "CheckCompliance<Popover>") })) })));
|
|
61
61
|
});
|
|
62
62
|
Popover.displayName = 'Popover';
|
|
63
63
|
Popover.__standard = 'Component<Popover>';
|
|
@@ -16,6 +16,7 @@ declare const DisabledTooltipContainer: {
|
|
|
16
16
|
popperOptions?: any;
|
|
17
17
|
repositionOnResize?: boolean | undefined;
|
|
18
18
|
positionFixed?: boolean | undefined;
|
|
19
|
+
hideWhenTargetClipped?: boolean | undefined;
|
|
19
20
|
accessibilityType?: "none" | "menu" | "tooltip" | undefined;
|
|
20
21
|
animateOutTime?: number | undefined;
|
|
21
22
|
'data-baseweb'?: string | undefined;
|
|
@@ -16,6 +16,7 @@ declare const StatefulContainer: {
|
|
|
16
16
|
popperOptions?: any;
|
|
17
17
|
repositionOnResize?: boolean | undefined;
|
|
18
18
|
positionFixed?: boolean | undefined;
|
|
19
|
+
hideWhenTargetClipped?: boolean | undefined;
|
|
19
20
|
accessibilityType?: "none" | "menu" | "tooltip" | undefined;
|
|
20
21
|
animateOutTime?: number | undefined;
|
|
21
22
|
'data-baseweb'?: string | undefined;
|
|
@@ -19,6 +19,7 @@ declare const StatefulTooltip: {
|
|
|
19
19
|
popperOptions?: any;
|
|
20
20
|
repositionOnResize?: boolean | undefined;
|
|
21
21
|
positionFixed?: boolean | undefined;
|
|
22
|
+
hideWhenTargetClipped?: boolean | undefined;
|
|
22
23
|
accessibilityType?: "none" | "menu" | "tooltip" | undefined;
|
|
23
24
|
animateOutTime?: number | undefined;
|
|
24
25
|
'data-baseweb'?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprinklrjs/spaceweb",
|
|
3
|
-
"version": "14.14.
|
|
3
|
+
"version": "14.14.3",
|
|
4
4
|
"description": "Components for SpaceWeb",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"ts-node": "^10.4.0"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@sprinklrjs/spaceweb-themes": "14.14.
|
|
104
|
+
"@sprinklrjs/spaceweb-themes": "14.14.3",
|
|
105
105
|
"react": ">=17.0.2 <19.0.0",
|
|
106
106
|
"react-dom": ">=17.0.2 <19.0.0"
|
|
107
107
|
}
|
package/popover/popover.js
CHANGED
|
@@ -19,7 +19,7 @@ var utils_1 = require("./utils");
|
|
|
19
19
|
// @ts-ignore -- displayName is not typed in BasePopover
|
|
20
20
|
popover_1.Popover.displayName = 'BaseUIPopover';
|
|
21
21
|
var Popover = React.forwardRef(function (_a, ref) {
|
|
22
|
-
var overrides = _a.overrides, children = _a.children, _b = _a.placement, placement = _b === void 0 ? 'auto' : _b, accessibilityType = _a.accessibilityType, _c = _a.triggerType, triggerType = _c === void 0 ? 'click' : _c, _d = _a.showArrow, showArrow = _d === void 0 ? false : _d, targetElement = _a.targetElement, isOpen = _a.isOpen, _e = _a.focusLock, focusLock = _e === void 0 ? false : _e, _f = _a.returnFocus, returnFocus = _f === void 0 ? triggerType === 'click' : _f, popperOptions = _a.popperOptions, ignoreBoundary = _a.ignoreBoundary, _g = _a.viewportAsBoundary, viewportAsBoundary = _g === void 0 ? true : _g, restProps = tslib_1.__rest(_a, ["overrides", "children", "placement", "accessibilityType", "triggerType", "showArrow", "targetElement", "isOpen", "focusLock", "returnFocus", "popperOptions", "ignoreBoundary", "viewportAsBoundary"]);
|
|
22
|
+
var overrides = _a.overrides, children = _a.children, _b = _a.placement, placement = _b === void 0 ? 'auto' : _b, accessibilityType = _a.accessibilityType, _c = _a.triggerType, triggerType = _c === void 0 ? 'click' : _c, _d = _a.showArrow, showArrow = _d === void 0 ? false : _d, targetElement = _a.targetElement, isOpen = _a.isOpen, _e = _a.focusLock, focusLock = _e === void 0 ? false : _e, _f = _a.returnFocus, returnFocus = _f === void 0 ? triggerType === 'click' : _f, popperOptions = _a.popperOptions, ignoreBoundary = _a.ignoreBoundary, _g = _a.viewportAsBoundary, viewportAsBoundary = _g === void 0 ? true : _g, hideWhenTargetClipped = _a.hideWhenTargetClipped, restProps = tslib_1.__rest(_a, ["overrides", "children", "placement", "accessibilityType", "triggerType", "showArrow", "targetElement", "isOpen", "focusLock", "returnFocus", "popperOptions", "ignoreBoundary", "viewportAsBoundary", "hideWhenTargetClipped"]);
|
|
23
23
|
var _h = (0, style_1.useStyle)(), isRTL = _h.isRTL, theme = _h.theme;
|
|
24
24
|
var focusLockProps = (0, hooks_1.useFocusLock)({ returnFocus: returnFocus, focusLock: focusLock });
|
|
25
25
|
var _j = tslib_1.__read((0, overrides_1.useOverrides)(overrides === null || overrides === void 0 ? void 0 : overrides.ArrowTriangle, styled_components_1.StyledArrowTriangle), 2), ArrowTriangle = _j[0], arrowTriangleProps = _j[1];
|
|
@@ -59,7 +59,7 @@ var Popover = React.forwardRef(function (_a, ref) {
|
|
|
59
59
|
}
|
|
60
60
|
var id = (0, useUniqueId_1.default)();
|
|
61
61
|
var mergedPopperOptions = (0, react_1.useMemo)(function () { return (tslib_1.__assign(tslib_1.__assign({}, (0, utils_1.getPopperOptions)({ ignoreBoundary: ignoreBoundary, viewportAsBoundary: viewportAsBoundary })), popperOptions)); }, [popperOptions, ignoreBoundary, viewportAsBoundary]);
|
|
62
|
-
return ((0, jsx_runtime_1.jsx)(Layer, tslib_1.__assign({ zIndex: layer_1.Z_INDEX.POPOVER }, layerProps, { children: (0, jsx_runtime_1.jsx)(popover_1.Popover, tslib_1.__assign({ id: id }, restProps, mappedProps, { showArrow: showArrow, isOpen: isOpen, overrides: _overrides, innerRef: combinedRef }, focusLockProps, { popperOptions: mergedPopperOptions }, { children: (0, jsx_runtime_1.jsx)(PopoverEnhancer_1.PopoverChildEnhancer, tslib_1.__assign({ targetElement: targetElement }, { children: childNode }), "CheckCompliance<Popover>") })) })));
|
|
62
|
+
return ((0, jsx_runtime_1.jsx)(Layer, tslib_1.__assign({ zIndex: layer_1.Z_INDEX.POPOVER }, layerProps, { children: (0, jsx_runtime_1.jsx)(popover_1.Popover, tslib_1.__assign({ id: id }, restProps, mappedProps, { showArrow: showArrow, isOpen: isOpen, overrides: _overrides, innerRef: combinedRef }, focusLockProps, { hideWhenTargetClipped: hideWhenTargetClipped, popperOptions: mergedPopperOptions }, { children: (0, jsx_runtime_1.jsx)(PopoverEnhancer_1.PopoverChildEnhancer, tslib_1.__assign({ targetElement: targetElement }, { children: childNode }), "CheckCompliance<Popover>") })) })));
|
|
63
63
|
});
|
|
64
64
|
Popover.displayName = 'Popover';
|
|
65
65
|
Popover.__standard = 'Component<Popover>';
|
|
@@ -16,6 +16,7 @@ declare const DisabledTooltipContainer: {
|
|
|
16
16
|
popperOptions?: any;
|
|
17
17
|
repositionOnResize?: boolean | undefined;
|
|
18
18
|
positionFixed?: boolean | undefined;
|
|
19
|
+
hideWhenTargetClipped?: boolean | undefined;
|
|
19
20
|
accessibilityType?: "none" | "menu" | "tooltip" | undefined;
|
|
20
21
|
animateOutTime?: number | undefined;
|
|
21
22
|
'data-baseweb'?: string | undefined;
|
|
@@ -16,6 +16,7 @@ declare const StatefulContainer: {
|
|
|
16
16
|
popperOptions?: any;
|
|
17
17
|
repositionOnResize?: boolean | undefined;
|
|
18
18
|
positionFixed?: boolean | undefined;
|
|
19
|
+
hideWhenTargetClipped?: boolean | undefined;
|
|
19
20
|
accessibilityType?: "none" | "menu" | "tooltip" | undefined;
|
|
20
21
|
animateOutTime?: number | undefined;
|
|
21
22
|
'data-baseweb'?: string | undefined;
|
|
@@ -19,6 +19,7 @@ declare const StatefulTooltip: {
|
|
|
19
19
|
popperOptions?: any;
|
|
20
20
|
repositionOnResize?: boolean | undefined;
|
|
21
21
|
positionFixed?: boolean | undefined;
|
|
22
|
+
hideWhenTargetClipped?: boolean | undefined;
|
|
22
23
|
accessibilityType?: "none" | "menu" | "tooltip" | undefined;
|
|
23
24
|
animateOutTime?: number | undefined;
|
|
24
25
|
'data-baseweb'?: string | undefined;
|