How to use @jupyter-widgets/schema - 2 common examples

To help you get started, we’ve selected a few @jupyter-widgets/schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyter-widgets / ipywidgets / packages / html-manager / src / libembed.ts View on Github external
declare var  __webpack_public_path__:string;
__webpack_public_path__ = (window as any).__jupyter_widgets_assets_path__ || __webpack_public_path__;

import 'font-awesome/css/font-awesome.css';
import '@phosphor/widgets/style/index.css';
import '@jupyter-widgets/controls/css/widgets.css';

// Used just for the typing. We must not import the javascript because we don't
// want to include it in the require embedding.
import {
    HTMLManager
} from './index';

// Load json schema validator
var Ajv = require('ajv');
var widget_state_schema = require('@jupyter-widgets/schema').v2.state;
var widget_view_schema = require('@jupyter-widgets/schema').v2.view;

let ajv = new Ajv()
let model_validate = ajv.compile(widget_state_schema);
let view_validate = ajv.compile(widget_view_schema);

/**
 * Render the inline widgets inside a DOM element.
 *
 * @param managerFactory A function that returns a new HTMLManager
 * @param element (default document.documentElement) The document element in which to process for widget state.
 */
export
function renderWidgets(managerFactory: () => HTMLManager, element: HTMLElement = document.documentElement) {
    let tags = element.querySelectorAll('script[type="application/vnd.jupyter.widget-state+json"]');
    for (let i=0; i!=tags.length; ++i) {
github jupyter-widgets / ipywidgets / packages / html-manager / src / libembed.ts View on Github external
__webpack_public_path__ = (window as any).__jupyter_widgets_assets_path__ || __webpack_public_path__;

import 'font-awesome/css/font-awesome.css';
import '@phosphor/widgets/style/index.css';
import '@jupyter-widgets/controls/css/widgets.css';

// Used just for the typing. We must not import the javascript because we don't
// want to include it in the require embedding.
import {
    HTMLManager
} from './index';

// Load json schema validator
var Ajv = require('ajv');
var widget_state_schema = require('@jupyter-widgets/schema').v2.state;
var widget_view_schema = require('@jupyter-widgets/schema').v2.view;

let ajv = new Ajv()
let model_validate = ajv.compile(widget_state_schema);
let view_validate = ajv.compile(widget_view_schema);

/**
 * Render the inline widgets inside a DOM element.
 *
 * @param managerFactory A function that returns a new HTMLManager
 * @param element (default document.documentElement) The document element in which to process for widget state.
 */
export
function renderWidgets(managerFactory: () => HTMLManager, element: HTMLElement = document.documentElement) {
    let tags = element.querySelectorAll('script[type="application/vnd.jupyter.widget-state+json"]');
    for (let i=0; i!=tags.length; ++i) {
        renderManager(element, JSON.parse(tags[i].innerHTML), managerFactory);

@jupyter-widgets/schema

Schemas for the Jupyter interactive Widgets

BSD-3-Clause
Latest version published 3 months ago

Package Health Score

87 / 100
Full package analysis

Popular @jupyter-widgets/schema functions