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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e0cf503bb2cd8309b4682f5fa03fbac83853d251624a0e695110dd7ca984b1e5
|
|
4
|
+
data.tar.gz: eb75b69501205a841d2fa1220f2510bea5e96ffb169f19307dedb968efc6edbb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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.
|
|
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
|
|
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:,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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="
|
|
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>
|