Sha256: 3923777e533acac5b1a350bd594df76223dc0793153f23c12f6e3d760a975b61

Contents?: true

Size: 815 Bytes

Versions: 6

Compression:

Stored size: 815 Bytes

Contents

import {controllerFactory} from '@utils/createController'
import {disableBodyScroll, enableBodyScroll} from 'body-scroll-lock'

export default class DialogController extends controllerFactory()({
  targets: {dialog: HTMLDialogElement},
}) {
  close() {
    this.dialogTarget.close()
    // reset any child forms
    // for (const form of this.dialogTarget.querySelectorAll('form') ?? []) {
    //   form.reset()
    // }
    enableBodyScroll(this.dialogTarget)
  }
  disconnect() {
    this.close()
  }
  open() {
    this.dialogTarget.showModal()
    disableBodyScroll(this.dialogTarget, {reserveScrollBarGap: true})
  }
  triggerClick() {
    if (this.dialogTarget.open) this.close()
    else this.open()
  }
  windowClick(e: MouseEvent) {
    if (e.target === this.dialogTarget) {
      this.close()
    }
  }
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.79.2 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.79.1 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.79 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.78 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.77 app/components/ariadne/ui/dialog/component.ts
ariadne_view_components-0.0.76.1 app/components/ariadne/ui/dialog/component.ts