@jupyterlab/apputils 4.0.0-alpha.2 → 4.0.0-alpha.5

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/lib/hoverbox.d.ts DELETED
@@ -1,82 +0,0 @@
1
- /**
2
- * A namespace for `HoverBox` members.
3
- */
4
- export declare namespace HoverBox {
5
- /**
6
- * Options for setting the geometry of a hovering node and its anchor node.
7
- */
8
- interface IOptions {
9
- /**
10
- * The referent anchor rectangle to which the hover box is bound.
11
- *
12
- * #### Notes
13
- * In an editor context, this value will typically be the cursor's
14
- * coordinate position, which can be retrieved via calling the
15
- * `getCoordinateForPosition` method.
16
- */
17
- anchor: DOMRect;
18
- /**
19
- * The node that hosts the anchor.
20
- *
21
- * #### Notes
22
- * The visibility of the anchor rectangle within this host node is the
23
- * heuristic that determines whether the hover box ought to be visible.
24
- */
25
- host: HTMLElement;
26
- /**
27
- * The maximum height of a hover box.
28
- *
29
- * #### Notes
30
- * This value is only used if a CSS max-height attribute is not set for the
31
- * hover box. It is a fallback value.
32
- */
33
- maxHeight: number;
34
- /**
35
- * The minimum height of a hover box.
36
- */
37
- minHeight: number;
38
- /**
39
- * The hover box node.
40
- */
41
- node: HTMLElement;
42
- /**
43
- * Optional pixel offset values added to where the hover box should render.
44
- *
45
- * #### Notes
46
- * This option is useful for passing in values that may pertain to CSS
47
- * borders or padding in cases where the text inside the hover box may need
48
- * to align with the text of the referent editor.
49
- *
50
- * Because the hover box calculation may render a box either above or below
51
- * the cursor, the `vertical` offset accepts `above` and `below` values for
52
- * the different render modes.
53
- */
54
- offset?: {
55
- horizontal?: number;
56
- vertical?: {
57
- above?: number;
58
- below?: number;
59
- };
60
- };
61
- /**
62
- * If space is available both above and below the anchor, denote which
63
- * location is privileged. Use forceBelow and forceAbove to mandate where
64
- * hover box should render relative to anchor.
65
- *
66
- * #### Notes
67
- * The default value is `'below'`.
68
- */
69
- privilege?: 'above' | 'below' | 'forceAbove' | 'forceBelow';
70
- /**
71
- * If the style of the node has already been computed, it can be passed into
72
- * the hover box for geometry calculation.
73
- */
74
- style?: CSSStyleDeclaration;
75
- }
76
- /**
77
- * Set the visible dimensions of a hovering box anchored to an editor cursor.
78
- *
79
- * @param options - The hover box geometry calculation options.
80
- */
81
- function setGeometry(options: IOptions): void;
82
- }
package/lib/hoverbox.js DELETED
@@ -1,100 +0,0 @@
1
- // Copyright (c) Jupyter Development Team.
2
- // Distributed under the terms of the Modified BSD License.
3
- /**
4
- * The class name added to all hover boxes.
5
- */
6
- const HOVERBOX_CLASS = 'jp-HoverBox';
7
- /**
8
- * The class name added to a hovering node that is scrolled out of view.
9
- */
10
- const OUTOFVIEW_CLASS = 'jp-mod-outofview';
11
- /**
12
- * A namespace for `HoverBox` members.
13
- */
14
- export var HoverBox;
15
- (function (HoverBox) {
16
- /**
17
- * Set the visible dimensions of a hovering box anchored to an editor cursor.
18
- *
19
- * @param options - The hover box geometry calculation options.
20
- */
21
- function setGeometry(options) {
22
- const { anchor, host, node, privilege } = options;
23
- // Add hover box class if it does not exist.
24
- node.classList.add(HOVERBOX_CLASS);
25
- // Hide the hover box before querying the DOM for the anchor coordinates.
26
- node.classList.add(OUTOFVIEW_CLASS);
27
- // If the current coordinates are not visible, bail.
28
- if (!host.contains(document.elementFromPoint(anchor.left, anchor.top))) {
29
- return;
30
- }
31
- // Clear any previously set max-height.
32
- node.style.maxHeight = '';
33
- // Clear any programmatically set margin-top.
34
- node.style.marginTop = '';
35
- // Make sure the node is visible so that its dimensions can be queried.
36
- node.classList.remove(OUTOFVIEW_CLASS);
37
- const style = options.style || window.getComputedStyle(node);
38
- const innerHeight = window.innerHeight;
39
- const spaceAbove = anchor.top;
40
- const spaceBelow = innerHeight - anchor.bottom;
41
- const marginTop = parseInt(style.marginTop, 10) || 0;
42
- const minHeight = parseInt(style.minHeight, 10) || options.minHeight;
43
- let maxHeight = parseInt(style.maxHeight, 10) || options.maxHeight;
44
- // Determine whether to render above or below; check privilege.
45
- const renderBelow = privilege === 'forceAbove'
46
- ? false
47
- : privilege === 'forceBelow'
48
- ? true
49
- : privilege === 'above'
50
- ? spaceAbove < maxHeight && spaceAbove < spaceBelow
51
- : spaceBelow >= maxHeight || spaceBelow >= spaceAbove;
52
- if (renderBelow) {
53
- maxHeight = Math.min(spaceBelow - marginTop, maxHeight);
54
- }
55
- else {
56
- maxHeight = Math.min(spaceAbove, maxHeight);
57
- // If the box renders above the text, its top margin is irrelevant.
58
- node.style.marginTop = '0px';
59
- }
60
- node.style.maxHeight = `${maxHeight}px`;
61
- // Make sure the box ought to be visible.
62
- const withinBounds = maxHeight > minHeight &&
63
- (spaceBelow >= minHeight || spaceAbove >= minHeight);
64
- if (!withinBounds) {
65
- node.classList.add(OUTOFVIEW_CLASS);
66
- return;
67
- }
68
- // Position the box vertically.
69
- const offsetAbove = (options.offset &&
70
- options.offset.vertical &&
71
- options.offset.vertical.above) ||
72
- 0;
73
- const offsetBelow = (options.offset &&
74
- options.offset.vertical &&
75
- options.offset.vertical.below) ||
76
- 0;
77
- const top = renderBelow
78
- ? innerHeight - spaceBelow + offsetBelow
79
- : spaceAbove - node.getBoundingClientRect().height + offsetAbove;
80
- node.style.top = `${Math.floor(top)}px`;
81
- // Position the box horizontally.
82
- const offsetHorizontal = (options.offset && options.offset.horizontal) || 0;
83
- let left = anchor.left + offsetHorizontal;
84
- node.style.left = `${Math.ceil(left)}px`;
85
- node.style.width = 'auto';
86
- // Expand the menu width by the scrollbar size, if present.
87
- if (node.scrollHeight >= maxHeight) {
88
- node.style.width = `${2 * node.offsetWidth - node.clientWidth}`;
89
- node.scrollTop = 0;
90
- }
91
- // Move left to fit in the window.
92
- const right = node.getBoundingClientRect().right;
93
- if (right > window.innerWidth) {
94
- left -= right - window.innerWidth;
95
- node.style.left = `${Math.ceil(left)}px`;
96
- }
97
- }
98
- HoverBox.setGeometry = setGeometry;
99
- })(HoverBox || (HoverBox = {}));
100
- //# sourceMappingURL=hoverbox.js.map
@@ -1 +0,0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U,CAAC;YAClC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;SAC1C;IACH,CAAC;IAhGe,oBAAW,cAgG1B,CAAA;AACH,CAAC,EAnLgB,QAAQ,KAAR,QAAQ,QAmLxB"}
@@ -1,13 +0,0 @@
1
- /*-----------------------------------------------------------------------------
2
- | Copyright (c) 2014-2016, Jupyter Development Team.
3
- |
4
- | Distributed under the terms of the Modified BSD License.
5
- |----------------------------------------------------------------------------*/
6
-
7
- .jp-HoverBox {
8
- position: fixed;
9
- }
10
-
11
- .jp-HoverBox.jp-mod-outofview {
12
- display: none;
13
- }