@opencitylabs/formio-custom-components 0.7.4 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -7927,12 +7927,19 @@ function fr(e) {
7927
7927
  static schema(...t) {
7928
7928
  return e.schema({ resetValueOn: [] }, ...t);
7929
7929
  }
7930
- checkRefreshOn(e, t = {}) {
7931
- super.checkRefreshOn(e, t);
7932
- let { resetValueOn: n } = this.component;
7933
- if (!n || !e?.length || this.root?.pristine !== !1) return;
7930
+ attach(e) {
7931
+ let t = super.attach(e), n = this.component?.resetValueOn;
7932
+ if (!n || !this.root) return t;
7933
+ this._resetValueOnHandler && this.root.off("change", this._resetValueOnHandler);
7934
7934
  let r = Array.isArray(n) ? n : [n];
7935
- r.length && e.some((e) => r.some((t) => t === "data" ? !0 : e.instance?.path === t || e.path === t)) && this.setValue(this.emptyValue);
7935
+ return r.length ? (this._resetValueOnHandler = (e, t) => {
7936
+ if (this.root?.pristine !== !1) return;
7937
+ let n = t?.changes || (t?.changed ? [t.changed] : []);
7938
+ n.length && n.some((e) => r.some((t) => t === "data" ? !0 : e.instance?.path === t || e.path === t)) && this.setValue(this.emptyValue);
7939
+ }, this.root.on("change", this._resetValueOnHandler), t) : t;
7940
+ }
7941
+ detach() {
7942
+ return this._resetValueOnHandler && this.root && (this.root.off("change", this._resetValueOnHandler), this._resetValueOnHandler = null), super.detach();
7936
7943
  }
7937
7944
  };
7938
7945
  }