lightview 1.8.1-b → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/workflows/daisyui-component-migration.md +155 -0
- package/.codacy/cli.sh +149 -0
- package/.codacy/codacy.yaml +15 -0
- package/.github/instructions/codacy.instructions.md +72 -0
- package/.wranglerignore +21 -0
- package/README.md +1331 -21
- package/_headers +4 -0
- package/build.js +70 -0
- package/components/actions/button.js +151 -0
- package/components/actions/dropdown.js +120 -0
- package/components/actions/modal.js +146 -0
- package/components/actions/swap.js +118 -0
- package/components/daisyui.js +288 -0
- package/components/data-display/accordion.js +128 -0
- package/components/data-display/alert.js +112 -0
- package/components/data-display/avatar.js +170 -0
- package/components/data-display/badge.js +82 -0
- package/components/data-display/card.js +151 -0
- package/components/data-display/carousel.js +94 -0
- package/components/data-display/chart.js +220 -0
- package/components/data-display/chat.js +128 -0
- package/components/data-display/collapse.js +103 -0
- package/components/data-display/countdown.js +69 -0
- package/components/data-display/diff.js +111 -0
- package/components/data-display/kbd.js +65 -0
- package/components/data-display/loading.js +75 -0
- package/components/data-display/progress.js +79 -0
- package/components/data-display/radial-progress.js +88 -0
- package/components/data-display/skeleton.js +66 -0
- package/components/data-display/stats.js +159 -0
- package/components/data-display/table.js +146 -0
- package/components/data-display/timeline.js +146 -0
- package/components/data-display/toast.js +72 -0
- package/components/data-display/tooltip.js +74 -0
- package/components/data-input/checkbox.js +253 -0
- package/components/data-input/file-input.js +224 -0
- package/components/data-input/input.js +264 -0
- package/components/data-input/radio.js +338 -0
- package/components/data-input/range.js +204 -0
- package/components/data-input/rating.js +219 -0
- package/components/data-input/select.js +287 -0
- package/components/data-input/textarea.js +287 -0
- package/components/data-input/toggle.js +201 -0
- package/components/index.js +137 -0
- package/components/layout/divider.js +72 -0
- package/components/layout/drawer.js +142 -0
- package/components/layout/footer.js +100 -0
- package/components/layout/hero.js +109 -0
- package/components/layout/indicator.js +90 -0
- package/components/layout/join.js +78 -0
- package/components/layout/navbar.js +110 -0
- package/components/navigation/breadcrumbs.js +91 -0
- package/components/navigation/dock.js +103 -0
- package/components/navigation/menu.js +126 -0
- package/components/navigation/pagination.js +105 -0
- package/components/navigation/steps.js +89 -0
- package/components/navigation/tabs.css +177 -0
- package/components/navigation/tabs.js +123 -0
- package/components/theme/theme-switch.css +65 -0
- package/components/theme/theme-switch.js +177 -0
- package/docs/about.html +164 -0
- package/docs/api/computed.html +184 -0
- package/docs/api/effects.html +173 -0
- package/docs/api/elements.html +180 -0
- package/docs/api/enhance.html +225 -0
- package/docs/api/hypermedia.html +165 -0
- package/docs/api/index.html +178 -0
- package/docs/api/nav.html +18 -0
- package/docs/api/signals.html +136 -0
- package/docs/api/state.html +217 -0
- package/docs/assets/images/logo-favicon.svg +42 -0
- package/docs/assets/images/logo-static.svg +40 -0
- package/docs/assets/images/logo.svg +66 -0
- package/docs/assets/js/examplify.js +395 -0
- package/docs/assets/styles/site.css +1102 -0
- package/docs/assets/styles/themes.css +236 -0
- package/docs/components/accordion.html +439 -0
- package/docs/components/alert.html +528 -0
- package/docs/components/avatar.html +586 -0
- package/docs/components/badge.html +531 -0
- package/docs/components/breadcrumbs.html +278 -0
- package/docs/components/button.html +579 -0
- package/docs/components/card.html +561 -0
- package/docs/components/carousel.html +286 -0
- package/docs/components/chart-area.html +702 -0
- package/docs/components/chart-bar.html +782 -0
- package/docs/components/chart-column.html +735 -0
- package/docs/components/chart-line.html +794 -0
- package/docs/components/chart-pie.html +823 -0
- package/docs/components/chart.html +612 -0
- package/docs/components/chat.html +547 -0
- package/docs/components/checkbox.html +641 -0
- package/docs/components/collapse.html +536 -0
- package/docs/components/component-nav.html +53 -0
- package/docs/components/countdown.html +470 -0
- package/docs/components/diff.html +245 -0
- package/docs/components/divider.html +240 -0
- package/docs/components/dock.html +277 -0
- package/docs/components/drawer.html +515 -0
- package/docs/components/dropdown.html +479 -0
- package/docs/components/file-input.html +591 -0
- package/docs/components/footer.html +301 -0
- package/docs/components/gallery.html +504 -0
- package/docs/components/hero.html +264 -0
- package/docs/components/index.css +840 -0
- package/docs/components/index.html +735 -0
- package/docs/components/indicator.html +342 -0
- package/docs/components/input.html +644 -0
- package/docs/components/join.html +285 -0
- package/docs/components/kbd.html +322 -0
- package/docs/components/loading.html +521 -0
- package/docs/components/menu.html +461 -0
- package/docs/components/modal.html +639 -0
- package/docs/components/navbar.html +321 -0
- package/docs/components/pagination.html +279 -0
- package/docs/components/progress.html +514 -0
- package/docs/components/radial-progress.html +434 -0
- package/docs/components/radio.html +655 -0
- package/docs/components/range.html +611 -0
- package/docs/components/rating.html +642 -0
- package/docs/components/select.html +696 -0
- package/docs/components/sidebar-setup.js +93 -0
- package/docs/components/skeleton.html +447 -0
- package/docs/components/spinner.html +68 -0
- package/docs/components/stats.html +486 -0
- package/docs/components/steps.html +356 -0
- package/docs/components/swap.html +517 -0
- package/docs/components/switch.html +68 -0
- package/docs/components/table.html +668 -0
- package/docs/components/tabs.html +506 -0
- package/docs/components/text-input.html +68 -0
- package/docs/components/textarea.html +603 -0
- package/docs/components/timeline.html +487 -0
- package/docs/components/toast.html +474 -0
- package/docs/components/toggle.html +564 -0
- package/docs/components/tooltip.html +423 -0
- package/docs/examples/getting-started-example.html +40 -0
- package/docs/examples/index.html +93 -0
- package/docs/getting-started/index.html +739 -0
- package/docs/getting-started/reviews.html +23 -0
- package/docs/getting-started/reviews.odom +108 -0
- package/docs/getting-started/reviews.vdom +84 -0
- package/docs/index.html +134 -0
- package/docs/playground.html +416 -0
- package/docs/router.html +285 -0
- package/docs/styles/index.html +190 -0
- package/functions/_middleware.js +32 -0
- package/index.html +309 -0
- package/lightview-router.js +364 -0
- package/lightview-x.js +1577 -0
- package/lightview.js +658 -1109
- package/lightview.js.backup +793 -0
- package/middleware/locale.js +25 -0
- package/middleware/markdown.js +44 -0
- package/middleware/notFound.js +37 -0
- package/package.json +27 -41
- package/watch.js +92 -0
- package/wrangler.toml +12 -0
- package/.idea/lightview.iml +0 -12
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/LICENSE +0 -21
- package/codepen-no-tabs-embed.css +0 -2
- package/components/chart/chart.html +0 -17
- package/components/chart/example.html +0 -32
- package/components/chart.html +0 -83
- package/components/components.js +0 -113
- package/components/gantt/example.html +0 -22
- package/components/gantt/gantt.html +0 -42
- package/components/gauge/example.html +0 -28
- package/components/gauge/gauge.html +0 -20
- package/components/gauge.html +0 -60
- package/components/orgchart/example.html +0 -25
- package/components/orgchart/orgchart.html +0 -41
- package/components/repl/code-editor.html +0 -64
- package/components/repl/editor.html +0 -37
- package/components/repl/editorjs-inline-tool/index.js +0 -3
- package/components/repl/editorjs-inline-tool/inline-tools.js +0 -28
- package/components/repl/editorjs-inline-tool/tool.js +0 -175
- package/components/repl/repl-with-wysiwyg.html +0 -355
- package/components/repl/repl.html +0 -345
- package/components/repl/sup.js +0 -44
- package/components/repl/wysiwyg-repl.html +0 -258
- package/components/timeline/example.html +0 -33
- package/components/timeline/timeline.html +0 -44
- package/components/timeline.html +0 -81
- package/examples/anchor.html +0 -11
- package/examples/chart.html +0 -34
- package/examples/counter.html +0 -26
- package/examples/counter.test.mjs +0 -47
- package/examples/counter2.html +0 -26
- package/examples/directives.html +0 -79
- package/examples/foreign.html +0 -50
- package/examples/forgeinform.html +0 -98
- package/examples/form.html +0 -61
- package/examples/gauge.html +0 -18
- package/examples/invalid-template-literals.html +0 -44
- package/examples/medium/remote.html +0 -60
- package/examples/message.html +0 -18
- package/examples/nested.html +0 -11
- package/examples/object-bound-form.html +0 -34
- package/examples/remote-server.js +0 -51
- package/examples/remote.html +0 -34
- package/examples/remote.json +0 -1
- package/examples/scratch.html +0 -69
- package/examples/sensors/index.html +0 -30
- package/examples/sensors/sensor-server.js +0 -30
- package/examples/shared.html +0 -41
- package/examples/template.html +0 -33
- package/examples/timeline.html +0 -21
- package/examples/todo.html +0 -38
- package/examples/top.html +0 -10
- package/examples/types.html +0 -94
- package/examples/xor.html +0 -62
- package/jest-puppeteer.config.js +0 -5
- package/jest.config.json +0 -12
- package/sites/client.html +0 -48
- package/sites/index.html +0 -247
- package/test/basic.html +0 -93
- package/test/basic.test.mjs +0 -315
- package/test/extended.html +0 -29
- package/test/extended.test.mjs +0 -448
- package/types.js +0 -534
- package/unsplash.key +0 -1
|
@@ -0,0 +1,642 @@
|
|
|
1
|
+
<!-- SEO-friendly SPA Shim -->
|
|
2
|
+
<script src="/lightview-router.js"></script>
|
|
3
|
+
<script>
|
|
4
|
+
if (window.LightviewRouter) {
|
|
5
|
+
LightviewRouter.base('/index.html');
|
|
6
|
+
}
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<!-- Load the page-specific stylesheet -->
|
|
10
|
+
<link rel="stylesheet" href="./index.css">
|
|
11
|
+
|
|
12
|
+
<!-- Gallery Structure -->
|
|
13
|
+
<div class="gallery-page">
|
|
14
|
+
<div class="gallery-layout">
|
|
15
|
+
<!-- Sidebar Overlay -->
|
|
16
|
+
<div id="sidebar-overlay" class="sidebar-overlay"></div>
|
|
17
|
+
|
|
18
|
+
<!-- Sidebar -->
|
|
19
|
+
<div id="gallery-sidebar" class="gallery-sidebar" style="visibility: hidden" src="./component-nav.html"></div>
|
|
20
|
+
|
|
21
|
+
<!-- Main Content -->
|
|
22
|
+
<div id="gallery-main" class="gallery-main">
|
|
23
|
+
<!-- Header Container -->
|
|
24
|
+
<div
|
|
25
|
+
style="position: sticky; top: 0; z-index: 30; background: var(--gallery-surface); border-bottom: 1px solid var(--gallery-border); backdrop-filter: blur(8px);">
|
|
26
|
+
<!-- Breadcrumbs Row -->
|
|
27
|
+
<div style="padding: 0.75rem 1.5rem 0;">
|
|
28
|
+
<script>
|
|
29
|
+
(() => {
|
|
30
|
+
const { Breadcrumbs } = Lightview.tags;
|
|
31
|
+
const breadcrumbs = Breadcrumbs({
|
|
32
|
+
id: 'page-breadcrumbs',
|
|
33
|
+
items: [
|
|
34
|
+
{ label: 'Components', href: '/docs/components' },
|
|
35
|
+
{ label: 'Rating' }
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
document.currentScript.replaceWith(breadcrumbs.domEl);
|
|
39
|
+
})();
|
|
40
|
+
</script>
|
|
41
|
+
</div>
|
|
42
|
+
<!-- Title Row -->
|
|
43
|
+
<div class="gallery-header"
|
|
44
|
+
style="border-bottom: none; height: auto; padding-top: 0.5rem; padding-bottom: 0.75rem;">
|
|
45
|
+
<button id="toggle-btn" class="toggle-btn" aria-label="Toggle Sidebar">
|
|
46
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="toggle-icon"
|
|
47
|
+
style="stroke: currentColor; stroke-width: 2;">
|
|
48
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7" />
|
|
49
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M11 19l-7-7 7-7" />
|
|
50
|
+
</svg>
|
|
51
|
+
</button>
|
|
52
|
+
<h1 class="gallery-title">Rating</h1>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<!-- Content -->
|
|
57
|
+
<div class="gallery-content">
|
|
58
|
+
<div class="section-content" style="max-width: 1000px;">
|
|
59
|
+
<p class="text-lg" style="opacity: 0.7; margin-bottom: 1.5rem;">
|
|
60
|
+
Rating allows users to rate items with stars or other shapes.
|
|
61
|
+
Supports labels, half stars, different masks, and reactive state binding.
|
|
62
|
+
</p>
|
|
63
|
+
|
|
64
|
+
<!-- Basic Example with Examplify -->
|
|
65
|
+
<div class="card bg-base-200" style="margin-bottom: 2rem;">
|
|
66
|
+
<div class="card-body">
|
|
67
|
+
<h2 class="card-title">Basic Examples</h2>
|
|
68
|
+
<p class="text-sm" style="opacity: 0.7; margin-bottom: 1rem;">Rating components with various
|
|
69
|
+
configurations</p>
|
|
70
|
+
|
|
71
|
+
<!-- Tabs -->
|
|
72
|
+
<script>
|
|
73
|
+
window.switchSyntaxTab = (tabId) => {
|
|
74
|
+
const tabs = ['tagged', 'vdom', 'object'];
|
|
75
|
+
tabs.forEach(t => {
|
|
76
|
+
const tabEl = document.getElementById(`tab-btn-${t}`);
|
|
77
|
+
const contentEl = document.getElementById(`syntax-${t}`);
|
|
78
|
+
if (t === tabId) {
|
|
79
|
+
tabEl.classList.add('syntax-tab-active');
|
|
80
|
+
contentEl.style.display = 'block';
|
|
81
|
+
} else {
|
|
82
|
+
tabEl.classList.remove('syntax-tab-active');
|
|
83
|
+
contentEl.style.display = 'none';
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
</script>
|
|
88
|
+
<div role="tablist" class="syntax-tabs" style="margin-bottom: 1rem;">
|
|
89
|
+
<button id="tab-btn-tagged" role="tab" class="syntax-tab syntax-tab-active"
|
|
90
|
+
onclick="switchSyntaxTab('tagged')">Tagged</button>
|
|
91
|
+
<button id="tab-btn-vdom" role="tab" class="syntax-tab"
|
|
92
|
+
onclick="switchSyntaxTab('vdom')">vDOM</button>
|
|
93
|
+
<button id="tab-btn-object" role="tab" class="syntax-tab"
|
|
94
|
+
onclick="switchSyntaxTab('object')">Object
|
|
95
|
+
DOM</button>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<!-- Tagged Syntax -->
|
|
99
|
+
<div id="syntax-tagged">
|
|
100
|
+
<pre><script>
|
|
101
|
+
examplify(document.currentScript.nextElementSibling, {
|
|
102
|
+
at: document.currentScript.parentElement,
|
|
103
|
+
scripts: ['/lightview.js', '/lightview-x.js'],
|
|
104
|
+
type: 'module',
|
|
105
|
+
minHeight: 300,
|
|
106
|
+
autoRun: true
|
|
107
|
+
});
|
|
108
|
+
</script><code contenteditable="true">const { default: Rating } = await import('/components/data-input/rating.js');
|
|
109
|
+
const { tags, $ } = Lightview;
|
|
110
|
+
const { div, p } = tags;
|
|
111
|
+
|
|
112
|
+
// 1. Basic rating
|
|
113
|
+
const basic = Rating({
|
|
114
|
+
defaultValue: 3
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// 2. Rating with label
|
|
118
|
+
const withLabel = Rating({
|
|
119
|
+
label: 'Rate this product',
|
|
120
|
+
defaultValue: 4,
|
|
121
|
+
max: 5
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// 3. Rating with different colors and masks
|
|
125
|
+
const hearts = Rating({
|
|
126
|
+
label: 'Love it?',
|
|
127
|
+
defaultValue: 3,
|
|
128
|
+
mask: 'heart',
|
|
129
|
+
color: 'red-500'
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// 4. Half stars
|
|
133
|
+
const halfStars = Rating({
|
|
134
|
+
label: 'Precise rating',
|
|
135
|
+
half: true,
|
|
136
|
+
defaultValue: 3.5,
|
|
137
|
+
hidden: true
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// Insert all examples
|
|
141
|
+
$('#example').content(
|
|
142
|
+
div({ style: 'display: flex; flex-direction: column; gap: 1.5rem' }, basic, withLabel, hearts, halfStars)
|
|
143
|
+
);</code></pre>
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
<!-- vDOM Syntax -->
|
|
147
|
+
<div id="syntax-vdom" style="display: none;">
|
|
148
|
+
<pre><script>
|
|
149
|
+
examplify(document.currentScript.nextElementSibling, {
|
|
150
|
+
at: document.currentScript.parentElement,
|
|
151
|
+
scripts: ['/lightview.js', '/lightview-x.js'],
|
|
152
|
+
type: 'module',
|
|
153
|
+
minHeight: 300
|
|
154
|
+
});
|
|
155
|
+
</script><code contenteditable="true">const { default: Rating } = await import('/components/data-input/rating.js');
|
|
156
|
+
const { $ } = Lightview;
|
|
157
|
+
|
|
158
|
+
const basic = {
|
|
159
|
+
tag: Rating,
|
|
160
|
+
attributes: {
|
|
161
|
+
defaultValue: 3
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const withLabel = {
|
|
166
|
+
tag: Rating,
|
|
167
|
+
attributes: {
|
|
168
|
+
label: 'Rate this product',
|
|
169
|
+
defaultValue: 4,
|
|
170
|
+
max: 5
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const hearts = {
|
|
175
|
+
tag: Rating,
|
|
176
|
+
attributes: {
|
|
177
|
+
label: 'Love it?',
|
|
178
|
+
defaultValue: 3,
|
|
179
|
+
mask: 'heart',
|
|
180
|
+
color: 'red-500'
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const halfStars = {
|
|
185
|
+
tag: Rating,
|
|
186
|
+
attributes: {
|
|
187
|
+
label: 'Precise rating',
|
|
188
|
+
half: true,
|
|
189
|
+
defaultValue: 3.5,
|
|
190
|
+
hidden: true
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
$('#example').content({
|
|
195
|
+
tag: 'div',
|
|
196
|
+
attributes: { style: 'display: flex; flex-direction: column; gap: 1.5rem' },
|
|
197
|
+
children: [basic, withLabel, hearts, halfStars]
|
|
198
|
+
});</code></pre>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<!-- Object DOM Syntax -->
|
|
202
|
+
<div id="syntax-object" style="display: none;">
|
|
203
|
+
<pre><script>
|
|
204
|
+
examplify(document.currentScript.nextElementSibling, {
|
|
205
|
+
at: document.currentScript.parentElement,
|
|
206
|
+
scripts: ['/lightview.js', '/lightview-x.js'],
|
|
207
|
+
type: 'module',
|
|
208
|
+
minHeight: 300
|
|
209
|
+
});
|
|
210
|
+
</script><code contenteditable="true">const { default: Rating } = await import('/components/data-input/rating.js');
|
|
211
|
+
const { tags, $ } = Lightview;
|
|
212
|
+
tags.Rating = Rating;
|
|
213
|
+
|
|
214
|
+
$('#example').content({
|
|
215
|
+
div: {
|
|
216
|
+
style: 'display: flex; flex-direction: column; gap: 1.5rem',
|
|
217
|
+
children: [
|
|
218
|
+
{
|
|
219
|
+
Rating: {
|
|
220
|
+
defaultValue: 3
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
Rating: {
|
|
225
|
+
label: 'Rate this product',
|
|
226
|
+
defaultValue: 4,
|
|
227
|
+
max: 5
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
Rating: {
|
|
232
|
+
label: 'Love it?',
|
|
233
|
+
defaultValue: 3,
|
|
234
|
+
mask: 'heart',
|
|
235
|
+
color: 'red-500'
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
Rating: {
|
|
240
|
+
label: 'Precise rating',
|
|
241
|
+
half: true,
|
|
242
|
+
defaultValue: 3.5,
|
|
243
|
+
hidden: true
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
});</code></pre>
|
|
249
|
+
</div>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
|
|
253
|
+
<!-- Reactive Example with Examplify -->
|
|
254
|
+
<div class="card bg-base-200" style="margin-bottom: 2rem;">
|
|
255
|
+
<div class="card-body">
|
|
256
|
+
<h2 class="card-title">Reactive Example</h2>
|
|
257
|
+
<p class="text-sm" style="opacity: 0.7; margin-bottom: 1rem;">Two-way binding with signals
|
|
258
|
+
</p>
|
|
259
|
+
|
|
260
|
+
<!-- Tabs -->
|
|
261
|
+
<script>
|
|
262
|
+
window.switchReactiveSyntaxTab = (tabId) => {
|
|
263
|
+
const tabs = ['tagged', 'vdom', 'object'];
|
|
264
|
+
tabs.forEach(t => {
|
|
265
|
+
const tabEl = document.getElementById(`reactive-tab-btn-${t}`);
|
|
266
|
+
const contentEl = document.getElementById(`reactive-syntax-${t}`);
|
|
267
|
+
if (t === tabId) {
|
|
268
|
+
tabEl.classList.add('syntax-tab-active');
|
|
269
|
+
contentEl.style.display = 'block';
|
|
270
|
+
} else {
|
|
271
|
+
tabEl.classList.remove('syntax-tab-active');
|
|
272
|
+
contentEl.style.display = 'none';
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
</script>
|
|
277
|
+
<div role="tablist" class="syntax-tabs" style="margin-bottom: 1rem;">
|
|
278
|
+
<button id="reactive-tab-btn-tagged" role="tab" class="syntax-tab syntax-tab-active"
|
|
279
|
+
onclick="switchReactiveSyntaxTab('tagged')">Tagged</button>
|
|
280
|
+
<button id="reactive-tab-btn-vdom" role="tab" class="syntax-tab"
|
|
281
|
+
onclick="switchReactiveSyntaxTab('vdom')">vDOM</button>
|
|
282
|
+
<button id="reactive-tab-btn-object" role="tab" class="syntax-tab"
|
|
283
|
+
onclick="switchReactiveSyntaxTab('object')">Object DOM</button>
|
|
284
|
+
</div>
|
|
285
|
+
|
|
286
|
+
<!-- Tagged Syntax -->
|
|
287
|
+
<div id="reactive-syntax-tagged">
|
|
288
|
+
<pre><script>
|
|
289
|
+
examplify(document.currentScript.nextElementSibling, {
|
|
290
|
+
at: document.currentScript.parentElement,
|
|
291
|
+
scripts: ['/lightview.js', '/lightview-x.js'],
|
|
292
|
+
type: 'module',
|
|
293
|
+
minHeight: 220
|
|
294
|
+
});
|
|
295
|
+
</script><code contenteditable="true">const { default: Rating } = await import('/components/data-input/rating.js');
|
|
296
|
+
const { signal, tags, $ } = Lightview;
|
|
297
|
+
const { div, p, span } = tags;
|
|
298
|
+
|
|
299
|
+
// Signal for two-way binding
|
|
300
|
+
const rating = signal(0);
|
|
301
|
+
|
|
302
|
+
// Reactive rating demo
|
|
303
|
+
const reactiveDemo = div({ style: 'display: flex; flex-direction: column; gap: 1rem' },
|
|
304
|
+
Rating({
|
|
305
|
+
label: 'How was your experience?',
|
|
306
|
+
value: rating,
|
|
307
|
+
max: 5,
|
|
308
|
+
size: 'lg',
|
|
309
|
+
hidden: true,
|
|
310
|
+
helper: 'Click to rate'
|
|
311
|
+
}),
|
|
312
|
+
div({ class: 'divider' }),
|
|
313
|
+
p({ class: 'text-lg font-semibold' },
|
|
314
|
+
() => {
|
|
315
|
+
const val = rating.value;
|
|
316
|
+
if (val === 0) return span({class: 'opacity-50'}, 'No rating yet');
|
|
317
|
+
if (val <= 1) return span({class: 'text-error'}, '😞 Poor');
|
|
318
|
+
if (val <= 2) return span({class: 'text-warning'}, '😐 Fair');
|
|
319
|
+
if (val <= 3) return span({class: 'text-info'}, '🙂 Good');
|
|
320
|
+
if (val <= 4) return span({class: 'text-success'}, '😊 Great');
|
|
321
|
+
return span({class: 'text-primary'}, '🤩 Excellent!');
|
|
322
|
+
}
|
|
323
|
+
),
|
|
324
|
+
p({ class: 'text-sm font-mono opacity-70' },
|
|
325
|
+
() => `Rating value: ${rating.value} / 5`
|
|
326
|
+
)
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
$('#example').content(reactiveDemo);</code></pre>
|
|
330
|
+
</div>
|
|
331
|
+
|
|
332
|
+
<!-- vDOM Syntax -->
|
|
333
|
+
<div id="reactive-syntax-vdom" style="display: none;">
|
|
334
|
+
<pre><script>
|
|
335
|
+
examplify(document.currentScript.nextElementSibling, {
|
|
336
|
+
at: document.currentScript.parentElement,
|
|
337
|
+
scripts: ['/lightview.js', '/lightview-x.js'],
|
|
338
|
+
type: 'module',
|
|
339
|
+
minHeight: 220
|
|
340
|
+
});
|
|
341
|
+
</script><code contenteditable="true">const { default: Rating } = await import('/components/data-input/rating.js');
|
|
342
|
+
const { signal, $ } = Lightview;
|
|
343
|
+
|
|
344
|
+
const rating = signal(0);
|
|
345
|
+
|
|
346
|
+
const reactiveDemo = {
|
|
347
|
+
tag: 'div',
|
|
348
|
+
attributes: { style: 'display: flex; flex-direction: column; gap: 1rem' },
|
|
349
|
+
children: [
|
|
350
|
+
{
|
|
351
|
+
tag: Rating,
|
|
352
|
+
attributes: {
|
|
353
|
+
label: 'How was your experience?',
|
|
354
|
+
value: rating,
|
|
355
|
+
max: 5,
|
|
356
|
+
size: 'lg',
|
|
357
|
+
hidden: true,
|
|
358
|
+
helper: 'Click to rate'
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
{ tag: 'div', attributes: { class: 'divider' } },
|
|
362
|
+
{
|
|
363
|
+
tag: 'p',
|
|
364
|
+
attributes: { class: 'text-lg font-semibold' },
|
|
365
|
+
children: [
|
|
366
|
+
() => {
|
|
367
|
+
const val = rating.value;
|
|
368
|
+
if (val === 0) return { tag: 'span', attributes: { class: 'opacity-50' }, children: ['No rating yet'] };
|
|
369
|
+
if (val <= 1) return { tag: 'span', attributes: { class: 'text-error' }, children: ['😞 Poor'] };
|
|
370
|
+
if (val <= 2) return { tag: 'span', attributes: { class: 'text-warning' }, children: ['😐 Fair'] };
|
|
371
|
+
if (val <= 3) return { tag: 'span', attributes: { class: 'text-info' }, children: ['🙂 Good'] };
|
|
372
|
+
if (val <= 4) return { tag: 'span', attributes: { class: 'text-success' }, children: ['😊 Great'] };
|
|
373
|
+
return { tag: 'span', attributes: { class: 'text-primary' }, children: ['🤩 Excellent!'] };
|
|
374
|
+
}
|
|
375
|
+
]
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
tag: 'p',
|
|
379
|
+
attributes: { class: 'text-sm font-mono opacity-70' },
|
|
380
|
+
children: [
|
|
381
|
+
() => `Rating value: ${rating.value} / 5`
|
|
382
|
+
]
|
|
383
|
+
}
|
|
384
|
+
]
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
$('#example').content(reactiveDemo);</code></pre>
|
|
388
|
+
</div>
|
|
389
|
+
|
|
390
|
+
<!-- Object DOM Syntax -->
|
|
391
|
+
<div id="reactive-syntax-object" style="display: none;">
|
|
392
|
+
<pre><script>
|
|
393
|
+
examplify(document.currentScript.nextElementSibling, {
|
|
394
|
+
at: document.currentScript.parentElement,
|
|
395
|
+
scripts: ['/lightview.js', '/lightview-x.js'],
|
|
396
|
+
type: 'module',
|
|
397
|
+
minHeight: 220
|
|
398
|
+
});
|
|
399
|
+
</script><code contenteditable="true">const { default: Rating } = await import('/components/data-input/rating.js');
|
|
400
|
+
const { signal, tags, $ } = Lightview;
|
|
401
|
+
tags.Rating = Rating;
|
|
402
|
+
|
|
403
|
+
const rating = signal(0);
|
|
404
|
+
|
|
405
|
+
const reactiveDemo = {
|
|
406
|
+
div: {
|
|
407
|
+
style: 'display: flex; flex-direction: column; gap: 1rem',
|
|
408
|
+
children: [
|
|
409
|
+
{
|
|
410
|
+
Rating: {
|
|
411
|
+
label: 'How was your experience?',
|
|
412
|
+
value: rating,
|
|
413
|
+
max: 5,
|
|
414
|
+
size: 'lg',
|
|
415
|
+
hidden: true,
|
|
416
|
+
helper: 'Click to rate'
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
{ div: { class: 'divider' } },
|
|
420
|
+
{
|
|
421
|
+
p: {
|
|
422
|
+
class: 'text-lg font-semibold',
|
|
423
|
+
children: [
|
|
424
|
+
() => {
|
|
425
|
+
const val = rating.value;
|
|
426
|
+
if (val === 0) return { span: { class: 'opacity-50', children: ['No rating yet'] } };
|
|
427
|
+
if (val <= 1) return { span: { class: 'text-error', children: ['😞 Poor'] } };
|
|
428
|
+
if (val <= 2) return { span: { class: 'text-warning', children: ['😐 Fair'] } };
|
|
429
|
+
if (val <= 3) return { span: { class: 'text-info', children: ['🙂 Good'] } };
|
|
430
|
+
if (val <= 4) return { span: { class: 'text-success', children: ['😊 Great'] } };
|
|
431
|
+
return { span: { class: 'text-primary', children: ['🤩 Excellent!'] } };
|
|
432
|
+
}
|
|
433
|
+
]
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
p: {
|
|
438
|
+
class: 'text-sm font-mono opacity-70',
|
|
439
|
+
children: [
|
|
440
|
+
() => `Rating value: ${rating.value} / 5`
|
|
441
|
+
]
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
]
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
$('#example').content(reactiveDemo);</code></pre>
|
|
449
|
+
</div>
|
|
450
|
+
</div>
|
|
451
|
+
</div>
|
|
452
|
+
|
|
453
|
+
<!-- Props Table -->
|
|
454
|
+
<h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Props</h2>
|
|
455
|
+
<div style="overflow-x: auto; margin-bottom: 2rem;">
|
|
456
|
+
<table class="table table-zebra">
|
|
457
|
+
<thead>
|
|
458
|
+
<tr>
|
|
459
|
+
<th>Prop</th>
|
|
460
|
+
<th>Type</th>
|
|
461
|
+
<th>Default</th>
|
|
462
|
+
<th>Description</th>
|
|
463
|
+
</tr>
|
|
464
|
+
</thead>
|
|
465
|
+
<tbody>
|
|
466
|
+
<tr>
|
|
467
|
+
<td><code>value</code></td>
|
|
468
|
+
<td>number | signal</td>
|
|
469
|
+
<td>-</td>
|
|
470
|
+
<td>Current rating value (reactive with signals)</td>
|
|
471
|
+
</tr>
|
|
472
|
+
<tr>
|
|
473
|
+
<td><code>defaultValue</code></td>
|
|
474
|
+
<td>number</td>
|
|
475
|
+
<td>0</td>
|
|
476
|
+
<td>Default value for uncontrolled mode</td>
|
|
477
|
+
</tr>
|
|
478
|
+
<tr>
|
|
479
|
+
<td><code>max</code></td>
|
|
480
|
+
<td>number</td>
|
|
481
|
+
<td>5</td>
|
|
482
|
+
<td>Maximum rating (number of stars)</td>
|
|
483
|
+
</tr>
|
|
484
|
+
<tr>
|
|
485
|
+
<td><code>label</code></td>
|
|
486
|
+
<td>string</td>
|
|
487
|
+
<td>-</td>
|
|
488
|
+
<td>Label text displayed above the rating</td>
|
|
489
|
+
</tr>
|
|
490
|
+
<tr>
|
|
491
|
+
<td><code>helper</code></td>
|
|
492
|
+
<td>string</td>
|
|
493
|
+
<td>-</td>
|
|
494
|
+
<td>Helper text displayed below the rating</td>
|
|
495
|
+
</tr>
|
|
496
|
+
<tr>
|
|
497
|
+
<td><code>half</code></td>
|
|
498
|
+
<td>boolean</td>
|
|
499
|
+
<td>false</td>
|
|
500
|
+
<td>Allow half-star ratings</td>
|
|
501
|
+
</tr>
|
|
502
|
+
<tr>
|
|
503
|
+
<td><code>hidden</code></td>
|
|
504
|
+
<td>boolean</td>
|
|
505
|
+
<td>false</td>
|
|
506
|
+
<td>Include hidden 0-star option for clearing</td>
|
|
507
|
+
</tr>
|
|
508
|
+
<tr>
|
|
509
|
+
<td><code>mask</code></td>
|
|
510
|
+
<td>string</td>
|
|
511
|
+
<td>'star-2'</td>
|
|
512
|
+
<td>'star' | 'star-2' | 'heart' | 'circle' | 'square' | 'diamond'</td>
|
|
513
|
+
</tr>
|
|
514
|
+
<tr>
|
|
515
|
+
<td><code>color</code></td>
|
|
516
|
+
<td>string</td>
|
|
517
|
+
<td>'orange-400'</td>
|
|
518
|
+
<td>Tailwind color class for the rating icons</td>
|
|
519
|
+
</tr>
|
|
520
|
+
<tr>
|
|
521
|
+
<td><code>size</code></td>
|
|
522
|
+
<td>string</td>
|
|
523
|
+
<td>-</td>
|
|
524
|
+
<td>'xs' | 'sm' | 'md' | 'lg'</td>
|
|
525
|
+
</tr>
|
|
526
|
+
<tr>
|
|
527
|
+
<td><code>disabled</code></td>
|
|
528
|
+
<td>boolean</td>
|
|
529
|
+
<td>false</td>
|
|
530
|
+
<td>Disable the rating</td>
|
|
531
|
+
</tr>
|
|
532
|
+
<tr>
|
|
533
|
+
<td><code>readOnly</code></td>
|
|
534
|
+
<td>boolean</td>
|
|
535
|
+
<td>false</td>
|
|
536
|
+
<td>Make rating read-only (display only)</td>
|
|
537
|
+
</tr>
|
|
538
|
+
<tr>
|
|
539
|
+
<td><code>onChange</code></td>
|
|
540
|
+
<td>function</td>
|
|
541
|
+
<td>-</td>
|
|
542
|
+
<td>Callback when rating changes: <code>(rating) => void</code></td>
|
|
543
|
+
</tr>
|
|
544
|
+
<tr>
|
|
545
|
+
<td><code>useShadow</code></td>
|
|
546
|
+
<td>boolean</td>
|
|
547
|
+
<td>*</td>
|
|
548
|
+
<td>Render in Shadow DOM</td>
|
|
549
|
+
</tr>
|
|
550
|
+
</tbody>
|
|
551
|
+
</table>
|
|
552
|
+
</div>
|
|
553
|
+
|
|
554
|
+
<!-- Sizes Example -->
|
|
555
|
+
<h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Sizes</h2>
|
|
556
|
+
<div class="example-stack" style="margin-bottom: 2rem;">
|
|
557
|
+
<div class="rating rating-xs">
|
|
558
|
+
<input type="radio" name="rating-xs" class="mask mask-star-2 bg-orange-400" />
|
|
559
|
+
<input type="radio" name="rating-xs" class="mask mask-star-2 bg-orange-400" />
|
|
560
|
+
<input type="radio" name="rating-xs" class="mask mask-star-2 bg-orange-400" checked />
|
|
561
|
+
<input type="radio" name="rating-xs" class="mask mask-star-2 bg-orange-400" />
|
|
562
|
+
<input type="radio" name="rating-xs" class="mask mask-star-2 bg-orange-400" />
|
|
563
|
+
</div>
|
|
564
|
+
<div class="rating rating-sm">
|
|
565
|
+
<input type="radio" name="rating-sm" class="mask mask-star-2 bg-orange-400" />
|
|
566
|
+
<input type="radio" name="rating-sm" class="mask mask-star-2 bg-orange-400" />
|
|
567
|
+
<input type="radio" name="rating-sm" class="mask mask-star-2 bg-orange-400" checked />
|
|
568
|
+
<input type="radio" name="rating-sm" class="mask mask-star-2 bg-orange-400" />
|
|
569
|
+
<input type="radio" name="rating-sm" class="mask mask-star-2 bg-orange-400" />
|
|
570
|
+
</div>
|
|
571
|
+
<div class="rating rating-md">
|
|
572
|
+
<input type="radio" name="rating-md" class="mask mask-star-2 bg-orange-400" />
|
|
573
|
+
<input type="radio" name="rating-md" class="mask mask-star-2 bg-orange-400" />
|
|
574
|
+
<input type="radio" name="rating-md" class="mask mask-star-2 bg-orange-400" checked />
|
|
575
|
+
<input type="radio" name="rating-md" class="mask mask-star-2 bg-orange-400" />
|
|
576
|
+
<input type="radio" name="rating-md" class="mask mask-star-2 bg-orange-400" />
|
|
577
|
+
</div>
|
|
578
|
+
<div class="rating rating-lg">
|
|
579
|
+
<input type="radio" name="rating-lg" class="mask mask-star-2 bg-orange-400" />
|
|
580
|
+
<input type="radio" name="rating-lg" class="mask mask-star-2 bg-orange-400" />
|
|
581
|
+
<input type="radio" name="rating-lg" class="mask mask-star-2 bg-orange-400" checked />
|
|
582
|
+
<input type="radio" name="rating-lg" class="mask mask-star-2 bg-orange-400" />
|
|
583
|
+
<input type="radio" name="rating-lg" class="mask mask-star-2 bg-orange-400" />
|
|
584
|
+
</div>
|
|
585
|
+
</div>
|
|
586
|
+
|
|
587
|
+
<!-- Half Stars Example -->
|
|
588
|
+
<h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Half Stars</h2>
|
|
589
|
+
<div class="rating rating-lg rating-half" style="margin-bottom: 2rem;">
|
|
590
|
+
<input type="radio" name="rating-half" class="rating-hidden" />
|
|
591
|
+
<input type="radio" name="rating-half" class="mask mask-star-2 mask-half-1 bg-green-500" />
|
|
592
|
+
<input type="radio" name="rating-half" class="mask mask-star-2 mask-half-2 bg-green-500" />
|
|
593
|
+
<input type="radio" name="rating-half" class="mask mask-star-2 mask-half-1 bg-green-500"
|
|
594
|
+
checked />
|
|
595
|
+
<input type="radio" name="rating-half" class="mask mask-star-2 mask-half-2 bg-green-500" />
|
|
596
|
+
<input type="radio" name="rating-half" class="mask mask-star-2 mask-half-1 bg-green-500" />
|
|
597
|
+
<input type="radio" name="rating-half" class="mask mask-star-2 mask-half-2 bg-green-500" />
|
|
598
|
+
<input type="radio" name="rating-half" class="mask mask-star-2 mask-half-1 bg-green-500" />
|
|
599
|
+
<input type="radio" name="rating-half" class="mask mask-star-2 mask-half-2 bg-green-500" />
|
|
600
|
+
<input type="radio" name="rating-half" class="mask mask-star-2 mask-half-1 bg-green-500" />
|
|
601
|
+
<input type="radio" name="rating-half" class="mask mask-star-2 mask-half-2 bg-green-500" />
|
|
602
|
+
</div>
|
|
603
|
+
|
|
604
|
+
<!-- Different Masks -->
|
|
605
|
+
<h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Different Shapes</h2>
|
|
606
|
+
<div class="example-stack" style="margin-bottom: 2rem;">
|
|
607
|
+
<div>
|
|
608
|
+
<p class="text-sm opacity-70 mb-1">Hearts</p>
|
|
609
|
+
<div class="rating">
|
|
610
|
+
<input type="radio" name="rating-heart" class="mask mask-heart bg-red-400" />
|
|
611
|
+
<input type="radio" name="rating-heart" class="mask mask-heart bg-red-400" />
|
|
612
|
+
<input type="radio" name="rating-heart" class="mask mask-heart bg-red-400" checked />
|
|
613
|
+
<input type="radio" name="rating-heart" class="mask mask-heart bg-red-400" />
|
|
614
|
+
<input type="radio" name="rating-heart" class="mask mask-heart bg-red-400" />
|
|
615
|
+
</div>
|
|
616
|
+
</div>
|
|
617
|
+
<div>
|
|
618
|
+
<p class="text-sm opacity-70 mb-1">Circles</p>
|
|
619
|
+
<div class="rating">
|
|
620
|
+
<input type="radio" name="rating-circle" class="mask mask-circle bg-blue-400" />
|
|
621
|
+
<input type="radio" name="rating-circle" class="mask mask-circle bg-blue-400" />
|
|
622
|
+
<input type="radio" name="rating-circle" class="mask mask-circle bg-blue-400" checked />
|
|
623
|
+
<input type="radio" name="rating-circle" class="mask mask-circle bg-blue-400" />
|
|
624
|
+
<input type="radio" name="rating-circle" class="mask mask-circle bg-blue-400" />
|
|
625
|
+
</div>
|
|
626
|
+
</div>
|
|
627
|
+
<div>
|
|
628
|
+
<p class="text-sm opacity-70 mb-1">Diamonds</p>
|
|
629
|
+
<div class="rating">
|
|
630
|
+
<input type="radio" name="rating-diamond" class="mask mask-diamond bg-purple-400" />
|
|
631
|
+
<input type="radio" name="rating-diamond" class="mask mask-diamond bg-purple-400" />
|
|
632
|
+
<input type="radio" name="rating-diamond" class="mask mask-diamond bg-purple-400"
|
|
633
|
+
checked />
|
|
634
|
+
<input type="radio" name="rating-diamond" class="mask mask-diamond bg-purple-400" />
|
|
635
|
+
<input type="radio" name="rating-diamond" class="mask mask-diamond bg-purple-400" />
|
|
636
|
+
</div>
|
|
637
|
+
</div>
|
|
638
|
+
</div>
|
|
639
|
+
</div>
|
|
640
|
+
</div>
|
|
641
|
+
</div>
|
|
642
|
+
</div>
|