@jupyterlab/ui-components 4.0.0-alpha.34 → 4.0.0-alpha.35
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/components/form.js +1 -1
- package/lib/components/form.js.map +1 -1
- package/lib/components/vdom.d.ts +1 -1
- package/lib/components/windowedlist.js +2 -1
- package/lib/components/windowedlist.js.map +1 -1
- package/lib/hoverbox.d.ts +1 -1
- package/lib/icon/labicon.js +49 -48
- package/lib/icon/labicon.js.map +1 -1
- package/lib/icon/widgets/tabbarsvg.js +2 -1
- package/lib/icon/widgets/tabbarsvg.js.map +1 -1
- package/package.json +20 -19
- package/src/FormRendererRegistry.tsx +60 -0
- package/src/components/accordiontoolbar.ts +252 -0
- package/src/components/button.tsx +45 -0
- package/src/components/collapser.ts +176 -0
- package/src/components/form.tsx +678 -0
- package/src/components/htmlselect.tsx +99 -0
- package/src/components/iframe.ts +153 -0
- package/src/components/index.ts +20 -0
- package/src/components/inputgroup.tsx +51 -0
- package/src/components/interface.ts +9 -0
- package/src/components/menu.ts +442 -0
- package/src/components/panelwithtoolbar.ts +41 -0
- package/src/components/search.tsx +216 -0
- package/src/components/sidepanel.ts +168 -0
- package/src/components/spinner.ts +31 -0
- package/src/components/styling.ts +114 -0
- package/src/components/switch.ts +103 -0
- package/src/components/toolbar.tsx +1119 -0
- package/src/components/vdom.ts +324 -0
- package/src/components/windowedlist.ts +1422 -0
- package/src/hoverbox.ts +401 -0
- package/src/icon/iconimports.ts +206 -0
- package/src/icon/index.ts +6 -0
- package/src/icon/labicon.tsx +955 -0
- package/src/icon/widgets/commandpalettesvg.ts +78 -0
- package/src/icon/widgets/index.ts +6 -0
- package/src/icon/widgets/menusvg.ts +218 -0
- package/src/icon/widgets/tabbarsvg.ts +122 -0
- package/src/index.ts +13 -0
- package/src/style/icon.ts +581 -0
- package/src/style/index.ts +4 -0
- package/src/svg.d.ts +58 -0
- package/src/tokens.ts +68 -0
- package/src/utils.ts +90 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { caretDownEmptyIcon, LabIcon } from '../icon';
|
|
6
|
+
import { classes } from '../utils';
|
|
7
|
+
import { DEFAULT_STYLE_CLASS, IElementRefProps } from './interface';
|
|
8
|
+
|
|
9
|
+
export const HTML_SELECT_CLASS = 'jp-HTMLSelect';
|
|
10
|
+
|
|
11
|
+
export interface IOptionProps {
|
|
12
|
+
/**
|
|
13
|
+
* A space-delimited list of class names
|
|
14
|
+
*/
|
|
15
|
+
className?: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Whether this option is non-interactive.
|
|
19
|
+
*/
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Label text for this option. If omitted, `value` is used as the label.
|
|
24
|
+
*/
|
|
25
|
+
label?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Value of this option.
|
|
29
|
+
*/
|
|
30
|
+
value: string | number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface IHTMLSelectProps
|
|
34
|
+
extends IElementRefProps<HTMLSelectElement>,
|
|
35
|
+
React.SelectHTMLAttributes<HTMLSelectElement> {
|
|
36
|
+
defaultStyle?: boolean;
|
|
37
|
+
|
|
38
|
+
iconProps?: LabIcon.IProps;
|
|
39
|
+
|
|
40
|
+
icon?: LabIcon;
|
|
41
|
+
|
|
42
|
+
options?: Array<string | number | IOptionProps>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class HTMLSelect extends React.Component<IHTMLSelectProps> {
|
|
46
|
+
public render(): JSX.Element {
|
|
47
|
+
const {
|
|
48
|
+
className,
|
|
49
|
+
defaultStyle = true,
|
|
50
|
+
disabled,
|
|
51
|
+
elementRef,
|
|
52
|
+
iconProps,
|
|
53
|
+
icon = caretDownEmptyIcon,
|
|
54
|
+
options = [],
|
|
55
|
+
...htmlProps
|
|
56
|
+
} = this.props;
|
|
57
|
+
|
|
58
|
+
const cls = classes(
|
|
59
|
+
HTML_SELECT_CLASS,
|
|
60
|
+
{
|
|
61
|
+
[DEFAULT_STYLE_CLASS]: defaultStyle
|
|
62
|
+
},
|
|
63
|
+
className
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const optionChildren = options.map(option => {
|
|
67
|
+
const props: IOptionProps =
|
|
68
|
+
typeof option === 'object' ? option : { value: option };
|
|
69
|
+
return (
|
|
70
|
+
<option {...props} key={props.value}>
|
|
71
|
+
{props.label || props.value}
|
|
72
|
+
</option>
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div className={cls}>
|
|
78
|
+
<select
|
|
79
|
+
disabled={disabled}
|
|
80
|
+
ref={elementRef}
|
|
81
|
+
{...htmlProps}
|
|
82
|
+
multiple={false}
|
|
83
|
+
>
|
|
84
|
+
{optionChildren}
|
|
85
|
+
{htmlProps.children}
|
|
86
|
+
</select>
|
|
87
|
+
<icon.react
|
|
88
|
+
{...{
|
|
89
|
+
tag: 'span',
|
|
90
|
+
stylesheet: 'select',
|
|
91
|
+
right: '7px',
|
|
92
|
+
top: '5px',
|
|
93
|
+
...iconProps
|
|
94
|
+
}}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import { Widget } from '@lumino/widgets';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A Lumino widget which wraps an IFrame.
|
|
8
|
+
*/
|
|
9
|
+
export class IFrame extends Widget {
|
|
10
|
+
/**
|
|
11
|
+
* Create a new IFrame widget.
|
|
12
|
+
*/
|
|
13
|
+
constructor(options: IFrame.IOptions = {}) {
|
|
14
|
+
super({ node: Private.createNode() });
|
|
15
|
+
this.addClass('jp-IFrame');
|
|
16
|
+
this.sandbox = options.sandbox || [];
|
|
17
|
+
this.referrerPolicy = options.referrerPolicy || 'no-referrer';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Referrer policy for the iframe.
|
|
22
|
+
*
|
|
23
|
+
* #### Notes
|
|
24
|
+
* By default, `no-referrer` is chosen.
|
|
25
|
+
*
|
|
26
|
+
* For more information, see
|
|
27
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/referrerPolicy
|
|
28
|
+
*/
|
|
29
|
+
get referrerPolicy(): IFrame.ReferrerPolicy {
|
|
30
|
+
return this._referrerPolicy;
|
|
31
|
+
}
|
|
32
|
+
set referrerPolicy(value: IFrame.ReferrerPolicy) {
|
|
33
|
+
if (this._referrerPolicy === value) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this._referrerPolicy = value;
|
|
37
|
+
const iframe = this.node.querySelector('iframe')!;
|
|
38
|
+
iframe.setAttribute('referrerpolicy', value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Exceptions to the sandboxing.
|
|
43
|
+
*
|
|
44
|
+
* #### Notes
|
|
45
|
+
* By default, all sandboxing security policies are enabled.
|
|
46
|
+
* This setting allows the user to selectively disable these
|
|
47
|
+
* policies. This should be done with care, as it can
|
|
48
|
+
* introduce security risks, and possibly allow malicious
|
|
49
|
+
* sites to execute code in a JupyterLab session.
|
|
50
|
+
*
|
|
51
|
+
* For more information, see
|
|
52
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
|
|
53
|
+
*/
|
|
54
|
+
get sandbox(): IFrame.SandboxExceptions[] {
|
|
55
|
+
return this._sandbox.slice();
|
|
56
|
+
}
|
|
57
|
+
set sandbox(values: IFrame.SandboxExceptions[]) {
|
|
58
|
+
this._sandbox = values.slice();
|
|
59
|
+
const iframe = this.node.querySelector('iframe')!;
|
|
60
|
+
const exceptions = values.length ? values.join(' ') : '';
|
|
61
|
+
iframe.setAttribute('sandbox', exceptions);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The url of the IFrame.
|
|
66
|
+
*/
|
|
67
|
+
get url(): string {
|
|
68
|
+
return this.node.querySelector('iframe')!.getAttribute('src') || '';
|
|
69
|
+
}
|
|
70
|
+
set url(url: string) {
|
|
71
|
+
this.node.querySelector('iframe')!.setAttribute('src', url);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private _sandbox: IFrame.SandboxExceptions[] = [];
|
|
75
|
+
private _referrerPolicy: IFrame.ReferrerPolicy;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A namespace for IFrame widget statics.
|
|
80
|
+
*/
|
|
81
|
+
export namespace IFrame {
|
|
82
|
+
/**
|
|
83
|
+
* Referrer policy for the iframe.
|
|
84
|
+
*
|
|
85
|
+
* User documentation for the policies can be found here:
|
|
86
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/referrerPolicy
|
|
87
|
+
*/
|
|
88
|
+
export type ReferrerPolicy =
|
|
89
|
+
| 'no-referrer'
|
|
90
|
+
| 'no-referrer-when-downgrade'
|
|
91
|
+
| 'origin'
|
|
92
|
+
| 'origin-when-cross-origin'
|
|
93
|
+
| 'same-origin'
|
|
94
|
+
| 'strict-origin'
|
|
95
|
+
| 'strict-origin-when-cross-origin'
|
|
96
|
+
| 'unsafe-url';
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Exceptions to the iframe sandboxing policies.
|
|
100
|
+
* These are specified here:
|
|
101
|
+
* https://www.w3.org/TR/2011/WD-html5-20110525/the-iframe-element.html#attr-iframe-sandbox
|
|
102
|
+
*
|
|
103
|
+
* More user-friendly documentation can be found here:
|
|
104
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#sandbox
|
|
105
|
+
*/
|
|
106
|
+
export type SandboxExceptions =
|
|
107
|
+
| 'allow-downloads'
|
|
108
|
+
| 'allow-forms'
|
|
109
|
+
| 'allow-modals'
|
|
110
|
+
| 'allow-orientation-lock'
|
|
111
|
+
| 'allow-pointer-lock'
|
|
112
|
+
| 'allow-popups'
|
|
113
|
+
| 'popups-to-escape-sandbox'
|
|
114
|
+
| 'allow-presentation'
|
|
115
|
+
| 'allow-same-origin'
|
|
116
|
+
| 'allow-scripts'
|
|
117
|
+
| 'allow-storage-access-by-user-activation'
|
|
118
|
+
| 'allow-top-navigation'
|
|
119
|
+
| 'allow-top-navigation-by-user-activation';
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Options for creating a new IFrame widget.
|
|
123
|
+
*/
|
|
124
|
+
export interface IOptions {
|
|
125
|
+
/**
|
|
126
|
+
* Exceptions for the iframe sandbox.
|
|
127
|
+
*/
|
|
128
|
+
sandbox?: SandboxExceptions[];
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Referrer policy for the iframe.
|
|
132
|
+
*/
|
|
133
|
+
referrerPolicy?: ReferrerPolicy;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* A namespace for private data.
|
|
139
|
+
*/
|
|
140
|
+
namespace Private {
|
|
141
|
+
/**
|
|
142
|
+
* Create the main content node of an iframe widget.
|
|
143
|
+
*/
|
|
144
|
+
export function createNode(): HTMLElement {
|
|
145
|
+
const node = document.createElement('div');
|
|
146
|
+
const iframe = document.createElement('iframe');
|
|
147
|
+
iframe.setAttribute('sandbox', '');
|
|
148
|
+
iframe.style.height = '100%';
|
|
149
|
+
iframe.style.width = '100%';
|
|
150
|
+
node.appendChild(iframe);
|
|
151
|
+
return node;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
export * from './button';
|
|
5
|
+
export * from './collapser';
|
|
6
|
+
export * from './form';
|
|
7
|
+
export * from './htmlselect';
|
|
8
|
+
export * from './iframe';
|
|
9
|
+
export * from './inputgroup';
|
|
10
|
+
export * from './interface';
|
|
11
|
+
export * from './menu';
|
|
12
|
+
export * from './panelwithtoolbar';
|
|
13
|
+
export * from './search';
|
|
14
|
+
export * from './sidepanel';
|
|
15
|
+
export * from './spinner';
|
|
16
|
+
export * from './styling';
|
|
17
|
+
export * from './switch';
|
|
18
|
+
export * from './toolbar';
|
|
19
|
+
export * from './vdom';
|
|
20
|
+
export * from './windowedlist';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Jupyter Development Team.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { LabIcon } from '../icon';
|
|
8
|
+
import { classes } from '../utils';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* InputGroup component properties
|
|
12
|
+
*/
|
|
13
|
+
export interface IInputGroupProps
|
|
14
|
+
extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
15
|
+
/**
|
|
16
|
+
* Pass a ref to the input element
|
|
17
|
+
*/
|
|
18
|
+
inputRef?: React.RefObject<HTMLInputElement>;
|
|
19
|
+
/**
|
|
20
|
+
* Right icon adornment
|
|
21
|
+
*/
|
|
22
|
+
rightIcon?: string | LabIcon;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* InputGroup component
|
|
27
|
+
*
|
|
28
|
+
* @param props Component properties
|
|
29
|
+
* @returns Component
|
|
30
|
+
*/
|
|
31
|
+
export function InputGroup(props: IInputGroupProps): JSX.Element {
|
|
32
|
+
const { className, inputRef, rightIcon, ...others } = props;
|
|
33
|
+
return (
|
|
34
|
+
<div className={classes('jp-InputGroup', className)}>
|
|
35
|
+
<input ref={inputRef} {...others}></input>
|
|
36
|
+
{rightIcon && (
|
|
37
|
+
<span className="jp-InputGroupAction">
|
|
38
|
+
{typeof rightIcon === 'string' ? (
|
|
39
|
+
<LabIcon.resolveReact
|
|
40
|
+
icon={rightIcon}
|
|
41
|
+
elementPosition="center"
|
|
42
|
+
tag="span"
|
|
43
|
+
/>
|
|
44
|
+
) : (
|
|
45
|
+
<rightIcon.react elementPosition="center" tag="span" />
|
|
46
|
+
)}
|
|
47
|
+
</span>
|
|
48
|
+
)}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
export const DEFAULT_STYLE_CLASS = 'jp-DefaultStyle';
|
|
5
|
+
|
|
6
|
+
export interface IElementRefProps<E extends HTMLElement> {
|
|
7
|
+
/** Ref handler to access the instance of the internal HTML element. */
|
|
8
|
+
elementRef?: (ref: E | null) => void;
|
|
9
|
+
}
|