@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
  */
@@ -303,8 +303,124 @@
303
303
  }
304
304
  }
305
305
 
306
+ /**
307
+ * Icon utilities for CustomViews widget
308
+ * Centralized SVG icons for better maintainability and reusability
309
+ */
310
+ /**
311
+ * Settings gear icon for modal header
312
+ */
313
+ function getGearIcon() {
314
+ return `<svg class="cv-modal-icon-svg" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
315
+ <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"/>
316
+ <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"/>
317
+ </svg>`;
318
+ }
319
+ /**
320
+ * Close/X icon for modal close button
321
+ */
322
+ function getCloseIcon() {
323
+ 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">
324
+ <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>
325
+ </svg>`;
326
+ }
327
+ /**
328
+ * Reset/refresh icon for reset button
329
+ */
330
+ function getResetIcon() {
331
+ return `<svg class="cv-btn-icon" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
332
+ <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"/>
333
+ </svg>`;
334
+ }
335
+ /**
336
+ * Copy icon for sharing URL button
337
+ */
338
+ function getCopyIcon() {
339
+ 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">
340
+ <g id="surface1">
341
+ <path d="M 11.273438 0 L 2.546875 0 C 1.746094 0 1.089844 0.613281 1.089844
342
+ 1.363281 L 1.089844 10.910156 L 2.546875 10.910156 L 2.546875 1.363281 L 11.273438
343
+ 1.363281 Z M 13.453125 2.726562 L 5.453125 2.726562 C 4.65625 2.726562 4 3.339844 4
344
+ 4.089844 L 4 13.636719 C 4 14.386719 4.65625 15 5.453125 15 L 13.453125 15 C 14.253906
345
+ 15 14.910156 14.386719 14.910156 13.636719 L 14.910156 4.089844 C 14.910156 3.339844
346
+ 14.253906 2.726562 13.453125 2.726562 Z M 13.453125 13.636719 L 5.453125 13.636719 L
347
+ 5.453125 4.089844 L 13.453125 4.089844 Z M 13.453125 13.636719 "></path>
348
+ </g>
349
+ </svg>`;
350
+ }
351
+ function getTickIcon() {
352
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="2 2 22 22" fill="currentColor">
353
+ <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
354
+ L 9 18.40625 L 9.71875 17.71875 L 20.71875 6.71875 Z"></path>
355
+ </svg>`;
356
+ }
357
+ function getNavHeadingOnIcon() {
358
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="250" height="181" viewBox="0 0 250 181">
359
+ <rect y="34.5001" width="250" height="146" rx="4" stroke="currentColor" stroke-width="10" fill="none"/>
360
+ <line x1="27" y1="62.0001" x2="77" y2="62.0001" stroke="currentColor" stroke-width="5"/>
361
+ <line x1="27" y1="77.8888" x2="77" y2="77.8888" stroke="currentColor" stroke-width="5"/>
362
+ <line x1="27" y1="97.4454" x2="221" y2="97.4454" stroke="currentColor" stroke-width="5"/>
363
+ <line x1="27" y1="114.555" x2="221" y2="114.555" stroke="currentColor" stroke-width="5"/>
364
+ <line x1="27" y1="132.889" x2="221" y2="132.889" stroke="currentColor" stroke-width="5"/>
365
+ <line x1="27" y1="150" x2="221" y2="150" stroke="currentColor" stroke-width="5"/>
366
+ <line x1="247.5" y1="43.0001" x2="247.5" y2="13.0001" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
367
+ <path d="M185 12.5001L247 12.5001" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
368
+ <line x1="204.09" y1="36.6095" x2="181.698" y2="10.0228" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
369
+ <path d="M125 9.50012L181 9.50012" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
370
+ <path d="M144.305 35.2579L120.095 6.56679" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
371
+ <path d="M120 6.50037L64 6.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
372
+ <path d="M87.1957 36.1024L59 2.50008" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
373
+ <path d="M59 2.50037L3 2.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
374
+ <path d="M2.5 38.5001L2.5 3.00012" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
375
+ </svg>`;
376
+ }
377
+ function getNavHeadingOffIcon() {
378
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="250" height="181" viewBox="0 0 250 181" fill="currentColor">
379
+ <rect y="34.5001" width="250" height="146" rx="4" stroke="currentColor" stroke-width="10" fill="none"/>
380
+ <line x1="27" y1="62" x2="77" y2="62" stroke="currentColor" stroke-width="5"/>
381
+ <line x1="27" y1="77.8887" x2="77" y2="77.8887" stroke="currentColor" stroke-width="5"/>
382
+ <line x1="27" y1="97.4453" x2="221" y2="97.4453" stroke="currentColor" stroke-width="5"/>
383
+ <line x1="27" y1="114.555" x2="221" y2="114.555" stroke="currentColor" stroke-width="5"/>
384
+ <line x1="27" y1="132.889" x2="221" y2="132.889" stroke="currentColor" stroke-width="5"/>
385
+ <line x1="27" y1="150" x2="221" y2="150" stroke="currentColor" stroke-width="5"/>
386
+ </svg>`;
387
+ }
388
+ /**
389
+ * Transition Icon for Navigation Headings
390
+ */
391
+ function getNavDashed() {
392
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="250" height="181" viewBox="0 0 250 181">
393
+ <rect y="34.5001" width="250" height="146" rx="4" stroke="currentColor" stroke-width="10" fill="none"/>
394
+ <line x1="27" y1="62.0001" x2="77" y2="62.0001" stroke="currentColor" stroke-width="5"/>
395
+ <line x1="27" y1="77.8888" x2="77" y2="77.8888" stroke="currentColor" stroke-width="5"/>
396
+ <line x1="27" y1="97.4454" x2="221" y2="97.4454" stroke="currentColor" stroke-width="5"/>
397
+ <line x1="27" y1="114.555" x2="221" y2="114.555" stroke="currentColor" stroke-width="5"/>
398
+ <line x1="27" y1="132.889" x2="221" y2="132.889" stroke="currentColor" stroke-width="5"/>
399
+ <line x1="27" y1="150" x2="221" y2="150" stroke="currentColor" stroke-width="5"/>
400
+ <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"/>
401
+ <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"/>
402
+ <path d="M125 9.50012L181 9.50012" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
403
+ <path d="M144.305 35.2579L120.095 6.56679" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
404
+ <path d="M120 6.50037L64 6.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
405
+ <path d="M87.1957 36.1024L59 2.50008" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
406
+ <path d="M59 2.50037L3 2.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
407
+ <path d="M2.5 38.5001L2.5 3.00012" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
408
+ <path d="M185 12.5001L247 12.5001" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
409
+ </svg>`;
410
+ }
411
+ function getPinIcon(isPinned = false) {
412
+ const opacity = isPinned ? '1' : '0.6'; // Optional: additional dimming effect
413
+ return `
414
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" opacity="${opacity}" xmlns="http://www.w3.org/2000/svg">
415
+ <g transform="rotate(45 8 8)">
416
+ <path d="M10.5 2H12V0H4V2H5.5V6L4 7.5V9H7.2V15H8.8V9H12V7.5L10.5 6V2Z"/>
417
+ </g>
418
+ </svg>
419
+ `.trim();
420
+ }
421
+
306
422
  // Constants for selectors
307
- const TABGROUP_SELECTOR = 'cv-tabgroup';
423
+ const TABGROUP_SELECTOR$1 = 'cv-tabgroup';
308
424
  const TAB_SELECTOR = 'cv-tab';
309
425
  const NAV_AUTO_SELECTOR = 'cv-tabgroup[nav="auto"], cv-tabgroup:not([nav])';
310
426
  const NAV_CONTAINER_CLASS = 'cv-tabs-nav';
@@ -320,21 +436,34 @@
320
436
  return trimmedIds;
321
437
  }
322
438
  /**
323
- * Apply tab selections to all tab groups in the DOM
439
+ * Apply tab selections to a given list of tab group elements
324
440
  */
325
- static applySelections(rootEl, tabs, cfgGroups) {
326
- // Find all cv-tabgroup elements
327
- const tabGroups = rootEl.querySelectorAll(TABGROUP_SELECTOR);
441
+ static applyTabSelections(tabGroups, tabs, cfgGroups) {
328
442
  tabGroups.forEach((groupEl) => {
329
443
  const groupId = groupEl.getAttribute('id');
330
- if (!groupId)
331
- return;
332
444
  // Determine the active tab for this group
333
- const activeTabId = this.resolveActiveTabForGroup(groupId, tabs, cfgGroups, groupEl);
445
+ let activeTabId;
446
+ if (groupId) {
447
+ activeTabId = this.resolveActiveTabForGroup(groupId, tabs, cfgGroups, groupEl);
448
+ }
449
+ else {
450
+ // For standalone groups without id, activate the first tab
451
+ const tabElements = Array.from(groupEl.children).filter((child) => child.tagName.toLowerCase() === TAB_SELECTOR);
452
+ const firstTab = tabElements[0];
453
+ if (firstTab) {
454
+ const firstTabId = firstTab.getAttribute('id') || firstTab.getAttribute('data-cv-internal-id') || '';
455
+ const splitIds = this.splitTabIds(firstTabId);
456
+ activeTabId = splitIds[0] || null;
457
+ }
458
+ else {
459
+ activeTabId = null;
460
+ }
461
+ }
334
462
  // Apply visibility to direct child cv-tab elements only (not nested ones)
335
463
  const tabElements = Array.from(groupEl.children).filter((child) => child.tagName.toLowerCase() === TAB_SELECTOR);
336
464
  tabElements.forEach((tabEl) => {
337
- const tabId = tabEl.getAttribute('id');
465
+ // Use id or internal id
466
+ const tabId = tabEl.getAttribute('id') || tabEl.getAttribute('data-cv-internal-id');
338
467
  if (!tabId)
339
468
  return;
340
469
  // Split IDs and check if any match the active tab
@@ -368,7 +497,9 @@
368
497
  // 3. Fallback to first direct cv-tab child in DOM
369
498
  const firstTab = Array.from(groupEl.children).find((child) => child.tagName.toLowerCase() === TAB_SELECTOR);
370
499
  if (firstTab) {
371
- const splitIds = this.splitTabIds(firstTab.getAttribute('id') || '');
500
+ // Use id or internal id
501
+ const tabId = firstTab.getAttribute('id') || firstTab.getAttribute('data-cv-internal-id') || '';
502
+ const splitIds = this.splitTabIds(tabId);
372
503
  return splitIds[0] || null;
373
504
  }
374
505
  return null;
@@ -410,15 +541,23 @@
410
541
  };
411
542
  }
412
543
  /**
413
- * Build navigation for tab groups with nav="auto" (one-time setup)
544
+ * Build navigation for tab groups (one-time setup)
414
545
  */
415
- static buildNavs(rootEl, cfgGroups, onTabClick, onTabDoubleClick) {
416
- // Find all cv-tabgroup elements with nav="auto" or no nav attribute
417
- const tabGroups = rootEl.querySelectorAll(NAV_AUTO_SELECTOR);
546
+ static buildNavs(tabGroups, cfgGroups, onTabClick, onTabDoubleClick) {
547
+ const rootEl = document.body; // Needed for NAV_HIDE_ROOT_CLASS check
418
548
  tabGroups.forEach((groupEl) => {
419
- const groupId = groupEl.getAttribute('id');
420
- if (!groupId)
549
+ // Prevent re-initialization
550
+ if (groupEl.hasAttribute('data-cv-initialized')) {
421
551
  return;
552
+ }
553
+ groupEl.setAttribute('data-cv-initialized', 'true');
554
+ // Filter to only build for groups with nav="auto" or no nav attribute
555
+ if (!groupEl.matches(NAV_AUTO_SELECTOR)) {
556
+ return;
557
+ }
558
+ const groupId = groupEl.getAttribute('id') || null;
559
+ // Note: groupId can be null for standalone tabgroups
560
+ // These won't sync with other groups or persist state
422
561
  // Check if nav already exists - if so, skip building
423
562
  let navContainer = groupEl.querySelector(`.${NAV_CONTAINER_CLASS}`);
424
563
  if (navContainer)
@@ -442,10 +581,13 @@
442
581
  }
443
582
  groupEl.insertBefore(navContainer, groupEl.firstChild);
444
583
  // Build nav items
445
- tabElements.forEach((tabEl) => {
446
- const rawTabId = tabEl.getAttribute('id');
447
- if (!rawTabId)
448
- return;
584
+ tabElements.forEach((tabEl, index) => {
585
+ let rawTabId = tabEl.getAttribute('id');
586
+ // If tab has no id, generate one based on position
587
+ if (!rawTabId) {
588
+ rawTabId = `${groupId}-tab-${index}`;
589
+ tabEl.setAttribute('data-cv-internal-id', rawTabId);
590
+ }
449
591
  const splitIds = this.splitTabIds(rawTabId);
450
592
  // If multiple IDs, use the first as primary
451
593
  const tabId = splitIds[0] || rawTabId;
@@ -463,8 +605,19 @@
463
605
  header = headerAttr;
464
606
  }
465
607
  else {
466
- // Use config label or id as fallback
467
- header = this.getTabLabel(tabId, groupId, cfgGroups) || tabId || '';
608
+ // Use config label if available (only if group has an id)
609
+ const configLabel = groupId ? this.getTabLabel(tabId, groupId, cfgGroups) : null;
610
+ if (configLabel) {
611
+ header = configLabel;
612
+ }
613
+ else if (tabEl.getAttribute('id')) {
614
+ // Use the original id if it exists
615
+ header = tabId;
616
+ }
617
+ else {
618
+ // Auto-generate label for tabs without id (Tab 1, Tab 2, etc.)
619
+ header = `Tab ${index + 1}`;
620
+ }
468
621
  }
469
622
  }
470
623
  // Create a single nav link for this tab element
@@ -472,14 +625,30 @@
472
625
  listItem.className = 'nav-item';
473
626
  const navLink = document.createElement('a');
474
627
  navLink.className = 'nav-link';
475
- navLink.innerHTML = header;
476
628
  navLink.href = '#';
477
629
  navLink.setAttribute('data-tab-id', tabId);
478
630
  navLink.setAttribute('data-raw-tab-id', rawTabId);
479
- navLink.setAttribute('data-group-id', groupId);
631
+ if (groupId) {
632
+ navLink.setAttribute('data-group-id', groupId);
633
+ }
480
634
  navLink.setAttribute('role', 'tab');
635
+ // Create header container with text and pin icon
636
+ const headerContainer = document.createElement('span');
637
+ headerContainer.className = 'cv-tab-header-container';
638
+ const headerText = document.createElement('span');
639
+ headerText.className = 'cv-tab-header-text';
640
+ headerText.innerHTML = header;
641
+ const pinIcon = document.createElement('span');
642
+ pinIcon.className = 'cv-tab-pin-icon';
643
+ pinIcon.innerHTML = getPinIcon(true);
644
+ pinIcon.style.display = 'none'; // Hidden by default
645
+ headerContainer.appendChild(headerText);
646
+ headerContainer.appendChild(pinIcon);
647
+ navLink.appendChild(headerContainer);
481
648
  // Check if any of the split IDs is active
482
- const activeTabId = this.resolveActiveTabForGroup(groupId, {}, cfgGroups, groupEl); // Pass empty tabs for initial state
649
+ const activeTabId = groupId
650
+ ? this.resolveActiveTabForGroup(groupId, {}, cfgGroups, groupEl)
651
+ : (index === 0 ? tabId : null); // For standalone groups, activate first tab
483
652
  const isActive = splitIds.includes(activeTabId || '');
484
653
  if (isActive) {
485
654
  navLink.classList.add('active');
@@ -492,15 +661,14 @@
492
661
  if (onTabClick) {
493
662
  navLink.addEventListener('click', (e) => {
494
663
  e.preventDefault();
495
- // console.log("Single-click detected");
496
- onTabClick(groupId, tabId, groupEl);
664
+ // For standalone groups (no groupId), use empty string
665
+ onTabClick(groupId || '', tabId, groupEl);
497
666
  });
498
667
  }
499
- // Add double-click handler for sync
500
- if (onTabDoubleClick) {
668
+ // Add double-click handler for sync (only for groups with id)
669
+ if (onTabDoubleClick && groupId) {
501
670
  navLink.addEventListener('dblclick', (e) => {
502
671
  e.preventDefault();
503
- // console.log("Double-click detected");
504
672
  onTabDoubleClick(groupId, tabId, groupEl);
505
673
  });
506
674
  }
@@ -590,8 +758,7 @@
590
758
  /**
591
759
  * Update active states for all tab groups based on current state
592
760
  */
593
- static updateAllNavActiveStates(rootEl, tabs, cfgGroups) {
594
- const tabGroups = rootEl.querySelectorAll(TABGROUP_SELECTOR);
761
+ static updateAllNavActiveStates(tabGroups, tabs, cfgGroups) {
595
762
  tabGroups.forEach((groupEl) => {
596
763
  const groupId = groupEl.getAttribute('id');
597
764
  if (!groupId)
@@ -627,7 +794,8 @@
627
794
  static applyTabLocalOnly(groupEl, activeTabId) {
628
795
  const tabElements = Array.from(groupEl.children).filter((child) => child.tagName.toLowerCase() === TAB_SELECTOR);
629
796
  tabElements.forEach((tabEl) => {
630
- const tabId = tabEl.getAttribute('id');
797
+ // Use id or internal id
798
+ const tabId = tabEl.getAttribute('id') || tabEl.getAttribute('data-cv-internal-id');
631
799
  if (!tabId)
632
800
  return;
633
801
  const splitIds = this.splitTabIds(tabId);
@@ -642,7 +810,8 @@
642
810
  static groupHasTab(groupEl, tabId) {
643
811
  const tabElements = Array.from(groupEl.children).filter((child) => child.tagName.toLowerCase() === TAB_SELECTOR);
644
812
  return tabElements.some((tabEl) => {
645
- const idAttr = tabEl.getAttribute('id') || '';
813
+ // Use id or internal id
814
+ const idAttr = tabEl.getAttribute('id') || tabEl.getAttribute('data-cv-internal-id') || '';
646
815
  const splitIds = this.splitTabIds(idAttr);
647
816
  return splitIds.includes(tabId);
648
817
  });
@@ -652,7 +821,7 @@
652
821
  */
653
822
  static getTabgroupsWithId(rootEl, sourceGroupId, tabId) {
654
823
  const syncedGroupEls = [];
655
- const allGroupEls = Array.from(rootEl.querySelectorAll(`${TABGROUP_SELECTOR}[id="${sourceGroupId}"]`));
824
+ const allGroupEls = Array.from(rootEl.querySelectorAll(`${TABGROUP_SELECTOR$1}[id="${sourceGroupId}"]`));
656
825
  allGroupEls.forEach((targetGroupEl) => {
657
826
  // Only sync if target group actually contains this tab
658
827
  if (this.groupHasTab(targetGroupEl, tabId)) {
@@ -661,6 +830,35 @@
661
830
  });
662
831
  return syncedGroupEls;
663
832
  }
833
+ /**
834
+ * Update pin icon visibility for all tab groups based on current state.
835
+ * Shows pin icon for tabs that are in the persisted state (i.e., have been double-clicked).
836
+ */
837
+ static updatePinIcons(tabGroups, tabs) {
838
+ tabGroups.forEach((groupEl) => {
839
+ const groupId = groupEl.getAttribute('id');
840
+ if (!groupId)
841
+ return;
842
+ const persistedTabId = tabs[groupId];
843
+ // Find all nav links in this group
844
+ const navLinks = groupEl.querySelectorAll('.nav-link');
845
+ navLinks.forEach((link) => {
846
+ const rawTabId = link.getAttribute('data-raw-tab-id');
847
+ const pinIcon = link.querySelector('.cv-tab-pin-icon');
848
+ if (!pinIcon || !rawTabId)
849
+ return;
850
+ // Check if persisted tab ID matches any of the split IDs (for multi-ID tabs)
851
+ const splitIds = this.splitTabIds(rawTabId);
852
+ const shouldShowPin = persistedTabId && splitIds.includes(persistedTabId);
853
+ if (shouldShowPin) {
854
+ pinIcon.style.display = 'inline-block';
855
+ }
856
+ else {
857
+ pinIcon.style.display = 'none';
858
+ }
859
+ });
860
+ });
861
+ }
664
862
  }
665
863
 
666
864
  class AssetsManager {
@@ -786,33 +984,31 @@
786
984
  }
787
985
  }
788
986
 
789
- // Constants for selectors
790
- const TOGGLE_DATA_SELECTOR = "[data-cv-toggle], [data-customviews-toggle]";
791
- const TOGGLE_ELEMENT_SELECTOR = "cv-toggle";
792
- const TOGGLE_SELECTOR = `${TOGGLE_DATA_SELECTOR}, ${TOGGLE_ELEMENT_SELECTOR}`;
793
987
  /**
794
988
  * ToggleManager handles discovery, visibility, and asset rendering for toggle elements
795
989
  */
796
990
  class ToggleManager {
797
991
  /**
798
- * Apply toggle visibility to all toggle elements in the DOM
992
+ * Apply toggle visibility to a given list of toggle elements
799
993
  */
800
- static applyToggles(rootEl, activeToggles) {
801
- rootEl.querySelectorAll(TOGGLE_SELECTOR).forEach(el => {
994
+ static applyToggles(elements, activeToggles) {
995
+ elements.forEach(el => {
802
996
  const categories = this.getToggleCategories(el);
803
997
  const shouldShow = categories.some(cat => activeToggles.includes(cat));
804
998
  this.applyToggleVisibility(el, shouldShow);
805
999
  });
806
1000
  }
807
1001
  /**
808
- * Render assets into toggle elements that are currently visible
1002
+ * Render assets into a given list of toggle elements that are currently visible
809
1003
  */
810
- static renderAssets(rootEl, activeToggles, assetsManager) {
811
- rootEl.querySelectorAll(TOGGLE_SELECTOR).forEach(el => {
1004
+ static renderAssets(elements, activeToggles, assetsManager) {
1005
+ elements.forEach(el => {
812
1006
  const categories = this.getToggleCategories(el);
813
1007
  const toggleId = this.getToggleId(el);
814
- if (toggleId && categories.some(cat => activeToggles.includes(cat))) {
1008
+ const isRendered = el.dataset.cvRendered === 'true';
1009
+ if (toggleId && !isRendered && categories.some(cat => activeToggles.includes(cat))) {
815
1010
  renderAssetInto(el, toggleId, assetsManager);
1011
+ el.dataset.cvRendered = 'true';
816
1012
  }
817
1013
  });
818
1014
  }
@@ -848,193 +1044,329 @@
848
1044
  el.classList.remove('cv-visible');
849
1045
  }
850
1046
  }
1047
+ /**
1048
+ * Scans a given DOM subtree for toggle elements and initializes them.
1049
+ * This includes applying visibility and rendering assets.
1050
+ */
1051
+ static initializeToggles(root, activeToggles, assetsManager) {
1052
+ const elements = [];
1053
+ if (root.matches('[data-cv-toggle], [data-customviews-toggle], cv-toggle')) {
1054
+ elements.push(root);
1055
+ }
1056
+ root.querySelectorAll('[data-cv-toggle], [data-customviews-toggle], cv-toggle').forEach(el => elements.push(el));
1057
+ if (elements.length === 0)
1058
+ return;
1059
+ this.applyToggles(elements, activeToggles);
1060
+ this.renderAssets(elements, activeToggles, assetsManager);
1061
+ }
1062
+ }
1063
+
1064
+ // src/utils/scroll-manager.ts
1065
+ class ScrollManager {
1066
+ /**
1067
+ * Finds the highest tab group currently in the viewport.
1068
+ * This is intended to be called BEFORE the state changes, to identify which element to scroll to.
1069
+ * @returns The HTMLElement of the highest visible tab group, or null if none are found.
1070
+ */
1071
+ static findHighestVisibleTabGroup() {
1072
+ // console.log('[ScrollManager] Finding highest visible tab group.');
1073
+ // 1. Detect fixed/sticky header and calculate its height for offset.
1074
+ let headerOffset = 0;
1075
+ const headerEl = document.querySelector('header');
1076
+ let isHeaderFixedOrSticky = false;
1077
+ if (headerEl) {
1078
+ const headerStyle = window.getComputedStyle(headerEl);
1079
+ isHeaderFixedOrSticky = ['fixed', 'sticky'].includes(headerStyle.position);
1080
+ if (isHeaderFixedOrSticky) {
1081
+ headerOffset = headerEl.getBoundingClientRect().height;
1082
+ }
1083
+ }
1084
+ const contentTop = headerOffset; // Viewport-relative position where content begins.
1085
+ // 2. Find all tab groups, filtering out any inside the main header.
1086
+ const allTabGroups = Array.from(document.querySelectorAll('cv-tabgroup'));
1087
+ const candidateGroups = allTabGroups.filter(groupEl => {
1088
+ if (isHeaderFixedOrSticky && headerEl && groupEl.closest('header') === headerEl) {
1089
+ return false;
1090
+ }
1091
+ return true;
1092
+ });
1093
+ // 3. Find the highest group that is visible in the content area (below the header).
1094
+ let highestVisibleGroup = null;
1095
+ let highestVisibleGroupTop = Infinity;
1096
+ for (const groupEl of candidateGroups) {
1097
+ const rect = groupEl.getBoundingClientRect();
1098
+ // A group is "visible" if it's not completely above the content area or completely below the viewport.
1099
+ const isVisibleInContentArea = rect.bottom > contentTop && rect.top < window.innerHeight;
1100
+ if (isVisibleInContentArea) {
1101
+ // We want the one with the smallest 'top' value (closest to the top of the viewport).
1102
+ if (rect.top < highestVisibleGroupTop) {
1103
+ highestVisibleGroup = groupEl;
1104
+ highestVisibleGroupTop = rect.top;
1105
+ }
1106
+ }
1107
+ }
1108
+ return highestVisibleGroup;
1109
+ }
1110
+ /**
1111
+ * Scrolls the page to align the given tab group's header (or the group itself)
1112
+ * to the top of the viewport, accounting for a fixed/sticky page header.
1113
+ * This should be called AFTER the content has changed.
1114
+ * @param groupEl The tab group element to scroll to.
1115
+ */
1116
+ static scrollToTabGroup(groupEl) {
1117
+ // console.log('[ScrollManager] Scrolling to tab group:', groupEl);
1118
+ // 1. Detect fixed/sticky header and calculate its height for offset.
1119
+ let headerOffset = 0;
1120
+ const headerEl = document.querySelector('header');
1121
+ if (headerEl) {
1122
+ const headerStyle = window.getComputedStyle(headerEl);
1123
+ if (['fixed', 'sticky'].includes(headerStyle.position)) {
1124
+ headerOffset = headerEl.getBoundingClientRect().height;
1125
+ }
1126
+ }
1127
+ const PADDING_BELOW_HEADER = 20; // Extra space.
1128
+ // 2. Calculate the target position.
1129
+ const targetElementRect = groupEl.getBoundingClientRect();
1130
+ // Calculate the absolute top position of the target element in the document.
1131
+ const scrollTargetY = targetElementRect.top + window.scrollY;
1132
+ // Adjust for the header offset and padding to position it just below the header.
1133
+ const finalScrollY = scrollTargetY - headerOffset - PADDING_BELOW_HEADER;
1134
+ // change to 'auto' if instant scroll is preferred.
1135
+ window.scrollTo({
1136
+ top: finalScrollY,
1137
+ behavior: 'smooth',
1138
+ });
1139
+ }
1140
+ /**
1141
+ * Adjusts the scroll position to keep a specific element in the same visual location
1142
+ * after a content change. This is useful for preventing the page from jumping when
1143
+ * content above the element is added or removed.
1144
+ * @param scrollAnchor An object containing the element to anchor and its initial top position.
1145
+ */
1146
+ static handleScrollAnchor(scrollAnchor) {
1147
+ requestAnimationFrame(() => {
1148
+ const { element, top: initialTop } = scrollAnchor;
1149
+ const newTop = element.getBoundingClientRect().top;
1150
+ const scrollDelta = newTop - initialTop;
1151
+ // Only scroll if there's a noticeable change to avoid jitter
1152
+ if (Math.abs(scrollDelta) > 1) {
1153
+ window.scrollBy({
1154
+ top: scrollDelta,
1155
+ behavior: 'instant'
1156
+ });
1157
+ }
1158
+ });
1159
+ }
851
1160
  }
852
1161
 
853
1162
  /**
854
1163
  * Styles for toggle visibility and animations
855
1164
  */
856
- const TOGGLE_STYLES = `
857
- /* Core toggle visibility transitions */
858
- [data-cv-toggle], [data-customviews-toggle], cv-toggle {
859
- transition: opacity 150ms ease,
860
- transform 150ms ease,
861
- max-height 200ms ease,
862
- margin 150ms ease;
863
- will-change: opacity, transform, max-height, margin;
864
- }
865
-
866
- .cv-visible {
867
- opacity: 1 !important;
868
- transform: translateY(0) !important;
869
- max-height: var(--cv-max-height, 9999px) !important;
870
- }
871
-
872
- .cv-hidden {
873
- opacity: 0 !important;
874
- transform: translateY(-4px) !important;
875
- pointer-events: none !important;
876
- padding-top: 0 !important;
877
- padding-bottom: 0 !important;
878
- border-top-width: 0 !important;
879
- border-bottom-width: 0 !important;
880
- max-height: 0 !important;
881
- margin-top: 0 !important;
882
- margin-bottom: 0 !important;
883
- overflow: hidden !important;
884
- }
1165
+ const TOGGLE_STYLES = `
1166
+ /* Core toggle visibility transitions */
1167
+ [data-cv-toggle], [data-customviews-toggle], cv-toggle {
1168
+ transition: opacity 150ms ease,
1169
+ transform 150ms ease,
1170
+ max-height 200ms ease,
1171
+ margin 150ms ease;
1172
+ will-change: opacity, transform, max-height, margin;
1173
+ }
1174
+
1175
+ .cv-visible {
1176
+ opacity: 1 !important;
1177
+ transform: translateY(0) !important;
1178
+ max-height: var(--cv-max-height, 9999px) !important;
1179
+ }
1180
+
1181
+ .cv-hidden {
1182
+ opacity: 0 !important;
1183
+ transform: translateY(-4px) !important;
1184
+ pointer-events: none !important;
1185
+ padding-top: 0 !important;
1186
+ padding-bottom: 0 !important;
1187
+ border-top-width: 0 !important;
1188
+ border-bottom-width: 0 !important;
1189
+ max-height: 0 !important;
1190
+ margin-top: 0 !important;
1191
+ margin-bottom: 0 !important;
1192
+ overflow: hidden !important;
1193
+ }
885
1194
  `;
886
1195
 
887
1196
  /**
888
1197
  * Styles for tab groups and tab navigation
889
1198
  */
890
- const TAB_STYLES = `
891
- /* Tab navigation styles - Bootstrap-style tabs matching MarkBind */
892
- .cv-tabs-nav {
893
- display: flex;
894
- flex-wrap: wrap;
895
- padding-left: 0;
896
- margin-top: 0.5rem;
897
- margin-bottom: 1rem;
898
- list-style: none;
899
- border-bottom: 1px solid #dee2e6;
900
-
901
- align-items: stretch;
902
- }
903
-
904
- .cv-tabs-nav .nav-item {
905
- margin-bottom: -1px;
906
- list-style: none;
907
- display: flex; /* was inline-block → make flex to stretch height */
908
- align-items: stretch; /* stretch link to full height */
909
- }
910
-
911
- .cv-tabs-nav .nav-link {
912
- display: flex;
913
- align-items: center;
914
- justify-content: center;
915
- padding: 0.5rem 1rem;
916
- color: #495057;
917
- text-decoration: none;
918
- background-color: transparent;
919
- border: 1px solid transparent;
920
- border-top-left-radius: 0.25rem;
921
- border-top-right-radius: 0.25rem;
922
- transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
923
- cursor: pointer;
924
- min-height: 2.5rem;
925
- box-sizing: border-box;
926
- }
927
-
928
- .cv-tabs-nav .nav-link p {
929
- margin: 0; /* remove default margins */
930
- display: inline; /* or inline-block */
931
- }
932
-
933
- .cv-tabs-nav .nav-link:hover,
934
- .cv-tabs-nav .nav-link:focus {
935
- border-color: #e9ecef #e9ecef #dee2e6;
936
- isolation: isolate;
937
- }
938
-
939
- .cv-tabs-nav .nav-link.active {
940
- color: #495057;
941
- background-color: #fff;
942
- border-color: #dee2e6 #dee2e6 #fff;
943
- }
944
-
945
- .cv-tabs-nav .nav-link:focus {
946
- outline: 0;
947
- box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
948
- }
949
-
950
- /* Legacy button-based nav (deprecated, kept for compatibility) */
951
- .cv-tabs-nav-item {
952
- background: none;
953
- border: none;
954
- border-bottom: 2px solid transparent;
955
- padding: 0.5rem 1rem;
956
- cursor: pointer;
957
- font-size: 1rem;
958
- color: #6c757d;
959
- transition: color 150ms ease, border-color 150ms ease;
960
- }
961
-
962
- .cv-tabs-nav-item:hover {
963
- color: #495057;
964
- border-bottom-color: #dee2e6;
965
- }
966
-
967
- .cv-tabs-nav-item.active {
968
- color: #007bff;
969
- border-bottom-color: #007bff;
970
- font-weight: 500;
971
- }
972
-
973
- .cv-tabs-nav-item:focus {
974
- outline: 2px solid #007bff;
975
- outline-offset: 2px;
976
- }
977
-
978
- /* Tab panel base styles */
979
- cv-tab {
980
- display: block;
981
- }
982
-
983
- /* Hide cv-tab-header source element; content is extracted to nav link */
984
- cv-tab-header {
985
- display: none !important;
986
- }
987
-
988
- /* Allow cv-tab-body to flow naturally */
989
- cv-tab-body {
990
- display: block;
991
- }
992
-
993
- /* Override visibility for tab panels - use display instead of collapse animation */
994
- cv-tab.cv-hidden {
995
- display: none !important;
996
- }
997
-
998
- cv-tab.cv-visible {
999
- display: block !important;
1000
- }
1001
-
1002
- cv-tabgroup {
1003
- display: block;
1004
- margin-bottom: 1.5rem;
1005
- }
1006
-
1007
- /* Bottom border line for tab groups */
1008
- .cv-tabgroup-bottom-border {
1009
- border-bottom: 1px solid #dee2e6;
1010
- margin-top: 1rem;
1011
- }
1012
-
1013
- /* Tab content wrapper */
1014
- .cv-tab-content {
1015
- padding: 1rem 0;
1016
- }
1017
-
1018
- /* Viewer-controlled nav visibility: hide nav containers when requested */
1019
- .cv-tabs-nav-hidden {
1020
- display: none !important;
1021
- }
1022
-
1023
- /* Print-friendly: hide tab navigation when printing to reduce clutter */
1024
- @media print {
1025
- .cv-tabs-nav {
1026
- display: none !important;
1027
- }
1028
- }
1199
+ const TAB_STYLES = `
1200
+ /* Tab navigation styles - Bootstrap-style tabs matching MarkBind */
1201
+ .cv-tabs-nav {
1202
+ display: flex;
1203
+ flex-wrap: wrap;
1204
+ padding-left: 0;
1205
+ margin-top: 0.5rem;
1206
+ margin-bottom: 1rem;
1207
+ list-style: none;
1208
+ border-bottom: 1px solid #dee2e6;
1209
+
1210
+ align-items: stretch;
1211
+ }
1212
+
1213
+ .cv-tabs-nav .nav-item {
1214
+ margin-bottom: -1px;
1215
+ list-style: none;
1216
+ display: flex; /* was inline-block → make flex to stretch height */
1217
+ align-items: stretch; /* stretch link to full height */
1218
+ }
1219
+
1220
+ .cv-tabs-nav .nav-link {
1221
+ display: flex;
1222
+ align-items: center;
1223
+ justify-content: center;
1224
+ padding: 0.5rem 1rem;
1225
+ color: #495057;
1226
+ text-decoration: none;
1227
+ background-color: transparent;
1228
+ border: 1px solid transparent;
1229
+ border-top-left-radius: 0.25rem;
1230
+ border-top-right-radius: 0.25rem;
1231
+ transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
1232
+ cursor: pointer;
1233
+ min-height: 2.5rem;
1234
+ box-sizing: border-box;
1235
+ }
1236
+
1237
+ .cv-tabs-nav .nav-link p {
1238
+ margin: 0; /* remove default margins */
1239
+ display: inline; /* or inline-block */
1240
+ }
1241
+
1242
+ /* Tab header container with pin icon */
1243
+ .cv-tab-header-container {
1244
+ display: flex;
1245
+ align-items: center;
1246
+ gap: 0.5rem;
1247
+ }
1248
+
1249
+ .cv-tab-header-text {
1250
+ flex: 1;
1251
+ }
1252
+
1253
+ .cv-tab-pin-icon {
1254
+ display: inline-block;
1255
+ line-height: 0;
1256
+ flex-shrink: 0;
1257
+ }
1258
+
1259
+ .cv-tab-pin-icon svg {
1260
+ vertical-align: middle;
1261
+ width: 14px;
1262
+ height: 14px;
1263
+ }
1264
+
1265
+ .cv-tabs-nav .nav-link:hover,
1266
+ .cv-tabs-nav .nav-link:focus {
1267
+ border-color: #e9ecef #e9ecef #dee2e6;
1268
+ isolation: isolate;
1269
+ }
1270
+
1271
+ .cv-tabs-nav .nav-link.active {
1272
+ color: #495057;
1273
+ background-color: #fff;
1274
+ border-color: #dee2e6 #dee2e6 #fff;
1275
+ }
1276
+
1277
+ .cv-tabs-nav .nav-link:focus {
1278
+ outline: 0;
1279
+ box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
1280
+ }
1281
+
1282
+ /* Legacy button-based nav (deprecated, kept for compatibility) */
1283
+ .cv-tabs-nav-item {
1284
+ background: none;
1285
+ border: none;
1286
+ border-bottom: 2px solid transparent;
1287
+ padding: 0.5rem 1rem;
1288
+ cursor: pointer;
1289
+ font-size: 1rem;
1290
+ color: #6c757d;
1291
+ transition: color 150ms ease, border-color 150ms ease;
1292
+ }
1293
+
1294
+ .cv-tabs-nav-item:hover {
1295
+ color: #495057;
1296
+ border-bottom-color: #dee2e6;
1297
+ }
1298
+
1299
+ .cv-tabs-nav-item.active {
1300
+ color: #007bff;
1301
+ border-bottom-color: #007bff;
1302
+ font-weight: 500;
1303
+ }
1304
+
1305
+ .cv-tabs-nav-item:focus {
1306
+ outline: 2px solid #007bff;
1307
+ outline-offset: 2px;
1308
+ }
1309
+
1310
+ /* Tab panel base styles */
1311
+ cv-tab {
1312
+ display: block;
1313
+ }
1314
+
1315
+ /* Hide cv-tab-header source element; content is extracted to nav link */
1316
+ cv-tab-header {
1317
+ display: none !important;
1318
+ }
1319
+
1320
+ /* Allow cv-tab-body to flow naturally */
1321
+ cv-tab-body {
1322
+ display: block;
1323
+ }
1324
+
1325
+ /* Override visibility for tab panels - use display instead of collapse animation */
1326
+ cv-tab.cv-hidden {
1327
+ display: none !important;
1328
+ }
1329
+
1330
+ cv-tab.cv-visible {
1331
+ display: block !important;
1332
+ }
1333
+
1334
+ cv-tabgroup {
1335
+ display: block;
1336
+ margin-bottom: 1.5rem;
1337
+ }
1338
+
1339
+ /* Bottom border line for tab groups */
1340
+ .cv-tabgroup-bottom-border {
1341
+ border-bottom: 1px solid #dee2e6;
1342
+ margin-top: 1rem;
1343
+ }
1344
+
1345
+ /* Tab content wrapper */
1346
+ .cv-tab-content {
1347
+ padding: 1rem 0;
1348
+ }
1349
+
1350
+ /* Viewer-controlled nav visibility: hide nav containers when requested */
1351
+ .cv-tabs-nav-hidden {
1352
+ display: none !important;
1353
+ }
1354
+
1355
+ /* Print-friendly: hide tab navigation when printing to reduce clutter */
1356
+ @media print {
1357
+ .cv-tabs-nav {
1358
+ display: none !important;
1359
+ }
1360
+ }
1029
1361
  `;
1030
1362
 
1031
1363
  /**
1032
1364
  * Combined core styles for toggles and tabs
1033
1365
  */
1034
- const CORE_STYLES = `
1035
- ${TOGGLE_STYLES}
1036
-
1037
- ${TAB_STYLES}
1366
+ const CORE_STYLES = `
1367
+ ${TOGGLE_STYLES}
1368
+
1369
+ ${TAB_STYLES}
1038
1370
  `;
1039
1371
  /**
1040
1372
  * Add styles for hiding and showing toggles animations and transitions to the document head
@@ -1050,11 +1382,18 @@ ${TAB_STYLES}
1050
1382
  document.head.appendChild(style);
1051
1383
  }
1052
1384
 
1385
+ const TOGGLE_SELECTOR = "[data-cv-toggle], [data-customviews-toggle], cv-toggle";
1386
+ const TABGROUP_SELECTOR = 'cv-tabgroup';
1053
1387
  class CustomViewsCore {
1054
1388
  rootEl;
1055
1389
  assetsManager;
1056
1390
  persistenceManager;
1057
1391
  visibilityManager;
1392
+ observer = null;
1393
+ componentRegistry = {
1394
+ toggles: new Set(),
1395
+ tabGroups: new Set(),
1396
+ };
1058
1397
  config;
1059
1398
  stateChangeListeners = [];
1060
1399
  showUrlEnabled;
@@ -1068,6 +1407,57 @@ ${TAB_STYLES}
1068
1407
  this.showUrlEnabled = opt.showUrl ?? false;
1069
1408
  this.lastAppliedState = this.cloneState(this.getComputedDefaultState());
1070
1409
  }
1410
+ /**
1411
+ * Scan the given element for toggles and tab groups, register them
1412
+ * Returns true if new components were found
1413
+ */
1414
+ scan(element) {
1415
+ let newComponentsFound = false;
1416
+ // Scan for toggles
1417
+ const toggles = Array.from(element.querySelectorAll(TOGGLE_SELECTOR));
1418
+ if (element.matches(TOGGLE_SELECTOR)) {
1419
+ toggles.unshift(element);
1420
+ }
1421
+ toggles.forEach((toggle) => {
1422
+ if (!this.componentRegistry.toggles.has(toggle)) {
1423
+ this.componentRegistry.toggles.add(toggle);
1424
+ newComponentsFound = true;
1425
+ }
1426
+ });
1427
+ // Scan for tab groups
1428
+ const tabGroups = Array.from(element.querySelectorAll(TABGROUP_SELECTOR));
1429
+ if (element.matches(TABGROUP_SELECTOR)) {
1430
+ tabGroups.unshift(element);
1431
+ }
1432
+ tabGroups.forEach((tabGroup) => {
1433
+ if (!this.componentRegistry.tabGroups.has(tabGroup)) {
1434
+ this.componentRegistry.tabGroups.add(tabGroup);
1435
+ newComponentsFound = true;
1436
+ }
1437
+ });
1438
+ return newComponentsFound;
1439
+ }
1440
+ /**
1441
+ * Unscan the given element for toggles and tab groups, de-register them
1442
+ */
1443
+ unscan(element) {
1444
+ // Unscan for toggles
1445
+ const toggles = Array.from(element.querySelectorAll(TOGGLE_SELECTOR));
1446
+ if (element.matches(TOGGLE_SELECTOR)) {
1447
+ toggles.unshift(element);
1448
+ }
1449
+ toggles.forEach((toggle) => {
1450
+ this.componentRegistry.toggles.delete(toggle);
1451
+ });
1452
+ // Unscan for tab groups
1453
+ const tabGroups = Array.from(element.querySelectorAll(TABGROUP_SELECTOR));
1454
+ if (element.matches(TABGROUP_SELECTOR)) {
1455
+ tabGroups.unshift(element);
1456
+ }
1457
+ tabGroups.forEach((tabGroup) => {
1458
+ this.componentRegistry.tabGroups.delete(tabGroup);
1459
+ });
1460
+ }
1071
1461
  getConfig() {
1072
1462
  return this.config;
1073
1463
  }
@@ -1102,7 +1492,7 @@ ${TAB_STYLES}
1102
1492
  });
1103
1493
  }
1104
1494
  const computedState = {
1105
- toggles: [...(this.config.allToggles || [])],
1495
+ toggles: this.config.toggles?.map(t => t.id) || [],
1106
1496
  tabs
1107
1497
  };
1108
1498
  return computedState;
@@ -1141,14 +1531,35 @@ ${TAB_STYLES}
1141
1531
  // Inject styles, setup listeners and call rendering logic
1142
1532
  async init() {
1143
1533
  injectCoreStyles();
1144
- // Build navigation once (with click and double-click handlers)
1145
- TabManager.buildNavs(this.rootEl, this.config.tabGroups,
1534
+ this.scan(this.rootEl);
1535
+ // Initialize all components found on initial scan
1536
+ this.initializeNewComponents();
1537
+ // Apply stored nav visibility preference on page load
1538
+ const navPref = this.persistenceManager.getPersistedTabNavVisibility();
1539
+ if (navPref !== null) {
1540
+ TabManager.setNavsVisibility(this.rootEl, navPref);
1541
+ }
1542
+ // For session history, clicks on back/forward button
1543
+ window.addEventListener("popstate", () => {
1544
+ this.loadAndCallApplyState();
1545
+ });
1546
+ this.loadAndCallApplyState();
1547
+ this.initObserver();
1548
+ }
1549
+ initializeNewComponents() {
1550
+ // Build navigation for any newly added tab groups.
1551
+ // The `data-cv-initialized` attribute in `buildNavs` prevents re-initialization.
1552
+ TabManager.buildNavs(Array.from(this.componentRegistry.tabGroups), this.config.tabGroups,
1146
1553
  // Single click: update clicked group only (local, no persistence)
1147
1554
  (groupId, tabId, groupEl) => {
1148
1555
  this.setActiveTab(groupId, tabId, groupEl);
1149
1556
  },
1150
1557
  // Double click: sync across all tabgroups with same id (with persistence)
1151
- (groupId, tabId, _groupEl) => {
1558
+ (groupId, tabId, groupEl) => {
1559
+ // 1. Record position before state change
1560
+ const navHeader = groupEl.querySelector('.cv-tabs-nav');
1561
+ const anchorElement = navHeader instanceof HTMLElement ? navHeader : groupEl;
1562
+ const initialTop = anchorElement.getBoundingClientRect().top;
1152
1563
  const currentTabs = this.getCurrentActiveTabs();
1153
1564
  currentTabs[groupId] = tabId;
1154
1565
  const currentToggles = this.getCurrentActiveToggles();
@@ -1156,19 +1567,51 @@ ${TAB_STYLES}
1156
1567
  toggles: currentToggles,
1157
1568
  tabs: currentTabs
1158
1569
  };
1159
- // applyState() will handle all visual updates via renderState()
1160
- this.applyState(newState);
1570
+ // 2. Apply state with scroll anchor information
1571
+ this.applyState(newState, {
1572
+ scrollAnchor: { element: anchorElement, top: initialTop }
1573
+ });
1161
1574
  });
1162
- // Apply stored nav visibility preference on page load
1163
- const navPref = this.persistenceManager.getPersistedTabNavVisibility();
1164
- if (navPref !== null) {
1165
- TabManager.setNavsVisibility(this.rootEl, navPref);
1166
- }
1167
- // For session history, clicks on back/forward button
1168
- window.addEventListener("popstate", () => {
1169
- this.loadAndCallApplyState();
1575
+ // Future components (e.g., toggles, widgets) can be initialized here
1576
+ }
1577
+ initObserver() {
1578
+ this.observer = new MutationObserver((mutations) => {
1579
+ let newComponentsFound = false;
1580
+ for (const mutation of mutations) {
1581
+ if (mutation.type === 'childList') {
1582
+ mutation.addedNodes.forEach((node) => {
1583
+ if (node instanceof Element) {
1584
+ // Scan the new node for components and add them to the registry
1585
+ if (this.scan(node)) {
1586
+ newComponentsFound = true;
1587
+ }
1588
+ }
1589
+ });
1590
+ mutation.removedNodes.forEach((node) => {
1591
+ if (node instanceof Element) {
1592
+ // Unscan the removed node to cleanup the registry
1593
+ this.unscan(node);
1594
+ }
1595
+ });
1596
+ }
1597
+ }
1598
+ if (newComponentsFound) {
1599
+ // Initialize navs for new components.
1600
+ this.initializeNewComponents();
1601
+ // Re-apply the last known state. renderState will handle disconnecting
1602
+ // the observer to prevent infinite loops.
1603
+ if (this.lastAppliedState) {
1604
+ this.renderState(this.lastAppliedState);
1605
+ }
1606
+ }
1170
1607
  });
1171
- this.loadAndCallApplyState();
1608
+ // Observe only the root element to avoid performance issues on large pages.
1609
+ if (this.rootEl) {
1610
+ this.observer.observe(this.rootEl, {
1611
+ childList: true,
1612
+ subtree: true,
1613
+ });
1614
+ }
1172
1615
  }
1173
1616
  // Priority: URL state > persisted state > config default > computed default
1174
1617
  // Also filters using the visibility manager to persist selection
@@ -1191,8 +1634,16 @@ ${TAB_STYLES}
1191
1634
  }
1192
1635
  /**
1193
1636
  * Apply a custom state, saves to localStorage and updates the URL
1637
+ * Add 'source' in options to indicate the origin of the state change
1638
+ * (e.g., 'widget' to trigger scroll behavior)
1639
+ * Add scrollAnchor in options to maintain scroll position of a specific element
1194
1640
  */
1195
- applyState(state) {
1641
+ applyState(state, options) {
1642
+ // console.log(`[Core] applyState called with source: ${options?.source}`, state);
1643
+ let groupToScrollTo = null;
1644
+ if (options?.source === 'widget') {
1645
+ groupToScrollTo = ScrollManager.findHighestVisibleTabGroup();
1646
+ }
1196
1647
  const snapshot = this.cloneState(state);
1197
1648
  this.renderState(snapshot);
1198
1649
  this.persistenceManager.persistState(snapshot);
@@ -1202,22 +1653,46 @@ ${TAB_STYLES}
1202
1653
  else {
1203
1654
  URLStateManager.clearURL();
1204
1655
  }
1656
+ if (groupToScrollTo) {
1657
+ // Defer scrolling until after the DOM has been updated by renderState
1658
+ queueMicrotask(() => {
1659
+ ScrollManager.scrollToTabGroup(groupToScrollTo);
1660
+ });
1661
+ }
1662
+ // Handle scroll anchoring for double-clicks
1663
+ // scroll to original position after content changes
1664
+ if (options?.scrollAnchor) {
1665
+ ScrollManager.handleScrollAnchor(options.scrollAnchor);
1666
+ }
1205
1667
  }
1206
- /** Render all toggles for the current state */
1668
+ /**
1669
+ * Renders state on components in ComponentRegistry
1670
+ * Applies the given state.
1671
+ * Disconnects the mutation observer during rendering to prevent loops
1672
+ **/
1207
1673
  renderState(state) {
1674
+ this.observer?.disconnect();
1208
1675
  this.lastAppliedState = this.cloneState(state);
1209
1676
  const toggles = state?.toggles || [];
1210
1677
  const finalToggles = this.visibilityManager.filterVisibleToggles(toggles);
1678
+ const toggleElements = Array.from(this.componentRegistry.toggles);
1679
+ const tabGroupElements = Array.from(this.componentRegistry.tabGroups);
1211
1680
  // Apply toggle visibility
1212
- ToggleManager.applyToggles(this.rootEl, finalToggles);
1681
+ ToggleManager.applyToggles(toggleElements, finalToggles);
1213
1682
  // Render assets into toggles
1214
- ToggleManager.renderAssets(this.rootEl, finalToggles, this.assetsManager);
1683
+ ToggleManager.renderAssets(toggleElements, finalToggles, this.assetsManager);
1215
1684
  // Apply tab selections
1216
- TabManager.applySelections(this.rootEl, state.tabs || {}, this.config.tabGroups);
1685
+ TabManager.applyTabSelections(tabGroupElements, state.tabs || {}, this.config.tabGroups);
1217
1686
  // Update nav active states (without rebuilding)
1218
- TabManager.updateAllNavActiveStates(this.rootEl, state.tabs || {}, this.config.tabGroups);
1687
+ TabManager.updateAllNavActiveStates(tabGroupElements, state.tabs || {}, this.config.tabGroups);
1688
+ // Update pin icons to show which tabs are persisted
1689
+ TabManager.updatePinIcons(tabGroupElements, state.tabs || {});
1219
1690
  // Notify state change listeners (like widgets)
1220
1691
  this.notifyStateChangeListeners();
1692
+ this.observer?.observe(document.body, {
1693
+ childList: true,
1694
+ subtree: true,
1695
+ });
1221
1696
  }
1222
1697
  /**
1223
1698
  * Reset to default state
@@ -1469,7 +1944,7 @@ ${TAB_STYLES}
1469
1944
  else {
1470
1945
  console.error("No config provided, using minimal default config");
1471
1946
  // Create a minimal default config
1472
- config = { allToggles: [], defaultState: {} };
1947
+ config = { toggles: [], defaultState: {} };
1473
1948
  }
1474
1949
  const coreOptions = {
1475
1950
  assetsManager,
@@ -1492,1077 +1967,1081 @@ ${TAB_STYLES}
1492
1967
  * Note: Styles are kept as a TypeScript string for compatibility with the build system.
1493
1968
  * This approach ensures the styles are properly bundled and don't require separate CSS file handling.
1494
1969
  */
1495
- const WIDGET_STYLES = `
1496
- /* Rounded rectangle widget icon styles */
1497
- .cv-widget-icon {
1498
- position: fixed;
1499
- /* Slightly transparent by default so the widget is subtle at the page edge */
1500
- background: rgba(255, 255, 255, 0.92);
1501
- color: rgba(0, 0, 0, 0.9);
1502
- opacity: 0.6;
1503
- display: flex;
1504
- align-items: center;
1505
- justify-content: center;
1506
- font-size: 18px;
1507
- font-weight: bold;
1508
- cursor: pointer;
1509
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
1510
- z-index: 9998;
1511
- transition: all 0.3s ease;
1512
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
1513
- }
1514
-
1515
- .cv-widget-icon:hover {
1516
- /* Become fully opaque on hover to improve readability */
1517
- background: rgba(255, 255, 255, 1);
1518
- color: rgba(0, 0, 0, 1);
1519
- opacity: 1;
1520
- }
1521
-
1522
- /* Top-right: rounded end on left, sticks out leftward on hover */
1523
- .cv-widget-top-right {
1524
- top: 20px;
1525
- right: 0;
1526
- border-radius: 18px 0 0 18px;
1527
- padding-left: 8px;
1528
- justify-content: flex-start;
1529
- }
1530
-
1531
- /* Top-left: rounded end on right, sticks out rightward on hover */
1532
- .cv-widget-top-left {
1533
- top: 20px;
1534
- left: 0;
1535
- border-radius: 0 18px 18px 0;
1536
- padding-right: 8px;
1537
- justify-content: flex-end;
1538
- }
1539
-
1540
- /* Bottom-right: rounded end on left, sticks out leftward on hover */
1541
- .cv-widget-bottom-right {
1542
- bottom: 20px;
1543
- right: 0;
1544
- border-radius: 18px 0 0 18px;
1545
- padding-left: 8px;
1546
- justify-content: flex-start;
1547
- }
1548
-
1549
- /* Bottom-left: rounded end on right, sticks out rightward on hover */
1550
- .cv-widget-bottom-left {
1551
- bottom: 20px;
1552
- left: 0;
1553
- border-radius: 0 18px 18px 0;
1554
- padding-right: 8px;
1555
- justify-content: flex-end;
1556
- }
1557
-
1558
- /* Middle-left: rounded end on right, sticks out rightward on hover */
1559
- .cv-widget-middle-left {
1560
- top: 50%;
1561
- left: 0;
1562
- transform: translateY(-50%);
1563
- border-radius: 0 18px 18px 0;
1564
- padding-right: 8px;
1565
- justify-content: flex-end;
1566
- }
1567
-
1568
- /* Middle-right: rounded end on left, sticks out leftward on hover */
1569
- .cv-widget-middle-right {
1570
- top: 50%;
1571
- right: 0;
1572
- transform: translateY(-50%);
1573
- border-radius: 18px 0 0 18px;
1574
- padding-left: 8px;
1575
- justify-content: flex-start;
1576
- }
1577
-
1578
- .cv-widget-top-right,
1579
- .cv-widget-middle-right,
1580
- .cv-widget-bottom-right,
1581
- .cv-widget-top-left,
1582
- .cv-widget-middle-left,
1583
- .cv-widget-bottom-left {
1584
- height: 36px;
1585
- width: 36px;
1586
- }
1587
-
1588
- .cv-widget-middle-right:hover,
1589
- .cv-widget-top-right:hover,
1590
- .cv-widget-bottom-right:hover,
1591
- .cv-widget-top-left:hover,
1592
- .cv-widget-middle-left:hover,
1593
- .cv-widget-bottom-left:hover {
1594
- width: 55px;
1595
- }
1596
-
1597
- /* Modal content styles */
1598
- .cv-widget-section {
1599
- margin-bottom: 16px;
1600
- }
1601
-
1602
- .cv-widget-section:last-child {
1603
- margin-bottom: 0;
1604
- }
1605
-
1606
- .cv-widget-section label {
1607
- display: block;
1608
- margin-bottom: 4px;
1609
- font-weight: 500;
1610
- color: #555;
1611
- }
1612
-
1613
- .cv-widget-profile-select,
1614
- .cv-widget-state-select {
1615
- width: 100%;
1616
- padding: 8px 12px;
1617
- border: 1px solid #ddd;
1618
- border-radius: 4px;
1619
- background: white;
1620
- font-size: 14px;
1621
- }
1622
-
1623
- .cv-widget-profile-select:focus,
1624
- .cv-widget-state-select:focus {
1625
- outline: none;
1626
- border-color: #007bff;
1627
- box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
1628
- }
1629
-
1630
- .cv-widget-profile-select:disabled,
1631
- .cv-widget-state-select:disabled {
1632
- background: #f8f9fa;
1633
- color: #6c757d;
1634
- cursor: not-allowed;
1635
- }
1636
-
1637
- .cv-widget-current {
1638
- margin: 16px 0;
1639
- padding: 12px;
1640
- background: #f8f9fa;
1641
- border-radius: 4px;
1642
- border-left: 4px solid #007bff;
1643
- }
1644
-
1645
- .cv-widget-current label {
1646
- font-size: 12px;
1647
- text-transform: uppercase;
1648
- letter-spacing: 0.5px;
1649
- color: #666;
1650
- margin-bottom: 4px;
1651
- }
1652
-
1653
- .cv-widget-current-view {
1654
- font-weight: 500;
1655
- color: #333;
1656
- }
1657
-
1658
- .cv-widget-reset {
1659
- width: 100%;
1660
- padding: 8px 16px;
1661
- background: #dc3545;
1662
- color: white;
1663
- border: none;
1664
- border-radius: 4px;
1665
- cursor: pointer;
1666
- font-size: 14px;
1667
- font-weight: 500;
1668
- }
1669
-
1670
- .cv-widget-reset:hover {
1671
- background: #c82333;
1672
- }
1673
-
1674
- .cv-widget-reset:active {
1675
- background: #bd2130;
1676
- }
1677
-
1678
- /* Responsive design for mobile */
1679
- @media (max-width: 768px) {
1680
- .cv-widget-top-right,
1681
- .cv-widget-top-left {
1682
- top: 10px;
1683
- }
1684
-
1685
- .cv-widget-bottom-right,
1686
- .cv-widget-bottom-left {
1687
- bottom: 10px;
1688
- }
1689
-
1690
- /* All widgets stay flush with screen edges */
1691
- .cv-widget-top-right,
1692
- .cv-widget-bottom-right,
1693
- .cv-widget-middle-right {
1694
- right: 0;
1695
- }
1696
-
1697
- .cv-widget-top-left,
1698
- .cv-widget-bottom-left,
1699
- .cv-widget-middle-left {
1700
- left: 0;
1701
- }
1702
-
1703
- /* Slightly smaller on mobile */
1704
- .cv-widget-icon {
1705
- width: 60px;
1706
- height: 32px;
1707
- }
1708
-
1709
- .cv-widget-icon:hover {
1710
- width: 75px;
1711
- }
1712
- }
1713
-
1714
- /* Modal styles */
1715
- .cv-widget-modal-overlay {
1716
- position: fixed;
1717
- top: 0;
1718
- left: 0;
1719
- right: 0;
1720
- bottom: 0;
1721
- background: rgba(0, 0, 0, 0.5);
1722
- display: flex;
1723
- align-items: center;
1724
- justify-content: center;
1725
- z-index: 10002;
1726
- animation: fadeIn 0.2s ease;
1727
- }
1728
-
1729
- @keyframes fadeIn {
1730
- from { opacity: 0; }
1731
- to { opacity: 1; }
1732
- }
1733
-
1734
- .cv-widget-modal {
1735
- background: white;
1736
- border-radius: 0.75rem;
1737
- box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
1738
- max-width: 32rem;
1739
- width: 90vw;
1740
- max-height: 80vh;
1741
- animation: slideIn 0.2s ease;
1742
- display: flex;
1743
- flex-direction: column;
1744
- }
1745
-
1746
- @keyframes slideIn {
1747
- from {
1748
- opacity: 0;
1749
- transform: scale(0.9) translateY(-20px);
1750
- }
1751
- to {
1752
- opacity: 1;
1753
- transform: scale(1) translateY(0);
1754
- }
1755
- }
1756
-
1757
- .cv-modal-header {
1758
- display: flex;
1759
- align-items: center;
1760
- justify-content: space-between;
1761
- padding: 0.5rem 1rem;
1762
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
1763
- }
1764
-
1765
- .cv-modal-header-content {
1766
- display: flex;
1767
- align-items: center;
1768
- gap: 0.75rem;
1769
- }
1770
-
1771
- .cv-modal-icon {
1772
- position: relative;
1773
- width: 1rem;
1774
- height: 1rem;
1775
- display: flex;
1776
- align-items: center;
1777
- justify-content: center;
1778
- border-radius: 9999px;
1779
- }
1780
-
1781
- .cv-modal-icon-svg {
1782
- width: 100%;
1783
- height: 100%;
1784
- opacity: 1;
1785
- }
1786
-
1787
- .cv-modal-title {
1788
- font-size: 1.125rem;
1789
- font-weight: bold;
1790
- color: rgba(0, 0, 0, 0.9);
1791
- margin: 0;
1792
- }
1793
-
1794
- .cv-modal-close {
1795
- width: 2rem;
1796
- height: 2rem;
1797
- display: flex;
1798
- align-items: center;
1799
- justify-content: center;
1800
- border-radius: 9999px;
1801
- background: transparent;
1802
- border: none;
1803
- color: rgba(0, 0, 0, 0.6);
1804
- cursor: pointer;
1805
- transition: all 0.2s ease;
1806
- }
1807
-
1808
- .cv-modal-close:hover {
1809
- background: rgba(62, 132, 244, 0.1);
1810
- color: #3e84f4;
1811
- }
1812
-
1813
- .cv-modal-close-icon {
1814
- width: 1.25rem;
1815
- height: 1.25rem;
1816
- }
1817
-
1818
- .cv-modal-main {
1819
- padding: 1rem;
1820
- flex: 1;
1821
- display: flex;
1822
- flex-direction: column;
1823
- gap: 1rem;
1824
- overflow-y: auto;
1825
- max-height: calc(80vh - 8rem);
1826
- }
1827
-
1828
- .cv-modal-description {
1829
- font-size: 0.875rem;
1830
- color: rgba(0, 0, 0, 0.8);
1831
- margin: 0;
1832
- line-height: 1.4;
1833
- }
1834
-
1835
- .cv-content-section,
1836
- .cv-tab-groups-section {
1837
- display: flex;
1838
- flex-direction: column;
1839
- gap: 0.75rem;
1840
- }
1841
-
1842
- .cv-section-heading {
1843
- font-size: 1rem;
1844
- font-weight: bold;
1845
- color: rgba(0, 0, 0, 0.9);
1846
- margin: 0;
1847
- }
1848
-
1849
- .cv-widget-modal-actions {
1850
- margin-top: 20px;
1851
- padding-top: 16px;
1852
- border-top: 1px solid #e9ecef;
1853
- }
1854
-
1855
- .cv-widget-restore {
1856
- width: 100%;
1857
- padding: 10px 16px;
1858
- background: #28a745;
1859
- color: white;
1860
- border: none;
1861
- border-radius: 4px;
1862
- cursor: pointer;
1863
- font-size: 14px;
1864
- font-weight: 500;
1865
- }
1866
-
1867
- .cv-widget-restore:hover {
1868
- background: #218838;
1869
- }
1870
-
1871
- .cv-widget-create-state {
1872
- width: 100%;
1873
- padding: 10px 16px;
1874
- background: #007bff;
1875
- color: white;
1876
- border: none;
1877
- border-radius: 4px;
1878
- cursor: pointer;
1879
- font-size: 14px;
1880
- font-weight: 500;
1881
- margin-bottom: 10px;
1882
- }
1883
-
1884
- .cv-widget-create-state:hover {
1885
- background: #0056b3;
1886
- }
1887
-
1888
- .cv-widget-theme-dark .cv-widget-modal {
1889
- background: #101722;
1890
- color: #e2e8f0;
1891
- }
1892
-
1893
- .cv-widget-theme-dark .cv-modal-header {
1894
- border-color: rgba(255, 255, 255, 0.1);
1895
- }
1896
-
1897
- .cv-widget-theme-dark .cv-modal-title {
1898
- color: #e2e8f0;
1899
- }
1900
-
1901
- .cv-widget-theme-dark .cv-modal-close {
1902
- color: rgba(255, 255, 255, 0.6);
1903
- }
1904
-
1905
- .cv-widget-theme-dark .cv-modal-close:hover {
1906
- background: rgba(62, 132, 244, 0.2);
1907
- color: #3e84f4;
1908
- }
1909
-
1910
- .cv-widget-theme-dark .cv-modal-description {
1911
- color: rgba(255, 255, 255, 0.8);
1912
- }
1913
-
1914
- .cv-widget-theme-dark .cv-section-heading {
1915
- color: #e2e8f0;
1916
- }
1917
-
1918
- .cv-widget-theme-dark .cv-toggles-container
1919
- .cv-widget-theme-dark .cv-tabgroups-container {
1920
- border-color: rgba(255, 255, 255, 0.1);
1921
- }
1922
-
1923
- .cv-widget-theme-dark .cv-toggle-card,
1924
- .cv-widget-theme-dark .cv-tabgroup-card {
1925
- background: #101722;
1926
- border-color: rgba(255, 255, 255, 0.1);
1927
- }
1928
-
1929
- .cv-widget-theme-dark .cv-toggle-title,
1930
- .cv-widget-theme-dark .cv-tabgroup-title {
1931
- color: #e2e8f0;
1932
- }
1933
-
1934
- .cv-widget-theme-dark .cv-toggle-description,
1935
- .cv-widget-theme-dark .cv-tabgroup-description {
1936
- color: rgba(255, 255, 255, 0.6);
1937
- }
1938
-
1939
- .cv-widget-theme-dark .cv-toggle-slider {
1940
- background: rgba(255, 255, 255, 0.2);
1941
- }
1942
-
1943
- .cv-widget-theme-dark .cv-tab-group-description {
1944
- color: rgba(255, 255, 255, 0.8);
1945
- }
1946
-
1947
- .cv-widget-theme-dark .cv-tabgroup-select {
1948
- background: #101722;
1949
- border-color: rgba(255, 255, 255, 0.2);
1950
- color: #e2e8f0;
1951
- }
1952
-
1953
- .cv-widget-theme-dark .cv-modal-footer {
1954
- border-color: rgba(255, 255, 255, 0.1);
1955
- background: #101722;
1956
- }
1957
-
1958
- .cv-widget-theme-dark .cv-reset-btn {
1959
- color: #e2e8f0;
1960
- background: rgba(255, 255, 255, 0.1);
1961
- }
1962
-
1963
- .cv-widget-theme-dark .cv-reset-btn:hover {
1964
- background: rgba(255, 255, 255, 0.2);
1965
- }
1966
-
1967
- /* Custom state creator styles */
1968
- .cv-custom-state-modal {
1969
- max-width: 500px;
1970
- }
1971
-
1972
- .cv-custom-state-form .cv-section-header {
1973
- font-size: 16px;
1974
- font-weight: 600;
1975
- color: #333;
1976
- border-bottom: 1px solid #e9ecef;
1977
- padding-bottom: 5px;
1978
- }
1979
-
1980
- .cv-custom-state-form p {
1981
- font-size: 15px;
1982
- line-height: 1.6;
1983
- color: #555;
1984
- margin-bottom: 24px;
1985
- text-align: justify;
1986
- }
1987
-
1988
- .cv-custom-state-section {
1989
- margin-bottom: 16px;
1990
- }
1991
-
1992
- .cv-custom-state-section label {
1993
- display: block;
1994
- margin-bottom: 4px;
1995
- font-weight: 500;
1996
- color: #555;
1997
- }
1998
-
1999
- .cv-custom-state-input {
2000
- width: 100%;
2001
- padding: 8px 12px;
2002
- border: 1px solid #ddd;
2003
- border-radius: 4px;
2004
- background: white;
2005
- font-size: 14px;
2006
- }
2007
-
2008
- .cv-custom-state-input:focus {
2009
- outline: none;
2010
- border-color: #007bff;
2011
- box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
2012
- }
2013
-
2014
- /* Toggles Container */
2015
- .cv-toggles-container {
2016
- display: flex;
2017
- flex-direction: column;
2018
- gap: 0.5rem;
2019
- border-radius: 0.5rem;
2020
- border: 1px solid rgba(0, 0, 0, 0.1);
2021
- overflow: hidden;
2022
- }
2023
-
2024
- .cv-toggle-card,
2025
- .cv-tabgroup-card {
2026
- background: white;
2027
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
2028
- }
2029
-
2030
- .cv-toggle-card:last-child {
2031
- border-bottom: none;
2032
- }
2033
-
2034
- .cv-toggle-content {
2035
- display: flex;
2036
- align-items: center;
2037
- justify-content: space-between;
2038
- padding: 0.75rem;
2039
- }
2040
-
2041
- .cv-toggle-title {
2042
- font-weight: 500;
2043
- font-size: 0.875rem;
2044
- color: rgba(0, 0, 0, 0.9);
2045
- margin: 0 0 0.125rem 0;
2046
- }
2047
-
2048
- .cv-toggle-description {
2049
- font-size: 0.75rem;
2050
- color: rgba(0, 0, 0, 0.6);
2051
- margin: 0;
2052
- }
2053
-
2054
- .cv-toggle-label{
2055
- position: relative;
2056
- display: inline-block;
2057
- width: 2.75rem;
2058
- height: 1.5rem;
2059
- cursor: pointer;
2060
- }
2061
-
2062
- .cv-toggle-input {
2063
- opacity: 0;
2064
- width: 0;
2065
- height: 0;
2066
- }
2067
-
2068
- .cv-toggle-slider {
2069
- position: absolute;
2070
- top: 0;
2071
- left: 0;
2072
- right: 0;
2073
- bottom: 0;
2074
- background: rgba(0, 0, 0, 0.2);
2075
- border-radius: 9999px;
2076
- transition: background-color 0.2s ease;
2077
- }
2078
-
2079
- .cv-toggle-slider:before {
2080
- position: absolute;
2081
- content: "";
2082
- height: 1rem;
2083
- width: 1rem;
2084
- left: 0.25rem;
2085
- bottom: 0.25rem;
2086
- background: white;
2087
- border-radius: 50%;
2088
- transition: transform 0.2s ease;
2089
- }
2090
-
2091
- .cv-toggle-input:checked + .cv-toggle-slider {
2092
- background: #3e84f4;
2093
- }
2094
-
2095
- .cv-toggle-input:checked + .cv-toggle-slider:before {
2096
- transform: translateX(1.25rem);
2097
- }
2098
-
2099
- /* Dark theme toggle switch styles */
2100
- .cv-widget-theme-dark .cv-toggle-switch {
2101
- background: #4a5568;
2102
- }
2103
-
2104
- .cv-widget-theme-dark .cv-toggle-switch:hover {
2105
- background: #5a6578;
2106
- }
2107
-
2108
- .cv-widget-theme-dark .cv-toggle-switch.cv-toggle-active {
2109
- background: #63b3ed;
2110
- }
2111
-
2112
- .cv-widget-theme-dark .cv-toggle-switch.cv-toggle-active:hover {
2113
- background: #4299e1;
2114
- }
2115
-
2116
- /* Tab Groups Container */
2117
- .cv-tab-groups-list {
2118
- display: flex;
2119
- flex-direction: column;
2120
- gap: 1px;
2121
- border: 1px solid rgba(0, 0, 0, 0.1);
2122
- border-radius: 0.5rem;
2123
- overflow: hidden;
2124
- }
2125
-
2126
- /* Tab Group Card - Header (Navigation Headers toggle) */
2127
- .cv-tabgroup-card.cv-tabgroup-header {
2128
- display: flex;
2129
- align-items: center;
2130
- justify-content: space-between;
2131
- padding: 0.75rem;
2132
- border-bottom: 0px;
2133
- }
2134
-
2135
- .cv-tabgroup-card.cv-tabgroup-header .cv-tabgroup-row {
2136
- display: flex;
2137
- align-items: center;
2138
- justify-content: space-between;
2139
- width: 100%;
2140
- gap: 1rem;
2141
- }
2142
-
2143
- /* Navigation toggle icon container */
2144
- .cv-nav-toggle-container {
2145
- display: flex;
2146
- align-items: center;
2147
- gap: 0.5rem;
2148
- }
2149
-
2150
- .cv-nav-icon {
2151
- width: 2rem;
2152
- height: 2rem;
2153
- color: rgba(0, 0, 0, 0.8);
2154
- display: flex;
2155
- align-items: center;
2156
- justify-content: center;
2157
- flex-shrink: 0;
2158
- transition: color 0.2s ease;
2159
- }
2160
-
2161
- /* Logo box - centered grey box on its own row */
2162
- .cv-tabgroup-logo-box {
2163
- width: 3.5rem;
2164
- height: 3.5rem;
2165
- background: rgba(0, 0, 0, 0.08);
2166
- border-radius: 0.5rem;
2167
- display: flex;
2168
- align-items: center;
2169
- justify-content: center;
2170
- flex-shrink: 0;
2171
- margin-bottom: 0.5rem;
2172
- }
2173
-
2174
- /* Title container for title alignment (without icon) */
2175
- .cv-tabgroup-title-container {
2176
- display: flex;
2177
- align-items: center;
2178
- gap: 0.5rem;
2179
- }
2180
-
2181
- /* Hover state for icon - apply to the entire tabgroup-row */
2182
- .cv-tabgroup-card.cv-tabgroup-header:hover .cv-nav-icon {
2183
- color: #3e84f4;
2184
- }
2185
-
2186
- .cv-widget-theme-dark .cv-nav-icon {
2187
- color: rgba(255, 255, 255, 0.8);
2188
- }
2189
-
2190
- .cv-widget-theme-dark .cv-tabgroup-card.cv-tabgroup-header:hover .cv-nav-icon {
2191
- color: #60a5fa;
2192
- }
2193
-
2194
- /* Tab Group Card - Items */
2195
- .cv-tabgroup-card.cv-tabgroup-item {
2196
- display: flex;
2197
- flex-direction: column;
2198
- gap: 0.5rem;
2199
- padding: 0.75rem;
2200
- background: white;
2201
- border-bottom: 1px solid rgba(0, 0, 0, 0.05);
2202
- }
2203
-
2204
- .cv-tabgroup-card.cv-tabgroup-item:last-child {
2205
- border-bottom: none;
2206
- }
2207
-
2208
- /* Tab Group Info */
2209
- .cv-tabgroup-info {
2210
- flex: 1;
2211
- display: flex;
2212
- flex-direction: column;
2213
- gap: 0.25rem;
2214
- }
2215
-
2216
- .cv-tabgroup-title {
2217
- font-weight: 500;
2218
- font-size: 0.875rem;
2219
- color: rgba(0, 0, 0, 0.9);
2220
- margin: 0 0 0 0;
2221
- }
2222
-
2223
- .cv-tabgroup-description {
2224
- font-size: 0.75rem;
2225
- color: rgba(0, 0, 0, 0.6);
2226
- margin: 0;
2227
- line-height: 1.3;
2228
- }
2229
-
2230
- /* Tab Group Label (for select dropdowns) */
2231
- .cv-tabgroup-label {
2232
- font-size: 0.875rem;
2233
- color: rgba(0, 0, 0, 0.8);
2234
- margin: 0;
2235
- line-height: 1.4;
2236
- font-weight: 500;
2237
- display: block;
2238
- cursor: pointer;
2239
- }
2240
-
2241
- /* Tab Group Select */
2242
- .cv-tabgroup-select {
2243
- width: 100%;
2244
- border-radius: 0.5rem;
2245
- background: white;
2246
- border: 1px solid rgba(0, 0, 0, 0.15);
2247
- color: rgba(0, 0, 0, 0.9);
2248
- padding: 0.5rem 0.75rem;
2249
- font-size: 0.875rem;
2250
- cursor: pointer;
2251
- transition: all 0.15s ease;
2252
- font-family: inherit;
2253
- }
2254
-
2255
- .cv-tabgroup-select:hover {
2256
- border-color: rgba(0, 0, 0, 0.25);
2257
- }
2258
-
2259
- .cv-tabgroup-select:focus {
2260
- outline: none;
2261
- border-color: #3e84f4;
2262
- box-shadow: 0 0 0 2px rgba(62, 132, 244, 0.2);
2263
- }
2264
-
2265
- /* Modern Toggle Switch */
2266
- .cv-toggle-switch {
2267
- position: relative;
2268
- display: inline-flex;
2269
- align-items: center;
2270
- width: 44px;
2271
- height: 24px;
2272
- background: rgba(0, 0, 0, 0.1);
2273
- border-radius: 9999px;
2274
- padding: 2px;
2275
- box-sizing: border-box;
2276
- cursor: pointer;
2277
- transition: background-color 0.2s ease;
2278
- border: none;
2279
- }
2280
-
2281
- .cv-toggle-switch input {
2282
- display: none;
2283
- }
2284
-
2285
- .cv-toggle-switch .cv-switch-bg {
2286
- position: absolute;
2287
- inset: 0;
2288
- border-radius: 9999px;
2289
- background: rgba(0, 0, 0, 0.1);
2290
- transition: background-color 0.2s ease;
2291
- pointer-events: none;
2292
- }
2293
-
2294
- .cv-toggle-switch .cv-switch-knob {
2295
- position: relative;
2296
- width: 20px;
2297
- height: 20px;
2298
- background: white;
2299
- border-radius: 50%;
2300
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
2301
- transition: transform 0.2s ease;
2302
- z-index: 1;
2303
- }
2304
-
2305
- .cv-toggle-switch input:checked + .cv-switch-bg {
2306
- background: #3e84f4;
2307
- }
2308
-
2309
- .cv-toggle-switch input:checked ~ .cv-switch-knob {
2310
- transform: translateX(20px);
2311
- }
2312
-
2313
- /* Dark Theme - Tab Groups */
2314
- .cv-widget-theme-dark .cv-tabgroup-card.cv-tabgroup-header {
2315
- background: #101722;
2316
- border-bottom-color: rgba(255, 255, 255, 0.1);
2317
- }
2318
-
2319
- .cv-widget-theme-dark .cv-tabgroup-card.cv-tabgroup-item {
2320
- background: #101722;
2321
- border-bottom-color: rgba(255, 255, 255, 0.05);
2322
- }
2323
-
2324
- .cv-widget-theme-dark .cv-tabgroup-title {
2325
- color: #e2e8f0;
2326
- }
2327
-
2328
- .cv-widget-theme-dark .cv-tabgroup-description {
2329
- color: rgba(255, 255, 255, 0.6);
2330
- }
2331
-
2332
- .cv-widget-theme-dark .cv-tabgroup-label {
2333
- color: rgba(255, 255, 255, 0.8);
2334
- }
2335
-
2336
- .cv-widget-theme-dark .cv-tab-groups-list {
2337
- border-color: rgba(255, 255, 255, 0.1);
2338
- }
2339
-
2340
- .cv-widget-theme-dark .cv-tabgroup-select {
2341
- background: #101722;
2342
- border-color: rgba(255, 255, 255, 0.15);
2343
- color: #e2e8f0;
2344
- }
2345
-
2346
- .cv-widget-theme-dark .cv-tabgroup-select:hover {
2347
- border-color: rgba(255, 255, 255, 0.25);
2348
- }
2349
-
2350
- .cv-widget-theme-dark .cv-tabgroup-select:focus {
2351
- border-color: #60a5fa;
2352
- box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
2353
- }
2354
-
2355
- /* Dark Theme - Toggle Switch */
2356
- .cv-widget-theme-dark .cv-toggle-switch .cv-switch-bg {
2357
- background: rgba(255, 255, 255, 0.1);
2358
- }
2359
-
2360
- .cv-widget-theme-dark .cv-toggle-switch .cv-switch-knob {
2361
- background: #e2e8f0;
2362
- }
2363
-
2364
- .cv-widget-theme-dark .cv-toggle-switch input:checked + .cv-switch-bg {
2365
- background: #63b3ed;
2366
- }
2367
-
2368
- .cv-modal-footer {
2369
- display: flex;
2370
- justify-content: space-between;
2371
- align-items: center;
2372
- padding: 0.75rem;
2373
- border-top: 1px solid rgba(0, 0, 0, 0.1);
2374
- }
2375
-
2376
- .cv-reset-btn,
2377
- .cv-share-btn {
2378
- display: flex;
2379
- align-items: center;
2380
- gap: 0.5rem;
2381
- padding: 0.375rem 0.75rem;
2382
- border-radius: 0.5rem;
2383
- font-weight: 600;
2384
- font-size: 0.875rem;
2385
- cursor: pointer;
2386
- transition: all 0.2s ease;
2387
- border: none;
2388
- }
2389
-
2390
- .cv-reset-btn {
2391
- color: rgba(0, 0, 0, 0.9);
2392
- background: rgba(0, 0, 0, 0.1);
2393
- }
2394
-
2395
- .cv-reset-btn:hover {
2396
- background: rgba(0, 0, 0, 0.2);
2397
- }
2398
-
2399
- .cv-share-btn {
2400
- color: white;
2401
- background: #3e84f4;
2402
- }
2403
-
2404
- .cv-share-btn:hover {
2405
- background: rgba(62, 132, 244, 0.9);
2406
- }
2407
-
2408
- .cv-btn-icon {
2409
- width: 1rem;
2410
- height: 1rem;
2411
- display: flex;
2412
- align-items: center;
2413
- justify-content: center;
2414
- transition: transform 0.2s ease;
2415
- }
2416
-
2417
- /* Dark theme custom state styles */
2418
- /* Welcome modal styles */
2419
- .cv-welcome-modal {
2420
- max-width: 32rem;
2421
- width: 90vw;
2422
- background: white;
2423
- border-radius: 0.75rem;
2424
- box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
2425
- animation: slideIn 0.2s ease;
2426
- display: flex;
2427
- flex-direction: column;
2428
- }
2429
-
2430
- .cv-modal-main {
2431
- padding: 1rem;
2432
- flex: 1;
2433
- display: flex;
2434
- flex-direction: column;
2435
- gap: 1rem;
2436
- overflow-y: auto;
2437
- max-height: calc(80vh - 8rem);
2438
- }
2439
-
2440
- .cv-welcome-message {
2441
- font-size: 0.875rem;
2442
- color: rgba(0, 0, 0, 0.8);
2443
- margin: 0;
2444
- line-height: 1.4;
2445
- text-align: center;
2446
- }
2447
-
2448
- .cv-welcome-message a {
2449
- color: #3e84f4;
2450
- text-align: justify;
2451
- text-decoration: none;
2452
- }
2453
-
2454
- .cv-welcome-message a:hover {
2455
- text-decoration: underline;
2456
- }
2457
-
2458
- .cv-welcome-widget-preview {
2459
- display: flex;
2460
- align-items: center;
2461
- justify-content: center;
2462
- gap: 1rem;
2463
- padding: 1rem;
2464
- background: #f8f9fa;
2465
- border-radius: 0.5rem;
2466
- margin: 1rem 0;
2467
- }
2468
-
2469
- .cv-welcome-widget-icon {
2470
- width: 2rem;
2471
- height: 2rem;
2472
- background: rgba(62, 132, 244, 0.1);
2473
- border-radius: 9999px;
2474
- display: flex;
2475
- align-items: center;
2476
- justify-content: center;
2477
- animation: cv-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
2478
- color: #3e84f4;
2479
- }
2480
-
2481
- .cv-welcome-widget-label {
2482
- font-size: 0.875rem;
2483
- font-weight: 500;
2484
- color: rgba(0, 0, 0, 0.8);
2485
- margin: 0;
2486
- }
2487
-
2488
- .cv-welcome-got-it {
2489
- width: 100%;
2490
- background: #3e84f4;
2491
- color: white;
2492
- font-weight: 600;
2493
- padding: 0.75rem 1rem;
2494
- border-radius: 0.5rem;
2495
- border: none;
2496
- cursor: pointer;
2497
- font-size: 0.875rem;
2498
- transition: background-color 0.2s ease;
2499
- outline: none;
2500
- }
2501
-
2502
- .cv-welcome-got-it:hover {
2503
- background: rgba(62, 132, 244, 0.9);
2504
- }
2505
-
2506
- .cv-welcome-got-it:focus {
2507
- box-shadow: 0 0 0 2px rgba(62, 132, 244, 0.5);
2508
- }
2509
-
2510
- /* Animations */
2511
- @keyframes cv-pulse {
2512
- 0%, 100% {
2513
- opacity: 1;
2514
- }
2515
- 50% {
2516
- opacity: 0.5;
2517
- }
2518
- }
2519
-
2520
- /* Dark theme welcome modal styles */
2521
- .cv-widget-theme-dark .cv-welcome-modal {
2522
- background: #101722;
2523
- }
2524
-
2525
- .cv-widget-theme-dark .cv-welcome-message {
2526
- color: rgba(255, 255, 255, 0.8);
2527
- }
2528
-
2529
- .cv-widget-theme-dark .cv-welcome-message a {
2530
- color: #60a5fa;
2531
- }
2532
-
2533
- .cv-widget-theme-dark .cv-welcome-widget-preview {
2534
- background: rgba(255, 255, 255, 0.1);
2535
- }
2536
-
2537
- .cv-widget-theme-dark .cv-welcome-widget-label {
2538
- color: #e2e8f0;
2539
- }
2540
-
2541
- /* Dark theme logo box */
2542
- .cv-widget-theme-dark .cv-tabgroup-logo-box {
2543
- background: rgba(255, 255, 255, 0.1);
2544
- }
2545
-
2546
- /* Spinning animation for reset button icon */
2547
- @keyframes cv-spin {
2548
- from {
2549
- transform: rotate(0deg);
2550
- }
2551
- to {
2552
- transform: rotate(-360deg);
2553
- }
2554
- }
2555
-
2556
- .cv-spinning {
2557
- animation: cv-spin 0.6s ease-in-out;
2558
- }
2559
-
2560
- /* Hide widget icon in print view */
2561
- @media print {
2562
- .cv-widget-icon {
2563
- display: none !important;
2564
- }
2565
- }
1970
+ const WIDGET_STYLES = `
1971
+ /* Rounded rectangle widget icon styles */
1972
+ .cv-widget-icon {
1973
+ position: fixed;
1974
+ /* Slightly transparent by default so the widget is subtle at the page edge */
1975
+ background: rgba(255, 255, 255, 0.92);
1976
+ color: rgba(0, 0, 0, 0.9);
1977
+ opacity: 0.6;
1978
+ display: flex;
1979
+ align-items: center;
1980
+ justify-content: center;
1981
+ font-size: 18px;
1982
+ font-weight: bold;
1983
+ cursor: pointer;
1984
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
1985
+ z-index: 9998;
1986
+ transition: all 0.3s ease;
1987
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
1988
+ }
1989
+
1990
+ .cv-widget-icon:hover {
1991
+ /* Become fully opaque on hover to improve readability */
1992
+ background: rgba(255, 255, 255, 1);
1993
+ color: rgba(0, 0, 0, 1);
1994
+ opacity: 1;
1995
+ }
1996
+
1997
+ /* Top-right: rounded end on left, sticks out leftward on hover */
1998
+ .cv-widget-top-right {
1999
+ top: 20px;
2000
+ right: 0;
2001
+ border-radius: 18px 0 0 18px;
2002
+ padding-left: 8px;
2003
+ justify-content: flex-start;
2004
+ }
2005
+
2006
+ /* Top-left: rounded end on right, sticks out rightward on hover */
2007
+ .cv-widget-top-left {
2008
+ top: 20px;
2009
+ left: 0;
2010
+ border-radius: 0 18px 18px 0;
2011
+ padding-right: 8px;
2012
+ justify-content: flex-end;
2013
+ }
2014
+
2015
+ /* Bottom-right: rounded end on left, sticks out leftward on hover */
2016
+ .cv-widget-bottom-right {
2017
+ bottom: 20px;
2018
+ right: 0;
2019
+ border-radius: 18px 0 0 18px;
2020
+ padding-left: 8px;
2021
+ justify-content: flex-start;
2022
+ }
2023
+
2024
+ /* Bottom-left: rounded end on right, sticks out rightward on hover */
2025
+ .cv-widget-bottom-left {
2026
+ bottom: 20px;
2027
+ left: 0;
2028
+ border-radius: 0 18px 18px 0;
2029
+ padding-right: 8px;
2030
+ justify-content: flex-end;
2031
+ }
2032
+
2033
+ /* Middle-left: rounded end on right, sticks out rightward on hover */
2034
+ .cv-widget-middle-left {
2035
+ top: 50%;
2036
+ left: 0;
2037
+ transform: translateY(-50%);
2038
+ border-radius: 0 18px 18px 0;
2039
+ padding-right: 8px;
2040
+ justify-content: flex-end;
2041
+ }
2042
+
2043
+ /* Middle-right: rounded end on left, sticks out leftward on hover */
2044
+ .cv-widget-middle-right {
2045
+ top: 50%;
2046
+ right: 0;
2047
+ transform: translateY(-50%);
2048
+ border-radius: 18px 0 0 18px;
2049
+ padding-left: 8px;
2050
+ justify-content: flex-start;
2051
+ }
2052
+
2053
+ .cv-widget-top-right,
2054
+ .cv-widget-middle-right,
2055
+ .cv-widget-bottom-right,
2056
+ .cv-widget-top-left,
2057
+ .cv-widget-middle-left,
2058
+ .cv-widget-bottom-left {
2059
+ height: 36px;
2060
+ width: 36px;
2061
+ }
2062
+
2063
+ .cv-widget-middle-right:hover,
2064
+ .cv-widget-top-right:hover,
2065
+ .cv-widget-bottom-right:hover,
2066
+ .cv-widget-top-left:hover,
2067
+ .cv-widget-middle-left:hover,
2068
+ .cv-widget-bottom-left:hover {
2069
+ width: 55px;
2070
+ }
2071
+
2072
+ /* Modal content styles */
2073
+ .cv-widget-section {
2074
+ margin-bottom: 16px;
2075
+ }
2076
+
2077
+ .cv-widget-section:last-child {
2078
+ margin-bottom: 0;
2079
+ }
2080
+
2081
+ .cv-widget-section label {
2082
+ display: block;
2083
+ margin-bottom: 4px;
2084
+ font-weight: 500;
2085
+ color: #555;
2086
+ }
2087
+
2088
+ .cv-widget-profile-select,
2089
+ .cv-widget-state-select {
2090
+ width: 100%;
2091
+ padding: 8px 12px;
2092
+ border: 1px solid #ddd;
2093
+ border-radius: 4px;
2094
+ background: white;
2095
+ font-size: 14px;
2096
+ }
2097
+
2098
+ .cv-widget-profile-select:focus,
2099
+ .cv-widget-state-select:focus {
2100
+ outline: none;
2101
+ border-color: #007bff;
2102
+ box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
2103
+ }
2104
+
2105
+ .cv-widget-profile-select:disabled,
2106
+ .cv-widget-state-select:disabled {
2107
+ background: #f8f9fa;
2108
+ color: #6c757d;
2109
+ cursor: not-allowed;
2110
+ }
2111
+
2112
+ .cv-widget-current {
2113
+ margin: 16px 0;
2114
+ padding: 12px;
2115
+ background: #f8f9fa;
2116
+ border-radius: 4px;
2117
+ border-left: 4px solid #007bff;
2118
+ }
2119
+
2120
+ .cv-widget-current label {
2121
+ font-size: 12px;
2122
+ text-transform: uppercase;
2123
+ letter-spacing: 0.5px;
2124
+ color: #666;
2125
+ margin-bottom: 4px;
2126
+ }
2127
+
2128
+ .cv-widget-current-view {
2129
+ font-weight: 500;
2130
+ color: #333;
2131
+ }
2132
+
2133
+ .cv-widget-reset {
2134
+ width: 100%;
2135
+ padding: 8px 16px;
2136
+ background: #dc3545;
2137
+ color: white;
2138
+ border: none;
2139
+ border-radius: 4px;
2140
+ cursor: pointer;
2141
+ font-size: 14px;
2142
+ font-weight: 500;
2143
+ }
2144
+
2145
+ .cv-widget-reset:hover {
2146
+ background: #c82333;
2147
+ }
2148
+
2149
+ .cv-widget-reset:active {
2150
+ background: #bd2130;
2151
+ }
2152
+
2153
+ /* Responsive design for mobile */
2154
+ @media (max-width: 768px) {
2155
+ .cv-widget-top-right,
2156
+ .cv-widget-top-left {
2157
+ top: 10px;
2158
+ }
2159
+
2160
+ .cv-widget-bottom-right,
2161
+ .cv-widget-bottom-left {
2162
+ bottom: 10px;
2163
+ }
2164
+
2165
+ /* All widgets stay flush with screen edges */
2166
+ .cv-widget-top-right,
2167
+ .cv-widget-bottom-right,
2168
+ .cv-widget-middle-right {
2169
+ right: 0;
2170
+ }
2171
+
2172
+ .cv-widget-top-left,
2173
+ .cv-widget-bottom-left,
2174
+ .cv-widget-middle-left {
2175
+ left: 0;
2176
+ }
2177
+
2178
+ /* Slightly smaller on mobile */
2179
+ .cv-widget-icon {
2180
+ width: 60px;
2181
+ height: 32px;
2182
+ }
2183
+
2184
+ .cv-widget-icon:hover {
2185
+ width: 75px;
2186
+ }
2187
+ }
2188
+
2189
+ /* Modal styles */
2190
+ .cv-widget-modal-overlay {
2191
+ position: fixed;
2192
+ top: 0;
2193
+ left: 0;
2194
+ right: 0;
2195
+ bottom: 0;
2196
+ background: rgba(0, 0, 0, 0.5);
2197
+ display: flex;
2198
+ align-items: center;
2199
+ justify-content: center;
2200
+ z-index: 10002;
2201
+ animation: fadeIn 0.2s ease;
2202
+ }
2203
+
2204
+ .cv-widget-modal-overlay.cv-hidden {
2205
+ display: none;
2206
+ }
2207
+
2208
+ @keyframes fadeIn {
2209
+ from { opacity: 0; }
2210
+ to { opacity: 1; }
2211
+ }
2212
+
2213
+ .cv-widget-modal {
2214
+ background: white;
2215
+ border-radius: 0.75rem;
2216
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
2217
+ max-width: 32rem;
2218
+ width: 90vw;
2219
+ max-height: 80vh;
2220
+ animation: slideIn 0.2s ease;
2221
+ display: flex;
2222
+ flex-direction: column;
2223
+ }
2224
+
2225
+ @keyframes slideIn {
2226
+ from {
2227
+ opacity: 0;
2228
+ transform: scale(0.9) translateY(-20px);
2229
+ }
2230
+ to {
2231
+ opacity: 1;
2232
+ transform: scale(1) translateY(0);
2233
+ }
2234
+ }
2235
+
2236
+ .cv-modal-header {
2237
+ display: flex;
2238
+ align-items: center;
2239
+ justify-content: space-between;
2240
+ padding: 0.5rem 1rem;
2241
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
2242
+ }
2243
+
2244
+ .cv-modal-header-content {
2245
+ display: flex;
2246
+ align-items: center;
2247
+ gap: 0.75rem;
2248
+ }
2249
+
2250
+ .cv-modal-icon {
2251
+ position: relative;
2252
+ width: 1rem;
2253
+ height: 1rem;
2254
+ display: flex;
2255
+ align-items: center;
2256
+ justify-content: center;
2257
+ border-radius: 9999px;
2258
+ }
2259
+
2260
+ .cv-modal-icon-svg {
2261
+ width: 100%;
2262
+ height: 100%;
2263
+ opacity: 1;
2264
+ }
2265
+
2266
+ .cv-modal-title {
2267
+ font-size: 1.125rem;
2268
+ font-weight: bold;
2269
+ color: rgba(0, 0, 0, 0.9);
2270
+ margin: 0;
2271
+ }
2272
+
2273
+ .cv-modal-close {
2274
+ width: 2rem;
2275
+ height: 2rem;
2276
+ display: flex;
2277
+ align-items: center;
2278
+ justify-content: center;
2279
+ border-radius: 9999px;
2280
+ background: transparent;
2281
+ border: none;
2282
+ color: rgba(0, 0, 0, 0.6);
2283
+ cursor: pointer;
2284
+ transition: all 0.2s ease;
2285
+ }
2286
+
2287
+ .cv-modal-close:hover {
2288
+ background: rgba(62, 132, 244, 0.1);
2289
+ color: #3e84f4;
2290
+ }
2291
+
2292
+ .cv-modal-close-icon {
2293
+ width: 1.25rem;
2294
+ height: 1.25rem;
2295
+ }
2296
+
2297
+ .cv-modal-main {
2298
+ padding: 1rem;
2299
+ flex: 1;
2300
+ display: flex;
2301
+ flex-direction: column;
2302
+ gap: 1rem;
2303
+ overflow-y: auto;
2304
+ max-height: calc(80vh - 8rem);
2305
+ }
2306
+
2307
+ .cv-modal-description {
2308
+ font-size: 0.875rem;
2309
+ color: rgba(0, 0, 0, 0.8);
2310
+ margin: 0;
2311
+ line-height: 1.4;
2312
+ }
2313
+
2314
+ .cv-content-section,
2315
+ .cv-tab-groups-section {
2316
+ display: flex;
2317
+ flex-direction: column;
2318
+ gap: 0.75rem;
2319
+ }
2320
+
2321
+ .cv-section-heading {
2322
+ font-size: 1rem;
2323
+ font-weight: bold;
2324
+ color: rgba(0, 0, 0, 0.9);
2325
+ margin: 0;
2326
+ }
2327
+
2328
+ .cv-widget-modal-actions {
2329
+ margin-top: 20px;
2330
+ padding-top: 16px;
2331
+ border-top: 1px solid #e9ecef;
2332
+ }
2333
+
2334
+ .cv-widget-restore {
2335
+ width: 100%;
2336
+ padding: 10px 16px;
2337
+ background: #28a745;
2338
+ color: white;
2339
+ border: none;
2340
+ border-radius: 4px;
2341
+ cursor: pointer;
2342
+ font-size: 14px;
2343
+ font-weight: 500;
2344
+ }
2345
+
2346
+ .cv-widget-restore:hover {
2347
+ background: #218838;
2348
+ }
2349
+
2350
+ .cv-widget-create-state {
2351
+ width: 100%;
2352
+ padding: 10px 16px;
2353
+ background: #007bff;
2354
+ color: white;
2355
+ border: none;
2356
+ border-radius: 4px;
2357
+ cursor: pointer;
2358
+ font-size: 14px;
2359
+ font-weight: 500;
2360
+ margin-bottom: 10px;
2361
+ }
2362
+
2363
+ .cv-widget-create-state:hover {
2364
+ background: #0056b3;
2365
+ }
2366
+
2367
+ .cv-widget-theme-dark .cv-widget-modal {
2368
+ background: #101722;
2369
+ color: #e2e8f0;
2370
+ }
2371
+
2372
+ .cv-widget-theme-dark .cv-modal-header {
2373
+ border-color: rgba(255, 255, 255, 0.1);
2374
+ }
2375
+
2376
+ .cv-widget-theme-dark .cv-modal-title {
2377
+ color: #e2e8f0;
2378
+ }
2379
+
2380
+ .cv-widget-theme-dark .cv-modal-close {
2381
+ color: rgba(255, 255, 255, 0.6);
2382
+ }
2383
+
2384
+ .cv-widget-theme-dark .cv-modal-close:hover {
2385
+ background: rgba(62, 132, 244, 0.2);
2386
+ color: #3e84f4;
2387
+ }
2388
+
2389
+ .cv-widget-theme-dark .cv-modal-description {
2390
+ color: rgba(255, 255, 255, 0.8);
2391
+ }
2392
+
2393
+ .cv-widget-theme-dark .cv-section-heading {
2394
+ color: #e2e8f0;
2395
+ }
2396
+
2397
+ .cv-widget-theme-dark .cv-toggles-container
2398
+ .cv-widget-theme-dark .cv-tabgroups-container {
2399
+ border-color: rgba(255, 255, 255, 0.1);
2400
+ }
2401
+
2402
+ .cv-widget-theme-dark .cv-toggle-card,
2403
+ .cv-widget-theme-dark .cv-tabgroup-card {
2404
+ background: #101722;
2405
+ border-color: rgba(255, 255, 255, 0.1);
2406
+ }
2407
+
2408
+ .cv-widget-theme-dark .cv-toggle-title,
2409
+ .cv-widget-theme-dark .cv-tabgroup-title {
2410
+ color: #e2e8f0;
2411
+ }
2412
+
2413
+ .cv-widget-theme-dark .cv-toggle-description,
2414
+ .cv-widget-theme-dark .cv-tabgroup-description {
2415
+ color: rgba(255, 255, 255, 0.6);
2416
+ }
2417
+
2418
+ .cv-widget-theme-dark .cv-toggle-slider {
2419
+ background: rgba(255, 255, 255, 0.2);
2420
+ }
2421
+
2422
+ .cv-widget-theme-dark .cv-tab-group-description {
2423
+ color: rgba(255, 255, 255, 0.8);
2424
+ }
2425
+
2426
+ .cv-widget-theme-dark .cv-tabgroup-select {
2427
+ background: #101722;
2428
+ border-color: rgba(255, 255, 255, 0.2);
2429
+ color: #e2e8f0;
2430
+ }
2431
+
2432
+ .cv-widget-theme-dark .cv-modal-footer {
2433
+ border-color: rgba(255, 255, 255, 0.1);
2434
+ background: #101722;
2435
+ }
2436
+
2437
+ .cv-widget-theme-dark .cv-reset-btn {
2438
+ color: #e2e8f0;
2439
+ background: rgba(255, 255, 255, 0.1);
2440
+ }
2441
+
2442
+ .cv-widget-theme-dark .cv-reset-btn:hover {
2443
+ background: rgba(255, 255, 255, 0.2);
2444
+ }
2445
+
2446
+ /* Custom state creator styles */
2447
+ .cv-custom-state-modal {
2448
+ max-width: 500px;
2449
+ }
2450
+
2451
+ .cv-custom-state-form .cv-section-header {
2452
+ font-size: 16px;
2453
+ font-weight: 600;
2454
+ color: #333;
2455
+ border-bottom: 1px solid #e9ecef;
2456
+ padding-bottom: 5px;
2457
+ }
2458
+
2459
+ .cv-custom-state-form p {
2460
+ font-size: 15px;
2461
+ line-height: 1.6;
2462
+ color: #555;
2463
+ margin-bottom: 24px;
2464
+ text-align: justify;
2465
+ }
2466
+
2467
+ .cv-custom-state-section {
2468
+ margin-bottom: 16px;
2469
+ }
2470
+
2471
+ .cv-custom-state-section label {
2472
+ display: block;
2473
+ margin-bottom: 4px;
2474
+ font-weight: 500;
2475
+ color: #555;
2476
+ }
2477
+
2478
+ .cv-custom-state-input {
2479
+ width: 100%;
2480
+ padding: 8px 12px;
2481
+ border: 1px solid #ddd;
2482
+ border-radius: 4px;
2483
+ background: white;
2484
+ font-size: 14px;
2485
+ }
2486
+
2487
+ .cv-custom-state-input:focus {
2488
+ outline: none;
2489
+ border-color: #007bff;
2490
+ box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
2491
+ }
2492
+
2493
+ /* Toggles Container */
2494
+ .cv-toggles-container {
2495
+ display: flex;
2496
+ flex-direction: column;
2497
+ gap: 0.5rem;
2498
+ border-radius: 0.5rem;
2499
+ border: 1px solid rgba(0, 0, 0, 0.1);
2500
+ overflow: hidden;
2501
+ }
2502
+
2503
+ .cv-toggle-card,
2504
+ .cv-tabgroup-card {
2505
+ background: white;
2506
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
2507
+ }
2508
+
2509
+ .cv-toggle-card:last-child {
2510
+ border-bottom: none;
2511
+ }
2512
+
2513
+ .cv-toggle-content {
2514
+ display: flex;
2515
+ align-items: center;
2516
+ justify-content: space-between;
2517
+ padding: 0.75rem;
2518
+ }
2519
+
2520
+ .cv-toggle-title {
2521
+ font-weight: 500;
2522
+ font-size: 0.875rem;
2523
+ color: rgba(0, 0, 0, 0.9);
2524
+ margin: 0 0 0.125rem 0;
2525
+ }
2526
+
2527
+ .cv-toggle-description {
2528
+ font-size: 0.75rem;
2529
+ color: rgba(0, 0, 0, 0.6);
2530
+ margin: 0;
2531
+ }
2532
+
2533
+ .cv-toggle-label{
2534
+ position: relative;
2535
+ display: inline-block;
2536
+ width: 2.75rem;
2537
+ height: 1.5rem;
2538
+ cursor: pointer;
2539
+ }
2540
+
2541
+ .cv-toggle-input {
2542
+ opacity: 0;
2543
+ width: 0;
2544
+ height: 0;
2545
+ }
2546
+
2547
+ .cv-toggle-slider {
2548
+ position: absolute;
2549
+ top: 0;
2550
+ left: 0;
2551
+ right: 0;
2552
+ bottom: 0;
2553
+ background: rgba(0, 0, 0, 0.2);
2554
+ border-radius: 9999px;
2555
+ transition: background-color 0.2s ease;
2556
+ }
2557
+
2558
+ .cv-toggle-slider:before {
2559
+ position: absolute;
2560
+ content: "";
2561
+ height: 1rem;
2562
+ width: 1rem;
2563
+ left: 0.25rem;
2564
+ bottom: 0.25rem;
2565
+ background: white;
2566
+ border-radius: 50%;
2567
+ transition: transform 0.2s ease;
2568
+ }
2569
+
2570
+ .cv-toggle-input:checked + .cv-toggle-slider {
2571
+ background: #3e84f4;
2572
+ }
2573
+
2574
+ .cv-toggle-input:checked + .cv-toggle-slider:before {
2575
+ transform: translateX(1.25rem);
2576
+ }
2577
+
2578
+ /* Dark theme toggle switch styles */
2579
+ .cv-widget-theme-dark .cv-toggle-switch {
2580
+ background: #4a5568;
2581
+ }
2582
+
2583
+ .cv-widget-theme-dark .cv-toggle-switch:hover {
2584
+ background: #5a6578;
2585
+ }
2586
+
2587
+ .cv-widget-theme-dark .cv-toggle-switch.cv-toggle-active {
2588
+ background: #63b3ed;
2589
+ }
2590
+
2591
+ .cv-widget-theme-dark .cv-toggle-switch.cv-toggle-active:hover {
2592
+ background: #4299e1;
2593
+ }
2594
+
2595
+ /* Tab Groups Container */
2596
+ .cv-tab-groups-list {
2597
+ display: flex;
2598
+ flex-direction: column;
2599
+ gap: 1px;
2600
+ border: 1px solid rgba(0, 0, 0, 0.1);
2601
+ border-radius: 0.5rem;
2602
+ overflow: hidden;
2603
+ }
2604
+
2605
+ /* Tab Group Card - Header (Navigation Headers toggle) */
2606
+ .cv-tabgroup-card.cv-tabgroup-header {
2607
+ display: flex;
2608
+ align-items: center;
2609
+ justify-content: space-between;
2610
+ padding: 0.75rem;
2611
+ border-bottom: 0px;
2612
+ }
2613
+
2614
+ .cv-tabgroup-card.cv-tabgroup-header .cv-tabgroup-row {
2615
+ display: flex;
2616
+ align-items: center;
2617
+ justify-content: space-between;
2618
+ width: 100%;
2619
+ gap: 1rem;
2620
+ }
2621
+
2622
+ /* Navigation toggle icon container */
2623
+ .cv-nav-toggle-container {
2624
+ display: flex;
2625
+ align-items: center;
2626
+ gap: 0.5rem;
2627
+ }
2628
+
2629
+ .cv-nav-icon {
2630
+ width: 2rem;
2631
+ height: 2rem;
2632
+ color: rgba(0, 0, 0, 0.8);
2633
+ display: flex;
2634
+ align-items: center;
2635
+ justify-content: center;
2636
+ flex-shrink: 0;
2637
+ transition: color 0.2s ease;
2638
+ }
2639
+
2640
+ /* Logo box - centered grey box on its own row */
2641
+ .cv-tabgroup-logo-box {
2642
+ width: 3.5rem;
2643
+ height: 3.5rem;
2644
+ background: rgba(0, 0, 0, 0.08);
2645
+ border-radius: 0.5rem;
2646
+ display: flex;
2647
+ align-items: center;
2648
+ justify-content: center;
2649
+ flex-shrink: 0;
2650
+ margin-bottom: 0.5rem;
2651
+ }
2652
+
2653
+ /* Title container for title alignment (without icon) */
2654
+ .cv-tabgroup-title-container {
2655
+ display: flex;
2656
+ align-items: center;
2657
+ gap: 0.5rem;
2658
+ }
2659
+
2660
+ /* Hover state for icon - apply to the entire tabgroup-row */
2661
+ .cv-tabgroup-card.cv-tabgroup-header:hover .cv-nav-icon {
2662
+ color: #3e84f4;
2663
+ }
2664
+
2665
+ .cv-widget-theme-dark .cv-nav-icon {
2666
+ color: rgba(255, 255, 255, 0.8);
2667
+ }
2668
+
2669
+ .cv-widget-theme-dark .cv-tabgroup-card.cv-tabgroup-header:hover .cv-nav-icon {
2670
+ color: #60a5fa;
2671
+ }
2672
+
2673
+ /* Tab Group Card - Items */
2674
+ .cv-tabgroup-card.cv-tabgroup-item {
2675
+ display: flex;
2676
+ flex-direction: column;
2677
+ gap: 0.5rem;
2678
+ padding: 0.75rem;
2679
+ background: white;
2680
+ border-bottom: 1px solid rgba(0, 0, 0, 0.05);
2681
+ }
2682
+
2683
+ .cv-tabgroup-card.cv-tabgroup-item:last-child {
2684
+ border-bottom: none;
2685
+ }
2686
+
2687
+ /* Tab Group Info */
2688
+ .cv-tabgroup-info {
2689
+ flex: 1;
2690
+ display: flex;
2691
+ flex-direction: column;
2692
+ gap: 0.25rem;
2693
+ }
2694
+
2695
+ .cv-tabgroup-title {
2696
+ font-weight: 500;
2697
+ font-size: 0.875rem;
2698
+ color: rgba(0, 0, 0, 0.9);
2699
+ margin: 0 0 0 0;
2700
+ }
2701
+
2702
+ .cv-tabgroup-description {
2703
+ font-size: 0.75rem;
2704
+ color: rgba(0, 0, 0, 0.6);
2705
+ margin: 0;
2706
+ line-height: 1.3;
2707
+ }
2708
+
2709
+ /* Tab Group Label (for select dropdowns) */
2710
+ .cv-tabgroup-label {
2711
+ font-size: 0.875rem;
2712
+ color: rgba(0, 0, 0, 0.8);
2713
+ margin: 0;
2714
+ line-height: 1.4;
2715
+ font-weight: 500;
2716
+ display: block;
2717
+ cursor: pointer;
2718
+ }
2719
+
2720
+ /* Tab Group Select */
2721
+ .cv-tabgroup-select {
2722
+ width: 100%;
2723
+ border-radius: 0.5rem;
2724
+ background: white;
2725
+ border: 1px solid rgba(0, 0, 0, 0.15);
2726
+ color: rgba(0, 0, 0, 0.9);
2727
+ padding: 0.5rem 0.75rem;
2728
+ font-size: 0.875rem;
2729
+ cursor: pointer;
2730
+ transition: all 0.15s ease;
2731
+ font-family: inherit;
2732
+ }
2733
+
2734
+ .cv-tabgroup-select:hover {
2735
+ border-color: rgba(0, 0, 0, 0.25);
2736
+ }
2737
+
2738
+ .cv-tabgroup-select:focus {
2739
+ outline: none;
2740
+ border-color: #3e84f4;
2741
+ box-shadow: 0 0 0 2px rgba(62, 132, 244, 0.2);
2742
+ }
2743
+
2744
+ /* Modern Toggle Switch */
2745
+ .cv-toggle-switch {
2746
+ position: relative;
2747
+ display: inline-flex;
2748
+ align-items: center;
2749
+ width: 44px;
2750
+ height: 24px;
2751
+ background: rgba(0, 0, 0, 0.1);
2752
+ border-radius: 9999px;
2753
+ padding: 2px;
2754
+ box-sizing: border-box;
2755
+ cursor: pointer;
2756
+ transition: background-color 0.2s ease;
2757
+ border: none;
2758
+ }
2759
+
2760
+ .cv-toggle-switch input {
2761
+ display: none;
2762
+ }
2763
+
2764
+ .cv-toggle-switch .cv-switch-bg {
2765
+ position: absolute;
2766
+ inset: 0;
2767
+ border-radius: 9999px;
2768
+ background: rgba(0, 0, 0, 0.1);
2769
+ transition: background-color 0.2s ease;
2770
+ pointer-events: none;
2771
+ }
2772
+
2773
+ .cv-toggle-switch .cv-switch-knob {
2774
+ position: relative;
2775
+ width: 20px;
2776
+ height: 20px;
2777
+ background: white;
2778
+ border-radius: 50%;
2779
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
2780
+ transition: transform 0.2s ease;
2781
+ z-index: 1;
2782
+ }
2783
+
2784
+ .cv-toggle-switch input:checked + .cv-switch-bg {
2785
+ background: #3e84f4;
2786
+ }
2787
+
2788
+ .cv-toggle-switch input:checked ~ .cv-switch-knob {
2789
+ transform: translateX(20px);
2790
+ }
2791
+
2792
+ /* Dark Theme - Tab Groups */
2793
+ .cv-widget-theme-dark .cv-tabgroup-card.cv-tabgroup-header {
2794
+ background: #101722;
2795
+ border-bottom-color: rgba(255, 255, 255, 0.1);
2796
+ }
2797
+
2798
+ .cv-widget-theme-dark .cv-tabgroup-card.cv-tabgroup-item {
2799
+ background: #101722;
2800
+ border-bottom-color: rgba(255, 255, 255, 0.05);
2801
+ }
2802
+
2803
+ .cv-widget-theme-dark .cv-tabgroup-title {
2804
+ color: #e2e8f0;
2805
+ }
2806
+
2807
+ .cv-widget-theme-dark .cv-tabgroup-description {
2808
+ color: rgba(255, 255, 255, 0.6);
2809
+ }
2810
+
2811
+ .cv-widget-theme-dark .cv-tabgroup-label {
2812
+ color: rgba(255, 255, 255, 0.8);
2813
+ }
2814
+
2815
+ .cv-widget-theme-dark .cv-tab-groups-list {
2816
+ border-color: rgba(255, 255, 255, 0.1);
2817
+ }
2818
+
2819
+ .cv-widget-theme-dark .cv-tabgroup-select {
2820
+ background: #101722;
2821
+ border-color: rgba(255, 255, 255, 0.15);
2822
+ color: #e2e8f0;
2823
+ }
2824
+
2825
+ .cv-widget-theme-dark .cv-tabgroup-select:hover {
2826
+ border-color: rgba(255, 255, 255, 0.25);
2827
+ }
2828
+
2829
+ .cv-widget-theme-dark .cv-tabgroup-select:focus {
2830
+ border-color: #60a5fa;
2831
+ box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
2832
+ }
2833
+
2834
+ /* Dark Theme - Toggle Switch */
2835
+ .cv-widget-theme-dark .cv-toggle-switch .cv-switch-bg {
2836
+ background: rgba(255, 255, 255, 0.1);
2837
+ }
2838
+
2839
+ .cv-widget-theme-dark .cv-toggle-switch .cv-switch-knob {
2840
+ background: #e2e8f0;
2841
+ }
2842
+
2843
+ .cv-widget-theme-dark .cv-toggle-switch input:checked + .cv-switch-bg {
2844
+ background: #63b3ed;
2845
+ }
2846
+
2847
+ .cv-modal-footer {
2848
+ display: flex;
2849
+ justify-content: space-between;
2850
+ align-items: center;
2851
+ padding: 0.75rem;
2852
+ border-top: 1px solid rgba(0, 0, 0, 0.1);
2853
+ }
2854
+
2855
+ .cv-reset-btn,
2856
+ .cv-share-btn {
2857
+ display: flex;
2858
+ align-items: center;
2859
+ gap: 0.5rem;
2860
+ padding: 0.375rem 0.75rem;
2861
+ border-radius: 0.5rem;
2862
+ font-weight: 600;
2863
+ font-size: 0.875rem;
2864
+ cursor: pointer;
2865
+ transition: all 0.2s ease;
2866
+ border: none;
2867
+ }
2868
+
2869
+ .cv-reset-btn {
2870
+ color: rgba(0, 0, 0, 0.9);
2871
+ background: rgba(0, 0, 0, 0.1);
2872
+ }
2873
+
2874
+ .cv-reset-btn:hover {
2875
+ background: rgba(0, 0, 0, 0.2);
2876
+ }
2877
+
2878
+ .cv-share-btn {
2879
+ color: white;
2880
+ background: #3e84f4;
2881
+ }
2882
+
2883
+ .cv-share-btn:hover {
2884
+ background: rgba(62, 132, 244, 0.9);
2885
+ }
2886
+
2887
+ .cv-btn-icon {
2888
+ width: 1rem;
2889
+ height: 1rem;
2890
+ display: flex;
2891
+ align-items: center;
2892
+ justify-content: center;
2893
+ transition: transform 0.2s ease;
2894
+ }
2895
+
2896
+ /* Dark theme custom state styles */
2897
+ /* Welcome modal styles */
2898
+ .cv-welcome-modal {
2899
+ max-width: 32rem;
2900
+ width: 90vw;
2901
+ background: white;
2902
+ border-radius: 0.75rem;
2903
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
2904
+ animation: slideIn 0.2s ease;
2905
+ display: flex;
2906
+ flex-direction: column;
2907
+ }
2908
+
2909
+ .cv-modal-main {
2910
+ padding: 1rem;
2911
+ flex: 1;
2912
+ display: flex;
2913
+ flex-direction: column;
2914
+ gap: 1rem;
2915
+ overflow-y: auto;
2916
+ max-height: calc(80vh - 8rem);
2917
+ }
2918
+
2919
+ .cv-welcome-message {
2920
+ font-size: 0.875rem;
2921
+ color: rgba(0, 0, 0, 0.8);
2922
+ margin: 0;
2923
+ line-height: 1.4;
2924
+ text-align: center;
2925
+ }
2926
+
2927
+ .cv-welcome-message a {
2928
+ color: #3e84f4;
2929
+ text-align: justify;
2930
+ text-decoration: none;
2931
+ }
2932
+
2933
+ .cv-welcome-message a:hover {
2934
+ text-decoration: underline;
2935
+ }
2936
+
2937
+ .cv-welcome-widget-preview {
2938
+ display: flex;
2939
+ align-items: center;
2940
+ justify-content: center;
2941
+ gap: 1rem;
2942
+ padding: 1rem;
2943
+ background: #f8f9fa;
2944
+ border-radius: 0.5rem;
2945
+ margin: 1rem 0;
2946
+ }
2947
+
2948
+ .cv-welcome-widget-icon {
2949
+ width: 2rem;
2950
+ height: 2rem;
2951
+ background: rgba(62, 132, 244, 0.1);
2952
+ border-radius: 9999px;
2953
+ display: flex;
2954
+ align-items: center;
2955
+ justify-content: center;
2956
+ animation: cv-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
2957
+ color: #3e84f4;
2958
+ }
2959
+
2960
+ .cv-welcome-widget-label {
2961
+ font-size: 0.875rem;
2962
+ font-weight: 500;
2963
+ color: rgba(0, 0, 0, 0.8);
2964
+ margin: 0;
2965
+ }
2966
+
2967
+ .cv-welcome-got-it {
2968
+ width: 100%;
2969
+ background: #3e84f4;
2970
+ color: white;
2971
+ font-weight: 600;
2972
+ padding: 0.75rem 1rem;
2973
+ border-radius: 0.5rem;
2974
+ border: none;
2975
+ cursor: pointer;
2976
+ font-size: 0.875rem;
2977
+ transition: background-color 0.2s ease;
2978
+ outline: none;
2979
+ }
2980
+
2981
+ .cv-welcome-got-it:hover {
2982
+ background: rgba(62, 132, 244, 0.9);
2983
+ }
2984
+
2985
+ .cv-welcome-got-it:focus {
2986
+ box-shadow: 0 0 0 2px rgba(62, 132, 244, 0.5);
2987
+ }
2988
+
2989
+ /* Animations */
2990
+ @keyframes cv-pulse {
2991
+ 0%, 100% {
2992
+ opacity: 1;
2993
+ }
2994
+ 50% {
2995
+ opacity: 0.5;
2996
+ }
2997
+ }
2998
+
2999
+ /* Dark theme welcome modal styles */
3000
+ .cv-widget-theme-dark .cv-welcome-modal {
3001
+ background: #101722;
3002
+ }
3003
+
3004
+ .cv-widget-theme-dark .cv-welcome-message {
3005
+ color: rgba(255, 255, 255, 0.8);
3006
+ }
3007
+
3008
+ .cv-widget-theme-dark .cv-welcome-message a {
3009
+ color: #60a5fa;
3010
+ }
3011
+
3012
+ .cv-widget-theme-dark .cv-welcome-widget-preview {
3013
+ background: rgba(255, 255, 255, 0.1);
3014
+ }
3015
+
3016
+ .cv-widget-theme-dark .cv-welcome-widget-label {
3017
+ color: #e2e8f0;
3018
+ }
3019
+
3020
+ /* Dark theme logo box */
3021
+ .cv-widget-theme-dark .cv-tabgroup-logo-box {
3022
+ background: rgba(255, 255, 255, 0.1);
3023
+ }
3024
+
3025
+ /* Spinning animation for reset button icon */
3026
+ @keyframes cv-spin {
3027
+ from {
3028
+ transform: rotate(0deg);
3029
+ }
3030
+ to {
3031
+ transform: rotate(-360deg);
3032
+ }
3033
+ }
3034
+
3035
+ .cv-spinning {
3036
+ animation: cv-spin 0.6s ease-in-out;
3037
+ }
3038
+
3039
+ /* Hide widget icon in print view */
3040
+ @media print {
3041
+ .cv-widget-icon {
3042
+ display: none !important;
3043
+ }
3044
+ }
2566
3045
  `;
2567
3046
  /**
2568
3047
  * Inject widget styles into the document head
@@ -2577,119 +3056,16 @@ ${TAB_STYLES}
2577
3056
  document.head.appendChild(style);
2578
3057
  }
2579
3058
 
2580
- /**
2581
- * Icon utilities for CustomViews widget
2582
- * Centralized SVG icons for better maintainability and reusability
2583
- */
2584
- /**
2585
- * Settings gear icon for modal header
2586
- */
2587
- function getGearIcon() {
2588
- return `<svg class="cv-modal-icon-svg" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2589
- <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"/>
2590
- <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"/>
2591
- </svg>`;
2592
- }
2593
- /**
2594
- * Close/X icon for modal close button
2595
- */
2596
- function getCloseIcon() {
2597
- 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">
2598
- <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>
2599
- </svg>`;
2600
- }
2601
- /**
2602
- * Reset/refresh icon for reset button
2603
- */
2604
- function getResetIcon() {
2605
- return `<svg class="cv-btn-icon" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2606
- <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"/>
2607
- </svg>`;
2608
- }
2609
- /**
2610
- * Copy icon for sharing URL button
2611
- */
2612
- function getCopyIcon() {
2613
- 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">
2614
- <g id="surface1">
2615
- <path d="M 11.273438 0 L 2.546875 0 C 1.746094 0 1.089844 0.613281 1.089844
2616
- 1.363281 L 1.089844 10.910156 L 2.546875 10.910156 L 2.546875 1.363281 L 11.273438
2617
- 1.363281 Z M 13.453125 2.726562 L 5.453125 2.726562 C 4.65625 2.726562 4 3.339844 4
2618
- 4.089844 L 4 13.636719 C 4 14.386719 4.65625 15 5.453125 15 L 13.453125 15 C 14.253906
2619
- 15 14.910156 14.386719 14.910156 13.636719 L 14.910156 4.089844 C 14.910156 3.339844
2620
- 14.253906 2.726562 13.453125 2.726562 Z M 13.453125 13.636719 L 5.453125 13.636719 L
2621
- 5.453125 4.089844 L 13.453125 4.089844 Z M 13.453125 13.636719 "></path>
2622
- </g>
2623
- </svg>`;
2624
- }
2625
- function getTickIcon() {
2626
- return `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="2 2 22 22" fill="currentColor">
2627
- <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
2628
- L 9 18.40625 L 9.71875 17.71875 L 20.71875 6.71875 Z"></path>
2629
- </svg>`;
2630
- }
2631
- function getNavHeadingOnIcon() {
2632
- return `<svg xmlns="http://www.w3.org/2000/svg" width="250" height="181" viewBox="0 0 250 181">
2633
- <rect y="34.5001" width="250" height="146" rx="4" stroke="currentColor" stroke-width="10" fill="none"/>
2634
- <line x1="27" y1="62.0001" x2="77" y2="62.0001" stroke="currentColor" stroke-width="5"/>
2635
- <line x1="27" y1="77.8888" x2="77" y2="77.8888" stroke="currentColor" stroke-width="5"/>
2636
- <line x1="27" y1="97.4454" x2="221" y2="97.4454" stroke="currentColor" stroke-width="5"/>
2637
- <line x1="27" y1="114.555" x2="221" y2="114.555" stroke="currentColor" stroke-width="5"/>
2638
- <line x1="27" y1="132.889" x2="221" y2="132.889" stroke="currentColor" stroke-width="5"/>
2639
- <line x1="27" y1="150" x2="221" y2="150" stroke="currentColor" stroke-width="5"/>
2640
- <line x1="247.5" y1="43.0001" x2="247.5" y2="13.0001" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2641
- <path d="M185 12.5001L247 12.5001" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2642
- <line x1="204.09" y1="36.6095" x2="181.698" y2="10.0228" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2643
- <path d="M125 9.50012L181 9.50012" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2644
- <path d="M144.305 35.2579L120.095 6.56679" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2645
- <path d="M120 6.50037L64 6.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2646
- <path d="M87.1957 36.1024L59 2.50008" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2647
- <path d="M59 2.50037L3 2.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2648
- <path d="M2.5 38.5001L2.5 3.00012" stroke="currentColor" stroke-width="5" stroke-linecap="round"/>
2649
- </svg>`;
2650
- }
2651
- function getNavHeadingOffIcon() {
2652
- return `<svg xmlns="http://www.w3.org/2000/svg" width="250" height="181" viewBox="0 0 250 181" fill="currentColor">
2653
- <rect y="34.5001" width="250" height="146" rx="4" stroke="currentColor" stroke-width="10" fill="none"/>
2654
- <line x1="27" y1="62" x2="77" y2="62" stroke="currentColor" stroke-width="5"/>
2655
- <line x1="27" y1="77.8887" x2="77" y2="77.8887" stroke="currentColor" stroke-width="5"/>
2656
- <line x1="27" y1="97.4453" x2="221" y2="97.4453" stroke="currentColor" stroke-width="5"/>
2657
- <line x1="27" y1="114.555" x2="221" y2="114.555" stroke="currentColor" stroke-width="5"/>
2658
- <line x1="27" y1="132.889" x2="221" y2="132.889" stroke="currentColor" stroke-width="5"/>
2659
- <line x1="27" y1="150" x2="221" y2="150" stroke="currentColor" stroke-width="5"/>
2660
- </svg>`;
2661
- }
2662
- /**
2663
- * Transition Icon for Navigation Headings
2664
- */
2665
- function getNavDashed() {
2666
- return `<svg xmlns="http://www.w3.org/2000/svg" width="250" height="181" viewBox="0 0 250 181">
2667
- <rect y="34.5001" width="250" height="146" rx="4" stroke="currentColor" stroke-width="10" fill="none"/>
2668
- <line x1="27" y1="62.0001" x2="77" y2="62.0001" stroke="currentColor" stroke-width="5"/>
2669
- <line x1="27" y1="77.8888" x2="77" y2="77.8888" stroke="currentColor" stroke-width="5"/>
2670
- <line x1="27" y1="97.4454" x2="221" y2="97.4454" stroke="currentColor" stroke-width="5"/>
2671
- <line x1="27" y1="114.555" x2="221" y2="114.555" stroke="currentColor" stroke-width="5"/>
2672
- <line x1="27" y1="132.889" x2="221" y2="132.889" stroke="currentColor" stroke-width="5"/>
2673
- <line x1="27" y1="150" x2="221" y2="150" stroke="currentColor" stroke-width="5"/>
2674
- <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"/>
2675
- <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"/>
2676
- <path d="M125 9.50012L181 9.50012" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2677
- <path d="M144.305 35.2579L120.095 6.56679" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2678
- <path d="M120 6.50037L64 6.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2679
- <path d="M87.1957 36.1024L59 2.50008" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2680
- <path d="M59 2.50037L3 2.50037" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2681
- <path d="M2.5 38.5001L2.5 3.00012" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2682
- <path d="M185 12.5001L247 12.5001" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-dasharray="10 10"/>
2683
- </svg>`;
2684
- }
2685
-
2686
3059
  class CustomViewsWidget {
2687
3060
  core;
2688
3061
  container;
2689
3062
  widgetIcon = null;
2690
3063
  options;
3064
+ _hasVisibleConfig = false;
3065
+ pageToggleIds = new Set();
3066
+ pageTabIds = new Set();
2691
3067
  // Modal state
2692
- modal = null;
3068
+ stateModal = null;
2693
3069
  constructor(options) {
2694
3070
  this.core = options.core;
2695
3071
  this.container = options.container || document.body;
@@ -2707,12 +3083,41 @@ ${TAB_STYLES}
2707
3083
  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>.',
2708
3084
  showTabGroups: options.showTabGroups ?? true
2709
3085
  };
2710
- // No external state manager to initialize
3086
+ // Determine if there are any configurations to show
3087
+ const config = this.core.getConfig();
3088
+ const allToggles = config?.toggles || [];
3089
+ const visibleToggles = allToggles.filter(toggle => {
3090
+ if (toggle.isLocal) {
3091
+ return !!document.querySelector(`[data-cv-toggle="${toggle.id}"], [data-cv-toggle-group-id="${toggle.id}"]`);
3092
+ }
3093
+ return true;
3094
+ });
3095
+ const allTabGroups = this.core.getTabGroups() || [];
3096
+ const visibleTabGroups = allTabGroups.filter(group => {
3097
+ if (group.isLocal) {
3098
+ return !!document.querySelector(`cv-tabgroup[id="${group.id}"]`);
3099
+ }
3100
+ return true;
3101
+ });
3102
+ if (visibleToggles.length > 0 || (this.options.showTabGroups && visibleTabGroups.length > 0)) {
3103
+ this._hasVisibleConfig = true;
3104
+ }
3105
+ // Scan for page-declared local components and cache them
3106
+ // Do this on initialization to avoid querying DOM repeatedly
3107
+ const pageTogglesAttr = document.querySelector('[data-cv-page-local-toggles]')?.getAttribute('data-cv-page-local-toggles') || '';
3108
+ this.pageToggleIds = new Set(pageTogglesAttr.split(',').map(id => id.trim()).filter(id => id));
3109
+ const pageTabsAttr = document.querySelector('[data-cv-page-local-tabs]')?.getAttribute('data-cv-page-local-tabs') || '';
3110
+ this.pageTabIds = new Set(pageTabsAttr.split(',').map(id => id.trim()).filter(id => id));
2711
3111
  }
2712
3112
  /**
2713
- * Render the widget
3113
+ * Render the widget modal icon
3114
+ *
3115
+ * Does not render if there are no visible toggles or tab groups.
2714
3116
  */
2715
- render() {
3117
+ renderModalIcon() {
3118
+ if (!this._hasVisibleConfig) {
3119
+ return;
3120
+ }
2716
3121
  this.widgetIcon = this.createWidgetIcon();
2717
3122
  this.attachEventListeners();
2718
3123
  // Always append to body since it's a floating icon
@@ -2745,9 +3150,9 @@ ${TAB_STYLES}
2745
3150
  this.widgetIcon = null;
2746
3151
  }
2747
3152
  // Clean up modal
2748
- if (this.modal) {
2749
- this.modal.remove();
2750
- this.modal = null;
3153
+ if (this.stateModal) {
3154
+ this.stateModal.remove();
3155
+ this.stateModal = null;
2751
3156
  }
2752
3157
  }
2753
3158
  attachEventListeners() {
@@ -2760,294 +3165,299 @@ ${TAB_STYLES}
2760
3165
  * Close the modal
2761
3166
  */
2762
3167
  closeModal() {
2763
- if (this.modal) {
2764
- this.modal.remove();
2765
- this.modal = null;
3168
+ if (this.stateModal) {
3169
+ this.stateModal.classList.add('cv-hidden');
2766
3170
  }
2767
3171
  }
2768
3172
  /**
2769
3173
  * Open the custom state creator
2770
3174
  */
2771
3175
  openStateModal() {
2772
- // Get toggles from current configuration and open the modal regardless of count
2773
- const config = this.core.getConfig();
2774
- const toggles = config?.allToggles || [];
2775
- this.createCustomStateModal(toggles);
3176
+ if (!this.stateModal) {
3177
+ this._createStateModal();
3178
+ }
3179
+ this._updateStateModalContent();
3180
+ this.stateModal.classList.remove('cv-hidden');
2776
3181
  }
2777
3182
  /**
2778
- * Create the custom state creator modal
3183
+ * Create the custom state creator modal shell and attach listeners
2779
3184
  */
2780
- createCustomStateModal(toggles) {
2781
- // Close existing modal
2782
- this.closeModal();
2783
- this.modal = document.createElement('div');
2784
- this.modal.className = 'cv-widget-modal-overlay';
3185
+ _createStateModal() {
3186
+ this.stateModal = document.createElement('div');
3187
+ this.stateModal.className = 'cv-widget-modal-overlay cv-hidden';
2785
3188
  this.applyThemeToModal();
2786
- const toggleControlsHtml = toggles.map(toggle => `
2787
- <div class="cv-toggle-card">
2788
- <div class="cv-toggle-content">
2789
- <div>
2790
- <p class="cv-toggle-title">${this.formatToggleName(toggle)}</p>
2791
- </div>
2792
- <label class="cv-toggle-label">
2793
- <input class="cv-toggle-input" type="checkbox" data-toggle="${toggle}"/>
2794
- <span class="cv-toggle-slider"></span>
2795
- </label>
2796
- </div>
2797
- </div>
3189
+ document.body.appendChild(this.stateModal);
3190
+ this._attachStateModalFrameEventListeners();
3191
+ }
3192
+ /**
3193
+ * Update the content of the state modal
3194
+ */
3195
+ _updateStateModalContent() {
3196
+ if (!this.stateModal)
3197
+ return;
3198
+ const pageToggleIds = this.pageToggleIds;
3199
+ const pageTabIds = this.pageTabIds;
3200
+ // Get toggles from current configuration
3201
+ const config = this.core.getConfig();
3202
+ const allToggles = config?.toggles || [];
3203
+ // Filter toggles to only include global and visible/declared local toggles
3204
+ const visibleToggles = allToggles.filter(toggle => {
3205
+ if (toggle.isLocal) {
3206
+ return pageToggleIds.has(toggle.id) || !!document.querySelector(`[data-cv-toggle="${toggle.id}"], [data-cv-toggle-group-id="${toggle.id}"]`);
3207
+ }
3208
+ return true; // Keep global toggles
3209
+ });
3210
+ const toggleControlsHtml = visibleToggles.map(toggle => `
3211
+ <div class="cv-toggle-card">
3212
+ <div class="cv-toggle-content">
3213
+ <div>
3214
+ <p class="cv-toggle-title">${toggle.label || toggle.id}</p>
3215
+ </div>
3216
+ <label class="cv-toggle-label">
3217
+ <input class="cv-toggle-input" type="checkbox" data-toggle="${toggle.id}"/>
3218
+ <span class="cv-toggle-slider"></span>
3219
+ </label>
3220
+ </div>
3221
+ </div>
2798
3222
  `).join('');
2799
- // Todo: Re-add description if needed (Line 168, add label field to toggles if needed change structure)
2800
- // <p class="cv-toggle-description">Show or hide the ${this.formatToggleName(toggle).toLowerCase()} area </p>
2801
3223
  // Get tab groups
2802
- const tabGroups = this.core.getTabGroups();
3224
+ const allTabGroups = this.core.getTabGroups() || [];
3225
+ const tabGroups = allTabGroups.filter(group => {
3226
+ if (group.isLocal) {
3227
+ return pageTabIds.has(group.id) || !!document.querySelector(`cv-tabgroup[id="${group.id}"]`);
3228
+ }
3229
+ return true; // Keep global tab groups
3230
+ });
2803
3231
  let tabGroupControlsHTML = '';
2804
3232
  if (this.options.showTabGroups && tabGroups && tabGroups.length > 0) {
2805
- // Determine initial nav visibility state
2806
3233
  const initialNavsVisible = TabManager.areNavsVisible(document.body);
2807
- tabGroupControlsHTML = `
2808
- <div class="cv-tabgroup-card cv-tabgroup-header">
2809
- <div class="cv-tabgroup-row">
2810
- <div class="cv-tabgroup-logo-box" id="cv-nav-icon-box">
2811
- <div class="cv-nav-icon" id="cv-nav-icon">${initialNavsVisible ? getNavHeadingOnIcon() : getNavHeadingOffIcon()}</div>
2812
- </div>
2813
- <div class="cv-tabgroup-info">
2814
- <div class="cv-tabgroup-title-container">
2815
- <p class="cv-tabgroup-title">Navigation Headers</p>
2816
- </div>
2817
- <p class="cv-tabgroup-description">Show or hide navigation headers</p>
2818
- </div>
2819
- <label class="cv-toggle-switch cv-nav-toggle">
2820
- <input class="cv-nav-pref-input" type="checkbox" ${initialNavsVisible ? 'checked' : ''} aria-label="Show or hide navigation headers" />
2821
- <span class="cv-switch-bg"></span>
2822
- <span class="cv-switch-knob"></span>
2823
- </label>
2824
- </div>
2825
- </div>
2826
- <div class="cv-tab-groups-list">
2827
- ${tabGroups.map(group => `
2828
- <div class="cv-tabgroup-card cv-tabgroup-item">
2829
- <label class="cv-tabgroup-label" for="tab-group-${group.id}">
2830
- ${group.label || group.id}
2831
- </label>
2832
- <select id="tab-group-${group.id}" class="cv-tabgroup-select" data-group-id="${group.id}">
2833
- ${group.tabs.map(tab => `<option value="${tab.id}">${tab.label || tab.id}</option>`).join('')}
2834
- </select>
2835
- </div>
2836
- `).join('')}
2837
- </div>
3234
+ tabGroupControlsHTML = `
3235
+ <div class="cv-tabgroup-card cv-tabgroup-header">
3236
+ <div class="cv-tabgroup-row">
3237
+ <div class="cv-tabgroup-logo-box" id="cv-nav-icon-box">
3238
+ <div class="cv-nav-icon" id="cv-nav-icon">${initialNavsVisible ? getNavHeadingOnIcon() : getNavHeadingOffIcon()}</div>
3239
+ </div>
3240
+ <div class="cv-tabgroup-info">
3241
+ <div class="cv-tabgroup-title-container">
3242
+ <p class="cv-tabgroup-title">Navigation Headers</p>
3243
+ </div>
3244
+ <p class="cv-tabgroup-description">Show or hide navigation headers</p>
3245
+ </div>
3246
+ <label class="cv-toggle-switch cv-nav-toggle">
3247
+ <input class="cv-nav-pref-input" type="checkbox" ${initialNavsVisible ? 'checked' : ''} aria-label="Show or hide navigation headers" />
3248
+ <span class="cv-switch-bg"></span>
3249
+ <span class="cv-switch-knob"></span>
3250
+ </label>
3251
+ </div>
3252
+ </div>
3253
+ <div class="cv-tab-groups-list">
3254
+ ${tabGroups.map(group => `
3255
+ <div class="cv-tabgroup-card cv-tabgroup-item">
3256
+ <label class="cv-tabgroup-label" for="tab-group-${group.id}">
3257
+ ${group.label || group.id}
3258
+ </label>
3259
+ <select id="tab-group-${group.id}" class="cv-tabgroup-select" data-group-id="${group.id}">
3260
+ ${group.tabs.map(tab => `<option value="${tab.id}">${tab.label || tab.id}</option>`).join('')}
3261
+ </select>
3262
+ </div>
3263
+ `).join('')}
3264
+ </div>
2838
3265
  `;
2839
3266
  }
2840
- this.modal.innerHTML = `
2841
- <div class="cv-widget-modal cv-custom-state-modal">
2842
- <header class="cv-modal-header">
2843
- <div class="cv-modal-header-content">
2844
- <div class="cv-modal-icon">
2845
- ${getGearIcon()}
2846
- </div>
2847
- <div class="cv-modal-title">${this.options.title}</div>
2848
- </div>
2849
- <button class="cv-modal-close" aria-label="Close modal">
2850
- ${getCloseIcon()}
2851
- </button>
2852
- </header>
2853
- <main class="cv-modal-main">
2854
- ${this.options.description ? `<p class="cv-modal-description">${this.options.description}</p>` : ''}
2855
-
2856
- ${toggles.length ? `
2857
- <div class="cv-content-section">
2858
- <div class="cv-section-heading">Toggles</div>
2859
- <div class="cv-toggles-container">
2860
- ${toggleControlsHtml}
2861
- </div>
2862
- </div>
2863
- ` : ''}
2864
-
2865
- ${this.options.showTabGroups && tabGroups && tabGroups.length > 0 ? `
2866
- <div class="cv-content-section">
2867
- <div class="cv-section-heading">Tab Groups</div>
2868
- <div class="cv-tabgroups-container">
2869
- ${tabGroupControlsHTML}
2870
- </div>
2871
- </div>
2872
- ` : ''}
2873
- </main>
2874
-
2875
- <footer class="cv-modal-footer">
2876
- ${this.options.showReset ? `
2877
- <button class="cv-reset-btn">
2878
- <span class="cv-reset-btn-icon">${getResetIcon()}</span>
2879
- <span>Reset to Default</span>
2880
- </button>
2881
- ` : ''}
2882
- <button class="cv-share-btn">
2883
- <span>Copy Shareable URL</span>
2884
- <span class="cv-share-btn-icon">${getCopyIcon()}</span>
2885
- </button>
2886
- </footer>
2887
- </div>
3267
+ this.stateModal.innerHTML = `
3268
+ <div class="cv-widget-modal cv-custom-state-modal">
3269
+ <header class="cv-modal-header">
3270
+ <div class="cv-modal-header-content">
3271
+ <div class="cv-modal-icon">
3272
+ ${getGearIcon()}
3273
+ </div>
3274
+ <div class="cv-modal-title">${this.options.title}</div>
3275
+ </div>
3276
+ <button class="cv-modal-close" aria-label="Close modal">
3277
+ ${getCloseIcon()}
3278
+ </button>
3279
+ </header>
3280
+ <main class="cv-modal-main">
3281
+ ${this.options.description ? `<p class="cv-modal-description">${this.options.description}</p>` : ''}
3282
+
3283
+ ${visibleToggles.length ? `
3284
+ <div class="cv-content-section">
3285
+ <div class="cv-section-heading">Toggles</div>
3286
+ <div class="cv-toggles-container">
3287
+ ${toggleControlsHtml}
3288
+ </div>
3289
+ </div>
3290
+ ` : ''}
3291
+
3292
+ ${this.options.showTabGroups && tabGroups && tabGroups.length > 0 ? `
3293
+ <div class="cv-content-section">
3294
+ <div class="cv-section-heading">Tab Groups</div>
3295
+ <div class="cv-tabgroups-container">
3296
+ ${tabGroupControlsHTML}
3297
+ </div>
3298
+ </div>
3299
+ ` : ''}
3300
+ </main>
3301
+
3302
+ <footer class="cv-modal-footer">
3303
+ ${this.options.showReset ? `
3304
+ <button class="cv-reset-btn">
3305
+ <span class="cv-reset-btn-icon">${getResetIcon()}</span>
3306
+ <span>Reset to Default</span>
3307
+ </button>
3308
+ ` : ''}
3309
+ <button class="cv-share-btn">
3310
+ <span>Copy Shareable URL</span>
3311
+ <span class="cv-share-btn-icon">${getCopyIcon()}</span>
3312
+ </button>
3313
+ </footer>
3314
+ </div>
2888
3315
  `;
2889
- document.body.appendChild(this.modal);
2890
- this.attachStateModalEventListeners();
2891
- // Load current state into form if we're already in a custom state
3316
+ this._attachStateModalContentEventListeners();
2892
3317
  this.loadCurrentStateIntoForm();
2893
3318
  }
2894
3319
  /**
2895
- * Attach event listeners for custom state creator
3320
+ * Attach event listeners for the modal frame (delegated events)
2896
3321
  */
2897
- attachStateModalEventListeners() {
2898
- if (!this.modal)
3322
+ _attachStateModalFrameEventListeners() {
3323
+ if (!this.stateModal)
2899
3324
  return;
2900
- // Close button
2901
- const closeBtn = this.modal.querySelector('.cv-modal-close');
2902
- if (closeBtn) {
2903
- closeBtn.addEventListener('click', () => {
3325
+ // Delegated click events
3326
+ this.stateModal.addEventListener('click', (e) => {
3327
+ const target = e.target;
3328
+ // Close button
3329
+ if (target.closest('.cv-modal-close')) {
2904
3330
  this.closeModal();
2905
- });
2906
- }
2907
- // Copy URL button
2908
- const copyUrlBtn = this.modal.querySelector('.cv-share-btn');
2909
- if (copyUrlBtn) {
2910
- copyUrlBtn.addEventListener('click', () => {
3331
+ return;
3332
+ }
3333
+ // Copy URL button
3334
+ if (target.closest('.cv-share-btn')) {
2911
3335
  this.copyShareableURL();
2912
- // Visual feedback: change icon to tick for 3 seconds
2913
- const iconContainer = copyUrlBtn.querySelector('.cv-share-btn-icon');
3336
+ const copyUrlBtn = target.closest('.cv-share-btn');
3337
+ const iconContainer = copyUrlBtn?.querySelector('.cv-share-btn-icon');
2914
3338
  if (iconContainer) {
2915
3339
  const originalIcon = iconContainer.innerHTML;
2916
3340
  iconContainer.innerHTML = getTickIcon();
2917
- // Revert after 3 seconds
2918
3341
  setTimeout(() => {
2919
3342
  iconContainer.innerHTML = originalIcon;
2920
3343
  }, 3000);
2921
3344
  }
2922
- });
2923
- }
2924
- // Reset to default button
2925
- const resetBtn = this.modal.querySelector('.cv-reset-btn');
2926
- if (resetBtn) {
2927
- resetBtn.addEventListener('click', () => {
2928
- // Add spinning animation to icon
2929
- const resetIcon = resetBtn.querySelector('.cv-reset-btn-icon');
3345
+ return;
3346
+ }
3347
+ // Reset to default button
3348
+ if (target.closest('.cv-reset-btn')) {
3349
+ const resetBtn = target.closest('.cv-reset-btn');
3350
+ const resetIcon = resetBtn?.querySelector('.cv-reset-btn-icon');
2930
3351
  if (resetIcon) {
2931
3352
  resetIcon.classList.add('cv-spinning');
2932
3353
  }
2933
3354
  this.core.resetToDefault();
2934
3355
  this.loadCurrentStateIntoForm();
2935
- // Remove spinning animation after it completes
2936
3356
  setTimeout(() => {
2937
3357
  if (resetIcon) {
2938
3358
  resetIcon.classList.remove('cv-spinning');
2939
3359
  }
2940
- }, 600); // 600ms matches the animation duration
2941
- });
2942
- }
3360
+ }, 600);
3361
+ return;
3362
+ }
3363
+ // Overlay click to close
3364
+ if (e.target === this.stateModal) {
3365
+ this.closeModal();
3366
+ }
3367
+ });
3368
+ // Escape key to close
3369
+ const handleEscape = (e) => {
3370
+ if (e.key === 'Escape') {
3371
+ this.closeModal();
3372
+ }
3373
+ };
3374
+ // We can't remove this listener easily if it's anonymous, so we attach it to the document
3375
+ // and it will stay for the lifetime of the widget. This is acceptable.
3376
+ document.addEventListener('keydown', handleEscape);
3377
+ }
3378
+ /**
3379
+ * Attach event listeners for custom state creator's dynamic content
3380
+ */
3381
+ _attachStateModalContentEventListeners() {
3382
+ if (!this.stateModal)
3383
+ return;
2943
3384
  // Listen to toggle switches
2944
- const toggleInputs = this.modal.querySelectorAll('.cv-toggle-input');
3385
+ const toggleInputs = this.stateModal.querySelectorAll('.cv-toggle-input');
2945
3386
  toggleInputs.forEach(toggleInput => {
2946
3387
  toggleInput.addEventListener('change', () => {
2947
3388
  const state = this.getCurrentCustomStateFromModal();
2948
- this.core.applyState(state);
3389
+ this.core.applyState(state, { source: 'widget' });
2949
3390
  });
2950
3391
  });
2951
3392
  // Listen to tab group selects
2952
- const tabGroupSelects = this.modal.querySelectorAll('.cv-tabgroup-select');
3393
+ const tabGroupSelects = this.stateModal.querySelectorAll('.cv-tabgroup-select');
2953
3394
  tabGroupSelects.forEach(select => {
2954
3395
  select.addEventListener('change', () => {
2955
3396
  const groupId = select.dataset.groupId;
2956
3397
  const tabId = select.value;
2957
3398
  if (groupId && tabId) {
2958
- // Get current state and update the tab for this group, then apply globally
2959
- // This triggers sync behavior and persistence
2960
3399
  const currentTabs = this.core.getCurrentActiveTabs();
2961
3400
  currentTabs[groupId] = tabId;
2962
- // Apply state globally for persistence and sync
2963
3401
  const currentToggles = this.core.getCurrentActiveToggles();
2964
3402
  const newState = {
2965
3403
  toggles: currentToggles,
2966
3404
  tabs: currentTabs
2967
3405
  };
2968
- this.core.applyState(newState);
3406
+ this.core.applyState(newState, { source: 'widget' });
2969
3407
  }
2970
3408
  });
2971
3409
  });
2972
3410
  // Listener for show/hide tab navs
2973
- const tabNavToggle = this.modal.querySelector('.cv-nav-pref-input');
2974
- const navIcon = this.modal?.querySelector('#cv-nav-icon');
2975
- const navHeaderCard = this.modal?.querySelector('.cv-tabgroup-card.cv-tabgroup-header');
3411
+ const tabNavToggle = this.stateModal.querySelector('.cv-nav-pref-input');
3412
+ const navIcon = this.stateModal?.querySelector('#cv-nav-icon');
3413
+ const navHeaderCard = this.stateModal?.querySelector('.cv-tabgroup-card.cv-tabgroup-header');
2976
3414
  if (tabNavToggle && navIcon && navHeaderCard) {
2977
- // Helper to update icon based on state
2978
3415
  const updateIcon = (isVisible, isHovering = false) => {
2979
3416
  if (isHovering) {
2980
- // On hover, show the transition icon
2981
3417
  navIcon.innerHTML = getNavDashed();
2982
3418
  }
2983
3419
  else {
2984
- // Normal state, show the status icon (on if visible, off if hidden)
2985
3420
  navIcon.innerHTML = isVisible ? getNavHeadingOnIcon() : getNavHeadingOffIcon();
2986
3421
  }
2987
3422
  };
2988
- // Add hover listeners to entire header card
2989
- navHeaderCard.addEventListener('mouseenter', () => {
2990
- updateIcon(tabNavToggle.checked, true);
2991
- });
2992
- navHeaderCard.addEventListener('mouseleave', () => {
2993
- updateIcon(tabNavToggle.checked, false);
2994
- });
2995
- // Add change listener
3423
+ navHeaderCard.addEventListener('mouseenter', () => updateIcon(tabNavToggle.checked, true));
3424
+ navHeaderCard.addEventListener('mouseleave', () => updateIcon(tabNavToggle.checked, false));
2996
3425
  tabNavToggle.addEventListener('change', () => {
2997
3426
  const visible = tabNavToggle.checked;
2998
- // Update the icon based on new state (not hovering)
2999
3427
  updateIcon(visible, false);
3000
- // Persist preference via core
3001
3428
  this.core.persistTabNavVisibility(visible);
3002
- // Apply to DOM using TabManager via core
3003
3429
  try {
3004
- const rootEl = document.body;
3005
- TabManager.setNavsVisibility(rootEl, visible);
3430
+ TabManager.setNavsVisibility(document.body, visible);
3006
3431
  }
3007
3432
  catch (e) {
3008
- // ignore errors
3009
3433
  console.error('Failed to set tab nav visibility:', e);
3010
3434
  }
3011
3435
  });
3012
3436
  }
3013
- // Overlay click to close
3014
- this.modal.addEventListener('click', (e) => {
3015
- if (e.target === this.modal) {
3016
- this.closeModal();
3017
- }
3018
- });
3019
- // Escape key to close
3020
- const handleEscape = (e) => {
3021
- if (e.key === 'Escape') {
3022
- this.closeModal();
3023
- document.removeEventListener('keydown', handleEscape);
3024
- }
3025
- };
3026
- document.addEventListener('keydown', handleEscape);
3027
3437
  }
3028
3438
  /**
3029
3439
  * Apply theme class to the modal overlay based on options
3030
3440
  */
3031
3441
  applyThemeToModal() {
3032
- if (!this.modal)
3442
+ if (!this.stateModal)
3033
3443
  return;
3034
3444
  if (this.options.theme === 'dark') {
3035
- this.modal.classList.add('cv-widget-theme-dark');
3445
+ this.stateModal.classList.add('cv-widget-theme-dark');
3036
3446
  }
3037
3447
  else {
3038
- this.modal.classList.remove('cv-widget-theme-dark');
3448
+ this.stateModal.classList.remove('cv-widget-theme-dark');
3039
3449
  }
3040
3450
  }
3041
3451
  /**
3042
3452
  * Get current state from form values
3043
3453
  */
3044
3454
  getCurrentCustomStateFromModal() {
3045
- if (!this.modal) {
3455
+ if (!this.stateModal) {
3046
3456
  return {};
3047
3457
  }
3048
3458
  // Collect toggle values
3049
3459
  const toggles = [];
3050
- const toggleInputs = this.modal.querySelectorAll('.cv-toggle-input');
3460
+ const toggleInputs = this.stateModal.querySelectorAll('.cv-toggle-input');
3051
3461
  toggleInputs.forEach(toggleInput => {
3052
3462
  const toggle = toggleInput.dataset.toggle;
3053
3463
  if (toggle && toggleInput.checked) {
@@ -3055,7 +3465,7 @@ ${TAB_STYLES}
3055
3465
  }
3056
3466
  });
3057
3467
  // Collect tab selections
3058
- const tabGroupSelects = this.modal.querySelectorAll('.cv-tabgroup-select');
3468
+ const tabGroupSelects = this.stateModal.querySelectorAll('.cv-tabgroup-select');
3059
3469
  const tabs = {};
3060
3470
  tabGroupSelects.forEach(select => {
3061
3471
  const groupId = select.dataset.groupId;
@@ -3083,25 +3493,25 @@ ${TAB_STYLES}
3083
3493
  * Load current state into form based on currently active toggles
3084
3494
  */
3085
3495
  loadCurrentStateIntoForm() {
3086
- if (!this.modal)
3496
+ if (!this.stateModal)
3087
3497
  return;
3088
3498
  // Get currently active toggles (from custom state or default configuration)
3089
3499
  const activeToggles = this.core.getCurrentActiveToggles();
3090
3500
  // First, uncheck all toggle inputs
3091
- const allToggleInputs = this.modal.querySelectorAll('.cv-toggle-input');
3501
+ const allToggleInputs = this.stateModal.querySelectorAll('.cv-toggle-input');
3092
3502
  allToggleInputs.forEach(toggleInput => {
3093
3503
  toggleInput.checked = false;
3094
3504
  });
3095
3505
  // Then check the ones that should be active
3096
3506
  activeToggles.forEach(toggle => {
3097
- const toggleInput = this.modal?.querySelector(`[data-toggle="${toggle}"]`);
3507
+ const toggleInput = this.stateModal?.querySelector(`[data-toggle="${toggle}"]`);
3098
3508
  if (toggleInput) {
3099
3509
  toggleInput.checked = true;
3100
3510
  }
3101
3511
  });
3102
3512
  // Load tab group selections
3103
3513
  const activeTabs = this.core.getCurrentActiveTabs();
3104
- const tabGroupSelects = this.modal.querySelectorAll('.cv-tabgroup-select');
3514
+ const tabGroupSelects = this.stateModal.querySelectorAll('.cv-tabgroup-select');
3105
3515
  tabGroupSelects.forEach(select => {
3106
3516
  const groupId = select.dataset.groupId;
3107
3517
  if (groupId && activeTabs[groupId]) {
@@ -3116,8 +3526,8 @@ ${TAB_STYLES}
3116
3526
  }
3117
3527
  return TabManager.areNavsVisible(document.body);
3118
3528
  })();
3119
- const tabNavToggle = this.modal.querySelector('.cv-nav-pref-input');
3120
- const navIcon = this.modal?.querySelector('#cv-nav-icon');
3529
+ const tabNavToggle = this.stateModal.querySelector('.cv-nav-pref-input');
3530
+ const navIcon = this.stateModal?.querySelector('#cv-nav-icon');
3121
3531
  if (tabNavToggle) {
3122
3532
  tabNavToggle.checked = navPref;
3123
3533
  // Ensure UI matches actual visibility
@@ -3128,33 +3538,22 @@ ${TAB_STYLES}
3128
3538
  }
3129
3539
  }
3130
3540
  }
3131
- /**
3132
- * Format toggle name for display
3133
- */
3134
- formatToggleName(toggle) {
3135
- return toggle.charAt(0).toUpperCase() + toggle.slice(1);
3136
- }
3137
3541
  /**
3138
3542
  * Check if this is the first visit and show welcome modal
3139
3543
  */
3140
3544
  showWelcomeModalIfFirstVisit() {
3545
+ if (!this._hasVisibleConfig)
3546
+ return;
3141
3547
  const STORAGE_KEY = 'cv-welcome-shown';
3142
3548
  // Check if welcome has been shown before
3143
3549
  const hasSeenWelcome = localStorage.getItem(STORAGE_KEY);
3144
3550
  if (!hasSeenWelcome) {
3145
- // Check if this page has any custom views elements
3146
- const hasCustomViewElements = document.querySelector('cv-tabgroup') !== null ||
3147
- document.querySelector('cv-tab') !== null ||
3148
- document.querySelector('cv-toggle') !== null ||
3149
- document.querySelector('[data-cv-toggle]') !== null;
3150
- if (hasCustomViewElements) {
3151
- // Show welcome modal after a short delay to let the page settle
3152
- setTimeout(() => {
3153
- this.createWelcomeModal();
3154
- }, 500);
3155
- // Mark as shown
3156
- localStorage.setItem(STORAGE_KEY, 'true');
3157
- }
3551
+ // Show welcome modal after a short delay to let the page settle
3552
+ setTimeout(() => {
3553
+ this.createWelcomeModal();
3554
+ }, 500);
3555
+ // Mark as shown
3556
+ localStorage.setItem(STORAGE_KEY, 'true');
3158
3557
  }
3159
3558
  }
3160
3559
  /**
@@ -3162,62 +3561,63 @@ ${TAB_STYLES}
3162
3561
  */
3163
3562
  createWelcomeModal() {
3164
3563
  // Don't show if there's already a modal open
3165
- if (this.modal)
3564
+ if (this.stateModal && !this.stateModal.classList.contains('cv-hidden'))
3166
3565
  return;
3167
- this.modal = document.createElement('div');
3168
- this.modal.className = 'cv-widget-modal-overlay cv-welcome-modal-overlay';
3169
- this.applyThemeToModal();
3170
- this.modal.innerHTML = `
3171
- <div class="cv-widget-modal cv-welcome-modal">
3172
- <header class="cv-modal-header">
3173
- <div class="cv-modal-header-content">
3174
- <div class="cv-modal-icon">
3175
- ${getGearIcon()}
3176
- </div>
3177
- <h1 class="cv-modal-title">${this.options.welcomeTitle}</h1>
3178
- </div>
3179
- </header>
3180
- <div class="cv-modal-main">
3181
- <p class="cv-welcome-message">${this.options.welcomeMessage}</p>
3182
-
3183
- <div class="cv-welcome-widget-preview">
3184
- <div class="cv-welcome-widget-icon">
3185
- ${getGearIcon()}
3186
- </div>
3187
- <p class="cv-welcome-widget-label">Look for this widget</p>
3188
- </div>
3189
-
3190
- <button class="cv-welcome-got-it">Got it!</button>
3191
- </div>
3192
- </div>
3566
+ const welcomeModal = document.createElement('div');
3567
+ welcomeModal.className = 'cv-widget-modal-overlay cv-welcome-modal-overlay';
3568
+ if (this.options.theme === 'dark') {
3569
+ welcomeModal.classList.add('cv-widget-theme-dark');
3570
+ }
3571
+ welcomeModal.innerHTML = `
3572
+ <div class="cv-widget-modal cv-welcome-modal">
3573
+ <header class="cv-modal-header">
3574
+ <div class="cv-modal-header-content">
3575
+ <div class="cv-modal-icon">
3576
+ ${getGearIcon()}
3577
+ </div>
3578
+ <h1 class="cv-modal-title">${this.options.welcomeTitle}</h1>
3579
+ </div>
3580
+ </header>
3581
+ <div class="cv-modal-main">
3582
+ <p class="cv-welcome-message">${this.options.welcomeMessage}</p>
3583
+
3584
+ <div class="cv-welcome-widget-preview">
3585
+ <div class="cv-welcome-widget-icon">
3586
+ ${getGearIcon()}
3587
+ </div>
3588
+ <p class="cv-welcome-widget-label">Look for this widget</p>
3589
+ </div>
3590
+
3591
+ <button class="cv-welcome-got-it">Got it!</button>
3592
+ </div>
3593
+ </div>
3193
3594
  `;
3194
- document.body.appendChild(this.modal);
3195
- this.attachWelcomeModalEventListeners();
3595
+ document.body.appendChild(welcomeModal);
3596
+ this.attachWelcomeModalEventListeners(welcomeModal);
3196
3597
  }
3197
3598
  /**
3198
3599
  * Attach event listeners for welcome modal
3199
3600
  */
3200
- attachWelcomeModalEventListeners() {
3201
- if (!this.modal)
3202
- return;
3601
+ attachWelcomeModalEventListeners(welcomeModal) {
3602
+ const closeModal = () => {
3603
+ welcomeModal.remove();
3604
+ document.removeEventListener('keydown', handleEscape);
3605
+ };
3203
3606
  // Got it button
3204
- const gotItBtn = this.modal.querySelector('.cv-welcome-got-it');
3607
+ const gotItBtn = welcomeModal.querySelector('.cv-welcome-got-it');
3205
3608
  if (gotItBtn) {
3206
- gotItBtn.addEventListener('click', () => {
3207
- this.closeModal();
3208
- });
3609
+ gotItBtn.addEventListener('click', closeModal);
3209
3610
  }
3210
3611
  // Overlay click to close
3211
- this.modal.addEventListener('click', (e) => {
3212
- if (e.target === this.modal) {
3213
- this.closeModal();
3612
+ welcomeModal.addEventListener('click', (e) => {
3613
+ if (e.target === welcomeModal) {
3614
+ closeModal();
3214
3615
  }
3215
3616
  });
3216
3617
  // Escape key to close
3217
3618
  const handleEscape = (e) => {
3218
3619
  if (e.key === 'Escape') {
3219
- this.closeModal();
3220
- document.removeEventListener('keydown', handleEscape);
3620
+ closeModal();
3221
3621
  }
3222
3622
  };
3223
3623
  document.addEventListener('keydown', handleEscape);
@@ -3287,7 +3687,7 @@ ${TAB_STYLES}
3287
3687
  console.warn(`[CustomViews] Config file not found at ${fullConfigPath}. Using defaults.`);
3288
3688
  // Provide minimal default config structure
3289
3689
  configFile = {
3290
- config: { allToggles: [], defaultState: {} },
3690
+ config: { toggles: [], defaultState: {} },
3291
3691
  widget: { enabled: true }
3292
3692
  };
3293
3693
  }
@@ -3325,7 +3725,7 @@ ${TAB_STYLES}
3325
3725
  core,
3326
3726
  ...configFile.widget
3327
3727
  });
3328
- widget.render();
3728
+ widget.renderModalIcon();
3329
3729
  // Store widget instance
3330
3730
  window.customViewsInstance.widget = widget;
3331
3731
  console.log('[CustomViews] Widget initialized and rendered');