@jupyterlab/ui-components 3.3.0-alpha.8 → 4.0.0-alpha.17

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 (49) 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/menu.js.map +1 -1
  20. package/lib/components/panelwithtoolbar.d.ts +27 -0
  21. package/lib/components/panelwithtoolbar.js +18 -0
  22. package/lib/components/panelwithtoolbar.js.map +1 -0
  23. package/lib/components/sidepanel.d.ts +84 -0
  24. package/lib/components/sidepanel.js +96 -0
  25. package/lib/components/sidepanel.js.map +1 -0
  26. package/lib/components/switch.js.map +1 -1
  27. package/lib/components/toolbar.d.ts +90 -17
  28. package/lib/components/toolbar.js +140 -50
  29. package/lib/components/toolbar.js.map +1 -1
  30. package/lib/icon/iconimports.d.ts +2 -0
  31. package/lib/icon/iconimports.js +4 -0
  32. package/lib/icon/iconimports.js.map +1 -1
  33. package/lib/icon/labicon.d.ts +1 -1
  34. package/lib/icon/labicon.js.map +1 -1
  35. package/lib/index.d.ts +0 -1
  36. package/lib/index.js +0 -1
  37. package/lib/index.js.map +1 -1
  38. package/lib/style/icon.js.map +1 -1
  39. package/package.json +15 -26
  40. package/style/base.css +89 -17
  41. package/style/deprecated.css +8 -0
  42. package/style/icons/sidebar/share.svg +5 -0
  43. package/style/icons/sidebar/user.svg +5 -0
  44. package/style/index.css +0 -2
  45. package/style/index.js +0 -2
  46. package/style/sidepanel.css +85 -0
  47. package/lib/blueprint.d.ts +0 -20
  48. package/lib/blueprint.js +0 -23
  49. package/lib/blueprint.js.map +0 -1
@@ -0,0 +1,36 @@
1
+ import { AccordionLayout, AccordionPanel, Title, Widget } from '@lumino/widgets';
2
+ export declare namespace AccordionToolbar {
3
+ /**
4
+ * Custom renderer for the SidePanel
5
+ */
6
+ class Renderer extends AccordionPanel.Renderer {
7
+ /**
8
+ * Render the collapse indicator for a section title.
9
+ *
10
+ * @param data - The data to use for rendering the section title.
11
+ *
12
+ * @returns A element representing the collapse indicator.
13
+ */
14
+ createCollapseIcon(data: Title<Widget>): HTMLElement;
15
+ /**
16
+ * Render the element for a section title.
17
+ *
18
+ * @param data - The data to use for rendering the section title.
19
+ *
20
+ * @returns A element representing the section title.
21
+ */
22
+ createSectionTitle(data: Title<Widget>): HTMLElement;
23
+ }
24
+ const defaultRenderer: Renderer;
25
+ /**
26
+ * Create an accordion layout for accordion panel with toolbar in the title.
27
+ *
28
+ * @param options Panel options
29
+ * @returns Panel layout
30
+ *
31
+ * #### Note
32
+ *
33
+ * Default titleSpace is 29 px (default var(--jp-private-toolbar-height) - but not styled)
34
+ */
35
+ function createLayout(options: AccordionPanel.IOptions): AccordionLayout;
36
+ }
@@ -0,0 +1,229 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { MessageLoop } from '@lumino/messaging';
4
+ import { AccordionLayout, AccordionPanel, Widget } from '@lumino/widgets';
5
+ import { caretDownIcon } from '../icon';
6
+ /**
7
+ * Accordion panel layout that adds a toolbar in widget title if present.
8
+ */
9
+ class AccordionToolbarLayout extends AccordionLayout {
10
+ constructor() {
11
+ super(...arguments);
12
+ this._toolbars = new WeakMap();
13
+ }
14
+ /**
15
+ * Insert a widget into the layout at the specified index.
16
+ *
17
+ * @param index - The index at which to insert the widget.
18
+ *
19
+ * @param widget - The widget to insert into the layout.
20
+ *
21
+ * #### Notes
22
+ * The index will be clamped to the bounds of the widgets.
23
+ *
24
+ * If the widget is already added to the layout, it will be moved.
25
+ *
26
+ * #### Undefined Behavior
27
+ * An `index` which is non-integral.
28
+ */
29
+ insertWidget(index, widget) {
30
+ if (widget.toolbar) {
31
+ this._toolbars.set(widget, widget.toolbar);
32
+ widget.toolbar.addClass('jp-AccordionPanel-toolbar');
33
+ }
34
+ super.insertWidget(index, widget);
35
+ }
36
+ /**
37
+ * Remove the widget at a given index from the layout.
38
+ *
39
+ * @param index - The index of the widget to remove.
40
+ *
41
+ * #### Notes
42
+ * A widget is automatically removed from the layout when its `parent`
43
+ * is set to `null`. This method should only be invoked directly when
44
+ * removing a widget from a layout which has yet to be installed on a
45
+ * parent widget.
46
+ *
47
+ * This method does *not* modify the widget's `parent`.
48
+ *
49
+ * #### Undefined Behavior
50
+ * An `index` which is non-integral.
51
+ */
52
+ removeWidgetAt(index) {
53
+ const widget = this.widgets[index];
54
+ super.removeWidgetAt(index);
55
+ // Remove the toolbar after the widget has `removeWidgetAt` will call `detachWidget`
56
+ if (widget && this._toolbars.has(widget)) {
57
+ this._toolbars.delete(widget);
58
+ }
59
+ }
60
+ /**
61
+ * Attach a widget to the parent's DOM node.
62
+ *
63
+ * @param index - The current index of the widget in the layout.
64
+ *
65
+ * @param widget - The widget to attach to the parent.
66
+ */
67
+ attachWidget(index, widget) {
68
+ super.attachWidget(index, widget);
69
+ const toolbar = this._toolbars.get(widget);
70
+ if (toolbar) {
71
+ // Send a `'before-attach'` message if the parent is attached.
72
+ if (this.parent.isAttached) {
73
+ MessageLoop.sendMessage(toolbar, Widget.Msg.BeforeAttach);
74
+ }
75
+ // Insert the toolbar in the title node.
76
+ this.titles[index].appendChild(toolbar.node);
77
+ // Send an `'after-attach'` message if the parent is attached.
78
+ if (this.parent.isAttached) {
79
+ MessageLoop.sendMessage(toolbar, Widget.Msg.AfterAttach);
80
+ }
81
+ }
82
+ }
83
+ /**
84
+ * Detach a widget from the parent's DOM node.
85
+ *
86
+ * @param index - The previous index of the widget in the layout.
87
+ *
88
+ * @param widget - The widget to detach from the parent.
89
+ */
90
+ detachWidget(index, widget) {
91
+ const toolbar = this._toolbars.get(widget);
92
+ if (toolbar) {
93
+ // Send a `'before-detach'` message if the parent is attached.
94
+ if (this.parent.isAttached) {
95
+ MessageLoop.sendMessage(toolbar, Widget.Msg.BeforeDetach);
96
+ }
97
+ // Remove the toolbar in the title node.
98
+ this.titles[index].removeChild(toolbar.node);
99
+ // Send an `'after-detach'` message if the parent is attached.
100
+ if (this.parent.isAttached) {
101
+ MessageLoop.sendMessage(toolbar, Widget.Msg.AfterDetach);
102
+ }
103
+ }
104
+ super.detachWidget(index, widget);
105
+ }
106
+ /**
107
+ * A message handler invoked on a `'before-attach'` message.
108
+ *
109
+ * #### Notes
110
+ * The default implementation of this method forwards the message
111
+ * to all widgets. It assumes all widget nodes are attached to the
112
+ * parent widget node.
113
+ *
114
+ * This may be reimplemented by subclasses as needed.
115
+ */
116
+ onBeforeAttach(msg) {
117
+ this.notifyToolbars(msg);
118
+ super.onBeforeAttach(msg);
119
+ }
120
+ /**
121
+ * A message handler invoked on an `'after-attach'` message.
122
+ *
123
+ * #### Notes
124
+ * The default implementation of this method forwards the message
125
+ * to all widgets. It assumes all widget nodes are attached to the
126
+ * parent widget node.
127
+ *
128
+ * This may be reimplemented by subclasses as needed.
129
+ */
130
+ onAfterAttach(msg) {
131
+ super.onAfterAttach(msg);
132
+ this.notifyToolbars(msg);
133
+ }
134
+ /**
135
+ * A message handler invoked on a `'before-detach'` message.
136
+ *
137
+ * #### Notes
138
+ * The default implementation of this method forwards the message
139
+ * to all widgets. It assumes all widget nodes are attached to the
140
+ * parent widget node.
141
+ *
142
+ * This may be reimplemented by subclasses as needed.
143
+ */
144
+ onBeforeDetach(msg) {
145
+ this.notifyToolbars(msg);
146
+ super.onBeforeDetach(msg);
147
+ }
148
+ /**
149
+ * A message handler invoked on an `'after-detach'` message.
150
+ *
151
+ * #### Notes
152
+ * The default implementation of this method forwards the message
153
+ * to all widgets. It assumes all widget nodes are attached to the
154
+ * parent widget node.
155
+ *
156
+ * This may be reimplemented by subclasses as needed.
157
+ */
158
+ onAfterDetach(msg) {
159
+ super.onAfterDetach(msg);
160
+ this.notifyToolbars(msg);
161
+ }
162
+ notifyToolbars(msg) {
163
+ this.widgets.forEach(widget => {
164
+ const toolbar = this._toolbars.get(widget);
165
+ if (toolbar) {
166
+ toolbar.processMessage(msg);
167
+ }
168
+ });
169
+ }
170
+ }
171
+ export var AccordionToolbar;
172
+ (function (AccordionToolbar) {
173
+ /**
174
+ * Custom renderer for the SidePanel
175
+ */
176
+ class Renderer extends AccordionPanel.Renderer {
177
+ /**
178
+ * Render the collapse indicator for a section title.
179
+ *
180
+ * @param data - The data to use for rendering the section title.
181
+ *
182
+ * @returns A element representing the collapse indicator.
183
+ */
184
+ createCollapseIcon(data) {
185
+ const iconDiv = document.createElement('div');
186
+ caretDownIcon.element({
187
+ container: iconDiv
188
+ });
189
+ return iconDiv;
190
+ }
191
+ /**
192
+ * Render the element for a section title.
193
+ *
194
+ * @param data - The data to use for rendering the section title.
195
+ *
196
+ * @returns A element representing the section title.
197
+ */
198
+ createSectionTitle(data) {
199
+ const handle = super.createSectionTitle(data);
200
+ handle.classList.add('jp-AccordionPanel-title');
201
+ return handle;
202
+ }
203
+ }
204
+ AccordionToolbar.Renderer = Renderer;
205
+ AccordionToolbar.defaultRenderer = new Renderer();
206
+ /**
207
+ * Create an accordion layout for accordion panel with toolbar in the title.
208
+ *
209
+ * @param options Panel options
210
+ * @returns Panel layout
211
+ *
212
+ * #### Note
213
+ *
214
+ * Default titleSpace is 29 px (default var(--jp-private-toolbar-height) - but not styled)
215
+ */
216
+ function createLayout(options) {
217
+ var _a;
218
+ return (options.layout ||
219
+ new AccordionToolbarLayout({
220
+ renderer: options.renderer || AccordionToolbar.defaultRenderer,
221
+ orientation: options.orientation,
222
+ alignment: options.alignment,
223
+ spacing: options.spacing,
224
+ titleSpace: (_a = options.titleSpace) !== null && _a !== void 0 ? _a : 29
225
+ }));
226
+ }
227
+ AccordionToolbar.createLayout = createLayout;
228
+ })(AccordionToolbar || (AccordionToolbar = {}));
229
+ //# sourceMappingURL=accordiontoolbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accordiontoolbar.js","sourceRoot":"","sources":["../../src/components/accordiontoolbar.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAW,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,eAAe,EACf,cAAc,EAEd,MAAM,EACP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC;;GAEG;AACH,MAAM,sBAAuB,SAAQ,eAAe;IAApD;;QA4KY,cAAS,GAAG,IAAI,OAAO,EAAmB,CAAC;IACvD,CAAC;IA5KC;;;;;;;;;;;;;;OAcG;IACH,YAAY,CAAC,KAAa,EAAE,MAA8B;QACxD,IAAI,MAAM,CAAC,OAAO,EAAE;YAClB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YAC3C,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAC,CAAC;SACtD;QACD,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,cAAc,CAAC,KAAa;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACnC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAC5B,oFAAoF;QACpF,IAAI,MAAM,IAAI,IAAI,CAAC,S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mB;YACpC,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC9C,aAAa,CAAC,OAAO,CAAC;gBACpB,SAAS,EAAE,OAAO;aACnB,CAAC,CAAC;YACH,OAAO,OAAO,CAAC;QACjB,CAAC;QAED;;;;;;WAMG;QACH,kBAAkB,CAAC,IAAmB;YACpC,MAAM,MAAM,GAAG,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;YAC9C,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;YAChD,OAAO,MAAM,CAAC;QAChB,CAAC;KACF;IA5BY,yBAAQ,WA4BpB,CAAA;IAEY,gCAAe,GAAG,IAAI,QAAQ,EAAE,CAAC;IAE9C;;;;;;;;;OASG;IACH,SAAgB,YAAY,CAC1B,OAAgC;;QAEhC,OAAO,CACL,OAAO,CAAC,MAAM;YACd,IAAI,sBAAsB,CAAC;gBACzB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,iBAAA,eAAe;gBAC7C,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,UAAU,EAAE,MAAA,OAAO,CAAC,UAAU,mCAAI,EAAE;aACrC,CAAC,CACH,CAAC;IACJ,CAAC;IAbe,6BAAY,eAa3B,CAAA;AACH,CAAC,EA5DgB,gBAAgB,KAAhB,gBAAgB,QA4DhC"}
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ /**
3
+ * Button component property
4
+ */
5
+ export interface IButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
6
+ /**
7
+ * Whether this button should use minimal styles.
8
+ */
9
+ minimal?: boolean;
10
+ /**
11
+ * Whether this button should use small styles.
12
+ */
13
+ small?: boolean;
14
+ }
15
+ /**
16
+ * Button component
17
+ *
18
+ * @param props Component properties
19
+ * @returns Component
20
+ */
21
+ export declare function Button(props: IButtonProps): JSX.Element;
@@ -0,0 +1,24 @@
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 { classes } from '../utils';
14
+ /**
15
+ * Button component
16
+ *
17
+ * @param props Component properties
18
+ * @returns Component
19
+ */
20
+ export function Button(props) {
21
+ const { minimal, small, children } = props, others = __rest(props, ["minimal", "small", "children"]);
22
+ return (React.createElement("button", Object.assign({}, others, { className: classes(props.className, minimal ? 'jp-mod-minimal' : '', small ? 'jp-mod-small' : '', 'jp-Button') }), children));
23
+ }
24
+ //# sourceMappingURL=button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/components/button.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAiBnC;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,KAAmB;IACxC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,KAAgB,KAAK,EAAhB,MAAM,UAAK,KAAK,EAA/C,gCAAuC,CAAQ,CAAC;IACtD,OAAO,CACL,gDACM,MAAM,IACV,SAAS,EAAE,OAAO,CAChB,KAAK,CAAC,SAAS,EACf,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAC/B,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,EAC3B,WAAW,CACZ,KAEA,QAAQ,CACF,CACV,CAAC;AACJ,CAAC"}
@@ -1,64 +1,19 @@
1
- import { Message } from '@lumino/messaging';
2
- import { ISignal } from '@lumino/signaling';
3
- import { Widget } from '@lumino/widgets';
1
+ import React from 'react';
4
2
  /**
5
- * A panel that supports a collapsible header made from the widget's title.
6
- * Clicking on the title expands or contracts the widget.
3
+ * Collapse component property
7
4
  */
8
- export declare class Collapse<T extends Widget = Widget> extends Widget {
9
- constructor(options: Collapse.IOptions<T>);
5
+ export interface ICollapseProps extends React.HTMLAttributes<HTMLDivElement> {
10
6
  /**
11
- * The widget inside the collapse panel.
12
- */
13
- get widget(): T;
14
- set widget(widget: T);
15
- /**
16
- * The collapsed state of the panel.
17
- */
18
- get collapsed(): boolean;
19
- set collapsed(value: boolean);
20
- /**
21
- * A signal for when the widget collapse state changes.
22
- */
23
- get collapseChanged(): ISignal<Collapse, void>;
24
- /**
25
- * Toggle the collapse state of the panel.
26
- */
27
- toggle(): void;
28
- /**
29
- * Dispose the widget.
30
- */
31
- dispose(): void;
32
- /**
33
- * Handle the DOM events for the Collapse widget.
7
+ * Whether the component is open or closed.
34
8
  *
35
- * @param event - The DOM event sent to the panel.
36
- *
37
- * #### Notes
38
- * This method implements the DOM `EventListener` interface and is
39
- * called in response to events on the panel's DOM node. It should
40
- * not be called directly by user code.
41
- */
42
- handleEvent(event: Event): void;
43
- protected onAfterAttach(msg: Message): void;
44
- protected onBeforeDetach(msg: Message): void;
45
- private _collapse;
46
- private _uncollapse;
47
- private _evtClick;
48
- /**
49
- * Handle the `changed` signal of a title object.
9
+ * @default false
50
10
  */
51
- private _onTitleChanged;
52
- private _setHeader;
53
- private _collapseChanged;
54
- private _collapsed;
55
- private _content;
56
- private _header;
57
- private _widget;
58
- }
59
- export declare namespace Collapse {
60
- interface IOptions<T extends Widget = Widget> extends Widget.IOptions {
61
- widget: T;
62
- collapsed?: boolean;
63
- }
11
+ isOpen?: boolean;
64
12
  }
13
+ /**
14
+ * Collapse component
15
+ *
16
+ * @param props Component properties
17
+ * @returns Component
18
+ */
19
+ export declare function Collapse(props: ICollapseProps): JSX.Element;
@@ -1,145 +1,24 @@
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';
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';
6
13
  /**
7
- * A panel that supports a collapsible header made from the widget's title.
8
- * Clicking on the title expands or contracts the widget.
14
+ * Collapse component
15
+ *
16
+ * @param props Component properties
17
+ * @returns Component
9
18
  */
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
- }
19
+ export function Collapse(props) {
20
+ const { children, isOpen } = props, others = __rest(props, ["children", "isOpen"]);
21
+ others['aria-hidden'] = !!isOpen;
22
+ return React.createElement("div", Object.assign({}, others), isOpen && children);
144
23
  }
145
24
  //# sourceMappingURL=collapse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collapse.js","sourceRoot":"","sources":["../../src/components/collapse.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,iBAAiB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAErD;;;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,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;QAE/C,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,C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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"}
1
+ {"version":3,"file":"collapse.js","sourceRoot":"","sources":["../../src/components/collapse.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAqB;IAC5C,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAgB,KAAK,EAAhB,MAAM,UAAK,KAAK,EAAvC,sBAA+B,CAAQ,CAAC;IAC9C,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,OAAO,6CAAS,MAAM,GAAG,MAAM,IAAI,QAAQ,CAAO,CAAC;AACrD,CAAC"}
@@ -0,0 +1,64 @@
1
+ import { Message } from '@lumino/messaging';
2
+ import { ISignal } from '@lumino/signaling';
3
+ import { Widget } from '@lumino/widgets';
4
+ /**
5
+ * A panel that supports a collapsible header made from the widget's title.
6
+ * Clicking on the title expands or contracts the widget.
7
+ */
8
+ export declare class Collapser<T extends Widget = Widget> extends Widget {
9
+ constructor(options: Collapser.IOptions<T>);
10
+ /**
11
+ * The widget inside the collapse panel.
12
+ */
13
+ get widget(): T;
14
+ set widget(widget: T);
15
+ /**
16
+ * The collapsed state of the panel.
17
+ */
18
+ get collapsed(): boolean;
19
+ set collapsed(value: boolean);
20
+ /**
21
+ * A signal for when the widget collapse state changes.
22
+ */
23
+ get collapseChanged(): ISignal<Collapser, void>;
24
+ /**
25
+ * Toggle the collapse state of the panel.
26
+ */
27
+ toggle(): void;
28
+ /**
29
+ * Dispose the widget.
30
+ */
31
+ dispose(): void;
32
+ /**
33
+ * Handle the DOM events for the Collapser widget.
34
+ *
35
+ * @param event - The DOM event sent to the panel.
36
+ *
37
+ * #### Notes
38
+ * This method implements the DOM `EventListener` interface and is
39
+ * called in response to events on the panel's DOM node. It should
40
+ * not be called directly by user code.
41
+ */
42
+ handleEvent(event: Event): void;
43
+ protected onAfterAttach(msg: Message): void;
44
+ protected onBeforeDetach(msg: Message): void;
45
+ private _collapse;
46
+ private _uncollapse;
47
+ private _evtClick;
48
+ /**
49
+ * Handle the `changed` signal of a title object.
50
+ */
51
+ private _onTitleChanged;
52
+ private _setHeader;
53
+ private _collapseChanged;
54
+ private _collapsed;
55
+ private _content;
56
+ private _header;
57
+ private _widget;
58
+ }
59
+ export declare namespace Collapser {
60
+ interface IOptions<T extends Widget = Widget> extends Widget.IOptions {
61
+ widget: T;
62
+ collapsed?: boolean;
63
+ }
64
+ }