// components/form/form.ts
Component({
  properties: {
    _loading: { type: Boolean, value: false },
    delay: { type: Number, value: 0 }
  },
  data: {
    _model: {}
  },
  methods: {
    onChange(event) {
      const model = { ...this.data._model, ...event.detail };
      this.setData({ _model: model });
    },
    onSubmit(event) {
      setTimeout(() => {
        if (this.data._loading) return;
        this.triggerEvent('submit', { target: event.target, value: this.data._model }, { bubbles: true, composed: true });
      }, this.data.delay);
    },
  }
})