@jupyterlab/launcher 0.17.2 → 0.18.4

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/index.js CHANGED
@@ -258,7 +258,7 @@ var Private;
258
258
  }
259
259
  // Finally, compare by display name.
260
260
  const aLabel = commands.label(a.command, Object.assign({}, a.args, { cwd }));
261
- const bLabel = commands.label(a.command, Object.assign({}, b.args, { cwd }));
261
+ const bLabel = commands.label(b.command, Object.assign({}, b.args, { cwd }));
262
262
  return aLabel.localeCompare(bLabel);
263
263
  }
264
264
  Private.sortCmp = sortCmp;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../launcher/src/index.tsx"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,2DAA2D;;;;;;;;;AAE3D,mDAI8B;AAE9B,mDAO6B;AAI7B,mDAAgE;AAEhE,qDAAuE;AAEvE,qDAAwD;AAExD,+CAA2C;AAE3C,6CAA+B;AAE/B,8BAA4B;AAE5B;;GAEG;AACH,MAAM,cAAc,GAAG,aAAa,CAAC;AAErC;;GAEG;AACH,MAAM,gBAAgB,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAElD,oBAAoB;AACpB;;GAEG;AACU,QAAA,SAAS,GAAG,IAAI,iBAAK,CAAY,gCAAgC,CAAC,CAAC;AAoBhF;;;GAGG;AACH,mBAA2B,SAAQ,oBAAS;IAC1C;;OAEG;IACH;QACE,KAAK,EAAE,CAAC;QAiCF,WAAM,GAA6B,EAAE,CAAC;IAhC9C,CAAC;IAED;;;;;;;;;OASG;IACH,GAAG,CAAC,OAA+B;QACjC,wEAAwE;QACxE,IAAI,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAEvC,IAAI,CAAC,M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EAAE,GAAG,CAAC,CAAC,IAAI,CAAC;QAChB,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC;QAChB,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,SAAS,EAAE;YACrD,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB;SAC1C;QAED,oCAAoC;QACpC,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,oBAAO,CAAC,CAAC,IAAI,IAAE,GAAG,IAAG,CAAC;QAC7D,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,oBAAO,CAAC,CAAC,IAAI,IAAE,GAAG,IAAG,CAAC;QAC7D,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAjBe,eAAO,UAiBtB,CAAA;AACH,CAAC,EAnDS,OAAO,KAAP,OAAO,QAmDhB","sourcesContent":["// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n\nimport {\n showErrorMessage,\n VDomModel,\n VDomRenderer\n} from '@jupyterlab/apputils';\n\nimport {\n ArrayExt,\n ArrayIterator,\n IIterator,\n map,\n each,\n toArray\n} from '@phosphor/algorithm';\n\nimport { CommandRegistry } from '@phosphor/commands';\n\nimport { Token, ReadonlyJSONObject } from '@phosphor/coreutils';\n\nimport { DisposableDelegate, IDisposable } from '@phosphor/disposable';\n\nimport { AttachedProperty } from '@phosphor/properties';\n\nimport { Widget } from '@phosphor/widgets';\n\nimport * as React from 'react';\n\nimport '../style/index.css';\n\n/**\n * The class name added to Launcher instances.\n */\nconst LAUNCHER_CLASS = 'jp-Launcher';\n\n/**\n * The known categories of launcher items and their default ordering.\n */\nconst KNOWN_CATEGORIES = ['Notebook', 'Console', 'Other'];\n\n/**\n * These launcher item categories are known to have kernels, so the kernel icons\n * are used.\n */\nconst KERNEL_CATEGORIES = ['Notebook', 'Console'];\n\n/* tslint:disable */\n/**\n * The launcher token.\n */\nexport const ILauncher = new Token<ILauncher>('@jupyterlab/launcher:ILauncher');\n/* tslint:enable */\n\n/**\n * The launcher interface.\n */\nexport interface ILauncher {\n /**\n * Add a command item to the launcher, and trigger re-render event for parent\n * widget.\n *\n * @param options - The specification options for a launcher item.\n *\n * @returns A disposable that will remove the item from Launcher, and trigger\n * re-render event for parent widget.\n *\n */\n add(options: ILauncher.IItemOptions): IDisposable;\n}\n\n/**\n * LauncherModel keeps track of the path to working directory and has a list of\n * LauncherItems, which the Launcher will render.\n */\nexport class LauncherModel extends VDomModel implements ILauncher {\n /**\n * Create a new launcher model.\n */\n constructor() {\n super();\n }\n\n /**\n * Add a command item to the launcher, and trigger re-render event for parent\n * widget.\n *\n * @param options - The specification options for a launcher item.\n *\n * @returns A disposable that will remove the item from Launcher, and trigger\n * re-render event for parent widget.\n *\n */\n add(options: ILauncher.IItemOptions): IDisposable {\n // Create a copy of the options to circumvent mutations to the original.\n let item = Private.createItem(options);\n\n this._items.push(item);\n this.stateChanged.emit(void 0);\n\n return new DisposableDelegate(() => {\n ArrayExt.removeFirstOf(this._items, item);\n this.stateChanged.emit(void 0);\n });\n }\n\n /**\n * Return an iterator of launcher items.\n */\n items(): IIterator<ILauncher.IItemOptions> {\n return new ArrayIterator(this._items);\n }\n\n private _items: ILauncher.IItemOptions[] = [];\n}\n\n/**\n * A virtual-DOM-based widget for the Launcher.\n */\nexport class Launcher extends VDomRenderer<LauncherModel> {\n /**\n * Construct a new launcher widget.\n */\n constructor(options: ILauncher.IOptions) {\n super();\n this._cwd = options.cwd;\n this._callback = options.callback;\n this._commands = options.commands;\n this.addClass(LAUNCHER_CLASS);\n }\n\n /**\n * The cwd of the launcher.\n */\n get cwd(): string {\n return this._cwd;\n }\n set cwd(value: string) {\n this._cwd = value;\n this.update();\n }\n\n /**\n * Whether there is a pending item being launched.\n */\n get pending(): boolean {\n return this._pending;\n }\n set pending(value: boolean) {\n this._pending = value;\n }\n\n /**\n * Render the launcher to virtual DOM nodes.\n */\n protected render(): React.ReactElement<any> {\n // Bail if there is no model.\n if (!this.model) {\n return null;\n }\n\n // First group-by categories\n let categories = Object.create(null);\n each(this.model.items(), (item, index) => {\n let cat = item.category || 'Other';\n if (!(cat in categories)) {\n categories[cat] = [];\n }\n categories[cat].push(item);\n });\n // Within each category sort by rank\n for (let cat in categories) {\n categories[cat] = categories[cat].sort(\n (a: ILauncher.IItemOptions, b: ILauncher.IItemOptions) => {\n return Private.sortCmp(a, b, this._cwd, this._commands);\n }\n );\n }\n\n // Variable to help create sections\n let sections: React.ReactElement<any>[] = [];\n let section: React.ReactElement<any>;\n\n // Assemble the final ordered list of categories, beginning with\n // KNOWN_CATEGORIES.\n let orderedCategories: string[] = [];\n each(KNOWN_CATEGORIES, (cat, index) => {\n orderedCategories.push(cat);\n });\n for (let cat in categories) {\n if (KNOWN_CATEGORIES.indexOf(cat) === -1) {\n orderedCategories.push(cat);\n }\n }\n\n // Now create the sections for each category\n orderedCategories.forEach(cat => {\n const item = categories[cat][0] as ILauncher.IItemOptions;\n let iconClass =\n `${this._commands.iconClass(item.command, {\n ...item.args,\n cwd: this.cwd\n })} ` + 'jp-Launcher-sectionIcon jp-Launcher-icon';\n let kernel = KERNEL_CATEGORIES.indexOf(cat) > -1;\n if (cat in categories) {\n section = (\n <div className=\"jp-Launcher-section\" key={cat}>\n <div className=\"jp-Launcher-sectionHeader\">\n {kernel && <div className={iconClass} />}\n <h2 className=\"jp-Launcher-sectionTitle\">{cat}</h2>\n </div>\n <div className=\"jp-Launcher-cardContainer\">\n {toArray(\n map(categories[cat], (item: ILauncher.IItemOptions) => {\n return Card(\n kernel,\n item,\n this,\n this._commands,\n this._callback\n );\n })\n )}\n </div>\n </div>\n );\n sections.push(section);\n }\n });\n\n // Wrap the sections in body and content divs.\n return (\n <div className=\"jp-Launcher-body\">\n <div className=\"jp-Launcher-content\">\n <div className=\"jp-Launcher-cwd\">\n <h3>{this.cwd}</h3>\n </div>\n {sections}\n </div>\n </div>\n );\n }\n\n private _commands: CommandRegistry;\n private _callback: (widget: Widget) => void;\n private _pending = false;\n private _cwd = '';\n}\n\n/**\n * The namespace for `ILauncher` class statics.\n */\nexport namespace ILauncher {\n /**\n * The options used to create a Launcher.\n */\n export interface IOptions {\n /**\n * The cwd of the launcher.\n */\n cwd: string;\n\n /**\n * The command registry used by the launcher.\n */\n commands: CommandRegistry;\n\n /**\n * The callback used when an item is launched.\n */\n callback: (widget: Widget) => void;\n }\n\n /**\n * The options used to create a launcher item.\n */\n export interface IItemOptions {\n /**\n * The command ID for the launcher item.\n *\n * #### Notes\n * If the command's `execute` method returns a `Widget` or\n * a promise that resolves with a `Widget`, then that widget will\n * replace the launcher in the same location of the application\n * shell. If the `execute` method does something else\n * (i.e., create a modal dialog), then the launcher will not be\n * disposed.\n */\n command: string;\n\n /**\n * The arguments given to the command for\n * creating the launcher item.\n *\n * ### Notes\n * The launcher will also add the current working\n * directory of the filebrowser in the `cwd` field\n * of the args, which a command may use to create\n * the activity with respect to the right directory.\n */\n args?: ReadonlyJSONObject;\n\n /**\n * The category for the launcher item.\n *\n * The default value is the an empty string.\n */\n category?: string;\n\n /**\n * The rank for the launcher item.\n *\n * The rank is used when ordering launcher items for display. After grouping\n * into categories, items are sorted in the following order:\n * 1. Rank (lower is better)\n * 3. Display Name (locale order)\n *\n * The default rank is `Infinity`.\n */\n rank?: number;\n\n /**\n * For items that have a kernel associated with them, the URL of the kernel\n * icon.\n *\n * This is not a CSS class, but the URL that points to the icon in the kernel\n * spec.\n */\n kernelIconUrl?: string;\n }\n}\n\n/**\n * A pure tsx component for a launcher card.\n *\n * @param kernel - whether the item takes uses a kernel.\n *\n * @param item - the launcher item to render.\n *\n * @param launcher - the Launcher instance to which this is added.\n *\n * @param launcherCallback - a callback to call after an item has been launched.\n *\n * @returns a vdom `VirtualElement` for the launcher card.\n */\nfunction Card(\n kernel: boolean,\n item: ILauncher.IItemOptions,\n launcher: Launcher,\n commands: CommandRegistry,\n launcherCallback: (widget: Widget) => void\n): React.ReactElement<any> {\n // Get some properties of the command\n const command = item.command;\n const args = { ...item.args, cwd: launcher.cwd };\n const label = commands.label(command, args);\n\n // Build the onclick handler.\n let onclick = () => {\n // If an item has already been launched,\n // don't try to launch another.\n if (launcher.pending === true) {\n return;\n }\n launcher.pending = true;\n commands\n .execute(command, {\n ...item.args,\n cwd: launcher.cwd\n })\n .then(value => {\n launcher.pending = false;\n if (value instanceof Widget) {\n launcherCallback(value);\n launcher.dispose();\n }\n })\n .catch(err => {\n launcher.pending = false;\n showErrorMessage('Launcher Error', err);\n });\n };\n\n // Return the VDOM element.\n return (\n <div\n className=\"jp-LauncherCard\"\n title={label}\n onClick={onclick}\n data-category={item.category || 'Other'}\n key={Private.keyProperty.get(item)}\n >\n <div className=\"jp-LauncherCard-icon\">\n {item.kernelIconUrl &&\n kernel && (\n <img src={item.kernelIconUrl} className=\"jp-Launcher-kernelIcon\" />\n )}\n {!item.kernelIconUrl &&\n !kernel && (\n <div\n className={`${commands.iconClass(\n command,\n args\n )} jp-Launcher-icon`}\n />\n )}\n {!item.kernelIconUrl &&\n kernel && (\n <div className=\"jp-LauncherCard-noKernelIcon\">\n {label[0].toUpperCase()}\n </div>\n )}\n </div>\n <div className=\"jp-LauncherCard-label\" title={label}>\n {label}\n </div>\n </div>\n );\n}\n\n/**\n * The namespace for module private data.\n */\nnamespace Private {\n /**\n * An incrementing counter for keys.\n */\n let id = 0;\n\n /**\n * An attached property for an item's key.\n */\n export const keyProperty = new AttachedProperty<\n ILauncher.IItemOptions,\n number\n >({\n name: 'key',\n create: () => id++\n });\n\n /**\n * Create a fully specified item given item options.\n */\n export function createItem(\n options: ILauncher.IItemOptions\n ): ILauncher.IItemOptions {\n return {\n ...options,\n category: options.category || '',\n rank: options.rank !== undefined ? options.rank : Infinity\n };\n }\n\n /**\n * A sort comparison function for a launcher item.\n */\n export function sortCmp(\n a: ILauncher.IItemOptions,\n b: ILauncher.IItemOptions,\n cwd: string,\n commands: CommandRegistry\n ): number {\n // First, compare by rank.\n let r1 = a.rank;\n let r2 = b.rank;\n if (r1 !== r2 && r1 !== undefined && r2 !== undefined) {\n return r1 < r2 ? -1 : 1; // Infinity safe\n }\n\n // Finally, compare by display name.\n const aLabel = commands.label(a.command, { ...a.args, cwd });\n const bLabel = commands.label(a.command, { ...b.args, cwd });\n return aLabel.localeCompare(bLabel);\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../launcher/src/index.tsx"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,2DAA2D;;;;;;;;;AAE3D,mDAI8B;AAE9B,mDAO6B;AAI7B,mDAAgE;AAEhE,qDAAuE;AAEvE,qDAAwD;AAExD,+CAA2C;AAE3C,6CAA+B;AAE/B,8BAA4B;AAE5B;;GAEG;AACH,MAAM,cAAc,GAAG,aAAa,CAAC;AAErC;;GAEG;AACH,MAAM,gBAAgB,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAElD,oBAAoB;AACpB;;GAEG;AACU,QAAA,SAAS,GAAG,IAAI,iBAAK,CAAY,gCAAgC,CAAC,CAAC;AAoBhF;;;GAGG;AACH,mBAA2B,SAAQ,oBAAS;IAC1C;;OAEG;IACH;QACE,KAAK,EAAE,CAAC;QAiCF,WAAM,GAA6B,EAAE,CAAC;IAhC9C,CAAC;IAED;;;;;;;;;OASG;IACH,GAAG,CAAC,OAA+B;QACjC,wEAAwE;QACxE,IAAI,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAEvC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,C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IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,SAAS,EAAE;YACrD,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB;SAC1C;QAED,oCAAoC;QACpC,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,oBAAO,CAAC,CAAC,IAAI,IAAE,GAAG,IAAG,CAAC;QAC7D,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,oBAAO,CAAC,CAAC,IAAI,IAAE,GAAG,IAAG,CAAC;QAC7D,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAjBe,eAAO,UAiBtB,CAAA;AACH,CAAC,EAnDS,OAAO,KAAP,OAAO,QAmDhB","sourcesContent":["// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n\nimport {\n showErrorMessage,\n VDomModel,\n VDomRenderer\n} from '@jupyterlab/apputils';\n\nimport {\n ArrayExt,\n ArrayIterator,\n IIterator,\n map,\n each,\n toArray\n} from '@phosphor/algorithm';\n\nimport { CommandRegistry } from '@phosphor/commands';\n\nimport { Token, ReadonlyJSONObject } from '@phosphor/coreutils';\n\nimport { DisposableDelegate, IDisposable } from '@phosphor/disposable';\n\nimport { AttachedProperty } from '@phosphor/properties';\n\nimport { Widget } from '@phosphor/widgets';\n\nimport * as React from 'react';\n\nimport '../style/index.css';\n\n/**\n * The class name added to Launcher instances.\n */\nconst LAUNCHER_CLASS = 'jp-Launcher';\n\n/**\n * The known categories of launcher items and their default ordering.\n */\nconst KNOWN_CATEGORIES = ['Notebook', 'Console', 'Other'];\n\n/**\n * These launcher item categories are known to have kernels, so the kernel icons\n * are used.\n */\nconst KERNEL_CATEGORIES = ['Notebook', 'Console'];\n\n/* tslint:disable */\n/**\n * The launcher token.\n */\nexport const ILauncher = new Token<ILauncher>('@jupyterlab/launcher:ILauncher');\n/* tslint:enable */\n\n/**\n * The launcher interface.\n */\nexport interface ILauncher {\n /**\n * Add a command item to the launcher, and trigger re-render event for parent\n * widget.\n *\n * @param options - The specification options for a launcher item.\n *\n * @returns A disposable that will remove the item from Launcher, and trigger\n * re-render event for parent widget.\n *\n */\n add(options: ILauncher.IItemOptions): IDisposable;\n}\n\n/**\n * LauncherModel keeps track of the path to working directory and has a list of\n * LauncherItems, which the Launcher will render.\n */\nexport class LauncherModel extends VDomModel implements ILauncher {\n /**\n * Create a new launcher model.\n */\n constructor() {\n super();\n }\n\n /**\n * Add a command item to the launcher, and trigger re-render event for parent\n * widget.\n *\n * @param options - The specification options for a launcher item.\n *\n * @returns A disposable that will remove the item from Launcher, and trigger\n * re-render event for parent widget.\n *\n */\n add(options: ILauncher.IItemOptions): IDisposable {\n // Create a copy of the options to circumvent mutations to the original.\n let item = Private.createItem(options);\n\n this._items.push(item);\n this.stateChanged.emit(void 0);\n\n return new DisposableDelegate(() => {\n ArrayExt.removeFirstOf(this._items, item);\n this.stateChanged.emit(void 0);\n });\n }\n\n /**\n * Return an iterator of launcher items.\n */\n items(): IIterator<ILauncher.IItemOptions> {\n return new ArrayIterator(this._items);\n }\n\n private _items: ILauncher.IItemOptions[] = [];\n}\n\n/**\n * A virtual-DOM-based widget for the Launcher.\n */\nexport class Launcher extends VDomRenderer<LauncherModel> {\n /**\n * Construct a new launcher widget.\n */\n constructor(options: ILauncher.IOptions) {\n super();\n this._cwd = options.cwd;\n this._callback = options.callback;\n this._commands = options.commands;\n this.addClass(LAUNCHER_CLASS);\n }\n\n /**\n * The cwd of the launcher.\n */\n get cwd(): string {\n return this._cwd;\n }\n set cwd(value: string) {\n this._cwd = value;\n this.update();\n }\n\n /**\n * Whether there is a pending item being launched.\n */\n get pending(): boolean {\n return this._pending;\n }\n set pending(value: boolean) {\n this._pending = value;\n }\n\n /**\n * Render the launcher to virtual DOM nodes.\n */\n protected render(): React.ReactElement<any> {\n // Bail if there is no model.\n if (!this.model) {\n return null;\n }\n\n // First group-by categories\n let categories = Object.create(null);\n each(this.model.items(), (item, index) => {\n let cat = item.category || 'Other';\n if (!(cat in categories)) {\n categories[cat] = [];\n }\n categories[cat].push(item);\n });\n // Within each category sort by rank\n for (let cat in categories) {\n categories[cat] = categories[cat].sort(\n (a: ILauncher.IItemOptions, b: ILauncher.IItemOptions) => {\n return Private.sortCmp(a, b, this._cwd, this._commands);\n }\n );\n }\n\n // Variable to help create sections\n let sections: React.ReactElement<any>[] = [];\n let section: React.ReactElement<any>;\n\n // Assemble the final ordered list of categories, beginning with\n // KNOWN_CATEGORIES.\n let orderedCategories: string[] = [];\n each(KNOWN_CATEGORIES, (cat, index) => {\n orderedCategories.push(cat);\n });\n for (let cat in categories) {\n if (KNOWN_CATEGORIES.indexOf(cat) === -1) {\n orderedCategories.push(cat);\n }\n }\n\n // Now create the sections for each category\n orderedCategories.forEach(cat => {\n const item = categories[cat][0] as ILauncher.IItemOptions;\n let iconClass =\n `${this._commands.iconClass(item.command, {\n ...item.args,\n cwd: this.cwd\n })} ` + 'jp-Launcher-sectionIcon jp-Launcher-icon';\n let kernel = KERNEL_CATEGORIES.indexOf(cat) > -1;\n if (cat in categories) {\n section = (\n <div className=\"jp-Launcher-section\" key={cat}>\n <div className=\"jp-Launcher-sectionHeader\">\n {kernel && <div className={iconClass} />}\n <h2 className=\"jp-Launcher-sectionTitle\">{cat}</h2>\n </div>\n <div className=\"jp-Launcher-cardContainer\">\n {toArray(\n map(categories[cat], (item: ILauncher.IItemOptions) => {\n return Card(\n kernel,\n item,\n this,\n this._commands,\n this._callback\n );\n })\n )}\n </div>\n </div>\n );\n sections.push(section);\n }\n });\n\n // Wrap the sections in body and content divs.\n return (\n <div className=\"jp-Launcher-body\">\n <div className=\"jp-Launcher-content\">\n <div className=\"jp-Launcher-cwd\">\n <h3>{this.cwd}</h3>\n </div>\n {sections}\n </div>\n </div>\n );\n }\n\n private _commands: CommandRegistry;\n private _callback: (widget: Widget) => void;\n private _pending = false;\n private _cwd = '';\n}\n\n/**\n * The namespace for `ILauncher` class statics.\n */\nexport namespace ILauncher {\n /**\n * The options used to create a Launcher.\n */\n export interface IOptions {\n /**\n * The cwd of the launcher.\n */\n cwd: string;\n\n /**\n * The command registry used by the launcher.\n */\n commands: CommandRegistry;\n\n /**\n * The callback used when an item is launched.\n */\n callback: (widget: Widget) => void;\n }\n\n /**\n * The options used to create a launcher item.\n */\n export interface IItemOptions {\n /**\n * The command ID for the launcher item.\n *\n * #### Notes\n * If the command's `execute` method returns a `Widget` or\n * a promise that resolves with a `Widget`, then that widget will\n * replace the launcher in the same location of the application\n * shell. If the `execute` method does something else\n * (i.e., create a modal dialog), then the launcher will not be\n * disposed.\n */\n command: string;\n\n /**\n * The arguments given to the command for\n * creating the launcher item.\n *\n * ### Notes\n * The launcher will also add the current working\n * directory of the filebrowser in the `cwd` field\n * of the args, which a command may use to create\n * the activity with respect to the right directory.\n */\n args?: ReadonlyJSONObject;\n\n /**\n * The category for the launcher item.\n *\n * The default value is the an empty string.\n */\n category?: string;\n\n /**\n * The rank for the launcher item.\n *\n * The rank is used when ordering launcher items for display. After grouping\n * into categories, items are sorted in the following order:\n * 1. Rank (lower is better)\n * 3. Display Name (locale order)\n *\n * The default rank is `Infinity`.\n */\n rank?: number;\n\n /**\n * For items that have a kernel associated with them, the URL of the kernel\n * icon.\n *\n * This is not a CSS class, but the URL that points to the icon in the kernel\n * spec.\n */\n kernelIconUrl?: string;\n }\n}\n\n/**\n * A pure tsx component for a launcher card.\n *\n * @param kernel - whether the item takes uses a kernel.\n *\n * @param item - the launcher item to render.\n *\n * @param launcher - the Launcher instance to which this is added.\n *\n * @param launcherCallback - a callback to call after an item has been launched.\n *\n * @returns a vdom `VirtualElement` for the launcher card.\n */\nfunction Card(\n kernel: boolean,\n item: ILauncher.IItemOptions,\n launcher: Launcher,\n commands: CommandRegistry,\n launcherCallback: (widget: Widget) => void\n): React.ReactElement<any> {\n // Get some properties of the command\n const command = item.command;\n const args = { ...item.args, cwd: launcher.cwd };\n const label = commands.label(command, args);\n\n // Build the onclick handler.\n let onclick = () => {\n // If an item has already been launched,\n // don't try to launch another.\n if (launcher.pending === true) {\n return;\n }\n launcher.pending = true;\n commands\n .execute(command, {\n ...item.args,\n cwd: launcher.cwd\n })\n .then(value => {\n launcher.pending = false;\n if (value instanceof Widget) {\n launcherCallback(value);\n launcher.dispose();\n }\n })\n .catch(err => {\n launcher.pending = false;\n showErrorMessage('Launcher Error', err);\n });\n };\n\n // Return the VDOM element.\n return (\n <div\n className=\"jp-LauncherCard\"\n title={label}\n onClick={onclick}\n data-category={item.category || 'Other'}\n key={Private.keyProperty.get(item)}\n >\n <div className=\"jp-LauncherCard-icon\">\n {item.kernelIconUrl &&\n kernel && (\n <img src={item.kernelIconUrl} className=\"jp-Launcher-kernelIcon\" />\n )}\n {!item.kernelIconUrl &&\n !kernel && (\n <div\n className={`${commands.iconClass(\n command,\n args\n )} jp-Launcher-icon`}\n />\n )}\n {!item.kernelIconUrl &&\n kernel && (\n <div className=\"jp-LauncherCard-noKernelIcon\">\n {label[0].toUpperCase()}\n </div>\n )}\n </div>\n <div className=\"jp-LauncherCard-label\" title={label}>\n {label}\n </div>\n </div>\n );\n}\n\n/**\n * The namespace for module private data.\n */\nnamespace Private {\n /**\n * An incrementing counter for keys.\n */\n let id = 0;\n\n /**\n * An attached property for an item's key.\n */\n export const keyProperty = new AttachedProperty<\n ILauncher.IItemOptions,\n number\n >({\n name: 'key',\n create: () => id++\n });\n\n /**\n * Create a fully specified item given item options.\n */\n export function createItem(\n options: ILauncher.IItemOptions\n ): ILauncher.IItemOptions {\n return {\n ...options,\n category: options.category || '',\n rank: options.rank !== undefined ? options.rank : Infinity\n };\n }\n\n /**\n * A sort comparison function for a launcher item.\n */\n export function sortCmp(\n a: ILauncher.IItemOptions,\n b: ILauncher.IItemOptions,\n cwd: string,\n commands: CommandRegistry\n ): number {\n // First, compare by rank.\n let r1 = a.rank;\n let r2 = b.rank;\n if (r1 !== r2 && r1 !== undefined && r2 !== undefined) {\n return r1 < r2 ? -1 : 1; // Infinity safe\n }\n\n // Finally, compare by display name.\n const aLabel = commands.label(a.command, { ...a.args, cwd });\n const bLabel = commands.label(b.command, { ...b.args, cwd });\n return aLabel.localeCompare(bLabel);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlab/launcher",
3
- "version": "0.17.2",
3
+ "version": "0.18.4",
4
4
  "description": "JupyterLab - Launcher Panel",
5
5
  "homepage": "https://github.com/jupyterlab/jupyterlab",
6
6
  "bugs": {
@@ -30,7 +30,7 @@
30
30
  "watch": "tsc -w --listEmittedFiles"
31
31
  },
32
32
  "dependencies": {
33
- "@jupyterlab/apputils": "^0.17.2",
33
+ "@jupyterlab/apputils": "^0.18.4",
34
34
  "@phosphor/algorithm": "^1.1.2",
35
35
  "@phosphor/commands": "^1.5.0",
36
36
  "@phosphor/coreutils": "^1.3.0",
package/style/index.css CHANGED
@@ -171,7 +171,6 @@
171
171
  background-size: var(--jp-private-launcher-large-icon-size)
172
172
  var(--jp-private-launcher-large-icon-size);
173
173
  background-repeat: no-repeat;
174
- cursor: pointer;
175
174
  }
176
175
 
177
176
  .jp-Launcher-kernelIcon {