json-crud-ui-components 1.3.1 → 1.4.2

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.
Files changed (58) hide show
  1. package/bin/v4/commands/addListeners/steps/checks.js +25 -0
  2. package/bin/{v2 → v4}/commands/addListeners/steps/resolveFolderName.js +1 -1
  3. package/bin/{v2/commands/addListeners/template/v2/start.js → v4/commands/addListeners/template/v2/hookAllListeners.js} +1 -1
  4. package/bin/{v2 → v4}/commands/addListeners.js +5 -0
  5. package/bin/v4/commands/htmlIdClick/steps/checks.js +25 -0
  6. package/bin/{v2 → v4}/commands/htmlIdClick/steps/resolveFolderName.js +2 -5
  7. package/bin/{v2 → v4}/commands/htmlIdClick.js +13 -1
  8. package/bin/v4/commands/init/steps/checks.js +23 -0
  9. package/bin/{v2 → v4}/commands/init.js +5 -2
  10. package/bin/v4/core/resolveCommand.js +16 -0
  11. package/bin/v4/core/showUsage.js +49 -0
  12. package/bin/{v2 → v4}/start.js +0 -1
  13. package/package.json +1 -1
  14. package/bin/v2/commands/addListeners/template/v1/AddListeners/start.js +0 -14
  15. package/bin/v2/commands/init/template/v1/Index/FormLoad/DomContentLoaded/buildHeader.js +0 -68
  16. package/bin/v2/commands/init/template/v1/Index/FormLoad/DomContentLoaded/runAfterDomLoad.js +0 -7
  17. package/bin/v2/commands/init/template/v2/FormLoad/DomContentLoaded/buildHeader.js +0 -68
  18. package/bin/v2/commands/init/template/v2/FormLoad/DomContentLoaded/buildMenuItem.js +0 -121
  19. package/bin/v2/commands/init/template/v2/FormLoad/DomContentLoaded/runAfterDomLoad.js +0 -7
  20. package/bin/v2/commands/init/template/v2/FormLoad/DomContentLoaded/start.js +0 -7
  21. package/bin/v2/commands/init/template/v2/FormLoad/start.js +0 -5
  22. package/bin/v2/commands/init/template/v2/start.js +0 -7
  23. package/bin/v2/commands/init/template/v3/FormLoad/DomContentLoaded/buildMenuItem.js +0 -121
  24. package/bin/v2/commands/init/template/v3/FormLoad/DomContentLoaded/start.js +0 -7
  25. package/bin/v2/commands/init/template/v3/FormLoad/start.js +0 -5
  26. package/bin/v2/commands/init/template/v3/start.js +0 -7
  27. package/bin/v2/core/resolveCommand.js +0 -16
  28. package/bin/v2/core/showUsage.js +0 -39
  29. /package/bin/{v2 → v4}/commands/addListeners/steps/announce.js +0 -0
  30. /package/bin/{v2 → v4}/commands/addListeners/steps/createProject.js +0 -0
  31. /package/bin/{v2 → v4}/commands/addListeners/steps/locateDestination.js +0 -0
  32. /package/bin/{v2 → v4}/commands/addListeners/steps/locateSource.js +0 -0
  33. /package/bin/{v2 → v4}/commands/buildHeader/steps/announce.js +0 -0
  34. /package/bin/{v2 → v4}/commands/buildHeader/steps/createProject.js +0 -0
  35. /package/bin/{v2 → v4}/commands/buildHeader/steps/locateDestination.js +0 -0
  36. /package/bin/{v2 → v4}/commands/buildHeader/steps/locateSource.js +0 -0
  37. /package/bin/{v2 → v4}/commands/buildHeader/steps/resolveFolderName.js +0 -0
  38. /package/bin/{v2 → v4}/commands/buildHeader/template/v1/buildHeader.js +0 -0
  39. /package/bin/{v2 → v4}/commands/buildHeader.js +0 -0
  40. /package/bin/{v2 → v4}/commands/htmlIdClick/steps/announce.js +0 -0
  41. /package/bin/{v2 → v4}/commands/htmlIdClick/steps/createProject.js +0 -0
  42. /package/bin/{v2 → v4}/commands/htmlIdClick/steps/locateDestination.js +0 -0
  43. /package/bin/{v2 → v4}/commands/htmlIdClick/steps/locateSource.js +0 -0
  44. /package/bin/{v2 → v4}/commands/htmlIdClick/template/v1/clickFunc.js +0 -0
  45. /package/bin/{v2 → v4}/commands/htmlIdClick/template/v1/start.js +0 -0
  46. /package/bin/{v2 → v4}/commands/init/steps/announce.js +0 -0
  47. /package/bin/{v2 → v4}/commands/init/steps/createProject.js +0 -0
  48. /package/bin/{v2 → v4}/commands/init/steps/locateDestination.js +0 -0
  49. /package/bin/{v2 → v4}/commands/init/steps/locateSource.js +0 -0
  50. /package/bin/{v2 → v4}/commands/init/steps/resolveFolderName.js +0 -0
  51. /package/bin/{v2 → v4}/commands/init/template/v3/FormLoad/DomContentLoaded/buildHeader.js +0 -0
  52. /package/bin/{v2/commands/init/template/v1/Index → v4/commands/init/template/v3}/FormLoad/DomContentLoaded/buildMenuItem.js +0 -0
  53. /package/bin/{v2 → v4}/commands/init/template/v3/FormLoad/DomContentLoaded/runAfterDomLoad.js +0 -0
  54. /package/bin/{v2/commands/init/template/v1/Index → v4/commands/init/template/v3}/FormLoad/DomContentLoaded/start.js +0 -0
  55. /package/bin/{v2/commands/init/template/v1/Index → v4/commands/init/template/v3}/FormLoad/start.js +0 -0
  56. /package/bin/{v2 → v4}/commands/init/template/v3/headers.json +0 -0
  57. /package/bin/{v2/commands/init/template/v1/Index → v4/commands/init/template/v3}/start.js +0 -0
  58. /package/bin/{v2 → v4}/core/parseInput.js +0 -0
@@ -0,0 +1,25 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+
4
+ const validate = ({ toPath, inDefaultFolderName, inFileNameToCheck }) => {
5
+ const fileNameToCheck = inFileNameToCheck;
6
+
7
+ const htmlPath = path.join(toPath, fileNameToCheck);
8
+ const indexPath = path.join(toPath, inDefaultFolderName);
9
+
10
+ if (!fs.existsSync(htmlPath)) {
11
+ console.log(`${fileNameToCheck} not found`);
12
+
13
+ return true;
14
+ };
15
+
16
+ if (fs.existsSync(indexPath)) {
17
+ console.log(`${folderNameToCheck} folder found`);
18
+
19
+ return true;
20
+ };
21
+
22
+ return false;
23
+ };
24
+
25
+ export default validate;
@@ -1,7 +1,7 @@
1
1
  import fs from "fs";
2
2
 
3
3
  export default function resolveFolderName({ name }) {
4
- const defaultFolerName = "htmlId";
4
+ const defaultFolerName = "AddListeners";
5
5
 
6
6
  // case 1: force new → timestamp
7
7
  if (name === null) {
@@ -1,4 +1,4 @@
1
1
  const hookAllListeners = () => {
2
2
  };
3
3
 
4
- export { hookAllListeners };
4
+ export default hookAllListeners;
@@ -5,8 +5,13 @@ import { createProject } from "./addListeners/steps/createProject.js";
5
5
  import { announce } from "./addListeners/steps/announce.js";
6
6
 
7
7
  import resolveFolderName from "./addListeners/steps/resolveFolderName.js";
8
+ import checks from "./addListeners/steps/checks.js";
8
9
 
9
10
  export default ({ folderName = "", toPath = process.cwd(), inAnnounce = true }) => {
11
+ const fromChecks = checks({ toPath, inAnnounce });
12
+
13
+ if (fromChecks) return false;
14
+
10
15
  const resolvedFolderName = resolveFolderName({
11
16
  name: folderName
12
17
  });
@@ -0,0 +1,25 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ const fileNameToCheck = "runAfterDomLoad.js";
4
+ const folderNameToCheck = "AddListeners";
5
+
6
+ const validate = ({ toPath }) => {
7
+ const htmlPath = path.join(toPath, fileNameToCheck);
8
+ const indexPath = path.join(toPath, folderNameToCheck);
9
+
10
+ if (!fs.existsSync(htmlPath)) {
11
+ console.log(`${fileNameToCheck} not found`);
12
+
13
+ return true;
14
+ };
15
+
16
+ if (fs.existsSync(indexPath)) {
17
+ console.log(`${folderNameToCheck} folder found`);
18
+
19
+ return true;
20
+ };
21
+
22
+ return false;
23
+ };
24
+
25
+ export default validate;
@@ -1,11 +1,8 @@
1
1
  import fs from "fs";
2
2
 
3
- export default function resolveFolderName({ name, inType = "basic" }) {
4
- const defaultFolerName = "AddListeners";
5
-
6
- // case 1: force new → timestamp
3
+ export default function resolveFolderName({ name, inDefaultFolderName = "<htmlId>" }) {
7
4
  if (name === null) {
8
- name = defaultFolerName;
5
+ name = inDefaultFolderName;
9
6
  };
10
7
 
11
8
  // case 2: user provided → strict
@@ -5,10 +5,22 @@ import { createProject } from "./htmlIdClick/steps/createProject.js";
5
5
  import { announce } from "./htmlIdClick/steps/announce.js";
6
6
 
7
7
  import resolveFolderName from "./htmlIdClick/steps/resolveFolderName.js";
8
+ import checks from "./addListeners/steps/checks.js";
9
+
10
+ const defaultFolderName = "htmlId";
11
+ const fileNameToCheck = "hookAllListeners.js";
8
12
 
9
13
  export default ({ folderName = "", toPath = process.cwd(), inAnnounce = true }) => {
14
+ const fromChecks = checks({
15
+ toPath, inAnnounce,
16
+ inDefaultFolderName: defaultFolderName,
17
+ inFileNameToCheck: fileNameToCheck
18
+ });
19
+
20
+ if (fromChecks) return false;
21
+
10
22
  const resolvedFolderName = resolveFolderName({
11
- name: folderName
23
+ name: folderName, inDefaultFolderName: defaultFolderName
12
24
  });
13
25
 
14
26
  const source = locateSource();
@@ -0,0 +1,23 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+
4
+ const validate = ({ toPath }) => {
5
+ const htmlPath = path.join(toPath, "index.html");
6
+ const indexPath = path.join(toPath, "index");
7
+
8
+ if (!fs.existsSync(htmlPath)) {
9
+ console.log("index.html not found");
10
+
11
+ return true;
12
+ };
13
+
14
+ if (fs.existsSync(indexPath)) {
15
+ console.log("index folder found");
16
+
17
+ return true;
18
+ };
19
+
20
+ return false;
21
+ };
22
+
23
+ export default validate;
@@ -5,8 +5,13 @@ import { createProject } from "./init/steps/createProject.js";
5
5
  import { announce } from "./init/steps/announce.js";
6
6
 
7
7
  import resolveFolderName from "./init/steps/resolveFolderName.js";
8
+ import checks from "./init/steps/checks.js";
8
9
 
9
10
  export default ({ folderName = "", toPath = process.cwd(), inAnnounce = true }) => {
11
+ const fromChecks = checks({ toPath, inAnnounce });
12
+
13
+ if (fromChecks) return false;
14
+
10
15
  const resolvedFolderName = resolveFolderName({
11
16
  name: folderName
12
17
  });
@@ -17,6 +22,4 @@ export default ({ folderName = "", toPath = process.cwd(), inAnnounce = true })
17
22
  createProject({ source, destination });
18
23
 
19
24
  if (inAnnounce) announce({ inResolvedFolderName: resolvedFolderName });
20
-
21
- console.log("aaaaaaaaa ", folderName, toPath, resolvedFolderName);
22
25
  };
@@ -0,0 +1,16 @@
1
+ import fs from "fs";
2
+
3
+ const files = fs.readdirSync(new URL("../commands/", import.meta.url));
4
+
5
+ const entries = await Promise.all(
6
+ files.filter(f => f.endsWith(".js"))
7
+ .map(async f => [f.replace(".js", ""), (await import(`../commands/${f}`)).default])
8
+ );
9
+
10
+ const map = Object.fromEntries(entries);
11
+
12
+ const resolveCommand = (cmd) => {
13
+ return map[cmd] || null;
14
+ };
15
+
16
+ export default resolveCommand;
@@ -0,0 +1,49 @@
1
+ /*
2
+ JSON CRUD UI CLI – Entry Flow
3
+
4
+ 1. Read user input from terminal (parseInput)
5
+ 2. If no command → show usage
6
+ 3. If help flags → show usage
7
+ 4. Resolve command dynamically
8
+ 5. If command not found → show usage
9
+ 6. Validate command requirements
10
+ 7. Execute command
11
+
12
+ Goal:
13
+ - Zero confusion for user
14
+ - Single source of truth (showUsage)
15
+ - Self-validating commands
16
+ - Easy to extend (drop-in command architecture)
17
+ */
18
+
19
+ export default function showUsage(version) {
20
+ const g = "\x1b[32m";
21
+ const y = "\x1b[33m";
22
+ const c = "\x1b[36m";
23
+ const gray = "\x1b[90m";
24
+ const r = "\x1b[0m";
25
+
26
+ console.log(`
27
+ ${c}🚀 json-crud-ui-components v${version}${r}
28
+
29
+ ${y}Usage:${r}
30
+ ${g}npx json-crud-ui-components${r} <command>
31
+
32
+ ${y}Commands:${r}
33
+ ${g}init${r} Creates initial boilerplate structure
34
+ ${g}addListeners${r} Adds listeners boilerplate
35
+ ${g}buildHeader${r} Builds header structure
36
+ ${g}htmlIdClick${r} Adds htmlIdClick handler
37
+
38
+ ${y}Examples:${r}
39
+ ${gray}npx json-crud-ui-components init${r}
40
+ ${gray}npx json-crud-ui-components addListeners${r}
41
+
42
+ ${y}Architecture:${r}
43
+ ${gray}commands are auto-loaded dynamically${r}
44
+ ${gray}each command validates required files${r}
45
+
46
+ ${y}Tip:${r}
47
+ ${gray}Run init first before feature commands${r}
48
+ `);
49
+ }
@@ -11,7 +11,6 @@ const run = async () => {
11
11
  const input = parseInput();
12
12
 
13
13
  if (input.action === "--help" || input.action === "-h" || input.action === "help") return showUsage(version);
14
- console.log("input : ", input);
15
14
 
16
15
  const command = resolveCommand(input.cmd);
17
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-crud-ui-components",
3
- "version": "1.3.1",
3
+ "version": "1.4.2",
4
4
  "description": "working on ui for our json crud using modules",
5
5
  "keywords": [
6
6
  "cli",
@@ -1,14 +0,0 @@
1
- import { funcToRun as funcToRunForLedgersHtmlId } from "./LedgersHtmlId/start.js";
2
- import { funcToRun as funcToRunForStockItemsHtmlId } from "./StockItemsHtmlId/start.js";
3
-
4
- import { funcToRun as funcToRunForImportHtmlId } from "./ImportHtmlId/start.js";
5
-
6
- const hookAllListeners = () => {
7
- funcToRunForLedgersHtmlId();
8
- funcToRunForStockItemsHtmlId();
9
-
10
- funcToRunForImportHtmlId();
11
-
12
- };
13
-
14
- export { hookAllListeners };
@@ -1,68 +0,0 @@
1
- import { initHeader } from "../../../../../../header/v6/initHeader.js";
2
-
3
- const buildHeader = () => {
4
- const headerConfig = {
5
- items: [
6
- {
7
- text: "ShowAll",
8
- id: "ShowAllHtmlId",
9
- icon: [
10
- "M4 6h16",
11
- "M4 10h16",
12
- "M4 14h10",
13
- "M6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
14
- ]
15
- },
16
- {
17
- text: "StockItems",
18
- id: "StockItemsHtmlId",
19
- icon: [
20
- "M3 7l9 4 9-4",
21
- "M3 7l9-4 9 4",
22
- "M3 7v10l9 4 9-4V7",
23
- "M12 11v10"
24
- ]
25
- },
26
- {
27
- text: "Transactions",
28
- id: "1",
29
- icon: [
30
-
31
- "M6 2h9l5 5v15a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z",
32
- "M14 2v6h6",
33
- "M8 12h8",
34
- "M8 16h8"
35
- ],
36
- href: "../../Transactions/V7/Create/index.html"
37
- },
38
- {
39
- text: "FromTally",
40
- id: "ImportHtmlId",
41
- icon: [
42
- "M4 6h16",
43
- "M4 10h16",
44
- "M4 14h10",
45
- "M6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
46
- ]
47
- }
48
- ]
49
- };
50
-
51
- initHeader(headerConfig);
52
- // callKSHeader(headerConfig).then();
53
- };
54
-
55
- const callKSHeader = async (config) => {
56
- if (window.KSHeader?.initHeader) {
57
- console.log("table loaded from window.KSTable");
58
-
59
- return window.KSHeader.initHeader(config); // extension or CDN
60
- } else {
61
- // const { initTableOnly } = await import("../../../../../../../../KSTableAi/V28/entry.js"); // local
62
- const { initTableOnly } = await import("https://keshavsoft.github.io/KsJsTableAi/Public/kstable.js"); // local
63
-
64
- return initTableOnly(config);
65
- };
66
- };
67
-
68
- export { buildHeader };
@@ -1,7 +0,0 @@
1
- import { buildHeader } from "./buildHeader.js";
2
-
3
- const runAfterDomLoad = () => {
4
- buildHeader();
5
- };
6
-
7
- export { runAfterDomLoad };
@@ -1,68 +0,0 @@
1
- import { initHeader } from "../../../../../../header/v6/initHeader.js";
2
-
3
- const buildHeader = () => {
4
- const headerConfig = {
5
- items: [
6
- {
7
- text: "ShowAll",
8
- id: "ShowAllHtmlId",
9
- icon: [
10
- "M4 6h16",
11
- "M4 10h16",
12
- "M4 14h10",
13
- "M6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
14
- ]
15
- },
16
- {
17
- text: "StockItems",
18
- id: "StockItemsHtmlId",
19
- icon: [
20
- "M3 7l9 4 9-4",
21
- "M3 7l9-4 9 4",
22
- "M3 7v10l9 4 9-4V7",
23
- "M12 11v10"
24
- ]
25
- },
26
- {
27
- text: "Transactions",
28
- id: "1",
29
- icon: [
30
-
31
- "M6 2h9l5 5v15a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z",
32
- "M14 2v6h6",
33
- "M8 12h8",
34
- "M8 16h8"
35
- ],
36
- href: "../../Transactions/V7/Create/index.html"
37
- },
38
- {
39
- text: "FromTally",
40
- id: "ImportHtmlId",
41
- icon: [
42
- "M4 6h16",
43
- "M4 10h16",
44
- "M4 14h10",
45
- "M6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
46
- ]
47
- }
48
- ]
49
- };
50
-
51
- initHeader(headerConfig);
52
- // callKSHeader(headerConfig).then();
53
- };
54
-
55
- const callKSHeader = async (config) => {
56
- if (window.KSHeader?.initHeader) {
57
- console.log("table loaded from window.KSTable");
58
-
59
- return window.KSHeader.initHeader(config); // extension or CDN
60
- } else {
61
- // const { initTableOnly } = await import("../../../../../../../../KSTableAi/V28/entry.js"); // local
62
- const { initTableOnly } = await import("https://keshavsoft.github.io/KsJsTableAi/Public/kstable.js"); // local
63
-
64
- return initTableOnly(config);
65
- };
66
- };
67
-
68
- export { buildHeader };
@@ -1,121 +0,0 @@
1
- // orchestrator
2
- export const buildMenuItem = ({
3
- inTextToShow,
4
- inHtmlId,
5
- inIconPaths,
6
- inHref
7
- }) => {
8
- const textToShow = inTextToShow;
9
- const htmlId = inHtmlId;
10
- const iconPaths = inIconPaths;
11
-
12
- const li = createLi();
13
- const a = createAnchor({ inHtmlId: htmlId, inHref });
14
- const span = createLabel({ inTextToShow: textToShow });
15
- const svg = createIcon({ inIconPaths: iconPaths });
16
-
17
- a.append(svg, span);
18
- li.appendChild(a);
19
-
20
- return li;
21
- };
22
-
23
- const createLi = () => {
24
- const htmlLi = document.createElement("li");
25
-
26
- htmlLi.className = "md:text-center";
27
-
28
- return htmlLi;
29
-
30
-
31
- };
32
-
33
- // createAnchor
34
- const createAnchor = ({ inHtmlId = "htmlId",
35
- inHref = "#"
36
- }) => {
37
- const a = document.createElement("a");
38
- a.id = inHtmlId;
39
- a.href = inHref;
40
- // a.className =
41
- // "group flex items-center md:flex-col md:items-center gap-0 md:gap-1 cursor-pointer hover:bg-gray-700 px-2 py-1 rounded transition-colors duration-200 active:scale-95 focus:outline-none focus:ring-2 focus:ring-gray-500";
42
-
43
- a.className = `flex justify-between items-center bg-gray-700 px-4 py-2 rounded-md
44
- hover:bg-gray-600 active:bg-gray-500 active:scale-95
45
- transition-all duration-150
46
- md:flex-col md:justify-center md:items-center
47
- lg:bg-transparent lg:px-2 lg:py-1`;
48
-
49
- return a;
50
- };
51
-
52
- // createLabel (no transform → no height change)
53
- const createLabel = ({ inTextToShow = "Menu1" }) => {
54
- const span = document.createElement("span");
55
- span.className =
56
- "ml-3 text-right w-full text-base md:w-auto md:text-center md:ml-0 lg:text-lg";
57
-
58
- span.textContent = inTextToShow;
59
-
60
- return span;
61
- };
62
-
63
- // createIcon (safe transform: no layout shift)
64
- const createIcon = ({ inIconPaths = [] }) => {
65
- const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
66
- // svg.setAttribute(
67
- // "class",
68
- // "w-6 h-6 md:order-1 md:mb-0 text-gray-400 group-hover:text-white transition-all duration-200 transform group-hover:scale-95 group-hover:-translate-y-0.5"
69
- // );
70
-
71
-
72
- svg.setAttribute(
73
- "class",
74
- "text-gray-300 w-6 h-6 lg:w-7 lg:h-7"
75
- );
76
-
77
-
78
- // <svg class="text-gray-300 w-6 h-6 lg:w-7 lg:h-7" fill="none" stroke="currentColor"
79
-
80
-
81
- svg.setAttribute("fill", "none");
82
- svg.setAttribute("stroke", "currentColor");
83
- svg.setAttribute("viewBox", "0 0 24 24");
84
- svg.setAttribute("stroke-width", "1.5");
85
- svg.setAttribute("stroke-linecap", "round");
86
- svg.setAttribute("stroke-linejoin", "round");
87
-
88
- inIconPaths.forEach(d => {
89
- const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
90
- path.setAttribute("d", d);
91
- svg.appendChild(path);
92
- });
93
-
94
- return svg;
95
- };
96
-
97
-
98
-
99
- // <li class="md:text-center">
100
- // <a id="LedgersHtmlId"
101
- // href="#" class="flex justify-between items-center bg-gray-700 px-4 py-2 rounded-md
102
- // hover:bg-gray-600 active:bg-gray-500 active:scale-95
103
- // transition-all duration-150
104
- // md:flex-col md:justify-center md:items-center
105
- // lg:bg-transparent lg:px-2 lg:py-1">
106
-
107
- // <!-- LEFT: ICON -->
108
- // <svg class="text-gray-300 w-6 h-6 lg:w-7 lg:h-7" fill="none" stroke="currentColor"
109
- // viewBox="0 0 24 24">
110
- // <path
111
- // d="M4 6h16M4 10h16M4 14h10M6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" />
112
- // </svg>
113
-
114
- // <!-- RIGHT: LABEL -->
115
- // <span class="ml-3 text-right w-full text-base
116
- // md:w-auto md:text-center md:ml-0
117
- // lg:text-lg
118
- // ">Ledgers</span>
119
-
120
- // </a>
121
- // </li>
@@ -1,7 +0,0 @@
1
- import { buildHeader } from "./buildHeader.js";
2
-
3
- const runAfterDomLoad = () => {
4
- buildHeader();
5
- };
6
-
7
- export { runAfterDomLoad };
@@ -1,7 +0,0 @@
1
- import { runAfterDomLoad } from "./runAfterDomLoad.js";
2
-
3
- export function startDomContentLoaded() {
4
- document.addEventListener("DOMContentLoaded", () => {
5
- runAfterDomLoad();
6
- });
7
- }
@@ -1,5 +0,0 @@
1
- import { startDomContentLoaded } from "./DomContentLoaded/start.js";
2
-
3
- export function startFormLoad() {
4
- startDomContentLoaded();
5
- }
@@ -1,7 +0,0 @@
1
- import { startFormLoad } from "./FormLoad/start.js";
2
-
3
- function startApp() {
4
- startFormLoad();
5
- };
6
-
7
- startApp();
@@ -1,121 +0,0 @@
1
- // orchestrator
2
- export const buildMenuItem = ({
3
- inTextToShow,
4
- inHtmlId,
5
- inIconPaths,
6
- inHref
7
- }) => {
8
- const textToShow = inTextToShow;
9
- const htmlId = inHtmlId;
10
- const iconPaths = inIconPaths;
11
-
12
- const li = createLi();
13
- const a = createAnchor({ inHtmlId: htmlId, inHref });
14
- const span = createLabel({ inTextToShow: textToShow });
15
- const svg = createIcon({ inIconPaths: iconPaths });
16
-
17
- a.append(svg, span);
18
- li.appendChild(a);
19
-
20
- return li;
21
- };
22
-
23
- const createLi = () => {
24
- const htmlLi = document.createElement("li");
25
-
26
- htmlLi.className = "md:text-center";
27
-
28
- return htmlLi;
29
-
30
-
31
- };
32
-
33
- // createAnchor
34
- const createAnchor = ({ inHtmlId = "htmlId",
35
- inHref = "#"
36
- }) => {
37
- const a = document.createElement("a");
38
- a.id = inHtmlId;
39
- a.href = inHref;
40
- // a.className =
41
- // "group flex items-center md:flex-col md:items-center gap-0 md:gap-1 cursor-pointer hover:bg-gray-700 px-2 py-1 rounded transition-colors duration-200 active:scale-95 focus:outline-none focus:ring-2 focus:ring-gray-500";
42
-
43
- a.className = `flex justify-between items-center bg-gray-700 px-4 py-2 rounded-md
44
- hover:bg-gray-600 active:bg-gray-500 active:scale-95
45
- transition-all duration-150
46
- md:flex-col md:justify-center md:items-center
47
- lg:bg-transparent lg:px-2 lg:py-1`;
48
-
49
- return a;
50
- };
51
-
52
- // createLabel (no transform → no height change)
53
- const createLabel = ({ inTextToShow = "Menu1" }) => {
54
- const span = document.createElement("span");
55
- span.className =
56
- "ml-3 text-right w-full text-base md:w-auto md:text-center md:ml-0 lg:text-lg";
57
-
58
- span.textContent = inTextToShow;
59
-
60
- return span;
61
- };
62
-
63
- // createIcon (safe transform: no layout shift)
64
- const createIcon = ({ inIconPaths = [] }) => {
65
- const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
66
- // svg.setAttribute(
67
- // "class",
68
- // "w-6 h-6 md:order-1 md:mb-0 text-gray-400 group-hover:text-white transition-all duration-200 transform group-hover:scale-95 group-hover:-translate-y-0.5"
69
- // );
70
-
71
-
72
- svg.setAttribute(
73
- "class",
74
- "text-gray-300 w-6 h-6 lg:w-7 lg:h-7"
75
- );
76
-
77
-
78
- // <svg class="text-gray-300 w-6 h-6 lg:w-7 lg:h-7" fill="none" stroke="currentColor"
79
-
80
-
81
- svg.setAttribute("fill", "none");
82
- svg.setAttribute("stroke", "currentColor");
83
- svg.setAttribute("viewBox", "0 0 24 24");
84
- svg.setAttribute("stroke-width", "1.5");
85
- svg.setAttribute("stroke-linecap", "round");
86
- svg.setAttribute("stroke-linejoin", "round");
87
-
88
- inIconPaths.forEach(d => {
89
- const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
90
- path.setAttribute("d", d);
91
- svg.appendChild(path);
92
- });
93
-
94
- return svg;
95
- };
96
-
97
-
98
-
99
- // <li class="md:text-center">
100
- // <a id="LedgersHtmlId"
101
- // href="#" class="flex justify-between items-center bg-gray-700 px-4 py-2 rounded-md
102
- // hover:bg-gray-600 active:bg-gray-500 active:scale-95
103
- // transition-all duration-150
104
- // md:flex-col md:justify-center md:items-center
105
- // lg:bg-transparent lg:px-2 lg:py-1">
106
-
107
- // <!-- LEFT: ICON -->
108
- // <svg class="text-gray-300 w-6 h-6 lg:w-7 lg:h-7" fill="none" stroke="currentColor"
109
- // viewBox="0 0 24 24">
110
- // <path
111
- // d="M4 6h16M4 10h16M4 14h10M6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" />
112
- // </svg>
113
-
114
- // <!-- RIGHT: LABEL -->
115
- // <span class="ml-3 text-right w-full text-base
116
- // md:w-auto md:text-center md:ml-0
117
- // lg:text-lg
118
- // ">Ledgers</span>
119
-
120
- // </a>
121
- // </li>
@@ -1,7 +0,0 @@
1
- import { runAfterDomLoad } from "./runAfterDomLoad.js";
2
-
3
- export function startDomContentLoaded() {
4
- document.addEventListener("DOMContentLoaded", () => {
5
- runAfterDomLoad();
6
- });
7
- }
@@ -1,5 +0,0 @@
1
- import { startDomContentLoaded } from "./DomContentLoaded/start.js";
2
-
3
- export function startFormLoad() {
4
- startDomContentLoaded();
5
- }
@@ -1,7 +0,0 @@
1
- import { startFormLoad } from "./FormLoad/start.js";
2
-
3
- function startApp() {
4
- startFormLoad();
5
- };
6
-
7
- startApp();
@@ -1,16 +0,0 @@
1
- import init from "../commands/init.js";
2
- import addListeners from "../commands/addListeners.js";
3
- import htmlIdClick from "../commands/htmlIdClick.js";
4
- import buildHeader from "../commands/buildHeader.js";
5
-
6
- // resolveCommand.js
7
- const map = {
8
- init,
9
- addListeners,
10
- htmlIdClick,
11
- buildHeader
12
- };
13
-
14
- export default function resolveCommand(cmd) {
15
- return map[cmd] || null;
16
- };
@@ -1,39 +0,0 @@
1
- /*
2
- KSchema CLI – Entry Flow
3
-
4
- 1. Read user input from terminal (parseInput)
5
- 2. If no command → show usage (first-time user safety)
6
- 3. If help flags → show usage (quick guidance)
7
- 4. Resolve command dynamically (no hardcoding logic)
8
- 5. If command not found → inform + guide back to usage
9
- 6. Execute command with parsed input
10
-
11
- Goal:
12
- - Zero confusion for user
13
- - Single source of truth (showUsage)
14
- - Easy to extend (just add commands, no core changes)
15
- */
16
-
17
- export default function showUsage(version) {
18
- const g = "\x1b[32m";
19
- const y = "\x1b[33m";
20
- const c = "\x1b[36m";
21
- const gray = "\x1b[90m";
22
- const r = "\x1b[0m";
23
-
24
- console.log(`
25
- ${c}🚀 json-crud-ui v${version}${r}
26
-
27
- ${y}Usage:${r}
28
- ${g}npx @keshavsoft/kschema-api-gen${r} <command> [options]
29
-
30
- ${y}Commands:${r}
31
- ${g}endPointsJs${r} Checks for end-points.js file in that location
32
-
33
- ${y}Examples:${r}
34
- ${gray}npx @keshavsoft/kschema-api-gen endPointsJs ShowAll${r}
35
-
36
- ${y}Tip:${r}
37
- ${gray}npm i -g @keshavsoft/kschema-api-gen${r}
38
- `);
39
- }
File without changes
File without changes
File without changes