diff --git a/resources/assets/src/scripts/modal.ts b/resources/assets/src/scripts/modal.ts new file mode 100644 index 00000000..ed36cb4f --- /dev/null +++ b/resources/assets/src/scripts/modal.ts @@ -0,0 +1,45 @@ +import $ from 'jquery' +import Vue from 'vue' +import Modal from '../components/Modal.vue' + +export interface ModalOptions { + mode?: 'alert' | 'confirm' | 'prompt' + title?: string + text?: string + dangerousHTML?: string + input?: string + placeholder?: string + inputType?: string + validator?(value: any): string | boolean | void + type?: string + showHeader?: boolean + center?: boolean + okButtonText?: string + okButtonType?: string + cancelButtonText?: string + cancelButtonType?: string + flexFooter?: boolean +} + +export interface ModalResult { + value: string +} + +export function showModal(options: ModalOptions = {}): Promise { + return new Promise((resolve, reject) => { + const container = document.createElement('div') + document.body.appendChild(container) + + const instance = new Vue({ + render: h => h(Modal, { + props: Object.assign({ center: true }, options), + on: { + confirm: resolve, + dismiss: reject, + }, + }), + }).$mount(container) + + $(instance.$el).modal('show') + }) +} diff --git a/resources/assets/src/scripts/notify.ts b/resources/assets/src/scripts/notify.ts index d0d429c1..eeadc3a7 100644 --- a/resources/assets/src/scripts/notify.ts +++ b/resources/assets/src/scripts/notify.ts @@ -1,47 +1,5 @@ -import $ from 'jquery' -import Vue from 'vue' -import Modal from '../components/Modal.vue' - -export interface ModalOptions { - mode?: 'alert' | 'confirm' | 'prompt' - title?: string - text?: string - dangerousHTML?: string - input?: string - placeholder?: string - inputType?: string - validator?(value: any): string | boolean | void - type?: string - showHeader?: boolean - center?: boolean - okButtonText?: string - okButtonType?: string - cancelButtonText?: string - cancelButtonType?: string - flexFooter?: boolean -} - -export interface ModalResult { - value: string -} - -export function showModal(options: ModalOptions = {}): Promise { - return new Promise((resolve, reject) => { - const container = document.createElement('div') - document.body.appendChild(container) - - const instance = new Vue({ - render: h => h(Modal, { - props: Object.assign({ center: true }, options), - on: { - confirm: resolve, - dismiss: reject, - }, - }), - }).$mount(container) - - $(instance.$el).modal('show') - }) -} +import { showModal } from './modal' Object.assign(blessing, { notify: { showModal } }) + +export * from './modal'