rails_modal_manager 1.0.28 → 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: ebcb6d9bc5128b747b71ad201b2e9fad380dc7d788064b373ff8b320ea79c47e
4
- data.tar.gz: fad2c3da1a425a4f565eafac8d22b3ae58393964494eff0ee5d854aee9a431aa
3
+ metadata.gz: 91f9473faad23228686f9fe959c83c9c048bdc814ecd3ed7e492eeac5ec10e6b
4
+ data.tar.gz: 6b81119b8eaa385bfe34ba0aad7fda92d5ff89c6a425a4328e38b81355b2d141
5
5
  SHA512:
6
- metadata.gz: e319bb433378cc2eb60025c84f98c8fa47286334895e9b588b80c5cc5b0c6476c6cfe5b444261048c8fc736994ffd8f7b9d4c7ca24de4fa44a9570104fb69d2f
7
- data.tar.gz: 1fd5038104cff012f5ba60f92cea95eea006e95b5c6f6ff8b592031ffcd586342a0a166c03cc000daa70301d4958dfeb4ef39f67815ba9cd32c4dc21bf0c106b
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
+ }
@@ -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.28"
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.28
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