@jupyterlab/ui-components 4.0.0-alpha.34 → 4.0.0-alpha.36
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/collapser.js +26 -10
- package/lib/components/collapser.js.map +1 -1
- package/lib/components/form.js +1 -1
- package/lib/components/form.js.map +1 -1
- package/lib/components/menu.d.ts +0 -7
- package/lib/components/menu.js +0 -9
- package/lib/components/menu.js.map +1 -1
- package/lib/components/vdom.d.ts +1 -1
- package/lib/components/windowedlist.d.ts +1 -1
- package/lib/components/windowedlist.js +3 -2
- package/lib/components/windowedlist.js.map +1 -1
- package/lib/hoverbox.d.ts +1 -1
- package/lib/icon/iconimports.d.ts +2 -0
- package/lib/icon/iconimports.js +4 -0
- package/lib/icon/iconimports.js.map +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/lib/style/icon.d.ts +0 -8
- package/lib/style/icon.js +1 -9
- package/lib/style/icon.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 +201 -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 +432 -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 +210 -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 +554 -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
- package/style/collapse.css +20 -6
- package/style/deprecated.css +10 -0
- package/style/icons/search/filter-dot.svg +8 -0
- package/style/icons/search/filter.svg +5 -0
- package/style/icons.css +4 -0
- package/style/rjsfTemplates.css +18 -13
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import { h, VirtualElement } from '@lumino/virtualdom';
|
|
5
|
+
import { CommandPalette } from '@lumino/widgets';
|
|
6
|
+
import { LabIconStyle } from '../../style';
|
|
7
|
+
import { classes } from '../../utils';
|
|
8
|
+
import { checkIcon, filterListIcon } from '../iconimports';
|
|
9
|
+
|
|
10
|
+
const searchHeaderIcon = filterListIcon.bindprops({
|
|
11
|
+
stylesheet: 'commandPaletteHeader',
|
|
12
|
+
className: 'jp-icon-hoverShow-content'
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export namespace CommandPaletteSvg {
|
|
16
|
+
/**
|
|
17
|
+
* a modified implementation of the CommandPalette Renderer
|
|
18
|
+
*/
|
|
19
|
+
export class Renderer extends CommandPalette.Renderer {
|
|
20
|
+
/**
|
|
21
|
+
* Render the virtual element for a command palette header.
|
|
22
|
+
*
|
|
23
|
+
* @param data - The data to use for rendering the header.
|
|
24
|
+
*
|
|
25
|
+
* @returns A virtual element representing the header.
|
|
26
|
+
*/
|
|
27
|
+
renderHeader(data: CommandPalette.IHeaderRenderData): VirtualElement {
|
|
28
|
+
const content = this.formatHeader(data);
|
|
29
|
+
return h.li(
|
|
30
|
+
{
|
|
31
|
+
className: classes('lm-CommandPalette-header', 'jp-icon-hoverShow')
|
|
32
|
+
},
|
|
33
|
+
content,
|
|
34
|
+
h.span(searchHeaderIcon)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Render the icon for a command palette item.
|
|
40
|
+
*
|
|
41
|
+
* @param data - The data to use for rendering the icon.
|
|
42
|
+
*
|
|
43
|
+
* @returns A virtual element representing the icon.
|
|
44
|
+
*/
|
|
45
|
+
renderItemIcon(data: CommandPalette.IItemRenderData): VirtualElement {
|
|
46
|
+
const className = this.createIconClass(data);
|
|
47
|
+
|
|
48
|
+
if (data.item.isToggled) {
|
|
49
|
+
// check mark icon takes precedence
|
|
50
|
+
return h.div({ className }, checkIcon, data.item.iconLabel);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// if data.item.icon is undefined, it will be ignored
|
|
54
|
+
return h.div({ className }, data.item.icon!, data.item.iconLabel);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Create the class name for the command item icon.
|
|
59
|
+
*
|
|
60
|
+
* @param data - The data to use for the class name.
|
|
61
|
+
*
|
|
62
|
+
* @returns The full class name for the item icon.
|
|
63
|
+
*/
|
|
64
|
+
createIconClass(data: CommandPalette.IItemRenderData): string {
|
|
65
|
+
let name = 'lm-CommandPalette-itemIcon';
|
|
66
|
+
|
|
67
|
+
return classes(
|
|
68
|
+
LabIconStyle.styleClass({
|
|
69
|
+
stylesheet: 'commandPaletteItem'
|
|
70
|
+
}),
|
|
71
|
+
data.item.iconClass,
|
|
72
|
+
name
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const defaultRenderer = new Renderer();
|
|
78
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import { IDisposable } from '@lumino/disposable';
|
|
5
|
+
import { ISignal, Signal } from '@lumino/signaling';
|
|
6
|
+
import { h, VirtualElement } from '@lumino/virtualdom';
|
|
7
|
+
import { ContextMenu, Menu } from '@lumino/widgets';
|
|
8
|
+
import { LabIconStyle } from '../../style';
|
|
9
|
+
import { classes } from '../../utils';
|
|
10
|
+
import { caretRightIcon, checkIcon } from '../iconimports';
|
|
11
|
+
|
|
12
|
+
const submenuIcon = caretRightIcon.bindprops({
|
|
13
|
+
stylesheet: 'menuItem'
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* An object which implements a universal context menu.
|
|
18
|
+
* Tweaked to use inline svg icons
|
|
19
|
+
*/
|
|
20
|
+
export class ContextMenuSvg extends ContextMenu implements IDisposable {
|
|
21
|
+
/**
|
|
22
|
+
* Construct a new context menu.
|
|
23
|
+
*
|
|
24
|
+
* @param options - The options for initializing the menu.
|
|
25
|
+
*/
|
|
26
|
+
constructor(options: ContextMenu.IOptions) {
|
|
27
|
+
super(options);
|
|
28
|
+
|
|
29
|
+
// override the vanilla .menu
|
|
30
|
+
this.menu = new MenuSvg(options);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
readonly menu: MenuSvg;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Test whether the context menu is disposed.
|
|
37
|
+
*/
|
|
38
|
+
get isDisposed(): boolean {
|
|
39
|
+
return this._isDisposed;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A signal fired when the context menu is opened.
|
|
44
|
+
*/
|
|
45
|
+
get opened(): ISignal<ContextMenu, void> {
|
|
46
|
+
return this._opened;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Dispose of the resources held by the context menu.
|
|
51
|
+
*/
|
|
52
|
+
dispose(): void {
|
|
53
|
+
if (this._isDisposed) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this._isDisposed = true;
|
|
58
|
+
this.menu.dispose();
|
|
59
|
+
Signal.disconnectSender(this);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Open the context menu in response to a `'contextmenu'` event.
|
|
64
|
+
*
|
|
65
|
+
* @param event - The `'contextmenu'` event of interest.
|
|
66
|
+
*
|
|
67
|
+
* @returns `true` if the menu was opened, or `false` if no items
|
|
68
|
+
* matched the event and the menu was not opened.
|
|
69
|
+
*
|
|
70
|
+
* #### Notes
|
|
71
|
+
* This method will populate the context menu with items which match
|
|
72
|
+
* the propagation path of the event, then open the menu at the mouse
|
|
73
|
+
* position indicated by the event.
|
|
74
|
+
*/
|
|
75
|
+
open(event: MouseEvent): boolean {
|
|
76
|
+
if (this._isDisposed) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
const hasItems = super.open(event);
|
|
80
|
+
if (hasItems) {
|
|
81
|
+
this._opened.emit();
|
|
82
|
+
}
|
|
83
|
+
return hasItems;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
protected _isDisposed = false;
|
|
87
|
+
protected _opened: Signal<ContextMenu, void> = new Signal<ContextMenu, void>(
|
|
88
|
+
this
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* a widget which displays items as a canonical menu.
|
|
94
|
+
* Tweaked to use inline svg icons
|
|
95
|
+
*/
|
|
96
|
+
export class MenuSvg extends Menu {
|
|
97
|
+
/**
|
|
98
|
+
* construct a new menu. Overrides the default renderer
|
|
99
|
+
*
|
|
100
|
+
* @param options - The options for initializing the tab bar.
|
|
101
|
+
*/
|
|
102
|
+
constructor(options: Menu.IOptions) {
|
|
103
|
+
options.renderer = options.renderer || MenuSvg.defaultRenderer;
|
|
104
|
+
super(options);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* insert a menu item into the menu at the specified index. Replaces the
|
|
109
|
+
* default renderer for submenus
|
|
110
|
+
*
|
|
111
|
+
* @param index - The index at which to insert the item.
|
|
112
|
+
*
|
|
113
|
+
* @param options - The options for creating the menu item.
|
|
114
|
+
*
|
|
115
|
+
* @returns The menu item added to the menu.
|
|
116
|
+
*
|
|
117
|
+
* #### Notes
|
|
118
|
+
* The index will be clamped to the bounds of the items.
|
|
119
|
+
*/
|
|
120
|
+
insertItem(index: number, options: Menu.IItemOptions): Menu.IItem {
|
|
121
|
+
if (options.submenu) {
|
|
122
|
+
MenuSvg.overrideDefaultRenderer(options.submenu);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return super.insertItem(index, options);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export namespace MenuSvg {
|
|
130
|
+
export function overrideDefaultRenderer(menu: Menu): void {
|
|
131
|
+
// override renderer, if needed
|
|
132
|
+
if (menu.renderer === Menu.defaultRenderer) {
|
|
133
|
+
// cast away readonly on menu.renderer
|
|
134
|
+
(menu as any).renderer = MenuSvg.defaultRenderer;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// ensure correct renderer on any submenus that get added in the future
|
|
138
|
+
const originalInsertItem = menu.insertItem.bind(menu);
|
|
139
|
+
menu.insertItem = (index: number, options: Menu.IItemOptions) => {
|
|
140
|
+
if (options.submenu) {
|
|
141
|
+
MenuSvg.overrideDefaultRenderer(options.submenu);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return originalInsertItem(index, options);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// recurse through submenus
|
|
148
|
+
for (const item of (menu as any)._items as Menu.IItem[]) {
|
|
149
|
+
if (item.submenu) {
|
|
150
|
+
overrideDefaultRenderer(item.submenu);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* a modified implementation of the Menu Renderer
|
|
157
|
+
*/
|
|
158
|
+
export class Renderer extends Menu.Renderer {
|
|
159
|
+
/**
|
|
160
|
+
* Render the icon element for a menu item.
|
|
161
|
+
*
|
|
162
|
+
* @param data - The data to use for rendering the icon.
|
|
163
|
+
*
|
|
164
|
+
* @returns A virtual element representing the item icon.
|
|
165
|
+
*/
|
|
166
|
+
renderIcon(data: Menu.IRenderData): VirtualElement {
|
|
167
|
+
const className = this.createIconClass(data);
|
|
168
|
+
|
|
169
|
+
if (data.item.isToggled) {
|
|
170
|
+
// check mark icon takes precedence
|
|
171
|
+
return h.div({ className }, checkIcon, data.item.iconLabel);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// if data.item.icon is undefined, it will be ignored
|
|
175
|
+
return h.div({ className }, data.item.icon!, data.item.iconLabel);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Create the class name for the menu item icon.
|
|
180
|
+
*
|
|
181
|
+
* @param data - The data to use for the class name.
|
|
182
|
+
*
|
|
183
|
+
* @returns The full class name for the item icon.
|
|
184
|
+
*/
|
|
185
|
+
createIconClass(data: Menu.IRenderData): string {
|
|
186
|
+
let name = 'lm-Menu-itemIcon';
|
|
187
|
+
|
|
188
|
+
if (data.item.type === 'separator') {
|
|
189
|
+
return classes(data.item.iconClass, name);
|
|
190
|
+
} else {
|
|
191
|
+
return classes(
|
|
192
|
+
LabIconStyle.styleClass({ stylesheet: 'menuItem' }),
|
|
193
|
+
data.item.iconClass,
|
|
194
|
+
name
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Render the submenu icon element for a menu item.
|
|
201
|
+
*
|
|
202
|
+
* @param data - The data to use for rendering the submenu icon.
|
|
203
|
+
*
|
|
204
|
+
* @returns A virtual element representing the submenu icon.
|
|
205
|
+
*/
|
|
206
|
+
renderSubmenu(data: Menu.IRenderData): VirtualElement {
|
|
207
|
+
const className = 'lm-Menu-itemSubmenuIcon';
|
|
208
|
+
|
|
209
|
+
if (data.item.type === 'submenu') {
|
|
210
|
+
return h.div({ className }, submenuIcon);
|
|
211
|
+
} else {
|
|
212
|
+
return h.div({ className });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export const defaultRenderer = new Renderer();
|
|
218
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
|
|
5
|
+
import { hpass, VirtualElement } from '@lumino/virtualdom';
|
|
6
|
+
import { DockPanel, TabBar, TabPanel, Widget } from '@lumino/widgets';
|
|
7
|
+
import { LabIconStyle } from '../../style';
|
|
8
|
+
import { classes } from '../../utils';
|
|
9
|
+
import { addIcon, closeIcon } from '../iconimports';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* a widget which displays titles as a single row or column of tabs.
|
|
13
|
+
* Tweaked to use an inline svg as the close icon
|
|
14
|
+
*/
|
|
15
|
+
export class TabBarSvg<T> extends TabBar<T> {
|
|
16
|
+
/**
|
|
17
|
+
* Translator object
|
|
18
|
+
*/
|
|
19
|
+
static translator: ITranslator | null = null;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Construct a new tab bar. Overrides the default renderer.
|
|
23
|
+
*
|
|
24
|
+
* @param options - The options for initializing the tab bar.
|
|
25
|
+
*/
|
|
26
|
+
constructor(options: TabBar.IOptions<T> = {}) {
|
|
27
|
+
super({ renderer: TabBarSvg.defaultRenderer, ...options });
|
|
28
|
+
const trans = (TabBarSvg.translator ?? nullTranslator).load('jupyterlab');
|
|
29
|
+
addIcon.element({
|
|
30
|
+
container: this.addButtonNode,
|
|
31
|
+
title: trans.__('New Launcher')
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export namespace TabBarSvg {
|
|
37
|
+
/**
|
|
38
|
+
* A modified implementation of the TabBar Renderer.
|
|
39
|
+
*/
|
|
40
|
+
export class Renderer extends TabBar.Renderer {
|
|
41
|
+
/**
|
|
42
|
+
* Render the close icon element for a tab.
|
|
43
|
+
*
|
|
44
|
+
* @param data - The data to use for rendering the tab.
|
|
45
|
+
*
|
|
46
|
+
* @returns A virtual element representing the tab close icon.
|
|
47
|
+
*/
|
|
48
|
+
renderCloseIcon(data: TabBar.IRenderData<any>): VirtualElement {
|
|
49
|
+
const className = classes(
|
|
50
|
+
'jp-icon-hover lm-TabBar-tabCloseIcon',
|
|
51
|
+
LabIconStyle.styleClass({
|
|
52
|
+
elementPosition: 'center',
|
|
53
|
+
height: '16px',
|
|
54
|
+
width: '16px'
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return hpass(
|
|
59
|
+
'div',
|
|
60
|
+
{ className },
|
|
61
|
+
closeIcon
|
|
62
|
+
) as unknown as VirtualElement;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const defaultRenderer = new Renderer();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* a widget which provides a flexible docking area for widgets.
|
|
71
|
+
* Tweaked to use an inline svg as the close icon
|
|
72
|
+
*/
|
|
73
|
+
export class DockPanelSvg extends DockPanel {
|
|
74
|
+
/**
|
|
75
|
+
* Construct a new dock panel.
|
|
76
|
+
*
|
|
77
|
+
* @param options - The options for initializing the panel.
|
|
78
|
+
*/
|
|
79
|
+
constructor(options: DockPanel.IOptions = {}) {
|
|
80
|
+
super({
|
|
81
|
+
renderer: DockPanelSvg.defaultRenderer,
|
|
82
|
+
...options
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export namespace DockPanelSvg {
|
|
88
|
+
/**
|
|
89
|
+
* A modified implementation of the DockPanel Renderer.
|
|
90
|
+
*/
|
|
91
|
+
export class Renderer extends DockPanel.Renderer {
|
|
92
|
+
/**
|
|
93
|
+
* Create a new tab bar (with inline svg icons enabled
|
|
94
|
+
* for use with a dock panel.
|
|
95
|
+
*
|
|
96
|
+
* @returns A new tab bar for a dock panel.
|
|
97
|
+
*/
|
|
98
|
+
createTabBar(): TabBarSvg<Widget> {
|
|
99
|
+
const bar = new TabBarSvg<Widget>();
|
|
100
|
+
bar.addClass('lm-DockPanel-tabBar');
|
|
101
|
+
return bar;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const defaultRenderer = new Renderer();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A widget which combines a `TabBar` and a `StackedPanel`.
|
|
110
|
+
* Tweaked to use an inline svg as the close icon
|
|
111
|
+
*/
|
|
112
|
+
export class TabPanelSvg extends TabPanel {
|
|
113
|
+
/**
|
|
114
|
+
* Construct a new tab panel.
|
|
115
|
+
*
|
|
116
|
+
* @param options - The options for initializing the tab panel.
|
|
117
|
+
*/
|
|
118
|
+
constructor(options: TabPanel.IOptions = {}) {
|
|
119
|
+
options.renderer = options.renderer || TabBarSvg.defaultRenderer;
|
|
120
|
+
super(options);
|
|
121
|
+
}
|
|
122
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
/**
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
* @module ui-components
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export * from './components';
|
|
9
|
+
export * from './icon';
|
|
10
|
+
export * from './hoverbox';
|
|
11
|
+
export * from './tokens';
|
|
12
|
+
export * from './utils';
|
|
13
|
+
export * from './FormRendererRegistry';
|