How to use @dojo/framework - 10 common examples

To help you get started, we’ve selected a few @dojo/framework 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 dojo / widgets / src / slide-pane / index.tsx View on Github external
protected render(): DNode {
		let { aria = {}, closeText, open = false, title = '', theme, classes } = this.properties;

		const contentStyles = this.getStyles();
		const contentClasses = this.getModifierClasses();
		const fixedContentClasses = this.getFixedModifierClasses();

		if (!closeText) {
			const { messages } = this.localizeBundle(commonBundle);
			closeText = `${messages.close} ${title}`;
		}

		// This is a side-effect of rendering, it clears the slide styles for the next render.
		this._slide = undefined;

		return v(
			'div',
			{
				'aria-labelledby': this._titleId,
				classes: this.theme(css.root),
				onmousedown: this._onSwipeStart,
				onmousemove: this._onSwipeMove,
				onmouseup: this._onSwipeEnd,
				ontouchend: this._onSwipeEnd,
				ontouchmove: this._onSwipeMove,
				ontouchstart: this._onSwipeStart
			},
			[
				open ? this.renderUnderlay() : null,
				v(
					'div',
					{
github dojo / widgets / src / slider / index.tsx View on Github external
showOutput?: boolean;
	/** Size of the slider increment */
	step?: number;
	/** If the value provided by the slider are valid */
	valid?: boolean;
	/** The current value */
	value?: number;
	/** Orients the slider vertically, false by default. */
	vertical?: boolean;
	/** Length of the vertical slider (only used if vertical is true) */
	verticalHeight?: string;
	/** The id used for the form input element */
	widgetId?: string;
}

@theme(css)
export class Slider extends ThemedMixin(FocusMixin(WidgetBase)) {
	// id used to associate input with output
	private _widgetId = uuid();

	private _onInput(event: Event) {
		event.stopPropagation();
		const value = (event.target as HTMLInputElement).value;

		this.properties.onValue && this.properties.onValue(parseFloat(value));
	}

	protected getRootClasses(): (string | null)[] {
		const { disabled, valid, readOnly, vertical = false } = this.properties;
		const focus = this.meta(Focus).get('root');

		return [
github dojo / widgets / src / combobox / index.tsx View on Github external
results?: any[];
	/** Determines if this input is valid */
	valid?: { valid?: boolean; message?: string } | boolean;
	/** Value to set on the input */
	value?: string;
	/** Optional id string for the combobox, set on the text input */
	widgetId?: string;
}

// Enum used when traversing items using arrow keys
export enum Operation {
	increase = 1,
	decrease = -1
}

@theme(css)
@diffProperty('results', reference)
export class ComboBox extends I18nMixin(ThemedMixin(FocusMixin(WidgetBase))) {
	private _activeIndex = 0;
	private _ignoreBlur: boolean | undefined;
	private _idBase = uuid();
	private _menuHasVisualFocus = false;
	private _open: boolean | undefined;
	private _wasOpen: boolean | undefined;

	private _closeMenu() {
		this._open = false;
		this.invalidate();
	}

	private _getMenuId() {
		return `${this._idBase}-menu`;
github dojo / widgets / src / slider / index.tsx View on Github external
/** Size of the slider increment */
	step?: number;
	/** If the value provided by the slider are valid */
	valid?: boolean;
	/** The current value */
	value?: number;
	/** Orients the slider vertically, false by default. */
	vertical?: boolean;
	/** Length of the vertical slider (only used if vertical is true) */
	verticalHeight?: string;
	/** The id used for the form input element */
	widgetId?: string;
}

@theme(css)
export class Slider extends ThemedMixin(FocusMixin(WidgetBase)) {
	// id used to associate input with output
	private _widgetId = uuid();

	private _onInput(event: Event) {
		event.stopPropagation();
		const value = (event.target as HTMLInputElement).value;

		this.properties.onValue && this.properties.onValue(parseFloat(value));
	}

	protected getRootClasses(): (string | null)[] {
		const { disabled, valid, readOnly, vertical = false } = this.properties;
		const focus = this.meta(Focus).get('root');

		return [
			css.root,
github dojo / widgets / src / combobox / index.tsx View on Github external
/** Determines if this input is valid */
	valid?: { valid?: boolean; message?: string } | boolean;
	/** Value to set on the input */
	value?: string;
	/** Optional id string for the combobox, set on the text input */
	widgetId?: string;
}

// Enum used when traversing items using arrow keys
export enum Operation {
	increase = 1,
	decrease = -1
}

@theme(css)
@diffProperty('results', reference)
export class ComboBox extends I18nMixin(ThemedMixin(FocusMixin(WidgetBase))) {
	private _activeIndex = 0;
	private _ignoreBlur: boolean | undefined;
	private _idBase = uuid();
	private _menuHasVisualFocus = false;
	private _open: boolean | undefined;
	private _wasOpen: boolean | undefined;

	private _closeMenu() {
		this._open = false;
		this.invalidate();
	}

	private _getMenuId() {
		return `${this._idBase}-menu`;
	}
github dojo / widgets / src / combobox / index.tsx View on Github external
valid?: { valid?: boolean; message?: string } | boolean;
	/** Value to set on the input */
	value?: string;
	/** Optional id string for the combobox, set on the text input */
	widgetId?: string;
}

// Enum used when traversing items using arrow keys
export enum Operation {
	increase = 1,
	decrease = -1
}

@theme(css)
@diffProperty('results', reference)
export class ComboBox extends I18nMixin(ThemedMixin(FocusMixin(WidgetBase))) {
	private _activeIndex = 0;
	private _ignoreBlur: boolean | undefined;
	private _idBase = uuid();
	private _menuHasVisualFocus = false;
	private _open: boolean | undefined;
	private _wasOpen: boolean | undefined;

	private _closeMenu() {
		this._open = false;
		this.invalidate();
	}

	private _getMenuId() {
		return `${this._idBase}-menu`;
	}
github dojo / cli-build-app / test-app / src / main.ts View on Github external
div.setAttribute('has-ci', 'ci');
}

div.textContent = `Built with Build Time Render: ${!!div.getAttribute('hasBtr')}
Currently Rendered by BTR: ${has('build-time-render')}`;

div.classList.add(...css.root.split(' '));
if (div.parentNode === null) {
	root!.appendChild(div);
}

const appRoot = document.getElementById('app-root')!;
console.log(appRoot);

const registry = new Registry();
const router = registerRouterInjector(routes, registry);

if (!btr) {
	router.setPath('/foo/bar');
}

const r = renderer(() => w(LazyApp, {}));
r.mount({ domNode: appRoot, registry });
github dojo / cli-build-app / test-app / src / main.ts View on Github external
import App from './App';
import * as css from './app.m.css';
import './Bar';
import LazyApp from './LazyApp';
import routes from './routes';
import test from './test.block';

'!has("bar")';

if (has('foo')) {
	console.log('foo');
}

const root = document.getElementById('app');

const btr = has('build-time-render');

App().then((result) => {
	console.log(result());
	console.log(require('foo/bar'));
});
let div = document.getElementById('div');
if (!div) {
	div = document.createElement('div');
	div.id = 'div';
}
if (btr) {
	test('./src/foo.txt').then((result: string) => {
		const nodeBtr = document.createElement('div');
		nodeBtr.id = 'nodeBtr';
		nodeBtr.innerHTML = result;
		root!.appendChild(nodeBtr);
github dojo / cli-build-app / test-app / src / main.ts View on Github external
}

if (has('dojo-debug')) {
	div.setAttribute('dojo-debug', 'true');
}

if (has('env') === 'prod') {
	div.setAttribute('has-prod', 'prod');
}

if (has('env') === 'ci') {
	div.setAttribute('has-ci', 'ci');
}

div.textContent = `Built with Build Time Render: ${!!div.getAttribute('hasBtr')}
Currently Rendered by BTR: ${has('build-time-render')}`;

div.classList.add(...css.root.split(' '));
if (div.parentNode === null) {
	root!.appendChild(div);
}

const appRoot = document.getElementById('app-root')!;
console.log(appRoot);

const registry = new Registry();
const router = registerRouterInjector(routes, registry);

if (!btr) {
	router.setPath('/foo/bar');
}
github webcomponents / custom-elements-everywhere / libraries / dojo / src / advanced-tests.ts View on Github external
it("can declaratively listen to a CAPScase DOM event dispatched by a Custom Element", function() {
      this.weight = 1;
      const r = renderer(() => w(ComponentWithDeclarativeEvent, {}));
      r.mount({ domNode: scratch, sync: true });
      const wc: any = document.querySelector("ce-with-event");
      let handledResult: any = document.querySelector("#caps");
      expect(handledResult.handled).to.be.false;
      wc.click();
      expect(handledResult.handled).to.be.true;
    });