rails_modal_manager 1.0.54 → 1.0.55

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: 5a176f75787294b2e24e87ca52d21f8320ba48687479ad7e68433525d1dc9ca2
4
- data.tar.gz: 13de8b01baca4cd5e78b50d0578730ccf01812056241cdf2017b1f88fd8e050d
3
+ metadata.gz: e0cf503bb2cd8309b4682f5fa03fbac83853d251624a0e695110dd7ca984b1e5
4
+ data.tar.gz: eb75b69501205a841d2fa1220f2510bea5e96ffb169f19307dedb968efc6edbb
5
5
  SHA512:
6
- metadata.gz: 6f444d0b166c4e32ef0af8c17a3b51a4402c34631ef55e39d2ad09a984abe7ecf07b34fc3212f96e73f82f50cd34116195e635e3d7caa9e8cb30728eb7e8bb1c
7
- data.tar.gz: ebe7588251b75cdedc70d5fcd73fb32f42c1afacdf5594981ef06244af9e46c7f37437926e4fcf29acbd29b0172e7a3cb77a4c431c21d9631dc0a41eb1bc2710
6
+ metadata.gz: 9f09c9cfdecc894a959360eb1f4ee4f8a36841b1d19e9e2922803e2d017a4ff810de075ac7a7e8c3ce9fe7d0ff6c8059f84a9252a2c80e0435278eed42f33153
7
+ data.tar.gz: 595f2da63377cde83786907e7c8adb78620ba965ad8cae92e605b072492291bc2ca7ce1f8a2cc3181254eb3c765db1f0457a840588fb22591e1ce96f522aba31
@@ -23,17 +23,24 @@ function renderButtonHtml(btn) {
23
23
  const classes = ["rmm-btn", `rmm-btn-${btn.variant || "secondary"}`]
24
24
  if (btn.loading) classes.push("rmm-btn-loading")
25
25
 
26
- const attrs = [`class="${classes.join(" ")}"`]
26
+ const type = btn.type || "button"
27
+ const attrs = [`type="${escapeHtml(type)}"`, `class="${classes.join(" ")}"`]
28
+ // v1.0.55+: button[form="..."] HTML5 attribute — submit a form that lives outside the button
29
+ if (btn.form) attrs.push(`form="${escapeHtml(btn.form)}"`)
27
30
  if (btn.disabled || btn.loading) attrs.push("disabled")
28
31
  if (btn.action) attrs.push(`data-action="${escapeHtml(btn.action)}"`)
29
- // v1.0.53+: onclick `data-rmm-onclick` 속성에 저장하고 setModalFooter
30
- // 렌더 직후 실제 click listener 로 바인딩. innerHTML 로 박힌 inline `onclick`
31
- // 은 일부 환경(CSP, 특정 브라우저 파싱) 에서 핸들러로 등록되지 않는 경우가 있어
32
- // 이 방식으로 확실히 동작시킴.
32
+ // DEPRECATED in v1.0.55. Kept for backward compatibility prefer type+form or action.
33
33
  if (btn.onclick) attrs.push(`data-rmm-onclick="${escapeHtml(btn.onclick)}"`)
34
+ // v1.0.55+: extra data-* attributes (e.g. data: { rmm_loading_label: "저장 중..." })
35
+ if (btn.data && typeof btn.data === "object") {
36
+ Object.entries(btn.data).forEach(([k, v]) => {
37
+ const key = String(k).replace(/_/g, "-")
38
+ attrs.push(`data-${escapeHtml(key)}="${escapeHtml(v)}"`)
39
+ })
40
+ }
34
41
  if (btn.id) attrs.push(`data-button-id="${escapeHtml(btn.id)}"`)
35
42
 
36
- return `<button type="button" ${attrs.join(" ")}>${escapeHtml(btn.label || "")}</button>`
43
+ return `<button ${attrs.join(" ")}>${escapeHtml(btn.label || "")}</button>`
37
44
  }
38
45
 
39
46
  /**
@@ -1,18 +1,43 @@
1
1
  <%#
2
- Rails Modal Manager - Footer Component
2
+ Rails Modal Manager - Footer Component (v1.0.55+)
3
3
 
4
4
  Locals:
5
5
  modal_id: String - The modal ID
6
6
  message: String - Footer message (optional)
7
- buttons: Array - Footer buttons [{id:, label:, variant:, disabled:, loading:, action:, onclick:}]
8
- variant: primary, secondary, danger, success, warning
9
- onclick: JavaScript code string. Bound as click listener on modal connect
10
- (v1.0.54+) so it works even without setModalFooter JS path.
7
+ buttons: Array - Footer buttons [{id:, label:, variant:, type:, form:, action:, disabled:, loading:, data:, onclick:}]
8
+
9
+ Button option fields:
10
+ id: String - Button identifier (rendered as data-button-id)
11
+ label: String - Button text
12
+ variant: String - primary, secondary, success, danger, warning (default: secondary)
13
+ type: String - "button" (default) or "submit"
14
+ With "submit" + form, the browser submits the form natively.
15
+ form: String - id of a form to submit when this button is clicked
16
+ (HTML5 button[form] attribute). Pairs with type: "submit".
17
+ action: String - Stimulus data-action (e.g. "click->my-controller#save")
18
+ disabled: Boolean - Render as disabled
19
+ loading: Boolean - DEPRECATED in 1.0.55. Was rmm-btn-loading class but its CSS
20
+ made the label transparent; prefer label-swap via data-rmm-loading-label.
21
+ data: Hash - Extra data-* attributes (e.g. { rmm_loading_label: "저장 중..." })
22
+ Keys are dasherized: rmm_loading_label → data-rmm-loading-label
23
+ onclick: String - DEPRECATED in 1.0.55. Inline JavaScript code string. Use type+form
24
+ or action: instead. Kept for backward compatibility.
25
+
26
+ Recommended pattern (form submission):
27
+ { id: "save", label: "저장", variant: "primary",
28
+ type: "submit", form: "my-form-id",
29
+ data: { rmm_loading_label: "저장 중..." } }
11
30
  %>
12
31
  <%
13
32
  modal_id ||= ""
14
33
  message ||= nil
15
34
  buttons ||= []
35
+
36
+ # Helper: dasherize hash keys → data-* attribute pairs string
37
+ data_attr_string = ->(data_hash) {
38
+ return "" unless data_hash.is_a?(Hash)
39
+ data_hash.map { |k, v| %(data-#{k.to_s.tr('_', '-')}="#{ERB::Util.html_escape(v)}") }.join(" ")
40
+ }
16
41
  %>
17
42
  <div class="rmm-footer">
18
43
  <div class="rmm-footer-left">
@@ -27,12 +52,15 @@
27
52
  btn_classes = ["rmm-btn"]
28
53
  btn_classes << "rmm-btn-#{btn[:variant] || 'secondary'}"
29
54
  btn_classes << "rmm-btn-loading" if btn[:loading]
55
+ btn_type = btn[:type].presence || "button"
30
56
  %>
31
- <button type="button"
57
+ <button type="<%= btn_type %>"
32
58
  class="<%= btn_classes.join(' ') %>"
59
+ <% if btn[:form].present? %>form="<%= btn[:form] %>"<% end %>
33
60
  <% if btn[:disabled] || btn[:loading] %>disabled<% end %>
34
61
  <% if btn[:action] %>data-action="<%= btn[:action] %>"<% end %>
35
62
  <% if btn[:onclick] %>data-rmm-onclick="<%= btn[:onclick] %>"<% end %>
63
+ <%= data_attr_string.call(btn[:data]).html_safe if btn[:data] %>
36
64
  data-button-id="<%= btn[:id] %>">
37
65
  <%= btn[:label] %>
38
66
  </button>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsModalManager
4
- VERSION = "1.0.54"
4
+ VERSION = "1.0.55"
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.54
4
+ version: 1.0.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - reshacs