plutonium 0.16.3 → 0.16.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -3364,7 +3364,6 @@
3364
3364
  window.Collapse = Collapse;
3365
3365
  window.initCollapses = initCollapses;
3366
3366
  }
3367
- var collapse_default = Collapse;
3368
3367
 
3369
3368
  // node_modules/flowbite/lib/esm/components/carousel/index.js
3370
3369
  var __assign3 = function() {
@@ -7269,19 +7268,27 @@
7269
7268
  static targets = ["trigger", "menu"];
7270
7269
  connect() {
7271
7270
  console.log(`resource-collapse connected: ${this.element}`);
7272
- this.collapse = new collapse_default(this.menuTarget, this.triggerTarget);
7273
- }
7274
- disconnect() {
7275
- this.collapse = null;
7271
+ if (!this.element.hasAttribute("data-visible")) {
7272
+ this.element.setAttribute("data-visible", "false");
7273
+ }
7274
+ this.#updateState();
7276
7275
  }
7277
7276
  toggle() {
7278
- this.collapse.toggle();
7279
- }
7280
- show() {
7281
- this.collapse.show();
7282
- }
7283
- hide() {
7284
- this.collapse.hide();
7277
+ const isVisible = this.element.getAttribute("data-visible") === "true";
7278
+ this.element.setAttribute("data-visible", (!isVisible).toString());
7279
+ this.#updateState();
7280
+ }
7281
+ #updateState() {
7282
+ const isVisible = this.element.getAttribute("data-visible") === "true";
7283
+ if (isVisible) {
7284
+ this.menuTarget.classList.remove("hidden");
7285
+ this.triggerTarget.setAttribute("aria-expanded", "true");
7286
+ this.dispatch("expand");
7287
+ } else {
7288
+ this.menuTarget.classList.add("hidden");
7289
+ this.triggerTarget.setAttribute("aria-expanded", "false");
7290
+ this.dispatch("collapse");
7291
+ }
7285
7292
  }
7286
7293
  };
7287
7294