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.
- package/README.md +47 -1283
- package/components/actions/button.js +5 -5
- package/components/actions/dropdown.js +6 -6
- package/components/actions/modal.js +9 -9
- package/components/actions/swap.js +5 -5
- package/components/data-display/accordion.js +6 -6
- package/components/data-display/alert.js +6 -6
- package/components/data-display/avatar.js +7 -7
- package/components/data-display/badge.js +5 -5
- package/components/data-display/card.js +7 -7
- package/components/data-display/carousel.js +4 -4
- package/components/data-display/chart.js +8 -8
- package/components/data-display/chat.js +7 -7
- package/components/data-display/collapse.js +5 -5
- package/components/data-display/countdown.js +3 -3
- package/components/data-display/diff.js +6 -6
- package/components/data-display/kbd.js +5 -5
- package/components/data-display/loading.js +5 -5
- package/components/data-display/progress.js +5 -5
- package/components/data-display/radial-progress.js +5 -5
- package/components/data-display/skeleton.js +3 -3
- package/components/data-display/stats.js +9 -9
- package/components/data-display/table.js +9 -9
- package/components/data-display/timeline.js +8 -8
- package/components/data-display/toast.js +3 -3
- package/components/data-display/tooltip.js +3 -3
- package/components/data-input/checkbox.js +5 -5
- package/components/data-input/file-input.js +3 -3
- package/components/data-input/input.js +5 -5
- package/components/data-input/radio.js +9 -9
- package/components/data-input/range.js +3 -3
- package/components/data-input/rating.js +3 -3
- package/components/data-input/select.js +5 -5
- package/components/data-input/textarea.js +3 -3
- package/components/data-input/toggle.js +5 -5
- package/components/layout/divider.js +3 -3
- package/components/layout/drawer.js +7 -7
- package/components/layout/footer.js +5 -5
- package/components/layout/hero.js +5 -5
- package/components/layout/indicator.js +4 -4
- package/components/layout/join.js +4 -4
- package/components/layout/navbar.js +6 -6
- package/components/navigation/breadcrumbs.js +4 -4
- package/components/navigation/dock.js +5 -5
- package/components/navigation/menu.js +6 -6
- package/components/navigation/pagination.js +3 -3
- package/components/navigation/steps.js +4 -4
- package/components/navigation/tabs.js +5 -5
- package/components/theme/theme-switch.js +30 -30
- package/docs/about.html +142 -14
- package/docs/api/computed.html +1 -6
- package/docs/api/effects.html +1 -7
- package/docs/api/elements.html +6 -10
- package/docs/api/enhance.html +1 -6
- package/docs/api/hypermedia.html +154 -22
- package/docs/api/index.html +7 -12
- package/docs/api/nav.html +18 -1
- package/docs/api/signals.html +1 -6
- package/docs/api/state.html +1 -6
- package/docs/assets/js/examplify-sandbox.html +2 -2
- package/docs/assets/js/examplify.js +15 -15
- package/docs/components/accordion.html +4 -4
- package/docs/components/alert.html +4 -4
- package/docs/components/avatar.html +4 -4
- package/docs/components/badge.html +4 -4
- package/docs/components/breadcrumbs.html +3 -3
- package/docs/components/button.html +5 -5
- package/docs/components/card.html +4 -4
- package/docs/components/carousel.html +3 -3
- package/docs/components/chart-area.html +6 -6
- package/docs/components/chart-bar.html +6 -6
- package/docs/components/chart-column.html +6 -6
- package/docs/components/chart-line.html +6 -6
- package/docs/components/chart-pie.html +6 -6
- package/docs/components/chart.html +2 -2
- package/docs/components/chat.html +4 -4
- package/docs/components/checkbox.html +4 -4
- package/docs/components/collapse.html +4 -4
- package/docs/components/countdown.html +4 -4
- package/docs/components/diff.html +3 -3
- package/docs/components/divider.html +3 -3
- package/docs/components/dock.html +3 -3
- package/docs/components/drawer.html +4 -4
- package/docs/components/dropdown.html +4 -4
- package/docs/components/file-input.html +4 -4
- package/docs/components/footer.html +3 -3
- package/docs/components/gallery.html +2 -2
- package/docs/components/hero.html +3 -3
- package/docs/components/index.css +5 -3
- package/docs/components/index.html +4 -4
- package/docs/components/indicator.html +3 -3
- package/docs/components/input.html +4 -4
- package/docs/components/join.html +3 -3
- package/docs/components/kbd.html +3 -3
- package/docs/components/loading.html +4 -4
- package/docs/components/menu.html +4 -4
- package/docs/components/modal.html +4 -4
- package/docs/components/navbar.html +3 -3
- package/docs/components/pagination.html +3 -3
- package/docs/components/progress.html +4 -4
- package/docs/components/radial-progress.html +3 -3
- package/docs/components/radio.html +4 -4
- package/docs/components/range.html +4 -4
- package/docs/components/rating.html +4 -4
- package/docs/components/select.html +4 -4
- package/docs/components/sidebar-setup.js +1 -1
- package/docs/components/skeleton.html +4 -4
- package/docs/components/spinner.html +4 -4
- package/docs/components/stats.html +4 -4
- package/docs/components/steps.html +3 -3
- package/docs/components/swap.html +4 -4
- package/docs/components/switch.html +4 -4
- package/docs/components/table.html +4 -4
- package/docs/components/tabs.html +4 -4
- package/docs/components/text-input.html +4 -4
- package/docs/components/textarea.html +4 -4
- package/docs/components/timeline.html +4 -4
- package/docs/components/toast.html +4 -4
- package/docs/components/toggle.html +4 -4
- package/docs/components/tooltip.html +4 -4
- package/docs/examples/getting-started-example.html +1 -1
- package/docs/examples/index.html +1 -2
- package/docs/getting-started/index.html +105 -14
- package/docs/index.html +2 -11
- package/docs/router-nav.html +13 -0
- package/docs/router.html +60 -17
- package/docs/styles/index.html +2 -7
- package/docs/syntax.html +144 -0
- package/functions/_middleware.js +17 -10
- package/functions/processServerScripts.js +127 -0
- package/index.html +8 -8
- package/lightview-router.js +141 -297
- package/lightview-x.js +604 -573
- package/lightview.js +179 -157
- package/package.json +33 -26
- package/scripts/analysis/README.md +2 -0
- package/scripts/analysis/analyze.js +266 -0
- package/scripts/analysis/latest_metrics.md +185 -0
- package/wrangler.toml +6 -0
- 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 } =
|
|
17
|
-
const LVX =
|
|
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 } =
|
|
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 } =
|
|
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 =
|
|
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 } =
|
|
16
|
-
const LVX =
|
|
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 } =
|
|
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 =
|
|
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 } =
|
|
16
|
-
const LVX =
|
|
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 } =
|
|
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
|
-
|
|
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 } =
|
|
16
|
-
const LVX =
|
|
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 } =
|
|
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 } =
|
|
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 } =
|
|
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 =
|
|
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 } =
|
|
16
|
-
const LVX =
|
|
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 } =
|
|
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 =
|
|
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 } =
|
|
16
|
-
const LVX =
|
|
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 } =
|
|
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 } =
|
|
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 =
|
|
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 } =
|
|
18
|
-
const LVX =
|
|
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 } =
|
|
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 } =
|
|
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 } =
|
|
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 =
|
|
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 } =
|
|
19
|
-
const LVX =
|
|
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
|
-
|
|
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 } =
|
|
16
|
-
const LVX =
|
|
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 } =
|
|
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 =
|
|
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 } =
|
|
17
|
-
const LVX =
|
|
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 } =
|
|
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 } =
|
|
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 =
|
|
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 } =
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
175
|
+
globalThis.Lightview.tags.ThemeSwitch = ThemeSwitch;
|
|
176
176
|
|
|
177
177
|
export default ThemeSwitch;
|