<commit_before>import Vue from 'vue'

import { isSSR } from '../plugins/platform.js'

const ssrAPI = { onOk () {}, okCancel () {}, hide () {} }

export default function (Component) {
  return ({ className, style, ...props }) => {
    if (isSSR) { return ssrAPI }

    const
      okFns = [],
      cancelFns = [],
      API = {
        onOk (fn) {
          okFns.push(fn)
          return API
        },
        onCancel (fn) {
          cancelFns.push(fn)
          return API
        },
        hide () {
          vm.$refs.dialog.hide()
          cancel()
          return API
        }
      }

    const node = document.createElement('div')
    document.body.appendChild(node)

    const
      ok = data => {
        okFns.forEach(fn => { fn(data) })
      },
      cancel = () => {
        cancelFns.forEach(fn => { fn() })
      }

    let vm = new Vue({
      el: node,

      data () {
        return { props }
      },

      render: h => h(Component, {
        ref: 'dialog',
        props,
        style,
        'class': className,
        on: {
          ok,
          cancel,
          hide: () => {
            vm.$destroy()
            vm = null
          }<commit_msg>fix: global-dialog util > remove el from DOM on hiding<commit_after>import Vue from 'vue'

import { isSSR } from '../plugins/platform.js'

const ssrAPI = { onOk () {}, okCancel () {}, hide () {} }

export default function (Component) {
  return ({ className, style, ...props }) => {
    if (isSSR) { return ssrAPI }

    const
      okFns = [],
      cancelFns = [],
      API = {
        onOk (fn) {
          okFns.push(fn)
          return API
        },
        onCancel (fn) {
          cancelFns.push(fn)
          return API
        },
        hide () {
          vm.$refs.dialog.hide()
          cancel()
          return API
        }
      }

    const node = document.createElement('div')
    document.body.appendChild(node)

    const
      ok = data => {
        okFns.forEach(fn => { fn(data) })
      },
      cancel = () => {
        cancelFns.forEach(fn => { fn() })
      }

    let vm = new Vue({
      el: node,

      data () {
        return { props }
      },

      render: h => h(Component, {
        ref: 'dialog',
        props,
        style,
        'class': className,
        on: {
          ok,
          cancel,
          hide: () => {
            vm.$destroy()
            vm.$el.remove()
            vm = null
          }
{'fraction_non_alphanumeric': 0.14572247237003683, 'fraction_numerical': 0.0, 'mean_word_length': 1.3187855787476281, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7430783', 'n_tokens_mistral': 751, 'n_tokens_neox': 735, 'n_words': 171}