/*
 * SonarQube
 * Copyright (C) 2009-2019 SonarSource SA
 * mailto:info AT sonarsource DOT com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
import * as React from 'react';
import * as classNames from 'classnames';
import DeferredSpinner from '../common/DeferredSpinner';

interface Props {
  checked: boolean;
  disabled?: boolean;
  children?: React.ReactNode;
  className?: string;
  id?: string;
  loading?: boolean;
  onCheck: (checked: boolean, id?: string) => void;
  right?: boolean;
  thirdState?: boolean;
  title?: string;
}

export default class Checkbox extends React.PureComponent<Props> {
  static defaultProps = {
    thirdState: false
  };

  handleClick = (event: React.SyntheticEvent<HTMLElement>) => {
    event.preventDefault();
    event.currentTarget.blur();
    if (!this.props.disabled) {
      this.props.onCheck(!this.props.checked, this.props.id);
    }
  };

  render() {
    const { checked, children, disabled, id, loading, right, thirdState, title } = this.props;
    const className = classNames('icon-checkbox', {
      'icon-checkbox-checked': checked,
      'icon-checkbox-single': thirdState,
      'icon-checkbox-disabled': disabled
    });

    if (children) {
      return (
        <a
          aria-checked={checked}
          className={classNames('link-checkbox', this.props.className, {
            note: disabled,
            disabled
          })}
          href="#"
          id={id}
          onClick={this.handleClick}
          role="checkbox"
          title={title}>
          {right && children}
          <DeferredSpinner loading={Boolean(loading)}>
            <i className={className} />
          </DeferredSpinner>
          {!right && children}
        </a>
      );
    }

    if (loading) {
      return <DeferredSpinner />;
    }

    return (
      <a
        aria-checked={checked}
        className={classNames(className, this.props.className)}
        href="#"
        id={id}
        onClick={this.handleClick}
        role="checkbox"
        title={title}
      />
    );
  }
}
-webapp-9.4.44.v20210927'>dependabot/maven/org.eclipse.jetty-jetty-webapp-9.4.44.v20210927</option>
<option value='dependabot/maven/org.eclipse.jgit-org.eclipse.jgit-3.5.3.201412180710-r'>dependabot/maven/org.eclipse.jgit-org.eclipse.jgit-3.5.3.201412180710-r</option>
<option value='dependabot/maven/org.hsqldb-hsqldb-2.7.1'>dependabot/maven/org.hsqldb-hsqldb-2.7.1</option>
<option value='documentation'>documentation</option>
<option value='documentation-7.6'>documentation-7.6</option>
<option value='downgrade-snapshot-version-20241105'>downgrade-snapshot-version-20241105</option>
<option value='exclude-element-screenshot'>exclude-element-screenshot</option>
<option value='feature/atmosphere-pure-javascript'>feature/atmosphere-pure-javascript</option>
<option value='feature/bootstrap-annotation'>feature/bootstrap-annotation</option>
<option value='feature/combobox-communication'>feature/combobox-communication</option>
<option value='feature/dalvik'>feature/dalvik</option>
<option value='feature/databinding'>feature/databinding</option>
<option value='feature/dnd'>feature/dnd</option>
<option value='feature/elements'>feature/elements</option>
<option value='feature/eventbus'>feature/eventbus</option>
<option value='feature/karaf-feature-file'>feature/karaf-feature-file</option>
<option value='feature/nullrepresentation'>feature/nullrepresentation</option>
<option value='feature/standard-gwt'>feature/standard-gwt</option>
<option value='feature/standard-sass'>feature/standard-sass</option>
<option value='feature/vaadin8'>feature/vaadin8</option>
<option value='feature/vaadin8-book'>feature/vaadin8-book</option>
<option value='feature/vaadin8-book-vol2'>feature/vaadin8-book-vol2</option>
<option value='feature/vaadin8-sass-valo-only'>feature/vaadin8-sass-valo-only</option>
<option value='fix11576'>fix11576</option>
<option value='fix_event_router_prototype'>fix_event_router_prototype</option>
<option value='grid'>grid</option>
<option value='grid_dnd_autoscroller'>grid_dnd_autoscroller</option>
<option value='grid_dragger'>grid_dragger</option>
<option value='issue/8307_select_using_collection'>issue/8307_select_using_collection</option>
<option value='master'>master</option>
<option value='mobile_drag_image_offset'>mobile_drag_image_offset</option>
<option value='pr/11306'>pr/11306</option>
<option value='remote-run/flow-atmosphere-test'>remote-run/flow-atmosphere-test</option>
<option value='snapshot/7.5'>snapshot/7.5</option>
<option value='snapshot/7.6'>snapshot/7.6</option>
<option value='tmattsso-patch-1'>tmattsso-patch-1</option>
<option value='update-minor-deps'>update-minor-deps</option>
<option value='vaadin-icons-3.0.1'>vaadin-icons-3.0.1</option>
<option value='wip-date-time-datatype'>wip-date-time-datatype</option>
<option value='wip-java-10-compat'>wip-java-10-compat</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>Vaadin 6, 7, 8 is a Java framework for modern Java web applications: https://github.com/vaadin/framework</td><td class='sub right'>www-data</td></tr></table>
<table class='tabs'><tr><td>
<a href='/vaadin-framework.git/?h=7.1.9'>summary</a><a href='/vaadin-framework.git/refs/?h=7.1.9&amp;id=befa3fe32effffc2ef616aca63761c321d8144c5'>refs</a><a href='/vaadin-framework.git/log/theme-compiler/tests/resources/sasslang/scss/193-update_stylesheet.scss?h=7.1.9'>log</a><a class='active' href='/vaadin-framework.git/tree/theme-compiler/tests/resources/sasslang/scss/193-update_stylesheet.scss?h=7.1.9&amp;id=befa3fe32effffc2ef616aca63761c321d8144c5'>tree</a><a href='/vaadin-framework.git/commit/theme-compiler/tests/resources/sasslang/scss/193-update_stylesheet.scss?h=7.1.9&amp;id=befa3fe32effffc2ef616aca63761c321d8144c5'>commit</a><a href='/vaadin-framework.git/diff/theme-compiler/tests/resources/sasslang/scss/193-update_stylesheet.scss?h=7.1.9&amp;id=befa3fe32effffc2ef616aca63761c321d8144c5'>diff</a><a href='/vaadin-framework.git/stats/theme-compiler/tests/resources/sasslang/scss/193-update_stylesheet.scss?h=7.1.9'>stats</a></td><td class='form'><form class='right' method='get' action='/vaadin-framework.git/log/theme-compiler/tests/resources/sasslang/scss/193-update_stylesheet.scss'>
<input type='hidden' name='h' value='7.1.9'/><input type='hidden' name='id' value='befa3fe32effffc2ef616aca63761c321d8144c5'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/vaadin-framework.git/tree/?h=7.1.9&amp;id=befa3fe32effffc2ef616aca63761c321d8144c5'>root</a>/<a href='/vaadin-framework.git/tree/theme-compiler?h=7.1.9&amp;id=befa3fe32effffc2ef616aca63761c321d8144c5'>theme-compiler</a>/<a href='/vaadin-framework.git/tree/theme-compiler/tests?h=7.1.9&amp;id=befa3fe32effffc2ef616aca63761c321d8144c5'>tests</a>/<a href='/vaadin-framework.git/tree/theme-compiler/tests/resources?h=7.1.9&amp;id=befa3fe32effffc2ef616aca63761c321d8144c5'>resources</a>/<a href='/vaadin-framework.git/tree/theme-compiler/tests/resources/sasslang?h=7.1.9&amp;id=befa3fe32effffc2ef616aca63761c321d8144c5'>sasslang</a>/<a href='/vaadin-framework.git/tree/theme-compiler/tests/resources/sasslang/scss?h=7.1.9&amp;id=befa3fe32effffc2ef616aca63761c321d8144c5'>scss</a>/<a href='/vaadin-framework.git/tree/theme-compiler/tests/resources/sasslang/scss/193-update_stylesheet.scss?h=7.1.9&amp;id=befa3fe32effffc2ef616aca63761c321d8144c5'>193-update_stylesheet.scss</a></div><div class='content'>blob: e43d50813ba56adf456f90d1cc34d8f2eab15e41 (<a href='/vaadin-framework.git/plain/theme-compiler/tests/resources/sasslang/scss/193-update_stylesheet.scss?h=7.1.9&amp;id=befa3fe32effffc2ef616aca63761c321d8144c5'>plain</a>)
<table summary='blob content' class='blob'>
<tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a>
<a id='n2' href='#n2'>2</a>
<a id='n3' href='#n3'>3</a>
<a id='n4' href='#n4'>4</a>
<a id='n5' href='#n5'>5</a>
<a id='n6' href='#n6'>6</a>
<a id='n7' href='#n7'>7</a>
<a id='n8' href='#n8'>8</a>
<a id='n9' href='#n9'>9</a>
<a id='n10' href='#n10'>10</a>
<a id='n11' href='#n11'>11</a>
<a id='n12' href='#n12'>12</a>
<a id='n13' href='#n13'>13</a>
<a id='n14' href='#n14'>14</a>
<a id='n15' href='#n15'>15</a>
<a id='n16' href='#n16'>16</a>
<a id='n17' href='#n17'>17</a>
<a id='n18' href='#n18'>18</a>
</pre></td>
<td class='lines'><pre><code>