1// Copyright (c) Jupyter Development Team. 2// Distributed under the terms of the Modified BSD License. 3'use strict'; 4 5import { 6 Widget 7} from '@lumino/widgets'; 8 9 10// Merge classes: 11export const UNCHANGED_MERGE_CLASS = 'jp-Merge-unchanged'; 12export const ONEWAY_LOCAL_CLASS = 'jp-Merge-oneway-local'; 13export const ONEWAY_REMOTE_CLASS = 'jp-Merge-oneway-remote'; 14export const TWOWAY_ADDITION_CLASS = 'jp-Merge-twoway-addition'; 15export const TWOWAY_DELETION_CLASS = 'jp-Merge-twoway-deletion'; 16 17const BASE_MERGE_CLASS = 'jp-Merge-base'; 18const LOCAL_MERGE_CLASS = 'jp-Merge-local'; 19const REMOTE_MERGE_CLASS = 'jp-Merge-remote'; 20const MERGED_MERGE_CLASS = 'jp-Merge-merged'; 21 22export const MERGE_CLASSES = [BASE_MERGE_CLASS, LOCAL_MERGE_CLASS, 23 REMOTE_MERGE_CLASS, MERGED_MERGE_CLASS]; 24 25 26/** 27 * Create a widget containing a checkbox with a label. 28 * 29 * @export 30 * @param {boolean} value - The initial check state (true = checked) 31 * @param {string} text - The text of the label 32 * @returns {{checkbox: HTMLInputElement, widget: Widget }} 33 */ 34export 35function createCheckbox(value: boolean, text: string, indeterminate=false): {checkbox: HTMLInputElement, widget: Widget } { 36 let checkbox = document.createElement('input'); 37 checkbox.setAttribute('type', 'checkbox'); 38 checkbox.checked = value; 39 checkbox.indeterminate = indeterminate; 40 // Create label for checkbox: 41 let widget = new Widget(); 42 let label = document.createElement('label'); 43 label.innerHTML = text; 44 // Combine checkbox and label: 45 label.insertBefore(checkbox, label.childNodes[0]); 46 // Add checkbox to header: 47 widget.node.appendChild(label); 48 return {checkbox, widget}; 49} 50