@jupyterlab/ui-components 3.3.0-alpha.7 → 4.0.0-alpha.16

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.
Files changed (38) hide show
  1. package/lib/components/accordiontoolbar.d.ts +36 -0
  2. package/lib/components/accordiontoolbar.js +229 -0
  3. package/lib/components/accordiontoolbar.js.map +1 -0
  4. package/lib/components/button.d.ts +21 -0
  5. package/lib/components/button.js +24 -0
  6. package/lib/components/button.js.map +1 -0
  7. package/lib/components/collapse.d.ts +13 -58
  8. package/lib/components/collapse.js +20 -141
  9. package/lib/components/collapse.js.map +1 -1
  10. package/lib/components/collapser.d.ts +64 -0
  11. package/lib/components/collapser.js +145 -0
  12. package/lib/components/collapser.js.map +1 -0
  13. package/lib/components/index.d.ts +6 -1
  14. package/lib/components/index.js +6 -1
  15. package/lib/components/index.js.map +1 -1
  16. package/lib/components/inputgroup.d.ts +18 -0
  17. package/lib/components/inputgroup.js +27 -0
  18. package/lib/components/inputgroup.js.map +1 -0
  19. package/lib/components/panelwithtoolbar.d.ts +27 -0
  20. package/lib/components/panelwithtoolbar.js +18 -0
  21. package/lib/components/panelwithtoolbar.js.map +1 -0
  22. package/lib/components/sidepanel.d.ts +84 -0
  23. package/lib/components/sidepanel.js +95 -0
  24. package/lib/components/sidepanel.js.map +1 -0
  25. package/lib/components/toolbar.d.ts +90 -17
  26. package/lib/components/toolbar.js +140 -50
  27. package/lib/components/toolbar.js.map +1 -1
  28. package/lib/index.d.ts +0 -1
  29. package/lib/index.js +0 -1
  30. package/lib/index.js.map +1 -1
  31. package/package.json +14 -25
  32. package/style/base.css +89 -17
  33. package/style/index.css +0 -2
  34. package/style/index.js +0 -2
  35. package/style/sidepanel.css +85 -0
  36. package/lib/blueprint.d.ts +0 -20
  37. package/lib/blueprint.js +0 -23
  38. package/lib/blueprint.js.map +0 -1
@@ -0,0 +1,145 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { Signal } from '@lumino/signaling';
4
+ import { Panel, PanelLayout, Widget } from '@lumino/widgets';
5
+ import { caretDownIcon, caretUpIcon } from '../icon';
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 Collapser 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 Collapser 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=collapser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collapser.js","sourceRoot":"","sources":["../../src/components/collapser.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAG3D,OAAO,EAAW,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAS,MAAM,EAAE,MAAM,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- export { Collapse as Collapser } from './collapse';
1
+ export * from './button';
2
+ export * from './collapse';
3
+ export * from './collapser';
2
4
  export * from './htmlselect';
3
5
  export * from './iframe';
6
+ export * from './inputgroup';
4
7
  export * from './interface';
5
8
  export * from './menu';
9
+ export * from './panelwithtoolbar';
10
+ export * from './sidepanel';
6
11
  export * from './spinner';
7
12
  export * from './styling';
8
13
  export * from './switch';
@@ -1,10 +1,15 @@
1
1
  // Copyright (c) Jupyter Development Team.
2
2
  // Distributed under the terms of the Modified BSD License.
3
- export { Collapse as Collapser } from './collapse';
3
+ export * from './button';
4
+ export * from './collapse';
5
+ export * from './collapser';
4
6
  export * from './htmlselect';
5
7
  export * from './iframe';
8
+ export * from './inputgroup';
6
9
  export * from './interface';
7
10
  export * from './menu';
11
+ export * from './panelwithtoolbar';
12
+ export * from './sidepanel';
8
13
  export * from './spinner';
9
14
  export * from './styling';
10
15
  export * from './switch';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AACnD,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { LabIcon } from '../icon';
3
+ /**
4
+ * InputGroup component properties
5
+ */
6
+ export interface IInputGroupProps extends React.InputHTMLAttributes<HTMLInputElement> {
7
+ /**
8
+ * Right icon adornment
9
+ */
10
+ rightIcon?: string | LabIcon;
11
+ }
12
+ /**
13
+ * InputGroup component
14
+ *
15
+ * @param props Component properties
16
+ * @returns Component
17
+ */
18
+ export declare function InputGroup(props: IInputGroupProps): JSX.Element;
@@ -0,0 +1,27 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React from 'react';
13
+ import { LabIcon } from '../icon';
14
+ import { classes } from '../utils';
15
+ /**
16
+ * InputGroup component
17
+ *
18
+ * @param props Component properties
19
+ * @returns Component
20
+ */
21
+ export function InputGroup(props) {
22
+ const { className, rightIcon } = props, others = __rest(props, ["className", "rightIcon"]);
23
+ return (React.createElement("div", { className: classes('jp-InputGroup', className) },
24
+ React.createElement("input", Object.assign({}, others)),
25
+ rightIcon && (React.createElement("span", { className: "jp-InputGroupAction" }, typeof rightIcon === 'string' ? (React.createElement(LabIcon.resolveReact, { icon: rightIcon, elementPosition: "center", tag: "span" })) : (React.createElement(rightIcon.react, { elementPosition: "center", tag: "span" }))))));
26
+ }
27
+ //# sourceMappingURL=inputgroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputgroup.js","sourceRoot":"","sources":["../../src/components/inputgroup.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAanC;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAuB;IAChD,MAAM,EAAE,SAAS,EAAE,SAAS,KAAgB,KAAK,EAAhB,MAAM,UAAK,KAAK,EAA3C,0BAAmC,CAAQ,CAAC;IAClD,OAAO,CACL,6BAAK,SAAS,EAAE,OAAO,CAAC,eAAe,EAAE,SAAS,CAAC;QACjD,+CAAW,MAAM,EAAU;QAC1B,SAAS,IAAI,CACZ,8BAAM,SAAS,EAAC,qBAAqB,IAClC,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,CAC/B,oBAAC,OAAO,CAAC,YAAY,IACnB,IAAI,EAAE,SAAS,EACf,eAAe,EAAC,QAAQ,EACxB,GAAG,EAAC,MAAM,GACV,CACH,CAAC,CAAC,CAAC,CACF,oBAAC,SAAS,CAAC,KAAK,IAAC,eAAe,EAAC,QAAQ,EAAC,GAAG,EAAC,MAAM,GAAG,CACxD,CACI,CACR,CACG,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { Panel } from '@lumino/widgets';
2
+ import { Toolbar } from './toolbar';
3
+ /**
4
+ * A base class for panel widget with toolbar.
5
+ */
6
+ export declare class PanelWithToolbar extends Panel implements Toolbar.IWidgetToolbar {
7
+ constructor(options?: PanelWithToolbar.IOptions);
8
+ /**
9
+ * Widget toolbar
10
+ */
11
+ get toolbar(): Toolbar;
12
+ protected _toolbar: Toolbar;
13
+ }
14
+ /**
15
+ * Namespace for panel with toolbar
16
+ */
17
+ export declare namespace PanelWithToolbar {
18
+ /**
19
+ * An options object for creating a panel with toolbar widget.
20
+ */
21
+ interface IOptions extends Panel.IOptions {
22
+ /**
23
+ * Custom toolbar
24
+ */
25
+ toolbar?: Toolbar;
26
+ }
27
+ }
@@ -0,0 +1,18 @@
1
+ import { Panel } from '@lumino/widgets';
2
+ import { Toolbar } from './toolbar';
3
+ /**
4
+ * A base class for panel widget with toolbar.
5
+ */
6
+ export class PanelWithToolbar extends Panel {
7
+ constructor(options = {}) {
8
+ super(options);
9
+ this._toolbar = new Toolbar();
10
+ }
11
+ /**
12
+ * Widget toolbar
13
+ */
14
+ get toolbar() {
15
+ return this._toolbar;
16
+ }
17
+ }
18
+ //# sourceMappingURL=panelwithtoolbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panelwithtoolbar.js","sourceRoot":"","sources":["../../src/components/panelwithtoolbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YAAY,UAAqC,EAAE;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CAGF"}
@@ -0,0 +1,84 @@
1
+ import { ITranslator, TranslationBundle } from '@jupyterlab/translation';
2
+ import { AccordionPanel, Panel, Widget } from '@lumino/widgets';
3
+ import { Toolbar } from './toolbar';
4
+ /**
5
+ * A widget meant to be contained in sidebars.
6
+ *
7
+ * #### Note
8
+ * By default the content widget is an accordion panel that supports widget with
9
+ * associated toolbar to be displayed in the widget title.
10
+ */
11
+ export declare class SidePanel extends Widget {
12
+ constructor(options?: SidePanel.IOptions);
13
+ /**
14
+ * The content hosted by the widget.
15
+ */
16
+ get content(): Panel;
17
+ /**
18
+ * A panel for widgets that sit on top of the widget.
19
+ */
20
+ get header(): Panel;
21
+ /**
22
+ * The toolbar hosted by the widget.
23
+ *
24
+ * It sits between the header and the content
25
+ */
26
+ get toolbar(): Toolbar;
27
+ /**
28
+ * A read-only array of the widgets in the content panel.
29
+ */
30
+ get widgets(): ReadonlyArray<Widget>;
31
+ /**
32
+ * Add a widget to the content panel bottom.
33
+ *
34
+ * @param widget Widget to add
35
+ */
36
+ addWidget(widget: Toolbar.IWidgetToolbar): void;
37
+ /**
38
+ * Insert a widget at the given position in the content panel.
39
+ *
40
+ * @param index Position
41
+ * @param widget Widget to insert
42
+ */
43
+ insertWidget(index: number, widget: Toolbar.IWidgetToolbar): void;
44
+ private addHeader;
45
+ private addToolbar;
46
+ protected _content: Panel;
47
+ protected _header: Panel;
48
+ protected _toolbar: Toolbar;
49
+ protected _trans: TranslationBundle;
50
+ }
51
+ /**
52
+ * The namespace for the `SidePanel` class statics.
53
+ */
54
+ export declare namespace SidePanel {
55
+ /**
56
+ * An options object for creating a side panel widget.
57
+ */
58
+ interface IOptions extends AccordionPanel.IOptions {
59
+ /**
60
+ * The main child of the side panel
61
+ *
62
+ * If nothing is provided it fallback to an AccordionToolbar panel.
63
+ */
64
+ content?: Panel;
65
+ /**
66
+ * The header is at the top of the SidePanel,
67
+ * and that extensions can populate.
68
+ *
69
+ * Defaults to an empty Panel if requested otherwise it won't be created.
70
+ */
71
+ header?: Panel;
72
+ /**
73
+ * The toolbar to use for the widget.
74
+ * It sits between the header and the content
75
+ *
76
+ * Defaults to an empty toolbar if requested otherwise it won't be created.
77
+ */
78
+ toolbar?: Toolbar;
79
+ /**
80
+ * The application language translator.
81
+ */
82
+ translator?: ITranslator;
83
+ }
84
+ }
@@ -0,0 +1,95 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { nullTranslator } from '@jupyterlab/translation';
4
+ import { AccordionPanel, Panel, PanelLayout, Widget } from '@lumino/widgets';
5
+ import { AccordionToolbar } from './accordiontoolbar';
6
+ import { Toolbar } from './toolbar';
7
+ /**
8
+ * A widget meant to be contained in sidebars.
9
+ *
10
+ * #### Note
11
+ * By default the content widget is an accordion panel that supports widget with
12
+ * associated toolbar to be displayed in the widget title.
13
+ */
14
+ export class SidePanel extends Widget {
15
+ constructor(options = {}) {
16
+ var _a;
17
+ super();
18
+ const layout = (this.layout = new PanelLayout());
19
+ this.addClass('jp-SidePanel');
20
+ const trans = (this._trans = (options.translator || nullTranslator).load('jupyterlab'));
21
+ if (options.header) {
22
+ this.addHeader(options.header);
23
+ }
24
+ const content = (this._content = (_a = options.content) !== null && _a !== void 0 ? _a : new AccordionPanel(Object.assign(Object.assign({}, options), { layout: AccordionToolbar.createLayout(options) })));
25
+ content.node.setAttribute('role', 'region');
26
+ content.node.setAttribute('aria-label', trans.__('side panel content'));
27
+ content.addClass('jp-SidePanel-content');
28
+ layout.addWidget(content);
29
+ if (options.toolbar) {
30
+ this.addToolbar(options.toolbar);
31
+ }
32
+ }
33
+ /**
34
+ * The content hosted by the widget.
35
+ */
36
+ get content() {
37
+ return this._content;
38
+ }
39
+ /**
40
+ * A panel for widgets that sit on top of the widget.
41
+ */
42
+ get header() {
43
+ if (!this._header) {
44
+ this.addHeader();
45
+ }
46
+ return this._header;
47
+ }
48
+ /**
49
+ * The toolbar hosted by the widget.
50
+ *
51
+ * It sits between the header and the content
52
+ */
53
+ get toolbar() {
54
+ if (!this._toolbar) {
55
+ this.addToolbar();
56
+ }
57
+ return this._toolbar;
58
+ }
59
+ /**
60
+ * A read-only array of the widgets in the content panel.
61
+ */
62
+ get widgets() {
63
+ return this.content.widgets;
64
+ }
65
+ /**
66
+ * Add a widget to the content panel bottom.
67
+ *
68
+ * @param widget Widget to add
69
+ */
70
+ addWidget(widget) {
71
+ this.content.addWidget(widget);
72
+ }
73
+ /**
74
+ * Insert a widget at the given position in the content panel.
75
+ *
76
+ * @param index Position
77
+ * @param widget Widget to insert
78
+ */
79
+ insertWidget(index, widget) {
80
+ this.content.insertWidget(index, widget);
81
+ }
82
+ addHeader(header) {
83
+ const theHeader = (this._header = header || new Panel());
84
+ theHeader.addClass('jp-SidePanel-header');
85
+ this.layout.insertWidget(0, theHeader);
86
+ }
87
+ addToolbar(toolbar) {
88
+ const theToolbar = (this._toolbar = toolbar !== null && toolbar !== void 0 ? toolbar : new Toolbar());
89
+ theToolbar.addClass('jp-SidePanel-toolbar');
90
+ theToolbar.node.setAttribute('role', 'navigation');
91
+ theToolbar.node.setAttribute('aria-label', this._trans.__('side panel actions'));
92
+ this.layout.insertWidget(this.layout.widgets.length - 1, theToolbar);
93
+ }
94
+ }
95
+ //# sourceMappingURL=sidepanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidepanel.js","sourceRoot":"","sources":["../../src/components/sidepanel.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAEL,cAAc,EAEf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,OAAO,SAAU,SAAQ,MAAM;IACnC,YAAY,UAA8B,EAAE;;QAC1C,KAAK,EAAE,CAAC;QACR,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QAE9B,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,cAAc,CAAC,CAAC,IAAI,CACtE,YAAY,CAC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OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAC,KAAa,EAAE,MAA8B;QACxD,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IAEO,SAAS,CAAC,MAAc;QAC9B,MAAM,SAAS,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;QACzD,SAAS,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;QAEzC,IAAI,CAAC,MAAsB,CAAC,YAAY,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAC1D,CAAC;IAEO,UAAU,CAAC,OAAiB;QAClC,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,QAAQ,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAI,OAAO,EAAE,CAAC,CAAC;QAC9D,UAAU,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;QAC5C,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACnD,UAAU,CAAC,IAAI,CAAC,YAAY,CAC1B,YAAY,EACZ,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,oBAAoB,CAAC,CACrC,CAAC;QACD,IAAI,CAAC,MAAsB,CAAC,YAAY,CACtC,IAAI,CAAC,MAAsB,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAC/C,UAAU,CACX,CAAC;IACJ,CAAC;CAMF"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ITranslator } from '@jupyterlab/translation';
3
2
  import { IIterator } from '@lumino/algorithm';
4
3
  import { CommandRegistry } from '@lumino/commands';
@@ -37,10 +36,6 @@ export declare class Toolbar<T extends Widget = Widget> extends Widget {
37
36
  * The item can be removed from the toolbar by setting its parent to `null`.
38
37
  */
39
38
  addItem(name: string, widget: T): boolean;
40
- /**
41
- * Dispose of the widget and its descendant widgets.
42
- */
43
- dispose(): void;
44
39
  /**
45
40
  * Insert an item into the toolbar at the specified index.
46
41
  *
@@ -116,11 +111,65 @@ export declare class Toolbar<T extends Widget = Widget> extends Widget {
116
111
  * Handle `before-detach` messages for the widget.
117
112
  */
118
113
  protected onBeforeDetach(msg: Message): void;
114
+ }
115
+ /**
116
+ * A class which provides a toolbar widget.
117
+ */
118
+ export declare class ReactiveToolbar extends Toolbar<Widget> {
119
+ /**
120
+ * Construct a new toolbar widget.
121
+ */
122
+ constructor();
123
+ /**
124
+ * Dispose of the widget and its descendant widgets.
125
+ */
126
+ dispose(): void;
127
+ /**
128
+ * Insert an item into the toolbar at the after a target item.
129
+ *
130
+ * @param at - The target item to insert after.
131
+ *
132
+ * @param name - The name of the item.
133
+ *
134
+ * @param widget - The widget to add.
135
+ *
136
+ * @returns Whether the item was added to the toolbar. Returns false if
137
+ * an item of the same name is already in the toolbar or if the target
138
+ * is the toolbar pop-up opener.
139
+ *
140
+ * #### Notes
141
+ * The index will be clamped to the bounds of the items.
142
+ * The item can be removed from the toolbar by setting its parent to `null`.
143
+ */
144
+ insertAfter(at: string, name: string, widget: Widget): boolean;
145
+ /**
146
+ * Insert an item into the toolbar at the specified index.
147
+ *
148
+ * @param index - The index at which to insert the item.
149
+ *
150
+ * @param name - The name of the item.
151
+ *
152
+ * @param widget - The widget to add.
153
+ *
154
+ * @returns Whether the item was added to the toolbar. Returns false if
155
+ * an item of the same name is already in the toolbar.
156
+ *
157
+ * #### Notes
158
+ * The index will be clamped to the bounds of the items.
159
+ * The item can be removed from the toolbar by setting its parent to `null`.
160
+ */
161
+ insertItem(index: number, name: string, widget: Widget): boolean;
162
+ /**
163
+ * A message handler invoked on a `'before-hide'` message.
164
+ *
165
+ * It will hide the pop-up panel
166
+ */
167
+ onBeforeHide(msg: Message): void;
119
168
  protected onResize(msg: Widget.ResizeMessage): void;
120
169
  private _onResize;
121
170
  private _saveWidgetWidth;
122
171
  private _getWidgetWidth;
123
- readonly popupOpener: ToolbarPopupOpener;
172
+ protected readonly popupOpener: ToolbarPopupOpener;
124
173
  private readonly _widgetWidths;
125
174
  private readonly _resizer;
126
175
  }
@@ -128,6 +177,15 @@ export declare class Toolbar<T extends Widget = Widget> extends Widget {
128
177
  * The namespace for Toolbar class statics.
129
178
  */
130
179
  export declare namespace Toolbar {
180
+ /**
181
+ * Widget with associated toolbar
182
+ */
183
+ interface IWidgetToolbar extends Widget {
184
+ /**
185
+ * Toolbar of actions on the widget
186
+ */
187
+ toolbar?: Toolbar;
188
+ }
131
189
  /**
132
190
  * Create a toolbar spacer item.
133
191
  *
@@ -321,34 +379,49 @@ declare class ToolbarPopup extends Widget {
321
379
  * the toolbar items overflow toolbar width
322
380
  */
323
381
  declare class ToolbarPopupOpener extends ToolbarButton {
324
- readonly _popup: ToolbarPopup;
325
382
  /**
326
383
  * Create a new popup opener
327
384
  */
328
385
  constructor();
329
- protected handleClick(): void;
330
- /**
331
- * Updates width and position of the popup
332
- * to align with the toolbar
333
- */
334
- updatePopup(): void;
335
386
  /**
336
387
  * Add widget to the popup, prepends widgets
337
388
  * @param widget the widget to add
338
389
  */
339
390
  addWidget(widget: Widget): void;
340
391
  /**
341
- * Returns total no of widgets in the popup
392
+ * Dispose of the widget and its descendant widgets.
393
+ *
394
+ * #### Notes
395
+ * It is unsafe to use the widget after it has been disposed.
396
+ *
397
+ * All calls made to this method after the first are a no-op.
342
398
  */
343
- widgetCount(): number;
399
+ dispose(): void;
400
+ /**
401
+ * Hides the opener and the popup
402
+ */
403
+ hide(): void;
404
+ /**
405
+ * Hides the popup
406
+ */
407
+ hidePopup(): void;
408
+ /**
409
+ * Updates width and position of the popup
410
+ * to align with the toolbar
411
+ */
412
+ updatePopup(): void;
344
413
  /**
345
414
  * Returns widget at index in the popup
346
415
  * @param index
347
416
  */
348
417
  widgetAt(index: number): Widget;
349
418
  /**
350
- * Hides the opener and the popup
419
+ * Returns total number of widgets in the popup
420
+ *
421
+ * @returns Number of widgets
351
422
  */
352
- hide(): void;
423
+ widgetCount(): number;
424
+ protected handleClick(): void;
425
+ protected popup: ToolbarPopup;
353
426
  }
354
427
  export {};