lightview 2.0.7 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/README.md +47 -1283
  2. package/components/actions/button.js +5 -5
  3. package/components/actions/dropdown.js +6 -6
  4. package/components/actions/modal.js +9 -9
  5. package/components/actions/swap.js +5 -5
  6. package/components/data-display/accordion.js +6 -6
  7. package/components/data-display/alert.js +6 -6
  8. package/components/data-display/avatar.js +7 -7
  9. package/components/data-display/badge.js +5 -5
  10. package/components/data-display/card.js +7 -7
  11. package/components/data-display/carousel.js +4 -4
  12. package/components/data-display/chart.js +8 -8
  13. package/components/data-display/chat.js +7 -7
  14. package/components/data-display/collapse.js +5 -5
  15. package/components/data-display/countdown.js +3 -3
  16. package/components/data-display/diff.js +6 -6
  17. package/components/data-display/kbd.js +5 -5
  18. package/components/data-display/loading.js +5 -5
  19. package/components/data-display/progress.js +5 -5
  20. package/components/data-display/radial-progress.js +5 -5
  21. package/components/data-display/skeleton.js +3 -3
  22. package/components/data-display/stats.js +9 -9
  23. package/components/data-display/table.js +9 -9
  24. package/components/data-display/timeline.js +8 -8
  25. package/components/data-display/toast.js +3 -3
  26. package/components/data-display/tooltip.js +3 -3
  27. package/components/data-input/checkbox.js +5 -5
  28. package/components/data-input/file-input.js +3 -3
  29. package/components/data-input/input.js +5 -5
  30. package/components/data-input/radio.js +9 -9
  31. package/components/data-input/range.js +3 -3
  32. package/components/data-input/rating.js +3 -3
  33. package/components/data-input/select.js +5 -5
  34. package/components/data-input/textarea.js +3 -3
  35. package/components/data-input/toggle.js +5 -5
  36. package/components/layout/divider.js +3 -3
  37. package/components/layout/drawer.js +7 -7
  38. package/components/layout/footer.js +5 -5
  39. package/components/layout/hero.js +5 -5
  40. package/components/layout/indicator.js +4 -4
  41. package/components/layout/join.js +4 -4
  42. package/components/layout/navbar.js +6 -6
  43. package/components/navigation/breadcrumbs.js +4 -4
  44. package/components/navigation/dock.js +5 -5
  45. package/components/navigation/menu.js +6 -6
  46. package/components/navigation/pagination.js +3 -3
  47. package/components/navigation/steps.js +4 -4
  48. package/components/navigation/tabs.js +5 -5
  49. package/components/theme/theme-switch.js +30 -30
  50. package/docs/about.html +142 -14
  51. package/docs/api/computed.html +1 -6
  52. package/docs/api/effects.html +1 -7
  53. package/docs/api/elements.html +6 -10
  54. package/docs/api/enhance.html +1 -6
  55. package/docs/api/hypermedia.html +154 -22
  56. package/docs/api/index.html +7 -12
  57. package/docs/api/nav.html +18 -1
  58. package/docs/api/signals.html +1 -6
  59. package/docs/api/state.html +1 -6
  60. package/docs/assets/js/examplify-sandbox.html +2 -2
  61. package/docs/assets/js/examplify.js +15 -15
  62. package/docs/components/accordion.html +4 -4
  63. package/docs/components/alert.html +4 -4
  64. package/docs/components/avatar.html +4 -4
  65. package/docs/components/badge.html +4 -4
  66. package/docs/components/breadcrumbs.html +3 -3
  67. package/docs/components/button.html +5 -5
  68. package/docs/components/card.html +4 -4
  69. package/docs/components/carousel.html +3 -3
  70. package/docs/components/chart-area.html +6 -6
  71. package/docs/components/chart-bar.html +6 -6
  72. package/docs/components/chart-column.html +6 -6
  73. package/docs/components/chart-line.html +6 -6
  74. package/docs/components/chart-pie.html +6 -6
  75. package/docs/components/chart.html +2 -2
  76. package/docs/components/chat.html +4 -4
  77. package/docs/components/checkbox.html +4 -4
  78. package/docs/components/collapse.html +4 -4
  79. package/docs/components/countdown.html +4 -4
  80. package/docs/components/diff.html +3 -3
  81. package/docs/components/divider.html +3 -3
  82. package/docs/components/dock.html +3 -3
  83. package/docs/components/drawer.html +4 -4
  84. package/docs/components/dropdown.html +4 -4
  85. package/docs/components/file-input.html +4 -4
  86. package/docs/components/footer.html +3 -3
  87. package/docs/components/gallery.html +2 -2
  88. package/docs/components/hero.html +3 -3
  89. package/docs/components/index.css +5 -3
  90. package/docs/components/index.html +4 -4
  91. package/docs/components/indicator.html +3 -3
  92. package/docs/components/input.html +4 -4
  93. package/docs/components/join.html +3 -3
  94. package/docs/components/kbd.html +3 -3
  95. package/docs/components/loading.html +4 -4
  96. package/docs/components/menu.html +4 -4
  97. package/docs/components/modal.html +4 -4
  98. package/docs/components/navbar.html +3 -3
  99. package/docs/components/pagination.html +3 -3
  100. package/docs/components/progress.html +4 -4
  101. package/docs/components/radial-progress.html +3 -3
  102. package/docs/components/radio.html +4 -4
  103. package/docs/components/range.html +4 -4
  104. package/docs/components/rating.html +4 -4
  105. package/docs/components/select.html +4 -4
  106. package/docs/components/sidebar-setup.js +1 -1
  107. package/docs/components/skeleton.html +4 -4
  108. package/docs/components/spinner.html +4 -4
  109. package/docs/components/stats.html +4 -4
  110. package/docs/components/steps.html +3 -3
  111. package/docs/components/swap.html +4 -4
  112. package/docs/components/switch.html +4 -4
  113. package/docs/components/table.html +4 -4
  114. package/docs/components/tabs.html +4 -4
  115. package/docs/components/text-input.html +4 -4
  116. package/docs/components/textarea.html +4 -4
  117. package/docs/components/timeline.html +4 -4
  118. package/docs/components/toast.html +4 -4
  119. package/docs/components/toggle.html +4 -4
  120. package/docs/components/tooltip.html +4 -4
  121. package/docs/examples/getting-started-example.html +1 -1
  122. package/docs/examples/index.html +1 -2
  123. package/docs/getting-started/index.html +105 -14
  124. package/docs/index.html +2 -11
  125. package/docs/router-nav.html +13 -0
  126. package/docs/router.html +60 -17
  127. package/docs/styles/index.html +2 -7
  128. package/docs/syntax.html +144 -0
  129. package/functions/_middleware.js +17 -10
  130. package/functions/processServerScripts.js +127 -0
  131. package/index.html +8 -8
  132. package/lightview-router.js +141 -297
  133. package/lightview-x.js +604 -573
  134. package/lightview.js +179 -157
  135. package/package.json +33 -26
  136. package/scripts/analysis/README.md +2 -0
  137. package/scripts/analysis/analyze.js +266 -0
  138. package/scripts/analysis/latest_metrics.md +185 -0
  139. package/wrangler.toml +6 -0
  140. package/docs/playground.html +0 -416
@@ -13,8 +13,8 @@ import '../daisyui.js';
13
13
  * @param {boolean} props.useShadow - Render in Shadow DOM with isolated DaisyUI styles
14
14
  */
15
15
  const Hero = (props = {}, ...children) => {
16
- const { tags } = window.Lightview || {};
17
- const LVX = window.LightviewX || {};
16
+ const { tags } = globalThis.Lightview || {};
17
+ const LVX = globalThis.LightviewX || {};
18
18
 
19
19
  if (!tags) return null;
20
20
 
@@ -77,7 +77,7 @@ const Hero = (props = {}, ...children) => {
77
77
  * Hero Content
78
78
  */
79
79
  Hero.Content = (props = {}, ...children) => {
80
- const { tags } = window.Lightview || {};
80
+ const { tags } = globalThis.Lightview || {};
81
81
  if (!tags) return null;
82
82
 
83
83
  const { position = 'center', center, class: className = '', ...rest } = props;
@@ -94,14 +94,14 @@ Hero.Content = (props = {}, ...children) => {
94
94
  * Hero Overlay
95
95
  */
96
96
  Hero.Overlay = (props = {}) => {
97
- const { tags } = window.Lightview || {};
97
+ const { tags } = globalThis.Lightview || {};
98
98
  if (!tags) return null;
99
99
 
100
100
  const { class: className = '', ...rest } = props;
101
101
  return tags.div({ class: `hero-overlay bg-opacity-60 ${className}`.trim(), ...rest });
102
102
  };
103
103
 
104
- const tags = window.Lightview.tags;
104
+ const tags = globalThis.Lightview.tags;
105
105
  tags.Hero = Hero;
106
106
  tags['Hero.Content'] = Hero.Content;
107
107
  tags['Hero.Overlay'] = Hero.Overlay;
@@ -12,8 +12,8 @@ import '../daisyui.js';
12
12
  * @param {boolean} props.useShadow - Render in Shadow DOM with isolated DaisyUI styles
13
13
  */
14
14
  const Indicator = (props = {}, ...children) => {
15
- const { tags } = window.Lightview || {};
16
- const LVX = window.LightviewX || {};
15
+ const { tags } = globalThis.Lightview || {};
16
+ const LVX = globalThis.LightviewX || {};
17
17
 
18
18
  if (!tags) return null;
19
19
 
@@ -55,7 +55,7 @@ const Indicator = (props = {}, ...children) => {
55
55
  * Indicator Item - the positioned element
56
56
  */
57
57
  Indicator.Item = (props = {}, ...children) => {
58
- const { tags } = window.Lightview || {};
58
+ const { tags } = globalThis.Lightview || {};
59
59
  if (!tags) return null;
60
60
 
61
61
  const {
@@ -83,7 +83,7 @@ Indicator.Item = (props = {}, ...children) => {
83
83
  return tags.span({ class: classes.join(' '), ...rest }, ...children);
84
84
  };
85
85
 
86
- const tags = window.Lightview.tags;
86
+ const tags = globalThis.Lightview.tags;
87
87
  tags.Indicator = Indicator;
88
88
  tags['Indicator.Item'] = Indicator.Item;
89
89
 
@@ -12,8 +12,8 @@ import '../daisyui.js';
12
12
  * @param {boolean} props.useShadow - Render in Shadow DOM with isolated DaisyUI styles
13
13
  */
14
14
  const Join = (props = {}, ...children) => {
15
- const { tags } = window.Lightview || {};
16
- const LVX = window.LightviewX || {};
15
+ const { tags } = globalThis.Lightview || {};
16
+ const LVX = globalThis.LightviewX || {};
17
17
 
18
18
  if (!tags) return null;
19
19
 
@@ -61,7 +61,7 @@ const Join = (props = {}, ...children) => {
61
61
  * Join Item - each joined element should have this class
62
62
  */
63
63
  Join.Item = (props = {}, ...children) => {
64
- const { tags } = window.Lightview || {};
64
+ const { tags } = globalThis.Lightview || {};
65
65
  if (!tags) return null;
66
66
 
67
67
  const { as = 'button', class: className = '', ...rest } = props;
@@ -73,6 +73,6 @@ Join.Item = (props = {}, ...children) => {
73
73
  }, ...children);
74
74
  };
75
75
 
76
- window.Lightview.tags.Join = Join;
76
+ globalThis.Lightview.tags.Join = Join;
77
77
 
78
78
  export default Join;
@@ -12,8 +12,8 @@ import '../daisyui.js';
12
12
  * @param {boolean} props.useShadow - Render in Shadow DOM with isolated DaisyUI styles
13
13
  */
14
14
  const Navbar = (props = {}, ...children) => {
15
- const { tags } = window.Lightview || {};
16
- const LVX = window.LightviewX || {};
15
+ const { tags } = globalThis.Lightview || {};
16
+ const LVX = globalThis.LightviewX || {};
17
17
 
18
18
  if (!tags) return null;
19
19
 
@@ -60,7 +60,7 @@ const Navbar = (props = {}, ...children) => {
60
60
  * Navbar Start
61
61
  */
62
62
  Navbar.Start = (props = {}, ...children) => {
63
- const { tags } = window.Lightview || {};
63
+ const { tags } = globalThis.Lightview || {};
64
64
  if (!tags) return null;
65
65
 
66
66
  const { class: className = '', ...rest } = props;
@@ -75,7 +75,7 @@ Navbar.Start = (props = {}, ...children) => {
75
75
  * Navbar Center
76
76
  */
77
77
  Navbar.Center = (props = {}, ...children) => {
78
- const { tags } = window.Lightview || {};
78
+ const { tags } = globalThis.Lightview || {};
79
79
  if (!tags) return null;
80
80
 
81
81
  const { class: className = '', ...rest } = props;
@@ -90,7 +90,7 @@ Navbar.Center = (props = {}, ...children) => {
90
90
  * Navbar End
91
91
  */
92
92
  Navbar.End = (props = {}, ...children) => {
93
- const { tags } = window.Lightview || {};
93
+ const { tags } = globalThis.Lightview || {};
94
94
  if (!tags) return null;
95
95
 
96
96
  const { class: className = '', ...rest } = props;
@@ -101,7 +101,7 @@ Navbar.End = (props = {}, ...children) => {
101
101
  }, ...children);
102
102
  };
103
103
 
104
- const tags = window.Lightview.tags;
104
+ const tags = globalThis.Lightview.tags;
105
105
  tags.Navbar = Navbar;
106
106
  tags['Navbar.Start'] = Navbar.Start;
107
107
  tags['Navbar.Center'] = Navbar.Center;
@@ -12,8 +12,8 @@ import '../daisyui.js';
12
12
  * @param {boolean} props.useShadow - Render in Shadow DOM with isolated DaisyUI styles
13
13
  */
14
14
  const Breadcrumbs = (props = {}, ...children) => {
15
- const { tags } = window.Lightview || {};
16
- const LVX = window.LightviewX || {};
15
+ const { tags } = globalThis.Lightview || {};
16
+ const LVX = globalThis.LightviewX || {};
17
17
 
18
18
  if (!tags) return null;
19
19
 
@@ -70,7 +70,7 @@ const Breadcrumbs = (props = {}, ...children) => {
70
70
  * Breadcrumbs Item
71
71
  */
72
72
  Breadcrumbs.Item = (props = {}, ...children) => {
73
- const { tags } = window.Lightview || {};
73
+ const { tags } = globalThis.Lightview || {};
74
74
  if (!tags) return null;
75
75
 
76
76
  const { href, class: className = '', ...rest } = props;
@@ -85,7 +85,7 @@ Breadcrumbs.Item = (props = {}, ...children) => {
85
85
  };
86
86
 
87
87
 
88
- const tags = window.Lightview.tags;
88
+ const tags = globalThis.Lightview.tags;
89
89
  tags.Breadcrumbs = Breadcrumbs;
90
90
  tags['Breadcrumbs.Item'] = Breadcrumbs.Item;
91
91
  export default Breadcrumbs;
@@ -12,8 +12,8 @@ import '../daisyui.js';
12
12
  * @param {boolean} props.useShadow - Render in Shadow DOM with isolated DaisyUI styles
13
13
  */
14
14
  const Dock = (props = {}, ...children) => {
15
- const { tags } = window.Lightview || {};
16
- const LVX = window.LightviewX || {};
15
+ const { tags } = globalThis.Lightview || {};
16
+ const LVX = globalThis.LightviewX || {};
17
17
 
18
18
  if (!tags) return null;
19
19
 
@@ -61,7 +61,7 @@ const Dock = (props = {}, ...children) => {
61
61
  * Dock Item
62
62
  */
63
63
  Dock.Item = (props = {}, ...children) => {
64
- const { tags } = window.Lightview || {};
64
+ const { tags } = globalThis.Lightview || {};
65
65
  if (!tags) return null;
66
66
 
67
67
  const {
@@ -84,7 +84,7 @@ Dock.Item = (props = {}, ...children) => {
84
84
  * Dock Label
85
85
  */
86
86
  Dock.Label = (props = {}, ...children) => {
87
- const { tags } = window.Lightview || {};
87
+ const { tags } = globalThis.Lightview || {};
88
88
  if (!tags) return null;
89
89
 
90
90
  const { class: className = '', ...rest } = props;
@@ -95,7 +95,7 @@ Dock.Label = (props = {}, ...children) => {
95
95
  }, ...children);
96
96
  };
97
97
 
98
- const tags = window.Lightview.tags;
98
+ const tags = globalThis.Lightview.tags;
99
99
  tags.Dock = Dock;
100
100
  tags['Dock.Item'] = Dock.Item;
101
101
  tags['Dock.Label'] = Dock.Label;
@@ -14,8 +14,8 @@ import '../daisyui.js';
14
14
  * @param {boolean} props.useShadow - Render in Shadow DOM with isolated DaisyUI styles
15
15
  */
16
16
  const Menu = (props = {}, ...children) => {
17
- const { tags } = window.Lightview || {};
18
- const LVX = window.LightviewX || {};
17
+ const { tags } = globalThis.Lightview || {};
18
+ const LVX = globalThis.LightviewX || {};
19
19
 
20
20
  if (!tags) return null;
21
21
 
@@ -66,7 +66,7 @@ const Menu = (props = {}, ...children) => {
66
66
  * Menu Item
67
67
  */
68
68
  Menu.Item = (props = {}, ...children) => {
69
- const { tags } = window.Lightview || {};
69
+ const { tags } = globalThis.Lightview || {};
70
70
  if (!tags) return null;
71
71
 
72
72
  const {
@@ -92,7 +92,7 @@ Menu.Item = (props = {}, ...children) => {
92
92
  * Menu Title
93
93
  */
94
94
  Menu.Title = (props = {}, ...children) => {
95
- const { tags } = window.Lightview || {};
95
+ const { tags } = globalThis.Lightview || {};
96
96
  if (!tags) return null;
97
97
 
98
98
  const { class: className = '', ...rest } = props;
@@ -104,7 +104,7 @@ Menu.Title = (props = {}, ...children) => {
104
104
  * Menu Dropdown (submenu)
105
105
  */
106
106
  Menu.Dropdown = (props = {}, ...children) => {
107
- const { tags } = window.Lightview || {};
107
+ const { tags } = globalThis.Lightview || {};
108
108
  if (!tags) return null;
109
109
 
110
110
  const { label, open = false, class: className = '', ...rest } = props;
@@ -117,7 +117,7 @@ Menu.Dropdown = (props = {}, ...children) => {
117
117
  return tags.li({}, details);
118
118
  };
119
119
 
120
- const tags = window.Lightview.tags;
120
+ const tags = globalThis.Lightview.tags;
121
121
  tags.Menu = Menu;
122
122
  tags['Menu.Item'] = Menu.Item;
123
123
  tags['Menu.Title'] = Menu.Title;
@@ -15,8 +15,8 @@ import '../daisyui.js';
15
15
  * @param {boolean} props.useShadow - Render in Shadow DOM with isolated DaisyUI styles
16
16
  */
17
17
  const Pagination = (props = {}, ...children) => {
18
- const { tags } = window.Lightview || {};
19
- const LVX = window.LightviewX || {};
18
+ const { tags } = globalThis.Lightview || {};
19
+ const LVX = globalThis.LightviewX || {};
20
20
 
21
21
  if (!tags) return null;
22
22
 
@@ -100,6 +100,6 @@ const Pagination = (props = {}, ...children) => {
100
100
  return paginationEl;
101
101
  };
102
102
 
103
- window.Lightview.tags.Pagination = Pagination;
103
+ globalThis.Lightview.tags.Pagination = Pagination;
104
104
 
105
105
  export default Pagination;
@@ -12,8 +12,8 @@ import '../daisyui.js';
12
12
  * @param {boolean} props.useShadow - Render in Shadow DOM with isolated DaisyUI styles
13
13
  */
14
14
  const Steps = (props = {}, ...children) => {
15
- const { tags } = window.Lightview || {};
16
- const LVX = window.LightviewX || {};
15
+ const { tags } = globalThis.Lightview || {};
16
+ const LVX = globalThis.LightviewX || {};
17
17
 
18
18
  if (!tags) return null;
19
19
 
@@ -61,7 +61,7 @@ const Steps = (props = {}, ...children) => {
61
61
  * Steps Item
62
62
  */
63
63
  Steps.Item = (props = {}, ...children) => {
64
- const { tags } = window.Lightview || {};
64
+ const { tags } = globalThis.Lightview || {};
65
65
  if (!tags) return null;
66
66
 
67
67
  const {
@@ -82,7 +82,7 @@ Steps.Item = (props = {}, ...children) => {
82
82
  }, ...children);
83
83
  };
84
84
 
85
- const tags = window.Lightview.tags;
85
+ const tags = globalThis.Lightview.tags;
86
86
  tags.Steps = Steps;
87
87
  tags['Steps.Item'] = Steps.Item;
88
88
 
@@ -13,8 +13,8 @@ import '../daisyui.js';
13
13
  * @param {boolean} props.useShadow - Render in Shadow DOM with isolated DaisyUI styles
14
14
  */
15
15
  const Tabs = (props = {}, ...children) => {
16
- const { tags } = window.Lightview || {};
17
- const LVX = window.LightviewX || {};
16
+ const { tags } = globalThis.Lightview || {};
17
+ const LVX = globalThis.LightviewX || {};
18
18
 
19
19
  if (!tags) return null;
20
20
 
@@ -70,7 +70,7 @@ const Tabs = (props = {}, ...children) => {
70
70
  * Tab Item
71
71
  */
72
72
  Tabs.Tab = (props = {}, ...children) => {
73
- const { tags } = window.Lightview || {};
73
+ const { tags } = globalThis.Lightview || {};
74
74
  if (!tags) return null;
75
75
 
76
76
  const {
@@ -103,7 +103,7 @@ Tabs.Tab = (props = {}, ...children) => {
103
103
  * Tab Content - for lifted tabs with content panels
104
104
  */
105
105
  Tabs.Content = (props = {}, ...children) => {
106
- const { tags } = window.Lightview || {};
106
+ const { tags } = globalThis.Lightview || {};
107
107
  if (!tags) return null;
108
108
 
109
109
  const { class: className = '', ...rest } = props;
@@ -115,7 +115,7 @@ Tabs.Content = (props = {}, ...children) => {
115
115
  }, ...children);
116
116
  };
117
117
 
118
- const tags = window.Lightview.tags;
118
+ const tags = globalThis.Lightview.tags;
119
119
  tags.Tabs = Tabs;
120
120
  tags['Tabs.Tab'] = Tabs.Tab;
121
121
  tags['Tabs.Content'] = Tabs.Content;
@@ -20,15 +20,15 @@ loadStylesheetSync(import.meta.url);
20
20
  * @param {Function} props.onChange - Theme change handler
21
21
  */
22
22
  const ThemeSwitch = (props = {}) => {
23
-
24
- const { tags, signal, effect } = window.Lightview || {};
23
+
24
+ const { tags, signal, effect } = globalThis.Lightview || {};
25
25
  if (!tags) {
26
26
  console.error('Lightview not found');
27
27
  return null;
28
28
  }
29
-
29
+
30
30
  const { button, span } = tags;
31
-
31
+
32
32
  const {
33
33
  theme,
34
34
  defaultTheme,
@@ -39,41 +39,41 @@ const ThemeSwitch = (props = {}) => {
39
39
  class: className = '',
40
40
  ...rest
41
41
  } = props;
42
-
42
+
43
43
  // Detect system preference
44
44
  const getSystemTheme = () => {
45
45
  if (typeof window === 'undefined') return 'light';
46
- return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
46
+ return globalThis.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
47
47
  };
48
-
48
+
49
49
  // Get initial theme
50
50
  const getInitialTheme = () => {
51
51
  if (typeof window === 'undefined') return defaultTheme || 'light';
52
-
52
+
53
53
  // Check localStorage first
54
54
  const stored = localStorage.getItem(storageKey);
55
55
  if (stored === 'light' || stored === 'dark') return stored;
56
-
56
+
57
57
  // Then default or system
58
58
  return defaultTheme || getSystemTheme();
59
59
  };
60
-
60
+
61
61
  // Internal state
62
62
  const internalTheme = signal ? signal(getInitialTheme()) : { value: getInitialTheme() };
63
-
63
+
64
64
  const isControlled = theme !== undefined;
65
-
65
+
66
66
  const getTheme = () => {
67
67
  if (isControlled) {
68
68
  return typeof theme === 'function' ? theme() :
69
- (theme && typeof theme.value !== 'undefined') ? theme.value : theme;
69
+ (theme && typeof theme.value !== 'undefined') ? theme.value : theme;
70
70
  }
71
71
  return internalTheme.value;
72
72
  };
73
-
73
+
74
74
  const applyTheme = (newTheme) => {
75
75
  document.documentElement.setAttribute('data-theme', newTheme);
76
-
76
+
77
77
  // Also update meta theme-color for mobile browsers
78
78
  let metaTheme = document.querySelector('meta[name="theme-color"]');
79
79
  if (!metaTheme) {
@@ -83,45 +83,45 @@ const ThemeSwitch = (props = {}) => {
83
83
  }
84
84
  metaTheme.content = newTheme === 'dark' ? '#0f172a' : '#ffffff';
85
85
  };
86
-
86
+
87
87
  const toggle = () => {
88
88
  const currentTheme = getTheme();
89
89
  const newTheme = currentTheme === 'light' ? 'dark' : 'light';
90
-
90
+
91
91
  if (!isControlled) {
92
92
  internalTheme.value = newTheme;
93
93
  }
94
-
94
+
95
95
  if (isControlled && theme && typeof theme.value !== 'undefined') {
96
96
  theme.value = newTheme;
97
97
  }
98
-
98
+
99
99
  // Persist to localStorage
100
100
  if (storageKey) {
101
101
  localStorage.setItem(storageKey, newTheme);
102
102
  }
103
-
103
+
104
104
  applyTheme(newTheme);
105
-
105
+
106
106
  if (onChange) {
107
107
  onChange(newTheme);
108
108
  }
109
109
  };
110
-
110
+
111
111
  // Apply theme on mount
112
112
  if (typeof window !== 'undefined') {
113
113
  // Apply immediately
114
114
  applyTheme(getTheme());
115
-
115
+
116
116
  // Set up effect to watch for changes
117
117
  if (effect) {
118
118
  effect(() => {
119
119
  applyTheme(getTheme());
120
120
  });
121
121
  }
122
-
122
+
123
123
  // Listen for system theme changes
124
- window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
124
+ globalThis.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
125
125
  if (!localStorage.getItem(storageKey)) {
126
126
  const newTheme = e.matches ? 'dark' : 'light';
127
127
  if (!isControlled) {
@@ -131,13 +131,13 @@ const ThemeSwitch = (props = {}) => {
131
131
  }
132
132
  });
133
133
  }
134
-
134
+
135
135
  const iconSize = size === 'sm' ? 16 : size === 'lg' ? 28 : 20;
136
-
136
+
137
137
  const classes = ['lv-theme-switch', `lv-theme-switch--${size}`];
138
138
  if (animated) classes.push('lv-theme-switch--animated');
139
139
  if (className) classes.push(className);
140
-
140
+
141
141
  if (animated) {
142
142
  return button({
143
143
  class: classes.join(' '),
@@ -156,7 +156,7 @@ const ThemeSwitch = (props = {}) => {
156
156
  })
157
157
  );
158
158
  }
159
-
159
+
160
160
  return button({
161
161
  class: classes.join(' '),
162
162
  onclick: toggle,
@@ -172,6 +172,6 @@ const ThemeSwitch = (props = {}) => {
172
172
  };
173
173
 
174
174
  // Auto-register
175
- window.Lightview.tags.ThemeSwitch = ThemeSwitch;
175
+ globalThis.Lightview.tags.ThemeSwitch = ThemeSwitch;
176
176
 
177
177
  export default ThemeSwitch;