json-to-spec 19.1.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/README.md +118 -0
- package/docs/demo.html +426 -0
- package/docs/dist/min.js +164 -0
- package/docs/dist/v1/min.js +124 -0
- package/docs/dist/v17/min.js +355 -0
- package/docs/dist/v18/min.js +160 -0
- package/docs/dist/v19/min.js +164 -0
- package/docs/dist/v2/min.js +129 -0
- package/docs/dist/v3/min.js +201 -0
- package/docs/index.html +248 -0
- package/docs/pages/architecture.html +115 -0
- package/docs/pages/how-it-works.html +125 -0
- package/docs/pages/what-not.html +100 -0
- package/docs/pages/what.html +105 -0
- package/docs/pages/why.html +88 -0
- package/docs/samples/form.html +265 -0
- package/docs/samples/index.html +112 -0
- package/docs/samples/table.html +306 -0
- package/index.js +2 -0
- package/package.json +50 -0
- package/samples/dataList/index.html +31 -0
- package/samples/dataList/index.js +62 -0
- package/samples/dataList/input/data.json +5043 -0
- package/samples/dataList/input/structure.json +38 -0
- package/samples/dataList copy/index.html +30 -0
- package/samples/dataList copy/index.js +61 -0
- package/samples/dataList copy/input/data.json +35307 -0
- package/samples/dataList copy/input/structure.json +18 -0
- package/samples/form/index.html +29 -0
- package/samples/form/index.js +64 -0
- package/samples/form/input/data.json +9 -0
- package/samples/form/input/structure.json +192 -0
- package/samples/form-/data.json +42 -0
- package/samples/form-/structure.json +110 -0
- package/samples/select/index.html +31 -0
- package/samples/select/index.js +61 -0
- package/samples/select/input/data.json +35287 -0
- package/samples/select/input/select.json +18 -0
- package/samples/select/input/structure.json +47 -0
- package/samples/table/index.html +29 -0
- package/samples/table/index.js +61 -0
- package/samples/table/input/data.json +35287 -0
- package/samples/table/input/structure copy.json +47 -0
- package/samples/table/input/structure.json +86 -0
- package/samples/table/input/table.json +135 -0
- package/samples/table-/data.json +68 -0
- package/samples/table-/structure.json +235 -0
- package/src/index.js +2 -0
- package/src/v10/index.js +96 -0
- package/src/v10/instructionEngine/compile/compileTree.js +191 -0
- package/src/v10/instructionEngine/compileTree.js +1 -0
- package/src/v10/instructionEngine/expandIteration.js +1 -0
- package/src/v10/instructionEngine/index.js +29 -0
- package/src/v10/instructionEngine/interpolate.js +2 -0
- package/src/v10/instructionEngine/iteration/expandIteration.js +95 -0
- package/src/v10/instructionEngine/operation/operation.js +237 -0
- package/src/v10/instructionEngine/other/other.js +150 -0
- package/src/v10/instructionEngine/pipeline/pipeline.js +47 -0
- package/src/v10/instructionEngine/replace/replace.js +173 -0
- package/src/v10/instructionEngine/resolve/resolvePath.js +18 -0
- package/src/v10/instructionEngine/resolve/resolveTokenValue.js +22 -0
- package/src/v10/instructionEngine/resolvePath.js +1 -0
- package/src/v10/instructionEngine/resolveTokenValue.js +1 -0
- package/src/v10/instructionEngine/story/storyInjector.js +50 -0
- package/src/v10/instructionEngine/storyInjector.js +1 -0
- package/src/v10/instructionEngine/value/interpolate.js +38 -0
- package/src/v11/index.js +116 -0
- package/src/v11/iterate.js +270 -0
- package/src/v11/replace.js +169 -0
- package/src/v11/resolvePath.js +29 -0
- package/src/v12/index.js +122 -0
- package/src/v12/iterate/bindFormValues.js +74 -0
- package/src/v12/iterate/expandIteration.js +181 -0
- package/src/v12/iterate/index.js +10 -0
- package/src/v12/iterate/iterate.js +56 -0
- package/src/v12/iterate/iterateNode.js +86 -0
- package/src/v12/iterate/resolveCollection.js +37 -0
- package/src/v12/iterate.js +270 -0
- package/src/v12/replace.js +169 -0
- package/src/v12/resolvePath.js +29 -0
- package/src/v13/index.js +110 -0
- package/src/v13/iterate/bindFormValues.js +74 -0
- package/src/v13/iterate/expandIteration.js +188 -0
- package/src/v13/iterate/index.js +9 -0
- package/src/v13/iterate/iterate.js +32 -0
- package/src/v13/iterate/iterateNode.js +86 -0
- package/src/v13/iterate/resolveCollection.js +37 -0
- package/src/v13/iterate/walk.js +90 -0
- package/src/v13/iterate.js +270 -0
- package/src/v13/replace.js +169 -0
- package/src/v13/resolvePath.js +29 -0
- package/src/v14/index.js +112 -0
- package/src/v14/iterate/bindFormValues.js +74 -0
- package/src/v14/iterate/expandIteration.js +188 -0
- package/src/v14/iterate/index.js +9 -0
- package/src/v14/iterate/iterate.js +32 -0
- package/src/v14/iterate/resolveCollection.js +37 -0
- package/src/v14/iterate/walk/walk copy 2.js +114 -0
- package/src/v14/iterate/walk/walk copy.js +90 -0
- package/src/v14/iterate/walk/walk.js +98 -0
- package/src/v14/iterate.js +270 -0
- package/src/v14/replace/index.js +16 -0
- package/src/v14/replace/walk.js +90 -0
- package/src/v14/replace.js +153 -0
- package/src/v14/resolvePath.js +29 -0
- package/src/v15/index.js +123 -0
- package/src/v15/iterate/bindFormValues.js +74 -0
- package/src/v15/iterate/expandIteration.js +188 -0
- package/src/v15/iterate/index.js +9 -0
- package/src/v15/iterate/iterate.js +32 -0
- package/src/v15/iterate/resolveCollection.js +37 -0
- package/src/v15/iterate/walk/walk copy 2.js +114 -0
- package/src/v15/iterate/walk/walk copy.js +90 -0
- package/src/v15/iterate/walk/walk.js +195 -0
- package/src/v15/iterate.js +270 -0
- package/src/v15/replace/index.js +16 -0
- package/src/v15/replace/walk.js +90 -0
- package/src/v15/replace.js +155 -0
- package/src/v15/resolvePath.js +29 -0
- package/src/v16/index.js +129 -0
- package/src/v16/iterate/bindFormValues.js +74 -0
- package/src/v16/iterate/expandIteration.js +188 -0
- package/src/v16/iterate/index.js +9 -0
- package/src/v16/iterate/iterate.js +32 -0
- package/src/v16/iterate/resolveCollection.js +37 -0
- package/src/v16/iterate/walk/walk copy 2.js +114 -0
- package/src/v16/iterate/walk/walk copy.js +90 -0
- package/src/v16/iterate/walk/walk.js +196 -0
- package/src/v16/iterate.js +270 -0
- package/src/v16/replace/index.js +16 -0
- package/src/v16/replace/walk.js +90 -0
- package/src/v16/replace.js +155 -0
- package/src/v16/resolvePath.js +29 -0
- package/src/v17/index.js +119 -0
- package/src/v17/iterate/bindFormValues.js +74 -0
- package/src/v17/iterate/expandIteration.js +188 -0
- package/src/v17/iterate/index.js +9 -0
- package/src/v17/iterate/iterate.js +32 -0
- package/src/v17/iterate/resolveCollection.js +37 -0
- package/src/v17/iterate/walk/iterateDo.js +42 -0
- package/src/v17/iterate/walk/replaceWithData.js +60 -0
- package/src/v17/iterate/walk/walk.js +94 -0
- package/src/v17/iterate.js +270 -0
- package/src/v17/replace/index.js +16 -0
- package/src/v17/replace/walk.js +90 -0
- package/src/v17/replace.js +160 -0
- package/src/v17/resolvePath.js +29 -0
- package/src/v18/index.js +66 -0
- package/src/v18/meta.js +7 -0
- package/src/v18/registerGlobal.js +17 -0
- package/src/v18/replace.js +18 -0
- package/src/v18/resolvePath.js +29 -0
- package/src/v18/walk/iterate/v1/index.js +42 -0
- package/src/v18/walk/iterate/v2/index.js +32 -0
- package/src/v18/walk/iterate/v3/index.js +46 -0
- package/src/v18/walk/iterate/v4/createChildren.js +24 -0
- package/src/v18/walk/iterate/v4/index.js +25 -0
- package/src/v18/walk/replaceWithData/v1/index.js +42 -0
- package/src/v18/walk/replaceWithData/v1/replaceCommon.js +21 -0
- package/src/v18/walk/replaceWithData/v2/index.js +105 -0
- package/src/v18/walk/replaceWithData/v2/replaceCommon.js +21 -0
- package/src/v18/walk/replaceWithData/v3/index.js +15 -0
- package/src/v18/walk/replaceWithData/v3/replaceAttributes.js +29 -0
- package/src/v18/walk/replaceWithData/v3/replaceCommon.js +23 -0
- package/src/v18/walk/replaceWithData/v3/replaceNodeValue.js +27 -0
- package/src/v18/walk/walk.js +94 -0
- package/src/v19/index.js +55 -0
- package/src/v19/meta.js +7 -0
- package/src/v19/registerGlobal.js +17 -0
- package/src/v19/replace.js +18 -0
- package/src/v19/resolvePath.js +29 -0
- package/src/v19/walk/iterate/v1/index.js +42 -0
- package/src/v19/walk/iterate/v2/index.js +32 -0
- package/src/v19/walk/iterate/v3/index.js +46 -0
- package/src/v19/walk/iterate/v4/createChildren.js +27 -0
- package/src/v19/walk/iterate/v4/index.js +25 -0
- package/src/v19/walk/replaceWithData/v1/index.js +42 -0
- package/src/v19/walk/replaceWithData/v1/replaceCommon.js +21 -0
- package/src/v19/walk/replaceWithData/v2/index.js +105 -0
- package/src/v19/walk/replaceWithData/v2/replaceCommon.js +21 -0
- package/src/v19/walk/replaceWithData/v3/index.js +15 -0
- package/src/v19/walk/replaceWithData/v3/replaceAttributes.js +29 -0
- package/src/v19/walk/replaceWithData/v3/replaceCommon.js +23 -0
- package/src/v19/walk/replaceWithData/v3/replaceNodeValue.js +27 -0
- package/src/v19/walk/walk.js +97 -0
- package/src/v8/index.js +69 -0
- package/src/v8/instructionEngine/compile/compileTree.js +191 -0
- package/src/v8/instructionEngine/compileTree.js +1 -0
- package/src/v8/instructionEngine/expandIteration.js +1 -0
- package/src/v8/instructionEngine/index.js +16 -0
- package/src/v8/instructionEngine/interpolate.js +2 -0
- package/src/v8/instructionEngine/iteration/expandIteration.js +95 -0
- package/src/v8/instructionEngine/resolve/resolvePath.js +18 -0
- package/src/v8/instructionEngine/resolve/resolveTokenValue.js +22 -0
- package/src/v8/instructionEngine/resolvePath.js +1 -0
- package/src/v8/instructionEngine/resolveTokenValue.js +1 -0
- package/src/v8/instructionEngine/story/storyInjector.js +50 -0
- package/src/v8/instructionEngine/storyInjector.js +1 -0
- package/src/v8/instructionEngine/value/interpolate.js +38 -0
- package/src/v9/index.js +96 -0
- package/src/v9/instructionEngine/compile/compileTree.js +191 -0
- package/src/v9/instructionEngine/compileTree.js +1 -0
- package/src/v9/instructionEngine/expandIteration.js +1 -0
- package/src/v9/instructionEngine/index.js +29 -0
- package/src/v9/instructionEngine/interpolate.js +2 -0
- package/src/v9/instructionEngine/iteration/expandIteration.js +95 -0
- package/src/v9/instructionEngine/operation/operation.js +237 -0
- package/src/v9/instructionEngine/other/other.js +150 -0
- package/src/v9/instructionEngine/pipeline/pipeline.js +47 -0
- package/src/v9/instructionEngine/replace/replace.js +173 -0
- package/src/v9/instructionEngine/resolve/resolvePath.js +18 -0
- package/src/v9/instructionEngine/resolve/resolveTokenValue.js +22 -0
- package/src/v9/instructionEngine/resolvePath.js +1 -0
- package/src/v9/instructionEngine/resolveTokenValue.js +1 -0
- package/src/v9/instructionEngine/story/storyInjector.js +50 -0
- package/src/v9/instructionEngine/storyInjector.js +1 -0
- package/src/v9/instructionEngine/value/interpolate.js +38 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tagName": "datalist",
|
|
3
|
+
"attributes": {
|
|
4
|
+
"id": "dl1"
|
|
5
|
+
},
|
|
6
|
+
"jsonToSpec": {
|
|
7
|
+
"operation": "iterate",
|
|
8
|
+
"source": "data",
|
|
9
|
+
"template": {
|
|
10
|
+
"tagName": "option",
|
|
11
|
+
"attributes": {
|
|
12
|
+
"value": "${LedgerName}"
|
|
13
|
+
},
|
|
14
|
+
"textContent": "${LedgerName}"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"children": []
|
|
18
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
+
<title>v30 - Input Only</title>
|
|
8
|
+
<script>
|
|
9
|
+
if (!location.pathname.endsWith('/') && !location.pathname.endsWith('.html')) {
|
|
10
|
+
location.replace(location.pathname + '/' + location.search + location.hash);
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet"
|
|
15
|
+
integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
|
|
16
|
+
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<main class="container">
|
|
21
|
+
<h1 id="head1" style="margin-top:0;font-size:1.25rem">Simple Input (v30)</h1>
|
|
22
|
+
<div id="dom-render-container">
|
|
23
|
+
<div class="text-center py-5 text-muted">Loading input demo...</div>
|
|
24
|
+
</div>
|
|
25
|
+
</main>
|
|
26
|
+
<script type="module" src="./index.js"></script>
|
|
27
|
+
</body>
|
|
28
|
+
|
|
29
|
+
</html>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { default as compile } from "../../src/index.js";
|
|
2
|
+
// import * as domEngine from "./json-to-dom.v27.min.js";
|
|
3
|
+
|
|
4
|
+
import { specToDom } from "https://keshavsoft.github.io/json-to-dom/dist/v31/min.js";
|
|
5
|
+
|
|
6
|
+
const folder = "input";
|
|
7
|
+
let actionBinding = null;
|
|
8
|
+
let state = { structure: null, data: null, compiled: null };
|
|
9
|
+
|
|
10
|
+
const loadInput = async () => {
|
|
11
|
+
const [structure, data] = await Promise.all([
|
|
12
|
+
fetch(`./${folder}/structure.json`).then((r) => r.json()),
|
|
13
|
+
fetch(`./${folder}/data.json`).then((r) => r.json())
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
structure,
|
|
18
|
+
data
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const render = (structure, data) => {
|
|
23
|
+
const t0 = performance.now();
|
|
24
|
+
|
|
25
|
+
console.log("lllllllllll : ", state);
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const specAsJsonToDom = compile(structure, data);
|
|
29
|
+
const compileTime = (performance.now() - t0).toFixed(2);
|
|
30
|
+
const compileBadge = document.getElementById("compile-time-badge");
|
|
31
|
+
if (compileBadge) compileBadge.textContent = `Compiled in ${compileTime}ms`;
|
|
32
|
+
|
|
33
|
+
const container = document.getElementById("dom-render-container");
|
|
34
|
+
if (container) container.innerHTML = "";
|
|
35
|
+
|
|
36
|
+
// console.log("222222222 : ", specAsJsonToDom);
|
|
37
|
+
|
|
38
|
+
specToDom({ spec: specAsJsonToDom, targetHtmlId: "dom-render-container" });
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const VARIANT = "inline"; // "stacked" | "inline" | "list"
|
|
42
|
+
|
|
43
|
+
const start = async () => {
|
|
44
|
+
try {
|
|
45
|
+
const {
|
|
46
|
+
structure,
|
|
47
|
+
data
|
|
48
|
+
} = await loadInput();
|
|
49
|
+
console.log("aaaaaaa : ", structure, data);
|
|
50
|
+
|
|
51
|
+
render(structure[VARIANT], data);
|
|
52
|
+
} catch (err) {
|
|
53
|
+
const container = document.getElementById("dom-render-container");
|
|
54
|
+
if (container) container.innerHTML = `<div style="color:#b91c1c">Error: ${err.message}</div>`;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
start();
|
|
59
|
+
|
|
60
|
+
const head1 = document.getElementById("head1");
|
|
61
|
+
const version = window?.ks?.["json-to-spec"]?.meta?.version;
|
|
62
|
+
if (version && head1) {
|
|
63
|
+
head1.innerHTML += ` - ${version}`;
|
|
64
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"fields": [
|
|
3
|
+
{ "label": "Ledger Name", "value": "360 one Quant Fund on 20.08.24" },
|
|
4
|
+
{ "label": "Ledger Parent Name", "value": "Investments" },
|
|
5
|
+
{ "label": "Ledger Type", "value": "Ledger" },
|
|
6
|
+
{ "label": "GST Registration Type", "value": "" },
|
|
7
|
+
{ "label": "Party GSTIN", "value": "" }
|
|
8
|
+
]
|
|
9
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
{
|
|
2
|
+
"stacked": {
|
|
3
|
+
"tagName": "div",
|
|
4
|
+
"attributes": { "class": "card shadow-sm" },
|
|
5
|
+
"children": [
|
|
6
|
+
{
|
|
7
|
+
"tagName": "div",
|
|
8
|
+
"attributes": { "class": "card-header fw-semibold" },
|
|
9
|
+
"children": [{ "tagName": "span", "textContent": "Ledger Details" }]
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"tagName": "div",
|
|
13
|
+
"attributes": { "class": "card-body" },
|
|
14
|
+
"jsonToSpec": {
|
|
15
|
+
"operation": "iterate",
|
|
16
|
+
"source": "fields",
|
|
17
|
+
"template": {
|
|
18
|
+
"tagName": "div",
|
|
19
|
+
"attributes": { "class": "mb-3" },
|
|
20
|
+
"children": [
|
|
21
|
+
{
|
|
22
|
+
"tagName": "label",
|
|
23
|
+
"attributes": { "class": "form-label" },
|
|
24
|
+
"textContent": "${label}"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"tagName": "input",
|
|
28
|
+
"attributes": {
|
|
29
|
+
"type": "text",
|
|
30
|
+
"class": "form-control",
|
|
31
|
+
"value": "${value}",
|
|
32
|
+
"readonly": "true"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"children": []
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"inline": {
|
|
43
|
+
"tagName": "div",
|
|
44
|
+
"attributes": { "class": "card shadow-sm" },
|
|
45
|
+
"children": [
|
|
46
|
+
{
|
|
47
|
+
"tagName": "div",
|
|
48
|
+
"attributes": { "class": "card-header fw-semibold" },
|
|
49
|
+
"children": [{ "tagName": "span", "textContent": "Ledger Details" }]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"tagName": "div",
|
|
53
|
+
"attributes": { "class": "card-body" },
|
|
54
|
+
"jsonToSpec": {
|
|
55
|
+
"operation": "iterate",
|
|
56
|
+
"source": "fields",
|
|
57
|
+
"template": {
|
|
58
|
+
"tagName": "div",
|
|
59
|
+
"attributes": { "class": "row mb-2 align-items-center" },
|
|
60
|
+
"children": [
|
|
61
|
+
{
|
|
62
|
+
"tagName": "label",
|
|
63
|
+
"attributes": { "class": "col-4 col-form-label fw-medium text-end" },
|
|
64
|
+
"textContent": "${label}"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"tagName": "div",
|
|
68
|
+
"attributes": { "class": "col-8" },
|
|
69
|
+
"children": [
|
|
70
|
+
{
|
|
71
|
+
"tagName": "input",
|
|
72
|
+
"attributes": {
|
|
73
|
+
"type": "text",
|
|
74
|
+
"class": "form-control form-control-sm",
|
|
75
|
+
"value": "${value}",
|
|
76
|
+
"readonly": "true"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"children": []
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"inlineWithButtons": {
|
|
89
|
+
"tagName": "div",
|
|
90
|
+
"attributes": { "class": "card shadow-sm" },
|
|
91
|
+
"children": [
|
|
92
|
+
{
|
|
93
|
+
"tagName": "div",
|
|
94
|
+
"attributes": { "class": "card-header fw-semibold" },
|
|
95
|
+
"children": [{ "tagName": "span", "textContent": "Ledger Details" }]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"tagName": "div",
|
|
99
|
+
"attributes": { "class": "card-body" },
|
|
100
|
+
"jsonToSpec": {
|
|
101
|
+
"operation": "iterate",
|
|
102
|
+
"source": "fields",
|
|
103
|
+
"template": {
|
|
104
|
+
"tagName": "div",
|
|
105
|
+
"attributes": { "class": "row mb-2 align-items-center" },
|
|
106
|
+
"children": [
|
|
107
|
+
{
|
|
108
|
+
"tagName": "label",
|
|
109
|
+
"attributes": { "class": "col-4 col-form-label fw-medium text-end" },
|
|
110
|
+
"textContent": "${label}"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"tagName": "div",
|
|
114
|
+
"attributes": { "class": "col-6" },
|
|
115
|
+
"children": [
|
|
116
|
+
{
|
|
117
|
+
"tagName": "input",
|
|
118
|
+
"attributes": {
|
|
119
|
+
"type": "text",
|
|
120
|
+
"class": "form-control form-control-sm",
|
|
121
|
+
"value": "${value}",
|
|
122
|
+
"readonly": "true"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"tagName": "div",
|
|
129
|
+
"attributes": { "class": "col-2 d-flex gap-1" },
|
|
130
|
+
"children": [
|
|
131
|
+
{
|
|
132
|
+
"tagName": "button",
|
|
133
|
+
"attributes": {
|
|
134
|
+
"type": "button",
|
|
135
|
+
"class": "btn btn-sm btn-outline-primary"
|
|
136
|
+
},
|
|
137
|
+
"textContent": "Edit"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"tagName": "button",
|
|
141
|
+
"attributes": {
|
|
142
|
+
"type": "button",
|
|
143
|
+
"class": "btn btn-sm btn-outline-secondary"
|
|
144
|
+
},
|
|
145
|
+
"textContent": "Copy"
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"children": []
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
"list": {
|
|
157
|
+
"tagName": "div",
|
|
158
|
+
"attributes": { "class": "card shadow-sm" },
|
|
159
|
+
"children": [
|
|
160
|
+
{
|
|
161
|
+
"tagName": "div",
|
|
162
|
+
"attributes": { "class": "card-header fw-semibold" },
|
|
163
|
+
"children": [{ "tagName": "span", "textContent": "Ledger Details" }]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"tagName": "ul",
|
|
167
|
+
"attributes": { "class": "list-group list-group-flush" },
|
|
168
|
+
"jsonToSpec": {
|
|
169
|
+
"operation": "iterate",
|
|
170
|
+
"source": "fields",
|
|
171
|
+
"template": {
|
|
172
|
+
"tagName": "li",
|
|
173
|
+
"attributes": { "class": "list-group-item d-flex justify-content-between align-items-center" },
|
|
174
|
+
"children": [
|
|
175
|
+
{
|
|
176
|
+
"tagName": "span",
|
|
177
|
+
"attributes": { "class": "text-muted" },
|
|
178
|
+
"textContent": "${label}"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"tagName": "span",
|
|
182
|
+
"attributes": { "class": "fw-medium" },
|
|
183
|
+
"textContent": "${value}"
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"children": []
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"columns": [
|
|
3
|
+
{
|
|
4
|
+
"columnName": "Category",
|
|
5
|
+
"title": "Category",
|
|
6
|
+
"field": "Category",
|
|
7
|
+
"value": "Beverages",
|
|
8
|
+
"isVisible": true
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"columnName": "ItemName",
|
|
12
|
+
"title": "Item Name",
|
|
13
|
+
"field": "ItemName",
|
|
14
|
+
"value": "Green Tea",
|
|
15
|
+
"isVisible": true
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"columnName": "Service",
|
|
19
|
+
"title": "Service",
|
|
20
|
+
"field": "Service",
|
|
21
|
+
"value": "Packaging",
|
|
22
|
+
"isVisible": true
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"columnName": "Rate",
|
|
26
|
+
"title": "Rate",
|
|
27
|
+
"field": "Rate",
|
|
28
|
+
"value": 150,
|
|
29
|
+
"isVisible": true
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"columnName": "pk",
|
|
33
|
+
"title": "pk",
|
|
34
|
+
"field": "pk",
|
|
35
|
+
"isVisible": false
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"Category": "Beverages",
|
|
39
|
+
"ItemName": "Green Tea",
|
|
40
|
+
"Service": "Packaging",
|
|
41
|
+
"Rate": 150
|
|
42
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tagName": "div",
|
|
3
|
+
"attributes": {
|
|
4
|
+
"class": "card shadow-sm border border-slate-200 rounded-xl overflow-hidden max-w-xl mx-auto"
|
|
5
|
+
},
|
|
6
|
+
"children": [
|
|
7
|
+
{
|
|
8
|
+
"tagName": "div",
|
|
9
|
+
"attributes": {
|
|
10
|
+
"class": "card-header bg-slate-100 px-6 py-4 border-b border-slate-200"
|
|
11
|
+
},
|
|
12
|
+
"children": [
|
|
13
|
+
{
|
|
14
|
+
"tagName": "h2",
|
|
15
|
+
"textContent": "Item Master Form",
|
|
16
|
+
"attributes": {
|
|
17
|
+
"class": "h5 mb-0 fw-bold text-slate-800"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"tagName": "p",
|
|
22
|
+
"textContent": "Dynamic rows generated by node-level iteration operation",
|
|
23
|
+
"attributes": {
|
|
24
|
+
"class": "small text-muted mb-0"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"tagName": "div",
|
|
31
|
+
"attributes": {
|
|
32
|
+
"id": "form-body",
|
|
33
|
+
"class": "card-body p-6 space-y-3"
|
|
34
|
+
},
|
|
35
|
+
"children": [
|
|
36
|
+
{
|
|
37
|
+
"operation": "iterate",
|
|
38
|
+
"source": "columns",
|
|
39
|
+
"filter": {
|
|
40
|
+
"isVisible": true
|
|
41
|
+
},
|
|
42
|
+
"template": {
|
|
43
|
+
"tagName": "div",
|
|
44
|
+
"attributes": {
|
|
45
|
+
"class": "row align-items-center g-2 mb-3"
|
|
46
|
+
},
|
|
47
|
+
"children": [
|
|
48
|
+
{
|
|
49
|
+
"tagName": "div",
|
|
50
|
+
"attributes": {
|
|
51
|
+
"class": "row align-items-center g-2"
|
|
52
|
+
},
|
|
53
|
+
"children": [
|
|
54
|
+
{
|
|
55
|
+
"tagName": "label",
|
|
56
|
+
"textContent": "${title}",
|
|
57
|
+
"attributes": {
|
|
58
|
+
"class": "col-sm-4 col-form-label text-sm-end mb-0 fw-semibold text-secondary small"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"tagName": "div",
|
|
63
|
+
"attributes": {
|
|
64
|
+
"class": "col-sm-8"
|
|
65
|
+
},
|
|
66
|
+
"children": [
|
|
67
|
+
{
|
|
68
|
+
"tagName": "input",
|
|
69
|
+
"attributes": {
|
|
70
|
+
"type": "text",
|
|
71
|
+
"name": "${field}",
|
|
72
|
+
"placeholder": "Enter ${title}...",
|
|
73
|
+
"class": "form-control"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"tagName": "div",
|
|
87
|
+
"attributes": {
|
|
88
|
+
"class": "card-footer bg-slate-50 px-6 py-3 border-t border-slate-200 d-flex justify-content-end gap-2"
|
|
89
|
+
},
|
|
90
|
+
"children": [
|
|
91
|
+
{
|
|
92
|
+
"tagName": "button",
|
|
93
|
+
"textContent": "Cancel",
|
|
94
|
+
"attributes": {
|
|
95
|
+
"type": "button",
|
|
96
|
+
"class": "btn btn-outline-secondary btn-sm"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"tagName": "button",
|
|
101
|
+
"textContent": "Save Item",
|
|
102
|
+
"attributes": {
|
|
103
|
+
"type": "submit",
|
|
104
|
+
"class": "btn btn-primary btn-sm"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
+
<title>v30 - Input Only</title>
|
|
8
|
+
<script>
|
|
9
|
+
if (!location.pathname.endsWith('/') && !location.pathname.endsWith('.html')) {
|
|
10
|
+
location.replace(location.pathname + '/' + location.search + location.hash);
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet"
|
|
15
|
+
integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
|
|
16
|
+
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<main>
|
|
21
|
+
<h1 id="head1" style="margin-top:0;font-size:1.25rem">Simple Input (v30)</h1>
|
|
22
|
+
<input list="dl1" class="form-control"></input>
|
|
23
|
+
<input list="uom" class="form-control"></input>
|
|
24
|
+
<div id="dom-render-container">
|
|
25
|
+
<div class="text-center py-5 text-muted">Loading input demo...</div>
|
|
26
|
+
</div>
|
|
27
|
+
</main>
|
|
28
|
+
<script type="module" src="./index.js"></script>
|
|
29
|
+
</body>
|
|
30
|
+
|
|
31
|
+
</html>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { default as compile } from "../../src/index.js";
|
|
2
|
+
// import * as domEngine from "./json-to-dom.v27.min.js";
|
|
3
|
+
|
|
4
|
+
import { specToDom } from "https://keshavsoft.github.io/json-to-dom/dist/v31/min.js";
|
|
5
|
+
|
|
6
|
+
const folder = "input";
|
|
7
|
+
let actionBinding = null;
|
|
8
|
+
let state = { structure: null, data: null, compiled: null };
|
|
9
|
+
|
|
10
|
+
const loadInput = async () => {
|
|
11
|
+
const [structure, data] = await Promise.all([
|
|
12
|
+
fetch(`./${folder}/structure.json`).then((r) => r.json()),
|
|
13
|
+
fetch(`./${folder}/data.json`).then((r) => r.json())
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
structure,
|
|
18
|
+
data
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const render = (structure, data) => {
|
|
23
|
+
const t0 = performance.now();
|
|
24
|
+
|
|
25
|
+
console.log("lllllllllll : ", state);
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const specAsJsonToDom = compile(structure, data);
|
|
29
|
+
const compileTime = (performance.now() - t0).toFixed(2);
|
|
30
|
+
const compileBadge = document.getElementById("compile-time-badge");
|
|
31
|
+
if (compileBadge) compileBadge.textContent = `Compiled in ${compileTime}ms`;
|
|
32
|
+
|
|
33
|
+
const container = document.getElementById("dom-render-container");
|
|
34
|
+
if (container) container.innerHTML = "";
|
|
35
|
+
|
|
36
|
+
// console.log("222222222 : ", specAsJsonToDom);
|
|
37
|
+
|
|
38
|
+
specToDom({ spec: specAsJsonToDom, targetHtmlId: "dom-render-container" });
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const start = async () => {
|
|
42
|
+
try {
|
|
43
|
+
const {
|
|
44
|
+
structure,
|
|
45
|
+
data
|
|
46
|
+
} = await loadInput();
|
|
47
|
+
|
|
48
|
+
render(structure, data);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
const container = document.getElementById("dom-render-container");
|
|
51
|
+
if (container) container.innerHTML = `<div style="color:#b91c1c">Error: ${err.message}</div>`;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
start();
|
|
56
|
+
|
|
57
|
+
const head1 = document.getElementById("head1");
|
|
58
|
+
const version = window?.ks?.["json-to-spec"]?.meta?.version;
|
|
59
|
+
if (version && head1) {
|
|
60
|
+
head1.innerHTML += ` - ${version}`;
|
|
61
|
+
};
|