@jupyterlab/apputils 3.4.3 → 4.0.0-alpha.11
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/commandpalette.d.ts +0 -32
- package/lib/commandpalette.js +1 -7
- package/lib/commandpalette.js.map +1 -1
- package/lib/dialog.d.ts +10 -1
- package/lib/dialog.js +1 -3
- package/lib/dialog.js.map +1 -1
- package/lib/domutils.js.map +1 -1
- package/lib/index.d.ts +29 -10
- package/lib/index.js +29 -10
- package/lib/index.js.map +1 -1
- package/lib/inputdialog.js +1 -1
- package/lib/inputdialog.js.map +1 -1
- package/lib/kernelstatuses.d.ts +73 -1
- package/lib/kernelstatuses.js +140 -1
- package/lib/kernelstatuses.js.map +1 -1
- package/lib/mainareawidget.d.ts +2 -2
- package/lib/mainareawidget.js +1 -2
- package/lib/mainareawidget.js.map +1 -1
- package/lib/menufactory.js.map +1 -1
- package/lib/runningSessions.d.ts +72 -0
- package/lib/runningSessions.js +119 -0
- package/lib/runningSessions.js.map +1 -0
- package/lib/sanitizer.js +1 -2
- package/lib/sanitizer.js.map +1 -1
- package/lib/semanticCommand.d.ts +48 -0
- package/lib/semanticCommand.js +42 -0
- package/lib/semanticCommand.js.map +1 -0
- package/lib/sessioncontext.js +7 -5
- package/lib/sessioncontext.js.map +1 -1
- package/lib/thememanager.d.ts +2 -3
- package/lib/thememanager.js +1 -1
- package/lib/thememanager.js.map +1 -1
- package/lib/tokens.d.ts +87 -10
- package/lib/tokens.js +13 -3
- package/lib/tokens.js.map +1 -1
- package/lib/toolbar/factory.d.ts +3 -2
- package/lib/toolbar/factory.js +22 -15
- package/lib/toolbar/factory.js.map +1 -1
- package/lib/toolbar/registry.d.ts +11 -0
- package/lib/toolbar/registry.js +16 -4
- package/lib/toolbar/registry.js.map +1 -1
- package/lib/toolbar/widget.d.ts +1 -435
- package/lib/toolbar/widget.js +3 -866
- package/lib/toolbar/widget.js.map +1 -1
- package/lib/widgettracker.js.map +1 -1
- package/lib/windowresolver.d.ts +1 -14
- package/lib/windowresolver.js +1 -6
- package/lib/windowresolver.js.map +1 -1
- package/package.json +23 -26
- package/style/base.css +0 -6
- package/style/commandpalette.css +7 -10
- package/style/dialog.css +10 -9
- package/style/index.css +1 -0
- package/style/index.js +1 -0
- package/style/materialcolors.css +3 -21
- package/lib/collapse.d.ts +0 -64
- package/lib/collapse.js +0 -145
- package/lib/collapse.js.map +0 -1
- package/lib/hoverbox.d.ts +0 -82
- package/lib/hoverbox.js +0 -100
- package/lib/hoverbox.js.map +0 -1
- package/lib/iframe.d.ts +0 -77
- package/lib/iframe.js +0 -89
- package/lib/iframe.js.map +0 -1
- package/lib/search.d.ts +0 -54
- package/lib/search.js +0 -100
- package/lib/search.js.map +0 -1
- package/lib/spinner.d.ts +0 -15
- package/lib/spinner.js +0 -28
- package/lib/spinner.js.map +0 -1
- package/lib/splash.d.ts +0 -19
- package/lib/splash.js +0 -9
- package/lib/splash.js.map +0 -1
- package/lib/styling.d.ts +0 -27
- package/lib/styling.js +0 -100
- package/lib/styling.js.map +0 -1
- package/lib/vdom.d.ts +0 -189
- package/lib/vdom.js +0 -203
- package/lib/vdom.js.map +0 -1
- package/style/collapse.css +0 -30
- package/style/hoverbox.css +0 -13
- package/style/iframe.css +0 -33
- package/style/spinner.css +0 -79
- package/style/styling.css +0 -101
- package/style/toolbar.css +0 -115
package/lib/collapse.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Jupyter Development Team.
|
|
2
|
-
// Distributed under the terms of the Modified BSD License.
|
|
3
|
-
import { caretDownIcon, caretUpIcon } from '@jupyterlab/ui-components';
|
|
4
|
-
import { Signal } from '@lumino/signaling';
|
|
5
|
-
import { Panel, PanelLayout, Widget } from '@lumino/widgets';
|
|
6
|
-
/**
|
|
7
|
-
* A panel that supports a collapsible header made from the widget's title.
|
|
8
|
-
* Clicking on the title expands or contracts the widget.
|
|
9
|
-
*/
|
|
10
|
-
export class Collapse extends Widget {
|
|
11
|
-
constructor(options) {
|
|
12
|
-
super(options);
|
|
13
|
-
this._collapseChanged = new Signal(this);
|
|
14
|
-
const { widget, collapsed = true } = options;
|
|
15
|
-
this.addClass('jp-Collapse');
|
|
16
|
-
this._header = new Widget();
|
|
17
|
-
this._header.addClass('jp-Collapse-header');
|
|
18
|
-
this._content = new Panel();
|
|
19
|
-
this._content.addClass('jp-Collapse-contents');
|
|
20
|
-
const layout = new PanelLayout();
|
|
21
|
-
this.layout = layout;
|
|
22
|
-
layout.addWidget(this._header);
|
|
23
|
-
layout.addWidget(this._content);
|
|
24
|
-
this.widget = widget;
|
|
25
|
-
this.collapsed = collapsed;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* The widget inside the collapse panel.
|
|
29
|
-
*/
|
|
30
|
-
get widget() {
|
|
31
|
-
return this._widget;
|
|
32
|
-
}
|
|
33
|
-
set widget(widget) {
|
|
34
|
-
const oldWidget = this._widget;
|
|
35
|
-
if (oldWidget) {
|
|
36
|
-
oldWidget.title.changed.disconnect(this._onTitleChanged, this);
|
|
37
|
-
oldWidget.parent = null;
|
|
38
|
-
}
|
|
39
|
-
this._widget = widget;
|
|
40
|
-
widget.title.changed.connect(this._onTitleChanged, this);
|
|
41
|
-
this._onTitleChanged(widget.title);
|
|
42
|
-
this._content.addWidget(widget);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* The collapsed state of the panel.
|
|
46
|
-
*/
|
|
47
|
-
get collapsed() {
|
|
48
|
-
return this._collapsed;
|
|
49
|
-
}
|
|
50
|
-
set collapsed(value) {
|
|
51
|
-
if (value === this._collapsed) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (value) {
|
|
55
|
-
this._collapse();
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
this._uncollapse();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* A signal for when the widget collapse state changes.
|
|
63
|
-
*/
|
|
64
|
-
get collapseChanged() {
|
|
65
|
-
return this._collapseChanged;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Toggle the collapse state of the panel.
|
|
69
|
-
*/
|
|
70
|
-
toggle() {
|
|
71
|
-
this.collapsed = !this.collapsed;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Dispose the widget.
|
|
75
|
-
*/
|
|
76
|
-
dispose() {
|
|
77
|
-
if (this.isDisposed) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
// Delete references we explicitly hold to other widgets.
|
|
81
|
-
this._header = null;
|
|
82
|
-
this._widget = null;
|
|
83
|
-
this._content = null;
|
|
84
|
-
super.dispose();
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Handle the DOM events for the Collapse widget.
|
|
88
|
-
*
|
|
89
|
-
* @param event - The DOM event sent to the panel.
|
|
90
|
-
*
|
|
91
|
-
* #### Notes
|
|
92
|
-
* This method implements the DOM `EventListener` interface and is
|
|
93
|
-
* called in response to events on the panel's DOM node. It should
|
|
94
|
-
* not be called directly by user code.
|
|
95
|
-
*/
|
|
96
|
-
handleEvent(event) {
|
|
97
|
-
switch (event.type) {
|
|
98
|
-
case 'click':
|
|
99
|
-
this._evtClick(event);
|
|
100
|
-
break;
|
|
101
|
-
default:
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
onAfterAttach(msg) {
|
|
106
|
-
this._header.node.addEventListener('click', this);
|
|
107
|
-
}
|
|
108
|
-
onBeforeDetach(msg) {
|
|
109
|
-
this._header.node.removeEventListener('click', this);
|
|
110
|
-
}
|
|
111
|
-
_collapse() {
|
|
112
|
-
this._collapsed = true;
|
|
113
|
-
if (this._content) {
|
|
114
|
-
this._content.hide();
|
|
115
|
-
}
|
|
116
|
-
this._setHeader();
|
|
117
|
-
this._collapseChanged.emit(void 0);
|
|
118
|
-
}
|
|
119
|
-
_uncollapse() {
|
|
120
|
-
this._collapsed = false;
|
|
121
|
-
if (this._content) {
|
|
122
|
-
this._content.show();
|
|
123
|
-
}
|
|
124
|
-
this._setHeader();
|
|
125
|
-
this._collapseChanged.emit(void 0);
|
|
126
|
-
}
|
|
127
|
-
_evtClick(event) {
|
|
128
|
-
this.toggle();
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Handle the `changed` signal of a title object.
|
|
132
|
-
*/
|
|
133
|
-
_onTitleChanged(sender) {
|
|
134
|
-
this._setHeader();
|
|
135
|
-
}
|
|
136
|
-
_setHeader() {
|
|
137
|
-
(this._collapsed ? caretUpIcon : caretDownIcon).element({
|
|
138
|
-
container: this._header.node,
|
|
139
|
-
label: this._widget.title.label,
|
|
140
|
-
elementPosition: 'right',
|
|
141
|
-
height: '28px'
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
//# sourceMappingURL=collapse.js.map
|
package/lib/collapse.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collapse.js","sourceRoot":"","sources":["../src/collapse.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAEvE,OAAO,EAAW,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAS,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEpE;;;GAGG;AACH,MAAM,OAAO,QAAoC,SAAQ,MAAM;IAC7D,YAAY,OAA6B;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAqJT,qBAAgB,GAAG,IAAI,MAAM,CAAa,IAAI,CAAC,CAAC;QApJtD,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;QAE7C,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,MAAM,EAA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CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;SACtB;QACD,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,CAAC;IAEO,SAAS,CAAC,KAAiB;QACjC,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED;;OAEG;IACK,eAAe,CAAC,MAAqB;QAC3C,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAEO,UAAU;QAChB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC;YACtD,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YAC5B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK;YAC/B,eAAe,EAAE,OAAO;YACxB,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC;CAOF"}
|
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: ClientRect;
|
|
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
|
package/lib/hoverbox.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hoverbox.js","sourceRoot":"","sources":["../src/hoverbox.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D;;GAEG;AACH,MAAM,cAAc,GAAG,aAAa,CAAC;AAErC;;GAEG;AACH,MAAM,eAAe,GAAG,kBA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mLxB"}
|
package/lib/iframe.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Widget } from '@lumino/widgets';
|
|
2
|
-
/**
|
|
3
|
-
* A phosphor widget which wraps an IFrame.
|
|
4
|
-
*/
|
|
5
|
-
export declare class IFrame extends Widget {
|
|
6
|
-
/**
|
|
7
|
-
* Create a new IFrame widget.
|
|
8
|
-
*/
|
|
9
|
-
constructor(options?: IFrame.IOptions);
|
|
10
|
-
/**
|
|
11
|
-
* Referrer policy for the iframe.
|
|
12
|
-
*
|
|
13
|
-
* #### Notes
|
|
14
|
-
* By default, `no-referrer` is chosen.
|
|
15
|
-
*
|
|
16
|
-
* For more information, see
|
|
17
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/referrerPolicy
|
|
18
|
-
*/
|
|
19
|
-
get referrerPolicy(): IFrame.ReferrerPolicy;
|
|
20
|
-
set referrerPolicy(value: IFrame.ReferrerPolicy);
|
|
21
|
-
/**
|
|
22
|
-
* Exceptions to the sandboxing.
|
|
23
|
-
*
|
|
24
|
-
* #### Notes
|
|
25
|
-
* By default, all sandboxing security policies are enabled.
|
|
26
|
-
* This setting allows the user to selectively disable these
|
|
27
|
-
* policies. This should be done with care, as it can
|
|
28
|
-
* introduce security risks, and possibly allow malicious
|
|
29
|
-
* sites to execute code in a JupyterLab session.
|
|
30
|
-
*
|
|
31
|
-
* For more information, see
|
|
32
|
-
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
|
|
33
|
-
*/
|
|
34
|
-
get sandbox(): IFrame.SandboxExceptions[];
|
|
35
|
-
set sandbox(values: IFrame.SandboxExceptions[]);
|
|
36
|
-
/**
|
|
37
|
-
* The url of the IFrame.
|
|
38
|
-
*/
|
|
39
|
-
get url(): string;
|
|
40
|
-
set url(url: string);
|
|
41
|
-
private _sandbox;
|
|
42
|
-
private _referrerPolicy;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* A namespace for IFrame widget statics.
|
|
46
|
-
*/
|
|
47
|
-
export declare namespace IFrame {
|
|
48
|
-
/**
|
|
49
|
-
* Referrer policy for the iframe.
|
|
50
|
-
*
|
|
51
|
-
* User documentation for the policies can be found here:
|
|
52
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/referrerPolicy
|
|
53
|
-
*/
|
|
54
|
-
type ReferrerPolicy = 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
|
55
|
-
/**
|
|
56
|
-
* Exceptions to the iframe sandboxing policies.
|
|
57
|
-
* These are specified here:
|
|
58
|
-
* https://www.w3.org/TR/2011/WD-html5-20110525/the-iframe-element.html#attr-iframe-sandbox
|
|
59
|
-
*
|
|
60
|
-
* More user-friendly documentation can be found here:
|
|
61
|
-
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#sandbox
|
|
62
|
-
*/
|
|
63
|
-
type SandboxExceptions = 'allow-downloads' | 'allow-forms' | 'allow-modals' | 'allow-orientation-lock' | 'allow-pointer-lock' | 'allow-popups' | 'popups-to-escape-sandbox' | 'allow-presentation' | 'allow-same-origin' | 'allow-scripts' | 'allow-storage-access-by-user-activation' | 'allow-top-navigation' | 'allow-top-navigation-by-user-activation';
|
|
64
|
-
/**
|
|
65
|
-
* Options for creating a new IFrame widget.
|
|
66
|
-
*/
|
|
67
|
-
interface IOptions {
|
|
68
|
-
/**
|
|
69
|
-
* Exceptions for the iframe sandbox.
|
|
70
|
-
*/
|
|
71
|
-
sandbox?: SandboxExceptions[];
|
|
72
|
-
/**
|
|
73
|
-
* Referrer policy for the iframe.
|
|
74
|
-
*/
|
|
75
|
-
referrerPolicy?: ReferrerPolicy;
|
|
76
|
-
}
|
|
77
|
-
}
|
package/lib/iframe.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Jupyter Development Team.
|
|
2
|
-
// Distributed under the terms of the Modified BSD License.
|
|
3
|
-
import { Widget } from '@lumino/widgets';
|
|
4
|
-
/**
|
|
5
|
-
* A phosphor widget which wraps an IFrame.
|
|
6
|
-
*/
|
|
7
|
-
export class IFrame extends Widget {
|
|
8
|
-
/**
|
|
9
|
-
* Create a new IFrame widget.
|
|
10
|
-
*/
|
|
11
|
-
constructor(options = {}) {
|
|
12
|
-
super({ node: Private.createNode() });
|
|
13
|
-
this._sandbox = [];
|
|
14
|
-
this.addClass('jp-IFrame');
|
|
15
|
-
this.sandbox = options.sandbox || [];
|
|
16
|
-
this.referrerPolicy = options.referrerPolicy || 'no-referrer';
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Referrer policy for the iframe.
|
|
20
|
-
*
|
|
21
|
-
* #### Notes
|
|
22
|
-
* By default, `no-referrer` is chosen.
|
|
23
|
-
*
|
|
24
|
-
* For more information, see
|
|
25
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/referrerPolicy
|
|
26
|
-
*/
|
|
27
|
-
get referrerPolicy() {
|
|
28
|
-
return this._referrerPolicy;
|
|
29
|
-
}
|
|
30
|
-
set referrerPolicy(value) {
|
|
31
|
-
if (this._referrerPolicy === value) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
this._referrerPolicy = value;
|
|
35
|
-
const iframe = this.node.querySelector('iframe');
|
|
36
|
-
iframe.setAttribute('referrerpolicy', value);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Exceptions to the sandboxing.
|
|
40
|
-
*
|
|
41
|
-
* #### Notes
|
|
42
|
-
* By default, all sandboxing security policies are enabled.
|
|
43
|
-
* This setting allows the user to selectively disable these
|
|
44
|
-
* policies. This should be done with care, as it can
|
|
45
|
-
* introduce security risks, and possibly allow malicious
|
|
46
|
-
* sites to execute code in a JupyterLab session.
|
|
47
|
-
*
|
|
48
|
-
* For more information, see
|
|
49
|
-
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
|
|
50
|
-
*/
|
|
51
|
-
get sandbox() {
|
|
52
|
-
return this._sandbox.slice();
|
|
53
|
-
}
|
|
54
|
-
set sandbox(values) {
|
|
55
|
-
this._sandbox = values.slice();
|
|
56
|
-
const iframe = this.node.querySelector('iframe');
|
|
57
|
-
const exceptions = values.length ? values.join(' ') : '';
|
|
58
|
-
iframe.setAttribute('sandbox', exceptions);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* The url of the IFrame.
|
|
62
|
-
*/
|
|
63
|
-
get url() {
|
|
64
|
-
return this.node.querySelector('iframe').getAttribute('src') || '';
|
|
65
|
-
}
|
|
66
|
-
set url(url) {
|
|
67
|
-
this.node.querySelector('iframe').setAttribute('src', url);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* A namespace for private data.
|
|
72
|
-
*/
|
|
73
|
-
var Private;
|
|
74
|
-
(function (Private) {
|
|
75
|
-
/**
|
|
76
|
-
* Create the main content node of an iframe widget.
|
|
77
|
-
*/
|
|
78
|
-
function createNode() {
|
|
79
|
-
const node = document.createElement('div');
|
|
80
|
-
const iframe = document.createElement('iframe');
|
|
81
|
-
iframe.setAttribute('sandbox', '');
|
|
82
|
-
iframe.style.height = '100%';
|
|
83
|
-
iframe.style.width = '100%';
|
|
84
|
-
node.appendChild(iframe);
|
|
85
|
-
return node;
|
|
86
|
-
}
|
|
87
|
-
Private.createNode = createNode;
|
|
88
|
-
})(Private || (Private = {}));
|
|
89
|
-
//# sourceMappingURL=iframe.js.map
|
package/lib/iframe.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"iframe.js","sourceRoot":"","sources":["../src/iframe.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC;;GAEG;AACH,MAAM,OAAO,MAAO,SAAQ,MAAM;IAChC;;OAEG;IACH,YAAY,UAA2B,E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,CAAC,aAAa,CAAC,QAAQ,CAAE,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACtE,CAAC;IACD,IAAI,GAAG,CAAC,GAAW;QACjB,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAE,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC9D,CAAC;CAIF;AA6DD;;GAEG;AACH,IAAU,OAAO,CAahB;AAbD,WAAU,OAAO;IACf;;OAEG;IACH,SAAgB,UAAU;QACxB,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACnC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;QAC7B,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;QAC5B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IARe,kBAAU,aAQzB,CAAA;AACH,CAAC,EAbS,OAAO,KAAP,OAAO,QAahB"}
|
package/lib/search.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ReactWidget } from './vdom';
|
|
3
|
-
/**
|
|
4
|
-
* The class name added to the filebrowser crumbs node.
|
|
5
|
-
*/
|
|
6
|
-
export interface IFilterBoxProps {
|
|
7
|
-
/**
|
|
8
|
-
* A function to callback when filter is updated.
|
|
9
|
-
*/
|
|
10
|
-
updateFilter: (filterFn: (item: string) => boolean | Partial<IScore> | null, query?: string) => void;
|
|
11
|
-
/**
|
|
12
|
-
* Whether to use the fuzzy filter.
|
|
13
|
-
*/
|
|
14
|
-
useFuzzyFilter: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Optional placeholder for the search box.
|
|
17
|
-
*/
|
|
18
|
-
placeholder?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Whether to force a refresh.
|
|
21
|
-
*/
|
|
22
|
-
forceRefresh?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Whether to use case-sensitive search
|
|
25
|
-
*/
|
|
26
|
-
caseSensitive?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* An optional initial search value.
|
|
29
|
-
*/
|
|
30
|
-
initialQuery?: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* A text match score with associated content item.
|
|
34
|
-
*/
|
|
35
|
-
export interface IScore {
|
|
36
|
-
/**
|
|
37
|
-
* The numerical score for the text match.
|
|
38
|
-
*/
|
|
39
|
-
score: number;
|
|
40
|
-
/**
|
|
41
|
-
* The indices of the text matches.
|
|
42
|
-
*/
|
|
43
|
-
indices: number[] | null;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Perform a fuzzy search on a single item.
|
|
47
|
-
*/
|
|
48
|
-
export declare function fuzzySearch(source: string, query: string): IScore | null;
|
|
49
|
-
export declare const updateFilterFunction: (value: string, useFuzzyFilter: boolean, caseSensitive?: boolean | undefined) => (item: string) => Partial<IScore> | null;
|
|
50
|
-
export declare const FilterBox: (props: IFilterBoxProps) => JSX.Element;
|
|
51
|
-
/**
|
|
52
|
-
* A widget which hosts a input textbox to filter on file names.
|
|
53
|
-
*/
|
|
54
|
-
export declare const FilenameSearcher: (props: IFilterBoxProps) => ReactWidget;
|
package/lib/search.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Jupyter Development Team.
|
|
2
|
-
// Distributed under the terms of the Modified BSD License.
|
|
3
|
-
import { InputGroup } from '@jupyterlab/ui-components';
|
|
4
|
-
import { StringExt } from '@lumino/algorithm';
|
|
5
|
-
import React, { useEffect, useState } from 'react';
|
|
6
|
-
import { ReactWidget } from './vdom';
|
|
7
|
-
/**
|
|
8
|
-
* Perform a fuzzy search on a single item.
|
|
9
|
-
*/
|
|
10
|
-
export function fuzzySearch(source, query) {
|
|
11
|
-
// Set up the match score and indices array.
|
|
12
|
-
let score = Infinity;
|
|
13
|
-
let indices = null;
|
|
14
|
-
// The regex for search word boundaries
|
|
15
|
-
const rgx = /\b\w/g;
|
|
16
|
-
let continueSearch = true;
|
|
17
|
-
// Search the source by word boundary.
|
|
18
|
-
while (continueSearch) {
|
|
19
|
-
// Find the next word boundary in the source.
|
|
20
|
-
let rgxMatch = rgx.exec(source);
|
|
21
|
-
// Break if there is no more source context.
|
|
22
|
-
if (!rgxMatch) {
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
// Run the string match on the relevant substring.
|
|
26
|
-
let match = StringExt.matchSumOfDeltas(source, query, rgxMatch.index);
|
|
27
|
-
// Break if there is no match.
|
|
28
|
-
if (!match) {
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
// Update the match if the score is better.
|
|
32
|
-
if (match && match.score <= score) {
|
|
33
|
-
score = match.score;
|
|
34
|
-
indices = match.indices;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// Bail if there was no match.
|
|
38
|
-
if (!indices || score === Infinity) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
// Handle a split match.
|
|
42
|
-
return {
|
|
43
|
-
score,
|
|
44
|
-
indices
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export const updateFilterFunction = (value, useFuzzyFilter, caseSensitive) => {
|
|
48
|
-
return (item) => {
|
|
49
|
-
if (useFuzzyFilter) {
|
|
50
|
-
// Run the fuzzy search for the item and query.
|
|
51
|
-
const query = value.toLowerCase();
|
|
52
|
-
// Ignore the item if it is not a match.
|
|
53
|
-
return fuzzySearch(item, query);
|
|
54
|
-
}
|
|
55
|
-
if (!caseSensitive) {
|
|
56
|
-
item = item.toLocaleLowerCase();
|
|
57
|
-
value = value.toLocaleLowerCase();
|
|
58
|
-
}
|
|
59
|
-
const i = item.indexOf(value);
|
|
60
|
-
if (i === -1) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
indices: [...Array(item.length).keys()].map(x => x + 1)
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
export const FilterBox = (props) => {
|
|
69
|
-
var _a;
|
|
70
|
-
const [filter, setFilter] = useState((_a = props.initialQuery) !== null && _a !== void 0 ? _a : '');
|
|
71
|
-
if (props.forceRefresh) {
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
props.updateFilter((item) => {
|
|
74
|
-
return {};
|
|
75
|
-
});
|
|
76
|
-
}, []);
|
|
77
|
-
}
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
// If there is an initial search value, pass the parent the initial filter function for that value.
|
|
80
|
-
if (props.initialQuery !== undefined) {
|
|
81
|
-
props.updateFilter(updateFilterFunction(props.initialQuery, props.useFuzzyFilter, props.caseSensitive), props.initialQuery);
|
|
82
|
-
}
|
|
83
|
-
}, []);
|
|
84
|
-
/**
|
|
85
|
-
* Handler for search input changes.
|
|
86
|
-
*/
|
|
87
|
-
const handleChange = (e) => {
|
|
88
|
-
const target = e.target;
|
|
89
|
-
setFilter(target.value);
|
|
90
|
-
props.updateFilter(updateFilterFunction(target.value, props.useFuzzyFilter, props.caseSensitive), target.value);
|
|
91
|
-
};
|
|
92
|
-
return (React.createElement(InputGroup, { type: "text", rightIcon: "ui-components:search", placeholder: props.placeholder, onChange: handleChange, className: "jp-FilterBox", value: filter }));
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* A widget which hosts a input textbox to filter on file names.
|
|
96
|
-
*/
|
|
97
|
-
export const FilenameSearcher = (props) => {
|
|
98
|
-
return ReactWidget.create(React.createElement(FilterBox, { updateFilter: props.updateFilter, useFuzzyFilter: props.useFuzzyFilter, placeholder: props.placeholder, forceRefresh: props.forceRefresh, caseSensitive: props.caseSensitive }));
|
|
99
|
-
};
|
|
100
|
-
//# s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