rails_accordion 0.1.11.pre.beta → 0.2.0.pre.beta

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 284d8cf2918779c43bc9ad68ee5d7e34d0a6b88b518f1477afd8b1d8311f2b81
4
- data.tar.gz: c00f66ee4f7017135e24604d363bb9bfa02f3173d2f0bd7cc6eac60327b0afe2
3
+ metadata.gz: 5e9e757eaa0cead4dab2b564df0a1ca006e5638d11c1d0fa6261595ea3faf367
4
+ data.tar.gz: 89a3fd28498cf34c6ac666abd5be076aba75a8c0125b3903a9eaa36b68d2d822
5
5
  SHA512:
6
- metadata.gz: c0a1cbbc177318dbfbfcfdc8e196c02a49467288406c5ba9a38e338b0dffd33fa1e98a0c75235a997df031818779b65a8d811979e1f07335f0f4f63266651ef3
7
- data.tar.gz: 216f76b79299ac8e6f5a899db55420cbee4743f1fdafa7872ccacd6ae762d85080978a48b8cdc030c0e7a0ddccc4360545f5d8438ed86fab73afef6498d2c49a
6
+ metadata.gz: a1c850657c4d42d3a00db7f82aee4862e7e8f8c26843c2092ed435913349ee5870961b79fd88ed6cb84a9400e5ceb37cb02caeb75d43344ec90d5b34a5928f38
7
+ data.tar.gz: 2a319415261a298555ad85e36f735f4775cb2c42c7f2ec53420bc366c608e9d8ba60db35e59d2fb51ae21bb1f83ad59fe00afc68d214a78b80bb7a9af0eb65e2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_accordion (0.1.11.pre.beta)
4
+ rails_accordion (0.2.0.pre.beta)
5
5
  stimulus-rails (~> 1.2)
6
6
  view_component (~> 2.52)
7
7
  zeitwerk (~> 2.6)
data/README.md CHANGED
@@ -5,13 +5,17 @@ rails_accordion is a Ruby gem that provides an easy-to-use accordion component f
5
5
  ## Installation
6
6
 
7
7
  ```rb
8
- gem 'rails_accordion', '~> 0.1.10.pre.beta'
8
+ gem 'rails_accordion', '~> 0.1.12.pre.beta'
9
9
  ```
10
10
 
11
11
  ```shell
12
12
  bundle install
13
13
  ```
14
14
 
15
+ ```shell
16
+ rails generate rails_accordion:install
17
+ ```
18
+
15
19
  In config/importmap.rb, add:
16
20
 
17
21
  ```rb
@@ -23,6 +27,11 @@ And in app/javascript/application.js, add:
23
27
  import 'rails_accordion'
24
28
  ```
25
29
 
30
+ in application.scss, add:
31
+ ```scss
32
+ @import 'rails_accordion'
33
+ ```
34
+
26
35
  ## Usage
27
36
 
28
37
  ```erb
@@ -518,10 +518,14 @@ video {
518
518
  width: 100%;
519
519
  overflow: hidden;
520
520
  transition-property: all;
521
+ transition-duration: 150ms;
521
522
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
522
- transition-duration: 300ms;
523
523
  }
524
524
 
525
525
  .accordion_toggle {
526
526
  cursor: pointer;
527
527
  }
528
+
529
+ .accordion_content-container {
530
+ height: max-content;
531
+ }
@@ -368,7 +368,7 @@
368
368
  return r2.path = "/v4/" + r2.authority + ".json", r2.params.push("secure"), this._makeAPIURL(r2, this._customAccessToken || e2);
369
369
  }, G.prototype.normalizeSpriteURL = function(t2, e2, r2, n2) {
370
370
  var i2 = Y(t2);
371
- return Z(t2) ? (i2.path = "/styles/v1" + i2.path + "/sprite" + e2 + r2, this._makeAPIURL(i2, this._customAccessToken || n2)) : (i2.path += "" + e2 + r2, $(i2));
371
+ return Z(t2) ? (i2.path = "/styles/v1" + i2.path + "/sprite" + e2 + r2, this._makeAPIURL(i2, this._customAccessToken || n2)) : (i2.path += "" + e2 + r2, $2(i2));
372
372
  }, G.prototype.normalizeTileURL = function(t2, e2) {
373
373
  if (this._isSkuTokenExpired() && this._createSkuToken(), t2 && !Z(t2)) {
374
374
  return t2;
@@ -409,7 +409,7 @@
409
409
  i2 >= 0 && t2.params.splice(i2, 1);
410
410
  }
411
411
  if ("/" !== n2.path && (t2.path = "" + n2.path + t2.path), !R.REQUIRE_ACCESS_TOKEN) {
412
- return $(t2);
412
+ return $2(t2);
413
413
  }
414
414
  if (!(e2 = e2 || R.ACCESS_TOKEN)) {
415
415
  throw new Error("An API access token is required to use Mapbox GL. " + r2);
@@ -419,7 +419,7 @@
419
419
  }
420
420
  return t2.params = t2.params.filter(function(t3) {
421
421
  return -1 === t3.indexOf("access_token");
422
- }), t2.params.push("access_token=" + e2), $(t2);
422
+ }), t2.params.push("access_token=" + e2), $2(t2);
423
423
  };
424
424
  var X = /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;
425
425
  function J(t2) {
@@ -433,7 +433,7 @@
433
433
  }
434
434
  return { protocol: e2[1], authority: e2[2], path: e2[3] || "/", params: e2[4] ? e2[4].split("&") : [] };
435
435
  }
436
- function $(t2) {
436
+ function $2(t2) {
437
437
  var e2 = t2.params.length ? "?" + t2.params.join("&") : "";
438
438
  return t2.protocol + "://" + t2.authority + t2.path + e2;
439
439
  }
@@ -488,7 +488,7 @@
488
488
  if (R.EVENTS_URL) {
489
489
  var a2 = Y(R.EVENTS_URL);
490
490
  a2.params.push("access_token=" + (n2 || R.ACCESS_TOKEN || ""));
491
- var o2 = { event: this.type, created: new Date(t2).toISOString(), sdkIdentifier: "mapbox-gl-js", sdkVersion: "1.13.3", skuId: K, userId: this.anonId }, s2 = e2 ? h(o2, e2) : o2, u2 = { url: $(a2), headers: { "Content-Type": "text/plain" }, body: JSON.stringify([s2]) };
491
+ var o2 = { event: this.type, created: new Date(t2).toISOString(), sdkIdentifier: "mapbox-gl-js", sdkVersion: "1.13.3", skuId: K, userId: this.anonId }, s2 = e2 ? h(o2, e2) : o2, u2 = { url: $2(a2), headers: { "Content-Type": "text/plain" }, body: JSON.stringify([s2]) };
492
492
  this.pendingRequest = wt(u2, function(t3) {
493
493
  i2.pendingRequest = null, r2(t3), i2.saveEventData(), i2.processRequests(n2);
494
494
  });
@@ -8832,8 +8832,8 @@
8832
8832
  var Y3 = n4.horizontal[H3];
8833
8833
  if (!z4) {
8834
8834
  R4 = ha(Y3.text);
8835
- var $3 = s5.layout.get("text-rotate").evaluate(b4, {}, S4);
8836
- z4 = new Wu(u5, e4, l4, p5, c6, Y3, h5, f5, y4, $3);
8835
+ var $4 = s5.layout.get("text-rotate").evaluate(b4, {}, S4);
8836
+ z4 = new Wu(u5, e4, l4, p5, c6, Y3, h5, f5, y4, $4);
8837
8837
  }
8838
8838
  var W3 = 1 === Y3.positionedLines.length;
8839
8839
  if (V4 += sl(t4, e4, Y3, a5, s5, y4, b4, d4, M4, n4.vertical ? wu.horizontal : wu.horizontalOnly, W3 ? Object.keys(n4.horizontal) : [H3], O4, D4, w4, S4), W3) {
@@ -8876,8 +8876,8 @@
8876
8876
  }
8877
8877
  } else if ("Point" === e3.type) {
8878
8878
  for (var J2 = 0, H2 = e3.geometry; J2 < H2.length; J2 += 1) {
8879
- for (var Y2 = 0, $2 = H2[J2]; Y2 < $2.length; Y2 += 1) {
8880
- var W2 = $2[Y2];
8879
+ for (var Y2 = 0, $3 = H2[J2]; Y2 < $3.length; Y2 += 1) {
8880
+ var W2 = $3[Y2];
8881
8881
  P3([W2], new Fu(W2.x, W2.y, 0));
8882
8882
  }
8883
8883
  }
@@ -9453,7 +9453,7 @@
9453
9453
  e2.minX = Math.min(e2.minX, t2[r2]), e2.minY = Math.min(e2.minY, t2[r2 + 1]), e2.maxX = Math.max(e2.maxX, t2[r2]), e2.maxY = Math.max(e2.maxY, t2[r2 + 1]);
9454
9454
  }
9455
9455
  }
9456
- function $(e2, t2, r2, i2) {
9456
+ function $2(e2, t2, r2, i2) {
9457
9457
  if (t2.geometry) {
9458
9458
  var o2 = t2.geometry.coordinates, n2 = t2.geometry.type, a2 = Math.pow(r2.tolerance / ((1 << r2.maxZoom) * r2.extent), 2), s2 = [], l2 = t2.id;
9459
9459
  if (r2.promoteId ? l2 = t2.properties[r2.promoteId] : r2.generateId && (l2 = i2 || 0), "Point" === n2) {
@@ -9478,7 +9478,7 @@
9478
9478
  if ("MultiPolygon" !== n2) {
9479
9479
  if ("GeometryCollection" === n2) {
9480
9480
  for (u2 = 0; u2 < t2.geometry.geometries.length; u2++) {
9481
- $(e2, { id: l2, geometry: t2.geometry.geometries[u2], properties: t2.properties }, r2, i2);
9481
+ $2(e2, { id: l2, geometry: t2.geometry.geometries[u2], properties: t2.properties }, r2, i2);
9482
9482
  }
9483
9483
  return;
9484
9484
  }
@@ -9735,10 +9735,10 @@
9735
9735
  var r3 = [];
9736
9736
  if ("FeatureCollection" === e3.type) {
9737
9737
  for (var i3 = 0; i3 < e3.features.length; i3++) {
9738
- $(r3, e3.features[i3], t3, i3);
9738
+ $2(r3, e3.features[i3], t3, i3);
9739
9739
  }
9740
9740
  } else {
9741
- $(r3, "Feature" === e3.type ? e3 : { geometry: e3 }, t3);
9741
+ $2(r3, "Feature" === e3.type ? e3 : { geometry: e3 }, t3);
9742
9742
  }
9743
9743
  return r3;
9744
9744
  }(e2, t2);
@@ -11155,7 +11155,7 @@
11155
11155
  t3 ? e3.enable(e3.STENCIL_TEST) : e3.disable(e3.STENCIL_TEST), this.current = t3, this.dirty = false;
11156
11156
  }
11157
11157
  }, e2;
11158
- }(j), $ = function(t2) {
11158
+ }(j), $2 = function(t2) {
11159
11159
  function e2() {
11160
11160
  t2.apply(this, arguments);
11161
11161
  }
@@ -11451,7 +11451,7 @@
11451
11451
  };
11452
11452
  Ct.disabled = new Ct(false, 1029, 2305), Ct.backCCW = new Ct(true, 1029, 2305);
11453
11453
  var zt = function(t2) {
11454
- this.gl = t2, this.extVertexArrayObject = this.gl.getExtension("OES_vertex_array_object"), this.clearColor = new V(this), this.clearDepth = new G(this), this.clearStencil = new W(this), this.colorMask = new X(this), this.depthMask = new H(this), this.stencilMask = new K(this), this.stencilFunc = new Y(this), this.stencilOp = new J(this), this.stencilTest = new Q(this), this.depthRange = new $(this), this.depthTest = new tt(this), this.depthFunc = new et(this), this.blend = new it(this), this.blendFunc = new ot(this), this.blendColor = new rt(this), this.blendEquation = new at(this), this.cullFace = new nt(this), this.cullFaceSide = new st(this), this.frontFace = new lt(this), this.program = new ct(this), this.activeTexture = new ut(this), this.viewport = new ht(this), this.bindFramebuffer = new pt(this), this.bindRenderbuffer = new dt(this), this.bindTexture = new _t(this), this.bindVertexBuffer = new ft(this), this.bindElementBuffer = new mt(this), this.bindVertexArrayOES = this.extVertexArrayObject && new gt(this), this.pixelStoreUnpack = new vt(this), this.pixelStoreUnpackPremultiplyAlpha = new yt(this), this.pixelStoreUnpackFlipY = new xt(this), this.extTextureFilterAnisotropic = t2.getExtension("EXT_texture_filter_anisotropic") || t2.getExtension("MOZ_EXT_texture_filter_anisotropic") || t2.getExtension("WEBKIT_EXT_texture_filter_anisotropic"), this.extTextureFilterAnisotropic && (this.extTextureFilterAnisotropicMax = t2.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)), this.extTextureHalfFloat = t2.getExtension("OES_texture_half_float"), this.extTextureHalfFloat && (t2.getExtension("OES_texture_half_float_linear"), this.extRenderToTextureHalfFloat = t2.getExtension("EXT_color_buffer_half_float")), this.extTimerQuery = t2.getExtension("EXT_disjoint_timer_query"), this.maxTextureSize = t2.getParameter(t2.MAX_TEXTURE_SIZE);
11454
+ this.gl = t2, this.extVertexArrayObject = this.gl.getExtension("OES_vertex_array_object"), this.clearColor = new V(this), this.clearDepth = new G(this), this.clearStencil = new W(this), this.colorMask = new X(this), this.depthMask = new H(this), this.stencilMask = new K(this), this.stencilFunc = new Y(this), this.stencilOp = new J(this), this.stencilTest = new Q(this), this.depthRange = new $2(this), this.depthTest = new tt(this), this.depthFunc = new et(this), this.blend = new it(this), this.blendFunc = new ot(this), this.blendColor = new rt(this), this.blendEquation = new at(this), this.cullFace = new nt(this), this.cullFaceSide = new st(this), this.frontFace = new lt(this), this.program = new ct(this), this.activeTexture = new ut(this), this.viewport = new ht(this), this.bindFramebuffer = new pt(this), this.bindRenderbuffer = new dt(this), this.bindTexture = new _t(this), this.bindVertexBuffer = new ft(this), this.bindElementBuffer = new mt(this), this.bindVertexArrayOES = this.extVertexArrayObject && new gt(this), this.pixelStoreUnpack = new vt(this), this.pixelStoreUnpackPremultiplyAlpha = new yt(this), this.pixelStoreUnpackFlipY = new xt(this), this.extTextureFilterAnisotropic = t2.getExtension("EXT_texture_filter_anisotropic") || t2.getExtension("MOZ_EXT_texture_filter_anisotropic") || t2.getExtension("WEBKIT_EXT_texture_filter_anisotropic"), this.extTextureFilterAnisotropic && (this.extTextureFilterAnisotropicMax = t2.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)), this.extTextureHalfFloat = t2.getExtension("OES_texture_half_float"), this.extTextureHalfFloat && (t2.getExtension("OES_texture_half_float_linear"), this.extRenderToTextureHalfFloat = t2.getExtension("EXT_color_buffer_half_float")), this.extTimerQuery = t2.getExtension("EXT_disjoint_timer_query"), this.maxTextureSize = t2.getParameter(t2.MAX_TEXTURE_SIZE);
11455
11455
  };
11456
11456
  zt.prototype.setDefault = function() {
11457
11457
  this.unbindVAO(), this.clearColor.setDefault(), this.clearDepth.setDefault(), this.clearStencil.setDefault(), this.colorMask.setDefault(), this.depthMask.setDefault(), this.stencilMask.setDefault(), this.stencilFunc.setDefault(), this.stencilOp.setDefault(), this.stencilTest.setDefault(), this.depthRange.setDefault(), this.depthTest.setDefault(), this.depthFunc.setDefault(), this.blend.setDefault(), this.blendFunc.setDefault(), this.blendColor.setDefault(), this.blendEquation.setDefault(), this.cullFace.setDefault(), this.cullFaceSide.setDefault(), this.frontFace.setDefault(), this.program.setDefault(), this.activeTexture.setDefault(), this.bindFramebuffer.setDefault(), this.pixelStoreUnpack.setDefault(), this.pixelStoreUnpackPremultiplyAlpha.setDefault(), this.pixelStoreUnpackFlipY.setDefault();
@@ -12452,8 +12452,8 @@
12452
12452
  if (K2 || Y2 ? Y2 ? K2 || (P3 = P3 && T3) : T3 = P3 && T3 : P3 = T3 = P3 && T3, T3 && d3 && d3.box && r2.collisionIndex.insertCollisionBox(d3.box, s2.get("text-ignore-placement"), n2.bucketInstanceId, D3 && D3.box && R2 ? R2 : L2, f2.ID), P3 && M2 && r2.collisionIndex.insertCollisionBox(M2.box, s2.get("icon-ignore-placement"), n2.bucketInstanceId, k2, f2.ID), A3 && (T3 && r2.collisionIndex.insertCollisionCircles(A3.circles, s2.get("text-ignore-placement"), n2.bucketInstanceId, L2, f2.ID), o2)) {
12453
12453
  var J2 = n2.bucketInstanceId, Q2 = r2.collisionCircleArrays[J2];
12454
12454
  void 0 === Q2 && (Q2 = r2.collisionCircleArrays[J2] = new me());
12455
- for (var $2 = 0; $2 < A3.circles.length; $2 += 4) {
12456
- Q2.circles.push(A3.circles[$2 + 0]), Q2.circles.push(A3.circles[$2 + 1]), Q2.circles.push(A3.circles[$2 + 2]), Q2.circles.push(A3.collisionDetected ? 1 : 0);
12455
+ for (var $3 = 0; $3 < A3.circles.length; $3 += 4) {
12456
+ Q2.circles.push(A3.circles[$3 + 0]), Q2.circles.push(A3.circles[$3 + 1]), Q2.circles.push(A3.circles[$3 + 2]), Q2.circles.push(A3.collisionDetected ? 1 : 0);
12457
12457
  }
12458
12458
  }
12459
12459
  r2.placements[e3.crossTileID] = new fe(T3 || E2, P3 || I2, S3 || n2.justReloaded), i2[e3.crossTileID] = true;
@@ -13710,15 +13710,15 @@
13710
13710
  }
13711
13711
  var V2 = pe(C2, 1, e2.transform.zoom), G2 = Jt(S2.posMatrix, g2, m2, e2.transform, V2), W2 = Qt(S2.posMatrix, g2, m2, e2.transform, V2), X2 = T2 && z2.hasTextData(), H2 = "none" !== o2.layout.get("icon-text-fit") && X2 && z2.hasIconData();
13712
13712
  v2 && ie(z2, S2.posMatrix, e2, a2, G2, W2, g2, u2);
13713
- var K2 = e2.translatePosMatrix(S2.posMatrix, C2, n2, s2), Y2 = v2 || a2 && T2 || H2 ? Ji : G2, J2 = e2.translatePosMatrix(W2, C2, n2, s2, true), Q2 = M2 && 0 !== o2.paint.get(a2 ? "text-halo-width" : "icon-halo-width").constantOr(1), $2 = { program: k2, buffers: D2, uniformValues: M2 ? z2.iconsInText ? Wi(L2.kind, B2, y2, g2, e2, K2, Y2, J2, O2, F2) : Gi(L2.kind, B2, y2, g2, e2, K2, Y2, J2, a2, O2, true) : Vi(L2.kind, B2, y2, g2, e2, K2, Y2, J2, a2, O2), atlasTexture: U2, atlasTextureIcon: Z2, atlasInterpolation: N2, atlasInterpolationIcon: q2, isSDF: M2, hasHalo: Q2 };
13713
+ var K2 = e2.translatePosMatrix(S2.posMatrix, C2, n2, s2), Y2 = v2 || a2 && T2 || H2 ? Ji : G2, J2 = e2.translatePosMatrix(W2, C2, n2, s2, true), Q2 = M2 && 0 !== o2.paint.get(a2 ? "text-halo-width" : "icon-halo-width").constantOr(1), $3 = { program: k2, buffers: D2, uniformValues: M2 ? z2.iconsInText ? Wi(L2.kind, B2, y2, g2, e2, K2, Y2, J2, O2, F2) : Gi(L2.kind, B2, y2, g2, e2, K2, Y2, J2, a2, O2, true) : Vi(L2.kind, B2, y2, g2, e2, K2, Y2, J2, a2, O2), atlasTexture: U2, atlasTextureIcon: Z2, atlasInterpolation: N2, atlasInterpolationIcon: q2, isSDF: M2, hasHalo: Q2 };
13714
13714
  if (x2 && z2.canOverlap) {
13715
13715
  b2 = true;
13716
13716
  for (var tt2 = 0, et2 = D2.segments.get(); tt2 < et2.length; tt2 += 1) {
13717
13717
  var it2 = et2[tt2];
13718
- E2.push({ segments: new t.SegmentVector([it2]), sortKey: it2.sortKey, state: $2 });
13718
+ E2.push({ segments: new t.SegmentVector([it2]), sortKey: it2.sortKey, state: $3 });
13719
13719
  }
13720
13720
  } else {
13721
- E2.push({ segments: D2.segments, sortKey: 0, state: $2 });
13721
+ E2.push({ segments: D2.segments, sortKey: 0, state: $3 });
13722
13722
  }
13723
13723
  }
13724
13724
  }
@@ -19667,35 +19667,52 @@
19667
19667
  var accordion_controller_default = class extends Controller {
19668
19668
  connect() {
19669
19669
  this.initAccordion();
19670
+ this.initDefaultState();
19671
+ }
19672
+ initDefaultState() {
19673
+ const items = this.element.querySelectorAll(".accordion_item");
19674
+ switch ($(this.element).data("default-state")) {
19675
+ case "all_closed":
19676
+ this.hideAll(items);
19677
+ break;
19678
+ case "all_opened":
19679
+ this.showAll(items);
19680
+ break;
19681
+ case "first_opened":
19682
+ this.hideAll(items);
19683
+ this.open(items[0].querySelector(".accordion_content"));
19684
+ }
19670
19685
  }
19671
19686
  initAccordion() {
19672
19687
  const items = this.element.querySelectorAll(".accordion_item");
19673
19688
  items.forEach((item) => {
19674
19689
  const toggle = item.querySelector(".accordion_toggle");
19690
+ const content = item.querySelector(".accordion_content");
19675
19691
  toggle.addEventListener("click", (e) => {
19676
- if (item.classList.contains("active")) {
19677
- this.hide(item);
19692
+ if (content.classList.contains("accordion_active")) {
19693
+ this.hide(content);
19678
19694
  } else {
19679
- this.hideAll(items);
19680
- this.open(item);
19695
+ if ($(this.element).data("multiple-open") != true) {
19696
+ this.hideAll(items);
19697
+ }
19698
+ this.open(content);
19681
19699
  }
19682
19700
  });
19683
19701
  });
19684
19702
  }
19685
19703
  hideAll(items) {
19686
- items.forEach((item) => this.hide(item));
19704
+ items.forEach((item) => this.hide(item.querySelector(".accordion_content")));
19705
+ }
19706
+ showAll(items) {
19707
+ items.forEach((item) => this.open(item.querySelector(".accordion_content")));
19687
19708
  }
19688
19709
  hide(item) {
19689
- item.classList.remove("active");
19690
- const content = item.querySelector(".accordion_content");
19691
- content.style.height = "0px";
19710
+ item.classList.remove("accordion_active");
19711
+ item.style.height = 0;
19692
19712
  }
19693
19713
  open(item) {
19694
- item.classList.add("active");
19695
- const content = item.querySelector(".accordion_content");
19696
- content.style.height = "auto";
19697
- const contentHeight = content.style.height;
19698
- content.animate({ height: contentHeight + "px" }, 50);
19714
+ item.classList.add("accordion_active");
19715
+ item.style.height = item.scrollHeight + "px";
19699
19716
  }
19700
19717
  };
19701
19718