Files
StarPilot/openpilot/starpilot/galaxy/web/js/dialog.js
T
firestar5683 00364fd645 Galaxy Access
Separate Galaxy authentication and local access policy from web presentation.

Co-authored-by: Danny <dannyirwin31@yahoo.com>
Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu>
Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com>
Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com>
2026-10-14 19:56:17 -05:00

19 lines
960 B
JavaScript

// Native modal behavior provides focus trapping, Escape, and focus restoration.
export const GxDialog = {
inheritAttrs: false,
props: { labelledby: { type: String, required: true }, describedby: String, alert: Boolean },
emits: ["close"],
mounted() { this.$refs.dialog.showModal() },
beforeUnmount() { this.$refs.dialog.close() },
methods: {
backdrop(event) {
if (event.target !== this.$refs.dialog) return
const rect = event.target.getBoundingClientRect()
if (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom) this.$emit("close")
},
},
template: `<Teleport to="body"><dialog ref="dialog" v-bind="$attrs" class="gx-card gx-settings__dialog gx-dialog"
:role="alert ? 'alertdialog' : 'dialog'" :aria-labelledby="labelledby" :aria-describedby="describedby"
@cancel.prevent="$emit('close')" @click="backdrop"><slot></slot></dialog></Teleport>`,
}