Sha256: 6f3a07b54cca472206b7a93b709efb28b6e0640b35f4f4be502406fa7d3db433

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

import {controller, target} from '@github/catalyst'

const SUBMIT_BUTTON_SELECTOR = 'input[type=submit],button[type=submit],button[data-submit-dialog-id]'

@controller
class DangerConfirmationDialogFormHelperElement extends HTMLElement {
  @target checkbox: HTMLInputElement

  get submitButton() {
    return this.querySelector<HTMLInputElement | HTMLButtonElement>(SUBMIT_BUTTON_SELECTOR)!
  }

  connectedCallback() {
    this.#reset()
  }

  toggle(): void {
    this.submitButton.disabled = !this.checkbox.checked
  }

  #reset(): void {
    this.checkbox.checked = false
    this.toggle()
  }
}

declare global {
  interface Window {
    DangerConfirmationDialogFormHelperElement: typeof DangerConfirmationDialogFormHelperElement
  }
}

if (!window.customElements.get('danger-confirmation-dialog-form-helper')) {
  window.DangerConfirmationDialogFormHelperElement = DangerConfirmationDialogFormHelperElement
  window.customElements.define('danger-confirmation-dialog-form-helper', DangerConfirmationDialogFormHelperElement)
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
openproject-primer_view_components-0.52.2 app/components/primer/open_project/danger_confirmation_dialog_form_helper.ts
openproject-primer_view_components-0.52.1 app/components/primer/open_project/danger_confirmation_dialog_form_helper.ts
openproject-primer_view_components-0.52.0 app/components/primer/open_project/danger_confirmation_dialog_form_helper.ts
openproject-primer_view_components-0.51.0 app/components/primer/open_project/danger_confirmation_dialog_form_helper.ts