@customviews-js/customviews 1.1.10 → 1.2.0

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 (36) hide show
  1. package/README.md +18 -362
  2. package/dist/custom-views.core.cjs.js +2080 -1680
  3. package/dist/custom-views.core.cjs.js.map +1 -1
  4. package/dist/custom-views.core.esm.js +2080 -1680
  5. package/dist/custom-views.core.esm.js.map +1 -1
  6. package/dist/custom-views.esm.js +2080 -1680
  7. package/dist/custom-views.esm.js.map +1 -1
  8. package/dist/custom-views.js +2079 -1679
  9. package/dist/custom-views.js.map +1 -1
  10. package/dist/custom-views.min.js +2 -2
  11. package/dist/custom-views.min.js.map +1 -1
  12. package/dist/types/core/assets-manager.d.ts +1 -1
  13. package/dist/types/core/assets-manager.d.ts.map +1 -1
  14. package/dist/types/core/core.d.ts +28 -2
  15. package/dist/types/core/core.d.ts.map +1 -1
  16. package/dist/types/core/render.d.ts +1 -1
  17. package/dist/types/core/render.d.ts.map +1 -1
  18. package/dist/types/core/tab-manager.d.ts +10 -5
  19. package/dist/types/core/tab-manager.d.ts.map +1 -1
  20. package/dist/types/core/toggle-manager.d.ts +9 -4
  21. package/dist/types/core/toggle-manager.d.ts.map +1 -1
  22. package/dist/types/core/widget.d.ts +20 -11
  23. package/dist/types/core/widget.d.ts.map +1 -1
  24. package/dist/types/lib/custom-views.d.ts +1 -1
  25. package/dist/types/lib/custom-views.d.ts.map +1 -1
  26. package/dist/types/styles/tab-styles.d.ts +1 -1
  27. package/dist/types/styles/tab-styles.d.ts.map +1 -1
  28. package/dist/types/styles/widget-styles.d.ts +1 -1
  29. package/dist/types/styles/widget-styles.d.ts.map +1 -1
  30. package/dist/types/types/types.d.ts +15 -2
  31. package/dist/types/types/types.d.ts.map +1 -1
  32. package/dist/types/utils/icons.d.ts +1 -0
  33. package/dist/types/utils/icons.d.ts.map +1 -1
  34. package/dist/types/utils/scroll-manager.d.ts +26 -0
  35. package/dist/types/utils/scroll-manager.d.ts.map +1 -0
  36. package/package.json +63 -62
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @customviews-js/customviews v1.1.10
2
+ * @customviews-js/customviews v1.2.0
3
3
  * (c) 2025 Chan Ger Teck
4
4
  * Released under the MIT License.
5
5
  */
@@ -297,8 +297,124 @@ class VisibilityManager {
297
297
  }
298
298
  }
299
299
 
300
+ /**
301
+ * Icon utilities for CustomViews widget
302
+ * Centralized SVG icons for better maintainability and reusability
303
+ */
304
+ /**
305
+ * Settings gear icon for modal header
306
+ */
307
+ function getGearIcon() {
308
+ return `<svg class="cv-modal-icon-svg" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
309
+ <path xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" d="M12 8.00002C9.79085 8.00002 7.99999 9.79088 7.99999 12C7.99999 14.2092 9.79085 16 12 16C14.2091 16 16 14.2092 16 12C16 9.79088 14.2091 8.00002 12 8.00002ZM9.99999 12C9.99999 10.8955 10.8954 10 12 10C13.1046 10 14 10.8955 14 12C14 13.1046 13.1046 14 12 14C10.8954 14 9.99999 13.1046 9.99999 12Z" fill="#0F1729"/>
310
+ <path xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" d="M10.7673 1.01709C10.9925 0.999829 11.2454 0.99993 11.4516 1.00001L12.5484 1.00001C12.7546 0.99993 13.0075 0.999829 13.2327 1.01709C13.4989 1.03749 13.8678 1.08936 14.2634 1.26937C14.7635 1.49689 15.1915 1.85736 15.5007 2.31147C15.7454 2.67075 15.8592 3.0255 15.9246 3.2843C15.9799 3.50334 16.0228 3.75249 16.0577 3.9557L16.1993 4.77635L16.2021 4.77788C16.2369 4.79712 16.2715 4.81659 16.306 4.8363L16.3086 4.83774L17.2455 4.49865C17.4356 4.42978 17.6693 4.34509 17.8835 4.28543C18.1371 4.2148 18.4954 4.13889 18.9216 4.17026C19.4614 4.20998 19.9803 4.39497 20.4235 4.70563C20.7734 4.95095 21.0029 5.23636 21.1546 5.4515C21.2829 5.63326 21.4103 5.84671 21.514 6.02029L22.0158 6.86003C22.1256 7.04345 22.2594 7.26713 22.3627 7.47527C22.4843 7.7203 22.6328 8.07474 22.6777 8.52067C22.7341 9.08222 22.6311 9.64831 22.3803 10.1539C22.1811 10.5554 21.9171 10.8347 21.7169 11.0212C21.5469 11.1795 21.3428 11.3417 21.1755 11.4746L20.5 12L21.1755 12.5254C21.3428 12.6584 21.5469 12.8205 21.7169 12.9789C21.9171 13.1653 22.1811 13.4446 22.3802 13.8461C22.631 14.3517 22.7341 14.9178 22.6776 15.4794C22.6328 15.9253 22.4842 16.2797 22.3626 16.5248C22.2593 16.7329 22.1255 16.9566 22.0158 17.14L21.5138 17.9799C21.4102 18.1535 21.2828 18.3668 21.1546 18.5485C21.0028 18.7637 20.7734 19.0491 20.4234 19.2944C19.9803 19.6051 19.4613 19.7901 18.9216 19.8298C18.4954 19.8612 18.1371 19.7852 17.8835 19.7146C17.6692 19.6549 17.4355 19.5703 17.2454 19.5014L16.3085 19.1623L16.306 19.1638C16.2715 19.1835 16.2369 19.2029 16.2021 19.2222L16.1993 19.2237L16.0577 20.0443C16.0228 20.2475 15.9799 20.4967 15.9246 20.7157C15.8592 20.9745 15.7454 21.3293 15.5007 21.6886C15.1915 22.1427 14.7635 22.5032 14.2634 22.7307C13.8678 22.9107 13.4989 22.9626 13.2327 22.983C13.0074 23.0002 12.7546 23.0001 12.5484 23H11.4516C11.2454 23.0001 10.9925 23.0002 10.7673 22.983C10.5011 22.9626 10.1322 22.9107 9.73655 22.7307C9.23648 22.5032 8.80849 22.1427 8.49926 21.6886C8.25461 21.3293 8.14077 20.9745 8.07542 20.7157C8.02011 20.4967 7.97723 20.2475 7.94225 20.0443L7.80068 19.2237L7.79791 19.2222C7.7631 19.2029 7.72845 19.1835 7.69396 19.1637L7.69142 19.1623L6.75458 19.5014C6.5645 19.5702 6.33078 19.6549 6.11651 19.7146C5.86288 19.7852 5.50463 19.8611 5.07841 19.8298C4.53866 19.7901 4.01971 19.6051 3.57654 19.2944C3.2266 19.0491 2.99714 18.7637 2.84539 18.5485C2.71718 18.3668 2.58974 18.1534 2.4861 17.9798L1.98418 17.14C1.87447 16.9566 1.74067 16.7329 1.63737 16.5248C1.51575 16.2797 1.36719 15.9253 1.32235 15.4794C1.26588 14.9178 1.36897 14.3517 1.61976 13.8461C1.81892 13.4446 2.08289 13.1653 2.28308 12.9789C2.45312 12.8205 2.65717 12.6584 2.82449 12.5254L3.47844 12.0054V11.9947L2.82445 11.4746C2.65712 11.3417 2.45308 11.1795 2.28304 11.0212C2.08285 10.8347 1.81888 10.5554 1.61972 10.1539C1.36893 9.64832 1.26584 9.08224 1.3223 8.52069C1.36714 8.07476 1.51571 7.72032 1.63732 7.47528C1.74062 7.26715 1.87443 7.04347 1.98414 6.86005L2.48605 6.02026C2.58969 5.84669 2.71714 5.63326 2.84534 5.45151C2.9971 5.23637 3.22655 4.95096 3.5765 4.70565C4.01966 4.39498 4.53862 4.20999 5.07837 4.17027C5.50458 4.1389 5.86284 4.21481 6.11646 4.28544C6.33072 4.34511 6.56444 4.4298 6.75451 4.49867L7.69141 4.83775L7.69394 4.8363C7.72844 4.8166 7.7631 4.79712 7.79791 4.77788L7.80068 4.77635L7.94225 3.95571C7.97723 3.7525 8.02011 3.50334 8.07542 3.2843C8.14077 3.0255 8.25461 2.67075 8.49926 2.31147C8.80849 1.85736 9.23648 1.49689 9.73655 1.26937C10.1322 1.08936 10.5011 1.03749 10.7673 1.01709ZM14.0938 4.3363C14.011 3.85634 13.9696 3.61637 13.8476 3.43717C13.7445 3.2858 13.6019 3.16564 13.4352 3.0898C13.2378 3.00002 12.9943 3.00002 12.5073 3.00002H11.4927C11.0057 3.00002 10.7621 3.00002 10.5648 3.0898C10.3981 3.16564 10.2555 3.2858 10.1524 3.43717C10.0304 3.61637 9.98895 3.85634 9.90615 4.3363L9.75012 5.24064C9.69445 5.56333 9.66662 5.72467 9.60765 5.84869C9.54975 5.97047 9.50241 6.03703 9.40636 6.13166C9.30853 6.22804 9.12753 6.3281 8.76554 6.52822C8.73884 6.54298 8.71227 6.55791 8.68582 6.57302C8.33956 6.77078 8.16643 6.86966 8.03785 6.90314C7.91158 6.93602 7.83293 6.94279 7.70289 6.93196C7.57049 6.92094 7.42216 6.86726 7.12551 6.7599L6.11194 6.39308C5.66271 6.2305 5.43809 6.14921 5.22515 6.16488C5.04524 6.17811 4.87225 6.23978 4.72453 6.34333C4.5497 6.46589 4.42715 6.67094 4.18206 7.08103L3.72269 7.84965C3.46394 8.2826 3.33456 8.49907 3.31227 8.72078C3.29345 8.90796 3.32781 9.09665 3.41141 9.26519C3.51042 9.4648 3.7078 9.62177 4.10256 9.9357L4.82745 10.5122C5.07927 10.7124 5.20518 10.8126 5.28411 10.9199C5.36944 11.036 5.40583 11.1114 5.44354 11.2504C5.47844 11.379 5.47844 11.586 5.47844 12C5.47844 12.414 5.47844 12.621 5.44354 12.7497C5.40582 12.8887 5.36944 12.9641 5.28413 13.0801C5.20518 13.1875 5.07927 13.2876 4.82743 13.4879L4.10261 14.0643C3.70785 14.3783 3.51047 14.5352 3.41145 14.7349C3.32785 14.9034 3.29349 15.0921 3.31231 15.2793C3.33461 15.501 3.46398 15.7174 3.72273 16.1504L4.1821 16.919C4.4272 17.3291 4.54974 17.5342 4.72457 17.6567C4.8723 17.7603 5.04528 17.8219 5.2252 17.8352C5.43813 17.8508 5.66275 17.7695 6.11199 17.607L7.12553 17.2402C7.42216 17.1328 7.5705 17.0791 7.7029 17.0681C7.83294 17.0573 7.91159 17.064 8.03786 17.0969C8.16644 17.1304 8.33956 17.2293 8.68582 17.427C8.71228 17.4421 8.73885 17.4571 8.76554 17.4718C9.12753 17.6719 9.30853 17.772 9.40635 17.8684C9.50241 17.963 9.54975 18.0296 9.60765 18.1514C9.66662 18.2754 9.69445 18.4367 9.75012 18.7594L9.90615 19.6637C9.98895 20.1437 10.0304 20.3837 10.1524 20.5629C10.2555 20.7142 10.3981 20.8344 10.5648 20.9102C10.7621 21 11.0057 21 11.4927 21H12.5073C12.9943 21 13.2378 21 13.4352 20.9102C13.6019 20.8344 13.7445 20.7142 13.8476 20.5629C13.9696 20.3837 14.011 20.1437 14.0938 19.6637L14.2499 18.7594C14.3055 18.4367 14.3334 18.2754 14.3923 18.1514C14.4502 18.0296 14.4976 17.963 14.5936 17.8684C14.6915 17.772 14.8725 17.6719 15.2344 17.4718C15.2611 17.4571 15.2877 17.4421 15.3141 17.427C15.6604 17.2293 15.8335 17.1304 15.9621 17.0969C16.0884 17.064 16.167 17.0573 16.2971 17.0681C16.4295 17.0791 16.5778 17.1328 16.8744 17.2402L17.888 17.607C18.3372 17.7696 18.5619 17.8509 18.7748 17.8352C18.9547 17.8219 19.1277 17.7603 19.2754 17.6567C19.4502 17.5342 19.5728 17.3291 19.8179 16.919L20.2773 16.1504C20.536 15.7175 20.6654 15.501 20.6877 15.2793C20.7065 15.0921 20.6721 14.9034 20.5885 14.7349C20.4895 14.5353 20.2921 14.3783 19.8974 14.0643L19.1726 13.4879C18.9207 13.2876 18.7948 13.1875 18.7159 13.0801C18.6306 12.9641 18.5942 12.8887 18.5564 12.7497C18.5215 12.6211 18.5215 12.414 18.5215 12C18.5215 11.586 18.5215 11.379 18.5564 11.2504C18.5942 11.1114 18.6306 11.036 18.7159 10.9199C18.7948 10.8126 18.9207 10.7124 19.1725 10.5122L19.8974 9.9357C20.2922 9.62176 20.4896 9.46479 20.5886 9.26517C20.6722 9.09664 20.7065 8.90795 20.6877 8.72076C20.6654 8.49906 20.5361 8.28259 20.2773 7.84964L19.8179 7.08102C19.5728 6.67093 19.4503 6.46588 19.2755 6.34332C19.1277 6.23977 18.9548 6.1781 18.7748 6.16486C18.5619 6.14919 18.3373 6.23048 17.888 6.39307L16.8745 6.75989C16.5778 6.86725 16.4295 6.92093 16.2971 6.93195C16.167 6.94278 16.0884 6.93601 15.9621 6.90313C15.8335 6.86965 15.6604 6.77077 15.3142 6.57302C15.2877 6.55791 15.2611 6.54298 15.2345 6.52822C14.8725 6.3281 14.6915 6.22804 14.5936 6.13166C14.4976 6.03703 14.4502 5.97047 14.3923 5.84869C14.3334 5.72467 14.3055 5.56332 14.2499 5.24064L14.0938 4.3363Z" fill="#0F1729"/>
311
+ </svg>`;
312
+ }
313
+ /**
314
+ * Close/X icon for modal close button
315
+ */
316
+ function getCloseIcon() {
317
+ return `<svg class="cv-modal-close-icon" fill="currentColor" height="20px" viewBox="0 0 256 256" width="20px" xmlns="http://www.w3.org/2000/svg">
318
+ <path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>
319
+ </svg>`;
320
+ }
321
+ /**
322
+ * Reset/refresh icon for reset button
323
+ */
324
+ function getResetIcon() {
325
+ return `<svg class="cv-btn-icon" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
326
+ <path d="M22.719 12A10.719 10.719 0 0 1 1.28 12h.838a9.916 9.916 0 1 0 1.373-5H8v1H2V2h1v4.2A10.71 10.71 0 0 1 22.719 12z"/><path fill="none" d="M0 0h24v24H0z"/>
327
+ </svg>`;
328
+ }
329
+ /**
330
+ * Copy icon for sharing URL button
331
+ */
332
+ function getCopyIcon() {
333
+ return `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="18" height="18" viewBox="0 0 18 18" version="1.1" fill="currentColor">
334
+ <g id="surface1">
335
+ <path d="M 11.273438 0 L 2.546875 0 C 1.746094 0 1.089844 0.613281 1.089844
336
+ 1.363281 L 1.089844 10.910156 L 2.546875 10.910156 L 2.546875 1.363281 L 11.273438
337
+ 1.363281 Z M 13.453125 2.726562 L 5.453125 2.726562 C 4.65625 2.726562 4 3.339844 4
338
+ 4.089844 L 4 13.636719 C 4 14.386719 4.65625 15 5.453125 15 L 13.453125 15 C 14.253906
339
+ 15 14.910156 14.386719 14.910156 13.636719 L 14.910156 4.089844 C 14.910156 3.339844
340
+ 14.253906 2.726562 13.453125 2.726562 Z M 13.453125 13.636719 L 5.453125 13.636719 L
341
+ 5.453125 4.089844 L 13.453125 4.089844 Z M 13.453125 13.636719 "></path>
342
+ </g>
343
+ </svg>`;
344
+ }
345
+ function getTickIcon() {
346
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="2 2 22 22" fill="currentColor">
347
+ <path d="M 19.28125 5.28125 L 9 15.5625 L 4.71875 11.28125 L 3.28125 12.71875 L 8.28125 17.71875
348
+ L 9 18.40625 L 9.71875 17.71875 L 20.71875 6.71875 Z"></path>
349
+ </svg>`;
350
+ }
351
+ function getNavHeadingOnIcon() {
352
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="250" height="181" viewBox="0 0 250 181">
353
+ <rect y="34.5001" width="250" height="146" rx="4" stroke="currentColor" stroke-width="10" fill="none"/>
354
+ <line x1="27" y1="62.0001" x2="77" y2="62.0001" stroke="currentColor" stroke-width="5"/>
355
+ <line x1="27" y1="77.8888" x2="77" y2="77.8888" stroke="currentColor" stroke-width="5"/>
356
+ <line x1="27" y1="97.4454" x2="221" y2="97.4454" stroke="currentColor" stroke-width="5"/>
357
+ <line x1="27" y1="114.555" x2="221" y2="114.555" stroke="currentColor" stroke-width="5"/>
358
+ <line x1="27" y1="132.889" x2="221" y2="132.889" stroke="currentColor" stroke-width="5"/>
359
+ <line x1="27" y1="150" x2="221" y2="150" stroke="currentColor" stroke-width="5"/>
360
+ <line x1="247.5" y1="43.0001" x2="247.5" y2="13.0001" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
361
+ <path d="M185 12.5001L247 12.5001" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
362
+ <line x1="204.09" y1="36.6095" x2="181.698" y2="10.0228" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
363
+ <path d="M125 9.50012L181 9.50012" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
364
+ <path d="M144.305 35.2579L120.095 6.56679" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
365
+ <path d="M120 6.50037L64 6.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
366
+ <path d="M87.1957 36.1024L59 2.50008" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
367
+ <path d="M59 2.50037L3 2.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
368
+ <path d="M2.5 38.5001L2.5 3.00012" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
369
+ </svg>`;
370
+ }
371
+ function getNavHeadingOffIcon() {
372
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="250" height="181" viewBox="0 0 250 181" fill="currentColor">
373
+ <rect y="34.5001" width="250" height="146" rx="4" stroke="currentColor" stroke-width="10" fill="none"/>
374
+ <line x1="27" y1="62" x2="77" y2="62" stroke="currentColor" stroke-width="5"/>
375
+ <line x1="27" y1="77.8887" x2="77" y2="77.8887" stroke="currentColor" stroke-width="5"/>
376
+ <line x1="27" y1="97.4453" x2="221" y2="97.4453" stroke="currentColor" stroke-width="5"/>
377
+ <line x1="27" y1="114.555" x2="221" y2="114.555" stroke="currentColor" stroke-width="5"/>
378
+ <line x1="27" y1="132.889" x2="221" y2="132.889" stroke="currentColor" stroke-width="5"/>
379
+ <line x1="27" y1="150" x2="221" y2="150" stroke="currentColor" stroke-width="5"/>
380
+ </svg>`;
381
+ }
382
+ /**
383
+ * Transition Icon for Navigation Headings
384
+ */
385
+ function getNavDashed() {
386
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="250" height="181" viewBox="0 0 250 181">
387
+ <rect y="34.5001" width="250" height="146" rx="4" stroke="currentColor" stroke-width="10" fill="none"/>
388
+ <line x1="27" y1="62.0001" x2="77" y2="62.0001" stroke="currentColor" stroke-width="5"/>
389
+ <line x1="27" y1="77.8888" x2="77" y2="77.8888" stroke="currentColor" stroke-width="5"/>
390
+ <line x1="27" y1="97.4454" x2="221" y2="97.4454" stroke="currentColor" stroke-width="5"/>
391
+ <line x1="27" y1="114.555" x2="221" y2="114.555" stroke="currentColor" stroke-width="5"/>
392
+ <line x1="27" y1="132.889" x2="221" y2="132.889" stroke="currentColor" stroke-width="5"/>
393
+ <line x1="27" y1="150" x2="221" y2="150" stroke="currentColor" stroke-width="5"/>
394
+ <path d="M245 37.0001V39.5001H250V37.0001H247.5H245ZM250 13.0001C250 11.6194 248.881 10.5001 247.5 10.5001C246.119 10.5001 245 11.6194 245 13.0001H247.5H250ZM250 31.0001C250 29.6194 248.881 28.5001 247.5 28.5001C246.119 28.5001 245 29.6194 245 31.0001H247.5H250ZM245 19.0001C245 20.3808 246.119 21.5001 247.5 21.5001C248.881 21.5001 250 20.3808 250 19.0001H247.5H245ZM247.5 37.0001H250V31.0001H247.5H245V37.0001H247.5ZM247.5 19.0001H250V13.0001H247.5H245V19.0001H247.5Z" fill="currentColor"/>
395
+ <line x1="204.09" y1="36.6095" x2="181.698" y2="10.0228" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
396
+ <path d="M125 9.50012L181 9.50012" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
397
+ <path d="M144.305 35.2579L120.095 6.56679" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
398
+ <path d="M120 6.50037L64 6.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
399
+ <path d="M87.1957 36.1024L59 2.50008" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
400
+ <path d="M59 2.50037L3 2.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
401
+ <path d="M2.5 38.5001L2.5 3.00012" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
402
+ <path d="M185 12.5001L247 12.5001" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
403
+ </svg>`;
404
+ }
405
+ function getPinIcon(isPinned = false) {
406
+ const opacity = isPinned ? '1' : '0.6'; // Optional: additional dimming effect
407
+ return `
408
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" opacity="${opacity}" xmlns="http://www.w3.org/2000/svg">
409
+ <g transform="rotate(45 8 8)">
410
+ <path d="M10.5 2H12V0H4V2H5.5V6L4 7.5V9H7.2V15H8.8V9H12V7.5L10.5 6V2Z"/>
411
+ </g>
412
+ </svg>
413
+ `.trim();
414
+ }
415
+
300
416
  // Constants for selectors
301
- const TABGROUP_SELECTOR = 'cv-tabgroup';
417
+ const TABGROUP_SELECTOR$1 = 'cv-tabgroup';
302
418
  const TAB_SELECTOR = 'cv-tab';
303
419
  const NAV_AUTO_SELECTOR = 'cv-tabgroup[nav="auto"], cv-tabgroup:not([nav])';
304
420
  const NAV_CONTAINER_CLASS = 'cv-tabs-nav';
@@ -314,21 +430,34 @@ class TabManager {
314
430
  return trimmedIds;
315
431
  }
316
432
  /**
317
- * Apply tab selections to all tab groups in the DOM
433
+ * Apply tab selections to a given list of tab group elements
318
434
  */
319
- static applySelections(rootEl, tabs, cfgGroups) {
320
- // Find all cv-tabgroup elements
321
- const tabGroups = rootEl.querySelectorAll(TABGROUP_SELECTOR);
435
+ static applyTabSelections(tabGroups, tabs, cfgGroups) {
322
436
  tabGroups.forEach((groupEl) => {
323
437
  const groupId = groupEl.getAttribute('id');
324
- if (!groupId)
325
- return;
326
438
  // Determine the active tab for this group
327
- const activeTabId = this.resolveActiveTabForGroup(groupId, tabs, cfgGroups, groupEl);
439
+ let activeTabId;
440
+ if (groupId) {
441
+ activeTabId = this.resolveActiveTabForGroup(groupId, tabs, cfgGroups, groupEl);
442
+ }
443
+ else {
444
+ // For standalone groups without id, activate the first tab
445
+ const tabElements = Array.from(groupEl.children).filter((child) => child.tagName.toLowerCase() === TAB_SELECTOR);
446
+ const firstTab = tabElements[0];
447
+ if (firstTab) {
448
+ const firstTabId = firstTab.getAttribute('id') || firstTab.getAttribute('data-cv-internal-id') || '';
449
+ const splitIds = this.splitTabIds(firstTabId);
450
+ activeTabId = splitIds[0] || null;
451
+ }
452
+ else {
453
+ activeTabId = null;
454
+ }
455
+ }
328
456
  // Apply visibility to direct child cv-tab elements only (not nested ones)
329
457
  const tabElements = Array.from(groupEl.children).filter((child) => child.tagName.toLowerCase() === TAB_SELECTOR);
330
458
  tabElements.forEach((tabEl) => {
331
- const tabId = tabEl.getAttribute('id');
459
+ // Use id or internal id
460
+ const tabId = tabEl.getAttribute('id') || tabEl.getAttribute('data-cv-internal-id');
332
461
  if (!tabId)
333
462
  return;
334
463
  // Split IDs and check if any match the active tab
@@ -362,7 +491,9 @@ class TabManager {
362
491
  // 3. Fallback to first direct cv-tab child in DOM
363
492
  const firstTab = Array.from(groupEl.children).find((child) => child.tagName.toLowerCase() === TAB_SELECTOR);
364
493
  if (firstTab) {
365
- const splitIds = this.splitTabIds(firstTab.getAttribute('id') || '');
494
+ // Use id or internal id
495
+ const tabId = firstTab.getAttribute('id') || firstTab.getAttribute('data-cv-internal-id') || '';
496
+ const splitIds = this.splitTabIds(tabId);
366
497
  return splitIds[0] || null;
367
498
  }
368
499
  return null;
@@ -404,15 +535,23 @@ class TabManager {
404
535
  };
405
536
  }
406
537
  /**
407
- * Build navigation for tab groups with nav="auto" (one-time setup)
538
+ * Build navigation for tab groups (one-time setup)
408
539
  */
409
- static buildNavs(rootEl, cfgGroups, onTabClick, onTabDoubleClick) {
410
- // Find all cv-tabgroup elements with nav="auto" or no nav attribute
411
- const tabGroups = rootEl.querySelectorAll(NAV_AUTO_SELECTOR);
540
+ static buildNavs(tabGroups, cfgGroups, onTabClick, onTabDoubleClick) {
541
+ const rootEl = document.body; // Needed for NAV_HIDE_ROOT_CLASS check
412
542
  tabGroups.forEach((groupEl) => {
413
- const groupId = groupEl.getAttribute('id');
414
- if (!groupId)
543
+ // Prevent re-initialization
544
+ if (groupEl.hasAttribute('data-cv-initialized')) {
545
+ return;
546
+ }
547
+ groupEl.setAttribute('data-cv-initialized', 'true');
548
+ // Filter to only build for groups with nav="auto" or no nav attribute
549
+ if (!groupEl.matches(NAV_AUTO_SELECTOR)) {
415
550
  return;
551
+ }
552
+ const groupId = groupEl.getAttribute('id') || null;
553
+ // Note: groupId can be null for standalone tabgroups
554
+ // These won't sync with other groups or persist state
416
555
  // Check if nav already exists - if so, skip building
417
556
  let navContainer = groupEl.querySelector(`.${NAV_CONTAINER_CLASS}`);
418
557
  if (navContainer)
@@ -436,10 +575,13 @@ class TabManager {
436
575
  }
437
576
  groupEl.insertBefore(navContainer, groupEl.firstChild);
438
577
  // Build nav items
439
- tabElements.forEach((tabEl) => {
440
- const rawTabId = tabEl.getAttribute('id');
441
- if (!rawTabId)
442
- return;
578
+ tabElements.forEach((tabEl, index) => {
579
+ let rawTabId = tabEl.getAttribute('id');
580
+ // If tab has no id, generate one based on position
581
+ if (!rawTabId) {
582
+ rawTabId = `${groupId}-tab-${index}`;
583
+ tabEl.setAttribute('data-cv-internal-id', rawTabId);
584
+ }
443
585
  const splitIds = this.splitTabIds(rawTabId);
444
586
  // If multiple IDs, use the first as primary
445
587
  const tabId = splitIds[0] || rawTabId;
@@ -457,8 +599,19 @@ class TabManager {
457
599
  header = headerAttr;
458
600
  }
459
601
  else {
460
- // Use config label or id as fallback
461
- header = this.getTabLabel(tabId, groupId, cfgGroups) || tabId || '';
602
+ // Use config label if available (only if group has an id)
603
+ const configLabel = groupId ? this.getTabLabel(tabId, groupId, cfgGroups) : null;
604
+ if (configLabel) {
605
+ header = configLabel;
606
+ }
607
+ else if (tabEl.getAttribute('id')) {
608
+ // Use the original id if it exists
609
+ header = tabId;
610
+ }
611
+ else {
612
+ // Auto-generate label for tabs without id (Tab 1, Tab 2, etc.)
613
+ header = `Tab ${index + 1}`;
614
+ }
462
615
  }
463
616
  }
464
617
  // Create a single nav link for this tab element
@@ -466,14 +619,30 @@ class TabManager {
466
619
  listItem.className = 'nav-item';
467
620
  const navLink = document.createElement('a');
468
621
  navLink.className = 'nav-link';
469
- navLink.innerHTML = header;
470
622
  navLink.href = '#';
471
623
  navLink.setAttribute('data-tab-id', tabId);
472
624
  navLink.setAttribute('data-raw-tab-id', rawTabId);
473
- navLink.setAttribute('data-group-id', groupId);
625
+ if (groupId) {
626
+ navLink.setAttribute('data-group-id', groupId);
627
+ }
474
628
  navLink.setAttribute('role', 'tab');
629
+ // Create header container with text and pin icon
630
+ const headerContainer = document.createElement('span');
631
+ headerContainer.className = 'cv-tab-header-container';
632
+ const headerText = document.createElement('span');
633
+ headerText.className = 'cv-tab-header-text';
634
+ headerText.innerHTML = header;
635
+ const pinIcon = document.createElement('span');
636
+ pinIcon.className = 'cv-tab-pin-icon';
637
+ pinIcon.innerHTML = getPinIcon(true);
638
+ pinIcon.style.display = 'none'; // Hidden by default
639
+ headerContainer.appendChild(headerText);
640
+ headerContainer.appendChild(pinIcon);
641
+ navLink.appendChild(headerContainer);
475
642
  // Check if any of the split IDs is active
476
- const activeTabId = this.resolveActiveTabForGroup(groupId, {}, cfgGroups, groupEl); // Pass empty tabs for initial state
643
+ const activeTabId = groupId
644
+ ? this.resolveActiveTabForGroup(groupId, {}, cfgGroups, groupEl)
645
+ : (index === 0 ? tabId : null); // For standalone groups, activate first tab
477
646
  const isActive = splitIds.includes(activeTabId || '');
478
647
  if (isActive) {
479
648
  navLink.classList.add('active');
@@ -486,15 +655,14 @@ class TabManager {
486
655
  if (onTabClick) {
487
656
  navLink.addEventListener('click', (e) => {
488
657
  e.preventDefault();
489
- // console.log("Single-click detected");
490
- onTabClick(groupId, tabId, groupEl);
658
+ // For standalone groups (no groupId), use empty string
659
+ onTabClick(groupId || '', tabId, groupEl);
491
660
  });
492
661
  }
493
- // Add double-click handler for sync
494
- if (onTabDoubleClick) {
662
+ // Add double-click handler for sync (only for groups with id)
663
+ if (onTabDoubleClick && groupId) {
495
664
  navLink.addEventListener('dblclick', (e) => {
496
665
  e.preventDefault();
497
- // console.log("Double-click detected");
498
666
  onTabDoubleClick(groupId, tabId, groupEl);
499
667
  });
500
668
  }
@@ -584,8 +752,7 @@ class TabManager {
584
752
  /**
585
753
  * Update active states for all tab groups based on current state
586
754
  */
587
- static updateAllNavActiveStates(rootEl, tabs, cfgGroups) {
588
- const tabGroups = rootEl.querySelectorAll(TABGROUP_SELECTOR);
755
+ static updateAllNavActiveStates(tabGroups, tabs, cfgGroups) {
589
756
  tabGroups.forEach((groupEl) => {
590
757
  const groupId = groupEl.getAttribute('id');
591
758
  if (!groupId)
@@ -621,7 +788,8 @@ class TabManager {
621
788
  static applyTabLocalOnly(groupEl, activeTabId) {
622
789
  const tabElements = Array.from(groupEl.children).filter((child) => child.tagName.toLowerCase() === TAB_SELECTOR);
623
790
  tabElements.forEach((tabEl) => {
624
- const tabId = tabEl.getAttribute('id');
791
+ // Use id or internal id
792
+ const tabId = tabEl.getAttribute('id') || tabEl.getAttribute('data-cv-internal-id');
625
793
  if (!tabId)
626
794
  return;
627
795
  const splitIds = this.splitTabIds(tabId);
@@ -636,7 +804,8 @@ class TabManager {
636
804
  static groupHasTab(groupEl, tabId) {
637
805
  const tabElements = Array.from(groupEl.children).filter((child) => child.tagName.toLowerCase() === TAB_SELECTOR);
638
806
  return tabElements.some((tabEl) => {
639
- const idAttr = tabEl.getAttribute('id') || '';
807
+ // Use id or internal id
808
+ const idAttr = tabEl.getAttribute('id') || tabEl.getAttribute('data-cv-internal-id') || '';
640
809
  const splitIds = this.splitTabIds(idAttr);
641
810
  return splitIds.includes(tabId);
642
811
  });
@@ -646,7 +815,7 @@ class TabManager {
646
815
  */
647
816
  static getTabgroupsWithId(rootEl, sourceGroupId, tabId) {
648
817
  const syncedGroupEls = [];
649
- const allGroupEls = Array.from(rootEl.querySelectorAll(`${TABGROUP_SELECTOR}[id="${sourceGroupId}"]`));
818
+ const allGroupEls = Array.from(rootEl.querySelectorAll(`${TABGROUP_SELECTOR$1}[id="${sourceGroupId}"]`));
650
819
  allGroupEls.forEach((targetGroupEl) => {
651
820
  // Only sync if target group actually contains this tab
652
821
  if (this.groupHasTab(targetGroupEl, tabId)) {
@@ -655,6 +824,35 @@ class TabManager {
655
824
  });
656
825
  return syncedGroupEls;
657
826
  }
827
+ /**
828
+ * Update pin icon visibility for all tab groups based on current state.
829
+ * Shows pin icon for tabs that are in the persisted state (i.e., have been double-clicked).
830
+ */
831
+ static updatePinIcons(tabGroups, tabs) {
832
+ tabGroups.forEach((groupEl) => {
833
+ const groupId = groupEl.getAttribute('id');
834
+ if (!groupId)
835
+ return;
836
+ const persistedTabId = tabs[groupId];
837
+ // Find all nav links in this group
838
+ const navLinks = groupEl.querySelectorAll('.nav-link');
839
+ navLinks.forEach((link) => {
840
+ const rawTabId = link.getAttribute('data-raw-tab-id');
841
+ const pinIcon = link.querySelector('.cv-tab-pin-icon');
842
+ if (!pinIcon || !rawTabId)
843
+ return;
844
+ // Check if persisted tab ID matches any of the split IDs (for multi-ID tabs)
845
+ const splitIds = this.splitTabIds(rawTabId);
846
+ const shouldShowPin = persistedTabId && splitIds.includes(persistedTabId);
847
+ if (shouldShowPin) {
848
+ pinIcon.style.display = 'inline-block';
849
+ }
850
+ else {
851
+ pinIcon.style.display = 'none';
852
+ }
853
+ });
854
+ });
855
+ }
658
856
  }
659
857
 
660
858
  class AssetsManager {
@@ -780,33 +978,31 @@ function renderAssetInto(el, assetId, assetsManager) {
780
978
  }
781
979
  }
782
980
 
783
- // Constants for selectors
784
- const TOGGLE_DATA_SELECTOR = "[data-cv-toggle], [data-customviews-toggle]";
785
- const TOGGLE_ELEMENT_SELECTOR = "cv-toggle";
786
- const TOGGLE_SELECTOR = `${TOGGLE_DATA_SELECTOR}, ${TOGGLE_ELEMENT_SELECTOR}`;
787
981
  /**
788
982
  * ToggleManager handles discovery, visibility, and asset rendering for toggle elements
789
983
  */
790
984
  class ToggleManager {
791
985
  /**
792
- * Apply toggle visibility to all toggle elements in the DOM
986
+ * Apply toggle visibility to a given list of toggle elements
793
987
  */
794
- static applyToggles(rootEl, activeToggles) {
795
- rootEl.querySelectorAll(TOGGLE_SELECTOR).forEach(el => {
988
+ static applyToggles(elements, activeToggles) {
989
+ elements.forEach(el => {
796
990
  const categories = this.getToggleCategories(el);
797
991
  const shouldShow = categories.some(cat => activeToggles.includes(cat));
798
992
  this.applyToggleVisibility(el, shouldShow);
799
993
  });
800
994
  }
801
995
  /**
802
- * Render assets into toggle elements that are currently visible
996
+ * Render assets into a given list of toggle elements that are currently visible
803
997
  */
804
- static renderAssets(rootEl, activeToggles, assetsManager) {
805
- rootEl.querySelectorAll(TOGGLE_SELECTOR).forEach(el => {
998
+ static renderAssets(elements, activeToggles, assetsManager) {
999
+ elements.forEach(el => {
806
1000
  const categories = this.getToggleCategories(el);
807
1001
  const toggleId = this.getToggleId(el);
808
- if (toggleId && categories.some(cat => activeToggles.includes(cat))) {
1002
+ const isRendered = el.dataset.cvRendered === 'true';
1003
+ if (toggleId && !isRendered && categories.some(cat => activeToggles.includes(cat))) {
809
1004
  renderAssetInto(el, toggleId, assetsManager);
1005
+ el.dataset.cvRendered = 'true';
810
1006
  }
811
1007
  });
812
1008
  }
@@ -842,193 +1038,329 @@ class ToggleManager {
842
1038
  el.classList.remove('cv-visible');
843
1039
  }
844
1040
  }
1041
+ /**
1042
+ * Scans a given DOM subtree for toggle elements and initializes them.
1043
+ * This includes applying visibility and rendering assets.
1044
+ */
1045
+ static initializeToggles(root, activeToggles, assetsManager) {
1046
+ const elements = [];
1047
+ if (root.matches('[data-cv-toggle], [data-customviews-toggle], cv-toggle')) {
1048
+ elements.push(root);
1049
+ }
1050
+ root.querySelectorAll('[data-cv-toggle], [data-customviews-toggle], cv-toggle').forEach(el => elements.push(el));
1051
+ if (elements.length === 0)
1052
+ return;
1053
+ this.applyToggles(elements, activeToggles);
1054
+ this.renderAssets(elements, activeToggles, assetsManager);
1055
+ }
1056
+ }
1057
+
1058
+ // src/utils/scroll-manager.ts
1059
+ class ScrollManager {
1060
+ /**
1061
+ * Finds the highest tab group currently in the viewport.
1062
+ * This is intended to be called BEFORE the state changes, to identify which element to scroll to.
1063
+ * @returns The HTMLElement of the highest visible tab group, or null if none are found.
1064
+ */
1065
+ static findHighestVisibleTabGroup() {
1066
+ // console.log('[ScrollManager] Finding highest visible tab group.');
1067
+ // 1. Detect fixed/sticky header and calculate its height for offset.
1068
+ let headerOffset = 0;
1069
+ const headerEl = document.querySelector('header');
1070
+ let isHeaderFixedOrSticky = false;
1071
+ if (headerEl) {
1072
+ const headerStyle = window.getComputedStyle(headerEl);
1073
+ isHeaderFixedOrSticky = ['fixed', 'sticky'].includes(headerStyle.position);
1074
+ if (isHeaderFixedOrSticky) {
1075
+ headerOffset = headerEl.getBoundingClientRect().height;
1076
+ }
1077
+ }
1078
+ const contentTop = headerOffset; // Viewport-relative position where content begins.
1079
+ // 2. Find all tab groups, filtering out any inside the main header.
1080
+ const allTabGroups = Array.from(document.querySelectorAll('cv-tabgroup'));
1081
+ const candidateGroups = allTabGroups.filter(groupEl => {
1082
+ if (isHeaderFixedOrSticky && headerEl && groupEl.closest('header') === headerEl) {
1083
+ return false;
1084
+ }
1085
+ return true;
1086
+ });
1087
+ // 3. Find the highest group that is visible in the content area (below the header).
1088
+ let highestVisibleGroup = null;
1089
+ let highestVisibleGroupTop = Infinity;
1090
+ for (const groupEl of candidateGroups) {
1091
+ const rect = groupEl.getBoundingClientRect();
1092
+ // A group is "visible" if it's not completely above the content area or completely below the viewport.
1093
+ const isVisibleInContentArea = rect.bottom > contentTop && rect.top < window.innerHeight;
1094
+ if (isVisibleInContentArea) {
1095
+ // We want the one with the smallest 'top' value (closest to the top of the viewport).
1096
+ if (rect.top < highestVisibleGroupTop) {
1097
+ highestVisibleGroup = groupEl;
1098
+ highestVisibleGroupTop = rect.top;
1099
+ }
1100
+ }
1101
+ }
1102
+ return highestVisibleGroup;
1103
+ }
1104
+ /**
1105
+ * Scrolls the page to align the given tab group's header (or the group itself)
1106
+ * to the top of the viewport, accounting for a fixed/sticky page header.
1107
+ * This should be called AFTER the content has changed.
1108
+ * @param groupEl The tab group element to scroll to.
1109
+ */
1110
+ static scrollToTabGroup(groupEl) {
1111
+ // console.log('[ScrollManager] Scrolling to tab group:', groupEl);
1112
+ // 1. Detect fixed/sticky header and calculate its height for offset.
1113
+ let headerOffset = 0;
1114
+ const headerEl = document.querySelector('header');
1115
+ if (headerEl) {
1116
+ const headerStyle = window.getComputedStyle(headerEl);
1117
+ if (['fixed', 'sticky'].includes(headerStyle.position)) {
1118
+ headerOffset = headerEl.getBoundingClientRect().height;
1119
+ }
1120
+ }
1121
+ const PADDING_BELOW_HEADER = 20; // Extra space.
1122
+ // 2. Calculate the target position.
1123
+ const targetElementRect = groupEl.getBoundingClientRect();
1124
+ // Calculate the absolute top position of the target element in the document.
1125
+ const scrollTargetY = targetElementRect.top + window.scrollY;
1126
+ // Adjust for the header offset and padding to position it just below the header.
1127
+ const finalScrollY = scrollTargetY - headerOffset - PADDING_BELOW_HEADER;
1128
+ // change to 'auto' if instant scroll is preferred.
1129
+ window.scrollTo({
1130
+ top: finalScrollY,
1131
+ behavior: 'smooth',
1132
+ });
1133
+ }
1134
+ /**
1135
+ * Adjusts the scroll position to keep a specific element in the same visual location
1136
+ * after a content change. This is useful for preventing the page from jumping when
1137
+ * content above the element is added or removed.
1138
+ * @param scrollAnchor An object containing the element to anchor and its initial top position.
1139
+ */
1140
+ static handleScrollAnchor(scrollAnchor) {
1141
+ requestAnimationFrame(() => {
1142
+ const { element, top: initialTop } = scrollAnchor;
1143
+ const newTop = element.getBoundingClientRect().top;
1144
+ const scrollDelta = newTop - initialTop;
1145
+ // Only scroll if there's a noticeable change to avoid jitter
1146
+ if (Math.abs(scrollDelta) > 1) {
1147
+ window.scrollBy({
1148
+ top: scrollDelta,
1149
+ behavior: 'instant'
1150
+ });
1151
+ }
1152
+ });
1153
+ }
845
1154
  }
846
1155
 
847
1156
  /**
848
1157
  * Styles for toggle visibility and animations
849
1158
  */
850
- const TOGGLE_STYLES = `
851
- /* Core toggle visibility transitions */
852
- [data-cv-toggle], [data-customviews-toggle], cv-toggle {
853
- transition: opacity 150ms ease,
854
- transform 150ms ease,
855
- max-height 200ms ease,
856
- margin 150ms ease;
857
- will-change: opacity, transform, max-height, margin;
858
- }
859
-
860
- .cv-visible {
861
- opacity: 1 !important;
862
- transform: translateY(0) !important;
863
- max-height: var(--cv-max-height, 9999px) !important;
864
- }
865
-
866
- .cv-hidden {
867
- opacity: 0 !important;
868
- transform: translateY(-4px) !important;
869
- pointer-events: none !important;
870
- padding-top: 0 !important;
871
- padding-bottom: 0 !important;
872
- border-top-width: 0 !important;
873
- border-bottom-width: 0 !important;
874
- max-height: 0 !important;
875
- margin-top: 0 !important;
876
- margin-bottom: 0 !important;
877
- overflow: hidden !important;
878
- }
1159
+ const TOGGLE_STYLES = `
1160
+ /* Core toggle visibility transitions */
1161
+ [data-cv-toggle], [data-customviews-toggle], cv-toggle {
1162
+ transition: opacity 150ms ease,
1163
+ transform 150ms ease,
1164
+ max-height 200ms ease,
1165
+ margin 150ms ease;
1166
+ will-change: opacity, transform, max-height, margin;
1167
+ }
1168
+
1169
+ .cv-visible {
1170
+ opacity: 1 !important;
1171
+ transform: translateY(0) !important;
1172
+ max-height: var(--cv-max-height, 9999px) !important;
1173
+ }
1174
+
1175
+ .cv-hidden {
1176
+ opacity: 0 !important;
1177
+ transform: translateY(-4px) !important;
1178
+ pointer-events: none !important;
1179
+ padding-top: 0 !important;
1180
+ padding-bottom: 0 !important;
1181
+ border-top-width: 0 !important;
1182
+ border-bottom-width: 0 !important;
1183
+ max-height: 0 !important;
1184
+ margin-top: 0 !important;
1185
+ margin-bottom: 0 !important;
1186
+ overflow: hidden !important;
1187
+ }
879
1188
  `;
880
1189
 
881
1190
  /**
882
1191
  * Styles for tab groups and tab navigation
883
1192
  */
884
- const TAB_STYLES = `
885
- /* Tab navigation styles - Bootstrap-style tabs matching MarkBind */
886
- .cv-tabs-nav {
887
- display: flex;
888
- flex-wrap: wrap;
889
- padding-left: 0;
890
- margin-top: 0.5rem;
891
- margin-bottom: 1rem;
892
- list-style: none;
893
- border-bottom: 1px solid #dee2e6;
894
-
895
- align-items: stretch;
896
- }
897
-
898
- .cv-tabs-nav .nav-item {
899
- margin-bottom: -1px;
900
- list-style: none;
901
- display: flex; /* was inline-block → make flex to stretch height */
902
- align-items: stretch; /* stretch link to full height */
903
- }
904
-
905
- .cv-tabs-nav .nav-link {
906
- display: flex;
907
- align-items: center;
908
- justify-content: center;
909
- padding: 0.5rem 1rem;
910
- color: #495057;
911
- text-decoration: none;
912
- background-color: transparent;
913
- border: 1px solid transparent;
914
- border-top-left-radius: 0.25rem;
915
- border-top-right-radius: 0.25rem;
916
- transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
917
- cursor: pointer;
918
- min-height: 2.5rem;
919
- box-sizing: border-box;
920
- }
921
-
922
- .cv-tabs-nav .nav-link p {
923
- margin: 0; /* remove default margins */
924
- display: inline; /* or inline-block */
925
- }
926
-
927
- .cv-tabs-nav .nav-link:hover,
928
- .cv-tabs-nav .nav-link:focus {
929
- border-color: #e9ecef #e9ecef #dee2e6;
930
- isolation: isolate;
931
- }
932
-
933
- .cv-tabs-nav .nav-link.active {
934
- color: #495057;
935
- background-color: #fff;
936
- border-color: #dee2e6 #dee2e6 #fff;
937
- }
938
-
939
- .cv-tabs-nav .nav-link:focus {
940
- outline: 0;
941
- box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
942
- }
943
-
944
- /* Legacy button-based nav (deprecated, kept for compatibility) */
945
- .cv-tabs-nav-item {
946
- background: none;
947
- border: none;
948
- border-bottom: 2px solid transparent;
949
- padding: 0.5rem 1rem;
950
- cursor: pointer;
951
- font-size: 1rem;
952
- color: #6c757d;
953
- transition: color 150ms ease, border-color 150ms ease;
954
- }
955
-
956
- .cv-tabs-nav-item:hover {
957
- color: #495057;
958
- border-bottom-color: #dee2e6;
959
- }
960
-
961
- .cv-tabs-nav-item.active {
962
- color: #007bff;
963
- border-bottom-color: #007bff;
964
- font-weight: 500;
965
- }
966
-
967
- .cv-tabs-nav-item:focus {
968
- outline: 2px solid #007bff;
969
- outline-offset: 2px;
970
- }
971
-
972
- /* Tab panel base styles */
973
- cv-tab {
974
- display: block;
975
- }
976
-
977
- /* Hide cv-tab-header source element; content is extracted to nav link */
978
- cv-tab-header {
979
- display: none !important;
980
- }
981
-
982
- /* Allow cv-tab-body to flow naturally */
983
- cv-tab-body {
984
- display: block;
985
- }
986
-
987
- /* Override visibility for tab panels - use display instead of collapse animation */
988
- cv-tab.cv-hidden {
989
- display: none !important;
990
- }
991
-
992
- cv-tab.cv-visible {
993
- display: block !important;
994
- }
995
-
996
- cv-tabgroup {
997
- display: block;
998
- margin-bottom: 1.5rem;
999
- }
1000
-
1001
- /* Bottom border line for tab groups */
1002
- .cv-tabgroup-bottom-border {
1003
- border-bottom: 1px solid #dee2e6;
1004
- margin-top: 1rem;
1005
- }
1006
-
1007
- /* Tab content wrapper */
1008
- .cv-tab-content {
1009
- padding: 1rem 0;
1010
- }
1011
-
1012
- /* Viewer-controlled nav visibility: hide nav containers when requested */
1013
- .cv-tabs-nav-hidden {
1014
- display: none !important;
1015
- }
1016
-
1017
- /* Print-friendly: hide tab navigation when printing to reduce clutter */
1018
- @media print {
1019
- .cv-tabs-nav {
1020
- display: none !important;
1021
- }
1022
- }
1193
+ const TAB_STYLES = `
1194
+ /* Tab navigation styles - Bootstrap-style tabs matching MarkBind */
1195
+ .cv-tabs-nav {
1196
+ display: flex;
1197
+ flex-wrap: wrap;
1198
+ padding-left: 0;
1199
+ margin-top: 0.5rem;
1200
+ margin-bottom: 1rem;
1201
+ list-style: none;
1202
+ border-bottom: 1px solid #dee2e6;
1203
+
1204
+ align-items: stretch;
1205
+ }
1206
+
1207
+ .cv-tabs-nav .nav-item {
1208
+ margin-bottom: -1px;
1209
+ list-style: none;
1210
+ display: flex; /* was inline-block → make flex to stretch height */
1211
+ align-items: stretch; /* stretch link to full height */
1212
+ }
1213
+
1214
+ .cv-tabs-nav .nav-link {
1215
+ display: flex;
1216
+ align-items: center;
1217
+ justify-content: center;
1218
+ padding: 0.5rem 1rem;
1219
+ color: #495057;
1220
+ text-decoration: none;
1221
+ background-color: transparent;
1222
+ border: 1px solid transparent;
1223
+ border-top-left-radius: 0.25rem;
1224
+ border-top-right-radius: 0.25rem;
1225
+ transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
1226
+ cursor: pointer;
1227
+ min-height: 2.5rem;
1228
+ box-sizing: border-box;
1229
+ }
1230
+
1231
+ .cv-tabs-nav .nav-link p {
1232
+ margin: 0; /* remove default margins */
1233
+ display: inline; /* or inline-block */
1234
+ }
1235
+
1236
+ /* Tab header container with pin icon */
1237
+ .cv-tab-header-container {
1238
+ display: flex;
1239
+ align-items: center;
1240
+ gap: 0.5rem;
1241
+ }
1242
+
1243
+ .cv-tab-header-text {
1244
+ flex: 1;
1245
+ }
1246
+
1247
+ .cv-tab-pin-icon {
1248
+ display: inline-block;
1249
+ line-height: 0;
1250
+ flex-shrink: 0;
1251
+ }
1252
+
1253
+ .cv-tab-pin-icon svg {
1254
+ vertical-align: middle;
1255
+ width: 14px;
1256
+ height: 14px;
1257
+ }
1258
+
1259
+ .cv-tabs-nav .nav-link:hover,
1260
+ .cv-tabs-nav .nav-link:focus {
1261
+ border-color: #e9ecef #e9ecef #dee2e6;
1262
+ isolation: isolate;
1263
+ }
1264
+
1265
+ .cv-tabs-nav .nav-link.active {
1266
+ color: #495057;
1267
+ background-color: #fff;
1268
+ border-color: #dee2e6 #dee2e6 #fff;
1269
+ }
1270
+
1271
+ .cv-tabs-nav .nav-link:focus {
1272
+ outline: 0;
1273
+ box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
1274
+ }
1275
+
1276
+ /* Legacy button-based nav (deprecated, kept for compatibility) */
1277
+ .cv-tabs-nav-item {
1278
+ background: none;
1279
+ border: none;
1280
+ border-bottom: 2px solid transparent;
1281
+ padding: 0.5rem 1rem;
1282
+ cursor: pointer;
1283
+ font-size: 1rem;
1284
+ color: #6c757d;
1285
+ transition: color 150ms ease, border-color 150ms ease;
1286
+ }
1287
+
1288
+ .cv-tabs-nav-item:hover {
1289
+ color: #495057;
1290
+ border-bottom-color: #dee2e6;
1291
+ }
1292
+
1293
+ .cv-tabs-nav-item.active {
1294
+ color: #007bff;
1295
+ border-bottom-color: #007bff;
1296
+ font-weight: 500;
1297
+ }
1298
+
1299
+ .cv-tabs-nav-item:focus {
1300
+ outline: 2px solid #007bff;
1301
+ outline-offset: 2px;
1302
+ }
1303
+
1304
+ /* Tab panel base styles */
1305
+ cv-tab {
1306
+ display: block;
1307
+ }
1308
+
1309
+ /* Hide cv-tab-header source element; content is extracted to nav link */
1310
+ cv-tab-header {
1311
+ display: none !important;
1312
+ }
1313
+
1314
+ /* Allow cv-tab-body to flow naturally */
1315
+ cv-tab-body {
1316
+ display: block;
1317
+ }
1318
+
1319
+ /* Override visibility for tab panels - use display instead of collapse animation */
1320
+ cv-tab.cv-hidden {
1321
+ display: none !important;
1322
+ }
1323
+
1324
+ cv-tab.cv-visible {
1325
+ display: block !important;
1326
+ }
1327
+
1328
+ cv-tabgroup {
1329
+ display: block;
1330
+ margin-bottom: 1.5rem;
1331
+ }
1332
+
1333
+ /* Bottom border line for tab groups */
1334
+ .cv-tabgroup-bottom-border {
1335
+ border-bottom: 1px solid #dee2e6;
1336
+ margin-top: 1rem;
1337
+ }
1338
+
1339
+ /* Tab content wrapper */
1340
+ .cv-tab-content {
1341
+ padding: 1rem 0;
1342
+ }
1343
+
1344
+ /* Viewer-controlled nav visibility: hide nav containers when requested */
1345
+ .cv-tabs-nav-hidden {
1346
+ display: none !important;
1347
+ }
1348
+
1349
+ /* Print-friendly: hide tab navigation when printing to reduce clutter */
1350
+ @media print {
1351
+ .cv-tabs-nav {
1352
+ display: none !important;
1353
+ }
1354
+ }
1023
1355
  `;
1024
1356
 
1025
1357
  /**
1026
1358
  * Combined core styles for toggles and tabs
1027
1359
  */
1028
- const CORE_STYLES = `
1029
- ${TOGGLE_STYLES}
1030
-
1031
- ${TAB_STYLES}
1360
+ const CORE_STYLES = `
1361
+ ${TOGGLE_STYLES}
1362
+
1363
+ ${TAB_STYLES}
1032
1364
  `;
1033
1365
  /**
1034
1366
  * Add styles for hiding and showing toggles animations and transitions to the document head
@@ -1044,11 +1376,18 @@ function injectCoreStyles() {
1044
1376
  document.head.appendChild(style);
1045
1377
  }
1046
1378
 
1379
+ const TOGGLE_SELECTOR = "[data-cv-toggle], [data-customviews-toggle], cv-toggle";
1380
+ const TABGROUP_SELECTOR = 'cv-tabgroup';
1047
1381
  class CustomViewsCore {
1048
1382
  rootEl;
1049
1383
  assetsManager;
1050
1384
  persistenceManager;
1051
1385
  visibilityManager;
1386
+ observer = null;
1387
+ componentRegistry = {
1388
+ toggles: new Set(),
1389
+ tabGroups: new Set(),
1390
+ };
1052
1391
  config;
1053
1392
  stateChangeListeners = [];
1054
1393
  showUrlEnabled;
@@ -1062,6 +1401,57 @@ class CustomViewsCore {
1062
1401
  this.showUrlEnabled = opt.showUrl ?? false;
1063
1402
  this.lastAppliedState = this.cloneState(this.getComputedDefaultState());
1064
1403
  }
1404
+ /**
1405
+ * Scan the given element for toggles and tab groups, register them
1406
+ * Returns true if new components were found
1407
+ */
1408
+ scan(element) {
1409
+ let newComponentsFound = false;
1410
+ // Scan for toggles
1411
+ const toggles = Array.from(element.querySelectorAll(TOGGLE_SELECTOR));
1412
+ if (element.matches(TOGGLE_SELECTOR)) {
1413
+ toggles.unshift(element);
1414
+ }
1415
+ toggles.forEach((toggle) => {
1416
+ if (!this.componentRegistry.toggles.has(toggle)) {
1417
+ this.componentRegistry.toggles.add(toggle);
1418
+ newComponentsFound = true;
1419
+ }
1420
+ });
1421
+ // Scan for tab groups
1422
+ const tabGroups = Array.from(element.querySelectorAll(TABGROUP_SELECTOR));
1423
+ if (element.matches(TABGROUP_SELECTOR)) {
1424
+ tabGroups.unshift(element);
1425
+ }
1426
+ tabGroups.forEach((tabGroup) => {
1427
+ if (!this.componentRegistry.tabGroups.has(tabGroup)) {
1428
+ this.componentRegistry.tabGroups.add(tabGroup);
1429
+ newComponentsFound = true;
1430
+ }
1431
+ });
1432
+ return newComponentsFound;
1433
+ }
1434
+ /**
1435
+ * Unscan the given element for toggles and tab groups, de-register them
1436
+ */
1437
+ unscan(element) {
1438
+ // Unscan for toggles
1439
+ const toggles = Array.from(element.querySelectorAll(TOGGLE_SELECTOR));
1440
+ if (element.matches(TOGGLE_SELECTOR)) {
1441
+ toggles.unshift(element);
1442
+ }
1443
+ toggles.forEach((toggle) => {
1444
+ this.componentRegistry.toggles.delete(toggle);
1445
+ });
1446
+ // Unscan for tab groups
1447
+ const tabGroups = Array.from(element.querySelectorAll(TABGROUP_SELECTOR));
1448
+ if (element.matches(TABGROUP_SELECTOR)) {
1449
+ tabGroups.unshift(element);
1450
+ }
1451
+ tabGroups.forEach((tabGroup) => {
1452
+ this.componentRegistry.tabGroups.delete(tabGroup);
1453
+ });
1454
+ }
1065
1455
  getConfig() {
1066
1456
  return this.config;
1067
1457
  }
@@ -1096,7 +1486,7 @@ class CustomViewsCore {
1096
1486
  });
1097
1487
  }
1098
1488
  const computedState = {
1099
- toggles: [...(this.config.allToggles || [])],
1489
+ toggles: this.config.toggles?.map(t => t.id) || [],
1100
1490
  tabs
1101
1491
  };
1102
1492
  return computedState;
@@ -1135,14 +1525,35 @@ class CustomViewsCore {
1135
1525
  // Inject styles, setup listeners and call rendering logic
1136
1526
  async init() {
1137
1527
  injectCoreStyles();
1138
- // Build navigation once (with click and double-click handlers)
1139
- TabManager.buildNavs(this.rootEl, this.config.tabGroups,
1528
+ this.scan(this.rootEl);
1529
+ // Initialize all components found on initial scan
1530
+ this.initializeNewComponents();
1531
+ // Apply stored nav visibility preference on page load
1532
+ const navPref = this.persistenceManager.getPersistedTabNavVisibility();
1533
+ if (navPref !== null) {
1534
+ TabManager.setNavsVisibility(this.rootEl, navPref);
1535
+ }
1536
+ // For session history, clicks on back/forward button
1537
+ window.addEventListener("popstate", () => {
1538
+ this.loadAndCallApplyState();
1539
+ });
1540
+ this.loadAndCallApplyState();
1541
+ this.initObserver();
1542
+ }
1543
+ initializeNewComponents() {
1544
+ // Build navigation for any newly added tab groups.
1545
+ // The `data-cv-initialized` attribute in `buildNavs` prevents re-initialization.
1546
+ TabManager.buildNavs(Array.from(this.componentRegistry.tabGroups), this.config.tabGroups,
1140
1547
  // Single click: update clicked group only (local, no persistence)
1141
1548
  (groupId, tabId, groupEl) => {
1142
1549
  this.setActiveTab(groupId, tabId, groupEl);
1143
1550
  },
1144
1551
  // Double click: sync across all tabgroups with same id (with persistence)
1145
- (groupId, tabId, _groupEl) => {
1552
+ (groupId, tabId, groupEl) => {
1553
+ // 1. Record position before state change
1554
+ const navHeader = groupEl.querySelector('.cv-tabs-nav');
1555
+ const anchorElement = navHeader instanceof HTMLElement ? navHeader : groupEl;
1556
+ const initialTop = anchorElement.getBoundingClientRect().top;
1146
1557
  const currentTabs = this.getCurrentActiveTabs();
1147
1558
  currentTabs[groupId] = tabId;
1148
1559
  const currentToggles = this.getCurrentActiveToggles();
@@ -1150,19 +1561,51 @@ class CustomViewsCore {
1150
1561
  toggles: currentToggles,
1151
1562
  tabs: currentTabs
1152
1563
  };
1153
- // applyState() will handle all visual updates via renderState()
1154
- this.applyState(newState);
1564
+ // 2. Apply state with scroll anchor information
1565
+ this.applyState(newState, {
1566
+ scrollAnchor: { element: anchorElement, top: initialTop }
1567
+ });
1155
1568
  });
1156
- // Apply stored nav visibility preference on page load
1157
- const navPref = this.persistenceManager.getPersistedTabNavVisibility();
1158
- if (navPref !== null) {
1159
- TabManager.setNavsVisibility(this.rootEl, navPref);
1160
- }
1161
- // For session history, clicks on back/forward button
1162
- window.addEventListener("popstate", () => {
1163
- this.loadAndCallApplyState();
1569
+ // Future components (e.g., toggles, widgets) can be initialized here
1570
+ }
1571
+ initObserver() {
1572
+ this.observer = new MutationObserver((mutations) => {
1573
+ let newComponentsFound = false;
1574
+ for (const mutation of mutations) {
1575
+ if (mutation.type === 'childList') {
1576
+ mutation.addedNodes.forEach((node) => {
1577
+ if (node instanceof Element) {
1578
+ // Scan the new node for components and add them to the registry
1579
+ if (this.scan(node)) {
1580
+ newComponentsFound = true;
1581
+ }
1582
+ }
1583
+ });
1584
+ mutation.removedNodes.forEach((node) => {
1585
+ if (node instanceof Element) {
1586
+ // Unscan the removed node to cleanup the registry
1587
+ this.unscan(node);
1588
+ }
1589
+ });
1590
+ }
1591
+ }
1592
+ if (newComponentsFound) {
1593
+ // Initialize navs for new components.
1594
+ this.initializeNewComponents();
1595
+ // Re-apply the last known state. renderState will handle disconnecting
1596
+ // the observer to prevent infinite loops.
1597
+ if (this.lastAppliedState) {
1598
+ this.renderState(this.lastAppliedState);
1599
+ }
1600
+ }
1164
1601
  });
1165
- this.loadAndCallApplyState();
1602
+ // Observe only the root element to avoid performance issues on large pages.
1603
+ if (this.rootEl) {
1604
+ this.observer.observe(this.rootEl, {
1605
+ childList: true,
1606
+ subtree: true,
1607
+ });
1608
+ }
1166
1609
  }
1167
1610
  // Priority: URL state > persisted state > config default > computed default
1168
1611
  // Also filters using the visibility manager to persist selection
@@ -1185,8 +1628,16 @@ class CustomViewsCore {
1185
1628
  }
1186
1629
  /**
1187
1630
  * Apply a custom state, saves to localStorage and updates the URL
1631
+ * Add 'source' in options to indicate the origin of the state change
1632
+ * (e.g., 'widget' to trigger scroll behavior)
1633
+ * Add scrollAnchor in options to maintain scroll position of a specific element
1188
1634
  */
1189
- applyState(state) {
1635
+ applyState(state, options) {
1636
+ // console.log(`[Core] applyState called with source: ${options?.source}`, state);
1637
+ let groupToScrollTo = null;
1638
+ if (options?.source === 'widget') {
1639
+ groupToScrollTo = ScrollManager.findHighestVisibleTabGroup();
1640
+ }
1190
1641
  const snapshot = this.cloneState(state);
1191
1642
  this.renderState(snapshot);
1192
1643
  this.persistenceManager.persistState(snapshot);
@@ -1196,22 +1647,46 @@ class CustomViewsCore {
1196
1647
  else {
1197
1648
  URLStateManager.clearURL();
1198
1649
  }
1650
+ if (groupToScrollTo) {
1651
+ // Defer scrolling until after the DOM has been updated by renderState
1652
+ queueMicrotask(() => {
1653
+ ScrollManager.scrollToTabGroup(groupToScrollTo);
1654
+ });
1655
+ }
1656
+ // Handle scroll anchoring for double-clicks
1657
+ // scroll to original position after content changes
1658
+ if (options?.scrollAnchor) {
1659
+ ScrollManager.handleScrollAnchor(options.scrollAnchor);
1660
+ }
1199
1661
  }
1200
- /** Render all toggles for the current state */
1662
+ /**
1663
+ * Renders state on components in ComponentRegistry
1664
+ * Applies the given state.
1665
+ * Disconnects the mutation observer during rendering to prevent loops
1666
+ **/
1201
1667
  renderState(state) {
1668
+ this.observer?.disconnect();
1202
1669
  this.lastAppliedState = this.cloneState(state);
1203
1670
  const toggles = state?.toggles || [];
1204
1671
  const finalToggles = this.visibilityManager.filterVisibleToggles(toggles);
1672
+ const toggleElements = Array.from(this.componentRegistry.toggles);
1673
+ const tabGroupElements = Array.from(this.componentRegistry.tabGroups);
1205
1674
  // Apply toggle visibility
1206
- ToggleManager.applyToggles(this.rootEl, finalToggles);
1675
+ ToggleManager.applyToggles(toggleElements, finalToggles);
1207
1676
  // Render assets into toggles
1208
- ToggleManager.renderAssets(this.rootEl, finalToggles, this.assetsManager);
1677
+ ToggleManager.renderAssets(toggleElements, finalToggles, this.assetsManager);
1209
1678
  // Apply tab selections
1210
- TabManager.applySelections(this.rootEl, state.tabs || {}, this.config.tabGroups);
1679
+ TabManager.applyTabSelections(tabGroupElements, state.tabs || {}, this.config.tabGroups);
1211
1680
  // Update nav active states (without rebuilding)
1212
- TabManager.updateAllNavActiveStates(this.rootEl, state.tabs || {}, this.config.tabGroups);
1681
+ TabManager.updateAllNavActiveStates(tabGroupElements, state.tabs || {}, this.config.tabGroups);
1682
+ // Update pin icons to show which tabs are persisted
1683
+ TabManager.updatePinIcons(tabGroupElements, state.tabs || {});
1213
1684
  // Notify state change listeners (like widgets)
1214
1685
  this.notifyStateChangeListeners();
1686
+ this.observer?.observe(document.body, {
1687
+ childList: true,
1688
+ subtree: true,
1689
+ });
1215
1690
  }
1216
1691
  /**
1217
1692
  * Reset to default state
@@ -1463,7 +1938,7 @@ class CustomViews {
1463
1938
  else {
1464
1939
  console.error("No config provided, using minimal default config");
1465
1940
  // Create a minimal default config
1466
- config = { allToggles: [], defaultState: {} };
1941
+ config = { toggles: [], defaultState: {} };
1467
1942
  }
1468
1943
  const coreOptions = {
1469
1944
  assetsManager,
@@ -1486,1195 +1961,1093 @@ class CustomViews {
1486
1961
  * Note: Styles are kept as a TypeScript string for compatibility with the build system.
1487
1962
  * This approach ensures the styles are properly bundled and don't require separate CSS file handling.
1488
1963
  */
1489
- const WIDGET_STYLES = `
1490
- /* Rounded rectangle widget icon styles */
1491
- .cv-widget-icon {
1492
- position: fixed;
1493
- /* Slightly transparent by default so the widget is subtle at the page edge */
1494
- background: rgba(255, 255, 255, 0.92);
1495
- color: rgba(0, 0, 0, 0.9);
1496
- opacity: 0.6;
1497
- display: flex;
1498
- align-items: center;
1499
- justify-content: center;
1500
- font-size: 18px;
1501
- font-weight: bold;
1502
- cursor: pointer;
1503
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
1504
- z-index: 9998;
1505
- transition: all 0.3s ease;
1506
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
1507
- }
1508
-
1509
- .cv-widget-icon:hover {
1510
- /* Become fully opaque on hover to improve readability */
1511
- background: rgba(255, 255, 255, 1);
1512
- color: rgba(0, 0, 0, 1);
1513
- opacity: 1;
1514
- }
1515
-
1516
- /* Top-right: rounded end on left, sticks out leftward on hover */
1517
- .cv-widget-top-right {
1518
- top: 20px;
1519
- right: 0;
1520
- border-radius: 18px 0 0 18px;
1521
- padding-left: 8px;
1522
- justify-content: flex-start;
1523
- }
1524
-
1525
- /* Top-left: rounded end on right, sticks out rightward on hover */
1526
- .cv-widget-top-left {
1527
- top: 20px;
1528
- left: 0;
1529
- border-radius: 0 18px 18px 0;
1530
- padding-right: 8px;
1531
- justify-content: flex-end;
1532
- }
1533
-
1534
- /* Bottom-right: rounded end on left, sticks out leftward on hover */
1535
- .cv-widget-bottom-right {
1536
- bottom: 20px;
1537
- right: 0;
1538
- border-radius: 18px 0 0 18px;
1539
- padding-left: 8px;
1540
- justify-content: flex-start;
1541
- }
1542
-
1543
- /* Bottom-left: rounded end on right, sticks out rightward on hover */
1544
- .cv-widget-bottom-left {
1545
- bottom: 20px;
1546
- left: 0;
1547
- border-radius: 0 18px 18px 0;
1548
- padding-right: 8px;
1549
- justify-content: flex-end;
1550
- }
1551
-
1552
- /* Middle-left: rounded end on right, sticks out rightward on hover */
1553
- .cv-widget-middle-left {
1554
- top: 50%;
1555
- left: 0;
1556
- transform: translateY(-50%);
1557
- border-radius: 0 18px 18px 0;
1558
- padding-right: 8px;
1559
- justify-content: flex-end;
1560
- }
1561
-
1562
- /* Middle-right: rounded end on left, sticks out leftward on hover */
1563
- .cv-widget-middle-right {
1564
- top: 50%;
1565
- right: 0;
1566
- transform: translateY(-50%);
1567
- border-radius: 18px 0 0 18px;
1568
- padding-left: 8px;
1569
- justify-content: flex-start;
1570
- }
1571
-
1572
- .cv-widget-top-right,
1573
- .cv-widget-middle-right,
1574
- .cv-widget-bottom-right,
1575
- .cv-widget-top-left,
1576
- .cv-widget-middle-left,
1577
- .cv-widget-bottom-left {
1578
- height: 36px;
1579
- width: 36px;
1580
- }
1581
-
1582
- .cv-widget-middle-right:hover,
1583
- .cv-widget-top-right:hover,
1584
- .cv-widget-bottom-right:hover,
1585
- .cv-widget-top-left:hover,
1586
- .cv-widget-middle-left:hover,
1587
- .cv-widget-bottom-left:hover {
1588
- width: 55px;
1589
- }
1590
-
1591
- /* Modal content styles */
1592
- .cv-widget-section {
1593
- margin-bottom: 16px;
1594
- }
1595
-
1596
- .cv-widget-section:last-child {
1597
- margin-bottom: 0;
1598
- }
1599
-
1600
- .cv-widget-section label {
1601
- display: block;
1602
- margin-bottom: 4px;
1603
- font-weight: 500;
1604
- color: #555;
1605
- }
1606
-
1607
- .cv-widget-profile-select,
1608
- .cv-widget-state-select {
1609
- width: 100%;
1610
- padding: 8px 12px;
1611
- border: 1px solid #ddd;
1612
- border-radius: 4px;
1613
- background: white;
1614
- font-size: 14px;
1615
- }
1616
-
1617
- .cv-widget-profile-select:focus,
1618
- .cv-widget-state-select:focus {
1619
- outline: none;
1620
- border-color: #007bff;
1621
- box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
1622
- }
1623
-
1624
- .cv-widget-profile-select:disabled,
1625
- .cv-widget-state-select:disabled {
1626
- background: #f8f9fa;
1627
- color: #6c757d;
1628
- cursor: not-allowed;
1629
- }
1630
-
1631
- .cv-widget-current {
1632
- margin: 16px 0;
1633
- padding: 12px;
1634
- background: #f8f9fa;
1635
- border-radius: 4px;
1636
- border-left: 4px solid #007bff;
1637
- }
1638
-
1639
- .cv-widget-current label {
1640
- font-size: 12px;
1641
- text-transform: uppercase;
1642
- letter-spacing: 0.5px;
1643
- color: #666;
1644
- margin-bottom: 4px;
1645
- }
1646
-
1647
- .cv-widget-current-view {
1648
- font-weight: 500;
1649
- color: #333;
1650
- }
1651
-
1652
- .cv-widget-reset {
1653
- width: 100%;
1654
- padding: 8px 16px;
1655
- background: #dc3545;
1656
- color: white;
1657
- border: none;
1658
- border-radius: 4px;
1659
- cursor: pointer;
1660
- font-size: 14px;
1661
- font-weight: 500;
1662
- }
1663
-
1664
- .cv-widget-reset:hover {
1665
- background: #c82333;
1666
- }
1667
-
1668
- .cv-widget-reset:active {
1669
- background: #bd2130;
1670
- }
1671
-
1672
- /* Responsive design for mobile */
1673
- @media (max-width: 768px) {
1674
- .cv-widget-top-right,
1675
- .cv-widget-top-left {
1676
- top: 10px;
1677
- }
1678
-
1679
- .cv-widget-bottom-right,
1680
- .cv-widget-bottom-left {
1681
- bottom: 10px;
1682
- }
1683
-
1684
- /* All widgets stay flush with screen edges */
1685
- .cv-widget-top-right,
1686
- .cv-widget-bottom-right,
1687
- .cv-widget-middle-right {
1688
- right: 0;
1689
- }
1690
-
1691
- .cv-widget-top-left,
1692
- .cv-widget-bottom-left,
1693
- .cv-widget-middle-left {
1694
- left: 0;
1695
- }
1696
-
1697
- /* Slightly smaller on mobile */
1698
- .cv-widget-icon {
1699
- width: 60px;
1700
- height: 32px;
1701
- }
1702
-
1703
- .cv-widget-icon:hover {
1704
- width: 75px;
1705
- }
1706
- }
1707
-
1708
- /* Modal styles */
1709
- .cv-widget-modal-overlay {
1710
- position: fixed;
1711
- top: 0;
1712
- left: 0;
1713
- right: 0;
1714
- bottom: 0;
1715
- background: rgba(0, 0, 0, 0.5);
1716
- display: flex;
1717
- align-items: center;
1718
- justify-content: center;
1719
- z-index: 10002;
1720
- animation: fadeIn 0.2s ease;
1721
- }
1722
-
1723
- @keyframes fadeIn {
1724
- from { opacity: 0; }
1725
- to { opacity: 1; }
1726
- }
1727
-
1728
- .cv-widget-modal {
1729
- background: white;
1730
- border-radius: 0.75rem;
1731
- box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
1732
- max-width: 32rem;
1733
- width: 90vw;
1734
- max-height: 80vh;
1735
- animation: slideIn 0.2s ease;
1736
- display: flex;
1737
- flex-direction: column;
1738
- }
1739
-
1740
- @keyframes slideIn {
1741
- from {
1742
- opacity: 0;
1743
- transform: scale(0.9) translateY(-20px);
1744
- }
1745
- to {
1746
- opacity: 1;
1747
- transform: scale(1) translateY(0);
1748
- }
1749
- }
1750
-
1751
- .cv-modal-header {
1752
- display: flex;
1753
- align-items: center;
1754
- justify-content: space-between;
1755
- padding: 0.5rem 1rem;
1756
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
1757
- }
1758
-
1759
- .cv-modal-header-content {
1760
- display: flex;
1761
- align-items: center;
1762
- gap: 0.75rem;
1763
- }
1764
-
1765
- .cv-modal-icon {
1766
- position: relative;
1767
- width: 1rem;
1768
- height: 1rem;
1769
- display: flex;
1770
- align-items: center;
1771
- justify-content: center;
1772
- border-radius: 9999px;
1773
- }
1774
-
1775
- .cv-modal-icon-svg {
1776
- width: 100%;
1777
- height: 100%;
1778
- opacity: 1;
1779
- }
1780
-
1781
- .cv-modal-title {
1782
- font-size: 1.125rem;
1783
- font-weight: bold;
1784
- color: rgba(0, 0, 0, 0.9);
1785
- margin: 0;
1786
- }
1787
-
1788
- .cv-modal-close {
1789
- width: 2rem;
1790
- height: 2rem;
1791
- display: flex;
1792
- align-items: center;
1793
- justify-content: center;
1794
- border-radius: 9999px;
1795
- background: transparent;
1796
- border: none;
1797
- color: rgba(0, 0, 0, 0.6);
1798
- cursor: pointer;
1799
- transition: all 0.2s ease;
1800
- }
1801
-
1802
- .cv-modal-close:hover {
1803
- background: rgba(62, 132, 244, 0.1);
1804
- color: #3e84f4;
1805
- }
1806
-
1807
- .cv-modal-close-icon {
1808
- width: 1.25rem;
1809
- height: 1.25rem;
1810
- }
1811
-
1812
- .cv-modal-main {
1813
- padding: 1rem;
1814
- flex: 1;
1815
- display: flex;
1816
- flex-direction: column;
1817
- gap: 1rem;
1818
- overflow-y: auto;
1819
- max-height: calc(80vh - 8rem);
1820
- }
1821
-
1822
- .cv-modal-description {
1823
- font-size: 0.875rem;
1824
- color: rgba(0, 0, 0, 0.8);
1825
- margin: 0;
1826
- line-height: 1.4;
1827
- }
1828
-
1829
- .cv-content-section,
1830
- .cv-tab-groups-section {
1831
- display: flex;
1832
- flex-direction: column;
1833
- gap: 0.75rem;
1834
- }
1835
-
1836
- .cv-section-heading {
1837
- font-size: 1rem;
1838
- font-weight: bold;
1839
- color: rgba(0, 0, 0, 0.9);
1840
- margin: 0;
1841
- }
1842
-
1843
- .cv-widget-modal-actions {
1844
- margin-top: 20px;
1845
- padding-top: 16px;
1846
- border-top: 1px solid #e9ecef;
1847
- }
1848
-
1849
- .cv-widget-restore {
1850
- width: 100%;
1851
- padding: 10px 16px;
1852
- background: #28a745;
1853
- color: white;
1854
- border: none;
1855
- border-radius: 4px;
1856
- cursor: pointer;
1857
- font-size: 14px;
1858
- font-weight: 500;
1859
- }
1860
-
1861
- .cv-widget-restore:hover {
1862
- background: #218838;
1863
- }
1864
-
1865
- .cv-widget-create-state {
1866
- width: 100%;
1867
- padding: 10px 16px;
1868
- background: #007bff;
1869
- color: white;
1870
- border: none;
1871
- border-radius: 4px;
1872
- cursor: pointer;
1873
- font-size: 14px;
1874
- font-weight: 500;
1875
- margin-bottom: 10px;
1876
- }
1877
-
1878
- .cv-widget-create-state:hover {
1879
- background: #0056b3;
1880
- }
1881
-
1882
- .cv-widget-theme-dark .cv-widget-modal {
1883
- background: #101722;
1884
- color: #e2e8f0;
1885
- }
1886
-
1887
- .cv-widget-theme-dark .cv-modal-header {
1888
- border-color: rgba(255, 255, 255, 0.1);
1889
- }
1890
-
1891
- .cv-widget-theme-dark .cv-modal-title {
1892
- color: #e2e8f0;
1893
- }
1894
-
1895
- .cv-widget-theme-dark .cv-modal-close {
1896
- color: rgba(255, 255, 255, 0.6);
1897
- }
1898
-
1899
- .cv-widget-theme-dark .cv-modal-close:hover {
1900
- background: rgba(62, 132, 244, 0.2);
1901
- color: #3e84f4;
1902
- }
1903
-
1904
- .cv-widget-theme-dark .cv-modal-description {
1905
- color: rgba(255, 255, 255, 0.8);
1906
- }
1907
-
1908
- .cv-widget-theme-dark .cv-section-heading {
1909
- color: #e2e8f0;
1910
- }
1911
-
1912
- .cv-widget-theme-dark .cv-toggles-container
1913
- .cv-widget-theme-dark .cv-tabgroups-container {
1914
- border-color: rgba(255, 255, 255, 0.1);
1915
- }
1916
-
1917
- .cv-widget-theme-dark .cv-toggle-card,
1918
- .cv-widget-theme-dark .cv-tabgroup-card {
1919
- background: #101722;
1920
- border-color: rgba(255, 255, 255, 0.1);
1921
- }
1922
-
1923
- .cv-widget-theme-dark .cv-toggle-title,
1924
- .cv-widget-theme-dark .cv-tabgroup-title {
1925
- color: #e2e8f0;
1926
- }
1927
-
1928
- .cv-widget-theme-dark .cv-toggle-description,
1929
- .cv-widget-theme-dark .cv-tabgroup-description {
1930
- color: rgba(255, 255, 255, 0.6);
1931
- }
1932
-
1933
- .cv-widget-theme-dark .cv-toggle-slider {
1934
- background: rgba(255, 255, 255, 0.2);
1935
- }
1936
-
1937
- .cv-widget-theme-dark .cv-tab-group-description {
1938
- color: rgba(255, 255, 255, 0.8);
1939
- }
1940
-
1941
- .cv-widget-theme-dark .cv-tabgroup-select {
1942
- background: #101722;
1943
- border-color: rgba(255, 255, 255, 0.2);
1944
- color: #e2e8f0;
1945
- }
1946
-
1947
- .cv-widget-theme-dark .cv-modal-footer {
1948
- border-color: rgba(255, 255, 255, 0.1);
1949
- background: #101722;
1950
- }
1951
-
1952
- .cv-widget-theme-dark .cv-reset-btn {
1953
- color: #e2e8f0;
1954
- background: rgba(255, 255, 255, 0.1);
1955
- }
1956
-
1957
- .cv-widget-theme-dark .cv-reset-btn:hover {
1958
- background: rgba(255, 255, 255, 0.2);
1959
- }
1960
-
1961
- /* Custom state creator styles */
1962
- .cv-custom-state-modal {
1963
- max-width: 500px;
1964
- }
1965
-
1966
- .cv-custom-state-form .cv-section-header {
1967
- font-size: 16px;
1968
- font-weight: 600;
1969
- color: #333;
1970
- border-bottom: 1px solid #e9ecef;
1971
- padding-bottom: 5px;
1972
- }
1973
-
1974
- .cv-custom-state-form p {
1975
- font-size: 15px;
1976
- line-height: 1.6;
1977
- color: #555;
1978
- margin-bottom: 24px;
1979
- text-align: justify;
1980
- }
1981
-
1982
- .cv-custom-state-section {
1983
- margin-bottom: 16px;
1984
- }
1985
-
1986
- .cv-custom-state-section label {
1987
- display: block;
1988
- margin-bottom: 4px;
1989
- font-weight: 500;
1990
- color: #555;
1991
- }
1992
-
1993
- .cv-custom-state-input {
1994
- width: 100%;
1995
- padding: 8px 12px;
1996
- border: 1px solid #ddd;
1997
- border-radius: 4px;
1998
- background: white;
1999
- font-size: 14px;
2000
- }
2001
-
2002
- .cv-custom-state-input:focus {
2003
- outline: none;
2004
- border-color: #007bff;
2005
- box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
2006
- }
2007
-
2008
- /* Toggles Container */
2009
- .cv-toggles-container {
2010
- display: flex;
2011
- flex-direction: column;
2012
- gap: 0.5rem;
2013
- border-radius: 0.5rem;
2014
- border: 1px solid rgba(0, 0, 0, 0.1);
2015
- overflow: hidden;
2016
- }
2017
-
2018
- .cv-toggle-card,
2019
- .cv-tabgroup-card {
2020
- background: white;
2021
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
2022
- }
2023
-
2024
- .cv-toggle-card:last-child {
2025
- border-bottom: none;
2026
- }
2027
-
2028
- .cv-toggle-content {
2029
- display: flex;
2030
- align-items: center;
2031
- justify-content: space-between;
2032
- padding: 0.75rem;
2033
- }
2034
-
2035
- .cv-toggle-title {
2036
- font-weight: 500;
2037
- font-size: 0.875rem;
2038
- color: rgba(0, 0, 0, 0.9);
2039
- margin: 0 0 0.125rem 0;
2040
- }
2041
-
2042
- .cv-toggle-description {
2043
- font-size: 0.75rem;
2044
- color: rgba(0, 0, 0, 0.6);
2045
- margin: 0;
2046
- }
2047
-
2048
- .cv-toggle-label{
2049
- position: relative;
2050
- display: inline-block;
2051
- width: 2.75rem;
2052
- height: 1.5rem;
2053
- cursor: pointer;
2054
- }
2055
-
2056
- .cv-toggle-input {
2057
- opacity: 0;
2058
- width: 0;
2059
- height: 0;
2060
- }
2061
-
2062
- .cv-toggle-slider {
2063
- position: absolute;
2064
- top: 0;
2065
- left: 0;
2066
- right: 0;
2067
- bottom: 0;
2068
- background: rgba(0, 0, 0, 0.2);
2069
- border-radius: 9999px;
2070
- transition: background-color 0.2s ease;
2071
- }
2072
-
2073
- .cv-toggle-slider:before {
2074
- position: absolute;
2075
- content: "";
2076
- height: 1rem;
2077
- width: 1rem;
2078
- left: 0.25rem;
2079
- bottom: 0.25rem;
2080
- background: white;
2081
- border-radius: 50%;
2082
- transition: transform 0.2s ease;
2083
- }
2084
-
2085
- .cv-toggle-input:checked + .cv-toggle-slider {
2086
- background: #3e84f4;
2087
- }
2088
-
2089
- .cv-toggle-input:checked + .cv-toggle-slider:before {
2090
- transform: translateX(1.25rem);
2091
- }
2092
-
2093
- /* Dark theme toggle switch styles */
2094
- .cv-widget-theme-dark .cv-toggle-switch {
2095
- background: #4a5568;
2096
- }
2097
-
2098
- .cv-widget-theme-dark .cv-toggle-switch:hover {
2099
- background: #5a6578;
2100
- }
2101
-
2102
- .cv-widget-theme-dark .cv-toggle-switch.cv-toggle-active {
2103
- background: #63b3ed;
2104
- }
2105
-
2106
- .cv-widget-theme-dark .cv-toggle-switch.cv-toggle-active:hover {
2107
- background: #4299e1;
2108
- }
2109
-
2110
- /* Tab Groups Container */
2111
- .cv-tab-groups-list {
2112
- display: flex;
2113
- flex-direction: column;
2114
- gap: 1px;
2115
- border: 1px solid rgba(0, 0, 0, 0.1);
2116
- border-radius: 0.5rem;
2117
- overflow: hidden;
2118
- }
2119
-
2120
- /* Tab Group Card - Header (Navigation Headers toggle) */
2121
- .cv-tabgroup-card.cv-tabgroup-header {
2122
- display: flex;
2123
- align-items: center;
2124
- justify-content: space-between;
2125
- padding: 0.75rem;
2126
- border-bottom: 0px;
2127
- }
2128
-
2129
- .cv-tabgroup-card.cv-tabgroup-header .cv-tabgroup-row {
2130
- display: flex;
2131
- align-items: center;
2132
- justify-content: space-between;
2133
- width: 100%;
2134
- gap: 1rem;
2135
- }
2136
-
2137
- /* Navigation toggle icon container */
2138
- .cv-nav-toggle-container {
2139
- display: flex;
2140
- align-items: center;
2141
- gap: 0.5rem;
2142
- }
2143
-
2144
- .cv-nav-icon {
2145
- width: 2rem;
2146
- height: 2rem;
2147
- color: rgba(0, 0, 0, 0.8);
2148
- display: flex;
2149
- align-items: center;
2150
- justify-content: center;
2151
- flex-shrink: 0;
2152
- transition: color 0.2s ease;
2153
- }
2154
-
2155
- /* Logo box - centered grey box on its own row */
2156
- .cv-tabgroup-logo-box {
2157
- width: 3.5rem;
2158
- height: 3.5rem;
2159
- background: rgba(0, 0, 0, 0.08);
2160
- border-radius: 0.5rem;
2161
- display: flex;
2162
- align-items: center;
2163
- justify-content: center;
2164
- flex-shrink: 0;
2165
- margin-bottom: 0.5rem;
2166
- }
2167
-
2168
- /* Title container for title alignment (without icon) */
2169
- .cv-tabgroup-title-container {
2170
- display: flex;
2171
- align-items: center;
2172
- gap: 0.5rem;
2173
- }
2174
-
2175
- /* Hover state for icon - apply to the entire tabgroup-row */
2176
- .cv-tabgroup-card.cv-tabgroup-header:hover .cv-nav-icon {
2177
- color: #3e84f4;
2178
- }
2179
-
2180
- .cv-widget-theme-dark .cv-nav-icon {
2181
- color: rgba(255, 255, 255, 0.8);
2182
- }
2183
-
2184
- .cv-widget-theme-dark .cv-tabgroup-card.cv-tabgroup-header:hover .cv-nav-icon {
2185
- color: #60a5fa;
2186
- }
2187
-
2188
- /* Tab Group Card - Items */
2189
- .cv-tabgroup-card.cv-tabgroup-item {
2190
- display: flex;
2191
- flex-direction: column;
2192
- gap: 0.5rem;
2193
- padding: 0.75rem;
2194
- background: white;
2195
- border-bottom: 1px solid rgba(0, 0, 0, 0.05);
2196
- }
2197
-
2198
- .cv-tabgroup-card.cv-tabgroup-item:last-child {
2199
- border-bottom: none;
2200
- }
2201
-
2202
- /* Tab Group Info */
2203
- .cv-tabgroup-info {
2204
- flex: 1;
2205
- display: flex;
2206
- flex-direction: column;
2207
- gap: 0.25rem;
2208
- }
2209
-
2210
- .cv-tabgroup-title {
2211
- font-weight: 500;
2212
- font-size: 0.875rem;
2213
- color: rgba(0, 0, 0, 0.9);
2214
- margin: 0 0 0 0;
2215
- }
2216
-
2217
- .cv-tabgroup-description {
2218
- font-size: 0.75rem;
2219
- color: rgba(0, 0, 0, 0.6);
2220
- margin: 0;
2221
- line-height: 1.3;
2222
- }
2223
-
2224
- /* Tab Group Label (for select dropdowns) */
2225
- .cv-tabgroup-label {
2226
- font-size: 0.875rem;
2227
- color: rgba(0, 0, 0, 0.8);
2228
- margin: 0;
2229
- line-height: 1.4;
2230
- font-weight: 500;
2231
- display: block;
2232
- cursor: pointer;
2233
- }
2234
-
2235
- /* Tab Group Select */
2236
- .cv-tabgroup-select {
2237
- width: 100%;
2238
- border-radius: 0.5rem;
2239
- background: white;
2240
- border: 1px solid rgba(0, 0, 0, 0.15);
2241
- color: rgba(0, 0, 0, 0.9);
2242
- padding: 0.5rem 0.75rem;
2243
- font-size: 0.875rem;
2244
- cursor: pointer;
2245
- transition: all 0.15s ease;
2246
- font-family: inherit;
2247
- }
2248
-
2249
- .cv-tabgroup-select:hover {
2250
- border-color: rgba(0, 0, 0, 0.25);
2251
- }
2252
-
2253
- .cv-tabgroup-select:focus {
2254
- outline: none;
2255
- border-color: #3e84f4;
2256
- box-shadow: 0 0 0 2px rgba(62, 132, 244, 0.2);
2257
- }
2258
-
2259
- /* Modern Toggle Switch */
2260
- .cv-toggle-switch {
2261
- position: relative;
2262
- display: inline-flex;
2263
- align-items: center;
2264
- width: 44px;
2265
- height: 24px;
2266
- background: rgba(0, 0, 0, 0.1);
2267
- border-radius: 9999px;
2268
- padding: 2px;
2269
- box-sizing: border-box;
2270
- cursor: pointer;
2271
- transition: background-color 0.2s ease;
2272
- border: none;
2273
- }
2274
-
2275
- .cv-toggle-switch input {
2276
- display: none;
2277
- }
2278
-
2279
- .cv-toggle-switch .cv-switch-bg {
2280
- position: absolute;
2281
- inset: 0;
2282
- border-radius: 9999px;
2283
- background: rgba(0, 0, 0, 0.1);
2284
- transition: background-color 0.2s ease;
2285
- pointer-events: none;
2286
- }
2287
-
2288
- .cv-toggle-switch .cv-switch-knob {
2289
- position: relative;
2290
- width: 20px;
2291
- height: 20px;
2292
- background: white;
2293
- border-radius: 50%;
2294
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
2295
- transition: transform 0.2s ease;
2296
- z-index: 1;
2297
- }
2298
-
2299
- .cv-toggle-switch input:checked + .cv-switch-bg {
2300
- background: #3e84f4;
2301
- }
2302
-
2303
- .cv-toggle-switch input:checked ~ .cv-switch-knob {
2304
- transform: translateX(20px);
2305
- }
2306
-
2307
- /* Dark Theme - Tab Groups */
2308
- .cv-widget-theme-dark .cv-tabgroup-card.cv-tabgroup-header {
2309
- background: #101722;
2310
- border-bottom-color: rgba(255, 255, 255, 0.1);
2311
- }
2312
-
2313
- .cv-widget-theme-dark .cv-tabgroup-card.cv-tabgroup-item {
2314
- background: #101722;
2315
- border-bottom-color: rgba(255, 255, 255, 0.05);
2316
- }
2317
-
2318
- .cv-widget-theme-dark .cv-tabgroup-title {
2319
- color: #e2e8f0;
2320
- }
2321
-
2322
- .cv-widget-theme-dark .cv-tabgroup-description {
2323
- color: rgba(255, 255, 255, 0.6);
2324
- }
2325
-
2326
- .cv-widget-theme-dark .cv-tabgroup-label {
2327
- color: rgba(255, 255, 255, 0.8);
2328
- }
2329
-
2330
- .cv-widget-theme-dark .cv-tab-groups-list {
2331
- border-color: rgba(255, 255, 255, 0.1);
2332
- }
2333
-
2334
- .cv-widget-theme-dark .cv-tabgroup-select {
2335
- background: #101722;
2336
- border-color: rgba(255, 255, 255, 0.15);
2337
- color: #e2e8f0;
2338
- }
2339
-
2340
- .cv-widget-theme-dark .cv-tabgroup-select:hover {
2341
- border-color: rgba(255, 255, 255, 0.25);
2342
- }
2343
-
2344
- .cv-widget-theme-dark .cv-tabgroup-select:focus {
2345
- border-color: #60a5fa;
2346
- box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
2347
- }
2348
-
2349
- /* Dark Theme - Toggle Switch */
2350
- .cv-widget-theme-dark .cv-toggle-switch .cv-switch-bg {
2351
- background: rgba(255, 255, 255, 0.1);
2352
- }
2353
-
2354
- .cv-widget-theme-dark .cv-toggle-switch .cv-switch-knob {
2355
- background: #e2e8f0;
2356
- }
2357
-
2358
- .cv-widget-theme-dark .cv-toggle-switch input:checked + .cv-switch-bg {
2359
- background: #63b3ed;
2360
- }
2361
-
2362
- .cv-modal-footer {
2363
- display: flex;
2364
- justify-content: space-between;
2365
- align-items: center;
2366
- padding: 0.75rem;
2367
- border-top: 1px solid rgba(0, 0, 0, 0.1);
2368
- }
2369
-
2370
- .cv-reset-btn,
2371
- .cv-share-btn {
2372
- display: flex;
2373
- align-items: center;
2374
- gap: 0.5rem;
2375
- padding: 0.375rem 0.75rem;
2376
- border-radius: 0.5rem;
2377
- font-weight: 600;
2378
- font-size: 0.875rem;
2379
- cursor: pointer;
2380
- transition: all 0.2s ease;
2381
- border: none;
2382
- }
2383
-
2384
- .cv-reset-btn {
2385
- color: rgba(0, 0, 0, 0.9);
2386
- background: rgba(0, 0, 0, 0.1);
2387
- }
2388
-
2389
- .cv-reset-btn:hover {
2390
- background: rgba(0, 0, 0, 0.2);
2391
- }
2392
-
2393
- .cv-share-btn {
2394
- color: white;
2395
- background: #3e84f4;
2396
- }
2397
-
2398
- .cv-share-btn:hover {
2399
- background: rgba(62, 132, 244, 0.9);
2400
- }
2401
-
2402
- .cv-btn-icon {
2403
- width: 1rem;
2404
- height: 1rem;
2405
- display: flex;
2406
- align-items: center;
2407
- justify-content: center;
2408
- transition: transform 0.2s ease;
2409
- }
2410
-
2411
- /* Dark theme custom state styles */
2412
- /* Welcome modal styles */
2413
- .cv-welcome-modal {
2414
- max-width: 32rem;
2415
- width: 90vw;
2416
- background: white;
2417
- border-radius: 0.75rem;
2418
- box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
2419
- animation: slideIn 0.2s ease;
2420
- display: flex;
2421
- flex-direction: column;
2422
- }
2423
-
2424
- .cv-modal-main {
2425
- padding: 1rem;
2426
- flex: 1;
2427
- display: flex;
2428
- flex-direction: column;
2429
- gap: 1rem;
2430
- overflow-y: auto;
2431
- max-height: calc(80vh - 8rem);
2432
- }
2433
-
2434
- .cv-welcome-message {
2435
- font-size: 0.875rem;
2436
- color: rgba(0, 0, 0, 0.8);
2437
- margin: 0;
2438
- line-height: 1.4;
2439
- text-align: center;
2440
- }
2441
-
2442
- .cv-welcome-message a {
2443
- color: #3e84f4;
2444
- text-align: justify;
2445
- text-decoration: none;
2446
- }
2447
-
2448
- .cv-welcome-message a:hover {
2449
- text-decoration: underline;
2450
- }
2451
-
2452
- .cv-welcome-widget-preview {
2453
- display: flex;
2454
- align-items: center;
2455
- justify-content: center;
2456
- gap: 1rem;
2457
- padding: 1rem;
2458
- background: #f8f9fa;
2459
- border-radius: 0.5rem;
2460
- margin: 1rem 0;
2461
- }
2462
-
2463
- .cv-welcome-widget-icon {
2464
- width: 2rem;
2465
- height: 2rem;
2466
- background: rgba(62, 132, 244, 0.1);
2467
- border-radius: 9999px;
2468
- display: flex;
2469
- align-items: center;
2470
- justify-content: center;
2471
- animation: cv-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
2472
- color: #3e84f4;
2473
- }
2474
-
2475
- .cv-welcome-widget-label {
2476
- font-size: 0.875rem;
2477
- font-weight: 500;
2478
- color: rgba(0, 0, 0, 0.8);
2479
- margin: 0;
2480
- }
2481
-
2482
- .cv-welcome-got-it {
2483
- width: 100%;
2484
- background: #3e84f4;
2485
- color: white;
2486
- font-weight: 600;
2487
- padding: 0.75rem 1rem;
2488
- border-radius: 0.5rem;
2489
- border: none;
2490
- cursor: pointer;
2491
- font-size: 0.875rem;
2492
- transition: background-color 0.2s ease;
2493
- outline: none;
2494
- }
2495
-
2496
- .cv-welcome-got-it:hover {
2497
- background: rgba(62, 132, 244, 0.9);
2498
- }
2499
-
2500
- .cv-welcome-got-it:focus {
2501
- box-shadow: 0 0 0 2px rgba(62, 132, 244, 0.5);
2502
- }
2503
-
2504
- /* Animations */
2505
- @keyframes cv-pulse {
2506
- 0%, 100% {
2507
- opacity: 1;
2508
- }
2509
- 50% {
2510
- opacity: 0.5;
2511
- }
2512
- }
2513
-
2514
- /* Dark theme welcome modal styles */
2515
- .cv-widget-theme-dark .cv-welcome-modal {
2516
- background: #101722;
2517
- }
2518
-
2519
- .cv-widget-theme-dark .cv-welcome-message {
2520
- color: rgba(255, 255, 255, 0.8);
2521
- }
2522
-
2523
- .cv-widget-theme-dark .cv-welcome-message a {
2524
- color: #60a5fa;
2525
- }
2526
-
2527
- .cv-widget-theme-dark .cv-welcome-widget-preview {
2528
- background: rgba(255, 255, 255, 0.1);
2529
- }
2530
-
2531
- .cv-widget-theme-dark .cv-welcome-widget-label {
2532
- color: #e2e8f0;
2533
- }
2534
-
2535
- /* Dark theme logo box */
2536
- .cv-widget-theme-dark .cv-tabgroup-logo-box {
2537
- background: rgba(255, 255, 255, 0.1);
2538
- }
2539
-
2540
- /* Spinning animation for reset button icon */
2541
- @keyframes cv-spin {
2542
- from {
2543
- transform: rotate(0deg);
2544
- }
2545
- to {
2546
- transform: rotate(-360deg);
2547
- }
2548
- }
2549
-
2550
- .cv-spinning {
2551
- animation: cv-spin 0.6s ease-in-out;
2552
- }
2553
-
2554
- /* Hide widget icon in print view */
2555
- @media print {
2556
- .cv-widget-icon {
2557
- display: none !important;
2558
- }
2559
- }
2560
- `;
2561
- /**
2562
- * Inject widget styles into the document head
2563
- */
2564
- function injectWidgetStyles() {
2565
- // Check if styles are already injected
2566
- if (document.querySelector('#cv-widget-styles'))
2567
- return;
2568
- const style = document.createElement('style');
2569
- style.id = 'cv-widget-styles';
2570
- style.textContent = WIDGET_STYLES;
2571
- document.head.appendChild(style);
1964
+ const WIDGET_STYLES = `
1965
+ /* Rounded rectangle widget icon styles */
1966
+ .cv-widget-icon {
1967
+ position: fixed;
1968
+ /* Slightly transparent by default so the widget is subtle at the page edge */
1969
+ background: rgba(255, 255, 255, 0.92);
1970
+ color: rgba(0, 0, 0, 0.9);
1971
+ opacity: 0.6;
1972
+ display: flex;
1973
+ align-items: center;
1974
+ justify-content: center;
1975
+ font-size: 18px;
1976
+ font-weight: bold;
1977
+ cursor: pointer;
1978
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
1979
+ z-index: 9998;
1980
+ transition: all 0.3s ease;
1981
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
2572
1982
  }
2573
1983
 
2574
- /**
2575
- * Icon utilities for CustomViews widget
2576
- * Centralized SVG icons for better maintainability and reusability
2577
- */
2578
- /**
2579
- * Settings gear icon for modal header
2580
- */
2581
- function getGearIcon() {
2582
- return `<svg class="cv-modal-icon-svg" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2583
- <path xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" d="M12 8.00002C9.79085 8.00002 7.99999 9.79088 7.99999 12C7.99999 14.2092 9.79085 16 12 16C14.2091 16 16 14.2092 16 12C16 9.79088 14.2091 8.00002 12 8.00002ZM9.99999 12C9.99999 10.8955 10.8954 10 12 10C13.1046 10 14 10.8955 14 12C14 13.1046 13.1046 14 12 14C10.8954 14 9.99999 13.1046 9.99999 12Z" fill="#0F1729"/>
2584
- <path xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" d="M10.7673 1.01709C10.9925 0.999829 11.2454 0.99993 11.4516 1.00001L12.5484 1.00001C12.7546 0.99993 13.0075 0.999829 13.2327 1.01709C13.4989 1.03749 13.8678 1.08936 14.2634 1.26937C14.7635 1.49689 15.1915 1.85736 15.5007 2.31147C15.7454 2.67075 15.8592 3.0255 15.9246 3.2843C15.9799 3.50334 16.0228 3.75249 16.0577 3.9557L16.1993 4.77635L16.2021 4.77788C16.2369 4.79712 16.2715 4.81659 16.306 4.8363L16.3086 4.83774L17.2455 4.49865C17.4356 4.42978 17.6693 4.34509 17.8835 4.28543C18.1371 4.2148 18.4954 4.13889 18.9216 4.17026C19.4614 4.20998 19.9803 4.39497 20.4235 4.70563C20.7734 4.95095 21.0029 5.23636 21.1546 5.4515C21.2829 5.63326 21.4103 5.84671 21.514 6.02029L22.0158 6.86003C22.1256 7.04345 22.2594 7.26713 22.3627 7.47527C22.4843 7.7203 22.6328 8.07474 22.6777 8.52067C22.7341 9.08222 22.6311 9.64831 22.3803 10.1539C22.1811 10.5554 21.9171 10.8347 21.7169 11.0212C21.5469 11.1795 21.3428 11.3417 21.1755 11.4746L20.5 12L21.1755 12.5254C21.3428 12.6584 21.5469 12.8205 21.7169 12.9789C21.9171 13.1653 22.1811 13.4446 22.3802 13.8461C22.631 14.3517 22.7341 14.9178 22.6776 15.4794C22.6328 15.9253 22.4842 16.2797 22.3626 16.5248C22.2593 16.7329 22.1255 16.9566 22.0158 17.14L21.5138 17.9799C21.4102 18.1535 21.2828 18.3668 21.1546 18.5485C21.0028 18.7637 20.7734 19.0491 20.4234 19.2944C19.9803 19.6051 19.4613 19.7901 18.9216 19.8298C18.4954 19.8612 18.1371 19.7852 17.8835 19.7146C17.6692 19.6549 17.4355 19.5703 17.2454 19.5014L16.3085 19.1623L16.306 19.1638C16.2715 19.1835 16.2369 19.2029 16.2021 19.2222L16.1993 19.2237L16.0577 20.0443C16.0228 20.2475 15.9799 20.4967 15.9246 20.7157C15.8592 20.9745 15.7454 21.3293 15.5007 21.6886C15.1915 22.1427 14.7635 22.5032 14.2634 22.7307C13.8678 22.9107 13.4989 22.9626 13.2327 22.983C13.0074 23.0002 12.7546 23.0001 12.5484 23H11.4516C11.2454 23.0001 10.9925 23.0002 10.7673 22.983C10.5011 22.9626 10.1322 22.9107 9.73655 22.7307C9.23648 22.5032 8.80849 22.1427 8.49926 21.6886C8.25461 21.3293 8.14077 20.9745 8.07542 20.7157C8.02011 20.4967 7.97723 20.2475 7.94225 20.0443L7.80068 19.2237L7.79791 19.2222C7.7631 19.2029 7.72845 19.1835 7.69396 19.1637L7.69142 19.1623L6.75458 19.5014C6.5645 19.5702 6.33078 19.6549 6.11651 19.7146C5.86288 19.7852 5.50463 19.8611 5.07841 19.8298C4.53866 19.7901 4.01971 19.6051 3.57654 19.2944C3.2266 19.0491 2.99714 18.7637 2.84539 18.5485C2.71718 18.3668 2.58974 18.1534 2.4861 17.9798L1.98418 17.14C1.87447 16.9566 1.74067 16.7329 1.63737 16.5248C1.51575 16.2797 1.36719 15.9253 1.32235 15.4794C1.26588 14.9178 1.36897 14.3517 1.61976 13.8461C1.81892 13.4446 2.08289 13.1653 2.28308 12.9789C2.45312 12.8205 2.65717 12.6584 2.82449 12.5254L3.47844 12.0054V11.9947L2.82445 11.4746C2.65712 11.3417 2.45308 11.1795 2.28304 11.0212C2.08285 10.8347 1.81888 10.5554 1.61972 10.1539C1.36893 9.64832 1.26584 9.08224 1.3223 8.52069C1.36714 8.07476 1.51571 7.72032 1.63732 7.47528C1.74062 7.26715 1.87443 7.04347 1.98414 6.86005L2.48605 6.02026C2.58969 5.84669 2.71714 5.63326 2.84534 5.45151C2.9971 5.23637 3.22655 4.95096 3.5765 4.70565C4.01966 4.39498 4.53862 4.20999 5.07837 4.17027C5.50458 4.1389 5.86284 4.21481 6.11646 4.28544C6.33072 4.34511 6.56444 4.4298 6.75451 4.49867L7.69141 4.83775L7.69394 4.8363C7.72844 4.8166 7.7631 4.79712 7.79791 4.77788L7.80068 4.77635L7.94225 3.95571C7.97723 3.7525 8.02011 3.50334 8.07542 3.2843C8.14077 3.0255 8.25461 2.67075 8.49926 2.31147C8.80849 1.85736 9.23648 1.49689 9.73655 1.26937C10.1322 1.08936 10.5011 1.03749 10.7673 1.01709ZM14.0938 4.3363C14.011 3.85634 13.9696 3.61637 13.8476 3.43717C13.7445 3.2858 13.6019 3.16564 13.4352 3.0898C13.2378 3.00002 12.9943 3.00002 12.5073 3.00002H11.4927C11.0057 3.00002 10.7621 3.00002 10.5648 3.0898C10.3981 3.16564 10.2555 3.2858 10.1524 3.43717C10.0304 3.61637 9.98895 3.85634 9.90615 4.3363L9.75012 5.24064C9.69445 5.56333 9.66662 5.72467 9.60765 5.84869C9.54975 5.97047 9.50241 6.03703 9.40636 6.13166C9.30853 6.22804 9.12753 6.3281 8.76554 6.52822C8.73884 6.54298 8.71227 6.55791 8.68582 6.57302C8.33956 6.77078 8.16643 6.86966 8.03785 6.90314C7.91158 6.93602 7.83293 6.94279 7.70289 6.93196C7.57049 6.92094 7.42216 6.86726 7.12551 6.7599L6.11194 6.39308C5.66271 6.2305 5.43809 6.14921 5.22515 6.16488C5.04524 6.17811 4.87225 6.23978 4.72453 6.34333C4.5497 6.46589 4.42715 6.67094 4.18206 7.08103L3.72269 7.84965C3.46394 8.2826 3.33456 8.49907 3.31227 8.72078C3.29345 8.90796 3.32781 9.09665 3.41141 9.26519C3.51042 9.4648 3.7078 9.62177 4.10256 9.9357L4.82745 10.5122C5.07927 10.7124 5.20518 10.8126 5.28411 10.9199C5.36944 11.036 5.40583 11.1114 5.44354 11.2504C5.47844 11.379 5.47844 11.586 5.47844 12C5.47844 12.414 5.47844 12.621 5.44354 12.7497C5.40582 12.8887 5.36944 12.9641 5.28413 13.0801C5.20518 13.1875 5.07927 13.2876 4.82743 13.4879L4.10261 14.0643C3.70785 14.3783 3.51047 14.5352 3.41145 14.7349C3.32785 14.9034 3.29349 15.0921 3.31231 15.2793C3.33461 15.501 3.46398 15.7174 3.72273 16.1504L4.1821 16.919C4.4272 17.3291 4.54974 17.5342 4.72457 17.6567C4.8723 17.7603 5.04528 17.8219 5.2252 17.8352C5.43813 17.8508 5.66275 17.7695 6.11199 17.607L7.12553 17.2402C7.42216 17.1328 7.5705 17.0791 7.7029 17.0681C7.83294 17.0573 7.91159 17.064 8.03786 17.0969C8.16644 17.1304 8.33956 17.2293 8.68582 17.427C8.71228 17.4421 8.73885 17.4571 8.76554 17.4718C9.12753 17.6719 9.30853 17.772 9.40635 17.8684C9.50241 17.963 9.54975 18.0296 9.60765 18.1514C9.66662 18.2754 9.69445 18.4367 9.75012 18.7594L9.90615 19.6637C9.98895 20.1437 10.0304 20.3837 10.1524 20.5629C10.2555 20.7142 10.3981 20.8344 10.5648 20.9102C10.7621 21 11.0057 21 11.4927 21H12.5073C12.9943 21 13.2378 21 13.4352 20.9102C13.6019 20.8344 13.7445 20.7142 13.8476 20.5629C13.9696 20.3837 14.011 20.1437 14.0938 19.6637L14.2499 18.7594C14.3055 18.4367 14.3334 18.2754 14.3923 18.1514C14.4502 18.0296 14.4976 17.963 14.5936 17.8684C14.6915 17.772 14.8725 17.6719 15.2344 17.4718C15.2611 17.4571 15.2877 17.4421 15.3141 17.427C15.6604 17.2293 15.8335 17.1304 15.9621 17.0969C16.0884 17.064 16.167 17.0573 16.2971 17.0681C16.4295 17.0791 16.5778 17.1328 16.8744 17.2402L17.888 17.607C18.3372 17.7696 18.5619 17.8509 18.7748 17.8352C18.9547 17.8219 19.1277 17.7603 19.2754 17.6567C19.4502 17.5342 19.5728 17.3291 19.8179 16.919L20.2773 16.1504C20.536 15.7175 20.6654 15.501 20.6877 15.2793C20.7065 15.0921 20.6721 14.9034 20.5885 14.7349C20.4895 14.5353 20.2921 14.3783 19.8974 14.0643L19.1726 13.4879C18.9207 13.2876 18.7948 13.1875 18.7159 13.0801C18.6306 12.9641 18.5942 12.8887 18.5564 12.7497C18.5215 12.6211 18.5215 12.414 18.5215 12C18.5215 11.586 18.5215 11.379 18.5564 11.2504C18.5942 11.1114 18.6306 11.036 18.7159 10.9199C18.7948 10.8126 18.9207 10.7124 19.1725 10.5122L19.8974 9.9357C20.2922 9.62176 20.4896 9.46479 20.5886 9.26517C20.6722 9.09664 20.7065 8.90795 20.6877 8.72076C20.6654 8.49906 20.5361 8.28259 20.2773 7.84964L19.8179 7.08102C19.5728 6.67093 19.4503 6.46588 19.2755 6.34332C19.1277 6.23977 18.9548 6.1781 18.7748 6.16486C18.5619 6.14919 18.3373 6.23048 17.888 6.39307L16.8745 6.75989C16.5778 6.86725 16.4295 6.92093 16.2971 6.93195C16.167 6.94278 16.0884 6.93601 15.9621 6.90313C15.8335 6.86965 15.6604 6.77077 15.3142 6.57302C15.2877 6.55791 15.2611 6.54298 15.2345 6.52822C14.8725 6.3281 14.6915 6.22804 14.5936 6.13166C14.4976 6.03703 14.4502 5.97047 14.3923 5.84869C14.3334 5.72467 14.3055 5.56332 14.2499 5.24064L14.0938 4.3363Z" fill="#0F1729"/>
2585
- </svg>`;
1984
+ .cv-widget-icon:hover {
1985
+ /* Become fully opaque on hover to improve readability */
1986
+ background: rgba(255, 255, 255, 1);
1987
+ color: rgba(0, 0, 0, 1);
1988
+ opacity: 1;
2586
1989
  }
2587
- /**
2588
- * Close/X icon for modal close button
2589
- */
2590
- function getCloseIcon() {
2591
- return `<svg class="cv-modal-close-icon" fill="currentColor" height="20px" viewBox="0 0 256 256" width="20px" xmlns="http://www.w3.org/2000/svg">
2592
- <path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>
2593
- </svg>`;
1990
+
1991
+ /* Top-right: rounded end on left, sticks out leftward on hover */
1992
+ .cv-widget-top-right {
1993
+ top: 20px;
1994
+ right: 0;
1995
+ border-radius: 18px 0 0 18px;
1996
+ padding-left: 8px;
1997
+ justify-content: flex-start;
2594
1998
  }
2595
- /**
2596
- * Reset/refresh icon for reset button
2597
- */
2598
- function getResetIcon() {
2599
- return `<svg class="cv-btn-icon" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2600
- <path d="M22.719 12A10.719 10.719 0 0 1 1.28 12h.838a9.916 9.916 0 1 0 1.373-5H8v1H2V2h1v4.2A10.71 10.71 0 0 1 22.719 12z"/><path fill="none" d="M0 0h24v24H0z"/>
2601
- </svg>`;
1999
+
2000
+ /* Top-left: rounded end on right, sticks out rightward on hover */
2001
+ .cv-widget-top-left {
2002
+ top: 20px;
2003
+ left: 0;
2004
+ border-radius: 0 18px 18px 0;
2005
+ padding-right: 8px;
2006
+ justify-content: flex-end;
2602
2007
  }
2603
- /**
2604
- * Copy icon for sharing URL button
2605
- */
2606
- function getCopyIcon() {
2607
- return `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="18" height="18" viewBox="0 0 18 18" version="1.1" fill="currentColor">
2608
- <g id="surface1">
2609
- <path d="M 11.273438 0 L 2.546875 0 C 1.746094 0 1.089844 0.613281 1.089844
2610
- 1.363281 L 1.089844 10.910156 L 2.546875 10.910156 L 2.546875 1.363281 L 11.273438
2611
- 1.363281 Z M 13.453125 2.726562 L 5.453125 2.726562 C 4.65625 2.726562 4 3.339844 4
2612
- 4.089844 L 4 13.636719 C 4 14.386719 4.65625 15 5.453125 15 L 13.453125 15 C 14.253906
2613
- 15 14.910156 14.386719 14.910156 13.636719 L 14.910156 4.089844 C 14.910156 3.339844
2614
- 14.253906 2.726562 13.453125 2.726562 Z M 13.453125 13.636719 L 5.453125 13.636719 L
2615
- 5.453125 4.089844 L 13.453125 4.089844 Z M 13.453125 13.636719 "></path>
2616
- </g>
2617
- </svg>`;
2008
+
2009
+ /* Bottom-right: rounded end on left, sticks out leftward on hover */
2010
+ .cv-widget-bottom-right {
2011
+ bottom: 20px;
2012
+ right: 0;
2013
+ border-radius: 18px 0 0 18px;
2014
+ padding-left: 8px;
2015
+ justify-content: flex-start;
2618
2016
  }
2619
- function getTickIcon() {
2620
- return `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="2 2 22 22" fill="currentColor">
2621
- <path d="M 19.28125 5.28125 L 9 15.5625 L 4.71875 11.28125 L 3.28125 12.71875 L 8.28125 17.71875
2622
- L 9 18.40625 L 9.71875 17.71875 L 20.71875 6.71875 Z"></path>
2623
- </svg>`;
2017
+
2018
+ /* Bottom-left: rounded end on right, sticks out rightward on hover */
2019
+ .cv-widget-bottom-left {
2020
+ bottom: 20px;
2021
+ left: 0;
2022
+ border-radius: 0 18px 18px 0;
2023
+ padding-right: 8px;
2024
+ justify-content: flex-end;
2624
2025
  }
2625
- function getNavHeadingOnIcon() {
2626
- return `<svg xmlns="http://www.w3.org/2000/svg" width="250" height="181" viewBox="0 0 250 181">
2627
- <rect y="34.5001" width="250" height="146" rx="4" stroke="currentColor" stroke-width="10" fill="none"/>
2628
- <line x1="27" y1="62.0001" x2="77" y2="62.0001" stroke="currentColor" stroke-width="5"/>
2629
- <line x1="27" y1="77.8888" x2="77" y2="77.8888" stroke="currentColor" stroke-width="5"/>
2630
- <line x1="27" y1="97.4454" x2="221" y2="97.4454" stroke="currentColor" stroke-width="5"/>
2631
- <line x1="27" y1="114.555" x2="221" y2="114.555" stroke="currentColor" stroke-width="5"/>
2632
- <line x1="27" y1="132.889" x2="221" y2="132.889" stroke="currentColor" stroke-width="5"/>
2633
- <line x1="27" y1="150" x2="221" y2="150" stroke="currentColor" stroke-width="5"/>
2634
- <line x1="247.5" y1="43.0001" x2="247.5" y2="13.0001" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2635
- <path d="M185 12.5001L247 12.5001" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2636
- <line x1="204.09" y1="36.6095" x2="181.698" y2="10.0228" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2637
- <path d="M125 9.50012L181 9.50012" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2638
- <path d="M144.305 35.2579L120.095 6.56679" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2639
- <path d="M120 6.50037L64 6.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2640
- <path d="M87.1957 36.1024L59 2.50008" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2641
- <path d="M59 2.50037L3 2.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2642
- <path d="M2.5 38.5001L2.5 3.00012" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2643
- </svg>`;
2026
+
2027
+ /* Middle-left: rounded end on right, sticks out rightward on hover */
2028
+ .cv-widget-middle-left {
2029
+ top: 50%;
2030
+ left: 0;
2031
+ transform: translateY(-50%);
2032
+ border-radius: 0 18px 18px 0;
2033
+ padding-right: 8px;
2034
+ justify-content: flex-end;
2644
2035
  }
2645
- function getNavHeadingOffIcon() {
2646
- return `<svg xmlns="http://www.w3.org/2000/svg" width="250" height="181" viewBox="0 0 250 181" fill="currentColor">
2647
- <rect y="34.5001" width="250" height="146" rx="4" stroke="currentColor" stroke-width="10" fill="none"/>
2648
- <line x1="27" y1="62" x2="77" y2="62" stroke="currentColor" stroke-width="5"/>
2649
- <line x1="27" y1="77.8887" x2="77" y2="77.8887" stroke="currentColor" stroke-width="5"/>
2650
- <line x1="27" y1="97.4453" x2="221" y2="97.4453" stroke="currentColor" stroke-width="5"/>
2651
- <line x1="27" y1="114.555" x2="221" y2="114.555" stroke="currentColor" stroke-width="5"/>
2652
- <line x1="27" y1="132.889" x2="221" y2="132.889" stroke="currentColor" stroke-width="5"/>
2653
- <line x1="27" y1="150" x2="221" y2="150" stroke="currentColor" stroke-width="5"/>
2654
- </svg>`;
2036
+
2037
+ /* Middle-right: rounded end on left, sticks out leftward on hover */
2038
+ .cv-widget-middle-right {
2039
+ top: 50%;
2040
+ right: 0;
2041
+ transform: translateY(-50%);
2042
+ border-radius: 18px 0 0 18px;
2043
+ padding-left: 8px;
2044
+ justify-content: flex-start;
2045
+ }
2046
+
2047
+ .cv-widget-top-right,
2048
+ .cv-widget-middle-right,
2049
+ .cv-widget-bottom-right,
2050
+ .cv-widget-top-left,
2051
+ .cv-widget-middle-left,
2052
+ .cv-widget-bottom-left {
2053
+ height: 36px;
2054
+ width: 36px;
2055
+ }
2056
+
2057
+ .cv-widget-middle-right:hover,
2058
+ .cv-widget-top-right:hover,
2059
+ .cv-widget-bottom-right:hover,
2060
+ .cv-widget-top-left:hover,
2061
+ .cv-widget-middle-left:hover,
2062
+ .cv-widget-bottom-left:hover {
2063
+ width: 55px;
2064
+ }
2065
+
2066
+ /* Modal content styles */
2067
+ .cv-widget-section {
2068
+ margin-bottom: 16px;
2069
+ }
2070
+
2071
+ .cv-widget-section:last-child {
2072
+ margin-bottom: 0;
2073
+ }
2074
+
2075
+ .cv-widget-section label {
2076
+ display: block;
2077
+ margin-bottom: 4px;
2078
+ font-weight: 500;
2079
+ color: #555;
2080
+ }
2081
+
2082
+ .cv-widget-profile-select,
2083
+ .cv-widget-state-select {
2084
+ width: 100%;
2085
+ padding: 8px 12px;
2086
+ border: 1px solid #ddd;
2087
+ border-radius: 4px;
2088
+ background: white;
2089
+ font-size: 14px;
2090
+ }
2091
+
2092
+ .cv-widget-profile-select:focus,
2093
+ .cv-widget-state-select:focus {
2094
+ outline: none;
2095
+ border-color: #007bff;
2096
+ box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
2097
+ }
2098
+
2099
+ .cv-widget-profile-select:disabled,
2100
+ .cv-widget-state-select:disabled {
2101
+ background: #f8f9fa;
2102
+ color: #6c757d;
2103
+ cursor: not-allowed;
2104
+ }
2105
+
2106
+ .cv-widget-current {
2107
+ margin: 16px 0;
2108
+ padding: 12px;
2109
+ background: #f8f9fa;
2110
+ border-radius: 4px;
2111
+ border-left: 4px solid #007bff;
2112
+ }
2113
+
2114
+ .cv-widget-current label {
2115
+ font-size: 12px;
2116
+ text-transform: uppercase;
2117
+ letter-spacing: 0.5px;
2118
+ color: #666;
2119
+ margin-bottom: 4px;
2120
+ }
2121
+
2122
+ .cv-widget-current-view {
2123
+ font-weight: 500;
2124
+ color: #333;
2125
+ }
2126
+
2127
+ .cv-widget-reset {
2128
+ width: 100%;
2129
+ padding: 8px 16px;
2130
+ background: #dc3545;
2131
+ color: white;
2132
+ border: none;
2133
+ border-radius: 4px;
2134
+ cursor: pointer;
2135
+ font-size: 14px;
2136
+ font-weight: 500;
2137
+ }
2138
+
2139
+ .cv-widget-reset:hover {
2140
+ background: #c82333;
2141
+ }
2142
+
2143
+ .cv-widget-reset:active {
2144
+ background: #bd2130;
2145
+ }
2146
+
2147
+ /* Responsive design for mobile */
2148
+ @media (max-width: 768px) {
2149
+ .cv-widget-top-right,
2150
+ .cv-widget-top-left {
2151
+ top: 10px;
2152
+ }
2153
+
2154
+ .cv-widget-bottom-right,
2155
+ .cv-widget-bottom-left {
2156
+ bottom: 10px;
2157
+ }
2158
+
2159
+ /* All widgets stay flush with screen edges */
2160
+ .cv-widget-top-right,
2161
+ .cv-widget-bottom-right,
2162
+ .cv-widget-middle-right {
2163
+ right: 0;
2164
+ }
2165
+
2166
+ .cv-widget-top-left,
2167
+ .cv-widget-bottom-left,
2168
+ .cv-widget-middle-left {
2169
+ left: 0;
2170
+ }
2171
+
2172
+ /* Slightly smaller on mobile */
2173
+ .cv-widget-icon {
2174
+ width: 60px;
2175
+ height: 32px;
2176
+ }
2177
+
2178
+ .cv-widget-icon:hover {
2179
+ width: 75px;
2180
+ }
2181
+ }
2182
+
2183
+ /* Modal styles */
2184
+ .cv-widget-modal-overlay {
2185
+ position: fixed;
2186
+ top: 0;
2187
+ left: 0;
2188
+ right: 0;
2189
+ bottom: 0;
2190
+ background: rgba(0, 0, 0, 0.5);
2191
+ display: flex;
2192
+ align-items: center;
2193
+ justify-content: center;
2194
+ z-index: 10002;
2195
+ animation: fadeIn 0.2s ease;
2196
+ }
2197
+
2198
+ .cv-widget-modal-overlay.cv-hidden {
2199
+ display: none;
2200
+ }
2201
+
2202
+ @keyframes fadeIn {
2203
+ from { opacity: 0; }
2204
+ to { opacity: 1; }
2205
+ }
2206
+
2207
+ .cv-widget-modal {
2208
+ background: white;
2209
+ border-radius: 0.75rem;
2210
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
2211
+ max-width: 32rem;
2212
+ width: 90vw;
2213
+ max-height: 80vh;
2214
+ animation: slideIn 0.2s ease;
2215
+ display: flex;
2216
+ flex-direction: column;
2217
+ }
2218
+
2219
+ @keyframes slideIn {
2220
+ from {
2221
+ opacity: 0;
2222
+ transform: scale(0.9) translateY(-20px);
2223
+ }
2224
+ to {
2225
+ opacity: 1;
2226
+ transform: scale(1) translateY(0);
2227
+ }
2228
+ }
2229
+
2230
+ .cv-modal-header {
2231
+ display: flex;
2232
+ align-items: center;
2233
+ justify-content: space-between;
2234
+ padding: 0.5rem 1rem;
2235
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
2236
+ }
2237
+
2238
+ .cv-modal-header-content {
2239
+ display: flex;
2240
+ align-items: center;
2241
+ gap: 0.75rem;
2242
+ }
2243
+
2244
+ .cv-modal-icon {
2245
+ position: relative;
2246
+ width: 1rem;
2247
+ height: 1rem;
2248
+ display: flex;
2249
+ align-items: center;
2250
+ justify-content: center;
2251
+ border-radius: 9999px;
2252
+ }
2253
+
2254
+ .cv-modal-icon-svg {
2255
+ width: 100%;
2256
+ height: 100%;
2257
+ opacity: 1;
2258
+ }
2259
+
2260
+ .cv-modal-title {
2261
+ font-size: 1.125rem;
2262
+ font-weight: bold;
2263
+ color: rgba(0, 0, 0, 0.9);
2264
+ margin: 0;
2265
+ }
2266
+
2267
+ .cv-modal-close {
2268
+ width: 2rem;
2269
+ height: 2rem;
2270
+ display: flex;
2271
+ align-items: center;
2272
+ justify-content: center;
2273
+ border-radius: 9999px;
2274
+ background: transparent;
2275
+ border: none;
2276
+ color: rgba(0, 0, 0, 0.6);
2277
+ cursor: pointer;
2278
+ transition: all 0.2s ease;
2279
+ }
2280
+
2281
+ .cv-modal-close:hover {
2282
+ background: rgba(62, 132, 244, 0.1);
2283
+ color: #3e84f4;
2284
+ }
2285
+
2286
+ .cv-modal-close-icon {
2287
+ width: 1.25rem;
2288
+ height: 1.25rem;
2289
+ }
2290
+
2291
+ .cv-modal-main {
2292
+ padding: 1rem;
2293
+ flex: 1;
2294
+ display: flex;
2295
+ flex-direction: column;
2296
+ gap: 1rem;
2297
+ overflow-y: auto;
2298
+ max-height: calc(80vh - 8rem);
2299
+ }
2300
+
2301
+ .cv-modal-description {
2302
+ font-size: 0.875rem;
2303
+ color: rgba(0, 0, 0, 0.8);
2304
+ margin: 0;
2305
+ line-height: 1.4;
2306
+ }
2307
+
2308
+ .cv-content-section,
2309
+ .cv-tab-groups-section {
2310
+ display: flex;
2311
+ flex-direction: column;
2312
+ gap: 0.75rem;
2313
+ }
2314
+
2315
+ .cv-section-heading {
2316
+ font-size: 1rem;
2317
+ font-weight: bold;
2318
+ color: rgba(0, 0, 0, 0.9);
2319
+ margin: 0;
2320
+ }
2321
+
2322
+ .cv-widget-modal-actions {
2323
+ margin-top: 20px;
2324
+ padding-top: 16px;
2325
+ border-top: 1px solid #e9ecef;
2326
+ }
2327
+
2328
+ .cv-widget-restore {
2329
+ width: 100%;
2330
+ padding: 10px 16px;
2331
+ background: #28a745;
2332
+ color: white;
2333
+ border: none;
2334
+ border-radius: 4px;
2335
+ cursor: pointer;
2336
+ font-size: 14px;
2337
+ font-weight: 500;
2338
+ }
2339
+
2340
+ .cv-widget-restore:hover {
2341
+ background: #218838;
2342
+ }
2343
+
2344
+ .cv-widget-create-state {
2345
+ width: 100%;
2346
+ padding: 10px 16px;
2347
+ background: #007bff;
2348
+ color: white;
2349
+ border: none;
2350
+ border-radius: 4px;
2351
+ cursor: pointer;
2352
+ font-size: 14px;
2353
+ font-weight: 500;
2354
+ margin-bottom: 10px;
2355
+ }
2356
+
2357
+ .cv-widget-create-state:hover {
2358
+ background: #0056b3;
2359
+ }
2360
+
2361
+ .cv-widget-theme-dark .cv-widget-modal {
2362
+ background: #101722;
2363
+ color: #e2e8f0;
2364
+ }
2365
+
2366
+ .cv-widget-theme-dark .cv-modal-header {
2367
+ border-color: rgba(255, 255, 255, 0.1);
2368
+ }
2369
+
2370
+ .cv-widget-theme-dark .cv-modal-title {
2371
+ color: #e2e8f0;
2372
+ }
2373
+
2374
+ .cv-widget-theme-dark .cv-modal-close {
2375
+ color: rgba(255, 255, 255, 0.6);
2376
+ }
2377
+
2378
+ .cv-widget-theme-dark .cv-modal-close:hover {
2379
+ background: rgba(62, 132, 244, 0.2);
2380
+ color: #3e84f4;
2381
+ }
2382
+
2383
+ .cv-widget-theme-dark .cv-modal-description {
2384
+ color: rgba(255, 255, 255, 0.8);
2385
+ }
2386
+
2387
+ .cv-widget-theme-dark .cv-section-heading {
2388
+ color: #e2e8f0;
2389
+ }
2390
+
2391
+ .cv-widget-theme-dark .cv-toggles-container
2392
+ .cv-widget-theme-dark .cv-tabgroups-container {
2393
+ border-color: rgba(255, 255, 255, 0.1);
2394
+ }
2395
+
2396
+ .cv-widget-theme-dark .cv-toggle-card,
2397
+ .cv-widget-theme-dark .cv-tabgroup-card {
2398
+ background: #101722;
2399
+ border-color: rgba(255, 255, 255, 0.1);
2400
+ }
2401
+
2402
+ .cv-widget-theme-dark .cv-toggle-title,
2403
+ .cv-widget-theme-dark .cv-tabgroup-title {
2404
+ color: #e2e8f0;
2405
+ }
2406
+
2407
+ .cv-widget-theme-dark .cv-toggle-description,
2408
+ .cv-widget-theme-dark .cv-tabgroup-description {
2409
+ color: rgba(255, 255, 255, 0.6);
2410
+ }
2411
+
2412
+ .cv-widget-theme-dark .cv-toggle-slider {
2413
+ background: rgba(255, 255, 255, 0.2);
2414
+ }
2415
+
2416
+ .cv-widget-theme-dark .cv-tab-group-description {
2417
+ color: rgba(255, 255, 255, 0.8);
2418
+ }
2419
+
2420
+ .cv-widget-theme-dark .cv-tabgroup-select {
2421
+ background: #101722;
2422
+ border-color: rgba(255, 255, 255, 0.2);
2423
+ color: #e2e8f0;
2424
+ }
2425
+
2426
+ .cv-widget-theme-dark .cv-modal-footer {
2427
+ border-color: rgba(255, 255, 255, 0.1);
2428
+ background: #101722;
2429
+ }
2430
+
2431
+ .cv-widget-theme-dark .cv-reset-btn {
2432
+ color: #e2e8f0;
2433
+ background: rgba(255, 255, 255, 0.1);
2434
+ }
2435
+
2436
+ .cv-widget-theme-dark .cv-reset-btn:hover {
2437
+ background: rgba(255, 255, 255, 0.2);
2438
+ }
2439
+
2440
+ /* Custom state creator styles */
2441
+ .cv-custom-state-modal {
2442
+ max-width: 500px;
2443
+ }
2444
+
2445
+ .cv-custom-state-form .cv-section-header {
2446
+ font-size: 16px;
2447
+ font-weight: 600;
2448
+ color: #333;
2449
+ border-bottom: 1px solid #e9ecef;
2450
+ padding-bottom: 5px;
2451
+ }
2452
+
2453
+ .cv-custom-state-form p {
2454
+ font-size: 15px;
2455
+ line-height: 1.6;
2456
+ color: #555;
2457
+ margin-bottom: 24px;
2458
+ text-align: justify;
2459
+ }
2460
+
2461
+ .cv-custom-state-section {
2462
+ margin-bottom: 16px;
2463
+ }
2464
+
2465
+ .cv-custom-state-section label {
2466
+ display: block;
2467
+ margin-bottom: 4px;
2468
+ font-weight: 500;
2469
+ color: #555;
2470
+ }
2471
+
2472
+ .cv-custom-state-input {
2473
+ width: 100%;
2474
+ padding: 8px 12px;
2475
+ border: 1px solid #ddd;
2476
+ border-radius: 4px;
2477
+ background: white;
2478
+ font-size: 14px;
2479
+ }
2480
+
2481
+ .cv-custom-state-input:focus {
2482
+ outline: none;
2483
+ border-color: #007bff;
2484
+ box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
2485
+ }
2486
+
2487
+ /* Toggles Container */
2488
+ .cv-toggles-container {
2489
+ display: flex;
2490
+ flex-direction: column;
2491
+ gap: 0.5rem;
2492
+ border-radius: 0.5rem;
2493
+ border: 1px solid rgba(0, 0, 0, 0.1);
2494
+ overflow: hidden;
2495
+ }
2496
+
2497
+ .cv-toggle-card,
2498
+ .cv-tabgroup-card {
2499
+ background: white;
2500
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
2501
+ }
2502
+
2503
+ .cv-toggle-card:last-child {
2504
+ border-bottom: none;
2505
+ }
2506
+
2507
+ .cv-toggle-content {
2508
+ display: flex;
2509
+ align-items: center;
2510
+ justify-content: space-between;
2511
+ padding: 0.75rem;
2512
+ }
2513
+
2514
+ .cv-toggle-title {
2515
+ font-weight: 500;
2516
+ font-size: 0.875rem;
2517
+ color: rgba(0, 0, 0, 0.9);
2518
+ margin: 0 0 0.125rem 0;
2519
+ }
2520
+
2521
+ .cv-toggle-description {
2522
+ font-size: 0.75rem;
2523
+ color: rgba(0, 0, 0, 0.6);
2524
+ margin: 0;
2525
+ }
2526
+
2527
+ .cv-toggle-label{
2528
+ position: relative;
2529
+ display: inline-block;
2530
+ width: 2.75rem;
2531
+ height: 1.5rem;
2532
+ cursor: pointer;
2533
+ }
2534
+
2535
+ .cv-toggle-input {
2536
+ opacity: 0;
2537
+ width: 0;
2538
+ height: 0;
2539
+ }
2540
+
2541
+ .cv-toggle-slider {
2542
+ position: absolute;
2543
+ top: 0;
2544
+ left: 0;
2545
+ right: 0;
2546
+ bottom: 0;
2547
+ background: rgba(0, 0, 0, 0.2);
2548
+ border-radius: 9999px;
2549
+ transition: background-color 0.2s ease;
2550
+ }
2551
+
2552
+ .cv-toggle-slider:before {
2553
+ position: absolute;
2554
+ content: "";
2555
+ height: 1rem;
2556
+ width: 1rem;
2557
+ left: 0.25rem;
2558
+ bottom: 0.25rem;
2559
+ background: white;
2560
+ border-radius: 50%;
2561
+ transition: transform 0.2s ease;
2562
+ }
2563
+
2564
+ .cv-toggle-input:checked + .cv-toggle-slider {
2565
+ background: #3e84f4;
2566
+ }
2567
+
2568
+ .cv-toggle-input:checked + .cv-toggle-slider:before {
2569
+ transform: translateX(1.25rem);
2570
+ }
2571
+
2572
+ /* Dark theme toggle switch styles */
2573
+ .cv-widget-theme-dark .cv-toggle-switch {
2574
+ background: #4a5568;
2575
+ }
2576
+
2577
+ .cv-widget-theme-dark .cv-toggle-switch:hover {
2578
+ background: #5a6578;
2579
+ }
2580
+
2581
+ .cv-widget-theme-dark .cv-toggle-switch.cv-toggle-active {
2582
+ background: #63b3ed;
2583
+ }
2584
+
2585
+ .cv-widget-theme-dark .cv-toggle-switch.cv-toggle-active:hover {
2586
+ background: #4299e1;
2587
+ }
2588
+
2589
+ /* Tab Groups Container */
2590
+ .cv-tab-groups-list {
2591
+ display: flex;
2592
+ flex-direction: column;
2593
+ gap: 1px;
2594
+ border: 1px solid rgba(0, 0, 0, 0.1);
2595
+ border-radius: 0.5rem;
2596
+ overflow: hidden;
2597
+ }
2598
+
2599
+ /* Tab Group Card - Header (Navigation Headers toggle) */
2600
+ .cv-tabgroup-card.cv-tabgroup-header {
2601
+ display: flex;
2602
+ align-items: center;
2603
+ justify-content: space-between;
2604
+ padding: 0.75rem;
2605
+ border-bottom: 0px;
2606
+ }
2607
+
2608
+ .cv-tabgroup-card.cv-tabgroup-header .cv-tabgroup-row {
2609
+ display: flex;
2610
+ align-items: center;
2611
+ justify-content: space-between;
2612
+ width: 100%;
2613
+ gap: 1rem;
2614
+ }
2615
+
2616
+ /* Navigation toggle icon container */
2617
+ .cv-nav-toggle-container {
2618
+ display: flex;
2619
+ align-items: center;
2620
+ gap: 0.5rem;
2621
+ }
2622
+
2623
+ .cv-nav-icon {
2624
+ width: 2rem;
2625
+ height: 2rem;
2626
+ color: rgba(0, 0, 0, 0.8);
2627
+ display: flex;
2628
+ align-items: center;
2629
+ justify-content: center;
2630
+ flex-shrink: 0;
2631
+ transition: color 0.2s ease;
2632
+ }
2633
+
2634
+ /* Logo box - centered grey box on its own row */
2635
+ .cv-tabgroup-logo-box {
2636
+ width: 3.5rem;
2637
+ height: 3.5rem;
2638
+ background: rgba(0, 0, 0, 0.08);
2639
+ border-radius: 0.5rem;
2640
+ display: flex;
2641
+ align-items: center;
2642
+ justify-content: center;
2643
+ flex-shrink: 0;
2644
+ margin-bottom: 0.5rem;
2645
+ }
2646
+
2647
+ /* Title container for title alignment (without icon) */
2648
+ .cv-tabgroup-title-container {
2649
+ display: flex;
2650
+ align-items: center;
2651
+ gap: 0.5rem;
2652
+ }
2653
+
2654
+ /* Hover state for icon - apply to the entire tabgroup-row */
2655
+ .cv-tabgroup-card.cv-tabgroup-header:hover .cv-nav-icon {
2656
+ color: #3e84f4;
2657
+ }
2658
+
2659
+ .cv-widget-theme-dark .cv-nav-icon {
2660
+ color: rgba(255, 255, 255, 0.8);
2661
+ }
2662
+
2663
+ .cv-widget-theme-dark .cv-tabgroup-card.cv-tabgroup-header:hover .cv-nav-icon {
2664
+ color: #60a5fa;
2665
+ }
2666
+
2667
+ /* Tab Group Card - Items */
2668
+ .cv-tabgroup-card.cv-tabgroup-item {
2669
+ display: flex;
2670
+ flex-direction: column;
2671
+ gap: 0.5rem;
2672
+ padding: 0.75rem;
2673
+ background: white;
2674
+ border-bottom: 1px solid rgba(0, 0, 0, 0.05);
2675
+ }
2676
+
2677
+ .cv-tabgroup-card.cv-tabgroup-item:last-child {
2678
+ border-bottom: none;
2679
+ }
2680
+
2681
+ /* Tab Group Info */
2682
+ .cv-tabgroup-info {
2683
+ flex: 1;
2684
+ display: flex;
2685
+ flex-direction: column;
2686
+ gap: 0.25rem;
2687
+ }
2688
+
2689
+ .cv-tabgroup-title {
2690
+ font-weight: 500;
2691
+ font-size: 0.875rem;
2692
+ color: rgba(0, 0, 0, 0.9);
2693
+ margin: 0 0 0 0;
2694
+ }
2695
+
2696
+ .cv-tabgroup-description {
2697
+ font-size: 0.75rem;
2698
+ color: rgba(0, 0, 0, 0.6);
2699
+ margin: 0;
2700
+ line-height: 1.3;
2701
+ }
2702
+
2703
+ /* Tab Group Label (for select dropdowns) */
2704
+ .cv-tabgroup-label {
2705
+ font-size: 0.875rem;
2706
+ color: rgba(0, 0, 0, 0.8);
2707
+ margin: 0;
2708
+ line-height: 1.4;
2709
+ font-weight: 500;
2710
+ display: block;
2711
+ cursor: pointer;
2712
+ }
2713
+
2714
+ /* Tab Group Select */
2715
+ .cv-tabgroup-select {
2716
+ width: 100%;
2717
+ border-radius: 0.5rem;
2718
+ background: white;
2719
+ border: 1px solid rgba(0, 0, 0, 0.15);
2720
+ color: rgba(0, 0, 0, 0.9);
2721
+ padding: 0.5rem 0.75rem;
2722
+ font-size: 0.875rem;
2723
+ cursor: pointer;
2724
+ transition: all 0.15s ease;
2725
+ font-family: inherit;
2726
+ }
2727
+
2728
+ .cv-tabgroup-select:hover {
2729
+ border-color: rgba(0, 0, 0, 0.25);
2730
+ }
2731
+
2732
+ .cv-tabgroup-select:focus {
2733
+ outline: none;
2734
+ border-color: #3e84f4;
2735
+ box-shadow: 0 0 0 2px rgba(62, 132, 244, 0.2);
2736
+ }
2737
+
2738
+ /* Modern Toggle Switch */
2739
+ .cv-toggle-switch {
2740
+ position: relative;
2741
+ display: inline-flex;
2742
+ align-items: center;
2743
+ width: 44px;
2744
+ height: 24px;
2745
+ background: rgba(0, 0, 0, 0.1);
2746
+ border-radius: 9999px;
2747
+ padding: 2px;
2748
+ box-sizing: border-box;
2749
+ cursor: pointer;
2750
+ transition: background-color 0.2s ease;
2751
+ border: none;
2752
+ }
2753
+
2754
+ .cv-toggle-switch input {
2755
+ display: none;
2756
+ }
2757
+
2758
+ .cv-toggle-switch .cv-switch-bg {
2759
+ position: absolute;
2760
+ inset: 0;
2761
+ border-radius: 9999px;
2762
+ background: rgba(0, 0, 0, 0.1);
2763
+ transition: background-color 0.2s ease;
2764
+ pointer-events: none;
2765
+ }
2766
+
2767
+ .cv-toggle-switch .cv-switch-knob {
2768
+ position: relative;
2769
+ width: 20px;
2770
+ height: 20px;
2771
+ background: white;
2772
+ border-radius: 50%;
2773
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
2774
+ transition: transform 0.2s ease;
2775
+ z-index: 1;
2776
+ }
2777
+
2778
+ .cv-toggle-switch input:checked + .cv-switch-bg {
2779
+ background: #3e84f4;
2780
+ }
2781
+
2782
+ .cv-toggle-switch input:checked ~ .cv-switch-knob {
2783
+ transform: translateX(20px);
2784
+ }
2785
+
2786
+ /* Dark Theme - Tab Groups */
2787
+ .cv-widget-theme-dark .cv-tabgroup-card.cv-tabgroup-header {
2788
+ background: #101722;
2789
+ border-bottom-color: rgba(255, 255, 255, 0.1);
2790
+ }
2791
+
2792
+ .cv-widget-theme-dark .cv-tabgroup-card.cv-tabgroup-item {
2793
+ background: #101722;
2794
+ border-bottom-color: rgba(255, 255, 255, 0.05);
2795
+ }
2796
+
2797
+ .cv-widget-theme-dark .cv-tabgroup-title {
2798
+ color: #e2e8f0;
2799
+ }
2800
+
2801
+ .cv-widget-theme-dark .cv-tabgroup-description {
2802
+ color: rgba(255, 255, 255, 0.6);
2803
+ }
2804
+
2805
+ .cv-widget-theme-dark .cv-tabgroup-label {
2806
+ color: rgba(255, 255, 255, 0.8);
2807
+ }
2808
+
2809
+ .cv-widget-theme-dark .cv-tab-groups-list {
2810
+ border-color: rgba(255, 255, 255, 0.1);
2811
+ }
2812
+
2813
+ .cv-widget-theme-dark .cv-tabgroup-select {
2814
+ background: #101722;
2815
+ border-color: rgba(255, 255, 255, 0.15);
2816
+ color: #e2e8f0;
2817
+ }
2818
+
2819
+ .cv-widget-theme-dark .cv-tabgroup-select:hover {
2820
+ border-color: rgba(255, 255, 255, 0.25);
2821
+ }
2822
+
2823
+ .cv-widget-theme-dark .cv-tabgroup-select:focus {
2824
+ border-color: #60a5fa;
2825
+ box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
2826
+ }
2827
+
2828
+ /* Dark Theme - Toggle Switch */
2829
+ .cv-widget-theme-dark .cv-toggle-switch .cv-switch-bg {
2830
+ background: rgba(255, 255, 255, 0.1);
2831
+ }
2832
+
2833
+ .cv-widget-theme-dark .cv-toggle-switch .cv-switch-knob {
2834
+ background: #e2e8f0;
2835
+ }
2836
+
2837
+ .cv-widget-theme-dark .cv-toggle-switch input:checked + .cv-switch-bg {
2838
+ background: #63b3ed;
2839
+ }
2840
+
2841
+ .cv-modal-footer {
2842
+ display: flex;
2843
+ justify-content: space-between;
2844
+ align-items: center;
2845
+ padding: 0.75rem;
2846
+ border-top: 1px solid rgba(0, 0, 0, 0.1);
2847
+ }
2848
+
2849
+ .cv-reset-btn,
2850
+ .cv-share-btn {
2851
+ display: flex;
2852
+ align-items: center;
2853
+ gap: 0.5rem;
2854
+ padding: 0.375rem 0.75rem;
2855
+ border-radius: 0.5rem;
2856
+ font-weight: 600;
2857
+ font-size: 0.875rem;
2858
+ cursor: pointer;
2859
+ transition: all 0.2s ease;
2860
+ border: none;
2861
+ }
2862
+
2863
+ .cv-reset-btn {
2864
+ color: rgba(0, 0, 0, 0.9);
2865
+ background: rgba(0, 0, 0, 0.1);
2866
+ }
2867
+
2868
+ .cv-reset-btn:hover {
2869
+ background: rgba(0, 0, 0, 0.2);
2870
+ }
2871
+
2872
+ .cv-share-btn {
2873
+ color: white;
2874
+ background: #3e84f4;
2875
+ }
2876
+
2877
+ .cv-share-btn:hover {
2878
+ background: rgba(62, 132, 244, 0.9);
2879
+ }
2880
+
2881
+ .cv-btn-icon {
2882
+ width: 1rem;
2883
+ height: 1rem;
2884
+ display: flex;
2885
+ align-items: center;
2886
+ justify-content: center;
2887
+ transition: transform 0.2s ease;
2888
+ }
2889
+
2890
+ /* Dark theme custom state styles */
2891
+ /* Welcome modal styles */
2892
+ .cv-welcome-modal {
2893
+ max-width: 32rem;
2894
+ width: 90vw;
2895
+ background: white;
2896
+ border-radius: 0.75rem;
2897
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
2898
+ animation: slideIn 0.2s ease;
2899
+ display: flex;
2900
+ flex-direction: column;
2901
+ }
2902
+
2903
+ .cv-modal-main {
2904
+ padding: 1rem;
2905
+ flex: 1;
2906
+ display: flex;
2907
+ flex-direction: column;
2908
+ gap: 1rem;
2909
+ overflow-y: auto;
2910
+ max-height: calc(80vh - 8rem);
2911
+ }
2912
+
2913
+ .cv-welcome-message {
2914
+ font-size: 0.875rem;
2915
+ color: rgba(0, 0, 0, 0.8);
2916
+ margin: 0;
2917
+ line-height: 1.4;
2918
+ text-align: center;
2919
+ }
2920
+
2921
+ .cv-welcome-message a {
2922
+ color: #3e84f4;
2923
+ text-align: justify;
2924
+ text-decoration: none;
2925
+ }
2926
+
2927
+ .cv-welcome-message a:hover {
2928
+ text-decoration: underline;
2929
+ }
2930
+
2931
+ .cv-welcome-widget-preview {
2932
+ display: flex;
2933
+ align-items: center;
2934
+ justify-content: center;
2935
+ gap: 1rem;
2936
+ padding: 1rem;
2937
+ background: #f8f9fa;
2938
+ border-radius: 0.5rem;
2939
+ margin: 1rem 0;
2940
+ }
2941
+
2942
+ .cv-welcome-widget-icon {
2943
+ width: 2rem;
2944
+ height: 2rem;
2945
+ background: rgba(62, 132, 244, 0.1);
2946
+ border-radius: 9999px;
2947
+ display: flex;
2948
+ align-items: center;
2949
+ justify-content: center;
2950
+ animation: cv-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
2951
+ color: #3e84f4;
2952
+ }
2953
+
2954
+ .cv-welcome-widget-label {
2955
+ font-size: 0.875rem;
2956
+ font-weight: 500;
2957
+ color: rgba(0, 0, 0, 0.8);
2958
+ margin: 0;
2959
+ }
2960
+
2961
+ .cv-welcome-got-it {
2962
+ width: 100%;
2963
+ background: #3e84f4;
2964
+ color: white;
2965
+ font-weight: 600;
2966
+ padding: 0.75rem 1rem;
2967
+ border-radius: 0.5rem;
2968
+ border: none;
2969
+ cursor: pointer;
2970
+ font-size: 0.875rem;
2971
+ transition: background-color 0.2s ease;
2972
+ outline: none;
2973
+ }
2974
+
2975
+ .cv-welcome-got-it:hover {
2976
+ background: rgba(62, 132, 244, 0.9);
2977
+ }
2978
+
2979
+ .cv-welcome-got-it:focus {
2980
+ box-shadow: 0 0 0 2px rgba(62, 132, 244, 0.5);
2981
+ }
2982
+
2983
+ /* Animations */
2984
+ @keyframes cv-pulse {
2985
+ 0%, 100% {
2986
+ opacity: 1;
2987
+ }
2988
+ 50% {
2989
+ opacity: 0.5;
2990
+ }
2991
+ }
2992
+
2993
+ /* Dark theme welcome modal styles */
2994
+ .cv-widget-theme-dark .cv-welcome-modal {
2995
+ background: #101722;
2996
+ }
2997
+
2998
+ .cv-widget-theme-dark .cv-welcome-message {
2999
+ color: rgba(255, 255, 255, 0.8);
3000
+ }
3001
+
3002
+ .cv-widget-theme-dark .cv-welcome-message a {
3003
+ color: #60a5fa;
3004
+ }
3005
+
3006
+ .cv-widget-theme-dark .cv-welcome-widget-preview {
3007
+ background: rgba(255, 255, 255, 0.1);
2655
3008
  }
3009
+
3010
+ .cv-widget-theme-dark .cv-welcome-widget-label {
3011
+ color: #e2e8f0;
3012
+ }
3013
+
3014
+ /* Dark theme logo box */
3015
+ .cv-widget-theme-dark .cv-tabgroup-logo-box {
3016
+ background: rgba(255, 255, 255, 0.1);
3017
+ }
3018
+
3019
+ /* Spinning animation for reset button icon */
3020
+ @keyframes cv-spin {
3021
+ from {
3022
+ transform: rotate(0deg);
3023
+ }
3024
+ to {
3025
+ transform: rotate(-360deg);
3026
+ }
3027
+ }
3028
+
3029
+ .cv-spinning {
3030
+ animation: cv-spin 0.6s ease-in-out;
3031
+ }
3032
+
3033
+ /* Hide widget icon in print view */
3034
+ @media print {
3035
+ .cv-widget-icon {
3036
+ display: none !important;
3037
+ }
3038
+ }
3039
+ `;
2656
3040
  /**
2657
- * Transition Icon for Navigation Headings
3041
+ * Inject widget styles into the document head
2658
3042
  */
2659
- function getNavDashed() {
2660
- return `<svg xmlns="http://www.w3.org/2000/svg" width="250" height="181" viewBox="0 0 250 181">
2661
- <rect y="34.5001" width="250" height="146" rx="4" stroke="currentColor" stroke-width="10" fill="none"/>
2662
- <line x1="27" y1="62.0001" x2="77" y2="62.0001" stroke="currentColor" stroke-width="5"/>
2663
- <line x1="27" y1="77.8888" x2="77" y2="77.8888" stroke="currentColor" stroke-width="5"/>
2664
- <line x1="27" y1="97.4454" x2="221" y2="97.4454" stroke="currentColor" stroke-width="5"/>
2665
- <line x1="27" y1="114.555" x2="221" y2="114.555" stroke="currentColor" stroke-width="5"/>
2666
- <line x1="27" y1="132.889" x2="221" y2="132.889" stroke="currentColor" stroke-width="5"/>
2667
- <line x1="27" y1="150" x2="221" y2="150" stroke="currentColor" stroke-width="5"/>
2668
- <path d="M245 37.0001V39.5001H250V37.0001H247.5H245ZM250 13.0001C250 11.6194 248.881 10.5001 247.5 10.5001C246.119 10.5001 245 11.6194 245 13.0001H247.5H250ZM250 31.0001C250 29.6194 248.881 28.5001 247.5 28.5001C246.119 28.5001 245 29.6194 245 31.0001H247.5H250ZM245 19.0001C245 20.3808 246.119 21.5001 247.5 21.5001C248.881 21.5001 250 20.3808 250 19.0001H247.5H245ZM247.5 37.0001H250V31.0001H247.5H245V37.0001H247.5ZM247.5 19.0001H250V13.0001H247.5H245V19.0001H247.5Z" fill="currentColor"/>
2669
- <line x1="204.09" y1="36.6095" x2="181.698" y2="10.0228" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2670
- <path d="M125 9.50012L181 9.50012" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2671
- <path d="M144.305 35.2579L120.095 6.56679" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2672
- <path d="M120 6.50037L64 6.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2673
- <path d="M87.1957 36.1024L59 2.50008" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2674
- <path d="M59 2.50037L3 2.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2675
- <path d="M2.5 38.5001L2.5 3.00012" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2676
- <path d="M185 12.5001L247 12.5001" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2677
- </svg>`;
3043
+ function injectWidgetStyles() {
3044
+ // Check if styles are already injected
3045
+ if (document.querySelector('#cv-widget-styles'))
3046
+ return;
3047
+ const style = document.createElement('style');
3048
+ style.id = 'cv-widget-styles';
3049
+ style.textContent = WIDGET_STYLES;
3050
+ document.head.appendChild(style);
2678
3051
  }
2679
3052
 
2680
3053
  class CustomViewsWidget {
@@ -2682,8 +3055,11 @@ class CustomViewsWidget {
2682
3055
  container;
2683
3056
  widgetIcon = null;
2684
3057
  options;
3058
+ _hasVisibleConfig = false;
3059
+ pageToggleIds = new Set();
3060
+ pageTabIds = new Set();
2685
3061
  // Modal state
2686
- modal = null;
3062
+ stateModal = null;
2687
3063
  constructor(options) {
2688
3064
  this.core = options.core;
2689
3065
  this.container = options.container || document.body;
@@ -2701,12 +3077,41 @@ class CustomViewsWidget {
2701
3077
  welcomeMessage: options.welcomeMessage || 'This site is powered by Custom Views. Use the widget on the side (⚙) to customize your experience. Your preferences will be saved and can be shared via URL.<br><br>Learn more at <a href="https://github.com/customviews-js/customviews" target="_blank">customviews GitHub</a>.',
2702
3078
  showTabGroups: options.showTabGroups ?? true
2703
3079
  };
2704
- // No external state manager to initialize
3080
+ // Determine if there are any configurations to show
3081
+ const config = this.core.getConfig();
3082
+ const allToggles = config?.toggles || [];
3083
+ const visibleToggles = allToggles.filter(toggle => {
3084
+ if (toggle.isLocal) {
3085
+ return !!document.querySelector(`[data-cv-toggle="${toggle.id}"], [data-cv-toggle-group-id="${toggle.id}"]`);
3086
+ }
3087
+ return true;
3088
+ });
3089
+ const allTabGroups = this.core.getTabGroups() || [];
3090
+ const visibleTabGroups = allTabGroups.filter(group => {
3091
+ if (group.isLocal) {
3092
+ return !!document.querySelector(`cv-tabgroup[id="${group.id}"]`);
3093
+ }
3094
+ return true;
3095
+ });
3096
+ if (visibleToggles.length > 0 || (this.options.showTabGroups && visibleTabGroups.length > 0)) {
3097
+ this._hasVisibleConfig = true;
3098
+ }
3099
+ // Scan for page-declared local components and cache them
3100
+ // Do this on initialization to avoid querying DOM repeatedly
3101
+ const pageTogglesAttr = document.querySelector('[data-cv-page-local-toggles]')?.getAttribute('data-cv-page-local-toggles') || '';
3102
+ this.pageToggleIds = new Set(pageTogglesAttr.split(',').map(id => id.trim()).filter(id => id));
3103
+ const pageTabsAttr = document.querySelector('[data-cv-page-local-tabs]')?.getAttribute('data-cv-page-local-tabs') || '';
3104
+ this.pageTabIds = new Set(pageTabsAttr.split(',').map(id => id.trim()).filter(id => id));
2705
3105
  }
2706
3106
  /**
2707
- * Render the widget
3107
+ * Render the widget modal icon
3108
+ *
3109
+ * Does not render if there are no visible toggles or tab groups.
2708
3110
  */
2709
- render() {
3111
+ renderModalIcon() {
3112
+ if (!this._hasVisibleConfig) {
3113
+ return;
3114
+ }
2710
3115
  this.widgetIcon = this.createWidgetIcon();
2711
3116
  this.attachEventListeners();
2712
3117
  // Always append to body since it's a floating icon
@@ -2739,9 +3144,9 @@ class CustomViewsWidget {
2739
3144
  this.widgetIcon = null;
2740
3145
  }
2741
3146
  // Clean up modal
2742
- if (this.modal) {
2743
- this.modal.remove();
2744
- this.modal = null;
3147
+ if (this.stateModal) {
3148
+ this.stateModal.remove();
3149
+ this.stateModal = null;
2745
3150
  }
2746
3151
  }
2747
3152
  attachEventListeners() {
@@ -2754,294 +3159,299 @@ class CustomViewsWidget {
2754
3159
  * Close the modal
2755
3160
  */
2756
3161
  closeModal() {
2757
- if (this.modal) {
2758
- this.modal.remove();
2759
- this.modal = null;
3162
+ if (this.stateModal) {
3163
+ this.stateModal.classList.add('cv-hidden');
2760
3164
  }
2761
3165
  }
2762
3166
  /**
2763
3167
  * Open the custom state creator
2764
3168
  */
2765
3169
  openStateModal() {
2766
- // Get toggles from current configuration and open the modal regardless of count
2767
- const config = this.core.getConfig();
2768
- const toggles = config?.allToggles || [];
2769
- this.createCustomStateModal(toggles);
3170
+ if (!this.stateModal) {
3171
+ this._createStateModal();
3172
+ }
3173
+ this._updateStateModalContent();
3174
+ this.stateModal.classList.remove('cv-hidden');
2770
3175
  }
2771
3176
  /**
2772
- * Create the custom state creator modal
3177
+ * Create the custom state creator modal shell and attach listeners
2773
3178
  */
2774
- createCustomStateModal(toggles) {
2775
- // Close existing modal
2776
- this.closeModal();
2777
- this.modal = document.createElement('div');
2778
- this.modal.className = 'cv-widget-modal-overlay';
3179
+ _createStateModal() {
3180
+ this.stateModal = document.createElement('div');
3181
+ this.stateModal.className = 'cv-widget-modal-overlay cv-hidden';
2779
3182
  this.applyThemeToModal();
2780
- const toggleControlsHtml = toggles.map(toggle => `
2781
- <div class="cv-toggle-card">
2782
- <div class="cv-toggle-content">
2783
- <div>
2784
- <p class="cv-toggle-title">${this.formatToggleName(toggle)}</p>
2785
- </div>
2786
- <label class="cv-toggle-label">
2787
- <input class="cv-toggle-input" type="checkbox" data-toggle="${toggle}"/>
2788
- <span class="cv-toggle-slider"></span>
2789
- </label>
2790
- </div>
2791
- </div>
3183
+ document.body.appendChild(this.stateModal);
3184
+ this._attachStateModalFrameEventListeners();
3185
+ }
3186
+ /**
3187
+ * Update the content of the state modal
3188
+ */
3189
+ _updateStateModalContent() {
3190
+ if (!this.stateModal)
3191
+ return;
3192
+ const pageToggleIds = this.pageToggleIds;
3193
+ const pageTabIds = this.pageTabIds;
3194
+ // Get toggles from current configuration
3195
+ const config = this.core.getConfig();
3196
+ const allToggles = config?.toggles || [];
3197
+ // Filter toggles to only include global and visible/declared local toggles
3198
+ const visibleToggles = allToggles.filter(toggle => {
3199
+ if (toggle.isLocal) {
3200
+ return pageToggleIds.has(toggle.id) || !!document.querySelector(`[data-cv-toggle="${toggle.id}"], [data-cv-toggle-group-id="${toggle.id}"]`);
3201
+ }
3202
+ return true; // Keep global toggles
3203
+ });
3204
+ const toggleControlsHtml = visibleToggles.map(toggle => `
3205
+ <div class="cv-toggle-card">
3206
+ <div class="cv-toggle-content">
3207
+ <div>
3208
+ <p class="cv-toggle-title">${toggle.label || toggle.id}</p>
3209
+ </div>
3210
+ <label class="cv-toggle-label">
3211
+ <input class="cv-toggle-input" type="checkbox" data-toggle="${toggle.id}"/>
3212
+ <span class="cv-toggle-slider"></span>
3213
+ </label>
3214
+ </div>
3215
+ </div>
2792
3216
  `).join('');
2793
- // Todo: Re-add description if needed (Line 168, add label field to toggles if needed change structure)
2794
- // <p class="cv-toggle-description">Show or hide the ${this.formatToggleName(toggle).toLowerCase()} area </p>
2795
3217
  // Get tab groups
2796
- const tabGroups = this.core.getTabGroups();
3218
+ const allTabGroups = this.core.getTabGroups() || [];
3219
+ const tabGroups = allTabGroups.filter(group => {
3220
+ if (group.isLocal) {
3221
+ return pageTabIds.has(group.id) || !!document.querySelector(`cv-tabgroup[id="${group.id}"]`);
3222
+ }
3223
+ return true; // Keep global tab groups
3224
+ });
2797
3225
  let tabGroupControlsHTML = '';
2798
3226
  if (this.options.showTabGroups && tabGroups && tabGroups.length > 0) {
2799
- // Determine initial nav visibility state
2800
3227
  const initialNavsVisible = TabManager.areNavsVisible(document.body);
2801
- tabGroupControlsHTML = `
2802
- <div class="cv-tabgroup-card cv-tabgroup-header">
2803
- <div class="cv-tabgroup-row">
2804
- <div class="cv-tabgroup-logo-box" id="cv-nav-icon-box">
2805
- <div class="cv-nav-icon" id="cv-nav-icon">${initialNavsVisible ? getNavHeadingOnIcon() : getNavHeadingOffIcon()}</div>
2806
- </div>
2807
- <div class="cv-tabgroup-info">
2808
- <div class="cv-tabgroup-title-container">
2809
- <p class="cv-tabgroup-title">Navigation Headers</p>
2810
- </div>
2811
- <p class="cv-tabgroup-description">Show or hide navigation headers</p>
2812
- </div>
2813
- <label class="cv-toggle-switch cv-nav-toggle">
2814
- <input class="cv-nav-pref-input" type="checkbox" ${initialNavsVisible ? 'checked' : ''} aria-label="Show or hide navigation headers" />
2815
- <span class="cv-switch-bg"></span>
2816
- <span class="cv-switch-knob"></span>
2817
- </label>
2818
- </div>
2819
- </div>
2820
- <div class="cv-tab-groups-list">
2821
- ${tabGroups.map(group => `
2822
- <div class="cv-tabgroup-card cv-tabgroup-item">
2823
- <label class="cv-tabgroup-label" for="tab-group-${group.id}">
2824
- ${group.label || group.id}
2825
- </label>
2826
- <select id="tab-group-${group.id}" class="cv-tabgroup-select" data-group-id="${group.id}">
2827
- ${group.tabs.map(tab => `<option value="${tab.id}">${tab.label || tab.id}</option>`).join('')}
2828
- </select>
2829
- </div>
2830
- `).join('')}
2831
- </div>
3228
+ tabGroupControlsHTML = `
3229
+ <div class="cv-tabgroup-card cv-tabgroup-header">
3230
+ <div class="cv-tabgroup-row">
3231
+ <div class="cv-tabgroup-logo-box" id="cv-nav-icon-box">
3232
+ <div class="cv-nav-icon" id="cv-nav-icon">${initialNavsVisible ? getNavHeadingOnIcon() : getNavHeadingOffIcon()}</div>
3233
+ </div>
3234
+ <div class="cv-tabgroup-info">
3235
+ <div class="cv-tabgroup-title-container">
3236
+ <p class="cv-tabgroup-title">Navigation Headers</p>
3237
+ </div>
3238
+ <p class="cv-tabgroup-description">Show or hide navigation headers</p>
3239
+ </div>
3240
+ <label class="cv-toggle-switch cv-nav-toggle">
3241
+ <input class="cv-nav-pref-input" type="checkbox" ${initialNavsVisible ? 'checked' : ''} aria-label="Show or hide navigation headers" />
3242
+ <span class="cv-switch-bg"></span>
3243
+ <span class="cv-switch-knob"></span>
3244
+ </label>
3245
+ </div>
3246
+ </div>
3247
+ <div class="cv-tab-groups-list">
3248
+ ${tabGroups.map(group => `
3249
+ <div class="cv-tabgroup-card cv-tabgroup-item">
3250
+ <label class="cv-tabgroup-label" for="tab-group-${group.id}">
3251
+ ${group.label || group.id}
3252
+ </label>
3253
+ <select id="tab-group-${group.id}" class="cv-tabgroup-select" data-group-id="${group.id}">
3254
+ ${group.tabs.map(tab => `<option value="${tab.id}">${tab.label || tab.id}</option>`).join('')}
3255
+ </select>
3256
+ </div>
3257
+ `).join('')}
3258
+ </div>
2832
3259
  `;
2833
3260
  }
2834
- this.modal.innerHTML = `
2835
- <div class="cv-widget-modal cv-custom-state-modal">
2836
- <header class="cv-modal-header">
2837
- <div class="cv-modal-header-content">
2838
- <div class="cv-modal-icon">
2839
- ${getGearIcon()}
2840
- </div>
2841
- <div class="cv-modal-title">${this.options.title}</div>
2842
- </div>
2843
- <button class="cv-modal-close" aria-label="Close modal">
2844
- ${getCloseIcon()}
2845
- </button>
2846
- </header>
2847
- <main class="cv-modal-main">
2848
- ${this.options.description ? `<p class="cv-modal-description">${this.options.description}</p>` : ''}
2849
-
2850
- ${toggles.length ? `
2851
- <div class="cv-content-section">
2852
- <div class="cv-section-heading">Toggles</div>
2853
- <div class="cv-toggles-container">
2854
- ${toggleControlsHtml}
2855
- </div>
2856
- </div>
2857
- ` : ''}
2858
-
2859
- ${this.options.showTabGroups && tabGroups && tabGroups.length > 0 ? `
2860
- <div class="cv-content-section">
2861
- <div class="cv-section-heading">Tab Groups</div>
2862
- <div class="cv-tabgroups-container">
2863
- ${tabGroupControlsHTML}
2864
- </div>
2865
- </div>
2866
- ` : ''}
2867
- </main>
2868
-
2869
- <footer class="cv-modal-footer">
2870
- ${this.options.showReset ? `
2871
- <button class="cv-reset-btn">
2872
- <span class="cv-reset-btn-icon">${getResetIcon()}</span>
2873
- <span>Reset to Default</span>
2874
- </button>
2875
- ` : ''}
2876
- <button class="cv-share-btn">
2877
- <span>Copy Shareable URL</span>
2878
- <span class="cv-share-btn-icon">${getCopyIcon()}</span>
2879
- </button>
2880
- </footer>
2881
- </div>
3261
+ this.stateModal.innerHTML = `
3262
+ <div class="cv-widget-modal cv-custom-state-modal">
3263
+ <header class="cv-modal-header">
3264
+ <div class="cv-modal-header-content">
3265
+ <div class="cv-modal-icon">
3266
+ ${getGearIcon()}
3267
+ </div>
3268
+ <div class="cv-modal-title">${this.options.title}</div>
3269
+ </div>
3270
+ <button class="cv-modal-close" aria-label="Close modal">
3271
+ ${getCloseIcon()}
3272
+ </button>
3273
+ </header>
3274
+ <main class="cv-modal-main">
3275
+ ${this.options.description ? `<p class="cv-modal-description">${this.options.description}</p>` : ''}
3276
+
3277
+ ${visibleToggles.length ? `
3278
+ <div class="cv-content-section">
3279
+ <div class="cv-section-heading">Toggles</div>
3280
+ <div class="cv-toggles-container">
3281
+ ${toggleControlsHtml}
3282
+ </div>
3283
+ </div>
3284
+ ` : ''}
3285
+
3286
+ ${this.options.showTabGroups && tabGroups && tabGroups.length > 0 ? `
3287
+ <div class="cv-content-section">
3288
+ <div class="cv-section-heading">Tab Groups</div>
3289
+ <div class="cv-tabgroups-container">
3290
+ ${tabGroupControlsHTML}
3291
+ </div>
3292
+ </div>
3293
+ ` : ''}
3294
+ </main>
3295
+
3296
+ <footer class="cv-modal-footer">
3297
+ ${this.options.showReset ? `
3298
+ <button class="cv-reset-btn">
3299
+ <span class="cv-reset-btn-icon">${getResetIcon()}</span>
3300
+ <span>Reset to Default</span>
3301
+ </button>
3302
+ ` : ''}
3303
+ <button class="cv-share-btn">
3304
+ <span>Copy Shareable URL</span>
3305
+ <span class="cv-share-btn-icon">${getCopyIcon()}</span>
3306
+ </button>
3307
+ </footer>
3308
+ </div>
2882
3309
  `;
2883
- document.body.appendChild(this.modal);
2884
- this.attachStateModalEventListeners();
2885
- // Load current state into form if we're already in a custom state
3310
+ this._attachStateModalContentEventListeners();
2886
3311
  this.loadCurrentStateIntoForm();
2887
3312
  }
2888
3313
  /**
2889
- * Attach event listeners for custom state creator
3314
+ * Attach event listeners for the modal frame (delegated events)
2890
3315
  */
2891
- attachStateModalEventListeners() {
2892
- if (!this.modal)
3316
+ _attachStateModalFrameEventListeners() {
3317
+ if (!this.stateModal)
2893
3318
  return;
2894
- // Close button
2895
- const closeBtn = this.modal.querySelector('.cv-modal-close');
2896
- if (closeBtn) {
2897
- closeBtn.addEventListener('click', () => {
3319
+ // Delegated click events
3320
+ this.stateModal.addEventListener('click', (e) => {
3321
+ const target = e.target;
3322
+ // Close button
3323
+ if (target.closest('.cv-modal-close')) {
2898
3324
  this.closeModal();
2899
- });
2900
- }
2901
- // Copy URL button
2902
- const copyUrlBtn = this.modal.querySelector('.cv-share-btn');
2903
- if (copyUrlBtn) {
2904
- copyUrlBtn.addEventListener('click', () => {
3325
+ return;
3326
+ }
3327
+ // Copy URL button
3328
+ if (target.closest('.cv-share-btn')) {
2905
3329
  this.copyShareableURL();
2906
- // Visual feedback: change icon to tick for 3 seconds
2907
- const iconContainer = copyUrlBtn.querySelector('.cv-share-btn-icon');
3330
+ const copyUrlBtn = target.closest('.cv-share-btn');
3331
+ const iconContainer = copyUrlBtn?.querySelector('.cv-share-btn-icon');
2908
3332
  if (iconContainer) {
2909
3333
  const originalIcon = iconContainer.innerHTML;
2910
3334
  iconContainer.innerHTML = getTickIcon();
2911
- // Revert after 3 seconds
2912
3335
  setTimeout(() => {
2913
3336
  iconContainer.innerHTML = originalIcon;
2914
3337
  }, 3000);
2915
3338
  }
2916
- });
2917
- }
2918
- // Reset to default button
2919
- const resetBtn = this.modal.querySelector('.cv-reset-btn');
2920
- if (resetBtn) {
2921
- resetBtn.addEventListener('click', () => {
2922
- // Add spinning animation to icon
2923
- const resetIcon = resetBtn.querySelector('.cv-reset-btn-icon');
3339
+ return;
3340
+ }
3341
+ // Reset to default button
3342
+ if (target.closest('.cv-reset-btn')) {
3343
+ const resetBtn = target.closest('.cv-reset-btn');
3344
+ const resetIcon = resetBtn?.querySelector('.cv-reset-btn-icon');
2924
3345
  if (resetIcon) {
2925
3346
  resetIcon.classList.add('cv-spinning');
2926
3347
  }
2927
3348
  this.core.resetToDefault();
2928
3349
  this.loadCurrentStateIntoForm();
2929
- // Remove spinning animation after it completes
2930
3350
  setTimeout(() => {
2931
3351
  if (resetIcon) {
2932
3352
  resetIcon.classList.remove('cv-spinning');
2933
3353
  }
2934
- }, 600); // 600ms matches the animation duration
2935
- });
2936
- }
3354
+ }, 600);
3355
+ return;
3356
+ }
3357
+ // Overlay click to close
3358
+ if (e.target === this.stateModal) {
3359
+ this.closeModal();
3360
+ }
3361
+ });
3362
+ // Escape key to close
3363
+ const handleEscape = (e) => {
3364
+ if (e.key === 'Escape') {
3365
+ this.closeModal();
3366
+ }
3367
+ };
3368
+ // We can't remove this listener easily if it's anonymous, so we attach it to the document
3369
+ // and it will stay for the lifetime of the widget. This is acceptable.
3370
+ document.addEventListener('keydown', handleEscape);
3371
+ }
3372
+ /**
3373
+ * Attach event listeners for custom state creator's dynamic content
3374
+ */
3375
+ _attachStateModalContentEventListeners() {
3376
+ if (!this.stateModal)
3377
+ return;
2937
3378
  // Listen to toggle switches
2938
- const toggleInputs = this.modal.querySelectorAll('.cv-toggle-input');
3379
+ const toggleInputs = this.stateModal.querySelectorAll('.cv-toggle-input');
2939
3380
  toggleInputs.forEach(toggleInput => {
2940
3381
  toggleInput.addEventListener('change', () => {
2941
3382
  const state = this.getCurrentCustomStateFromModal();
2942
- this.core.applyState(state);
3383
+ this.core.applyState(state, { source: 'widget' });
2943
3384
  });
2944
3385
  });
2945
3386
  // Listen to tab group selects
2946
- const tabGroupSelects = this.modal.querySelectorAll('.cv-tabgroup-select');
3387
+ const tabGroupSelects = this.stateModal.querySelectorAll('.cv-tabgroup-select');
2947
3388
  tabGroupSelects.forEach(select => {
2948
3389
  select.addEventListener('change', () => {
2949
3390
  const groupId = select.dataset.groupId;
2950
3391
  const tabId = select.value;
2951
3392
  if (groupId && tabId) {
2952
- // Get current state and update the tab for this group, then apply globally
2953
- // This triggers sync behavior and persistence
2954
3393
  const currentTabs = this.core.getCurrentActiveTabs();
2955
3394
  currentTabs[groupId] = tabId;
2956
- // Apply state globally for persistence and sync
2957
3395
  const currentToggles = this.core.getCurrentActiveToggles();
2958
3396
  const newState = {
2959
3397
  toggles: currentToggles,
2960
3398
  tabs: currentTabs
2961
3399
  };
2962
- this.core.applyState(newState);
3400
+ this.core.applyState(newState, { source: 'widget' });
2963
3401
  }
2964
3402
  });
2965
3403
  });
2966
3404
  // Listener for show/hide tab navs
2967
- const tabNavToggle = this.modal.querySelector('.cv-nav-pref-input');
2968
- const navIcon = this.modal?.querySelector('#cv-nav-icon');
2969
- const navHeaderCard = this.modal?.querySelector('.cv-tabgroup-card.cv-tabgroup-header');
3405
+ const tabNavToggle = this.stateModal.querySelector('.cv-nav-pref-input');
3406
+ const navIcon = this.stateModal?.querySelector('#cv-nav-icon');
3407
+ const navHeaderCard = this.stateModal?.querySelector('.cv-tabgroup-card.cv-tabgroup-header');
2970
3408
  if (tabNavToggle && navIcon && navHeaderCard) {
2971
- // Helper to update icon based on state
2972
3409
  const updateIcon = (isVisible, isHovering = false) => {
2973
3410
  if (isHovering) {
2974
- // On hover, show the transition icon
2975
3411
  navIcon.innerHTML = getNavDashed();
2976
3412
  }
2977
3413
  else {
2978
- // Normal state, show the status icon (on if visible, off if hidden)
2979
3414
  navIcon.innerHTML = isVisible ? getNavHeadingOnIcon() : getNavHeadingOffIcon();
2980
3415
  }
2981
3416
  };
2982
- // Add hover listeners to entire header card
2983
- navHeaderCard.addEventListener('mouseenter', () => {
2984
- updateIcon(tabNavToggle.checked, true);
2985
- });
2986
- navHeaderCard.addEventListener('mouseleave', () => {
2987
- updateIcon(tabNavToggle.checked, false);
2988
- });
2989
- // Add change listener
3417
+ navHeaderCard.addEventListener('mouseenter', () => updateIcon(tabNavToggle.checked, true));
3418
+ navHeaderCard.addEventListener('mouseleave', () => updateIcon(tabNavToggle.checked, false));
2990
3419
  tabNavToggle.addEventListener('change', () => {
2991
3420
  const visible = tabNavToggle.checked;
2992
- // Update the icon based on new state (not hovering)
2993
3421
  updateIcon(visible, false);
2994
- // Persist preference via core
2995
3422
  this.core.persistTabNavVisibility(visible);
2996
- // Apply to DOM using TabManager via core
2997
3423
  try {
2998
- const rootEl = document.body;
2999
- TabManager.setNavsVisibility(rootEl, visible);
3424
+ TabManager.setNavsVisibility(document.body, visible);
3000
3425
  }
3001
3426
  catch (e) {
3002
- // ignore errors
3003
3427
  console.error('Failed to set tab nav visibility:', e);
3004
3428
  }
3005
3429
  });
3006
3430
  }
3007
- // Overlay click to close
3008
- this.modal.addEventListener('click', (e) => {
3009
- if (e.target === this.modal) {
3010
- this.closeModal();
3011
- }
3012
- });
3013
- // Escape key to close
3014
- const handleEscape = (e) => {
3015
- if (e.key === 'Escape') {
3016
- this.closeModal();
3017
- document.removeEventListener('keydown', handleEscape);
3018
- }
3019
- };
3020
- document.addEventListener('keydown', handleEscape);
3021
3431
  }
3022
3432
  /**
3023
3433
  * Apply theme class to the modal overlay based on options
3024
3434
  */
3025
3435
  applyThemeToModal() {
3026
- if (!this.modal)
3436
+ if (!this.stateModal)
3027
3437
  return;
3028
3438
  if (this.options.theme === 'dark') {
3029
- this.modal.classList.add('cv-widget-theme-dark');
3439
+ this.stateModal.classList.add('cv-widget-theme-dark');
3030
3440
  }
3031
3441
  else {
3032
- this.modal.classList.remove('cv-widget-theme-dark');
3442
+ this.stateModal.classList.remove('cv-widget-theme-dark');
3033
3443
  }
3034
3444
  }
3035
3445
  /**
3036
3446
  * Get current state from form values
3037
3447
  */
3038
3448
  getCurrentCustomStateFromModal() {
3039
- if (!this.modal) {
3449
+ if (!this.stateModal) {
3040
3450
  return {};
3041
3451
  }
3042
3452
  // Collect toggle values
3043
3453
  const toggles = [];
3044
- const toggleInputs = this.modal.querySelectorAll('.cv-toggle-input');
3454
+ const toggleInputs = this.stateModal.querySelectorAll('.cv-toggle-input');
3045
3455
  toggleInputs.forEach(toggleInput => {
3046
3456
  const toggle = toggleInput.dataset.toggle;
3047
3457
  if (toggle && toggleInput.checked) {
@@ -3049,7 +3459,7 @@ class CustomViewsWidget {
3049
3459
  }
3050
3460
  });
3051
3461
  // Collect tab selections
3052
- const tabGroupSelects = this.modal.querySelectorAll('.cv-tabgroup-select');
3462
+ const tabGroupSelects = this.stateModal.querySelectorAll('.cv-tabgroup-select');
3053
3463
  const tabs = {};
3054
3464
  tabGroupSelects.forEach(select => {
3055
3465
  const groupId = select.dataset.groupId;
@@ -3077,25 +3487,25 @@ class CustomViewsWidget {
3077
3487
  * Load current state into form based on currently active toggles
3078
3488
  */
3079
3489
  loadCurrentStateIntoForm() {
3080
- if (!this.modal)
3490
+ if (!this.stateModal)
3081
3491
  return;
3082
3492
  // Get currently active toggles (from custom state or default configuration)
3083
3493
  const activeToggles = this.core.getCurrentActiveToggles();
3084
3494
  // First, uncheck all toggle inputs
3085
- const allToggleInputs = this.modal.querySelectorAll('.cv-toggle-input');
3495
+ const allToggleInputs = this.stateModal.querySelectorAll('.cv-toggle-input');
3086
3496
  allToggleInputs.forEach(toggleInput => {
3087
3497
  toggleInput.checked = false;
3088
3498
  });
3089
3499
  // Then check the ones that should be active
3090
3500
  activeToggles.forEach(toggle => {
3091
- const toggleInput = this.modal?.querySelector(`[data-toggle="${toggle}"]`);
3501
+ const toggleInput = this.stateModal?.querySelector(`[data-toggle="${toggle}"]`);
3092
3502
  if (toggleInput) {
3093
3503
  toggleInput.checked = true;
3094
3504
  }
3095
3505
  });
3096
3506
  // Load tab group selections
3097
3507
  const activeTabs = this.core.getCurrentActiveTabs();
3098
- const tabGroupSelects = this.modal.querySelectorAll('.cv-tabgroup-select');
3508
+ const tabGroupSelects = this.stateModal.querySelectorAll('.cv-tabgroup-select');
3099
3509
  tabGroupSelects.forEach(select => {
3100
3510
  const groupId = select.dataset.groupId;
3101
3511
  if (groupId && activeTabs[groupId]) {
@@ -3110,8 +3520,8 @@ class CustomViewsWidget {
3110
3520
  }
3111
3521
  return TabManager.areNavsVisible(document.body);
3112
3522
  })();
3113
- const tabNavToggle = this.modal.querySelector('.cv-nav-pref-input');
3114
- const navIcon = this.modal?.querySelector('#cv-nav-icon');
3523
+ const tabNavToggle = this.stateModal.querySelector('.cv-nav-pref-input');
3524
+ const navIcon = this.stateModal?.querySelector('#cv-nav-icon');
3115
3525
  if (tabNavToggle) {
3116
3526
  tabNavToggle.checked = navPref;
3117
3527
  // Ensure UI matches actual visibility
@@ -3122,33 +3532,22 @@ class CustomViewsWidget {
3122
3532
  }
3123
3533
  }
3124
3534
  }
3125
- /**
3126
- * Format toggle name for display
3127
- */
3128
- formatToggleName(toggle) {
3129
- return toggle.charAt(0).toUpperCase() + toggle.slice(1);
3130
- }
3131
3535
  /**
3132
3536
  * Check if this is the first visit and show welcome modal
3133
3537
  */
3134
3538
  showWelcomeModalIfFirstVisit() {
3539
+ if (!this._hasVisibleConfig)
3540
+ return;
3135
3541
  const STORAGE_KEY = 'cv-welcome-shown';
3136
3542
  // Check if welcome has been shown before
3137
3543
  const hasSeenWelcome = localStorage.getItem(STORAGE_KEY);
3138
3544
  if (!hasSeenWelcome) {
3139
- // Check if this page has any custom views elements
3140
- const hasCustomViewElements = document.querySelector('cv-tabgroup') !== null ||
3141
- document.querySelector('cv-tab') !== null ||
3142
- document.querySelector('cv-toggle') !== null ||
3143
- document.querySelector('[data-cv-toggle]') !== null;
3144
- if (hasCustomViewElements) {
3145
- // Show welcome modal after a short delay to let the page settle
3146
- setTimeout(() => {
3147
- this.createWelcomeModal();
3148
- }, 500);
3149
- // Mark as shown
3150
- localStorage.setItem(STORAGE_KEY, 'true');
3151
- }
3545
+ // Show welcome modal after a short delay to let the page settle
3546
+ setTimeout(() => {
3547
+ this.createWelcomeModal();
3548
+ }, 500);
3549
+ // Mark as shown
3550
+ localStorage.setItem(STORAGE_KEY, 'true');
3152
3551
  }
3153
3552
  }
3154
3553
  /**
@@ -3156,62 +3555,63 @@ class CustomViewsWidget {
3156
3555
  */
3157
3556
  createWelcomeModal() {
3158
3557
  // Don't show if there's already a modal open
3159
- if (this.modal)
3558
+ if (this.stateModal && !this.stateModal.classList.contains('cv-hidden'))
3160
3559
  return;
3161
- this.modal = document.createElement('div');
3162
- this.modal.className = 'cv-widget-modal-overlay cv-welcome-modal-overlay';
3163
- this.applyThemeToModal();
3164
- this.modal.innerHTML = `
3165
- <div class="cv-widget-modal cv-welcome-modal">
3166
- <header class="cv-modal-header">
3167
- <div class="cv-modal-header-content">
3168
- <div class="cv-modal-icon">
3169
- ${getGearIcon()}
3170
- </div>
3171
- <h1 class="cv-modal-title">${this.options.welcomeTitle}</h1>
3172
- </div>
3173
- </header>
3174
- <div class="cv-modal-main">
3175
- <p class="cv-welcome-message">${this.options.welcomeMessage}</p>
3176
-
3177
- <div class="cv-welcome-widget-preview">
3178
- <div class="cv-welcome-widget-icon">
3179
- ${getGearIcon()}
3180
- </div>
3181
- <p class="cv-welcome-widget-label">Look for this widget</p>
3182
- </div>
3183
-
3184
- <button class="cv-welcome-got-it">Got it!</button>
3185
- </div>
3186
- </div>
3560
+ const welcomeModal = document.createElement('div');
3561
+ welcomeModal.className = 'cv-widget-modal-overlay cv-welcome-modal-overlay';
3562
+ if (this.options.theme === 'dark') {
3563
+ welcomeModal.classList.add('cv-widget-theme-dark');
3564
+ }
3565
+ welcomeModal.innerHTML = `
3566
+ <div class="cv-widget-modal cv-welcome-modal">
3567
+ <header class="cv-modal-header">
3568
+ <div class="cv-modal-header-content">
3569
+ <div class="cv-modal-icon">
3570
+ ${getGearIcon()}
3571
+ </div>
3572
+ <h1 class="cv-modal-title">${this.options.welcomeTitle}</h1>
3573
+ </div>
3574
+ </header>
3575
+ <div class="cv-modal-main">
3576
+ <p class="cv-welcome-message">${this.options.welcomeMessage}</p>
3577
+
3578
+ <div class="cv-welcome-widget-preview">
3579
+ <div class="cv-welcome-widget-icon">
3580
+ ${getGearIcon()}
3581
+ </div>
3582
+ <p class="cv-welcome-widget-label">Look for this widget</p>
3583
+ </div>
3584
+
3585
+ <button class="cv-welcome-got-it">Got it!</button>
3586
+ </div>
3587
+ </div>
3187
3588
  `;
3188
- document.body.appendChild(this.modal);
3189
- this.attachWelcomeModalEventListeners();
3589
+ document.body.appendChild(welcomeModal);
3590
+ this.attachWelcomeModalEventListeners(welcomeModal);
3190
3591
  }
3191
3592
  /**
3192
3593
  * Attach event listeners for welcome modal
3193
3594
  */
3194
- attachWelcomeModalEventListeners() {
3195
- if (!this.modal)
3196
- return;
3595
+ attachWelcomeModalEventListeners(welcomeModal) {
3596
+ const closeModal = () => {
3597
+ welcomeModal.remove();
3598
+ document.removeEventListener('keydown', handleEscape);
3599
+ };
3197
3600
  // Got it button
3198
- const gotItBtn = this.modal.querySelector('.cv-welcome-got-it');
3601
+ const gotItBtn = welcomeModal.querySelector('.cv-welcome-got-it');
3199
3602
  if (gotItBtn) {
3200
- gotItBtn.addEventListener('click', () => {
3201
- this.closeModal();
3202
- });
3603
+ gotItBtn.addEventListener('click', closeModal);
3203
3604
  }
3204
3605
  // Overlay click to close
3205
- this.modal.addEventListener('click', (e) => {
3206
- if (e.target === this.modal) {
3207
- this.closeModal();
3606
+ welcomeModal.addEventListener('click', (e) => {
3607
+ if (e.target === welcomeModal) {
3608
+ closeModal();
3208
3609
  }
3209
3610
  });
3210
3611
  // Escape key to close
3211
3612
  const handleEscape = (e) => {
3212
3613
  if (e.key === 'Escape') {
3213
- this.closeModal();
3214
- document.removeEventListener('keydown', handleEscape);
3614
+ closeModal();
3215
3615
  }
3216
3616
  };
3217
3617
  document.addEventListener('keydown', handleEscape);
@@ -3281,7 +3681,7 @@ function initializeFromScript() {
3281
3681
  console.warn(`[CustomViews] Config file not found at ${fullConfigPath}. Using defaults.`);
3282
3682
  // Provide minimal default config structure
3283
3683
  configFile = {
3284
- config: { allToggles: [], defaultState: {} },
3684
+ config: { toggles: [], defaultState: {} },
3285
3685
  widget: { enabled: true }
3286
3686
  };
3287
3687
  }
@@ -3319,7 +3719,7 @@ function initializeFromScript() {
3319
3719
  core,
3320
3720
  ...configFile.widget
3321
3721
  });
3322
- widget.render();
3722
+ widget.renderModalIcon();
3323
3723
  // Store widget instance
3324
3724
  window.customViewsInstance.widget = widget;
3325
3725
  console.log('[CustomViews] Widget initialized and rendered');