@nsnanocat/preference-panes 0.8.1 → 0.9.0

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.
@@ -9,6 +9,6 @@
9
9
  </head>
10
10
  <body>
11
11
  <main id="preferences"></main>
12
- <script type="module" src="/settings/assets/app.mjs?v=0.8.1"></script>
12
+ <script type="module" src="/settings/assets/app.mjs?v=0.9.0"></script>
13
13
  </body>
14
14
  </html>
@@ -146,6 +146,10 @@ class ModuleFrame extends EventTarget {
146
146
  this.#state = { ...event.detail, actions: event.detail.actions ?? [] };
147
147
  this.dispatchEvent(new Event("change"));
148
148
  };
149
+ #confirmation = event => {
150
+ const request = new CustomEvent("confirm", { cancelable: true, detail: event.detail });
151
+ if (!this.dispatchEvent(request)) event.preventDefault();
152
+ };
149
153
 
150
154
  /**
151
155
  * 建立 iframe 与请求输入;调用方挂载 element 后调用 load。
@@ -162,6 +166,7 @@ class ModuleFrame extends EventTarget {
162
166
  this.element.title = `${inputs.module} 设置`;
163
167
  this.element.dataset.preferencePanes = JSON.stringify(inputs);
164
168
  this.element.addEventListener("preferencepanes:change", this.#change);
169
+ this.element.addEventListener("preferencepanes:confirm", this.#confirmation);
165
170
  this.#state = { title: inputs.module, module: inputs.module, busy: false, canGoBack: true, actions: [] };
166
171
  options.signal?.addEventListener("abort", this.#abort, { once: true });
167
172
  }
@@ -222,6 +227,7 @@ class ModuleFrame extends EventTarget {
222
227
  this.#controller.abort();
223
228
  this.#options.signal?.removeEventListener("abort", this.#abort);
224
229
  this.element.removeEventListener("preferencepanes:change", this.#change);
230
+ this.element.removeEventListener("preferencepanes:confirm", this.#confirmation);
225
231
  }
226
232
  }
227
233