diff --git a/src/index.ts b/src/index.ts index 425c8e9b..21cf9d37 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,6 +54,7 @@ import { Directives } from './types/directives' import { modules, Modules } from './store' import { setTheme } from './utils' import { Loading, Message, MessageBox, Notification } from './plugins/elementUI' +import { SDialogMixin } from './mixins' const components = [ { component: SApp, name: Components.SApp }, @@ -177,6 +178,7 @@ export { STabs, STable, STableColumn, - STooltip + STooltip, + SDialogMixin } export default SoramitsuElements diff --git a/src/mixins/SDialogMixin.ts b/src/mixins/SDialogMixin.ts new file mode 100644 index 00000000..17782ba5 --- /dev/null +++ b/src/mixins/SDialogMixin.ts @@ -0,0 +1,23 @@ +import { Vue, Component, Prop, Watch } from 'vue-property-decorator' + +@Component +export default class SDialogMixin extends Vue { + /** + * Dialog visibility + * + * `false` by default + */ + @Prop({ type: Boolean, default: false, required: true }) readonly visible!: boolean + + isVisible = this.visible + + @Watch('visible') + public handleVisibleChange (value: boolean): void { + this.isVisible = value + } + + @Watch('isVisible') + public handleIsVisibleChange (value: boolean): void { + this.$emit('update:visible', value) + } +} diff --git a/src/mixins/index.ts b/src/mixins/index.ts new file mode 100644 index 00000000..a6a993ad --- /dev/null +++ b/src/mixins/index.ts @@ -0,0 +1,9 @@ +import SDialogMixin from './SDialogMixin' +import BorderRadiusMixin from './BorderRadiusMixin' +import SizeMixin from './SizeMixin' + +export { + SDialogMixin, + BorderRadiusMixin, + SizeMixin +}