rails_modal_manager 1.0.27 → 1.0.29

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: e919b275fd361881663b301cd23661d0ac6bb593c2798eb2a77b0bb231e4f4c1
4
- data.tar.gz: 553fe6e5cc9235cd0c87997d07c630795893c235a79983416d8423d65a4f013d
3
+ metadata.gz: 91f9473faad23228686f9fe959c83c9c048bdc814ecd3ed7e492eeac5ec10e6b
4
+ data.tar.gz: 6b81119b8eaa385bfe34ba0aad7fda92d5ff89c6a425a4328e38b81355b2d141
5
5
  SHA512:
6
- metadata.gz: 18794e80fb189d47781ba21e1a673499f459cabcc835509c97d87748d5ad16781634a2341796b3e14c45f6442a0af1643b80c0a534dbf3075696bf690a785396
7
- data.tar.gz: 2f26034a4577fba61a50ab77292203df2c2f4916f4b9dbe8b9879ea30e93baeae66b896dd75f23d73f9713e80cee0f8171fcb24dab7d50b93348a18b95891b84
6
+ metadata.gz: 0c04a02908fc63c7e6343efa32171dbb2949dabbd35503638e44b6ec5a884b5d96faf979c98fa52ea4d5005bc538e664ab032a5d38514edbf363e5defe4d97fc
7
+ data.tar.gz: fa6749e2a862836755ad7de5cd46c4df4d3e546063524aaa0c6515c30b8060ea3972b66d6e2b3a08c9fe75a41291eec6c0797214cc85dccec26ea8fa76fe8dce
@@ -1292,3 +1292,73 @@
1292
1292
  white-space: nowrap;
1293
1293
  border: 0;
1294
1294
  }
1295
+
1296
+ /* ============================================
1297
+ Content Loading Overlay
1298
+ ============================================ */
1299
+ .rmm-content-loader {
1300
+ position: absolute;
1301
+ inset: 0;
1302
+ display: flex;
1303
+ align-items: center;
1304
+ justify-content: center;
1305
+ background: rgba(255, 255, 255, 0.7);
1306
+ z-index: 5;
1307
+ opacity: 0;
1308
+ visibility: hidden;
1309
+ transition: opacity 0.2s ease, visibility 0.2s ease;
1310
+ }
1311
+
1312
+ .dark .rmm-content-loader {
1313
+ background: rgba(30, 41, 59, 0.7);
1314
+ }
1315
+
1316
+ .rmm-content-loader.rmm-active {
1317
+ opacity: 1;
1318
+ visibility: visible;
1319
+ }
1320
+
1321
+ /* Loading indicator wrapper */
1322
+ .rmm-content-loader-inner {
1323
+ display: flex;
1324
+ flex-direction: column;
1325
+ align-items: center;
1326
+ gap: 12px;
1327
+ }
1328
+
1329
+ /* Spinner sizes */
1330
+ .rmm-spinner-sm {
1331
+ width: 20px;
1332
+ height: 20px;
1333
+ border-width: 2px;
1334
+ }
1335
+
1336
+ .rmm-spinner-md {
1337
+ width: 32px;
1338
+ height: 32px;
1339
+ border-width: 3px;
1340
+ }
1341
+
1342
+ .rmm-spinner-lg {
1343
+ width: 48px;
1344
+ height: 48px;
1345
+ border-width: 4px;
1346
+ }
1347
+
1348
+ /* Loading text */
1349
+ .rmm-content-loader-text {
1350
+ font-size: 14px;
1351
+ color: var(--rmm-submenu-item-text);
1352
+ }
1353
+
1354
+ /* Container with loading state (relative positioning for overlay) */
1355
+ .rmm-loading-container {
1356
+ position: relative;
1357
+ min-height: 100px;
1358
+ }
1359
+
1360
+ /* Fade effect for content during loading */
1361
+ .rmm-loading-container.rmm-loading > *:not(.rmm-content-loader) {
1362
+ opacity: 0.5;
1363
+ transition: opacity 0.2s ease;
1364
+ }
@@ -205,19 +205,14 @@ export default class extends Controller {
205
205
  return
206
206
  }
207
207
 
208
- // 서브메뉴가 있는 경우 forceReloadActive 호출하여 콘텐츠 새로고침
209
- const submenuId = item.dataset.submenuId
210
- if (submenuId) {
211
- this.triggerSubmenuReload(submenuId)
212
- }
213
-
214
- // 이벤트 발생
208
+ // 이벤트만 발생 (커스텀 컨트롤러에서 콘텐츠 로드 처리)
209
+ // triggerSubmenuReload는 호출하지 않음 - 중복 로드 방지
215
210
  this.dispatch('itemSelect', {
216
211
  detail: {
217
212
  modalId: this.modalIdValue,
218
213
  itemId: item.dataset.itemId,
219
214
  itemLabel: item.dataset.itemLabel,
220
- hasSubmenu: !!submenuId,
215
+ hasSubmenu: !!item.dataset.submenuId,
221
216
  isReselect: true,
222
217
  }
223
218
  })
@@ -152,3 +152,92 @@ export function getOpenModalCount() {
152
152
  export function getModalStore() {
153
153
  return modalStore
154
154
  }
155
+
156
+ // ============================================
157
+ // Content Loader Functions
158
+ // ============================================
159
+
160
+ // Store for active loader timeouts (for delay feature)
161
+ const loaderTimeouts = new Map()
162
+
163
+ /**
164
+ * Show a content loader by ID
165
+ * @param {string} loaderId - The loader element's ID
166
+ * @param {Object} options - Options
167
+ * @param {number} options.delay - Delay in ms before showing (overrides data-rmm-loader-delay)
168
+ */
169
+ export function showLoader(loaderId, options = {}) {
170
+ const loader = document.getElementById(loaderId)
171
+ if (!loader) return
172
+
173
+ // Clear any existing timeout
174
+ if (loaderTimeouts.has(loaderId)) {
175
+ clearTimeout(loaderTimeouts.get(loaderId))
176
+ loaderTimeouts.delete(loaderId)
177
+ }
178
+
179
+ // Get delay from options or data attribute
180
+ const delay = options.delay ?? parseInt(loader.dataset.rmmLoaderDelay || '0', 10)
181
+
182
+ // Also add loading class to parent container
183
+ const container = loader.parentElement
184
+ if (container && container.classList.contains('rmm-loading-container')) {
185
+ container.classList.add('rmm-loading')
186
+ }
187
+
188
+ if (delay > 0) {
189
+ // Show after delay
190
+ const timeout = setTimeout(() => {
191
+ loader.classList.add('rmm-active')
192
+ loader.setAttribute('aria-hidden', 'false')
193
+ loaderTimeouts.delete(loaderId)
194
+ }, delay)
195
+ loaderTimeouts.set(loaderId, timeout)
196
+ } else {
197
+ // Show immediately
198
+ loader.classList.add('rmm-active')
199
+ loader.setAttribute('aria-hidden', 'false')
200
+ }
201
+ }
202
+
203
+ /**
204
+ * Hide a content loader by ID
205
+ * @param {string} loaderId - The loader element's ID
206
+ */
207
+ export function hideLoader(loaderId) {
208
+ const loader = document.getElementById(loaderId)
209
+ if (!loader) return
210
+
211
+ // Clear any pending timeout
212
+ if (loaderTimeouts.has(loaderId)) {
213
+ clearTimeout(loaderTimeouts.get(loaderId))
214
+ loaderTimeouts.delete(loaderId)
215
+ }
216
+
217
+ loader.classList.remove('rmm-active')
218
+ loader.setAttribute('aria-hidden', 'true')
219
+
220
+ // Remove loading class from parent container
221
+ const container = loader.parentElement
222
+ if (container && container.classList.contains('rmm-loading-container')) {
223
+ container.classList.remove('rmm-loading')
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Check if a loader is currently active (visible or pending)
229
+ * @param {string} loaderId - The loader element's ID
230
+ * @returns {boolean}
231
+ */
232
+ export function isLoaderActive(loaderId) {
233
+ const loader = document.getElementById(loaderId)
234
+ if (!loader) return false
235
+ return loader.classList.contains('rmm-active') || loaderTimeouts.has(loaderId)
236
+ }
237
+
238
+ // Register global functions for easy access
239
+ if (typeof window !== 'undefined') {
240
+ window.rmmShowLoader = showLoader
241
+ window.rmmHideLoader = hideLoader
242
+ window.rmmIsLoaderActive = isLoaderActive
243
+ }
@@ -0,0 +1,59 @@
1
+ <%#
2
+ Rails Modal Manager - Content Loader Component
3
+
4
+ A reusable loading overlay with spinner that can be placed inside any container.
5
+ The container should have `position: relative` or use the `rmm-loading-container` class.
6
+
7
+ Usage:
8
+ ```erb
9
+ <div id="my-content" class="rmm-loading-container">
10
+ <%= render "rails_modal_manager/content_loader", loader_id: "my-loader" %>
11
+ <!-- Your content here -->
12
+ </div>
13
+ ```
14
+
15
+ Then control via JavaScript:
16
+ ```javascript
17
+ // Show loader
18
+ RailsModalManager.showLoader('my-loader')
19
+
20
+ // Hide loader
21
+ RailsModalManager.hideLoader('my-loader')
22
+
23
+ // Or using the global function
24
+ window.rmmShowLoader('my-loader')
25
+ window.rmmHideLoader('my-loader')
26
+ ```
27
+
28
+ Optional locals:
29
+ loader_id: String - Unique loader identifier (default: auto-generated)
30
+ size: String - sm, md, lg (default: "md")
31
+ text: String - Loading text (default: nil, no text shown)
32
+ delay: Number - Delay in ms before showing (default: 0)
33
+ active: Boolean - Initially active (default: false)
34
+ %>
35
+ <%
36
+ loader_id ||= "rmm-loader-#{SecureRandom.hex(4)}"
37
+ size ||= "md"
38
+ text ||= nil
39
+ delay ||= 0
40
+ active ||= false
41
+
42
+ loader_classes = ["rmm-content-loader"]
43
+ loader_classes << "rmm-active" if active
44
+
45
+ spinner_classes = ["rmm-spinner", "rmm-spinner-#{size}"]
46
+ %>
47
+
48
+ <div id="<%= loader_id %>"
49
+ class="<%= loader_classes.join(' ') %>"
50
+ data-rmm-loader
51
+ data-rmm-loader-delay="<%= delay %>"
52
+ aria-hidden="<%= !active %>">
53
+ <div class="rmm-content-loader-inner">
54
+ <div class="<%= spinner_classes.join(' ') %>"></div>
55
+ <% if text.present? %>
56
+ <span class="rmm-content-loader-text"><%= text %></span>
57
+ <% end %>
58
+ </div>
59
+ </div>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsModalManager
4
- VERSION = "1.0.27"
4
+ VERSION = "1.0.29"
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.27
4
+ version: 1.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - reshacs
@@ -59,6 +59,7 @@ files:
59
59
  - app/javascript/rails_modal_manager/history_stack_manager.js
60
60
  - app/javascript/rails_modal_manager/index.js
61
61
  - app/javascript/rails_modal_manager/modal_store.js
62
+ - app/views/rails_modal_manager/_content_loader.html.erb
62
63
  - app/views/rails_modal_manager/_footer.html.erb
63
64
  - app/views/rails_modal_manager/_header.html.erb
64
65
  - app/views/rails_modal_manager/_modal.html.erb