lightview 1.8.2 → 2.0.1
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/.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 +1330 -19
- 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 +610 -15
- 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 +485 -42
- 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 +132 -42
- 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 +659 -1200
- 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/docs/CNAME +0 -1
- package/docs/api.html +0 -674
- package/docs/blank.html +0 -10
- package/docs/comparedto.html +0 -89
- package/docs/components/chart-repl.html +0 -69
- package/docs/components/components.js +0 -113
- package/docs/components/contents.html +0 -17
- package/docs/components/gantt-repl.html +0 -61
- package/docs/components/gantt.html +0 -42
- package/docs/components/gauge-repl.html +0 -66
- package/docs/components/gauge.html +0 -20
- package/docs/components/orgchart-repl.html +0 -64
- package/docs/components/orgchart.html +0 -41
- package/docs/components/repl-as-src.html +0 -17
- package/docs/components/repl-repl.html +0 -95
- package/docs/components/repl.html +0 -527
- package/docs/components/timeline-repl.html +0 -72
- package/docs/components.html +0 -14
- package/docs/css/highlightjs.min.css +0 -9
- package/docs/css/tutorial.css +0 -35
- package/docs/examples/anchor.html +0 -11
- package/docs/examples/chart.html +0 -34
- package/docs/examples/counter.html +0 -26
- package/docs/examples/counter.test.mjs +0 -47
- package/docs/examples/counter2.html +0 -26
- package/docs/examples/directives.html +0 -79
- package/docs/examples/foreign.html +0 -50
- package/docs/examples/forgeinform.html +0 -98
- package/docs/examples/form.html +0 -61
- package/docs/examples/gauge.html +0 -18
- package/docs/examples/invalid-template-literals.html +0 -44
- package/docs/examples/medium/remote.html +0 -60
- package/docs/examples/message.html +0 -18
- package/docs/examples/nested.html +0 -11
- package/docs/examples/object-bound-form.html +0 -34
- package/docs/examples/remote-server.js +0 -51
- package/docs/examples/remote.html +0 -34
- package/docs/examples/remote.json +0 -1
- package/docs/examples/scratch.html +0 -69
- package/docs/examples/sensors/index.html +0 -44
- package/docs/examples/sensors/sensor-server.js +0 -30
- package/docs/examples/shared.html +0 -41
- package/docs/examples/template.html +0 -33
- package/docs/examples/timeline.html +0 -21
- package/docs/examples/todo.html +0 -40
- package/docs/examples/top.html +0 -10
- package/docs/examples/types.html +0 -94
- package/docs/examples/xor.html +0 -62
- package/docs/examples.html +0 -25
- package/docs/javascript/codejar.min.js +0 -8
- package/docs/javascript/highlightjs.min.js +0 -1173
- package/docs/javascript/isomorphic-git.js +0 -9
- package/docs/javascript/json5.min.js +0 -1
- package/docs/javascript/lightning-fs.js +0 -1
- package/docs/javascript/lightview.js +0 -1285
- package/docs/javascript/marked.min.js +0 -6
- package/docs/javascript/peerjs.min.js +0 -70
- package/docs/javascript/turndown.js +0 -973
- package/docs/javascript/types.js +0 -606
- package/docs/javascript/utils.js +0 -45
- package/docs/lightview.html +0 -63
- package/docs/old_index.html +0 -965
- package/docs/old_index.md +0 -1132
- package/docs/slidein.html +0 -51
- package/docs/tutorial/0-getting-started.html +0 -67
- package/docs/tutorial/1-intro-to-variables.html +0 -103
- package/docs/tutorial/10-template-components.html +0 -80
- package/docs/tutorial/11-linked-components.html +0 -76
- package/docs/tutorial/12-imported-components.html +0 -67
- package/docs/tutorial/13-input-binding.html +0 -94
- package/docs/tutorial/14-automatic-variable-creation.html +0 -74
- package/docs/tutorial/15-form-binding.html +0 -110
- package/docs/tutorial/16-if-directive.html +0 -60
- package/docs/tutorial/17-loop-directives.html +0 -83
- package/docs/tutorial/18-sanitizing-and-escaping-input.html +0 -79
- package/docs/tutorial/2-imported-and-exported-variables.html +0 -80
- package/docs/tutorial/3-data-types.html +0 -89
- package/docs/tutorial/4-extended-data-types.html +0 -83
- package/docs/tutorial/5-extended-functional-types.html +0 -96
- package/docs/tutorial/5.1-extended-functional-types.html +0 -79
- package/docs/tutorial/5.2-extended-functional-types.html +0 -70
- package/docs/tutorial/6-conventional-javascript.html +0 -75
- package/docs/tutorial/7-monitoring-with-observers.html +0 -107
- package/docs/tutorial/8-event-listeners.html +0 -65
- package/docs/tutorial/9-intro-to-components.html +0 -91
- package/docs/tutorial/contents.html +0 -32
- package/docs/tutorial/my-component.html +0 -29
- package/docs/tutorial/remote-value.json +0 -4
- package/docs/websiterepl.html +0 -46
- package/jest-puppeteer.config.js +0 -5
- package/jest.config.json +0 -12
- package/lightview.min.js +0 -1
- package/lightview_good.js +0 -1267
- package/lightview_optimized.js +0 -1274
- package/repl_hold.html +0 -320
- package/test/basic.html +0 -104
- package/test/basic.test.mjs +0 -315
- package/test/extended.html +0 -29
- package/test/extended.test.mjs +0 -448
- package/types.js +0 -607
- package/unsplash.key +0 -1
|
@@ -0,0 +1,644 @@
|
|
|
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: 'Input' }
|
|
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">Input</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
|
+
Text input allows users to enter and edit text.
|
|
61
|
+
Supports labels, validation, helper text, and reactive state binding.
|
|
62
|
+
</p>
|
|
63
|
+
|
|
64
|
+
<!-- Basic Examples -->
|
|
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;">Simple inputs with various
|
|
69
|
+
configurations
|
|
70
|
+
</p>
|
|
71
|
+
|
|
72
|
+
<!-- Tabs -->
|
|
73
|
+
<script>
|
|
74
|
+
window.switchSyntaxTab = (tabId) => {
|
|
75
|
+
const tabs = ['tagged', 'vdom', 'object', 'html'];
|
|
76
|
+
tabs.forEach(t => {
|
|
77
|
+
const tabEl = document.getElementById(`tab-btn-${t}`);
|
|
78
|
+
const contentEl = document.getElementById(`syntax-${t}`);
|
|
79
|
+
if (t === tabId) {
|
|
80
|
+
tabEl.classList.add('syntax-tab-active');
|
|
81
|
+
contentEl.style.display = 'block';
|
|
82
|
+
} else {
|
|
83
|
+
tabEl.classList.remove('syntax-tab-active');
|
|
84
|
+
contentEl.style.display = 'none';
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
</script>
|
|
89
|
+
<div role="tablist" class="syntax-tabs" style="margin-bottom: 1rem;">
|
|
90
|
+
<button id="tab-btn-tagged" role="tab" class="syntax-tab syntax-tab-active"
|
|
91
|
+
onclick="switchSyntaxTab('tagged')">Tagged</button>
|
|
92
|
+
<button id="tab-btn-vdom" role="tab" class="syntax-tab"
|
|
93
|
+
onclick="switchSyntaxTab('vdom')">vDOM</button>
|
|
94
|
+
<button id="tab-btn-object" role="tab" class="syntax-tab"
|
|
95
|
+
onclick="switchSyntaxTab('object')">Object
|
|
96
|
+
DOM</button>
|
|
97
|
+
<button id="tab-btn-html" role="tab" class="syntax-tab"
|
|
98
|
+
onclick="switchSyntaxTab('html')">HTML</button>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<!-- Tagged Syntax -->
|
|
102
|
+
<div id="syntax-tagged">
|
|
103
|
+
<pre><script>
|
|
104
|
+
examplify(document.currentScript.nextElementSibling, {
|
|
105
|
+
at: document.currentScript.parentElement,
|
|
106
|
+
scripts: ['/lightview.js', '/lightview-x.js'],
|
|
107
|
+
styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
|
|
108
|
+
type: 'module',
|
|
109
|
+
minHeight: 320,
|
|
110
|
+
autoRun: true
|
|
111
|
+
});
|
|
112
|
+
</script><code contenteditable="true">await import('/components/data-input/input.js');
|
|
113
|
+
const { tags, $ } = Lightview;
|
|
114
|
+
const { div, Input } = tags;
|
|
115
|
+
|
|
116
|
+
// 1. Basic input
|
|
117
|
+
const basic = Input({
|
|
118
|
+
placeholder: 'Basic input'
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// 2. Input with label and helper
|
|
122
|
+
const withLabel = Input({
|
|
123
|
+
label: 'Email Address',
|
|
124
|
+
type: 'email',
|
|
125
|
+
placeholder: 'you@example.com',
|
|
126
|
+
helper: 'We will never share your email.'
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// 3. Input with color
|
|
130
|
+
const withColor = Input({
|
|
131
|
+
label: 'Primary Color',
|
|
132
|
+
placeholder: 'Styled input',
|
|
133
|
+
color: 'primary'
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// 4. Required input
|
|
137
|
+
const requiredInput = Input({
|
|
138
|
+
label: 'Username',
|
|
139
|
+
placeholder: 'Enter username',
|
|
140
|
+
required: true
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Insert all examples
|
|
144
|
+
$('#example').content(
|
|
145
|
+
div({ style: 'display: flex; flex-direction: column; gap: 1rem;' }, basic, withLabel, withColor, requiredInput)
|
|
146
|
+
);</code></pre>
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<!-- vDOM Syntax -->
|
|
150
|
+
<div id="syntax-vdom" style="display: none;">
|
|
151
|
+
<pre><script>
|
|
152
|
+
examplify(document.currentScript.nextElementSibling, {
|
|
153
|
+
at: document.currentScript.parentElement,
|
|
154
|
+
scripts: ['/lightview.js', '/lightview-x.js'],
|
|
155
|
+
styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
|
|
156
|
+
type: 'module',
|
|
157
|
+
minHeight: 320
|
|
158
|
+
});
|
|
159
|
+
</script><code contenteditable="true">await import('/components/data-input/input.js');
|
|
160
|
+
const { $, tags } = Lightview;
|
|
161
|
+
const { Input, div } = tags;
|
|
162
|
+
|
|
163
|
+
const basic = {
|
|
164
|
+
tag: Input,
|
|
165
|
+
attributes: { placeholder: 'Basic input' }
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const withLabel = {
|
|
169
|
+
tag: Input,
|
|
170
|
+
attributes: {
|
|
171
|
+
label: 'Email Address',
|
|
172
|
+
type: 'email',
|
|
173
|
+
placeholder: 'you@example.com',
|
|
174
|
+
helper: 'We will never share your email.'
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const withColor = {
|
|
179
|
+
tag: Input,
|
|
180
|
+
attributes: {
|
|
181
|
+
label: 'Primary Color',
|
|
182
|
+
placeholder: 'Styled input',
|
|
183
|
+
color: 'primary'
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const requiredInput = {
|
|
188
|
+
tag: Input,
|
|
189
|
+
attributes: {
|
|
190
|
+
label: 'Username',
|
|
191
|
+
placeholder: 'Enter username',
|
|
192
|
+
required: true
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
$('#example').content({
|
|
197
|
+
tag: div,
|
|
198
|
+
attributes: { style: 'display: flex; flex-direction: column; gap: 1rem;' },
|
|
199
|
+
children: [basic, withLabel, withColor, requiredInput]
|
|
200
|
+
});</code></pre>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<!-- Object DOM Syntax -->
|
|
204
|
+
<div id="syntax-object" style="display: none;">
|
|
205
|
+
<pre><script>
|
|
206
|
+
examplify(document.currentScript.nextElementSibling, {
|
|
207
|
+
at: document.currentScript.parentElement,
|
|
208
|
+
scripts: ['/lightview.js', '/lightview-x.js'],
|
|
209
|
+
styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
|
|
210
|
+
type: 'module',
|
|
211
|
+
minHeight: 320
|
|
212
|
+
});
|
|
213
|
+
</script><code contenteditable="true">await import('/components/data-input/input.js');
|
|
214
|
+
const { $ } = Lightview;
|
|
215
|
+
|
|
216
|
+
const demo = {
|
|
217
|
+
div: {
|
|
218
|
+
style: 'display: flex; flex-direction: column; gap: 1rem;',
|
|
219
|
+
children: [
|
|
220
|
+
{ Input: { placeholder: 'Basic input' } },
|
|
221
|
+
{
|
|
222
|
+
Input: {
|
|
223
|
+
label: 'Email Address',
|
|
224
|
+
type: 'email',
|
|
225
|
+
placeholder: 'you@example.com',
|
|
226
|
+
helper: 'We will never share your email.'
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
Input: {
|
|
231
|
+
label: 'Primary Color',
|
|
232
|
+
placeholder: 'Styled input',
|
|
233
|
+
color: 'primary'
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
Input: {
|
|
238
|
+
label: 'Username',
|
|
239
|
+
placeholder: 'Enter username',
|
|
240
|
+
required: true
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
$('#example').content(demo);</code></pre>
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
<!-- HTML Syntax -->
|
|
251
|
+
<div id="syntax-html" style="display: none;">
|
|
252
|
+
<pre><script>
|
|
253
|
+
examplify(document.currentScript.nextElementSibling, {
|
|
254
|
+
at: document.currentScript.parentElement,
|
|
255
|
+
scripts: ['/lightview.js', '/lightview-x.js'],
|
|
256
|
+
styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
|
|
257
|
+
type: 'module',
|
|
258
|
+
language: 'html',
|
|
259
|
+
minHeight: 320
|
|
260
|
+
});
|
|
261
|
+
</script><code contenteditable="true" class="language-html"><!-- Import the component (registers lv-input) -->
|
|
262
|
+
<script type="module" src="/components/data-input/input.js"></script>
|
|
263
|
+
|
|
264
|
+
<div style="display: flex; flex-direction: column; gap: 1rem;">
|
|
265
|
+
<lv-input placeholder="Basic input"></lv-input>
|
|
266
|
+
<lv-input label="Email Address" type="email" placeholder="you@example.com" helper="We'll never share your email."></lv-input>
|
|
267
|
+
<lv-input label="Primary Color" placeholder="Styled input" color="primary"></lv-input>
|
|
268
|
+
<lv-input label="Username" placeholder="Enter username" required></lv-input>
|
|
269
|
+
</div></code></pre>
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
</div>
|
|
273
|
+
|
|
274
|
+
<!-- Reactive Example -->
|
|
275
|
+
<div
|
|
276
|
+
style="background-color: oklch(var(--b2)); border-radius: var(--rounded-box, 1rem); margin-bottom: 2rem;">
|
|
277
|
+
<div style="padding: 1.5rem;">
|
|
278
|
+
<h2 style="font-size: 1.5rem; font-weight: 600; line-height: 2rem;">Reactive Example</h2>
|
|
279
|
+
<p style="font-size: 0.875rem; opacity: 0.7; margin-bottom: 1rem;">Two-way binding with
|
|
280
|
+
signals
|
|
281
|
+
and live
|
|
282
|
+
validation</p>
|
|
283
|
+
|
|
284
|
+
<!-- Tabs -->
|
|
285
|
+
<script>
|
|
286
|
+
window.switchReactiveSyntaxTab = (tabId) => {
|
|
287
|
+
const tabs = ['tagged', 'vdom', 'object'];
|
|
288
|
+
tabs.forEach(t => {
|
|
289
|
+
const tabEl = document.getElementById(`reactive-tab-btn-${t}`);
|
|
290
|
+
const contentEl = document.getElementById(`reactive-syntax-${t}`);
|
|
291
|
+
if (t === tabId) {
|
|
292
|
+
tabEl.classList.add('syntax-tab-active');
|
|
293
|
+
contentEl.style.display = 'block';
|
|
294
|
+
} else {
|
|
295
|
+
tabEl.classList.remove('syntax-tab-active');
|
|
296
|
+
contentEl.style.display = 'none';
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
</script>
|
|
301
|
+
<div role="tablist" class="syntax-tabs" style="margin-bottom: 1rem;">
|
|
302
|
+
<button id="reactive-tab-btn-tagged" role="tab" class="syntax-tab syntax-tab-active"
|
|
303
|
+
onclick="switchReactiveSyntaxTab('tagged')">Tagged</button>
|
|
304
|
+
<button id="reactive-tab-btn-vdom" role="tab" class="syntax-tab"
|
|
305
|
+
onclick="switchReactiveSyntaxTab('vdom')">vDOM</button>
|
|
306
|
+
<button id="reactive-tab-btn-object" role="tab" class="syntax-tab"
|
|
307
|
+
onclick="switchReactiveSyntaxTab('object')">Object DOM</button>
|
|
308
|
+
</div>
|
|
309
|
+
|
|
310
|
+
<!-- Tagged Syntax -->
|
|
311
|
+
<div id="reactive-syntax-tagged">
|
|
312
|
+
<pre><script>
|
|
313
|
+
examplify(document.currentScript.nextElementSibling, {
|
|
314
|
+
at: document.currentScript.parentElement,
|
|
315
|
+
scripts: ['/lightview.js', '/lightview-x.js'],
|
|
316
|
+
styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
|
|
317
|
+
type: 'module',
|
|
318
|
+
minHeight: 220
|
|
319
|
+
});
|
|
320
|
+
</script><code contenteditable="true">await import('/components/data-input/input.js');
|
|
321
|
+
const { signal, tags, $ } = Lightview;
|
|
322
|
+
const { div, p, span, Input } = tags;
|
|
323
|
+
|
|
324
|
+
// Signal for two-way binding
|
|
325
|
+
const username = signal('');
|
|
326
|
+
|
|
327
|
+
// Validation function
|
|
328
|
+
const validateUsername = (val) => {
|
|
329
|
+
if (!val) return 'Username is required';
|
|
330
|
+
if (val.length < 3) return 'Username must be at least 3 characters';
|
|
331
|
+
if (!/^[a-zA-Z0-9_]+$/.test(val)) return 'Only letters, numbers, and underscores allowed';
|
|
332
|
+
return null;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// Reactive input with validation
|
|
336
|
+
const reactiveDemo = div({ style: 'display: flex; flex-direction: column; gap: 1rem;' },
|
|
337
|
+
Input({
|
|
338
|
+
label: 'Username',
|
|
339
|
+
placeholder: 'Enter your username...',
|
|
340
|
+
value: username,
|
|
341
|
+
validate: validateUsername,
|
|
342
|
+
required: true
|
|
343
|
+
}),
|
|
344
|
+
p({ style: 'font-size: 0.875rem;' },
|
|
345
|
+
span({ style: 'opacity: 0.7;' }, 'Current value: '),
|
|
346
|
+
span({ style: 'font-family: monospace; color: oklch(var(--p));' }, () => username.value || '(empty)')
|
|
347
|
+
),
|
|
348
|
+
p({ style: 'font-size: 0.875rem;' },
|
|
349
|
+
() => {
|
|
350
|
+
const error = validateUsername(username.value);
|
|
351
|
+
return error
|
|
352
|
+
? span({ style: 'color: oklch(var(--er));' }, '✗ ' + error)
|
|
353
|
+
: span({ style: 'color: oklch(var(--su));' }, '✓ Username is valid!');
|
|
354
|
+
}
|
|
355
|
+
)
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
$('#example').content(reactiveDemo);</code></pre>
|
|
359
|
+
</div>
|
|
360
|
+
|
|
361
|
+
<!-- vDOM Syntax -->
|
|
362
|
+
<div id="reactive-syntax-vdom" style="display: none;">
|
|
363
|
+
<pre><script>
|
|
364
|
+
examplify(document.currentScript.nextElementSibling, {
|
|
365
|
+
at: document.currentScript.parentElement,
|
|
366
|
+
scripts: ['/lightview.js', '/lightview-x.js'],
|
|
367
|
+
styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
|
|
368
|
+
type: 'module',
|
|
369
|
+
minHeight: 220
|
|
370
|
+
});
|
|
371
|
+
</script><code contenteditable="true">await import('/components/data-input/input.js');
|
|
372
|
+
const { signal, $, tags } = Lightview;
|
|
373
|
+
const { Input, div, p, span } = tags;
|
|
374
|
+
|
|
375
|
+
const username = signal('');
|
|
376
|
+
|
|
377
|
+
const validateUsername = (val) => {
|
|
378
|
+
if (!val) return 'Username is required';
|
|
379
|
+
if (val.length < 3) return 'Username must be at least 3 characters';
|
|
380
|
+
if (!/^[a-zA-Z0-9_]+$/.test(val)) return 'Only letters, numbers, and underscores allowed';
|
|
381
|
+
return null;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
const reactiveDemo = {
|
|
385
|
+
tag: div,
|
|
386
|
+
attributes: { style: 'display: flex; flex-direction: column; gap: 1rem;' },
|
|
387
|
+
children: [
|
|
388
|
+
{
|
|
389
|
+
tag: Input,
|
|
390
|
+
attributes: {
|
|
391
|
+
label: 'Username',
|
|
392
|
+
placeholder: 'Enter your username...',
|
|
393
|
+
value: username,
|
|
394
|
+
validate: validateUsername,
|
|
395
|
+
required: true
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
tag: p,
|
|
400
|
+
attributes: { style: 'font-size: 0.875rem;' },
|
|
401
|
+
children: [
|
|
402
|
+
{ tag: span, attributes: { style: 'opacity: 0.7;' }, children: ['Current value: '] },
|
|
403
|
+
{ tag: span, attributes: { style: 'font-family: monospace; color: oklch(var(--p));' }, children: [() => username.value || '(empty)'] }
|
|
404
|
+
]
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
tag: p,
|
|
408
|
+
attributes: { style: 'font-size: 0.875rem;' },
|
|
409
|
+
children: [
|
|
410
|
+
() => {
|
|
411
|
+
const error = validateUsername(username.value);
|
|
412
|
+
return error
|
|
413
|
+
? { tag: span, attributes: { style: 'color: oklch(var(--er));' }, children: ['✗ ' + error] }
|
|
414
|
+
: { tag: span, attributes: { style: 'color: oklch(var(--su));' }, children: ['✓ Username is valid!'] };
|
|
415
|
+
}
|
|
416
|
+
]
|
|
417
|
+
}
|
|
418
|
+
]
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
$('#example').content(reactiveDemo);</code></pre>
|
|
422
|
+
</div>
|
|
423
|
+
|
|
424
|
+
<!-- Object DOM Syntax -->
|
|
425
|
+
<div id="reactive-syntax-object" style="display: none;">
|
|
426
|
+
<pre><script>
|
|
427
|
+
examplify(document.currentScript.nextElementSibling, {
|
|
428
|
+
at: document.currentScript.parentElement,
|
|
429
|
+
scripts: ['/lightview.js', '/lightview-x.js'],
|
|
430
|
+
styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
|
|
431
|
+
type: 'module',
|
|
432
|
+
minHeight: 220
|
|
433
|
+
});
|
|
434
|
+
</script><code contenteditable="true">await import('/components/data-input/input.js');
|
|
435
|
+
const { signal, tags, $ } = Lightview;
|
|
436
|
+
const { Input, div, p, span } = tags;
|
|
437
|
+
|
|
438
|
+
const username = signal('');
|
|
439
|
+
|
|
440
|
+
const validateUsername = (val) => {
|
|
441
|
+
if (!val) return 'Username is required';
|
|
442
|
+
if (val.length < 3) return 'Username must be at least 3 characters';
|
|
443
|
+
if (!/^[a-zA-Z0-9_]+$/.test(val)) return 'Only letters, numbers, and underscores allowed';
|
|
444
|
+
return null;
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
const reactiveDemo = {
|
|
448
|
+
div: {
|
|
449
|
+
style: 'display: flex; flex-direction: column; gap: 1rem;',
|
|
450
|
+
children: [
|
|
451
|
+
{
|
|
452
|
+
Input: {
|
|
453
|
+
label: 'Username',
|
|
454
|
+
placeholder: 'Enter your username...',
|
|
455
|
+
value: username,
|
|
456
|
+
validate: validateUsername,
|
|
457
|
+
required: true
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
p: {
|
|
462
|
+
style: 'font-size: 0.875rem;',
|
|
463
|
+
children: [
|
|
464
|
+
{ span: { style: 'opacity: 0.7;', children: ['Current value: '] } },
|
|
465
|
+
{ span: { style: 'font-family: monospace; color: oklch(var(--p));', children: [() => username.value || '(empty)'] } }
|
|
466
|
+
]
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
p: {
|
|
471
|
+
style: 'font-size: 0.875rem;',
|
|
472
|
+
children: [
|
|
473
|
+
() => {
|
|
474
|
+
const error = validateUsername(username.value);
|
|
475
|
+
return error
|
|
476
|
+
? { span: { style: 'color: oklch(var(--er));', children: ['✗ ' + error] } }
|
|
477
|
+
: { span: { style: 'color: oklch(var(--su));', children: ['✓ Username is valid!'] } };
|
|
478
|
+
}
|
|
479
|
+
]
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
]
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
$('#example').content(reactiveDemo);</code></pre>
|
|
487
|
+
</div>
|
|
488
|
+
</div>
|
|
489
|
+
</div>
|
|
490
|
+
|
|
491
|
+
<!-- Props Table -->
|
|
492
|
+
<h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Props</h2>
|
|
493
|
+
<div style="overflow-x: auto; margin-bottom: 2rem;">
|
|
494
|
+
<table class="table table-zebra">
|
|
495
|
+
<thead>
|
|
496
|
+
<tr>
|
|
497
|
+
<th>Prop</th>
|
|
498
|
+
<th>Type</th>
|
|
499
|
+
<th>Default</th>
|
|
500
|
+
<th>Description</th>
|
|
501
|
+
</tr>
|
|
502
|
+
</thead>
|
|
503
|
+
<tbody>
|
|
504
|
+
<tr>
|
|
505
|
+
<td><code>type</code></td>
|
|
506
|
+
<td>string</td>
|
|
507
|
+
<td>'text'</td>
|
|
508
|
+
<td>Input type (text, password, email, number, etc.)</td>
|
|
509
|
+
</tr>
|
|
510
|
+
<tr>
|
|
511
|
+
<td><code>value</code></td>
|
|
512
|
+
<td>string | signal</td>
|
|
513
|
+
<td>-</td>
|
|
514
|
+
<td>Input value (reactive with signals)</td>
|
|
515
|
+
</tr>
|
|
516
|
+
<tr>
|
|
517
|
+
<td><code>defaultValue</code></td>
|
|
518
|
+
<td>string</td>
|
|
519
|
+
<td>''</td>
|
|
520
|
+
<td>Default value for uncontrolled mode</td>
|
|
521
|
+
</tr>
|
|
522
|
+
<tr>
|
|
523
|
+
<td><code>placeholder</code></td>
|
|
524
|
+
<td>string</td>
|
|
525
|
+
<td>-</td>
|
|
526
|
+
<td>Placeholder text</td>
|
|
527
|
+
</tr>
|
|
528
|
+
<tr>
|
|
529
|
+
<td><code>label</code></td>
|
|
530
|
+
<td>string</td>
|
|
531
|
+
<td>-</td>
|
|
532
|
+
<td>Label text displayed above input</td>
|
|
533
|
+
</tr>
|
|
534
|
+
<tr>
|
|
535
|
+
<td><code>helper</code></td>
|
|
536
|
+
<td>string</td>
|
|
537
|
+
<td>-</td>
|
|
538
|
+
<td>Helper text displayed below the input</td>
|
|
539
|
+
</tr>
|
|
540
|
+
<tr>
|
|
541
|
+
<td><code>error</code></td>
|
|
542
|
+
<td>string | function</td>
|
|
543
|
+
<td>-</td>
|
|
544
|
+
<td>Error message or reactive error function</td>
|
|
545
|
+
</tr>
|
|
546
|
+
<tr>
|
|
547
|
+
<td><code>validate</code></td>
|
|
548
|
+
<td>function</td>
|
|
549
|
+
<td>-</td>
|
|
550
|
+
<td>Validation function: <code>(value) => errorMessage | null</code></td>
|
|
551
|
+
</tr>
|
|
552
|
+
<tr>
|
|
553
|
+
<td><code>color</code></td>
|
|
554
|
+
<td>string</td>
|
|
555
|
+
<td>-</td>
|
|
556
|
+
<td>'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error'
|
|
557
|
+
</td>
|
|
558
|
+
</tr>
|
|
559
|
+
<tr>
|
|
560
|
+
<td><code>size</code></td>
|
|
561
|
+
<td>string</td>
|
|
562
|
+
<td>'md'</td>
|
|
563
|
+
<td>'xs' | 'sm' | 'md' | 'lg'</td>
|
|
564
|
+
</tr>
|
|
565
|
+
<tr>
|
|
566
|
+
<td><code>ghost</code></td>
|
|
567
|
+
<td>boolean</td>
|
|
568
|
+
<td>false</td>
|
|
569
|
+
<td>Ghost style (no background)</td>
|
|
570
|
+
</tr>
|
|
571
|
+
<tr>
|
|
572
|
+
<td><code>disabled</code></td>
|
|
573
|
+
<td>boolean</td>
|
|
574
|
+
<td>false</td>
|
|
575
|
+
<td>Disable the input</td>
|
|
576
|
+
</tr>
|
|
577
|
+
<tr>
|
|
578
|
+
<td><code>required</code></td>
|
|
579
|
+
<td>boolean</td>
|
|
580
|
+
<td>false</td>
|
|
581
|
+
<td>Mark as required field (shows asterisk)</td>
|
|
582
|
+
</tr>
|
|
583
|
+
<tr>
|
|
584
|
+
<td><code>onChange</code></td>
|
|
585
|
+
<td>function</td>
|
|
586
|
+
<td>-</td>
|
|
587
|
+
<td>Callback when value changes: <code>(value, event) => void</code></td>
|
|
588
|
+
</tr>
|
|
589
|
+
<tr>
|
|
590
|
+
<td><code>onBlur</code></td>
|
|
591
|
+
<td>function</td>
|
|
592
|
+
<td>-</td>
|
|
593
|
+
<td>Callback when input loses focus</td>
|
|
594
|
+
</tr>
|
|
595
|
+
<tr>
|
|
596
|
+
<td><code>useShadow</code></td>
|
|
597
|
+
<td>boolean</td>
|
|
598
|
+
<td>*</td>
|
|
599
|
+
<td>Render in Shadow DOM. *Follows global <code>initComponents()</code> setting</td>
|
|
600
|
+
</tr>
|
|
601
|
+
</tbody>
|
|
602
|
+
</table>
|
|
603
|
+
</div>
|
|
604
|
+
|
|
605
|
+
<!-- Sizes Example -->
|
|
606
|
+
<h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Sizes</h2>
|
|
607
|
+
<div style="display: flex; align-items: flex-end; gap: 0.5rem; margin-bottom: 2rem;">
|
|
608
|
+
<input type="text" placeholder="Extra small" class="input input-xs" />
|
|
609
|
+
<input type="text" placeholder="Small" class="input input-sm" />
|
|
610
|
+
<input type="text" placeholder="Medium" class="input" />
|
|
611
|
+
<input type="text" placeholder="Large" class="input input-lg" />
|
|
612
|
+
</div>
|
|
613
|
+
|
|
614
|
+
<!-- Colors Example -->
|
|
615
|
+
<h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Colors</h2>
|
|
616
|
+
<div
|
|
617
|
+
style="display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 1rem; margin-bottom: 2rem;">
|
|
618
|
+
<input type="text" placeholder="Primary" class="input input-primary" />
|
|
619
|
+
<input type="text" placeholder="Secondary" class="input input-secondary" />
|
|
620
|
+
<input type="text" placeholder="Accent" class="input input-accent" />
|
|
621
|
+
<input type="text" placeholder="Info" class="input input-info" />
|
|
622
|
+
<input type="text" placeholder="Success" class="input input-success" />
|
|
623
|
+
<input type="text" placeholder="Warning" class="input input-warning" />
|
|
624
|
+
<input type="text" placeholder="Error" class="input input-error" />
|
|
625
|
+
<input type="text" placeholder="Ghost" class="input input-ghost" />
|
|
626
|
+
</div>
|
|
627
|
+
|
|
628
|
+
<!-- With Fieldset -->
|
|
629
|
+
<h2 class="text-xl font-bold" style="margin-bottom: 1rem;">With Label (Fieldset Pattern)</h2>
|
|
630
|
+
<div style="max-width: 28rem; margin-bottom: 2rem;">
|
|
631
|
+
<fieldset
|
|
632
|
+
style="display: flex; flex-direction: column; gap: 0.5rem; border: none; padding: 0.5rem 0;">
|
|
633
|
+
<legend
|
|
634
|
+
style="font-size: 0.875rem; font-weight: 700; color: oklch(var(--bc)/0.8); padding: 0 0.5rem;">
|
|
635
|
+
Email Address</legend>
|
|
636
|
+
<input type="email" class="input" style="width: 100%;" placeholder="you@example.com" />
|
|
637
|
+
<p style="font-size: 0.875rem; color: oklch(var(--bc)/0.6); padding: 0 0.5rem;">We'll never
|
|
638
|
+
share your email.</p>
|
|
639
|
+
</fieldset>
|
|
640
|
+
</div>
|
|
641
|
+
</div>
|
|
642
|
+
</div>
|
|
643
|
+
</div>
|
|
644
|
+
</div>
|