UNPKG

2.88 kBJavaScriptView Raw
1// Copyright (c) Jupyter Development Team.
2// Distributed under the terms of the Modified BSD License.
3import { h } from '@lumino/virtualdom';
4import { CommandPalette } from '@lumino/widgets';
5import { LabIconStyle } from '../../style';
6import { classes } from '../../utils';
7import { checkIcon, filterListIcon } from '../iconimports';
8const searchHeaderIcon = filterListIcon.bindprops({
9 stylesheet: 'commandPaletteHeader'
10});
11export var CommandPaletteSvg;
12(function (CommandPaletteSvg) {
13 /**
14 * a modified implementation of the CommandPalette Renderer
15 */
16 class Renderer extends CommandPalette.Renderer {
17 /**
18 * Render the virtual element for a command palette header.
19 *
20 * @param data - The data to use for rendering the header.
21 *
22 * @returns A virtual element representing the header.
23 */
24 renderHeader(data) {
25 const content = this.formatHeader(data);
26 return h.li({
27 className: classes('lm-CommandPalette-header', 'jp-icon-hoverShow',
28 /* <DEPRECATED> */
29 'p-CommandPalette-header'
30 /* </DEPRECATED> */
31 )
32 }, content, h.span(searchHeaderIcon));
33 }
34 /**
35 * Render the icon for a command palette item.
36 *
37 * @param data - The data to use for rendering the icon.
38 *
39 * @returns A virtual element representing the icon.
40 */
41 renderItemIcon(data) {
42 const className = this.createIconClass(data);
43 if (data.item.isToggled) {
44 // check mark icon takes precedence
45 return h.div({ className }, checkIcon, data.item.iconLabel);
46 }
47 /* <DEPRECATED> */
48 if (typeof data.item.icon === 'string') {
49 return h.div({ className }, data.item.iconLabel);
50 }
51 /* </DEPRECATED> */
52 // if data.item.icon is undefined, it will be ignored
53 return h.div({ className }, data.item.icon, data.item.iconLabel);
54 }
55 /**
56 * Create the class name for the command item icon.
57 *
58 * @param data - The data to use for the class name.
59 *
60 * @returns The full class name for the item icon.
61 */
62 createIconClass(data) {
63 let name = 'lm-CommandPalette-itemIcon';
64 /* <DEPRECATED> */
65 name += ' p-CommandPalette-itemIcon';
66 /* </DEPRECATED> */
67 return classes(LabIconStyle.styleClass({
68 stylesheet: 'commandPaletteItem'
69 }), data.item.iconClass, name);
70 }
71 }
72 CommandPaletteSvg.Renderer = Renderer;
73 CommandPaletteSvg.defaultRenderer = new Renderer();
74})(CommandPaletteSvg || (CommandPaletteSvg = {}));
75//# sourceMappingURL=commandpalettesvg.js.map
\No newline at end of file