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