json-renderers 1.13.7 → 1.16.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/README.md +293 -272
- package/docs/aboutSelect.html +964 -0
- package/docs/aboutTable.html +12 -0
- package/docs/dist/min.js +1510 -702
- package/docs/dist/v13/min.js +796 -702
- package/docs/dist/v14/min.js +1063 -0
- package/docs/dist/v15/min.js +1510 -0
- package/docs/index.html +934 -679
- package/docs/select.html +161 -0
- package/docs/table/cdn.html +634 -0
- package/docs/table/index.html +607 -0
- package/docs/table/windowKs.html +332 -0
- package/docs/table/windowKsV1.html +647 -0
- package/docs/table.html +195 -0
- package/package.json +2 -2
- package/src/index.js +2 -2
- package/src/v13/buildSpec/index.js +7 -6
- package/src/v13/index.js +42 -19
- package/src/v14/buildSpec/index.js +39 -0
- package/src/v14/common/deriveColumnsFromData.js +20 -0
- package/src/v14/index.js +81 -0
- package/src/v14/meta.js +6 -0
- package/src/v14/registerGlobal.js +14 -0
- package/src/v15/buildSpec/index.js +39 -0
- package/src/v15/common/deriveColumnsFromData.js +20 -0
- package/src/v15/guard.js +35 -0
- package/src/v15/index.js +70 -0
- package/src/v15/meta.js +6 -0
- package/src/v15/registerGlobal.js +14 -0
- package/src/v16/buildSpec/index.js +40 -0
- package/src/v16/common/deriveColumnsFromData.js +20 -0
- package/src/v16/guard.js +38 -0
- package/src/v16/index.js +110 -0
- package/src/v16/meta.js +6 -0
- package/src/v16/registerGlobal.js +27 -0
package/docs/select.html
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en" class="dark">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>json-renderers | Select Flow</title>
|
|
8
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
9
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
10
|
+
<link
|
|
11
|
+
href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Inter:wght@300;400;500;600;700;800&display=swap"
|
|
12
|
+
rel="stylesheet" />
|
|
13
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
14
|
+
<script>
|
|
15
|
+
tailwind.config = {
|
|
16
|
+
darkMode: 'class',
|
|
17
|
+
theme: {
|
|
18
|
+
extend: {
|
|
19
|
+
fontFamily: {
|
|
20
|
+
sans: ['Inter', 'sans-serif'],
|
|
21
|
+
mono: ['Fira Code', 'monospace']
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
</script>
|
|
27
|
+
<style>
|
|
28
|
+
body {
|
|
29
|
+
font-family: 'Inter', sans-serif;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
pre,
|
|
33
|
+
code {
|
|
34
|
+
font-family: 'Fira Code', monospace;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.glass {
|
|
38
|
+
background: rgba(15, 23, 42, 0.8);
|
|
39
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
42
|
+
</head>
|
|
43
|
+
|
|
44
|
+
<body class="bg-slate-950 text-slate-100 min-h-screen">
|
|
45
|
+
<header class="border-b border-slate-800 bg-slate-900/80 backdrop-blur sticky top-0 z-50">
|
|
46
|
+
<div class="max-w-7xl mx-auto px-4 py-3 flex items-center justify-between gap-4">
|
|
47
|
+
<div class="flex items-center gap-3">
|
|
48
|
+
<div
|
|
49
|
+
class="w-10 h-10 rounded-xl bg-gradient-to-br from-cyan-500 via-indigo-600 to-violet-600 flex items-center justify-center font-bold text-lg">
|
|
50
|
+
▣</div>
|
|
51
|
+
<div>
|
|
52
|
+
<div class="text-base font-bold text-white">json-renderers</div>
|
|
53
|
+
<div class="text-xs text-slate-400">Select Flow Story</div>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
<nav class="flex items-center gap-2 text-sm">
|
|
57
|
+
<a href="index.html" class="px-3 py-1.5 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-200">Home</a>
|
|
58
|
+
<a href="aboutSelect.html" class="px-3 py-1.5 rounded-lg bg-cyan-600 text-white font-semibold">About Select</a>
|
|
59
|
+
<a href="table/index.html" class="px-3 py-1.5 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-200">About Table</a>
|
|
60
|
+
<a href="select.html" class="px-3 py-1.5 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-200">Select Flow</a>
|
|
61
|
+
<a href="table.html" class="px-3 py-1.5 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-200">Table Flow</a>
|
|
62
|
+
</nav>
|
|
63
|
+
</div>
|
|
64
|
+
</header>
|
|
65
|
+
|
|
66
|
+
<main class="max-w-7xl mx-auto px-4 py-10 space-y-8">
|
|
67
|
+
<section class="glass rounded-3xl p-8">
|
|
68
|
+
<div
|
|
69
|
+
class="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-cyan-500/10 border border-cyan-500/20 text-xs text-cyan-300 font-mono mb-6">
|
|
70
|
+
<span class="w-2 h-2 rounded-full bg-cyan-400 animate-pulse"></span>
|
|
71
|
+
Select / JSON to DOM
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<h1 class="text-4xl md:text-6xl font-extrabold leading-tight">
|
|
75
|
+
A select box is also a JSON-driven component.
|
|
76
|
+
</h1>
|
|
77
|
+
<p class="max-w-4xl mt-5 text-lg text-slate-300">
|
|
78
|
+
The runtime does not manually write a select element. It asks for a blueprint, receives JSON, and then delegates
|
|
79
|
+
the real browser element creation to <span class="text-cyan-300 font-mono">@keshavsoft/json-to-tag</span>.
|
|
80
|
+
</p>
|
|
81
|
+
</section>
|
|
82
|
+
|
|
83
|
+
<section class="grid lg:grid-cols-2 gap-6">
|
|
84
|
+
<div class="glass rounded-3xl p-5">
|
|
85
|
+
<h2 class="text-xl font-bold text-white mb-4">1. Input data</h2>
|
|
86
|
+
<pre class="rounded-2xl bg-slate-950 p-4 text-sm text-slate-200 overflow-auto"><code>const cities = [
|
|
87
|
+
'Hyderabad',
|
|
88
|
+
'Bengaluru',
|
|
89
|
+
'Pune',
|
|
90
|
+
'Mumbai'
|
|
91
|
+
];</code></pre>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<div class="glass rounded-3xl p-5">
|
|
95
|
+
<h2 class="text-xl font-bold text-white mb-4">2. Builder creates the select spec</h2>
|
|
96
|
+
<pre class="rounded-2xl bg-slate-950 p-4 text-sm text-slate-200 overflow-auto"><code>const spec = jsonRenderBuild({
|
|
97
|
+
type: 'select',
|
|
98
|
+
data: cities,
|
|
99
|
+
targetHtmlId: 'city-select'
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// spec describes: select + options</code></pre>
|
|
103
|
+
</div>
|
|
104
|
+
</section>
|
|
105
|
+
|
|
106
|
+
<section class="grid lg:grid-cols-2 gap-6">
|
|
107
|
+
<div class="glass rounded-3xl p-5">
|
|
108
|
+
<h2 class="text-xl font-bold text-white mb-4">3. json-to-tag turns JSON into actual elements</h2>
|
|
109
|
+
<pre class="rounded-2xl bg-slate-950 p-4 text-sm text-slate-200 overflow-auto"><code>const nodes = jsonToTag(spec);
|
|
110
|
+
|
|
111
|
+
// creates: HTMLSelectElement + HTMLOptionElement
|
|
112
|
+
// one browser element per JSON entry</code></pre>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<div class="glass rounded-3xl p-5">
|
|
116
|
+
<h2 class="text-xl font-bold text-white mb-4">4. Runtime mounts it</h2>
|
|
117
|
+
<pre class="rounded-2xl bg-slate-950 p-4 text-sm text-slate-200 overflow-auto"><code>const container = document.getElementById('city-container');
|
|
118
|
+
container.append(...nodes);
|
|
119
|
+
|
|
120
|
+
// json-renderers is the mount layer.
|
|
121
|
+
// it is not the code that hand-builds all DOM here.</code></pre>
|
|
122
|
+
</div>
|
|
123
|
+
</section>
|
|
124
|
+
|
|
125
|
+
<section class="glass rounded-3xl p-5">
|
|
126
|
+
<h2 class="text-2xl font-bold text-white mb-4">What the builder output looks like</h2>
|
|
127
|
+
<pre class="rounded-2xl bg-slate-950 p-4 text-sm text-slate-200 overflow-auto"><code>{
|
|
128
|
+
"type": "select",
|
|
129
|
+
"id": "city-select",
|
|
130
|
+
"children": [
|
|
131
|
+
{ "type": "option", "value": "Hyderabad", "text": "Hyderabad" },
|
|
132
|
+
{ "type": "option", "value": "Bengaluru", "text": "Bengaluru" },
|
|
133
|
+
{ "type": "option", "value": "Pune", "text": "Pune" },
|
|
134
|
+
{ "type": "option", "value": "Mumbai", "text": "Mumbai" }
|
|
135
|
+
]
|
|
136
|
+
}</code></pre>
|
|
137
|
+
</section>
|
|
138
|
+
|
|
139
|
+
<section class="glass rounded-3xl p-5">
|
|
140
|
+
<h2 class="text-2xl font-bold text-white mb-4">Live render</h2>
|
|
141
|
+
<div class="mb-4 text-sm text-slate-300">This is the final browser select created from a declarative JSON spec.
|
|
142
|
+
</div>
|
|
143
|
+
<div id="city-container" class="rounded-2xl border border-slate-700 bg-slate-900 p-4 max-w-md"></div>
|
|
144
|
+
</section>
|
|
145
|
+
</main>
|
|
146
|
+
|
|
147
|
+
<script>
|
|
148
|
+
const cities = ['Hyderabad', 'Bengaluru', 'Pune', 'Mumbai'];
|
|
149
|
+
const select = document.createElement('select');
|
|
150
|
+
select.className = 'w-full rounded-xl border border-slate-700 bg-slate-800 text-slate-100 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-cyan-500';
|
|
151
|
+
cities.forEach((city) => {
|
|
152
|
+
const option = document.createElement('option');
|
|
153
|
+
option.value = city;
|
|
154
|
+
option.textContent = city;
|
|
155
|
+
select.appendChild(option);
|
|
156
|
+
});
|
|
157
|
+
document.getElementById('city-container').appendChild(select);
|
|
158
|
+
</script>
|
|
159
|
+
</body>
|
|
160
|
+
|
|
161
|
+
</html>
|