rails_modal_manager 1.0.52 → 1.0.53

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: 9f0c284c73e8a2d5bf8c4a04293332dce7bc16a61cc53279e99dfa1c133e0894
4
- data.tar.gz: 5215a66e121f1057d17420ce7407c7d4961f8cd1a21d16cf9303a3989abe7892
3
+ metadata.gz: f5ea3c9a0f748719fffb7a377e31eb8ffa82aa92a51fe5e57d0c9e766757f6bd
4
+ data.tar.gz: 299fa546552e45abccac98ddd60d258b8b24d8a5ffe3b4e8c8e5647df5b63003
5
5
  SHA512:
6
- metadata.gz: 13644c5657a20e5baa80b1304344cf9dcd411856f641e924882a657fed63ca67116a0e61603aa01ca0cf93bb49a3a5724a7117bf1bd797ec79d38348020ebdb7
7
- data.tar.gz: a2af506573c6b393eb1fa10cfd4246d90a71bdd3d8235fa5e4728cb381d9923dad06aeaed870abf2c4dfb34e083fbe7adfb56a8f900800a73b8a2318a4cc731a
6
+ metadata.gz: 577924acb8554d70314b4380100d2f6c72ffed2216fb43f78c6197007508e833b35c11f527644cf8ca3e2115cfd06328bb3fa74b7c4eb648336ba3a94587f779
7
+ data.tar.gz: f56d2917b83eab179ec1a54e9cf3654e0c81e3e3fe778d0982279d13c18e859dd069f1d7bf73238c0771ddea72d1dbe0b6d189db039bfc0892ad7bfce414b877
@@ -26,9 +26,11 @@ function renderButtonHtml(btn) {
26
26
  const attrs = [`class="${classes.join(" ")}"`]
27
27
  if (btn.disabled || btn.loading) attrs.push("disabled")
28
28
  if (btn.action) attrs.push(`data-action="${escapeHtml(btn.action)}"`)
29
- // v1.0.52+: onclick 지원 Stimulus 컨트롤러 scope 밖(footer 는 panel 밖에 있음)에서
30
- // 본문의 저장 버튼을 프로그래밍적으로 클릭하거나 form.requestSubmit() 호출하는 용도.
31
- if (btn.onclick) attrs.push(`onclick="${escapeHtml(btn.onclick)}"`)
29
+ // v1.0.53+: onclick `data-rmm-onclick` 속성에 저장하고 setModalFooter
30
+ // 렌더 직후 실제 click listener 바인딩. innerHTML 로 박힌 inline `onclick`
31
+ // 은 일부 환경(CSP, 특정 브라우저 파싱) 에서 핸들러로 등록되지 않는 경우가 있어
32
+ // 이 방식으로 확실히 동작시킴.
33
+ if (btn.onclick) attrs.push(`data-rmm-onclick="${escapeHtml(btn.onclick)}"`)
32
34
  if (btn.id) attrs.push(`data-button-id="${escapeHtml(btn.id)}"`)
33
35
 
34
36
  return `<button type="button" ${attrs.join(" ")}>${escapeHtml(btn.label || "")}</button>`
@@ -63,6 +65,20 @@ export function setModalFooter(modal, buttons = [], message = null) {
63
65
  // 우측 버튼 영역
64
66
  right.innerHTML = (buttons || []).map(renderButtonHtml).join("")
65
67
 
68
+ // v1.0.53+: data-rmm-onclick 속성을 실제 click 이벤트 리스너로 바인딩
69
+ right.querySelectorAll("[data-rmm-onclick]").forEach(function(btn) {
70
+ const code = btn.getAttribute("data-rmm-onclick")
71
+ btn.removeAttribute("data-rmm-onclick")
72
+ btn.addEventListener("click", function() {
73
+ try {
74
+ // 버튼 본인을 `this` 로 전달 (호출측에서 this.dataset 등 접근 가능)
75
+ new Function(code).call(btn)
76
+ } catch (e) {
77
+ console.warn("[rmm-footer] onclick handler error:", e)
78
+ }
79
+ })
80
+ })
81
+
66
82
  // 교체 이벤트 dispatch (앱에서 후처리 원할 경우용)
67
83
  footer.dispatchEvent(
68
84
  new CustomEvent("rmm-footer:updated", {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsModalManager
4
- VERSION = "1.0.52"
4
+ VERSION = "1.0.53"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_modal_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.52
4
+ version: 1.0.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - reshacs