@customviews-js/customviews 1.1.4 → 1.1.6

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @customviews-js/customviews v1.1.4
2
+ * @customviews-js/customviews v1.1.6
3
3
  * (c) 2025 Chan Ger Teck
4
4
  * Released under the MIT License.
5
5
  */
@@ -370,10 +370,17 @@ const TABGROUP_SELECTOR = 'cv-tabgroup';
370
370
  const TAB_SELECTOR = 'cv-tab';
371
371
  const NAV_AUTO_SELECTOR = 'cv-tabgroup[nav="auto"], cv-tabgroup:not([nav])';
372
372
  const NAV_CONTAINER_CLASS = 'cv-tabs-nav';
373
- /**
374
- * TabManager handles discovery, visibility, and navigation for tab groups and tabs
375
- */
373
+ const NAV_HIDE_ROOT_CLASS = 'cv-hide-tab-navs';
374
+ const NAV_HIDDEN_CLASS = 'cv-tabs-nav-hidden';
376
375
  class TabManager {
376
+ /**
377
+ * Split a tab ID into multiple IDs if it contains spaces or |
378
+ */
379
+ static splitTabIds(tabId) {
380
+ const splitIds = tabId.split(/[\s|]+/).filter(id => id.trim() !== '');
381
+ const trimmedIds = splitIds.map(id => id.trim());
382
+ return trimmedIds;
383
+ }
377
384
  /**
378
385
  * Apply tab selections to all tab groups in the DOM
379
386
  */
@@ -385,22 +392,26 @@ class TabManager {
385
392
  if (!groupId)
386
393
  return;
387
394
  // Determine the active tab for this group
388
- const activeTabId = this.resolveActiveTab(groupId, tabs, cfgGroups, groupEl);
395
+ const activeTabId = this.resolveActiveTabForGroup(groupId, tabs, cfgGroups, groupEl);
389
396
  // Apply visibility to direct child cv-tab elements only (not nested ones)
390
397
  const tabElements = Array.from(groupEl.children).filter((child) => child.tagName.toLowerCase() === TAB_SELECTOR);
391
398
  tabElements.forEach((tabEl) => {
392
399
  const tabId = tabEl.getAttribute('id');
393
400
  if (!tabId)
394
401
  return;
395
- const isActive = tabId === activeTabId;
402
+ // Split IDs and check if any match the active tab
403
+ const splitIds = this.splitTabIds(tabId);
404
+ const isActive = splitIds.includes(activeTabId || '');
396
405
  this.applyTabVisibility(tabEl, isActive);
397
406
  });
398
407
  });
399
408
  }
400
409
  /**
401
410
  * Resolve the active tab for a group based on state, config, and DOM
411
+ *
412
+ * Pass in the current tabs state, config groups, and the group element
402
413
  */
403
- static resolveActiveTab(groupId, tabs, cfgGroups, groupEl) {
414
+ static resolveActiveTabForGroup(groupId, tabs, cfgGroups, groupEl) {
404
415
  // 1. Check state
405
416
  if (tabs[groupId]) {
406
417
  return tabs[groupId];
@@ -422,7 +433,8 @@ class TabManager {
422
433
  // 3. Fallback to first direct cv-tab child in DOM
423
434
  const firstTab = Array.from(groupEl.children).find((child) => child.tagName.toLowerCase() === TAB_SELECTOR);
424
435
  if (firstTab) {
425
- return firstTab.getAttribute('id');
436
+ const splitIds = this.splitTabIds(firstTab.getAttribute('id') || '');
437
+ return splitIds[0] || null;
426
438
  }
427
439
  return null;
428
440
  }
@@ -442,7 +454,7 @@ class TabManager {
442
454
  /**
443
455
  * Build navigation for tab groups with nav="auto" (one-time setup)
444
456
  */
445
- static buildNavs(rootEl, cfgGroups, onTabClick) {
457
+ static buildNavs(rootEl, cfgGroups, onTabClick, onTabDoubleClick) {
446
458
  // Find all cv-tabgroup elements with nav="auto" or no nav attribute
447
459
  const tabGroups = rootEl.querySelectorAll(NAV_AUTO_SELECTOR);
448
460
  // Check if any tab headers contain Font Awesome shortcodes
@@ -453,11 +465,14 @@ class TabManager {
453
465
  if (!groupId)
454
466
  return;
455
467
  const tabElements = Array.from(groupEl.children).filter((child) => child.tagName.toLowerCase() === 'cv-tab');
468
+ // Check for Font Awesome shortcodes in tab headers
456
469
  tabElements.forEach((tabEl) => {
457
- const tabId = tabEl.getAttribute('id');
458
- if (!tabId)
470
+ const rawTabId = tabEl.getAttribute('id');
471
+ if (!rawTabId)
459
472
  return;
460
- const header = tabEl.getAttribute('header') || this.getTabLabel(tabId, groupId, cfgGroups) || tabId;
473
+ const splitIds = this.splitTabIds(rawTabId);
474
+ const tabId = splitIds[0] || rawTabId;
475
+ const header = tabEl.getAttribute('header') || this.getTabLabel(tabId, groupId, cfgGroups) || tabId || '';
461
476
  if (/:fa-[\w-]+:/.test(header)) {
462
477
  hasFontAwesomeShortcodes = true;
463
478
  }
@@ -483,25 +498,49 @@ class TabManager {
483
498
  navContainer = document.createElement('ul');
484
499
  navContainer.className = `${NAV_CONTAINER_CLASS} nav-tabs`;
485
500
  navContainer.setAttribute('role', 'tablist');
501
+ // Respect viewer preference on the root to show/hide navs
502
+ const showNavs = !rootEl.classList.contains(NAV_HIDE_ROOT_CLASS);
503
+ if (!showNavs) {
504
+ navContainer.classList.add(NAV_HIDDEN_CLASS);
505
+ navContainer.setAttribute('aria-hidden', 'true');
506
+ }
507
+ else {
508
+ navContainer.setAttribute('aria-hidden', 'false');
509
+ }
486
510
  groupEl.insertBefore(navContainer, groupEl.firstChild);
487
511
  // Build nav items
488
512
  tabElements.forEach((tabEl) => {
489
- const tabId = tabEl.getAttribute('id');
490
- if (!tabId)
513
+ const rawTabId = tabEl.getAttribute('id');
514
+ if (!rawTabId)
491
515
  return;
492
- const header = tabEl.getAttribute('header') || this.getTabLabel(tabId, groupId, cfgGroups) || tabId;
516
+ const splitIds = this.splitTabIds(rawTabId);
517
+ // If multiple IDs, use the first as primary
518
+ const tabId = splitIds[0] || rawTabId;
519
+ // Get header for this tab (single header, not multiple)
520
+ const headerAttr = tabEl.getAttribute('header') || '';
521
+ let header = '';
522
+ if (headerAttr) {
523
+ // Single header provided on the element
524
+ header = headerAttr;
525
+ }
526
+ else {
527
+ // Use config label or id as fallback
528
+ header = this.getTabLabel(tabId, groupId, cfgGroups) || tabId || '';
529
+ }
530
+ // Create a single nav link for this tab element
493
531
  const listItem = document.createElement('li');
494
532
  listItem.className = 'nav-item';
495
533
  const navLink = document.createElement('a');
496
534
  navLink.className = 'nav-link';
497
- // Replace icon shortcodes in header
498
535
  navLink.innerHTML = replaceIconShortcodes(header);
499
536
  navLink.href = '#';
500
537
  navLink.setAttribute('data-tab-id', tabId);
538
+ navLink.setAttribute('data-raw-tab-id', rawTabId);
501
539
  navLink.setAttribute('data-group-id', groupId);
502
540
  navLink.setAttribute('role', 'tab');
503
- // Check if this tab is currently active
504
- const isActive = tabEl.classList.contains('cv-visible');
541
+ // Check if any of the split IDs is active
542
+ const activeTabId = this.resolveActiveTabForGroup(groupId, {}, cfgGroups, groupEl); // Pass empty tabs for initial state
543
+ const isActive = splitIds.includes(activeTabId || '');
505
544
  if (isActive) {
506
545
  navLink.classList.add('active');
507
546
  navLink.setAttribute('aria-selected', 'true');
@@ -509,13 +548,24 @@ class TabManager {
509
548
  else {
510
549
  navLink.setAttribute('aria-selected', 'false');
511
550
  }
512
- // Add click handler
551
+ // Add click handler for local tab switch (if split id, switches to default first ID)
513
552
  if (onTabClick) {
514
553
  navLink.addEventListener('click', (e) => {
515
554
  e.preventDefault();
516
- onTabClick(groupId, tabId);
555
+ // console.log("Single-click detected");
556
+ onTabClick(groupId, tabId, groupEl);
557
+ });
558
+ }
559
+ // Add double-click handler for sync
560
+ if (onTabDoubleClick) {
561
+ navLink.addEventListener('dblclick', (e) => {
562
+ e.preventDefault();
563
+ // console.log("Double-click detected");
564
+ onTabDoubleClick(groupId, tabId, groupEl);
517
565
  });
518
566
  }
567
+ // Add tooltip for UX feedback (use native title attribute)
568
+ navLink.setAttribute('title', 'Double click to change switch tabs across all groups');
519
569
  listItem.appendChild(navLink);
520
570
  navContainer.appendChild(listItem);
521
571
  });
@@ -525,6 +575,44 @@ class TabManager {
525
575
  groupEl.appendChild(bottomBorder);
526
576
  });
527
577
  }
578
+ /**
579
+ * Toggle nav visibility for all tab groups (viewer-controlled)
580
+ */
581
+ static setNavsVisibility(rootEl, visible) {
582
+ if (visible) {
583
+ rootEl.classList.remove(NAV_HIDE_ROOT_CLASS);
584
+ }
585
+ else {
586
+ rootEl.classList.add(NAV_HIDE_ROOT_CLASS);
587
+ }
588
+ const navContainers = rootEl.querySelectorAll(`.${NAV_CONTAINER_CLASS}`);
589
+ navContainers.forEach((nav) => {
590
+ if (visible) {
591
+ nav.classList.remove(NAV_HIDDEN_CLASS);
592
+ nav.setAttribute('aria-hidden', 'false');
593
+ }
594
+ else {
595
+ nav.classList.add(NAV_HIDDEN_CLASS);
596
+ nav.setAttribute('aria-hidden', 'true');
597
+ }
598
+ });
599
+ // Also hide/show the bottom border of tab groups
600
+ const bottomBorders = rootEl.querySelectorAll('.cv-tabgroup-bottom-border');
601
+ bottomBorders.forEach((border) => {
602
+ if (visible) {
603
+ border.classList.remove('cv-hidden');
604
+ }
605
+ else {
606
+ border.classList.add('cv-hidden');
607
+ }
608
+ });
609
+ }
610
+ /**
611
+ * Read current nav visibility (viewer preference)
612
+ */
613
+ static areNavsVisible(rootEl) {
614
+ return !rootEl.classList.contains(NAV_HIDE_ROOT_CLASS);
615
+ }
528
616
  /**
529
617
  * Get tab label from config
530
618
  */
@@ -538,23 +626,25 @@ class TabManager {
538
626
  return tabCfg?.label || null;
539
627
  }
540
628
  /**
541
- * Update active state in navs after selection change (single group)
629
+ * Update active state in navs for a specific tabgroup element only
542
630
  */
543
- static updateNavActiveState(rootEl, groupId, activeTabId) {
544
- const tabGroups = rootEl.querySelectorAll(`${TABGROUP_SELECTOR}[id="${groupId}"]`);
545
- tabGroups.forEach((groupEl) => {
546
- const navLinks = groupEl.querySelectorAll('.nav-link');
547
- navLinks.forEach((link) => {
548
- const tabId = link.getAttribute('data-tab-id');
549
- if (tabId === activeTabId) {
550
- link.classList.add('active');
551
- link.setAttribute('aria-selected', 'true');
552
- }
553
- else {
554
- link.classList.remove('active');
555
- link.setAttribute('aria-selected', 'false');
556
- }
557
- });
631
+ static updateNavActiveState(groupEl, activeTabId) {
632
+ const navLinks = groupEl.querySelectorAll('.nav-link');
633
+ navLinks.forEach((link) => {
634
+ const rawTabId = link.getAttribute('data-raw-tab-id');
635
+ if (!rawTabId)
636
+ return;
637
+ // Check if activeTabId is in the split IDs of this link
638
+ const splitIds = this.splitTabIds(rawTabId);
639
+ const isActive = splitIds.includes(activeTabId);
640
+ if (isActive) {
641
+ link.classList.add('active');
642
+ link.setAttribute('aria-selected', 'true');
643
+ }
644
+ else {
645
+ link.classList.remove('active');
646
+ link.setAttribute('aria-selected', 'false');
647
+ }
558
648
  });
559
649
  }
560
650
  /**
@@ -567,14 +657,19 @@ class TabManager {
567
657
  if (!groupId)
568
658
  return;
569
659
  // Determine the active tab for this group
570
- const activeTabId = this.resolveActiveTab(groupId, tabs, cfgGroups, groupEl);
660
+ const activeTabId = this.resolveActiveTabForGroup(groupId, tabs, cfgGroups, groupEl);
571
661
  if (!activeTabId)
572
662
  return;
573
663
  // Update nav links for this group
574
664
  const navLinks = groupEl.querySelectorAll('.nav-link');
575
665
  navLinks.forEach((link) => {
576
- const tabId = link.getAttribute('data-tab-id');
577
- if (tabId === activeTabId) {
666
+ const rawTabId = link.getAttribute('data-raw-tab-id');
667
+ if (!rawTabId)
668
+ return;
669
+ // Check if activeTabId is in the split IDs of this link
670
+ const splitIds = this.splitTabIds(rawTabId);
671
+ const isActive = splitIds.includes(activeTabId);
672
+ if (isActive) {
578
673
  link.classList.add('active');
579
674
  link.setAttribute('aria-selected', 'true');
580
675
  }
@@ -585,6 +680,47 @@ class TabManager {
585
680
  });
586
681
  });
587
682
  }
683
+ /**
684
+ * Apply tab selection to a specific tabgroup element only (not globally).
685
+ * Used for single-click behavior to update only the clicked tabgroup.
686
+ */
687
+ static applyTabLocalOnly(groupEl, activeTabId) {
688
+ const tabElements = Array.from(groupEl.children).filter((child) => child.tagName.toLowerCase() === TAB_SELECTOR);
689
+ tabElements.forEach((tabEl) => {
690
+ const tabId = tabEl.getAttribute('id');
691
+ if (!tabId)
692
+ return;
693
+ const splitIds = this.splitTabIds(tabId);
694
+ const isActive = splitIds.includes(activeTabId);
695
+ this.applyTabVisibility(tabEl, isActive);
696
+ });
697
+ }
698
+ /**
699
+ * Check if a tabgroup element contains a specific tab ID (respects split IDs).
700
+ * Accepts groupEl to avoid repeated DOM queries.
701
+ */
702
+ static groupHasTab(groupEl, tabId) {
703
+ const tabElements = Array.from(groupEl.children).filter((child) => child.tagName.toLowerCase() === TAB_SELECTOR);
704
+ return tabElements.some((tabEl) => {
705
+ const idAttr = tabEl.getAttribute('id') || '';
706
+ const splitIds = this.splitTabIds(idAttr);
707
+ return splitIds.includes(tabId);
708
+ });
709
+ }
710
+ /**
711
+ * Returns array of group elements to be synced (excluding source).
712
+ */
713
+ static getTabgroupsWithId(rootEl, sourceGroupId, tabId) {
714
+ const syncedGroupEls = [];
715
+ const allGroupEls = Array.from(rootEl.querySelectorAll(`${TABGROUP_SELECTOR}[id="${sourceGroupId}"]`));
716
+ allGroupEls.forEach((targetGroupEl) => {
717
+ // Only sync if target group actually contains this tab
718
+ if (this.groupHasTab(targetGroupEl, tabId)) {
719
+ syncedGroupEls.push(targetGroupEl);
720
+ }
721
+ });
722
+ return syncedGroupEls;
723
+ }
588
724
  }
589
725
 
590
726
  class AssetsManager {
@@ -700,154 +836,166 @@ class ToggleManager {
700
836
  /**
701
837
  * Styles for toggle visibility and animations
702
838
  */
703
- const TOGGLE_STYLES = `
704
- /* Core toggle visibility transitions */
705
- [data-cv-toggle], [data-customviews-toggle], cv-toggle {
706
- transition: opacity 150ms ease,
707
- transform 150ms ease,
708
- max-height 200ms ease,
709
- margin 150ms ease;
710
- will-change: opacity, transform, max-height, margin;
711
- }
712
-
713
- .cv-visible {
714
- opacity: 1 !important;
715
- transform: translateY(0) !important;
716
- max-height: var(--cv-max-height, 9999px) !important;
717
- }
718
-
719
- .cv-hidden {
720
- opacity: 0 !important;
721
- transform: translateY(-4px) !important;
722
- pointer-events: none !important;
723
- padding-top: 0 !important;
724
- padding-bottom: 0 !important;
725
- border-top-width: 0 !important;
726
- border-bottom-width: 0 !important;
727
- max-height: 0 !important;
728
- margin-top: 0 !important;
729
- margin-bottom: 0 !important;
730
- overflow: hidden !important;
731
- }
839
+ const TOGGLE_STYLES = `
840
+ /* Core toggle visibility transitions */
841
+ [data-cv-toggle], [data-customviews-toggle], cv-toggle {
842
+ transition: opacity 150ms ease,
843
+ transform 150ms ease,
844
+ max-height 200ms ease,
845
+ margin 150ms ease;
846
+ will-change: opacity, transform, max-height, margin;
847
+ }
848
+
849
+ .cv-visible {
850
+ opacity: 1 !important;
851
+ transform: translateY(0) !important;
852
+ max-height: var(--cv-max-height, 9999px) !important;
853
+ }
854
+
855
+ .cv-hidden {
856
+ opacity: 0 !important;
857
+ transform: translateY(-4px) !important;
858
+ pointer-events: none !important;
859
+ padding-top: 0 !important;
860
+ padding-bottom: 0 !important;
861
+ border-top-width: 0 !important;
862
+ border-bottom-width: 0 !important;
863
+ max-height: 0 !important;
864
+ margin-top: 0 !important;
865
+ margin-bottom: 0 !important;
866
+ overflow: hidden !important;
867
+ }
732
868
  `;
733
869
 
734
870
  /**
735
871
  * Styles for tab groups and tab navigation
736
872
  */
737
- const TAB_STYLES = `
738
- /* Tab navigation styles - Bootstrap-style tabs matching MarkBind */
739
- .cv-tabs-nav {
740
- display: flex;
741
- flex-wrap: wrap;
742
- padding-left: 0;
743
- margin-top: 0.5rem;
744
- margin-bottom: 1rem;
745
- list-style: none;
746
- border-bottom: 1px solid #dee2e6;
747
- }
748
-
749
- .cv-tabs-nav .nav-item {
750
- margin-bottom: -1px;
751
- list-style: none;
752
- display: inline-block;
753
- }
754
-
755
- .cv-tabs-nav .nav-link {
756
- display: block;
757
- padding: 0.5rem 1rem;
758
- color: #495057;
759
- text-decoration: none;
760
- background-color: transparent;
761
- border: 1px solid transparent;
762
- border-top-left-radius: 0.25rem;
763
- border-top-right-radius: 0.25rem;
764
- transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
765
- cursor: pointer;
766
- }
767
-
768
- .cv-tabs-nav .nav-link:hover,
769
- .cv-tabs-nav .nav-link:focus {
770
- border-color: #e9ecef #e9ecef #dee2e6;
771
- isolation: isolate;
772
- }
773
-
774
- .cv-tabs-nav .nav-link.active {
775
- color: #495057;
776
- background-color: #fff;
777
- border-color: #dee2e6 #dee2e6 #fff;
778
- }
779
-
780
- .cv-tabs-nav .nav-link:focus {
781
- outline: 0;
782
- box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
783
- }
784
-
785
- /* Legacy button-based nav (deprecated, kept for compatibility) */
786
- .cv-tabs-nav-item {
787
- background: none;
788
- border: none;
789
- border-bottom: 2px solid transparent;
790
- padding: 0.5rem 1rem;
791
- cursor: pointer;
792
- font-size: 1rem;
793
- color: #6c757d;
794
- transition: color 150ms ease, border-color 150ms ease;
795
- }
796
-
797
- .cv-tabs-nav-item:hover {
798
- color: #495057;
799
- border-bottom-color: #dee2e6;
800
- }
801
-
802
- .cv-tabs-nav-item.active {
803
- color: #007bff;
804
- border-bottom-color: #007bff;
805
- font-weight: 500;
806
- }
807
-
808
- .cv-tabs-nav-item:focus {
809
- outline: 2px solid #007bff;
810
- outline-offset: 2px;
811
- }
812
-
813
- /* Tab panel base styles */
814
- cv-tab {
815
- display: block;
816
- }
817
-
818
- /* Override visibility for tab panels - use display instead of collapse animation */
819
- cv-tab.cv-hidden {
820
- display: none !important;
821
- }
822
-
823
- cv-tab.cv-visible {
824
- display: block !important;
825
- }
826
-
827
- cv-tabgroup {
828
- display: block;
829
- margin-bottom: 1.5rem;
830
- }
831
-
832
- /* Bottom border line for tab groups */
833
- .cv-tabgroup-bottom-border {
834
- border-bottom: 1px solid #dee2e6;
835
- margin-top: 1rem;
836
- }
837
-
838
- /* Tab content wrapper */
839
- .cv-tab-content {
840
- padding: 1rem 0;
841
- }
873
+ const TAB_STYLES = `
874
+ /* Tab navigation styles - Bootstrap-style tabs matching MarkBind */
875
+ .cv-tabs-nav {
876
+ display: flex;
877
+ flex-wrap: wrap;
878
+ padding-left: 0;
879
+ margin-top: 0.5rem;
880
+ margin-bottom: 1rem;
881
+ list-style: none;
882
+ border-bottom: 1px solid #dee2e6;
883
+ }
884
+
885
+ .cv-tabs-nav .nav-item {
886
+ margin-bottom: -1px;
887
+ list-style: none;
888
+ display: inline-block;
889
+ }
890
+
891
+ .cv-tabs-nav .nav-link {
892
+ display: block;
893
+ padding: 0.5rem 1rem;
894
+ color: #495057;
895
+ text-decoration: none;
896
+ background-color: transparent;
897
+ border: 1px solid transparent;
898
+ border-top-left-radius: 0.25rem;
899
+ border-top-right-radius: 0.25rem;
900
+ transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
901
+ cursor: pointer;
902
+ }
903
+
904
+ .cv-tabs-nav .nav-link:hover,
905
+ .cv-tabs-nav .nav-link:focus {
906
+ border-color: #e9ecef #e9ecef #dee2e6;
907
+ isolation: isolate;
908
+ }
909
+
910
+ .cv-tabs-nav .nav-link.active {
911
+ color: #495057;
912
+ background-color: #fff;
913
+ border-color: #dee2e6 #dee2e6 #fff;
914
+ }
915
+
916
+ .cv-tabs-nav .nav-link:focus {
917
+ outline: 0;
918
+ box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
919
+ }
920
+
921
+ /* Legacy button-based nav (deprecated, kept for compatibility) */
922
+ .cv-tabs-nav-item {
923
+ background: none;
924
+ border: none;
925
+ border-bottom: 2px solid transparent;
926
+ padding: 0.5rem 1rem;
927
+ cursor: pointer;
928
+ font-size: 1rem;
929
+ color: #6c757d;
930
+ transition: color 150ms ease, border-color 150ms ease;
931
+ }
932
+
933
+ .cv-tabs-nav-item:hover {
934
+ color: #495057;
935
+ border-bottom-color: #dee2e6;
936
+ }
937
+
938
+ .cv-tabs-nav-item.active {
939
+ color: #007bff;
940
+ border-bottom-color: #007bff;
941
+ font-weight: 500;
942
+ }
943
+
944
+ .cv-tabs-nav-item:focus {
945
+ outline: 2px solid #007bff;
946
+ outline-offset: 2px;
947
+ }
948
+
949
+ /* Tab panel base styles */
950
+ cv-tab {
951
+ display: block;
952
+ }
953
+
954
+ /* Override visibility for tab panels - use display instead of collapse animation */
955
+ cv-tab.cv-hidden {
956
+ display: none !important;
957
+ }
958
+
959
+ cv-tab.cv-visible {
960
+ display: block !important;
961
+ }
962
+
963
+ cv-tabgroup {
964
+ display: block;
965
+ margin-bottom: 1.5rem;
966
+ }
967
+
968
+ /* Bottom border line for tab groups */
969
+ .cv-tabgroup-bottom-border {
970
+ border-bottom: 1px solid #dee2e6;
971
+ margin-top: 1rem;
972
+ }
973
+
974
+ /* Tab content wrapper */
975
+ .cv-tab-content {
976
+ padding: 1rem 0;
977
+ }
978
+
979
+ /* Viewer-controlled nav visibility: hide nav containers when requested */
980
+ .cv-tabs-nav-hidden {
981
+ display: none !important;
982
+ }
983
+
984
+ /* Print-friendly: hide tab navigation when printing to reduce clutter */
985
+ @media print {
986
+ .cv-tabs-nav {
987
+ display: none !important;
988
+ }
989
+ }
842
990
  `;
843
991
 
844
992
  /**
845
993
  * Combined core styles for toggles and tabs
846
994
  */
847
- const CORE_STYLES = `
848
- ${TOGGLE_STYLES}
849
-
850
- ${TAB_STYLES}
995
+ const CORE_STYLES = `
996
+ ${TOGGLE_STYLES}
997
+
998
+ ${TAB_STYLES}
851
999
  `;
852
1000
  /**
853
1001
  * Add styles for hiding and showing toggles animations and transitions to the document head
@@ -906,33 +1054,51 @@ class CustomViewsCore {
906
1054
  /**
907
1055
  * Set active tab for a group and apply state
908
1056
  */
909
- setActiveTab(groupId, tabId) {
910
- // Get current state
911
- const currentToggles = this.getCurrentActiveToggles();
912
- const currentTabs = this.getCurrentActiveTabs();
913
- // Merge new tab selection
914
- const newTabs = { ...currentTabs, [groupId]: tabId };
915
- // Create new state
916
- const newState = {
917
- toggles: currentToggles,
918
- tabs: newTabs
919
- };
920
- // Apply the state
921
- this.applyState(newState);
922
- // Emit custom event
923
- const event = new CustomEvent('customviews:tab-change', {
924
- detail: { groupId, tabId },
925
- bubbles: true
926
- });
927
- document.dispatchEvent(event);
1057
+ setActiveTab(groupId, tabId, groupEl) {
1058
+ // If groupEl is provided, apply tab selection locally to just that element
1059
+ // Single-click: only updates DOM visually, no persistence
1060
+ if (groupEl) {
1061
+ TabManager.applyTabLocalOnly(groupEl, tabId);
1062
+ // Update nav active state for this group element only
1063
+ TabManager.updateNavActiveState(groupEl, tabId);
1064
+ // Emit custom event for local tab change
1065
+ const event = new CustomEvent('customviews:tab-change', {
1066
+ detail: { groupId, tabId, synced: false },
1067
+ bubbles: true
1068
+ });
1069
+ document.dispatchEvent(event);
1070
+ }
928
1071
  }
929
1072
  // Inject styles, setup listeners and call rendering logic
930
1073
  async init() {
931
1074
  injectCoreStyles();
932
- // Build navigation once (with click handlers)
933
- TabManager.buildNavs(this.rootEl, this.config.tabGroups, (groupId, tabId) => {
934
- this.setActiveTab(groupId, tabId);
1075
+ // Build navigation once (with click and double-click handlers)
1076
+ TabManager.buildNavs(this.rootEl, this.config.tabGroups,
1077
+ // Single click: update clicked group only (local, no persistence)
1078
+ (groupId, tabId, groupEl) => {
1079
+ this.setActiveTab(groupId, tabId, groupEl);
1080
+ },
1081
+ // Double click: sync across all tabgroups with same id (with persistence)
1082
+ (groupId, tabId, _groupEl) => {
1083
+ const currentTabs = this.getCurrentActiveTabs();
1084
+ currentTabs[groupId] = tabId;
1085
+ const currentToggles = this.getCurrentActiveToggles();
1086
+ const newState = {
1087
+ toggles: currentToggles,
1088
+ tabs: currentTabs
1089
+ };
1090
+ // applyState() will handle all visual updates via renderState()
1091
+ this.applyState(newState);
935
1092
  });
1093
+ // Apply stored nav visibility preference on page load
1094
+ try {
1095
+ const navPref = localStorage.getItem('cv-tab-navs-visible');
1096
+ if (navPref !== null) {
1097
+ const visible = navPref === 'true';
1098
+ TabManager.setNavsVisibility(this.rootEl, visible);
1099
+ }
1100
+ }
1101
+ catch (e) { /* ignore */ }
936
1102
  // For session history, clicks on back/forward button
937
1103
  window.addEventListener("popstate", () => {
938
1104
  this.loadAndCallApplyState();
@@ -1223,696 +1389,993 @@ class CustomViews {
1223
1389
  * Note: Styles are kept as a TypeScript string for compatibility with the build system.
1224
1390
  * This approach ensures the styles are properly bundled and don't require separate CSS file handling.
1225
1391
  */
1226
- const WIDGET_STYLES = `
1227
- /* Rounded rectangle widget icon styles */
1228
- .cv-widget-icon {
1229
- position: fixed;
1230
- /* Slightly transparent by default so the widget is subtle at the page edge */
1231
- background: rgba(255, 255, 255, 0.92);
1232
- color: rgba(0, 0, 0, 0.9);
1233
- opacity: 0.6;
1234
- display: flex;
1235
- align-items: center;
1236
- justify-content: center;
1237
- font-size: 18px;
1238
- font-weight: bold;
1239
- cursor: pointer;
1240
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
1241
- z-index: 9998;
1242
- transition: all 0.3s ease;
1243
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
1244
- }
1245
-
1246
- .cv-widget-icon:hover {
1247
- /* Become fully opaque on hover to improve readability */
1248
- background: rgba(255, 255, 255, 1);
1249
- color: rgba(0, 0, 0, 1);
1250
- opacity: 1;
1251
- }
1252
-
1253
- /* Top-right: rounded end on left, sticks out leftward on hover */
1254
- .cv-widget-top-right {
1255
- top: 20px;
1256
- right: 0;
1257
- border-radius: 18px 0 0 18px;
1258
- padding-left: 8px;
1259
- justify-content: flex-start;
1260
- }
1261
-
1262
- /* Top-left: rounded end on right, sticks out rightward on hover */
1263
- .cv-widget-top-left {
1264
- top: 20px;
1265
- left: 0;
1266
- border-radius: 0 18px 18px 0;
1267
- padding-right: 8px;
1268
- justify-content: flex-end;
1269
- }
1270
-
1271
- /* Bottom-right: rounded end on left, sticks out leftward on hover */
1272
- .cv-widget-bottom-right {
1273
- bottom: 20px;
1274
- right: 0;
1275
- border-radius: 18px 0 0 18px;
1276
- padding-left: 8px;
1277
- justify-content: flex-start;
1278
- }
1279
-
1280
- /* Bottom-left: rounded end on right, sticks out rightward on hover */
1281
- .cv-widget-bottom-left {
1282
- bottom: 20px;
1283
- left: 0;
1284
- border-radius: 0 18px 18px 0;
1285
- padding-right: 8px;
1286
- justify-content: flex-end;
1287
- }
1288
-
1289
- /* Middle-left: rounded end on right, sticks out rightward on hover */
1290
- .cv-widget-middle-left {
1291
- top: 50%;
1292
- left: 0;
1293
- transform: translateY(-50%);
1294
- border-radius: 0 18px 18px 0;
1295
- padding-right: 8px;
1296
- justify-content: flex-end;
1297
- }
1298
-
1299
- /* Middle-right: rounded end on left, sticks out leftward on hover */
1300
- .cv-widget-middle-right {
1301
- top: 50%;
1302
- right: 0;
1303
- transform: translateY(-50%);
1304
- border-radius: 18px 0 0 18px;
1305
- padding-left: 8px;
1306
- justify-content: flex-start;
1307
- }
1308
-
1309
- .cv-widget-top-right,
1310
- .cv-widget-middle-right,
1311
- .cv-widget-bottom-right,
1312
- .cv-widget-top-left,
1313
- .cv-widget-middle-left,
1314
- .cv-widget-bottom-left {
1315
- height: 36px;
1316
- width: 36px;
1317
- }
1318
-
1319
- .cv-widget-middle-right:hover,
1320
- .cv-widget-top-right:hover,
1321
- .cv-widget-bottom-right:hover,
1322
- .cv-widget-top-left:hover,
1323
- .cv-widget-middle-left:hover,
1324
- .cv-widget-bottom-left:hover {
1325
- width: 55px;
1326
- }
1327
-
1328
- /* Modal content styles */
1329
- .cv-widget-section {
1330
- margin-bottom: 16px;
1331
- }
1332
-
1333
- .cv-widget-section:last-child {
1334
- margin-bottom: 0;
1335
- }
1336
-
1337
- .cv-widget-section label {
1338
- display: block;
1339
- margin-bottom: 4px;
1340
- font-weight: 500;
1341
- color: #555;
1342
- }
1343
-
1344
- .cv-widget-profile-select,
1345
- .cv-widget-state-select {
1346
- width: 100%;
1347
- padding: 8px 12px;
1348
- border: 1px solid #ddd;
1349
- border-radius: 4px;
1350
- background: white;
1351
- font-size: 14px;
1352
- }
1353
-
1354
- .cv-widget-profile-select:focus,
1355
- .cv-widget-state-select:focus {
1356
- outline: none;
1357
- border-color: #007bff;
1358
- box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
1359
- }
1360
-
1361
- .cv-widget-profile-select:disabled,
1362
- .cv-widget-state-select:disabled {
1363
- background: #f8f9fa;
1364
- color: #6c757d;
1365
- cursor: not-allowed;
1366
- }
1367
-
1368
- .cv-widget-current {
1369
- margin: 16px 0;
1370
- padding: 12px;
1371
- background: #f8f9fa;
1372
- border-radius: 4px;
1373
- border-left: 4px solid #007bff;
1374
- }
1375
-
1376
- .cv-widget-current label {
1377
- font-size: 12px;
1378
- text-transform: uppercase;
1379
- letter-spacing: 0.5px;
1380
- color: #666;
1381
- margin-bottom: 4px;
1382
- }
1383
-
1384
- .cv-widget-current-view {
1385
- font-weight: 500;
1386
- color: #333;
1387
- }
1388
-
1389
- .cv-widget-reset {
1390
- width: 100%;
1391
- padding: 8px 16px;
1392
- background: #dc3545;
1393
- color: white;
1394
- border: none;
1395
- border-radius: 4px;
1396
- cursor: pointer;
1397
- font-size: 14px;
1398
- font-weight: 500;
1399
- }
1400
-
1401
- .cv-widget-reset:hover {
1402
- background: #c82333;
1403
- }
1404
-
1405
- .cv-widget-reset:active {
1406
- background: #bd2130;
1407
- }
1408
-
1409
- /* Responsive design for mobile */
1410
- @media (max-width: 768px) {
1411
- .cv-widget-top-right,
1412
- .cv-widget-top-left {
1413
- top: 10px;
1414
- }
1415
-
1416
- .cv-widget-bottom-right,
1417
- .cv-widget-bottom-left {
1418
- bottom: 10px;
1419
- }
1420
-
1421
- /* All widgets stay flush with screen edges */
1422
- .cv-widget-top-right,
1423
- .cv-widget-bottom-right,
1424
- .cv-widget-middle-right {
1425
- right: 0;
1426
- }
1427
-
1428
- .cv-widget-top-left,
1429
- .cv-widget-bottom-left,
1430
- .cv-widget-middle-left {
1431
- left: 0;
1432
- }
1433
-
1434
- /* Slightly smaller on mobile */
1435
- .cv-widget-icon {
1436
- width: 60px;
1437
- height: 32px;
1438
- }
1439
-
1440
- .cv-widget-icon:hover {
1441
- width: 75px;
1442
- }
1443
- }
1444
-
1445
- /* Modal styles */
1446
- .cv-widget-modal-overlay {
1447
- position: fixed;
1448
- top: 0;
1449
- left: 0;
1450
- right: 0;
1451
- bottom: 0;
1452
- background: rgba(0, 0, 0, 0.5);
1453
- display: flex;
1454
- align-items: center;
1455
- justify-content: center;
1456
- z-index: 10002;
1457
- animation: fadeIn 0.2s ease;
1458
- }
1459
-
1460
- @keyframes fadeIn {
1461
- from { opacity: 0; }
1462
- to { opacity: 1; }
1463
- }
1464
-
1465
- .cv-widget-modal {
1466
- background: white;
1467
- border-radius: 8px;
1468
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
1469
- max-width: 400px;
1470
- width: 90vw;
1471
- max-height: 80vh;
1472
- overflow-y: auto;
1473
- animation: slideIn 0.2s ease;
1474
- }
1475
-
1476
- @keyframes slideIn {
1477
- from {
1478
- opacity: 0;
1479
- transform: scale(0.9) translateY(-20px);
1480
- }
1481
- to {
1482
- opacity: 1;
1483
- transform: scale(1) translateY(0);
1484
- }
1485
- }
1486
-
1487
- .cv-widget-modal-header {
1488
- display: flex;
1489
- justify-content: space-between;
1490
- align-items: center;
1491
- padding: 16px 20px;
1492
- border-bottom: 1px solid #e9ecef;
1493
- background: #f8f9fa;
1494
- border-radius: 8px 8px 0 0;
1495
- }
1496
-
1497
- .cv-widget-modal-header h3 {
1498
- margin: 0;
1499
- font-size: 18px;
1500
- font-weight: 600;
1501
- color: #333;
1502
- }
1503
-
1504
- .cv-widget-modal-close {
1505
- background: none;
1506
- border: none;
1507
- font-size: 20px;
1508
- cursor: pointer;
1509
- padding: 0;
1510
- width: 32px;
1511
- height: 32px;
1512
- display: flex;
1513
- align-items: center;
1514
- justify-content: center;
1515
- border-radius: 4px;
1516
- color: #666;
1517
- line-height: 1;
1518
- transition: all 0.2s ease;
1519
- }
1520
-
1521
- .cv-widget-modal-close:hover {
1522
- background: #e9ecef;
1523
- color: #333;
1524
- }
1525
-
1526
- .cv-widget-modal-content {
1527
- padding: 20px;
1528
- }
1529
-
1530
- .cv-widget-modal-actions {
1531
- margin-top: 20px;
1532
- padding-top: 16px;
1533
- border-top: 1px solid #e9ecef;
1534
- }
1535
-
1536
- .cv-widget-restore {
1537
- width: 100%;
1538
- padding: 10px 16px;
1539
- background: #28a745;
1540
- color: white;
1541
- border: none;
1542
- border-radius: 4px;
1543
- cursor: pointer;
1544
- font-size: 14px;
1545
- font-weight: 500;
1546
- }
1547
-
1548
- .cv-widget-restore:hover {
1549
- background: #218838;
1550
- }
1551
-
1552
- .cv-widget-create-state {
1553
- width: 100%;
1554
- padding: 10px 16px;
1555
- background: #007bff;
1556
- color: white;
1557
- border: none;
1558
- border-radius: 4px;
1559
- cursor: pointer;
1560
- font-size: 14px;
1561
- font-weight: 500;
1562
- margin-bottom: 10px;
1563
- }
1564
-
1565
- .cv-widget-create-state:hover {
1566
- background: #0056b3;
1567
- }
1568
-
1569
- /* Dark theme modal styles */
1570
- .cv-widget-theme-dark .cv-widget-modal {
1571
- background: #2d3748;
1572
- color: #e2e8f0;
1573
- }
1574
-
1575
- .cv-widget-theme-dark .cv-widget-modal-header {
1576
- background: #1a202c;
1577
- border-color: #4a5568;
1578
- }
1579
-
1580
- .cv-widget-theme-dark .cv-widget-modal-header h3 {
1581
- color: #e2e8f0;
1582
- }
1583
-
1584
- .cv-widget-theme-dark .cv-widget-modal-close {
1585
- color: #a0aec0;
1586
- }
1587
-
1588
- .cv-widget-theme-dark .cv-widget-modal-close:hover {
1589
- background: #4a5568;
1590
- color: #e2e8f0;
1591
- }
1592
-
1593
- .cv-widget-theme-dark .cv-widget-modal-actions {
1594
- border-color: #4a5568;
1595
- }
1596
-
1597
- /* Custom state creator styles */
1598
- .cv-custom-state-modal {
1599
- max-width: 500px;
1600
- }
1601
-
1602
- .cv-custom-state-form h4 {
1603
- margin: 20px 0 10px 0;
1604
- font-size: 16px;
1605
- font-weight: 600;
1606
- color: #333;
1607
- border-bottom: 1px solid #e9ecef;
1608
- padding-bottom: 5px;
1609
- }
1610
-
1611
- .cv-custom-state-form p {
1612
- font-size: 15px;
1613
- line-height: 1.6;
1614
- color: #555;
1615
- margin-bottom: 24px;
1616
- text-align: justify;
1617
- }
1618
-
1619
- .cv-custom-state-section {
1620
- margin-bottom: 16px;
1621
- }
1622
-
1623
- .cv-custom-state-section label {
1624
- display: block;
1625
- margin-bottom: 4px;
1626
- font-weight: 500;
1627
- color: #555;
1628
- }
1629
-
1630
- .cv-custom-state-input {
1631
- width: 100%;
1632
- padding: 8px 12px;
1633
- border: 1px solid #ddd;
1634
- border-radius: 4px;
1635
- background: white;
1636
- font-size: 14px;
1637
- }
1638
-
1639
- .cv-custom-state-input:focus {
1640
- outline: none;
1641
- border-color: #007bff;
1642
- box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
1643
- }
1644
-
1645
- .cv-custom-toggles {
1646
- display: grid;
1647
- grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
1648
- gap: 10px;
1649
- }
1650
-
1651
- .cv-custom-state-toggle {
1652
- display: flex;
1653
- align-items: center;
1654
- }
1655
-
1656
- .cv-custom-state-toggle label {
1657
- display: flex;
1658
- align-items: center;
1659
- cursor: pointer;
1660
- font-weight: normal;
1661
- margin: 0;
1662
- }
1663
-
1664
- .cv-toggle-switch {
1665
- position: relative;
1666
- width: 44px;
1667
- height: 24px;
1668
- background: #ccc;
1669
- border-radius: 12px;
1670
- margin-right: 12px;
1671
- cursor: pointer;
1672
- transition: background-color 0.3s ease;
1673
- flex-shrink: 0;
1674
- }
1675
-
1676
- .cv-toggle-switch:hover {
1677
- background: #bbb;
1678
- }
1679
-
1680
- .cv-toggle-switch.cv-toggle-active {
1681
- background: #007bff;
1682
- }
1683
-
1684
- .cv-toggle-switch.cv-toggle-active:hover {
1685
- background: #0056b3;
1686
- }
1687
-
1688
- .cv-toggle-handle {
1689
- position: absolute;
1690
- top: 2px;
1691
- left: 2px;
1692
- width: 20px;
1693
- height: 20px;
1694
- background: white;
1695
- border-radius: 50%;
1696
- transition: transform 0.3s ease;
1697
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
1698
- }
1699
-
1700
- .cv-toggle-switch.cv-toggle-active .cv-toggle-handle {
1701
- transform: translateX(20px);
1702
- }
1703
-
1704
- /* Dark theme toggle switch styles */
1705
- .cv-widget-theme-dark .cv-toggle-switch {
1706
- background: #4a5568;
1707
- }
1708
-
1709
- .cv-widget-theme-dark .cv-toggle-switch:hover {
1710
- background: #5a6578;
1711
- }
1712
-
1713
- .cv-widget-theme-dark .cv-toggle-switch.cv-toggle-active {
1714
- background: #63b3ed;
1715
- }
1716
-
1717
- .cv-widget-theme-dark .cv-toggle-switch.cv-toggle-active:hover {
1718
- background: #4299e1;
1719
- }
1720
-
1721
- .cv-tab-groups {
1722
- margin-top: 20px;
1723
- }
1724
-
1725
- .cv-tab-group-control {
1726
- margin-bottom: 15px;
1727
- }
1728
-
1729
- .cv-tab-group-control label {
1730
- display: block;
1731
- margin-bottom: 5px;
1732
- font-weight: 500;
1733
- font-size: 14px;
1734
- }
1735
-
1736
- .cv-tab-group-select {
1737
- width: 100%;
1738
- padding: 8px 12px;
1739
- border: 1px solid #ced4da;
1740
- border-radius: 4px;
1741
- font-size: 14px;
1742
- background-color: white;
1743
- cursor: pointer;
1744
- }
1745
-
1746
- .cv-tab-group-select:focus {
1747
- outline: none;
1748
- border-color: #007bff;
1749
- box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
1750
- }
1751
-
1752
- .cv-widget-theme-dark .cv-tab-group-select {
1753
- background-color: #2d3748;
1754
- border-color: #4a5568;
1755
- color: #e2e8f0;
1756
- }
1757
-
1758
- .cv-custom-state-actions {
1759
- display: flex;
1760
- gap: 10px;
1761
- margin-top: 20px;
1762
- padding-top: 16px;
1763
- border-top: 1px solid #e9ecef;
1764
- }
1765
-
1766
- .cv-custom-state-cancel,
1767
- .cv-custom-state-copy-url {
1768
- flex: 1;
1769
- padding: 10px 16px;
1770
- border: none;
1771
- border-radius: 4px;
1772
- cursor: pointer;
1773
- font-size: 14px;
1774
- font-weight: 500;
1775
- }
1776
-
1777
- .cv-custom-state-reset {
1778
- flex: 1;
1779
- padding: 10px 16px;
1780
- border: none;
1781
- border-radius: 4px;
1782
- cursor: pointer;
1783
- font-size: 14px;
1784
- font-weight: 500;
1785
- background: #dc3545;
1786
- color: white;
1787
- }
1788
-
1789
- .cv-custom-state-reset:hover {
1790
- background: #c82333;
1791
- }
1792
-
1793
- .cv-custom-state-cancel {
1794
- background: #6c757d;
1795
- color: white;
1796
- }
1797
-
1798
- .cv-custom-state-cancel:hover {
1799
- background: #5a6268;
1800
- }
1801
-
1802
- .cv-custom-state-copy-url {
1803
- background: #28a745;
1804
- color: white;
1805
- }
1806
-
1807
- .cv-custom-state-copy-url:hover {
1808
- background: #218838;
1809
- }
1810
-
1811
- /* Dark theme custom state styles */
1812
- .cv-widget-theme-dark .cv-custom-state-form h4 {
1813
- color: #e2e8f0;
1814
- border-color: #4a5568;
1815
- }
1816
-
1817
- .cv-widget-theme-dark .cv-custom-state-form p {
1818
- color: #cbd5e0;
1819
- }
1820
-
1821
- .cv-widget-theme-dark .cv-custom-state-section label {
1822
- color: #a0aec0;
1823
- }
1824
-
1825
- .cv-widget-theme-dark .cv-custom-state-input {
1826
- background: #1a202c;
1827
- border-color: #4a5568;
1828
- color: #e2e8f0;
1829
- }
1830
-
1831
- .cv-widget-theme-dark .cv-custom-state-actions {
1832
- border-color: #4a5568;
1833
- }
1834
-
1835
- /* Welcome modal styles */
1836
- .cv-welcome-modal {
1837
- max-width: 500px;
1838
- }
1839
-
1840
- .cv-welcome-content {
1841
- text-align: center;
1842
- }
1843
-
1844
- .cv-welcome-content p {
1845
- font-size: 15px;
1846
- line-height: 1.6;
1847
- color: #555;
1848
- margin-bottom: 24px;
1849
- text-align: justify;
1850
- }
1851
-
1852
- .cv-welcome-widget-preview {
1853
- display: flex;
1854
- flex-direction: column;
1855
- align-items: center;
1856
- gap: 12px;
1857
- padding: 20px;
1858
- background: #f8f9fa;
1859
- border-radius: 8px;
1860
- margin-bottom: 24px;
1861
- }
1862
-
1863
- .cv-welcome-widget-icon {
1864
- width: 36px;
1865
- height: 36px;
1866
- background: white;
1867
- color: black;
1868
- border-radius: 0 18px 18px 0;
1869
- display: flex;
1870
- align-items: center;
1871
- justify-content: center;
1872
- font-size: 18px;
1873
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
1874
- }
1875
-
1876
- .cv-welcome-widget-label {
1877
- font-size: 14px;
1878
- color: #666;
1879
- margin: 0;
1880
- font-weight: 500;
1881
- }
1882
-
1883
- .cv-welcome-got-it {
1884
- width: 100%;
1885
- padding: 12px 24px;
1886
- background: #007bff;
1887
- color: white;
1888
- border: none;
1889
- border-radius: 4px;
1890
- cursor: pointer;
1891
- font-size: 16px;
1892
- font-weight: 600;
1893
- transition: background 0.2s ease;
1894
- }
1895
-
1896
- .cv-welcome-got-it:hover {
1897
- background: #0056b3;
1898
- }
1899
-
1900
- .cv-welcome-got-it:active {
1901
- background: #004494;
1902
- }
1903
-
1904
- /* Dark theme welcome modal styles */
1905
- .cv-widget-theme-dark .cv-welcome-content p {
1906
- color: #cbd5e0;
1907
- }
1908
-
1909
- .cv-widget-theme-dark .cv-welcome-widget-preview {
1910
- background: #1a202c;
1911
- }
1912
-
1913
- .cv-widget-theme-dark .cv-welcome-widget-label {
1914
- color: #a0aec0;
1915
- }
1392
+ const WIDGET_STYLES = `
1393
+ /* Rounded rectangle widget icon styles */
1394
+ .cv-widget-icon {
1395
+ position: fixed;
1396
+ /* Slightly transparent by default so the widget is subtle at the page edge */
1397
+ background: rgba(255, 255, 255, 0.92);
1398
+ color: rgba(0, 0, 0, 0.9);
1399
+ opacity: 0.6;
1400
+ display: flex;
1401
+ align-items: center;
1402
+ justify-content: center;
1403
+ font-size: 18px;
1404
+ font-weight: bold;
1405
+ cursor: pointer;
1406
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
1407
+ z-index: 9998;
1408
+ transition: all 0.3s ease;
1409
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
1410
+ }
1411
+
1412
+ .cv-widget-icon:hover {
1413
+ /* Become fully opaque on hover to improve readability */
1414
+ background: rgba(255, 255, 255, 1);
1415
+ color: rgba(0, 0, 0, 1);
1416
+ opacity: 1;
1417
+ }
1418
+
1419
+ /* Top-right: rounded end on left, sticks out leftward on hover */
1420
+ .cv-widget-top-right {
1421
+ top: 20px;
1422
+ right: 0;
1423
+ border-radius: 18px 0 0 18px;
1424
+ padding-left: 8px;
1425
+ justify-content: flex-start;
1426
+ }
1427
+
1428
+ /* Top-left: rounded end on right, sticks out rightward on hover */
1429
+ .cv-widget-top-left {
1430
+ top: 20px;
1431
+ left: 0;
1432
+ border-radius: 0 18px 18px 0;
1433
+ padding-right: 8px;
1434
+ justify-content: flex-end;
1435
+ }
1436
+
1437
+ /* Bottom-right: rounded end on left, sticks out leftward on hover */
1438
+ .cv-widget-bottom-right {
1439
+ bottom: 20px;
1440
+ right: 0;
1441
+ border-radius: 18px 0 0 18px;
1442
+ padding-left: 8px;
1443
+ justify-content: flex-start;
1444
+ }
1445
+
1446
+ /* Bottom-left: rounded end on right, sticks out rightward on hover */
1447
+ .cv-widget-bottom-left {
1448
+ bottom: 20px;
1449
+ left: 0;
1450
+ border-radius: 0 18px 18px 0;
1451
+ padding-right: 8px;
1452
+ justify-content: flex-end;
1453
+ }
1454
+
1455
+ /* Middle-left: rounded end on right, sticks out rightward on hover */
1456
+ .cv-widget-middle-left {
1457
+ top: 50%;
1458
+ left: 0;
1459
+ transform: translateY(-50%);
1460
+ border-radius: 0 18px 18px 0;
1461
+ padding-right: 8px;
1462
+ justify-content: flex-end;
1463
+ }
1464
+
1465
+ /* Middle-right: rounded end on left, sticks out leftward on hover */
1466
+ .cv-widget-middle-right {
1467
+ top: 50%;
1468
+ right: 0;
1469
+ transform: translateY(-50%);
1470
+ border-radius: 18px 0 0 18px;
1471
+ padding-left: 8px;
1472
+ justify-content: flex-start;
1473
+ }
1474
+
1475
+ .cv-widget-top-right,
1476
+ .cv-widget-middle-right,
1477
+ .cv-widget-bottom-right,
1478
+ .cv-widget-top-left,
1479
+ .cv-widget-middle-left,
1480
+ .cv-widget-bottom-left {
1481
+ height: 36px;
1482
+ width: 36px;
1483
+ }
1484
+
1485
+ .cv-widget-middle-right:hover,
1486
+ .cv-widget-top-right:hover,
1487
+ .cv-widget-bottom-right:hover,
1488
+ .cv-widget-top-left:hover,
1489
+ .cv-widget-middle-left:hover,
1490
+ .cv-widget-bottom-left:hover {
1491
+ width: 55px;
1492
+ }
1493
+
1494
+ /* Modal content styles */
1495
+ .cv-widget-section {
1496
+ margin-bottom: 16px;
1497
+ }
1498
+
1499
+ .cv-widget-section:last-child {
1500
+ margin-bottom: 0;
1501
+ }
1502
+
1503
+ .cv-widget-section label {
1504
+ display: block;
1505
+ margin-bottom: 4px;
1506
+ font-weight: 500;
1507
+ color: #555;
1508
+ }
1509
+
1510
+ .cv-widget-profile-select,
1511
+ .cv-widget-state-select {
1512
+ width: 100%;
1513
+ padding: 8px 12px;
1514
+ border: 1px solid #ddd;
1515
+ border-radius: 4px;
1516
+ background: white;
1517
+ font-size: 14px;
1518
+ }
1519
+
1520
+ .cv-widget-profile-select:focus,
1521
+ .cv-widget-state-select:focus {
1522
+ outline: none;
1523
+ border-color: #007bff;
1524
+ box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
1525
+ }
1526
+
1527
+ .cv-widget-profile-select:disabled,
1528
+ .cv-widget-state-select:disabled {
1529
+ background: #f8f9fa;
1530
+ color: #6c757d;
1531
+ cursor: not-allowed;
1532
+ }
1533
+
1534
+ .cv-widget-current {
1535
+ margin: 16px 0;
1536
+ padding: 12px;
1537
+ background: #f8f9fa;
1538
+ border-radius: 4px;
1539
+ border-left: 4px solid #007bff;
1540
+ }
1541
+
1542
+ .cv-widget-current label {
1543
+ font-size: 12px;
1544
+ text-transform: uppercase;
1545
+ letter-spacing: 0.5px;
1546
+ color: #666;
1547
+ margin-bottom: 4px;
1548
+ }
1549
+
1550
+ .cv-widget-current-view {
1551
+ font-weight: 500;
1552
+ color: #333;
1553
+ }
1554
+
1555
+ .cv-widget-reset {
1556
+ width: 100%;
1557
+ padding: 8px 16px;
1558
+ background: #dc3545;
1559
+ color: white;
1560
+ border: none;
1561
+ border-radius: 4px;
1562
+ cursor: pointer;
1563
+ font-size: 14px;
1564
+ font-weight: 500;
1565
+ }
1566
+
1567
+ .cv-widget-reset:hover {
1568
+ background: #c82333;
1569
+ }
1570
+
1571
+ .cv-widget-reset:active {
1572
+ background: #bd2130;
1573
+ }
1574
+
1575
+ /* Responsive design for mobile */
1576
+ @media (max-width: 768px) {
1577
+ .cv-widget-top-right,
1578
+ .cv-widget-top-left {
1579
+ top: 10px;
1580
+ }
1581
+
1582
+ .cv-widget-bottom-right,
1583
+ .cv-widget-bottom-left {
1584
+ bottom: 10px;
1585
+ }
1586
+
1587
+ /* All widgets stay flush with screen edges */
1588
+ .cv-widget-top-right,
1589
+ .cv-widget-bottom-right,
1590
+ .cv-widget-middle-right {
1591
+ right: 0;
1592
+ }
1593
+
1594
+ .cv-widget-top-left,
1595
+ .cv-widget-bottom-left,
1596
+ .cv-widget-middle-left {
1597
+ left: 0;
1598
+ }
1599
+
1600
+ /* Slightly smaller on mobile */
1601
+ .cv-widget-icon {
1602
+ width: 60px;
1603
+ height: 32px;
1604
+ }
1605
+
1606
+ .cv-widget-icon:hover {
1607
+ width: 75px;
1608
+ }
1609
+ }
1610
+
1611
+ /* Modal styles */
1612
+ .cv-widget-modal-overlay {
1613
+ position: fixed;
1614
+ top: 0;
1615
+ left: 0;
1616
+ right: 0;
1617
+ bottom: 0;
1618
+ background: rgba(0, 0, 0, 0.5);
1619
+ display: flex;
1620
+ align-items: center;
1621
+ justify-content: center;
1622
+ z-index: 10002;
1623
+ animation: fadeIn 0.2s ease;
1624
+ }
1625
+
1626
+ @keyframes fadeIn {
1627
+ from { opacity: 0; }
1628
+ to { opacity: 1; }
1629
+ }
1630
+
1631
+ .cv-widget-modal {
1632
+ background: white;
1633
+ border-radius: 0.75rem;
1634
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
1635
+ max-width: 32rem;
1636
+ width: 90vw;
1637
+ max-height: 80vh;
1638
+ animation: slideIn 0.2s ease;
1639
+ display: flex;
1640
+ flex-direction: column;
1641
+ }
1642
+
1643
+ @keyframes slideIn {
1644
+ from {
1645
+ opacity: 0;
1646
+ transform: scale(0.9) translateY(-20px);
1647
+ }
1648
+ to {
1649
+ opacity: 1;
1650
+ transform: scale(1) translateY(0);
1651
+ }
1652
+ }
1653
+
1654
+ .cv-modal-header {
1655
+ display: flex;
1656
+ align-items: center;
1657
+ justify-content: space-between;
1658
+ padding: 0.5rem 1rem;
1659
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
1660
+ }
1661
+
1662
+ .cv-modal-header-content {
1663
+ display: flex;
1664
+ align-items: center;
1665
+ gap: 0.75rem;
1666
+ }
1667
+
1668
+ .cv-modal-icon {
1669
+ position: relative;
1670
+ width: 1rem;
1671
+ height: 1rem;
1672
+ display: flex;
1673
+ align-items: center;
1674
+ justify-content: center;
1675
+ border-radius: 9999px;
1676
+ }
1677
+
1678
+ .cv-modal-icon-svg {
1679
+ width: 100%;
1680
+ height: 100%;
1681
+ opacity: 1;
1682
+ }
1683
+
1684
+ .cv-modal-title {
1685
+ font-size: 1.125rem;
1686
+ font-weight: bold;
1687
+ color: rgba(0, 0, 0, 0.9);
1688
+ margin: 0;
1689
+ }
1690
+
1691
+ .cv-modal-close {
1692
+ width: 2rem;
1693
+ height: 2rem;
1694
+ display: flex;
1695
+ align-items: center;
1696
+ justify-content: center;
1697
+ border-radius: 9999px;
1698
+ background: transparent;
1699
+ border: none;
1700
+ color: rgba(0, 0, 0, 0.6);
1701
+ cursor: pointer;
1702
+ transition: all 0.2s ease;
1703
+ }
1704
+
1705
+ .cv-modal-close:hover {
1706
+ background: rgba(62, 132, 244, 0.1);
1707
+ color: #3e84f4;
1708
+ }
1709
+
1710
+ .cv-modal-close-icon {
1711
+ width: 1.25rem;
1712
+ height: 1.25rem;
1713
+ }
1714
+
1715
+ .cv-modal-main {
1716
+ padding: 1rem;
1717
+ flex: 1;
1718
+ display: flex;
1719
+ flex-direction: column;
1720
+ gap: 1rem;
1721
+ overflow-y: auto;
1722
+ max-height: calc(80vh - 8rem);
1723
+ }
1724
+
1725
+ .cv-modal-description {
1726
+ font-size: 0.875rem;
1727
+ color: rgba(0, 0, 0, 0.8);
1728
+ margin: 0;
1729
+ line-height: 1.4;
1730
+ }
1731
+
1732
+ .cv-content-section,
1733
+ .cv-tab-groups-section {
1734
+ display: flex;
1735
+ flex-direction: column;
1736
+ gap: 0.75rem;
1737
+ }
1738
+
1739
+ .cv-section-heading {
1740
+ font-size: 1rem;
1741
+ font-weight: bold;
1742
+ color: rgba(0, 0, 0, 0.9);
1743
+ margin: 0;
1744
+ }
1745
+
1746
+ .cv-widget-modal-actions {
1747
+ margin-top: 20px;
1748
+ padding-top: 16px;
1749
+ border-top: 1px solid #e9ecef;
1750
+ }
1751
+
1752
+ .cv-widget-restore {
1753
+ width: 100%;
1754
+ padding: 10px 16px;
1755
+ background: #28a745;
1756
+ color: white;
1757
+ border: none;
1758
+ border-radius: 4px;
1759
+ cursor: pointer;
1760
+ font-size: 14px;
1761
+ font-weight: 500;
1762
+ }
1763
+
1764
+ .cv-widget-restore:hover {
1765
+ background: #218838;
1766
+ }
1767
+
1768
+ .cv-widget-create-state {
1769
+ width: 100%;
1770
+ padding: 10px 16px;
1771
+ background: #007bff;
1772
+ color: white;
1773
+ border: none;
1774
+ border-radius: 4px;
1775
+ cursor: pointer;
1776
+ font-size: 14px;
1777
+ font-weight: 500;
1778
+ margin-bottom: 10px;
1779
+ }
1780
+
1781
+ .cv-widget-create-state:hover {
1782
+ background: #0056b3;
1783
+ }
1784
+
1785
+ .cv-widget-theme-dark .cv-widget-modal {
1786
+ background: #101722;
1787
+ color: #e2e8f0;
1788
+ }
1789
+
1790
+ .cv-widget-theme-dark .cv-modal-header {
1791
+ border-color: rgba(255, 255, 255, 0.1);
1792
+ }
1793
+
1794
+ .cv-widget-theme-dark .cv-modal-title {
1795
+ color: #e2e8f0;
1796
+ }
1797
+
1798
+ .cv-widget-theme-dark .cv-modal-close {
1799
+ color: rgba(255, 255, 255, 0.6);
1800
+ }
1801
+
1802
+ .cv-widget-theme-dark .cv-modal-close:hover {
1803
+ background: rgba(62, 132, 244, 0.2);
1804
+ color: #3e84f4;
1805
+ }
1806
+
1807
+ .cv-widget-theme-dark .cv-modal-description {
1808
+ color: rgba(255, 255, 255, 0.8);
1809
+ }
1810
+
1811
+ .cv-widget-theme-dark .cv-section-heading {
1812
+ color: #e2e8f0;
1813
+ }
1814
+
1815
+ .cv-widget-theme-dark .cv-toggles-container
1816
+ .cv-widget-theme-dark .cv-tabgroups-container {
1817
+ border-color: rgba(255, 255, 255, 0.1);
1818
+ }
1819
+
1820
+ .cv-widget-theme-dark .cv-toggle-card,
1821
+ .cv-widget-theme-dark .cv-tabgroup-card {
1822
+ background: #101722;
1823
+ border-color: rgba(255, 255, 255, 0.1);
1824
+ }
1825
+
1826
+ .cv-widget-theme-dark .cv-toggle-title,
1827
+ .cv-widget-theme-dark .cv-tabgroup-title {
1828
+ color: #e2e8f0;
1829
+ }
1830
+
1831
+ .cv-widget-theme-dark .cv-toggle-description,
1832
+ .cv-widget-theme-dark .cv-tabgroup-description {
1833
+ color: rgba(255, 255, 255, 0.6);
1834
+ }
1835
+
1836
+ .cv-widget-theme-dark .cv-toggle-slider {
1837
+ background: rgba(255, 255, 255, 0.2);
1838
+ }
1839
+
1840
+ .cv-widget-theme-dark .cv-tab-group-description {
1841
+ color: rgba(255, 255, 255, 0.8);
1842
+ }
1843
+
1844
+ .cv-widget-theme-dark .cv-tabgroup-select {
1845
+ background: #101722;
1846
+ border-color: rgba(255, 255, 255, 0.2);
1847
+ color: #e2e8f0;
1848
+ }
1849
+
1850
+ .cv-widget-theme-dark .cv-modal-footer {
1851
+ border-color: rgba(255, 255, 255, 0.1);
1852
+ background: #101722;
1853
+ }
1854
+
1855
+ .cv-widget-theme-dark .cv-reset-btn {
1856
+ color: #e2e8f0;
1857
+ background: rgba(255, 255, 255, 0.1);
1858
+ }
1859
+
1860
+ .cv-widget-theme-dark .cv-reset-btn:hover {
1861
+ background: rgba(255, 255, 255, 0.2);
1862
+ }
1863
+
1864
+ /* Custom state creator styles */
1865
+ .cv-custom-state-modal {
1866
+ max-width: 500px;
1867
+ }
1868
+
1869
+ .cv-custom-state-form .cv-section-header {
1870
+ font-size: 16px;
1871
+ font-weight: 600;
1872
+ color: #333;
1873
+ border-bottom: 1px solid #e9ecef;
1874
+ padding-bottom: 5px;
1875
+ }
1876
+
1877
+ .cv-custom-state-form p {
1878
+ font-size: 15px;
1879
+ line-height: 1.6;
1880
+ color: #555;
1881
+ margin-bottom: 24px;
1882
+ text-align: justify;
1883
+ }
1884
+
1885
+ .cv-custom-state-section {
1886
+ margin-bottom: 16px;
1887
+ }
1888
+
1889
+ .cv-custom-state-section label {
1890
+ display: block;
1891
+ margin-bottom: 4px;
1892
+ font-weight: 500;
1893
+ color: #555;
1894
+ }
1895
+
1896
+ .cv-custom-state-input {
1897
+ width: 100%;
1898
+ padding: 8px 12px;
1899
+ border: 1px solid #ddd;
1900
+ border-radius: 4px;
1901
+ background: white;
1902
+ font-size: 14px;
1903
+ }
1904
+
1905
+ .cv-custom-state-input:focus {
1906
+ outline: none;
1907
+ border-color: #007bff;
1908
+ box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
1909
+ }
1910
+
1911
+ /* Toggles Container */
1912
+ .cv-toggles-container {
1913
+ display: flex;
1914
+ flex-direction: column;
1915
+ gap: 0.5rem;
1916
+ border-radius: 0.5rem;
1917
+ border: 1px solid rgba(0, 0, 0, 0.1);
1918
+ overflow: hidden;
1919
+ }
1920
+
1921
+ .cv-toggle-card,
1922
+ .cv-tabgroup-card {
1923
+ background: white;
1924
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
1925
+ }
1926
+
1927
+ .cv-toggle-card:last-child {
1928
+ border-bottom: none;
1929
+ }
1930
+
1931
+ .cv-toggle-content {
1932
+ display: flex;
1933
+ align-items: center;
1934
+ justify-content: space-between;
1935
+ padding: 0.75rem;
1936
+ }
1937
+
1938
+ .cv-toggle-title {
1939
+ font-weight: 500;
1940
+ font-size: 0.875rem;
1941
+ color: rgba(0, 0, 0, 0.9);
1942
+ margin: 0 0 0.125rem 0;
1943
+ }
1944
+
1945
+ .cv-toggle-description {
1946
+ font-size: 0.75rem;
1947
+ color: rgba(0, 0, 0, 0.6);
1948
+ margin: 0;
1949
+ }
1950
+
1951
+ .cv-toggle-label{
1952
+ position: relative;
1953
+ display: inline-block;
1954
+ width: 2.75rem;
1955
+ height: 1.5rem;
1956
+ cursor: pointer;
1957
+ }
1958
+
1959
+ .cv-toggle-input {
1960
+ opacity: 0;
1961
+ width: 0;
1962
+ height: 0;
1963
+ }
1964
+
1965
+ .cv-toggle-slider {
1966
+ position: absolute;
1967
+ top: 0;
1968
+ left: 0;
1969
+ right: 0;
1970
+ bottom: 0;
1971
+ background: rgba(0, 0, 0, 0.2);
1972
+ border-radius: 9999px;
1973
+ transition: background-color 0.2s ease;
1974
+ }
1975
+
1976
+ .cv-toggle-slider:before {
1977
+ position: absolute;
1978
+ content: "";
1979
+ height: 1rem;
1980
+ width: 1rem;
1981
+ left: 0.25rem;
1982
+ bottom: 0.25rem;
1983
+ background: white;
1984
+ border-radius: 50%;
1985
+ transition: transform 0.2s ease;
1986
+ }
1987
+
1988
+ .cv-toggle-input:checked + .cv-toggle-slider {
1989
+ background: #3e84f4;
1990
+ }
1991
+
1992
+ .cv-toggle-input:checked + .cv-toggle-slider:before {
1993
+ transform: translateX(1.25rem);
1994
+ }
1995
+
1996
+ /* Dark theme toggle switch styles */
1997
+ .cv-widget-theme-dark .cv-toggle-switch {
1998
+ background: #4a5568;
1999
+ }
2000
+
2001
+ .cv-widget-theme-dark .cv-toggle-switch:hover {
2002
+ background: #5a6578;
2003
+ }
2004
+
2005
+ .cv-widget-theme-dark .cv-toggle-switch.cv-toggle-active {
2006
+ background: #63b3ed;
2007
+ }
2008
+
2009
+ .cv-widget-theme-dark .cv-toggle-switch.cv-toggle-active:hover {
2010
+ background: #4299e1;
2011
+ }
2012
+
2013
+ /* Tab Groups Container */
2014
+ .cv-tab-groups-list {
2015
+ display: flex;
2016
+ flex-direction: column;
2017
+ gap: 1px;
2018
+ border: 1px solid rgba(0, 0, 0, 0.1);
2019
+ border-radius: 0.5rem;
2020
+ overflow: hidden;
2021
+ }
2022
+
2023
+ /* Tab Group Card - Header (Navigation Headers toggle) */
2024
+ .cv-tabgroup-card.cv-tabgroup-header {
2025
+ display: flex;
2026
+ align-items: center;
2027
+ justify-content: space-between;
2028
+ padding: 0.75rem;
2029
+ border-bottom: 0px;
2030
+ }
2031
+
2032
+ .cv-tabgroup-card.cv-tabgroup-header .cv-tabgroup-row {
2033
+ display: flex;
2034
+ align-items: center;
2035
+ justify-content: space-between;
2036
+ width: 100%;
2037
+ gap: 1rem;
2038
+ }
2039
+
2040
+ /* Tab Group Card - Items */
2041
+ .cv-tabgroup-card.cv-tabgroup-item {
2042
+ display: flex;
2043
+ flex-direction: column;
2044
+ gap: 0.5rem;
2045
+ padding: 0.75rem;
2046
+ background: white;
2047
+ border-bottom: 1px solid rgba(0, 0, 0, 0.05);
2048
+ }
2049
+
2050
+ .cv-tabgroup-card.cv-tabgroup-item:last-child {
2051
+ border-bottom: none;
2052
+ }
2053
+
2054
+ /* Tab Group Info */
2055
+ .cv-tabgroup-info {
2056
+ flex: 1;
2057
+ }
2058
+
2059
+ .cv-tabgroup-title {
2060
+ font-weight: 500;
2061
+ font-size: 0.875rem;
2062
+ color: rgba(0, 0, 0, 0.9);
2063
+ margin: 0 0 0.25rem 0;
2064
+ }
2065
+
2066
+ .cv-tabgroup-description {
2067
+ font-size: 0.75rem;
2068
+ color: rgba(0, 0, 0, 0.6);
2069
+ margin: 0;
2070
+ line-height: 1.3;
2071
+ }
2072
+
2073
+ /* Tab Group Label (for select dropdowns) */
2074
+ .cv-tabgroup-label {
2075
+ font-size: 0.875rem;
2076
+ color: rgba(0, 0, 0, 0.8);
2077
+ margin: 0;
2078
+ line-height: 1.4;
2079
+ font-weight: 500;
2080
+ display: block;
2081
+ cursor: pointer;
2082
+ }
2083
+
2084
+ /* Tab Group Select */
2085
+ .cv-tabgroup-select {
2086
+ width: 100%;
2087
+ border-radius: 0.5rem;
2088
+ background: white;
2089
+ border: 1px solid rgba(0, 0, 0, 0.15);
2090
+ color: rgba(0, 0, 0, 0.9);
2091
+ padding: 0.5rem 0.75rem;
2092
+ font-size: 0.875rem;
2093
+ cursor: pointer;
2094
+ transition: all 0.15s ease;
2095
+ font-family: inherit;
2096
+ }
2097
+
2098
+ .cv-tabgroup-select:hover {
2099
+ border-color: rgba(0, 0, 0, 0.25);
2100
+ }
2101
+
2102
+ .cv-tabgroup-select:focus {
2103
+ outline: none;
2104
+ border-color: #3e84f4;
2105
+ box-shadow: 0 0 0 2px rgba(62, 132, 244, 0.2);
2106
+ }
2107
+
2108
+ /* Modern Toggle Switch */
2109
+ .cv-toggle-switch {
2110
+ position: relative;
2111
+ display: inline-flex;
2112
+ align-items: center;
2113
+ width: 44px;
2114
+ height: 24px;
2115
+ background: rgba(0, 0, 0, 0.1);
2116
+ border-radius: 9999px;
2117
+ padding: 2px;
2118
+ box-sizing: border-box;
2119
+ cursor: pointer;
2120
+ transition: background-color 0.2s ease;
2121
+ border: none;
2122
+ }
2123
+
2124
+ .cv-toggle-switch input {
2125
+ display: none;
2126
+ }
2127
+
2128
+ .cv-toggle-switch .cv-switch-bg {
2129
+ position: absolute;
2130
+ inset: 0;
2131
+ border-radius: 9999px;
2132
+ background: rgba(0, 0, 0, 0.1);
2133
+ transition: background-color 0.2s ease;
2134
+ pointer-events: none;
2135
+ }
2136
+
2137
+ .cv-toggle-switch .cv-switch-knob {
2138
+ position: relative;
2139
+ width: 20px;
2140
+ height: 20px;
2141
+ background: white;
2142
+ border-radius: 50%;
2143
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
2144
+ transition: transform 0.2s ease;
2145
+ z-index: 1;
2146
+ }
2147
+
2148
+ .cv-toggle-switch input:checked + .cv-switch-bg {
2149
+ background: #3e84f4;
2150
+ }
2151
+
2152
+ .cv-toggle-switch input:checked ~ .cv-switch-knob {
2153
+ transform: translateX(20px);
2154
+ }
2155
+
2156
+ /* Dark Theme - Tab Groups */
2157
+ .cv-widget-theme-dark .cv-tabgroup-card.cv-tabgroup-header {
2158
+ background: #101722;
2159
+ border-bottom-color: rgba(255, 255, 255, 0.1);
2160
+ }
2161
+
2162
+ .cv-widget-theme-dark .cv-tabgroup-card.cv-tabgroup-item {
2163
+ background: #101722;
2164
+ border-bottom-color: rgba(255, 255, 255, 0.05);
2165
+ }
2166
+
2167
+ .cv-widget-theme-dark .cv-tabgroup-title {
2168
+ color: #e2e8f0;
2169
+ }
2170
+
2171
+ .cv-widget-theme-dark .cv-tabgroup-description {
2172
+ color: rgba(255, 255, 255, 0.6);
2173
+ }
2174
+
2175
+ .cv-widget-theme-dark .cv-tabgroup-label {
2176
+ color: rgba(255, 255, 255, 0.8);
2177
+ }
2178
+
2179
+ .cv-widget-theme-dark .cv-tab-groups-list {
2180
+ border-color: rgba(255, 255, 255, 0.1);
2181
+ }
2182
+
2183
+ .cv-widget-theme-dark .cv-tabgroup-select {
2184
+ background: #101722;
2185
+ border-color: rgba(255, 255, 255, 0.15);
2186
+ color: #e2e8f0;
2187
+ }
2188
+
2189
+ .cv-widget-theme-dark .cv-tabgroup-select:hover {
2190
+ border-color: rgba(255, 255, 255, 0.25);
2191
+ }
2192
+
2193
+ .cv-widget-theme-dark .cv-tabgroup-select:focus {
2194
+ border-color: #60a5fa;
2195
+ box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
2196
+ }
2197
+
2198
+ /* Dark Theme - Toggle Switch */
2199
+ .cv-widget-theme-dark .cv-toggle-switch .cv-switch-bg {
2200
+ background: rgba(255, 255, 255, 0.1);
2201
+ }
2202
+
2203
+ .cv-widget-theme-dark .cv-toggle-switch .cv-switch-knob {
2204
+ background: #e2e8f0;
2205
+ }
2206
+
2207
+ .cv-widget-theme-dark .cv-toggle-switch input:checked + .cv-switch-bg {
2208
+ background: #63b3ed;
2209
+ }
2210
+
2211
+ .cv-modal-footer {
2212
+ display: flex;
2213
+ justify-content: space-between;
2214
+ align-items: center;
2215
+ padding: 0.75rem;
2216
+ border-top: 1px solid rgba(0, 0, 0, 0.1);
2217
+ }
2218
+
2219
+ .cv-reset-btn,
2220
+ .cv-share-btn {
2221
+ display: flex;
2222
+ align-items: center;
2223
+ gap: 0.5rem;
2224
+ padding: 0.375rem 0.75rem;
2225
+ border-radius: 0.5rem;
2226
+ font-weight: 600;
2227
+ font-size: 0.875rem;
2228
+ cursor: pointer;
2229
+ transition: all 0.2s ease;
2230
+ border: none;
2231
+ }
2232
+
2233
+ .cv-reset-btn {
2234
+ color: rgba(0, 0, 0, 0.9);
2235
+ background: rgba(0, 0, 0, 0.1);
2236
+ }
2237
+
2238
+ .cv-reset-btn:hover {
2239
+ background: rgba(0, 0, 0, 0.2);
2240
+ }
2241
+
2242
+ .cv-share-btn {
2243
+ color: white;
2244
+ background: #3e84f4;
2245
+ }
2246
+
2247
+ .cv-share-btn:hover {
2248
+ background: rgba(62, 132, 244, 0.9);
2249
+ }
2250
+
2251
+ .cv-btn-icon {
2252
+ width: 1rem;
2253
+ height: 1rem;
2254
+ }
2255
+
2256
+ /* Dark theme custom state styles */
2257
+ /* Welcome modal styles */
2258
+ .cv-welcome-modal {
2259
+ max-width: 32rem;
2260
+ width: 90vw;
2261
+ background: white;
2262
+ border-radius: 0.75rem;
2263
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
2264
+ animation: slideIn 0.2s ease;
2265
+ display: flex;
2266
+ flex-direction: column;
2267
+ }
2268
+
2269
+ .cv-modal-main {
2270
+ padding: 1rem;
2271
+ flex: 1;
2272
+ display: flex;
2273
+ flex-direction: column;
2274
+ gap: 1rem;
2275
+ overflow-y: auto;
2276
+ max-height: calc(80vh - 8rem);
2277
+ }
2278
+
2279
+ .cv-welcome-message {
2280
+ font-size: 0.875rem;
2281
+ color: rgba(0, 0, 0, 0.8);
2282
+ margin: 0;
2283
+ line-height: 1.4;
2284
+ text-align: center;
2285
+ }
2286
+
2287
+ .cv-welcome-message a {
2288
+ color: #3e84f4;
2289
+ text-align: justify;
2290
+ text-decoration: none;
2291
+ }
2292
+
2293
+ .cv-welcome-message a:hover {
2294
+ text-decoration: underline;
2295
+ }
2296
+
2297
+ .cv-welcome-widget-preview {
2298
+ display: flex;
2299
+ align-items: center;
2300
+ justify-content: center;
2301
+ gap: 1rem;
2302
+ padding: 1rem;
2303
+ background: #f8f9fa;
2304
+ border-radius: 0.5rem;
2305
+ margin: 1rem 0;
2306
+ }
2307
+
2308
+ .cv-welcome-widget-icon {
2309
+ width: 2rem;
2310
+ height: 2rem;
2311
+ background: rgba(62, 132, 244, 0.1);
2312
+ border-radius: 9999px;
2313
+ display: flex;
2314
+ align-items: center;
2315
+ justify-content: center;
2316
+ animation: cv-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
2317
+ color: #3e84f4;
2318
+ }
2319
+
2320
+ .cv-welcome-widget-label {
2321
+ font-size: 0.875rem;
2322
+ font-weight: 500;
2323
+ color: rgba(0, 0, 0, 0.8);
2324
+ margin: 0;
2325
+ }
2326
+
2327
+ .cv-welcome-got-it {
2328
+ width: 100%;
2329
+ background: #3e84f4;
2330
+ color: white;
2331
+ font-weight: 600;
2332
+ padding: 0.75rem 1rem;
2333
+ border-radius: 0.5rem;
2334
+ border: none;
2335
+ cursor: pointer;
2336
+ font-size: 0.875rem;
2337
+ transition: background-color 0.2s ease;
2338
+ outline: none;
2339
+ }
2340
+
2341
+ .cv-welcome-got-it:hover {
2342
+ background: rgba(62, 132, 244, 0.9);
2343
+ }
2344
+
2345
+ .cv-welcome-got-it:focus {
2346
+ box-shadow: 0 0 0 2px rgba(62, 132, 244, 0.5);
2347
+ }
2348
+
2349
+ /* Animations */
2350
+ @keyframes cv-pulse {
2351
+ 0%, 100% {
2352
+ opacity: 1;
2353
+ }
2354
+ 50% {
2355
+ opacity: 0.5;
2356
+ }
2357
+ }
2358
+
2359
+ /* Dark theme welcome modal styles */
2360
+ .cv-widget-theme-dark .cv-welcome-modal {
2361
+ background: #101722;
2362
+ }
2363
+
2364
+ .cv-widget-theme-dark .cv-welcome-message {
2365
+ color: rgba(255, 255, 255, 0.8);
2366
+ }
2367
+
2368
+ .cv-widget-theme-dark .cv-welcome-message a {
2369
+ color: #60a5fa;
2370
+ }
2371
+
2372
+ .cv-widget-theme-dark .cv-welcome-widget-preview {
2373
+ background: rgba(255, 255, 255, 0.1);
2374
+ }
2375
+
2376
+ .cv-widget-theme-dark .cv-welcome-widget-label {
2377
+ color: #e2e8f0;
2378
+ }
1916
2379
  `;
1917
2380
  /**
1918
2381
  * Inject widget styles into the document head
@@ -1927,6 +2390,45 @@ function injectWidgetStyles() {
1927
2390
  document.head.appendChild(style);
1928
2391
  }
1929
2392
 
2393
+ /**
2394
+ * Icon utilities for CustomViews widget
2395
+ * Centralized SVG icons for better maintainability and reusability
2396
+ */
2397
+ /**
2398
+ * Settings gear icon for modal header
2399
+ */
2400
+ function getGearIcon() {
2401
+ return `<svg class="cv-modal-icon-svg" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2402
+ <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"/>
2403
+ <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"/>
2404
+ </svg>`;
2405
+ }
2406
+ /**
2407
+ * Close/X icon for modal close button
2408
+ */
2409
+ function getCloseIcon() {
2410
+ 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">
2411
+ <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>
2412
+ </svg>`;
2413
+ }
2414
+ /**
2415
+ * Reset/refresh icon for reset button
2416
+ */
2417
+ function getResetIcon() {
2418
+ return `<svg class="cv-btn-icon" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2419
+ <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"/>
2420
+ </svg>`;
2421
+ }
2422
+ /**
2423
+ * Share icon for share button
2424
+ */
2425
+ function getShareIcon() {
2426
+ return `<svg class="cv-btn-icon" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2427
+ <path xmlns="http://www.w3.org/2000/svg" d="M6 11C6 8.17157 6 6.75736 6.87868 5.87868C7.75736 5 9.17157 5 12 5H15C17.8284 5 19.2426 5 20.1213 5.87868C21 6.75736 21 8.17157 21 11V16C21 18.8284 21 20.2426 20.1213 21.1213C19.2426 22 17.8284 22 15 22H12C9.17157 22 7.75736 22 6.87868 21.1213C6 20.2426 6 18.8284 6 16V11Z" stroke="#1C274C" stroke-width="1.5"/>
2428
+ <path xmlns="http://www.w3.org/2000/svg" opacity="0.5" d="M6 19C4.34315 19 3 17.6569 3 16V10C3 6.22876 3 4.34315 4.17157 3.17157C5.34315 2 7.22876 2 11 2H15C16.6569 2 18 3.34315 18 5" stroke="#1C274C" stroke-width="1.5"/>
2429
+ </svg>`;
2430
+ }
2431
+
1930
2432
  class CustomViewsWidget {
1931
2433
  core;
1932
2434
  container;
@@ -1945,7 +2447,7 @@ class CustomViewsWidget {
1945
2447
  theme: options.theme || 'light',
1946
2448
  showReset: options.showReset ?? true,
1947
2449
  title: options.title || 'Customize View',
1948
- description: options.description || 'Toggle different content sections to customize your view. Changes are applied instantly and the URL will be updated for sharing.',
2450
+ description: options.description || '',
1949
2451
  showWelcome: options.showWelcome ?? false,
1950
2452
  welcomeTitle: options.welcomeTitle || 'Site Customization',
1951
2453
  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>.',
@@ -2027,21 +2529,24 @@ class CustomViewsWidget {
2027
2529
  this.modal = document.createElement('div');
2028
2530
  this.modal.className = 'cv-widget-modal-overlay';
2029
2531
  this.applyThemeToModal();
2030
- const toggleControls = toggles.length
2031
- ? toggles.map(toggle => `
2032
- <div class="cv-custom-state-toggle">
2033
- <label>
2034
- <div class="cv-toggle-switch" data-toggle="${toggle}">
2035
- <div class="cv-toggle-handle"></div>
2036
- </div>
2037
- ${this.formatToggleName(toggle)}
2038
- </label>
2039
- </div>
2040
- `).join('')
2041
- : `<p class="cv-no-toggles">No configurable sections available.</p>`;
2532
+ const toggleControlsHtml = toggles.map(toggle => `
2533
+ <div class="cv-toggle-card">
2534
+ <div class="cv-toggle-content">
2535
+ <div>
2536
+ <p class="cv-toggle-title">${this.formatToggleName(toggle)}</p>
2537
+ </div>
2538
+ <label class="cv-toggle-label">
2539
+ <input class="cv-toggle-input" type="checkbox" data-toggle="${toggle}"/>
2540
+ <span class="cv-toggle-slider"></span>
2541
+ </label>
2542
+ </div>
2543
+ </div>
2544
+ `).join('');
2545
+ // Todo: Re-add description if needed (Line 168, add label field to toggles if needed change structure)
2546
+ // <p class="cv-toggle-description">Show or hide the ${this.formatToggleName(toggle).toLowerCase()} area </p>
2042
2547
  // Get tab groups
2043
2548
  const tabGroups = this.core.getTabGroups();
2044
- let tabGroupsHTML = '';
2549
+ let tabGroupControlsHTML = '';
2045
2550
  // Check if any tab group or tab labels contain Font Awesome shortcodes
2046
2551
  let hasFontAwesomeShortcodes = false;
2047
2552
  if (this.options.showTabGroups && tabGroups && tabGroups.length > 0) {
@@ -2065,48 +2570,82 @@ class CustomViewsWidget {
2065
2570
  ensureFontAwesomeInjected();
2066
2571
  }
2067
2572
  if (this.options.showTabGroups && tabGroups && tabGroups.length > 0) {
2068
- const tabGroupControls = tabGroups.map(group => {
2069
- const options = group.tabs.map(tab => `<option value="${tab.id}">${replaceIconShortcodes(tab.label || tab.id)}</option>`).join('');
2070
- return `
2071
- <div class="cv-tab-group-control">
2072
- <label for="tab-group-${group.id}">${replaceIconShortcodes(group.label || group.id)}</label>
2073
- <select id="tab-group-${group.id}" class="cv-tab-group-select" data-group-id="${group.id}">
2074
- ${options}
2075
- </select>
2076
- </div>
2077
- `;
2078
- }).join('');
2079
- tabGroupsHTML = `
2080
- <h4>Tab Groups</h4>
2081
- <div class="cv-tab-groups">
2082
- ${tabGroupControls}
2083
- </div>
2573
+ tabGroupControlsHTML = `
2574
+ <div class="cv-tabgroup-card cv-tabgroup-header">
2575
+ <div class="cv-tabgroup-row">
2576
+ <div class="cv-tabgroup-info">
2577
+ <p class="cv-tabgroup-title">Navigation Headers</p>
2578
+ <p class="cv-tabgroup-description">Show or hide navigation headers</p>
2579
+ </div>
2580
+ <label class="cv-toggle-switch cv-nav-toggle">
2581
+ <input class="cv-nav-pref-input" type="checkbox" aria-label="Show or hide navigation headers" />
2582
+ <span class="cv-switch-bg"></span>
2583
+ <span class="cv-switch-knob"></span>
2584
+ </label>
2585
+ </div>
2586
+ </div>
2587
+ <div class="cv-tab-groups-list">
2588
+ ${tabGroups.map(group => `
2589
+ <div class="cv-tabgroup-card cv-tabgroup-item">
2590
+ <label class="cv-tabgroup-label" for="tab-group-${group.id}">
2591
+ ${replaceIconShortcodes(group.label || group.id)}
2592
+ </label>
2593
+ <select id="tab-group-${group.id}" class="cv-tabgroup-select" data-group-id="${group.id}">
2594
+ ${group.tabs.map(tab => `<option value="${tab.id}">${replaceIconShortcodes(tab.label || tab.id)}</option>`).join('')}
2595
+ </select>
2596
+ </div>
2597
+ `).join('')}
2598
+ </div>
2084
2599
  `;
2085
2600
  }
2086
- this.modal.innerHTML = `
2087
- <div class="cv-widget-modal cv-custom-state-modal">
2088
- <div class="cv-widget-modal-header">
2089
- <h3>${this.options.title}</h3>
2090
- <button class="cv-widget-modal-close" aria-label="Close modal">×</button>
2091
- </div>
2092
- <div class="cv-widget-modal-content">
2093
- <div class="cv-custom-state-form">
2094
- <p>${this.options.description}</p>
2095
-
2096
- <h4>Content Sections</h4>
2097
- <div class="cv-custom-toggles">
2098
- ${toggleControls}
2099
- </div>
2100
-
2101
- ${tabGroupsHTML}
2102
-
2103
- <div class="cv-custom-state-actions">
2104
- ${this.options.showReset ? `<button class="cv-custom-state-reset">Reset to Default</button>` : ''}
2105
- <button class="cv-custom-state-copy-url">Copy Shareable URL</button>
2106
- </div>
2107
- </div>
2108
- </div>
2109
- </div>
2601
+ this.modal.innerHTML = `
2602
+ <div class="cv-widget-modal cv-custom-state-modal">
2603
+ <header class="cv-modal-header">
2604
+ <div class="cv-modal-header-content">
2605
+ <div class="cv-modal-icon">
2606
+ ${getGearIcon()}
2607
+ </div>
2608
+ <div class="cv-modal-title">${this.options.title}</div>
2609
+ </div>
2610
+ <button class="cv-modal-close" aria-label="Close modal">
2611
+ ${getCloseIcon()}
2612
+ </button>
2613
+ </header>
2614
+ <main class="cv-modal-main">
2615
+ ${this.options.description ? `<p class="cv-modal-description">${this.options.description}</p>` : ''}
2616
+
2617
+ ${toggles.length ? `
2618
+ <div class="cv-content-section">
2619
+ <div class="cv-section-heading">Toggles</div>
2620
+ <div class="cv-toggles-container">
2621
+ ${toggleControlsHtml}
2622
+ </div>
2623
+ </div>
2624
+ ` : ''}
2625
+
2626
+ ${this.options.showTabGroups && tabGroups && tabGroups.length > 0 ? `
2627
+ <div class="cv-content-section">
2628
+ <div class="cv-section-heading">Tab Groups</div>
2629
+ <div class="cv-tabgroups-container">
2630
+ ${tabGroupControlsHTML}
2631
+ </div>
2632
+ </div>
2633
+ ` : ''}
2634
+ </main>
2635
+
2636
+ <footer class="cv-modal-footer">
2637
+ ${this.options.showReset ? `
2638
+ <button class="cv-reset-btn">
2639
+ ${getResetIcon()}
2640
+ <span>Reset to Default</span>
2641
+ </button>
2642
+ ` : ''}
2643
+ <button class="cv-share-btn">
2644
+ ${getShareIcon()}
2645
+ <span>Copy Shareable URL</span>
2646
+ </button>
2647
+ </footer>
2648
+ </div>
2110
2649
  `;
2111
2650
  document.body.appendChild(this.modal);
2112
2651
  this.attachStateModalEventListeners();
@@ -2120,21 +2659,21 @@ class CustomViewsWidget {
2120
2659
  if (!this.modal)
2121
2660
  return;
2122
2661
  // Close button
2123
- const closeBtn = this.modal.querySelector('.cv-widget-modal-close');
2662
+ const closeBtn = this.modal.querySelector('.cv-modal-close');
2124
2663
  if (closeBtn) {
2125
2664
  closeBtn.addEventListener('click', () => {
2126
2665
  this.closeModal();
2127
2666
  });
2128
2667
  }
2129
2668
  // Copy URL button
2130
- const copyUrlBtn = this.modal.querySelector('.cv-custom-state-copy-url');
2669
+ const copyUrlBtn = this.modal.querySelector('.cv-share-btn');
2131
2670
  if (copyUrlBtn) {
2132
2671
  copyUrlBtn.addEventListener('click', () => {
2133
2672
  this.copyShareableURL();
2134
2673
  });
2135
2674
  }
2136
2675
  // Reset to default button
2137
- const resetBtn = this.modal.querySelector('.cv-custom-state-reset');
2676
+ const resetBtn = this.modal.querySelector('.cv-reset-btn');
2138
2677
  if (resetBtn) {
2139
2678
  resetBtn.addEventListener('click', () => {
2140
2679
  this.core.resetToDefault();
@@ -2142,25 +2681,55 @@ class CustomViewsWidget {
2142
2681
  });
2143
2682
  }
2144
2683
  // Listen to toggle switches
2145
- const toggleSwitches = this.modal.querySelectorAll('.cv-toggle-switch');
2146
- toggleSwitches.forEach(toggleSwitch => {
2147
- toggleSwitch.addEventListener('click', () => {
2148
- toggleSwitch.classList.toggle('cv-toggle-active');
2684
+ const toggleInputs = this.modal.querySelectorAll('.cv-toggle-input');
2685
+ toggleInputs.forEach(toggleInput => {
2686
+ toggleInput.addEventListener('change', () => {
2149
2687
  const state = this.getCurrentCustomStateFromModal();
2150
2688
  this.core.applyState(state);
2151
2689
  });
2152
2690
  });
2153
2691
  // Listen to tab group selects
2154
- const tabGroupSelects = this.modal.querySelectorAll('.cv-tab-group-select');
2692
+ const tabGroupSelects = this.modal.querySelectorAll('.cv-tabgroup-select');
2155
2693
  tabGroupSelects.forEach(select => {
2156
2694
  select.addEventListener('change', () => {
2157
2695
  const groupId = select.dataset.groupId;
2158
2696
  const tabId = select.value;
2159
2697
  if (groupId && tabId) {
2160
- this.core.setActiveTab(groupId, tabId);
2698
+ // Get current state and update the tab for this group, then apply globally
2699
+ // This triggers sync behavior and persistence
2700
+ const currentTabs = this.core.getCurrentActiveTabs();
2701
+ currentTabs[groupId] = tabId;
2702
+ // Apply state globally for persistence and sync
2703
+ const currentToggles = this.core.getCurrentActiveToggles();
2704
+ const newState = {
2705
+ toggles: currentToggles,
2706
+ tabs: currentTabs
2707
+ };
2708
+ this.core.applyState(newState);
2161
2709
  }
2162
2710
  });
2163
2711
  });
2712
+ // Listener for show/hide tab navs
2713
+ const tabNavToggle = this.modal.querySelector('.cv-nav-pref-input');
2714
+ if (tabNavToggle) {
2715
+ tabNavToggle.addEventListener('change', () => {
2716
+ const visible = tabNavToggle.checked;
2717
+ // Persist preference
2718
+ try {
2719
+ localStorage.setItem('cv-tab-navs-visible', visible ? 'true' : 'false');
2720
+ }
2721
+ catch (e) { /* ignore */ }
2722
+ // Apply to DOM using TabManager via core
2723
+ try {
2724
+ const rootEl = document.body;
2725
+ TabManager.setNavsVisibility(rootEl, visible);
2726
+ }
2727
+ catch (e) {
2728
+ // ignore errors
2729
+ console.error('Failed to set tab nav visibility:', e);
2730
+ }
2731
+ });
2732
+ }
2164
2733
  // Overlay click to close
2165
2734
  this.modal.addEventListener('click', (e) => {
2166
2735
  if (e.target === this.modal) {
@@ -2198,15 +2767,15 @@ class CustomViewsWidget {
2198
2767
  }
2199
2768
  // Collect toggle values
2200
2769
  const toggles = [];
2201
- const toggleSwitches = this.modal.querySelectorAll('.cv-toggle-switch');
2202
- toggleSwitches.forEach(toggleSwitch => {
2203
- const toggle = toggleSwitch.dataset.toggle;
2204
- if (toggle && toggleSwitch.classList.contains('cv-toggle-active')) {
2770
+ const toggleInputs = this.modal.querySelectorAll('.cv-toggle-input');
2771
+ toggleInputs.forEach(toggleInput => {
2772
+ const toggle = toggleInput.dataset.toggle;
2773
+ if (toggle && toggleInput.checked) {
2205
2774
  toggles.push(toggle);
2206
2775
  }
2207
2776
  });
2208
2777
  // Collect tab selections
2209
- const tabGroupSelects = this.modal.querySelectorAll('.cv-tab-group-select');
2778
+ const tabGroupSelects = this.modal.querySelectorAll('.cv-tabgroup-select');
2210
2779
  const tabs = {};
2211
2780
  tabGroupSelects.forEach(select => {
2212
2781
  const groupId = select.dataset.groupId;
@@ -2238,27 +2807,45 @@ class CustomViewsWidget {
2238
2807
  return;
2239
2808
  // Get currently active toggles (from custom state or default configuration)
2240
2809
  const activeToggles = this.core.getCurrentActiveToggles();
2241
- // First, deactivate all toggle switches
2242
- const allToggleSwitches = this.modal.querySelectorAll('.cv-toggle-switch');
2243
- allToggleSwitches.forEach(toggleSwitch => {
2244
- toggleSwitch.classList.remove('cv-toggle-active');
2810
+ // First, uncheck all toggle inputs
2811
+ const allToggleInputs = this.modal.querySelectorAll('.cv-toggle-input');
2812
+ allToggleInputs.forEach(toggleInput => {
2813
+ toggleInput.checked = false;
2245
2814
  });
2246
- // Then activate the ones that should be active
2815
+ // Then check the ones that should be active
2247
2816
  activeToggles.forEach(toggle => {
2248
- const toggleSwitch = this.modal?.querySelector(`[data-toggle="${toggle}"]`);
2249
- if (toggleSwitch) {
2250
- toggleSwitch.classList.add('cv-toggle-active');
2817
+ const toggleInput = this.modal?.querySelector(`[data-toggle="${toggle}"]`);
2818
+ if (toggleInput) {
2819
+ toggleInput.checked = true;
2251
2820
  }
2252
2821
  });
2253
2822
  // Load tab group selections
2254
2823
  const activeTabs = this.core.getCurrentActiveTabs();
2255
- const tabGroupSelects = this.modal.querySelectorAll('.cv-tab-group-select');
2824
+ const tabGroupSelects = this.modal.querySelectorAll('.cv-tabgroup-select');
2256
2825
  tabGroupSelects.forEach(select => {
2257
2826
  const groupId = select.dataset.groupId;
2258
2827
  if (groupId && activeTabs[groupId]) {
2259
2828
  select.value = activeTabs[groupId];
2260
2829
  }
2261
2830
  });
2831
+ // Load tab nav visibility preference
2832
+ const navPref = (() => {
2833
+ try {
2834
+ const raw = localStorage.getItem('cv-tab-navs-visible');
2835
+ if (raw === null)
2836
+ return TabManager.areNavsVisible(document.body);
2837
+ return raw === 'true';
2838
+ }
2839
+ catch (e) {
2840
+ return TabManager.areNavsVisible(document.body);
2841
+ }
2842
+ })();
2843
+ const tabNavToggle = this.modal.querySelector('.cv-nav-pref-input');
2844
+ if (tabNavToggle) {
2845
+ tabNavToggle.checked = navPref;
2846
+ // Ensure UI matches actual visibility
2847
+ TabManager.setNavsVisibility(document.body, navPref);
2848
+ }
2262
2849
  }
2263
2850
  /**
2264
2851
  * Format toggle name for display
@@ -2292,25 +2879,29 @@ class CustomViewsWidget {
2292
2879
  this.modal = document.createElement('div');
2293
2880
  this.modal.className = 'cv-widget-modal-overlay cv-welcome-modal-overlay';
2294
2881
  this.applyThemeToModal();
2295
- this.modal.innerHTML = `
2296
- <div class="cv-widget-modal cv-welcome-modal">
2297
- <div class="cv-widget-modal-header">
2298
- <h3>${this.options.welcomeTitle}</h3>
2299
- <button class="cv-widget-modal-close" aria-label="Close modal">×</button>
2300
- </div>
2301
- <div class="cv-widget-modal-content">
2302
- <div class="cv-welcome-content">
2303
- <p style="text-align: justify;">${this.options.welcomeMessage}</p>
2304
-
2305
- <div class="cv-welcome-widget-preview">
2306
- <div class="cv-welcome-widget-icon">⚙</div>
2307
- <p class="cv-welcome-widget-label">Look for this widget on the side of the screen</p>
2308
- </div>
2309
-
2310
- <button class="cv-welcome-got-it">Got it!</button>
2311
- </div>
2312
- </div>
2313
- </div>
2882
+ this.modal.innerHTML = `
2883
+ <div class="cv-widget-modal cv-welcome-modal">
2884
+ <header class="cv-modal-header">
2885
+ <div class="cv-modal-header-content">
2886
+ <div class="cv-modal-icon">
2887
+ ${getGearIcon()}
2888
+ </div>
2889
+ <h1 class="cv-modal-title">${this.options.welcomeTitle}</h1>
2890
+ </div>
2891
+ </header>
2892
+ <div class="cv-modal-main">
2893
+ <p class="cv-welcome-message">${this.options.welcomeMessage}</p>
2894
+
2895
+ <div class="cv-welcome-widget-preview">
2896
+ <div class="cv-welcome-widget-icon">
2897
+ ${getGearIcon()}
2898
+ </div>
2899
+ <p class="cv-welcome-widget-label">Look for this widget</p>
2900
+ </div>
2901
+
2902
+ <button class="cv-welcome-got-it">Got it!</button>
2903
+ </div>
2904
+ </div>
2314
2905
  `;
2315
2906
  document.body.appendChild(this.modal);
2316
2907
  this.attachWelcomeModalEventListeners();
@@ -2321,13 +2912,6 @@ class CustomViewsWidget {
2321
2912
  attachWelcomeModalEventListeners() {
2322
2913
  if (!this.modal)
2323
2914
  return;
2324
- // Close button
2325
- const closeBtn = this.modal.querySelector('.cv-widget-modal-close');
2326
- if (closeBtn) {
2327
- closeBtn.addEventListener('click', () => {
2328
- this.closeModal();
2329
- });
2330
- }
2331
2915
  // Got it button
2332
2916
  const gotItBtn = this.modal.querySelector('.cv-welcome-got-it');
2333
2917
  if (gotItBtn) {