plutonium 0.26.2 → 0.26.4

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.
@@ -16290,19 +16290,46 @@ ${text2}</tr>
16290
16290
 
16291
16291
  // src/js/controllers/easymde_controller.js
16292
16292
  var easymde_controller_default = class extends Controller {
16293
+ static targets = ["textarea"];
16293
16294
  connect() {
16295
+ if (this.easyMDE)
16296
+ return;
16297
+ this.originalValue = this.element.value;
16294
16298
  this.easyMDE = new EasyMDE(this.#buildOptions());
16295
- this.element.setAttribute("data-action", "turbo:morph-element->easymde#reconnect");
16299
+ this.element.addEventListener("turbo:before-morph-element", (event) => {
16300
+ if (event.target === this.element && this.easyMDE) {
16301
+ this.storedValue = this.easyMDE.value();
16302
+ }
16303
+ });
16304
+ this.element.addEventListener("turbo:morph-element", (event) => {
16305
+ if (event.target === this.element) {
16306
+ requestAnimationFrame(() => this.#handleMorph());
16307
+ }
16308
+ });
16296
16309
  }
16297
16310
  disconnect() {
16298
16311
  if (this.easyMDE) {
16299
- this.easyMDE.toTextArea();
16312
+ try {
16313
+ if (this.element.isConnected && this.element.parentNode) {
16314
+ this.easyMDE.toTextArea();
16315
+ }
16316
+ } catch (error2) {
16317
+ console.warn("EasyMDE cleanup error:", error2);
16318
+ }
16300
16319
  this.easyMDE = null;
16301
16320
  }
16302
16321
  }
16303
- reconnect() {
16304
- this.disconnect();
16305
- this.connect();
16322
+ #handleMorph() {
16323
+ if (!this.element.isConnected)
16324
+ return;
16325
+ if (this.easyMDE) {
16326
+ this.easyMDE = null;
16327
+ }
16328
+ this.easyMDE = new EasyMDE(this.#buildOptions());
16329
+ if (this.storedValue !== void 0) {
16330
+ this.easyMDE.value(this.storedValue);
16331
+ this.storedValue = void 0;
16332
+ }
16306
16333
  }
16307
16334
  #buildOptions() {
16308
16335
  let options2 = {
@@ -16333,6 +16360,16 @@ ${text2}</tr>
16333
16360
  // src/js/controllers/slim_select_controller.js
16334
16361
  var slim_select_controller_default = class extends Controller {
16335
16362
  connect() {
16363
+ if (this.slimSelect)
16364
+ return;
16365
+ this.#setupSlimSelect();
16366
+ this.element.addEventListener("turbo:morph-element", (event) => {
16367
+ if (event.target === this.element) {
16368
+ requestAnimationFrame(() => this.#handleMorph());
16369
+ }
16370
+ });
16371
+ }
16372
+ #setupSlimSelect() {
16336
16373
  const settings = {};
16337
16374
  const modal = document.querySelector('[data-controller="remote-modal"]');
16338
16375
  if (modal) {
@@ -16362,10 +16399,6 @@ ${text2}</tr>
16362
16399
  this.element.addEventListener("ss:open", this.boundHandleDropdownOpen);
16363
16400
  this.element.addEventListener("ss:close", this.boundHandleDropdownClose);
16364
16401
  this.setupAriaObserver();
16365
- this.element.setAttribute(
16366
- "data-action",
16367
- "turbo:morph-element->slim-select#reconnect"
16368
- );
16369
16402
  }
16370
16403
  handleDropdownPosition() {
16371
16404
  if (this.dropdownContainer) {
@@ -16444,6 +16477,15 @@ ${text2}</tr>
16444
16477
  }
16445
16478
  }
16446
16479
  disconnect() {
16480
+ this.#cleanupSlimSelect();
16481
+ }
16482
+ #handleMorph() {
16483
+ if (!this.element.isConnected)
16484
+ return;
16485
+ this.#cleanupSlimSelect();
16486
+ this.#setupSlimSelect();
16487
+ }
16488
+ #cleanupSlimSelect() {
16447
16489
  if (this.element) {
16448
16490
  if (this.boundHandleDropdownOpen) {
16449
16491
  this.element.removeEventListener(
@@ -16480,21 +16522,24 @@ ${text2}</tr>
16480
16522
  this.modifiedSelectWrapper = null;
16481
16523
  }
16482
16524
  }
16483
- reconnect() {
16484
- this.disconnect();
16485
- setTimeout(() => this.connect(), 10);
16486
- }
16487
16525
  };
16488
16526
 
16489
16527
  // src/js/controllers/flatpickr_controller.js
16490
16528
  var flatpickr_controller_default = class extends Controller {
16491
16529
  connect() {
16530
+ if (this.picker)
16531
+ return;
16492
16532
  this.modal = document.querySelector("[data-controller=remote-modal]");
16493
16533
  this.picker = new flatpickr(this.element, this.#buildOptions());
16494
- this.element.setAttribute(
16495
- "data-action",
16496
- "turbo:morph-element->flatpickr#reconnect"
16497
- );
16534
+ this.element.addEventListener("turbo:morph-element", (event) => {
16535
+ if (event.target === this.element && !this.morphing) {
16536
+ this.morphing = true;
16537
+ requestAnimationFrame(() => {
16538
+ this.#handleMorph();
16539
+ this.morphing = false;
16540
+ });
16541
+ }
16542
+ });
16498
16543
  }
16499
16544
  disconnect() {
16500
16545
  if (this.picker) {
@@ -16502,9 +16547,15 @@ ${text2}</tr>
16502
16547
  this.picker = null;
16503
16548
  }
16504
16549
  }
16505
- reconnect() {
16506
- this.disconnect();
16507
- this.connect();
16550
+ #handleMorph() {
16551
+ if (!this.element.isConnected)
16552
+ return;
16553
+ if (this.picker) {
16554
+ this.picker.destroy();
16555
+ this.picker = null;
16556
+ }
16557
+ this.modal = document.querySelector("[data-controller=remote-modal]");
16558
+ this.picker = new flatpickr(this.element, this.#buildOptions());
16508
16559
  }
16509
16560
  #buildOptions() {
16510
16561
  let options2 = { altInput: true };
@@ -16530,10 +16581,18 @@ ${text2}</tr>
16530
16581
  this.inputTargetDisconnected();
16531
16582
  }
16532
16583
  inputTargetConnected() {
16533
- if (!this.hasInputTarget)
16584
+ if (!this.hasInputTarget || this.iti)
16534
16585
  return;
16535
16586
  this.iti = window.intlTelInput(this.inputTarget, this.#buildOptions());
16536
- this.inputTarget.setAttribute("data-action", "turbo:morph-element->intl-tel-input#reconnect");
16587
+ this.element.addEventListener("turbo:morph-element", (event) => {
16588
+ if (event.target === this.element && !this.morphing) {
16589
+ this.morphing = true;
16590
+ requestAnimationFrame(() => {
16591
+ this.#handleMorph();
16592
+ this.morphing = false;
16593
+ });
16594
+ }
16595
+ });
16537
16596
  }
16538
16597
  inputTargetDisconnected() {
16539
16598
  if (this.iti) {
@@ -16541,9 +16600,14 @@ ${text2}</tr>
16541
16600
  this.iti = null;
16542
16601
  }
16543
16602
  }
16544
- reconnect() {
16545
- this.inputTargetDisconnected();
16546
- this.inputTargetConnected();
16603
+ #handleMorph() {
16604
+ if (!this.inputTarget || !this.inputTarget.isConnected)
16605
+ return;
16606
+ if (this.iti) {
16607
+ this.iti.destroy();
16608
+ this.iti = null;
16609
+ }
16610
+ this.iti = window.intlTelInput(this.inputTarget, this.#buildOptions());
16547
16611
  }
16548
16612
  #buildOptions() {
16549
16613
  return {
@@ -29304,6 +29368,7 @@ this.ifd0Offset: ${this.ifd0Offset}, file.byteLength: ${e4.byteLength}`), e4.tif
29304
29368
  var attachment_input_controller_default = class extends Controller {
29305
29369
  static values = {
29306
29370
  identifier: String,
29371
+ endpoint: String,
29307
29372
  maxFileSize: { type: Number, default: null },
29308
29373
  minFileSize: { type: Number, default: null },
29309
29374
  maxTotalSize: { type: Number, default: null },
@@ -29315,14 +29380,45 @@ this.ifd0Offset: ${this.ifd0Offset}, file.byteLength: ${e4.byteLength}`), e4.tif
29315
29380
  static outlets = ["attachment-preview", "attachment-preview-container"];
29316
29381
  //======= Lifecycle
29317
29382
  connect() {
29383
+ if (this.uppy)
29384
+ return;
29318
29385
  this.uploadedFiles = [];
29319
29386
  this.element.style["display"] = "none";
29320
29387
  this.configureUppy();
29321
29388
  this.#buildTriggers();
29322
29389
  this.#onAttachmentsChanged();
29390
+ this.element.addEventListener("turbo:morph-element", (event) => {
29391
+ if (event.target === this.element && !this.morphing) {
29392
+ this.morphing = true;
29393
+ requestAnimationFrame(() => {
29394
+ this.#handleMorph();
29395
+ this.morphing = false;
29396
+ });
29397
+ }
29398
+ });
29323
29399
  }
29324
29400
  disconnect() {
29325
- this.uppy = null;
29401
+ this.#cleanupUppy();
29402
+ }
29403
+ #handleMorph() {
29404
+ if (!this.element.isConnected)
29405
+ return;
29406
+ this.#cleanupUppy();
29407
+ this.uploadedFiles = [];
29408
+ this.element.style["display"] = "none";
29409
+ this.configureUppy();
29410
+ this.#buildTriggers();
29411
+ this.#onAttachmentsChanged();
29412
+ }
29413
+ #cleanupUppy() {
29414
+ if (this.uppy) {
29415
+ this.uppy.destroy();
29416
+ this.uppy = null;
29417
+ }
29418
+ if (this.triggerContainer && this.triggerContainer.parentNode) {
29419
+ this.triggerContainer.parentNode.removeChild(this.triggerContainer);
29420
+ this.triggerContainer = null;
29421
+ }
29326
29422
  }
29327
29423
  attachmentPreviewOutletConnected(outlet, element) {
29328
29424
  this.#onAttachmentsChanged();
@@ -29348,7 +29444,7 @@ this.ifd0Offset: ${this.ifd0Offset}, file.byteLength: ${e4.byteLength}`), e4.tif
29348
29444
  }
29349
29445
  #configureUploader() {
29350
29446
  this.uppy.use(XHRUpload, {
29351
- endpoint: "/upload"
29447
+ endpoint: this.endpointValue
29352
29448
  // path to the upload endpoint
29353
29449
  });
29354
29450
  }