plutonium 0.26.3 → 0.26.6

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.
@@ -13151,31 +13151,40 @@
13151
13151
 
13152
13152
  // src/js/controllers/color_mode_controller.js
13153
13153
  var color_mode_controller_default = class extends Controller {
13154
- // static targets = ["trigger", "menu"]
13154
+ static values = { current: String };
13155
13155
  connect() {
13156
- this.updateColorMode();
13156
+ const mode = localStorage.theme || "light";
13157
+ this.setMode(mode);
13157
13158
  }
13158
- disconnect() {
13159
+ toggleMode() {
13160
+ const current = this.currentValue || "light";
13161
+ const next = current === "light" ? "dark" : "light";
13162
+ this.setMode(next);
13159
13163
  }
13160
- updateColorMode() {
13161
- if (localStorage.theme === "dark" || !("theme" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches) {
13164
+ setMode(mode) {
13165
+ if (mode === "dark") {
13162
13166
  document.documentElement.classList.add("dark");
13167
+ localStorage.theme = "dark";
13163
13168
  } else {
13164
13169
  document.documentElement.classList.remove("dark");
13170
+ localStorage.theme = "light";
13171
+ }
13172
+ this.currentValue = mode;
13173
+ this.toggleIcons(mode);
13174
+ }
13175
+ toggleIcons(mode) {
13176
+ const sun = this.element.querySelector(".color-mode-icon-light");
13177
+ const moon = this.element.querySelector(".color-mode-icon-dark");
13178
+ if (sun && moon) {
13179
+ if (mode === "light") {
13180
+ sun.classList.remove("hidden");
13181
+ moon.classList.add("hidden");
13182
+ } else {
13183
+ sun.classList.add("hidden");
13184
+ moon.classList.remove("hidden");
13185
+ }
13165
13186
  }
13166
13187
  }
13167
- setLightColorMode() {
13168
- localStorage.theme = "light";
13169
- this.updateColorMode();
13170
- }
13171
- setDarkColorMode() {
13172
- localStorage.theme = "dark";
13173
- this.updateColorMode();
13174
- }
13175
- setSystemColorMode() {
13176
- localStorage.removeItem("theme");
13177
- this.updateColorMode();
13178
- }
13179
13188
  };
13180
13189
 
13181
13190
  // node_modules/dompurify/dist/purify.es.mjs
@@ -16290,19 +16299,46 @@ ${text2}</tr>
16290
16299
 
16291
16300
  // src/js/controllers/easymde_controller.js
16292
16301
  var easymde_controller_default = class extends Controller {
16302
+ static targets = ["textarea"];
16293
16303
  connect() {
16304
+ if (this.easyMDE)
16305
+ return;
16306
+ this.originalValue = this.element.value;
16294
16307
  this.easyMDE = new EasyMDE(this.#buildOptions());
16295
- this.element.setAttribute("data-action", "turbo:morph-element->easymde#reconnect");
16308
+ this.element.addEventListener("turbo:before-morph-element", (event) => {
16309
+ if (event.target === this.element && this.easyMDE) {
16310
+ this.storedValue = this.easyMDE.value();
16311
+ }
16312
+ });
16313
+ this.element.addEventListener("turbo:morph-element", (event) => {
16314
+ if (event.target === this.element) {
16315
+ requestAnimationFrame(() => this.#handleMorph());
16316
+ }
16317
+ });
16296
16318
  }
16297
16319
  disconnect() {
16298
16320
  if (this.easyMDE) {
16299
- this.easyMDE.toTextArea();
16321
+ try {
16322
+ if (this.element.isConnected && this.element.parentNode) {
16323
+ this.easyMDE.toTextArea();
16324
+ }
16325
+ } catch (error2) {
16326
+ console.warn("EasyMDE cleanup error:", error2);
16327
+ }
16300
16328
  this.easyMDE = null;
16301
16329
  }
16302
16330
  }
16303
- reconnect() {
16304
- this.disconnect();
16305
- this.connect();
16331
+ #handleMorph() {
16332
+ if (!this.element.isConnected)
16333
+ return;
16334
+ if (this.easyMDE) {
16335
+ this.easyMDE = null;
16336
+ }
16337
+ this.easyMDE = new EasyMDE(this.#buildOptions());
16338
+ if (this.storedValue !== void 0) {
16339
+ this.easyMDE.value(this.storedValue);
16340
+ this.storedValue = void 0;
16341
+ }
16306
16342
  }
16307
16343
  #buildOptions() {
16308
16344
  let options2 = {
@@ -16333,6 +16369,16 @@ ${text2}</tr>
16333
16369
  // src/js/controllers/slim_select_controller.js
16334
16370
  var slim_select_controller_default = class extends Controller {
16335
16371
  connect() {
16372
+ if (this.slimSelect)
16373
+ return;
16374
+ this.#setupSlimSelect();
16375
+ this.element.addEventListener("turbo:morph-element", (event) => {
16376
+ if (event.target === this.element) {
16377
+ requestAnimationFrame(() => this.#handleMorph());
16378
+ }
16379
+ });
16380
+ }
16381
+ #setupSlimSelect() {
16336
16382
  const settings = {};
16337
16383
  const modal = document.querySelector('[data-controller="remote-modal"]');
16338
16384
  if (modal) {
@@ -16362,10 +16408,6 @@ ${text2}</tr>
16362
16408
  this.element.addEventListener("ss:open", this.boundHandleDropdownOpen);
16363
16409
  this.element.addEventListener("ss:close", this.boundHandleDropdownClose);
16364
16410
  this.setupAriaObserver();
16365
- this.element.setAttribute(
16366
- "data-action",
16367
- "turbo:morph-element->slim-select#reconnect"
16368
- );
16369
16411
  }
16370
16412
  handleDropdownPosition() {
16371
16413
  if (this.dropdownContainer) {
@@ -16444,6 +16486,15 @@ ${text2}</tr>
16444
16486
  }
16445
16487
  }
16446
16488
  disconnect() {
16489
+ this.#cleanupSlimSelect();
16490
+ }
16491
+ #handleMorph() {
16492
+ if (!this.element.isConnected)
16493
+ return;
16494
+ this.#cleanupSlimSelect();
16495
+ this.#setupSlimSelect();
16496
+ }
16497
+ #cleanupSlimSelect() {
16447
16498
  if (this.element) {
16448
16499
  if (this.boundHandleDropdownOpen) {
16449
16500
  this.element.removeEventListener(
@@ -16480,21 +16531,24 @@ ${text2}</tr>
16480
16531
  this.modifiedSelectWrapper = null;
16481
16532
  }
16482
16533
  }
16483
- reconnect() {
16484
- this.disconnect();
16485
- setTimeout(() => this.connect(), 10);
16486
- }
16487
16534
  };
16488
16535
 
16489
16536
  // src/js/controllers/flatpickr_controller.js
16490
16537
  var flatpickr_controller_default = class extends Controller {
16491
16538
  connect() {
16539
+ if (this.picker)
16540
+ return;
16492
16541
  this.modal = document.querySelector("[data-controller=remote-modal]");
16493
16542
  this.picker = new flatpickr(this.element, this.#buildOptions());
16494
- this.element.setAttribute(
16495
- "data-action",
16496
- "turbo:morph-element->flatpickr#reconnect"
16497
- );
16543
+ this.element.addEventListener("turbo:morph-element", (event) => {
16544
+ if (event.target === this.element && !this.morphing) {
16545
+ this.morphing = true;
16546
+ requestAnimationFrame(() => {
16547
+ this.#handleMorph();
16548
+ this.morphing = false;
16549
+ });
16550
+ }
16551
+ });
16498
16552
  }
16499
16553
  disconnect() {
16500
16554
  if (this.picker) {
@@ -16502,9 +16556,15 @@ ${text2}</tr>
16502
16556
  this.picker = null;
16503
16557
  }
16504
16558
  }
16505
- reconnect() {
16506
- this.disconnect();
16507
- this.connect();
16559
+ #handleMorph() {
16560
+ if (!this.element.isConnected)
16561
+ return;
16562
+ if (this.picker) {
16563
+ this.picker.destroy();
16564
+ this.picker = null;
16565
+ }
16566
+ this.modal = document.querySelector("[data-controller=remote-modal]");
16567
+ this.picker = new flatpickr(this.element, this.#buildOptions());
16508
16568
  }
16509
16569
  #buildOptions() {
16510
16570
  let options2 = { altInput: true };
@@ -16530,10 +16590,18 @@ ${text2}</tr>
16530
16590
  this.inputTargetDisconnected();
16531
16591
  }
16532
16592
  inputTargetConnected() {
16533
- if (!this.hasInputTarget)
16593
+ if (!this.hasInputTarget || this.iti)
16534
16594
  return;
16535
16595
  this.iti = window.intlTelInput(this.inputTarget, this.#buildOptions());
16536
- this.inputTarget.setAttribute("data-action", "turbo:morph-element->intl-tel-input#reconnect");
16596
+ this.element.addEventListener("turbo:morph-element", (event) => {
16597
+ if (event.target === this.element && !this.morphing) {
16598
+ this.morphing = true;
16599
+ requestAnimationFrame(() => {
16600
+ this.#handleMorph();
16601
+ this.morphing = false;
16602
+ });
16603
+ }
16604
+ });
16537
16605
  }
16538
16606
  inputTargetDisconnected() {
16539
16607
  if (this.iti) {
@@ -16541,9 +16609,14 @@ ${text2}</tr>
16541
16609
  this.iti = null;
16542
16610
  }
16543
16611
  }
16544
- reconnect() {
16545
- this.inputTargetDisconnected();
16546
- this.inputTargetConnected();
16612
+ #handleMorph() {
16613
+ if (!this.inputTarget || !this.inputTarget.isConnected)
16614
+ return;
16615
+ if (this.iti) {
16616
+ this.iti.destroy();
16617
+ this.iti = null;
16618
+ }
16619
+ this.iti = window.intlTelInput(this.inputTarget, this.#buildOptions());
16547
16620
  }
16548
16621
  #buildOptions() {
16549
16622
  return {
@@ -29316,14 +29389,45 @@ this.ifd0Offset: ${this.ifd0Offset}, file.byteLength: ${e4.byteLength}`), e4.tif
29316
29389
  static outlets = ["attachment-preview", "attachment-preview-container"];
29317
29390
  //======= Lifecycle
29318
29391
  connect() {
29392
+ if (this.uppy)
29393
+ return;
29319
29394
  this.uploadedFiles = [];
29320
29395
  this.element.style["display"] = "none";
29321
29396
  this.configureUppy();
29322
29397
  this.#buildTriggers();
29323
29398
  this.#onAttachmentsChanged();
29399
+ this.element.addEventListener("turbo:morph-element", (event) => {
29400
+ if (event.target === this.element && !this.morphing) {
29401
+ this.morphing = true;
29402
+ requestAnimationFrame(() => {
29403
+ this.#handleMorph();
29404
+ this.morphing = false;
29405
+ });
29406
+ }
29407
+ });
29324
29408
  }
29325
29409
  disconnect() {
29326
- this.uppy = null;
29410
+ this.#cleanupUppy();
29411
+ }
29412
+ #handleMorph() {
29413
+ if (!this.element.isConnected)
29414
+ return;
29415
+ this.#cleanupUppy();
29416
+ this.uploadedFiles = [];
29417
+ this.element.style["display"] = "none";
29418
+ this.configureUppy();
29419
+ this.#buildTriggers();
29420
+ this.#onAttachmentsChanged();
29421
+ }
29422
+ #cleanupUppy() {
29423
+ if (this.uppy) {
29424
+ this.uppy.destroy();
29425
+ this.uppy = null;
29426
+ }
29427
+ if (this.triggerContainer && this.triggerContainer.parentNode) {
29428
+ this.triggerContainer.parentNode.removeChild(this.triggerContainer);
29429
+ this.triggerContainer = null;
29430
+ }
29327
29431
  }
29328
29432
  attachmentPreviewOutletConnected(outlet, element) {
29329
29433
  this.#onAttachmentsChanged();