Skip to content

Commit

Permalink
Custom widgets working
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed Jul 17, 2024
1 parent cbcbbad commit 76de527
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/voila/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ import { Widget } from '@lumino/widgets';

import { requireLoader } from './loader';

function windowDefine(name: string, module: any) {
if (typeof window !== 'undefined' && typeof window.define !== 'undefined') {
window.define(name, module);
}
}

if (typeof window !== 'undefined' && typeof window.define !== 'undefined') {
window.define('jquery', $);

Expand Down Expand Up @@ -184,13 +190,18 @@ export class WidgetManager extends JupyterLabManager {
this.register({
name: '@jupyter-widgets/base',
version: "2.0.0",
exports: async () => require('@jupyter-widgets/base') as any,
exports: async () => {
const baseWidgets = require('@jupyter-widgets/base') as any;
windowDefine('@jupyter-widgets/base', baseWidgets);
return baseWidgets;
},
});
this.register({
name: '@jupyter-widgets/controls',
version: "2.0.0",
exports: async () => {
const controlsWidgets = require('@jupyter-widgets/controls') as any;
windowDefine('@jupyter-widgets/controls', controlsWidgets);
require('@jupyter-widgets/controls/css/widgets-base.css');
return controlsWidgets;
},
Expand All @@ -203,13 +214,18 @@ export class WidgetManager extends JupyterLabManager {
this.register({
name: '@jupyter-widgets/base',
version: "1.2.0",
exports: async () => require('@jupyter-widgets/base7') as any,
exports: async () => {
const base7Widgets = require('@jupyter-widgets/base7') as any
windowDefine('@jupyter-widgets/base', base7Widgets);
return base7Widgets;
},
});
this.register({
name: '@jupyter-widgets/controls',
version: "1.5.0",
exports: async () => {
const controls7Widget = require('@jupyter-widgets/controls7') as any;
windowDefine('@jupyter-widgets/controls', controls7Widget);
require('@jupyter-widgets/controls7/css/widgets-base.css');
return controls7Widget;
},
Expand Down

0 comments on commit 76de527

Please sign in to comment.