UNPKG

3.12 kBJavaScriptView Raw
1/* -----------------------------------------------------------------------------
2| Copyright (c) Jupyter Development Team.
3| Distributed under the terms of the Modified BSD License.
4|----------------------------------------------------------------------------*/
5import * as React from 'react';
6import { ReactWidget } from '@jupyterlab/apputils';
7import { ellipsesIcon } from '@jupyterlab/ui-components';
8/**
9 * The CSS class added to placeholders.
10 */
11const PLACEHOLDER_CLASS = 'jp-Placeholder';
12/**
13 * The CSS classes added to input placeholder prompts.
14 */
15const INPUT_PROMPT_CLASS = 'jp-Placeholder-prompt jp-InputPrompt';
16/**
17 * The CSS classes added to output placeholder prompts.
18 */
19const OUTPUT_PROMPT_CLASS = 'jp-Placeholder-prompt jp-OutputPrompt';
20/**
21 * The CSS class added to placeholder content.
22 */
23const CONTENT_CLASS = 'jp-Placeholder-content';
24/**
25 * The CSS class added to input placeholders.
26 */
27const INPUT_PLACEHOLDER_CLASS = 'jp-InputPlaceholder';
28/**
29 * The CSS class added to output placeholders.
30 */
31const OUTPUT_PLACEHOLDER_CLASS = 'jp-OutputPlaceholder';
32/**
33 * An abstract base class for placeholders
34 *
35 * ### Notes
36 * A placeholder is the element that is shown when input/output
37 * is hidden.
38 */
39export class Placeholder extends ReactWidget {
40 /**
41 * Construct a new placeholder.
42 */
43 constructor(callback) {
44 super();
45 this.addClass(PLACEHOLDER_CLASS);
46 this._callback = callback;
47 }
48 /**
49 * Handle the click event.
50 */
51 handleClick(e) {
52 const callback = this._callback;
53 callback(e);
54 }
55}
56/**
57 * The input placeholder class.
58 */
59export class InputPlaceholder extends Placeholder {
60 /**
61 * Construct a new input placeholder.
62 */
63 constructor(callback) {
64 super(callback);
65 this.addClass(INPUT_PLACEHOLDER_CLASS);
66 }
67 /**
68 * Render the input placeholder using the virtual DOM.
69 */
70 render() {
71 return [
72 React.createElement("div", { className: INPUT_PROMPT_CLASS, key: "input" }),
73 React.createElement("div", { className: CONTENT_CLASS, onClick: e => this.handleClick(e), key: "content" },
74 React.createElement(ellipsesIcon.react, { className: "jp-MoreHorizIcon", elementPosition: "center", height: "auto", width: "32px" }))
75 ];
76 }
77}
78/**
79 * The output placeholder class.
80 */
81export class OutputPlaceholder extends Placeholder {
82 /**
83 * Construct a new output placeholder.
84 */
85 constructor(callback) {
86 super(callback);
87 this.addClass(OUTPUT_PLACEHOLDER_CLASS);
88 }
89 /**
90 * Render the output placeholder using the virtual DOM.
91 */
92 render() {
93 return [
94 React.createElement("div", { className: OUTPUT_PROMPT_CLASS, key: "output" }),
95 React.createElement("div", { className: CONTENT_CLASS, onClick: e => this.handleClick(e), key: "content" },
96 React.createElement(ellipsesIcon.react, { className: "jp-MoreHorizIcon", elementPosition: "center", height: "auto", width: "32px" }))
97 ];
98 }
99}
100//# sourceMappingURL=placeholder.js.map
\No newline at end of file