diff --git a/src/mixins/bind-event.ts b/src/mixins/bind-event.ts deleted file mode 100644 index d727ac160..000000000 --- a/src/mixins/bind-event.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Bind event when mounted or activated - */ -import { on, off } from '../utils/dom/event'; - -type BindEventMixinThis = { - binded: boolean; -}; - -type BindEventHandler = (bind: typeof on | typeof off, isBind: boolean) => void; - -export function BindEventMixin(handler: BindEventHandler) { - function bind(this: BindEventMixinThis) { - if (!this.binded) { - handler.call(this, on, true); - this.binded = true; - } - } - - function unbind(this: BindEventMixinThis) { - if (this.binded) { - handler.call(this, off, false); - this.binded = false; - } - } - - return { - mounted: bind, - activated: bind, - deactivated: unbind, - beforeUnmount: unbind, - }; -} diff --git a/src/mixins/field.js b/src/mixins/field.js deleted file mode 100644 index 0933adbf7..000000000 --- a/src/mixins/field.js +++ /dev/null @@ -1,29 +0,0 @@ -import { FIELD_KEY } from '../field'; - -export const FieldMixin = { - inject: { - vanField: { - from: FIELD_KEY, - default: null, - }, - }, - - watch: { - modelValue() { - const field = this.vanField; - - if (field) { - field.resetValidation(); - field.validateWithTrigger('onChange'); - } - }, - }, - - created() { - const field = this.vanField; - - if (field && !field.childFieldValue.value) { - field.childFieldValue.value = () => this.modelValue; - } - }, -}; diff --git a/src/mixins/relation.js b/src/mixins/relation.js deleted file mode 100644 index c0bae840c..000000000 --- a/src/mixins/relation.js +++ /dev/null @@ -1,67 +0,0 @@ -export function ChildrenMixin(parent, options = {}) { - const indexKey = options.indexKey || 'index'; - - return { - inject: { - // TODO: disableBindRelation - parent: { - from: parent, - default: null, - }, - }, - - computed: { - [indexKey]() { - this.bindRelation(); - - if (this.parent) { - return this.parent.children.indexOf(this); - } - - return null; - }, - }, - - mounted() { - this.bindRelation(); - }, - - beforeUnmount() { - if (this.parent) { - this.parent.children = this.parent.children.filter( - (item) => item !== this - ); - } - }, - - methods: { - bindRelation() { - if (!this.parent || this.parent.children.indexOf(this) !== -1) { - return; - } - - const children = [...this.parent.children, this]; - - // TODO sortChildren - - this.parent.children = children; - }, - }, - }; -} - -export function ParentMixin(parent) { - return { - provide() { - return { - [parent]: this, - }; - }, - - data() { - return { - children: [], - }; - }, - }; -}