nodality 1.0.107 → 1.0.109

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.
Files changed (205) hide show
  1. package/dist/animator.cjs.js +1 -1
  2. package/dist/animator.esm.js +1 -1
  3. package/dist/audionew.cjs.js +1 -1
  4. package/dist/audionew.esm.js +1 -1
  5. package/dist/beta-desktop-bar.cjs.js +1 -1
  6. package/dist/beta-desktop-bar.esm.js +1 -1
  7. package/dist/beta-mobile-bar.cjs.js +1 -1
  8. package/dist/beta-mobile-bar.esm.js +1 -1
  9. package/dist/bundle.umd.js +1 -1
  10. package/dist/button.cjs.js +1 -1
  11. package/dist/button.esm.js +1 -1
  12. package/dist/center.cjs.js +1 -1
  13. package/dist/center.esm.js +1 -1
  14. package/dist/checkbox.cjs.js +1 -1
  15. package/dist/checkbox.esm.js +1 -1
  16. package/dist/code.cjs.js +1 -1
  17. package/dist/code.esm.js +1 -1
  18. package/dist/container.cjs.js +1 -1
  19. package/dist/container.esm.js +1 -1
  20. package/dist/designer.cjs.js +1 -1
  21. package/dist/designer.esm.js +1 -1
  22. package/dist/dropdown.cjs.js +1 -1
  23. package/dist/dropdown.esm.js +1 -1
  24. package/dist/element-mapper.cjs.js +1 -1
  25. package/dist/element-mapper.esm.js +1 -1
  26. package/dist/finalresult.esm.js +1 -1
  27. package/dist/flex-card.cjs.js +1 -1
  28. package/dist/flex-card.esm.js +1 -1
  29. package/dist/flex-grid.cjs.js +1 -1
  30. package/dist/flex-grid.esm.js +1 -1
  31. package/dist/flex-row.cjs.js +1 -1
  32. package/dist/flex-row.esm.js +1 -1
  33. package/dist/floating-input.cjs.js +1 -1
  34. package/dist/floating-input.esm.js +1 -1
  35. package/dist/free.cjs.js +1 -1
  36. package/dist/free.esm.js +1 -1
  37. package/dist/image-picker.cjs.js +1 -1
  38. package/dist/image-picker.esm.js +1 -1
  39. package/dist/image.cjs.js +1 -1
  40. package/dist/image.esm.js +1 -1
  41. package/dist/index.cjs.js +1 -1
  42. package/dist/index.esm.js +1 -1
  43. package/dist/link-getter.cjs.js +1 -1
  44. package/dist/link-getter.esm.js +1 -1
  45. package/dist/link.cjs.js +1 -1
  46. package/dist/link.esm.js +1 -1
  47. package/dist/multiswitcher.cjs.js +1 -1
  48. package/dist/multiswitcher.esm.js +1 -1
  49. package/dist/new-nav-bar.cjs.js +1 -1
  50. package/dist/new-nav-bar.esm.js +1 -1
  51. package/dist/picker.cjs.js +1 -1
  52. package/dist/picker.esm.js +1 -1
  53. package/dist/side-nav-bar.cjs.js +1 -1
  54. package/dist/side-nav-bar.esm.js +1 -1
  55. package/dist/simple-bar.cjs.js +1 -1
  56. package/dist/simple-bar.esm.js +1 -1
  57. package/dist/slider-2025.cjs.js +1 -1
  58. package/dist/slider-2025.esm.js +1 -1
  59. package/dist/table.cjs.js +1 -1
  60. package/dist/table.esm.js +1 -1
  61. package/dist/text-field.cjs.js +1 -1
  62. package/dist/text-field.esm.js +1 -1
  63. package/dist/text.cjs.js +1 -1
  64. package/dist/text.esm.js +1 -1
  65. package/dist/ulist.cjs.js +1 -1
  66. package/dist/ulist.esm.js +1 -1
  67. package/dist/video.cjs.js +1 -1
  68. package/dist/video.esm.js +1 -1
  69. package/dist/zoom-card.cjs.js +1 -1
  70. package/dist/zoom-card.esm.js +1 -1
  71. package/layout/animator.js +651 -118
  72. package/layout/audio.js +1 -1
  73. package/layout/audionew.js +1 -1
  74. package/layout/base-2.js +1 -1
  75. package/layout/base.js +1 -1
  76. package/layout/beta-desktop-bar.js +1 -1
  77. package/layout/beta-mobile-bar.js +1 -1
  78. package/layout/box.js +1 -1
  79. package/layout/button.js +1 -1
  80. package/layout/cards.js +1 -1
  81. package/layout/center.js +1 -1
  82. package/layout/checkbox.js +1 -1
  83. package/layout/circle.js +1 -1
  84. package/layout/clean-row.js +1 -1
  85. package/layout/code.js +1 -1
  86. package/layout/container.js +1 -1
  87. package/layout/custom.js +1 -1
  88. package/layout/div-image.js +1 -1
  89. package/layout/dropdown-2025.js +1 -1
  90. package/layout/dropdown.js +1 -1
  91. package/layout/empty-element.js +1 -1
  92. package/layout/external-stylesheet.js +1 -1
  93. package/layout/flex-card.js +1 -1
  94. package/layout/flex-grid.js +1 -1
  95. package/layout/flex-row.js +1 -1
  96. package/layout/footer.js +1 -1
  97. package/layout/form-components/custom.js +1 -1
  98. package/layout/form-components/data-list.js +1 -1
  99. package/layout/form-components/floating-input.js +1 -1
  100. package/layout/form-components/form-all.js +1 -1
  101. package/layout/form-components/form.js +1 -1
  102. package/layout/form-components/image-picker.js +1 -1
  103. package/layout/form-components/picker.js +1 -1
  104. package/layout/form-components/radio.js +1 -1
  105. package/layout/form-components/radiogroup.js +1 -1
  106. package/layout/form-components/range.js +1 -1
  107. package/layout/free.js +1 -1
  108. package/layout/grid-new.js +1 -1
  109. package/layout/grid-switcher.js +1 -1
  110. package/layout/grid.js +1 -1
  111. package/layout/group.js +1 -1
  112. package/layout/header.js +1 -1
  113. package/layout/horizontal-scroller.js +1 -1
  114. package/layout/image-old.js +1 -1
  115. package/layout/image.js +1 -1
  116. package/layout/index.js +1 -1
  117. package/layout/label.js +1 -1
  118. package/layout/link.js +1 -1
  119. package/layout/list-OLD.js +1 -1
  120. package/layout/list.js +1 -1
  121. package/layout/meta-adder.js +1 -1
  122. package/layout/modal-2025.js +1 -1
  123. package/layout/modernwrap.js +1 -1
  124. package/layout/multiswitcher.js +1 -1
  125. package/layout/multiswitcherBeta.js +1 -1
  126. package/layout/nav-bar.js +1 -1
  127. package/layout/nav-factor/custom-div.js +1 -1
  128. package/layout/navBar-OLD.js +1 -1
  129. package/layout/new-flat-adder.js +1 -1
  130. package/layout/new-nav-bar.js +1 -1
  131. package/layout/offset-container.js +1 -1
  132. package/layout/polygon.js +1 -1
  133. package/layout/progress.js +1 -1
  134. package/layout/row.js +1 -1
  135. package/layout/saved-new-nav-bar.js +1 -1
  136. package/layout/scroll-video.js +1 -1
  137. package/layout/side-bar.js +1 -1
  138. package/layout/side-nav-bar.js +1 -1
  139. package/layout/simple-bar.js +1 -1
  140. package/layout/slider-2025.js +1 -1
  141. package/layout/spacer.js +1 -1
  142. package/layout/stack.js +1 -1
  143. package/layout/styler.js +1 -1
  144. package/layout/switcher.js +1 -1
  145. package/layout/table.js +1 -1
  146. package/layout/text-field.js +1 -1
  147. package/layout/text.js +1 -1
  148. package/layout/ulist.js +1 -1
  149. package/layout/video.js +1 -1
  150. package/layout/without-new.js +1 -1
  151. package/layout/wrap.js +1 -1
  152. package/layout/zoom-card.js +1 -1
  153. package/lib/card-getter.js +1 -1
  154. package/lib/designer.js +1 -1
  155. package/lib/element-mapper.js +1 -1
  156. package/lib/keyframe-animation.js +1 -1
  157. package/lib/link-getter.js +1 -1
  158. package/lib/scroll-video.js +1 -1
  159. package/lib/stacker.js +1 -1
  160. package/lib/transform-anim.js +1 -1
  161. package/package.json +1 -1
  162. package/dist/appleanim.cjs.js +0 -2
  163. package/dist/appleanim.esm.js +0 -2
  164. package/dist/betaDesktopBar.esm.js +0 -2
  165. package/dist/betaMobileBar.esm.js +0 -2
  166. package/dist/cardGetter.cjs.js +0 -2
  167. package/dist/cardGetter.esm.js +0 -2
  168. package/dist/datalist.cjs.js +0 -2
  169. package/dist/datalist.esm.js +0 -2
  170. package/dist/elementMapper.cjs.js +0 -2
  171. package/dist/elementMapper.esm.js +0 -2
  172. package/dist/flexCard.cjs.js +0 -2
  173. package/dist/flexCard.esm.js +0 -2
  174. package/dist/flexGrid.cjs.js +0 -2
  175. package/dist/flexGrid.esm.js +0 -2
  176. package/dist/flexRow.cjs.js +0 -2
  177. package/dist/flexRow.esm.js +0 -2
  178. package/dist/floatingInput.cjs.js +0 -2
  179. package/dist/floatingInput.esm.js +0 -2
  180. package/dist/horizontalScroller.esm.js +0 -2
  181. package/dist/imagePicker.cjs.js +0 -2
  182. package/dist/imagePicker.esm.js +0 -2
  183. package/dist/linkGetter.cjs.js +0 -2
  184. package/dist/linkGetter.esm.js +0 -2
  185. package/dist/metaAdder.cjs.js +0 -2
  186. package/dist/metaAdder.esm.js +0 -2
  187. package/dist/modal2025.cjs.js +0 -2
  188. package/dist/modal2025.esm.js +0 -2
  189. package/dist/multiswitchers.esm.js +0 -2
  190. package/dist/newNavBar.cjs.js +0 -2
  191. package/dist/newNavBar.esm.js +0 -2
  192. package/dist/scrollvideo.cjs.js +0 -2
  193. package/dist/scrollvideo.esm.js +0 -2
  194. package/dist/sideBar.cjs.js +0 -2
  195. package/dist/sideBar.esm.js +0 -2
  196. package/dist/sideNavBar.cjs.js +0 -2
  197. package/dist/sideNavBar.esm.js +0 -2
  198. package/dist/simpleBar.cjs.js +0 -2
  199. package/dist/simpleBar.esm.js +0 -2
  200. package/dist/textField.cjs.js +0 -2
  201. package/dist/textField.esm.js +0 -2
  202. package/dist/transformanim.cjs.js +0 -2
  203. package/dist/transformanim.esm.js +0 -2
  204. package/dist/zoomCard.cjs.js +0 -2
  205. package/dist/zoomCard.esm.js +0 -2
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.0.107
2
+ * nodality v1.0.109
3
3
  * (c) 2025 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -325,14 +325,360 @@ class Animator {
325
325
  window.addEventListener("resize", react);
326
326
  react();
327
327
  }*/
328
+
329
+
330
+
331
+ /*
328
332
  respad(arr) {
329
333
  this._applyResponsive(arr, (applied) => {
330
334
  console.log("Applying padding for", applied.breakpoint);
331
335
  this.pad(applied.values);
332
336
  });
337
+ }*/
338
+ /**
339
+ * @private
340
+ * Sets up the single resize listener and runs all registered tasks.
341
+ */
342
+
343
+ /**
344
+ * @private
345
+ * Sets up the single resize listener and runs all registered tasks.
346
+ * Ensures setup logic runs only ONCE.
347
+ */
348
+ _setupResponsiveManager() {
349
+ // 1. Initialize tasks list if it doesn't exist
350
+ this._responsiveTasks = this._responsiveTasks || [];
351
+
352
+ // 2. Define the reactor function
353
+ const react = () => {
354
+ this._responsiveTasks.forEach(taskFn => {
355
+ taskFn();
356
+ });
357
+ };
358
+
359
+ // 3. Setup Event Listener (ONLY ONCE)
360
+ // We check if the handler is already assigned to avoid duplicate listeners
361
+ if (!this._responsiveHandler) {
362
+ this._responsiveHandler = react;
363
+ window.addEventListener("resize", react);
364
+ }
365
+
366
+ // 4. Trigger Execution (ALWAYS)
367
+ // We run this every time this function is called (by resprop or respad)
368
+ // to ensure the newly added task is executed immediately.
369
+ setTimeout(() => {
370
+ react();
371
+ }, 0);
372
+ }
373
+
374
+ resprop(arr) {
375
+ // --- 1. CONFIGURATION & NORMALIZATION ---
376
+ const breakpoints = {
377
+ default: [0, 100000], xs: [0, 575], sm: [576, 767], md: [768, 991],
378
+ lg: [992, 1199], xl: [1200, 1399], xxl: [1400, 100000]
379
+ };
380
+ const excludedKeys = ['resprop', 'breakpoint', 'value', 'values', 'range'];
381
+
382
+ // A. Normalize breakpoints and assign range (handles named, [min, max], and "px" inputs)
383
+ arr.forEach(item => {
384
+ if (breakpoints[item.breakpoint] !== undefined) {
385
+ item.range = breakpoints[item.breakpoint];
386
+ } else if (Array.isArray(item.breakpoint) && item.breakpoint.length === 2) {
387
+ item.range = [parseInt(item.breakpoint[0], 10), parseInt(item.breakpoint[1], 10)];
388
+ } else {
389
+ item.range = [parseInt(item.breakpoint, 10), 100000];
390
+ }
391
+ });
392
+
393
+ // B. Sort by the minimum value of the range
394
+ arr.sort((a, b) => a.range[0] - b.range[0]);
395
+
396
+ // C. Find/Ensure the base style object
397
+ let defaultItem = arr.find(item => item.breakpoint === "default");
398
+ if (!defaultItem) {
399
+ defaultItem = { breakpoint: "default", range: breakpoints.default };
400
+ arr.unshift(defaultItem);
401
+ }
402
+
403
+ // --- 2. STATE CAPTURE & RESET PREPARATION ---
404
+
405
+ // D. Capture initial non-responsive styles (for global reset)
406
+ this.prevStyles = {};
407
+ for (const prop in this.res.style) {
408
+ if (this.res.style.hasOwnProperty(prop) && isNaN(parseInt(prop))) {
409
+ this.prevStyles[prop] = this.res.style[prop];
410
+ }
411
+ }
412
+
413
+ // E. Identify all properties that are responsive (e.g., 'color', 'size')
414
+ const responsiveProps = new Set();
415
+ arr.forEach(bp => {
416
+ Object.keys(bp).forEach(key => {
417
+ if (!excludedKeys.includes(key) && key !== 'range') {
418
+ responsiveProps.add(key);
419
+ }
420
+ });
421
+ });
422
+
423
+ // F. Ensure 'defaultItem' holds the base/reset value for every responsive property.
424
+ responsiveProps.forEach(key => {
425
+ if (defaultItem[key] === undefined) {
426
+ defaultItem[key] = this.options[key] || "initial";
427
+ }
428
+ });
429
+
430
+
431
+ // --- 3. CORE LOGIC: The Responsive Task Function ---
432
+ const respropTask = () => {
433
+ const width = window.innerWidth;
434
+ let applied = defaultItem;
435
+
436
+ // 1. RANGE LOGIC: Find the exact breakpoint whose range matches the current width.
437
+ for (let i = 0; i < arr.length; i++) {
438
+ const bp = arr[i];
439
+ const [min, max] = bp.range;
440
+
441
+ if (bp.breakpoint === "default") continue;
442
+
443
+ if (width >= min && width <= max) {
444
+ applied = bp;
445
+ break;
446
+ }
447
+ }
448
+
449
+ // --- Apply Styles ---
450
+
451
+ // A. Full Reset: Restore all non-responsive styles.
452
+ /* for (const key in this.prevStyles) {
453
+ this.res.style[key] = this.prevStyles[key];
454
+ }*/
455
+
456
+ // B. Clear Responsive Props: Apply the 'default' item's base values.
457
+ responsiveProps.forEach(key => {
458
+ this.res.style[key] = defaultItem[key];
459
+ });
460
+
461
+ // C. Apply Overrides: Apply the properties of the currently matching breakpoint
462
+ for (const key in applied) {
463
+ if (!excludedKeys.includes(key) && key !== 'range') {
464
+ const value = applied[key];
465
+
466
+ if (typeof this[key] === 'function') {
467
+ // Custom property (e.g., this.size(value)): call the internal method
468
+ this[key](value);
469
+ } else {
470
+ // Standard CSS property: set the style directly.
471
+ this.res.style[key] = value;
472
+ }
473
+ }
474
+ }
475
+ };
476
+
477
+
478
+ // --- 4. REGISTRATION ---
479
+ this._responsiveTasks = this._responsiveTasks || [];
480
+ this._responsiveTasks.push(respropTask);
481
+
482
+ // Ensure the unified handler is set up and starts listening
483
+ this._setupResponsiveManager();
484
+ }
485
+
486
+
487
+ respad(arr) {
488
+ // --- 1. CONFIGURATION & NORMALIZATION ---
489
+ const breakpoints = {
490
+ default: [0, 100000], xs: [0, 575], sm: [576, 767], md: [768, 991],
491
+ lg: [992, 1199], xl: [1200, 1399], xxl: [1400, 100000]
492
+ };
493
+ // Note: 'values' is handled specifically here, so it is not excluded globally.
494
+
495
+ // A. Normalize breakpoints and assign range (handles named, [min, max], and "px" inputs)
496
+ arr.forEach(item => {
497
+ if (breakpoints[item.breakpoint] !== undefined) {
498
+ item.range = breakpoints[item.breakpoint];
499
+ } else if (Array.isArray(item.breakpoint) && item.breakpoint.length === 2) {
500
+ item.range = [parseInt(item.breakpoint[0], 10), parseInt(item.breakpoint[1], 10)];
501
+ } else {
502
+ item.range = [parseInt(item.breakpoint, 10), 100000];
503
+ }
504
+ });
505
+
506
+ // B. Sort by the minimum value of the range
507
+ arr.sort((a, b) => a.range[0] - b.range[0]);
508
+
509
+ // C. Find/Ensure the base style object
510
+ let defaultItem = arr.find(item => item.breakpoint === "default");
511
+ if (!defaultItem) {
512
+ defaultItem = { breakpoint: "default", range: breakpoints.default };
513
+ arr.unshift(defaultItem);
514
+ }
515
+
516
+ // --- 2. STATE CAPTURE & RESET PREPARATION ---
517
+
518
+ // D. Ensure 'defaultItem' has a 'values' property, falling back to the base 'pad' option.
519
+ if (defaultItem.values === undefined) {
520
+ defaultItem.values = this.options.pad || null;
521
+ }
522
+
523
+
524
+ // --- 3. CORE LOGIC: The Responsive Task Function ---
525
+ const respadTask = () => {
526
+ const width = window.innerWidth;
527
+ let applied = defaultItem;
528
+
529
+ // 1. RANGE LOGIC: Find the exact breakpoint whose range matches the current width.
530
+ for (let i = 0; i < arr.length; i++) {
531
+ const bp = arr[i];
532
+ const [min, max] = bp.range;
533
+
534
+ if (bp.breakpoint === "default") continue;
535
+
536
+ if (width >= min && width <= max) {
537
+ applied = bp;
538
+ break;
539
+ }
540
+ }
541
+
542
+ // --- Apply Pad Style ---
543
+
544
+ // Determine the final padding value: use applied.values if it exists, otherwise defaultItem.values
545
+ const finalPadValue = applied.values !== undefined ? applied.values : defaultItem.values;
546
+
547
+
548
+ if (finalPadValue !== undefined && finalPadValue !== null) {
549
+ // Note: We trust this.pad handles the style application and clearing
550
+ this.pad(finalPadValue);
551
+ }
552
+ };
553
+
554
+
555
+ // --- 4. REGISTRATION ---
556
+ this._responsiveTasks = this._responsiveTasks || [];
557
+ this._responsiveTasks.push(respadTask);
558
+
559
+ // Ensure the unified handler is set up and starts listening
560
+ this._setupResponsiveManager();
333
561
  }
334
562
 
335
563
 
564
+ /*
565
+ respad(arr) { // COOL
566
+ // --- 1. CONFIGURATION & NORMALIZATION ---
567
+
568
+ // Breakpoints defined by explicit [min, max] ranges
569
+ const breakpoints = {
570
+ default: [0, 100000],
571
+ xs: [0, 575],
572
+ sm: [576, 767],
573
+ md: [768, 991],
574
+ lg: [992, 1199],
575
+ xl: [1200, 1399],
576
+ xxl: [1400, 100000]
577
+ };
578
+
579
+ // Control keys: We exclude keys not related to the responsive style or range.
580
+ const excludedKeys = ['resprop', 'breakpoint', 'range'];
581
+
582
+ // A. Normalize custom breakpoints: Assign the [min, max] array to the 'range' property
583
+ arr.forEach(item => {
584
+ // 1. Check for named breakpoints (e.g., 'sm', 'md')
585
+ if (breakpoints[item.breakpoint] !== undefined) {
586
+ item.range = breakpoints[item.breakpoint];
587
+
588
+ // 2. Check if the input is already an array [min, max] (e.g., [600, 700])
589
+ } else if (Array.isArray(item.breakpoint) && item.breakpoint.length === 2) {
590
+ const [min, max] = item.breakpoint;
591
+
592
+ item.range = [
593
+ parseInt(min, 10),
594
+ parseInt(max, 10)
595
+ ];
596
+
597
+ // 3. Assume the input is a single pixel string (e.g., "700px")
598
+ } else {
599
+ // Treat as a min-width override up to a large maximum
600
+ const min = parseInt(item.breakpoint, 10);
601
+ item.range = [min, 100000];
602
+ }
603
+ });
604
+
605
+ // B. Sort by the minimum value of the range (range[0])
606
+ arr.sort((a, b) => a.range[0] - b.range[0]);
607
+
608
+ // C. Find/Ensure the base style object
609
+ let defaultItem = arr.find(item => item.breakpoint === "default");
610
+ if (!defaultItem) {
611
+ defaultItem = { breakpoint: "default", range: breakpoints.default };
612
+ arr.unshift(defaultItem);
613
+ }
614
+
615
+ // --- 2. STATE CAPTURE & RESET PREPARATION (Specific to 'pad'/'values') ---
616
+
617
+ // D. Capture the initial base 'values' (which should be the base padding config)
618
+ // NOTE: This assumes the non-responsive 'pad' was set via this.options.pad or similar.
619
+ // For simplicity with your usage, we will use the 'values' from the defaultItem itself.
620
+
621
+ // E. Ensure 'defaultItem' has a 'values' property, or it will use the base config.
622
+ if (defaultItem.values === undefined) {
623
+ // This assumes the core padding is defined elsewhere if not in the responsive array.
624
+ // If no 'default' values are set, use the base 'pad' option if available.
625
+ defaultItem.values = this.options.pad || null;
626
+ }
627
+
628
+
629
+ // --- 3. CORE LOGIC: The 'react' function (Responsive Style Application) ---
630
+
631
+ const react = () => {
632
+ const width = window.innerWidth;
633
+ let applied = defaultItem;
634
+
635
+ // 1. RANGE LOGIC: Find the exact breakpoint whose range matches the current width.
636
+ for (let i = 0; i < arr.length; i++) {
637
+ const bp = arr[i];
638
+ const [min, max] = bp.range;
639
+
640
+ if (bp.breakpoint === "default") {
641
+ continue; // Skip default, it's the fallback
642
+ }
643
+
644
+ // Check if width is WITHIN the [min, max] range
645
+ if (width >= min && width <= max) {
646
+ applied = bp;
647
+ break; // Found the exact range.
648
+ }
649
+ }
650
+
651
+ // --- Apply Pad Style ---
652
+
653
+ // Determine the final padding value to apply:
654
+ // Use applied.values if it exists, otherwise fall back to defaultItem.values
655
+ const finalPadValue = applied.values !== undefined ? applied.values : defaultItem.values;
656
+
657
+
658
+ if (finalPadValue !== undefined && finalPadValue !== null) {
659
+ console.log("Applying padding for", applied.breakpoint);
660
+
661
+ // Call the base 'pad' method with the structure found on the 'values' key.
662
+ this.pad(finalPadValue);
663
+ }
664
+ };
665
+
666
+
667
+ // --- 4. EVENT LISTENERS SETUP ---
668
+
669
+ // Prevent duplicate listeners
670
+ if (this._responsiveHandler) window.removeEventListener("resize", this._responsiveHandler);
671
+ this._responsiveHandler = react;
672
+
673
+ window.addEventListener("resize", react);
674
+
675
+ // Defer the initial execution to solve the refresh race condition.
676
+ setTimeout(() => {
677
+ react();
678
+ }, 0);
679
+ }*/
680
+
681
+
336
682
  /*resmar(arr){
337
683
  const react = () => { // 00:49:12 22/03/2025
338
684
  this.mar(arr[0].values);
@@ -349,172 +695,359 @@ respad(arr) {
349
695
  react();
350
696
  }*/
351
697
 
352
- _applyResponsive(arr, applyFn) {
698
+ _applyResponsive(arr, applyFn) {
699
+ // Breakpoints defined by explicit [min, max] ranges
353
700
  const breakpoints = {
354
- default: 0,
355
- xs: 0,
356
- sm: 576,
357
- md: 768,
358
- lg: 992,
359
- xl: 1200,
360
- xxl: 1400
701
+ default: [0, 100000],
702
+ xs: [0, 575],
703
+ sm: [576, 767],
704
+ md: [768, 991],
705
+ lg: [992, 1199],
706
+ xl: [1200, 1399],
707
+ xxl: [1400, 100000]
361
708
  };
362
709
 
363
- // ✅ Normalize breakpoints
710
+ // ✅ Normalize breakpoints: Assign the [min, max] array to the 'range' property
364
711
  arr.forEach(item => {
365
712
  if (breakpoints[item.breakpoint] !== undefined) {
366
- item._value = breakpoints[item.breakpoint];
713
+ item.range = breakpoints[item.breakpoint];
367
714
  } else {
368
- item._value = parseInt(item.breakpoint, 10); // e.g. "700px" → 700
715
+ const min = parseInt(item.breakpoint, 10);
716
+ item.range = [min, 100000]; // Custom pixel value becomes a Min-Width range
369
717
  }
370
718
  });
371
719
 
372
- // ✅ Sort by numeric value ascending
373
- arr.sort((a, b) => a._value - b._value);
720
+ // ✅ Sort by the minimum value of the range (range[0])
721
+ arr.sort((a, b) => a.range[0] - b.range[0]);
374
722
 
375
- const defaultItem = arr.find(item => item.breakpoint === "default");
723
+ // Use the default item or a placeholder as the base
724
+ const defaultItem = arr.find(item => item.breakpoint === "default") || { breakpoint: "default", range: breakpoints.default };
376
725
 
377
726
  const react = () => {
378
727
  const width = window.innerWidth;
379
- let applied = defaultItem || null;
728
+ let applied = defaultItem; // Start with the base style object
380
729
 
381
- // ✅ Apply the FIRST breakpoint whose max-width matches
730
+ // ✅ RANGE LOGIC: Find the FIRST breakpoint whose range matches the current width.
382
731
  for (let i = 0; i < arr.length; i++) {
383
732
  const bp = arr[i];
384
- if (bp.breakpoint !== "default" && width <= bp._value) {
733
+ const [min, max] = bp.range;
734
+
735
+ if (bp.breakpoint === "default") {
736
+ continue; // Skip default, it's the fallback
737
+ }
738
+
739
+ // Check if width is WITHIN the [min, max] range
740
+ if (width >= min && width <= max) {
385
741
  applied = bp;
386
- break;
742
+ break; // Found the exact range, no need to search further.
387
743
  }
388
744
  }
389
745
 
390
- if (applied) {
391
- applyFn(applied);
392
- }
746
+ applyFn(applied);
393
747
  };
394
748
 
749
+
395
750
  // Prevent duplicate listeners
396
751
  if (this._responsiveHandler) window.removeEventListener("resize", this._responsiveHandler);
397
752
  this._responsiveHandler = react;
398
753
 
399
754
  window.addEventListener("resize", react);
400
- react();
401
- }
402
-
403
- resmar(arr) {
404
- this._applyResponsive(arr, (applied) => {
405
- console.log("Applying margin for", applied.breakpoint);
406
- this.mar(applied.values);
407
- });
755
+
756
+ // ⭐ FIX: Defer the initial call slightly to avoid race conditions on refresh.
757
+ setTimeout(() => {
758
+ react();
759
+ }, 0);
408
760
  }
409
761
 
410
762
  /*
411
- resprop(arr) {
412
- this.prevStyles = {};
413
- for (let i = 0; i < this.res.style.length; i++) {
414
- const prop = this.res.style[i];
415
- this.prevStyles[prop] = this.res.style[prop];
416
- }
763
+ resprop(arr) { // COOL
764
+ // --- 1. CONFIGURATION & NORMALIZATION ---
765
+
766
+ // Breakpoints defined by explicit [min, max] ranges
767
+ const breakpoints = {
768
+ default: [0, 100000], // Use a huge max for default/base
769
+ xs: [0, 575],
770
+ sm: [576, 767],
771
+ md: [768, 991],
772
+ lg: [992, 1199], // Corrected range assumption based on XL starting at 1200
773
+ xl: [1200, 1399],
774
+ xxl: [1400, 100000] // Use a huge max for the largest range
775
+ };
417
776
 
418
- this._applyResponsive(arr, (applied) => {
419
- console.log("Applying styles for", applied.breakpoint);
420
-
421
- // Reset to previous styles (Important for cascading/overwriting)
422
- for (const key in this.prevStyles) {
423
- // NOTE: If this.res.style[key] was set to null/undefined before,
424
- // you might want to consider deleting the property here instead of setting it.
425
- // For simplicity, I'm sticking to your original reset structure.
426
- this.res.style[key] = this.prevStyles[key];
777
+ // Ensure all control keys are excluded
778
+ const excludedKeys = ['resprop', 'breakpoint', 'value', 'values'];
779
+
780
+ // A. Normalize custom breakpoints: Attach the [min, max] array to the item
781
+ /*arr.forEach(item => {
782
+ if (breakpoints[item.breakpoint] !== undefined) {
783
+ item.range = breakpoints[item.breakpoint];
784
+ } else {
785
+ // If a custom pixel value is used (e.g., "700px"), treat it as a min-width override.
786
+ const min = parseInt(item.breakpoint, 10);
787
+ item.range = [min, 100000];
788
+ }
789
+ });
790
+
791
+ arr.forEach(item => {
792
+ // 1. Check for named breakpoints (e.g., 'sm', 'md')
793
+ if (breakpoints[item.breakpoint] !== undefined) {
794
+ item.range = breakpoints[item.breakpoint];
795
+
796
+ // 2. Check if the input is already an array [min, max] (e.g., [600, 700])
797
+ } else if (Array.isArray(item.breakpoint) && item.breakpoint.length === 2) {
798
+ const [min, max] = item.breakpoint;
799
+
800
+ // Ensure values are treated as numbers and min <= max
801
+ item.range = [
802
+ parseInt(min, 10),
803
+ parseInt(max, 10)
804
+ ];
805
+
806
+ // 3. Assume the input is a single pixel string (e.g., "700px")
807
+ } else {
808
+ // Treat as a min-width override up to a large maximum
809
+ const min = parseInt(item.breakpoint, 10);
810
+ item.range = [min, 100000];
427
811
  }
812
+ });
428
813
 
429
- // 3. Apply new responsive properties with custom logic check.
430
- for (const key in applied) {
431
- if (key !== "breakpoint" && key !== "_value" && key !== "values") {
432
- const value = applied[key];
814
+ // B. Sort by the minimum value of the range (range[0])
815
+ arr.sort((a, b) => a.range[0] - b.range[0]);
433
816
 
434
- // --- Custom Logic: Detect Non-Standard Property ---
435
- if (typeof this[key] === 'function') {
436
- // If a method with the property name exists on 'this',
437
- // call it with the value. (e.g., if key is "mar", calls this.mar(value))
438
- this[key](value);
439
- } else {
440
- // Standard CSS property: set the style directly.
441
- this.res.style[key] = value;
817
+ // C. Find/Ensure the base style object
818
+ let defaultItem = arr.find(item => item.breakpoint === "default");
819
+ if (!defaultItem) {
820
+ defaultItem = { breakpoint: "default", range: breakpoints.default };
821
+ arr.unshift(defaultItem);
822
+ }
823
+
824
+ // --- 2. STATE CAPTURE & RESET PREPARATION ---
825
+
826
+ // D. Capture initial non-responsive styles (for global reset)
827
+ this.prevStyles = {};
828
+ for (const prop in this.res.style) {
829
+ if (this.res.style.hasOwnProperty(prop) && isNaN(parseInt(prop))) {
830
+ this.prevStyles[prop] = this.res.style[prop];
442
831
  }
443
- // --------------------------------------------------
444
- }
445
832
  }
446
- });
447
833
 
834
+ // E. Identify all properties that are responsive (defined in *any* breakpoint)
835
+ const responsiveProps = new Set();
836
+ arr.forEach(bp => {
837
+ Object.keys(bp).forEach(key => {
838
+ if (!excludedKeys.includes(key) && key !== 'range') {
839
+ responsiveProps.add(key);
840
+ }
841
+ });
842
+ });
843
+
844
+ // F. Ensure 'defaultItem' holds the base/reset value for every responsive property.
845
+ responsiveProps.forEach(key => {
846
+ if (defaultItem[key] === undefined) {
847
+ // Use the initial component option (e.g., color: "white") as the true reset value.
848
+ defaultItem[key] = this.options[key] || "initial";
849
+ }
850
+ });
851
+
852
+
853
+ // --- 3. CORE LOGIC: The 'react' function (Responsive Style Application) ---
854
+
855
+ const react = () => {
856
+ const width = window.innerWidth;
857
+ let applied = defaultItem;
858
+
859
+ // 1. RANGE LOGIC: Find the FIRST breakpoint whose range matches the current width.
860
+ // We skip defaultItem since it's the fallback.
861
+ for (let i = 0; i < arr.length; i++) {
862
+ const bp = arr[i];
863
+ const [min, max] = bp.range;
864
+
865
+ if (bp.breakpoint === "default") {
866
+ continue; // Skip default, it's the fallback
867
+ }
868
+
869
+ // Check if width is WITHIN the [min, max] range
870
+ if (width >= min && width <= max) {
871
+ applied = bp;
872
+ break; // Found the exact range, no need to search further.
873
+ }
874
+ }
875
+
876
+ // --- Apply Styles ---
877
+
878
+ // A. Full Reset: Restore all non-responsive styles captured initially.
879
+ for (const key in this.prevStyles) {
880
+ this.res.style[key] = this.prevStyles[key];
881
+ }
882
+
883
+ // B. Clear Responsive Props: Apply the 'default' item's base values.
884
+ responsiveProps.forEach(key => {
885
+ this.res.style[key] = defaultItem[key];
886
+ });
887
+
888
+ // C. Apply Overrides: Apply the properties of the currently matching breakpoint
889
+ for (const key in applied) {
890
+ if (!excludedKeys.includes(key) && key !== 'range') {
891
+ const value = applied[key];
892
+
893
+ if (typeof this[key] === 'function') {
894
+ // Custom property (e.g., pad, size): call the internal method
895
+ this[key](value);
896
+ } else {
897
+ // Standard CSS property: set the style directly.
898
+ this.res.style[key] = value;
899
+ }
900
+ }
901
+ }
902
+ };
903
+
904
+
905
+ // --- 4. EVENT LISTENERS SETUP ---
906
+
907
+ // Prevent duplicate listeners
908
+ if (this._responsiveHandler) window.removeEventListener("resize", this._responsiveHandler);
909
+ this._responsiveHandler = react;
910
+
911
+ window.addEventListener("resize", react);
912
+
913
+ // Defer the initial execution to solve the refresh race condition.
914
+ setTimeout(() => {
915
+ react();
916
+ }, 0);
448
917
  }*/
449
918
 
919
+ /*
450
920
  resprop(arr) {
921
+ // --- 1. CONFIGURATION & NORMALIZATION ---
922
+ const breakpoints = {
923
+ default: 0,
924
+ xs: [0, 577],
925
+ sm: [576, 767],
926
+ md: [768, 991],
927
+ lg: [992, 993],
928
+ xl: [1200, 1399],
929
+ xxl: [1400, 10000]
930
+ };
931
+ // Ensure all control keys are excluded
932
+ const excludedKeys = ['resprop', 'breakpoint', 'value', 'values'];
451
933
 
452
- // 1. Find or create the 'default' breakpoint object in the array
453
- let defaultItem = arr.find(item => item.breakpoint === "default");
454
- if (!defaultItem) {
455
- defaultItem = { breakpoint: "default" };
456
- arr.unshift(defaultItem); // Add it to the start of the array
457
- }
458
-
459
- // 2. Identify base properties from the initial set() call (this.options)
460
- const baseProperties = Object.keys(this.options);
461
-
462
- // Define properties that should NOT be injected into the default reset,
463
- // or properties that are only for control flow.
464
- const excludedKeys = ['resprop', 'breakpoint', '_value', 'values'];
465
-
466
- // 3. Inject missing reset values into the default item
467
- baseProperties.forEach(key => {
468
- // Check if the property is a valid style/prop and not already set in the default item
469
- if (!excludedKeys.includes(key) && defaultItem[key] !== undefined) {
470
-
471
- // Use "initial" as a general CSS reset for styles, or null/undefined
472
- // if the property is custom or needs an explicit clear.
473
- // Since the property comes from this.options, using "initial" is a safe general CSS reset.
474
- defaultItem[key] = "initial";
934
+ // A. Normalize custom breakpoints and assign numeric values to the 'value' property
935
+ arr.forEach(item => {
936
+ if (breakpoints[item.breakpoint] !== undefined) {
937
+ item.value = breakpoints[item.breakpoint];
938
+ } else {
939
+ item.value = parseInt(item.breakpoint, 10); // e.g. "700px" → 700
940
+ }
941
+ });
475
942
 
476
- alert(key);
477
- }
478
- });
943
+ // B. Sort by numeric value ascending
944
+ arr.sort((a, b) => a.value - b.value);
479
945
 
946
+ // C. Find/Ensure the base style object
947
+ let defaultItem = arr.find(item => item.breakpoint === "default");
948
+ if (!defaultItem) {
949
+ defaultItem = { breakpoint: "default", value: 0 };
950
+ arr.unshift(defaultItem);
951
+ }
952
+
953
+ // --- 2. STATE CAPTURE & RESET PREPARATION ---
480
954
 
481
- this.prevStyles = {};
482
-
483
- // 1. Store the initial styles (using for...in loop for object properties)
484
- // Assuming this.res.style is an object containing current styles.
485
- for (const prop in this.res.style) {
486
- if (this.res.style.hasOwnProperty(prop) && isNaN(parseInt(prop))) {
487
- this.prevStyles[prop] = this.res.style[prop];
955
+ // D. Capture initial non-responsive styles (for global reset)
956
+ this.prevStyles = {};
957
+ for (const prop in this.res.style) {
958
+ if (this.res.style.hasOwnProperty(prop) && isNaN(parseInt(prop))) {
959
+ this.prevStyles[prop] = this.res.style[prop];
960
+ }
488
961
  }
489
- }
490
962
 
491
- this._applyResponsive(arr, (applied) => {
492
- console.log("Applying styles for", applied.breakpoint);
963
+ // E. Identify all properties that are responsive (defined in *any* breakpoint)
964
+ const responsiveProps = new Set();
965
+ arr.forEach(bp => {
966
+ Object.keys(bp).forEach(key => {
967
+ if (!excludedKeys.includes(key)) {
968
+ responsiveProps.add(key);
969
+ }
970
+ });
971
+ });
493
972
 
494
- // Reset to initial styles (from before resprop was called)
495
- for (const key in this.prevStyles) {
496
- this.res.style[key] = this.prevStyles[key];
497
- }
973
+ // F. Ensure 'defaultItem' holds the base/reset value for every responsive property.
974
+ responsiveProps.forEach(key => {
975
+ if (defaultItem[key] === undefined) {
976
+ // Use the initial component option (e.g., color: "white") as the true reset value.
977
+ defaultItem[key] = this.options[key] || "initial";
978
+ }
979
+ });
498
980
 
499
- // Apply responsive props
500
- for (const key in applied) {
501
- if (key !== "breakpoint" && key !== "_value" && key !== "values") {
502
- const value = applied[key];
503
-
504
- // --- Modified Custom Logic: Detect and Call Custom Method ---
505
- if (typeof this[key] === 'function') {
506
- // If a method exists, call it.
507
- // NOTE: The custom method (e.g., this.pad) is responsible
508
- // for CLEARING its own associated CSS styles if 'value' implies a reset
509
- // or before applying the new derived styles.
510
- this[key](value);
511
- } else {
512
- // Standard CSS property: set the style directly.
513
- this.res.style[key] = value;
981
+
982
+ // --- 3. CORE LOGIC: The 'react' function (Responsive Style Application) ---
983
+
984
+ const react = () => {
985
+ const width = window.innerWidth;
986
+ let applied = defaultItem;
987
+
988
+ // 1. STANDARD MIN-WIDTH LOGIC: Find the LARGEST breakpoint whose MIN-WIDTH is matched.
989
+ for (let i = 0; i < arr.length; i++) {
990
+ const bp = arr[i];
991
+
992
+ if (bp.breakpoint !== "default" && width >= bp.value) {
993
+ // Since the array is sorted, this continuously updates 'applied' to the widest match.
994
+ applied = bp;
995
+ } else if (width < bp.value) {
996
+ // Optimization: stop searching once the breakpoint value is greater than the current width.
997
+ break;
998
+ }
514
999
  }
515
- // --------------------------------------------------
516
- }
517
- }
1000
+
1001
+ // --- Apply Styles ---
1002
+
1003
+ // A. Full Reset: Restore all non-responsive styles captured initially.
1004
+ for (const key in this.prevStyles) {
1005
+ this.res.style[key] = this.prevStyles[key];
1006
+ }
1007
+
1008
+ // B. Clear Responsive Props: Apply the 'default' item's base values (e.g., "white" color)
1009
+ // This is done for all responsive properties to ensure a clean slate before applying overrides.
1010
+ responsiveProps.forEach(key => {
1011
+ this.res.style[key] = defaultItem[key];
1012
+ });
1013
+
1014
+ // C. Apply Overrides: Apply the properties of the currently matching breakpoint
1015
+ for (const key in applied) {
1016
+ if (!excludedKeys.includes(key)) {
1017
+ const value = applied[key];
1018
+
1019
+ if (typeof this[key] === 'function') {
1020
+ // Custom property (e.g., pad, size): call the internal method
1021
+ this[key](value);
1022
+ } else {
1023
+ // Standard CSS property: set the style directly.
1024
+ this.res.style[key] = value;
1025
+ }
1026
+ }
1027
+ }
1028
+ };
1029
+
1030
+
1031
+ // --- 4. EVENT LISTENERS SETUP (The Fix for Resize/Refresh) ---
1032
+
1033
+ // Prevent duplicate listeners
1034
+ if (this._responsiveHandler) window.removeEventListener("resize", this._responsiveHandler);
1035
+ this._responsiveHandler = react;
1036
+
1037
+ window.addEventListener("resize", react);
1038
+
1039
+ // Run immediately on load/refresh (This ensures the correct styles are applied on initial load)
1040
+ // react();
1041
+ setTimeout(() => {
1042
+ react();
1043
+ }, 0);
1044
+ }*/
1045
+
1046
+
1047
+ resmar(arr) {
1048
+ this._applyResponsive(arr, (applied) => {
1049
+ console.log("Applying margin for", applied.breakpoint);
1050
+ this.mar(applied.values);
518
1051
  });
519
1052
  }
520
1053