@skalfa/skalfa-app-core 1.0.0 → 1.0.4
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/LICENSE +21 -0
- package/README.md +63 -0
- package/dist/{api.util.js → api/api.js} +2 -2
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/{auth.util.js → auth/auth.js} +1 -1
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.js +1 -0
- package/dist/{cavity.util.js → cavity/cavity.js} +2 -2
- package/dist/cavity/index.d.ts +1 -0
- package/dist/cavity/index.js +1 -0
- package/dist/cn/index.d.ts +1 -0
- package/dist/cn/index.js +1 -0
- package/dist/commands/blueprint.js +2 -2
- package/dist/commands/cli.d.ts +6 -0
- package/dist/commands/cli.js +107 -0
- package/dist/commands/use-pdf.js +1 -1
- package/dist/conversion/index.d.ts +1 -0
- package/dist/conversion/index.js +1 -0
- package/dist/encryption/index.d.ts +1 -0
- package/dist/encryption/index.js +1 -0
- package/dist/{form.util.d.ts → form/form.d.ts} +2 -2
- package/dist/{form.util.js → form/form.js} +3 -3
- package/dist/form/index.d.ts +1 -0
- package/dist/form/index.js +1 -0
- package/dist/hooks.d.ts +14 -0
- package/dist/hooks.js +63 -0
- package/dist/index.d.ts +14 -26
- package/dist/index.js +14 -75
- package/dist/resource/index.d.ts +1 -0
- package/dist/resource/index.js +1 -0
- package/dist/{resource.util.d.ts → resource/resource.d.ts} +1 -1
- package/dist/{resource.util.js → resource/resource.js} +2 -2
- package/dist/shortcut/index.d.ts +1 -0
- package/dist/shortcut/index.js +1 -0
- package/dist/table/index.d.ts +1 -0
- package/dist/table/index.js +1 -0
- package/dist/{table.util.d.ts → table/table.d.ts} +2 -2
- package/dist/{table.util.js → table/table.js} +2 -2
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/index.js +1 -0
- package/dist/{validation.util.js → validation/validation.js} +1 -1
- package/package.json +4 -3
- package/dist/commands/barrels.d.ts +0 -1
- package/dist/commands/barrels.js +0 -22
- package/dist/commands/light.d.ts +0 -1
- package/dist/commands/light.js +0 -16
- package/dist/langs/index.d.ts +0 -1
- package/dist/langs/index.js +0 -1
- /package/dist/{api.util.d.ts → api/api.d.ts} +0 -0
- /package/dist/{auth.util.d.ts → auth/auth.d.ts} +0 -0
- /package/dist/{cavity.util.d.ts → cavity/cavity.d.ts} +0 -0
- /package/dist/{cn.util.d.ts → cn/cn.d.ts} +0 -0
- /package/dist/{cn.util.js → cn/cn.js} +0 -0
- /package/dist/{conversion.util.d.ts → conversion/conversion.d.ts} +0 -0
- /package/dist/{conversion.util.js → conversion/conversion.js} +0 -0
- /package/dist/{encryption.util.d.ts → encryption/encryption.d.ts} +0 -0
- /package/dist/{encryption.util.js → encryption/encryption.js} +0 -0
- /package/dist/{commands/logger.d.ts → logger.d.ts} +0 -0
- /package/dist/{commands/logger.js → logger.js} +0 -0
- /package/dist/{shortcut.util.d.ts → shortcut/shortcut.d.ts} +0 -0
- /package/dist/{shortcut.util.js → shortcut/shortcut.js} +0 -0
- /package/dist/{validation.util.d.ts → validation/validation.d.ts} +0 -0
- /package/dist/{langs → validation}/validation.langs.d.ts +0 -0
- /package/dist/{langs → validation}/validation.langs.js +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Skalfa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://skalfa.sejedigital.com/images/logo-skalfa.png" alt="Skalfa Logo" width="300" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# @skalfa/skalfa-app-core
|
|
6
|
+
|
|
7
|
+
> Core framework engine and foundational utility hook library for the Skalfa Next.js frontend.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## About this Package
|
|
12
|
+
|
|
13
|
+
This package is part of the **Skalfa Framework**, a premium development ecosystem designed to build high-performance, modular web applications and APIs.
|
|
14
|
+
|
|
15
|
+
### Usage Scope & Standalone Status
|
|
16
|
+
> 🔒 **Skalfa Ecosystem Integration:** This package is designed to run **integrated within the Skalfa ecosystem** (such as Skalfa API or Skalfa App). It relies on the global service registry and core framework abstractions to operate.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Documentation
|
|
21
|
+
|
|
22
|
+
See the usage documentation at [Documentation](https://skalfa.sejedigital.com).
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
You can install this package using your preferred package manager:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Using npm
|
|
32
|
+
npm install @skalfa/skalfa-app-core
|
|
33
|
+
|
|
34
|
+
# Using bun
|
|
35
|
+
bun add @skalfa/skalfa-app-core
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Pre-installed Dependencies
|
|
41
|
+
|
|
42
|
+
The following key dependencies are packaged and managed within this project:
|
|
43
|
+
|
|
44
|
+
| Dependency | Scope | Version |
|
|
45
|
+
| :--- | :--- | :--- |
|
|
46
|
+
| `axios` | runtime | `^1.12.0` |
|
|
47
|
+
| `clsx` | runtime | `^2.1.1` |
|
|
48
|
+
| `crypto-js` | runtime | `^4.2.0` |
|
|
49
|
+
| `js-cookie` | runtime | `^3.0.5` |
|
|
50
|
+
| `lz-string` | runtime | `^1.5.0` |
|
|
51
|
+
| `moment` | runtime | `^2.30.1` |
|
|
52
|
+
| `tailwind-merge` | runtime | `^3.0.2` |
|
|
53
|
+
| `validator` | runtime | `^13.15.22` |
|
|
54
|
+
| `@types/node` | development | `^20.0.0` |
|
|
55
|
+
| `@types/react` | development | `^19.0.0` |
|
|
56
|
+
| `@types/react-dom` | development | `^19.0.0` |
|
|
57
|
+
| `typescript` | development | `^6.0.3` |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
This package is licensed under the **MIT License**. For full license text, see the [LICENSE](LICENSE) file.
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import axios from "axios";
|
|
4
4
|
import { redirect } from "next/navigation";
|
|
5
|
-
import { auth } from "
|
|
6
|
-
import { cavity } from "
|
|
5
|
+
import { auth } from "../auth";
|
|
6
|
+
import { cavity } from "../cavity";
|
|
7
7
|
// =========================>
|
|
8
8
|
// ## Build auth bearer
|
|
9
9
|
// =========================>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./api";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./api";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./auth";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./auth";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { registry } from "
|
|
2
|
-
import { logger } from "
|
|
1
|
+
import { registry } from "../registry";
|
|
2
|
+
import { logger } from "../logger";
|
|
3
3
|
const name = String(process.env.NEXT_PUBLIC_APP_NAME || "").toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "") + ".cavity";
|
|
4
4
|
const storeName = "cache";
|
|
5
5
|
const version = 1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./cavity";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./cavity";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./cn";
|
package/dist/cn/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./cn";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { conversion } from "../conversion/conversion";
|
|
4
|
+
import { logger } from "../logger";
|
|
5
5
|
const renderJS = (value, indent = 0) => {
|
|
6
6
|
const pad = " ".repeat(indent);
|
|
7
7
|
if (Array.isArray(value)) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
export declare const usePdfCommand: Command;
|
|
3
|
+
export declare const blueprintCommand: Command;
|
|
4
|
+
export declare const barrelsCommand: Command;
|
|
5
|
+
export declare const watchBarrelsCommand: Command;
|
|
6
|
+
export declare function runCli(): void;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { usePdf } from "./use-pdf";
|
|
3
|
+
import { blueprint } from "./blueprint";
|
|
4
|
+
import { logger } from "../logger";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { exec, execSync } from "child_process";
|
|
8
|
+
// =====================================>
|
|
9
|
+
// ## Command: use-pdf
|
|
10
|
+
// =====================================>
|
|
11
|
+
export const usePdfCommand = new Command("use-pdf")
|
|
12
|
+
.description("Copy pdf.worker.min.mjs ke folder public/")
|
|
13
|
+
.action(() => {
|
|
14
|
+
usePdf();
|
|
15
|
+
});
|
|
16
|
+
// =====================================>
|
|
17
|
+
// ## Command: blueprint
|
|
18
|
+
// =====================================>
|
|
19
|
+
export const blueprintCommand = new Command("blueprint")
|
|
20
|
+
.description("Generate blueprint")
|
|
21
|
+
.option("-o, --only <names...>", "Run only specific blueprints")
|
|
22
|
+
.action(async (opts) => {
|
|
23
|
+
await blueprint({ only: opts.only });
|
|
24
|
+
logger.info("Success run all blueprints!");
|
|
25
|
+
process.exit(0);
|
|
26
|
+
});
|
|
27
|
+
// =====================================>
|
|
28
|
+
// ## Command: barrels (run once)
|
|
29
|
+
// =====================================>
|
|
30
|
+
export const barrelsCommand = new Command("barrels")
|
|
31
|
+
.description("Generate barrels auto-imports using barrelsby")
|
|
32
|
+
.action(() => {
|
|
33
|
+
const rootDir = process.cwd();
|
|
34
|
+
const configPath = path.join(rootDir, "barrels.json");
|
|
35
|
+
if (!fs.existsSync(configPath)) {
|
|
36
|
+
logger.error("barrels.json config file not found at project root");
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
logger.info("Generating barrels...");
|
|
40
|
+
try {
|
|
41
|
+
execSync("npx barrelsby -c barrels.json", { cwd: rootDir, stdio: "inherit" });
|
|
42
|
+
logger.info("Barrels successfully generated!");
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
logger.error(`Failed to generate barrels: ${err}`);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
// =====================================>
|
|
51
|
+
// ## Command: watch:barrels (file watcher)
|
|
52
|
+
// =====================================>
|
|
53
|
+
export const watchBarrelsCommand = new Command("watch:barrels")
|
|
54
|
+
.description("Watch directories and update barrels automatically on file changes")
|
|
55
|
+
.action(async () => {
|
|
56
|
+
const rootDir = process.cwd();
|
|
57
|
+
const configPath = path.join(rootDir, "barrels.json");
|
|
58
|
+
if (!fs.existsSync(configPath)) {
|
|
59
|
+
logger.error("barrels.json config file not found at project root");
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
let config = {};
|
|
63
|
+
try {
|
|
64
|
+
const configText = fs.readFileSync(configPath, "utf8");
|
|
65
|
+
config = JSON.parse(configText);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
logger.error(`Failed to parse barrels.json: ${err}`);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
const directories = Array.isArray(config.directory) ? config.directory : [config.directory];
|
|
72
|
+
// Run barrels once at startup
|
|
73
|
+
logger.info("Initializing barrels generation...");
|
|
74
|
+
try {
|
|
75
|
+
execSync("npx barrelsby -c barrels.json", { cwd: rootDir });
|
|
76
|
+
}
|
|
77
|
+
catch { }
|
|
78
|
+
directories.forEach((dir) => {
|
|
79
|
+
const absoluteDir = path.join(rootDir, dir);
|
|
80
|
+
if (!fs.existsSync(absoluteDir)) {
|
|
81
|
+
logger.error(`Barrels error: ${absoluteDir} directory not found`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
fs.watch(absoluteDir, { recursive: true }, (_, filename) => {
|
|
85
|
+
if (filename && (filename.endsWith(".ts") || filename.endsWith(".tsx")) && filename !== "index.ts") {
|
|
86
|
+
exec("npx barrelsby -c barrels.json", { cwd: rootDir }, (error) => {
|
|
87
|
+
if (error) {
|
|
88
|
+
logger.error(`Failed to update barrels for ${dir}: ${error.message}`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
logger.info(`Barrels updated: ${path.join(dir, "index.ts")}`);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
logger.start("Barrels watcher running for: " + directories.join(", "));
|
|
98
|
+
});
|
|
99
|
+
export function runCli() {
|
|
100
|
+
const program = new Command();
|
|
101
|
+
program.name("skalfa").description("Skalfa-app CLI").version("1.0.0");
|
|
102
|
+
program.addCommand(usePdfCommand);
|
|
103
|
+
program.addCommand(blueprintCommand);
|
|
104
|
+
program.addCommand(barrelsCommand);
|
|
105
|
+
program.addCommand(watchBarrelsCommand);
|
|
106
|
+
program.parse(process.argv);
|
|
107
|
+
}
|
package/dist/commands/use-pdf.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { fileURLToPath } from "url";
|
|
4
|
-
import { logger } from "
|
|
4
|
+
import { logger } from "../logger";
|
|
5
5
|
export function usePdf() {
|
|
6
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = path.dirname(__filename);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./conversion";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./conversion";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./encryption";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./encryption";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useReducer, useEffect, useState } from "react";
|
|
3
|
-
import { registry } from "
|
|
4
|
-
import { validation } from "
|
|
5
|
-
import { api } from "
|
|
3
|
+
import { registry } from "../registry";
|
|
4
|
+
import { validation } from "../validation";
|
|
5
|
+
import { api } from "../api";
|
|
6
6
|
const initialState = {
|
|
7
7
|
formRegisters: [],
|
|
8
8
|
formValues: [],
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./form";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./form";
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const useResponsive: () => {
|
|
2
|
+
isXs: boolean;
|
|
3
|
+
isSm: boolean;
|
|
4
|
+
isMd: boolean;
|
|
5
|
+
isLg: boolean;
|
|
6
|
+
isXl: boolean;
|
|
7
|
+
isMobile: boolean;
|
|
8
|
+
isTablet: boolean;
|
|
9
|
+
isDesktop: boolean;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
};
|
|
13
|
+
export declare function useKeyboardOpen(): boolean;
|
|
14
|
+
export declare const useLazySearch: (keyword: string) => string[];
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
// ==============================>
|
|
4
|
+
// ## Detect device size
|
|
5
|
+
// ==============================>
|
|
6
|
+
export const useResponsive = () => {
|
|
7
|
+
const [windowSize, setWindowSize] = useState({ width: 0, height: 0 });
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (typeof window === "undefined")
|
|
10
|
+
return;
|
|
11
|
+
const handleResize = () => {
|
|
12
|
+
setWindowSize({ width: window.innerWidth, height: window.innerHeight });
|
|
13
|
+
};
|
|
14
|
+
handleResize();
|
|
15
|
+
window.addEventListener("resize", handleResize);
|
|
16
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
17
|
+
}, []);
|
|
18
|
+
return {
|
|
19
|
+
isXs: windowSize.width < 640,
|
|
20
|
+
isSm: windowSize.width < 768,
|
|
21
|
+
isMd: windowSize.width < 1024,
|
|
22
|
+
isLg: windowSize.width < 1280,
|
|
23
|
+
isXl: windowSize.width >= 1280,
|
|
24
|
+
isMobile: windowSize.width < 768,
|
|
25
|
+
isTablet: windowSize.width >= 768 && windowSize.width < 1024,
|
|
26
|
+
isDesktop: windowSize.width >= 1024,
|
|
27
|
+
width: windowSize.width,
|
|
28
|
+
height: windowSize.height,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
// ==============================>
|
|
32
|
+
// ## Detect keyboard open
|
|
33
|
+
// ==============================>
|
|
34
|
+
export function useKeyboardOpen() {
|
|
35
|
+
const [isKeyboardOpen, setIsKeyboardOpen] = useState(false);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const handleResize = () => {
|
|
38
|
+
if (window.visualViewport) {
|
|
39
|
+
const viewportHeight = window.visualViewport.height;
|
|
40
|
+
const windowHeight = window.innerHeight;
|
|
41
|
+
setIsKeyboardOpen(viewportHeight < windowHeight);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
window.visualViewport?.addEventListener("resize", handleResize);
|
|
45
|
+
return () => window.visualViewport?.removeEventListener("resize", handleResize);
|
|
46
|
+
}, []);
|
|
47
|
+
return isKeyboardOpen;
|
|
48
|
+
}
|
|
49
|
+
// ==============================>
|
|
50
|
+
// ## Search with typing reference
|
|
51
|
+
// ==============================>
|
|
52
|
+
export const useLazySearch = (keyword) => {
|
|
53
|
+
const [keywordSearch, setKeywordSearch] = useState("");
|
|
54
|
+
const [doSearch, setDoSearch] = useState(false);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (keyword != undefined) {
|
|
57
|
+
const delaySearch = setTimeout(() => setDoSearch(!doSearch), 500);
|
|
58
|
+
return () => clearTimeout(delaySearch);
|
|
59
|
+
}
|
|
60
|
+
}, [keyword]);
|
|
61
|
+
useEffect(() => setKeywordSearch(keyword), [doSearch]);
|
|
62
|
+
return [keywordSearch];
|
|
63
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
export * from "./api
|
|
2
|
-
export * from "./auth
|
|
3
|
-
export * from "./cavity
|
|
4
|
-
export * from "./encryption
|
|
5
|
-
export * from "./cn
|
|
6
|
-
export * from "./form
|
|
7
|
-
export * from "./resource
|
|
8
|
-
export * from "./table
|
|
9
|
-
export * from "./validation
|
|
10
|
-
export * from "./conversion
|
|
11
|
-
export * from "./shortcut
|
|
12
|
-
export * from "./
|
|
1
|
+
export * from "./api";
|
|
2
|
+
export * from "./auth";
|
|
3
|
+
export * from "./cavity";
|
|
4
|
+
export * from "./encryption";
|
|
5
|
+
export * from "./cn";
|
|
6
|
+
export * from "./form";
|
|
7
|
+
export * from "./resource";
|
|
8
|
+
export * from "./table";
|
|
9
|
+
export * from "./validation";
|
|
10
|
+
export * from "./conversion";
|
|
11
|
+
export * from "./shortcut";
|
|
12
|
+
export * from "./logger";
|
|
13
13
|
export * from "./registry";
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
isSm: boolean;
|
|
17
|
-
isMd: boolean;
|
|
18
|
-
isLg: boolean;
|
|
19
|
-
isXl: boolean;
|
|
20
|
-
isMobile: boolean;
|
|
21
|
-
isTablet: boolean;
|
|
22
|
-
isDesktop: boolean;
|
|
23
|
-
width: number;
|
|
24
|
-
height: number;
|
|
25
|
-
};
|
|
26
|
-
export declare function useKeyboardOpen(): boolean;
|
|
27
|
-
export declare const useLazySearch: (keyword: string) => string[];
|
|
14
|
+
export * from "./commands/cli";
|
|
15
|
+
export * from "./hooks";
|
package/dist/index.js
CHANGED
|
@@ -1,79 +1,18 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
1
|
// ==============================>
|
|
4
2
|
// ## Export all from core utils
|
|
5
3
|
// ==============================>
|
|
6
|
-
export * from "./api
|
|
7
|
-
export * from "./auth
|
|
8
|
-
export * from "./cavity
|
|
9
|
-
export * from "./encryption
|
|
10
|
-
export * from "./cn
|
|
11
|
-
export * from "./form
|
|
12
|
-
export * from "./resource
|
|
13
|
-
export * from "./table
|
|
14
|
-
export * from "./validation
|
|
15
|
-
export * from "./conversion
|
|
16
|
-
export * from "./shortcut
|
|
17
|
-
export * from "./
|
|
4
|
+
export * from "./api";
|
|
5
|
+
export * from "./auth";
|
|
6
|
+
export * from "./cavity";
|
|
7
|
+
export * from "./encryption";
|
|
8
|
+
export * from "./cn";
|
|
9
|
+
export * from "./form";
|
|
10
|
+
export * from "./resource";
|
|
11
|
+
export * from "./table";
|
|
12
|
+
export * from "./validation";
|
|
13
|
+
export * from "./conversion";
|
|
14
|
+
export * from "./shortcut";
|
|
15
|
+
export * from "./logger";
|
|
18
16
|
export * from "./registry";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// ==============================>
|
|
22
|
-
export const useResponsive = () => {
|
|
23
|
-
const [windowSize, setWindowSize] = useState({ width: 0, height: 0 });
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (typeof window === "undefined")
|
|
26
|
-
return;
|
|
27
|
-
const handleResize = () => {
|
|
28
|
-
setWindowSize({ width: window.innerWidth, height: window.innerHeight });
|
|
29
|
-
};
|
|
30
|
-
handleResize();
|
|
31
|
-
window.addEventListener("resize", handleResize);
|
|
32
|
-
return () => window.removeEventListener("resize", handleResize);
|
|
33
|
-
}, []);
|
|
34
|
-
return {
|
|
35
|
-
isXs: windowSize.width < 640,
|
|
36
|
-
isSm: windowSize.width < 768,
|
|
37
|
-
isMd: windowSize.width < 1024,
|
|
38
|
-
isLg: windowSize.width < 1280,
|
|
39
|
-
isXl: windowSize.width >= 1280,
|
|
40
|
-
isMobile: windowSize.width < 768,
|
|
41
|
-
isTablet: windowSize.width >= 768 && windowSize.width < 1024,
|
|
42
|
-
isDesktop: windowSize.width >= 1024,
|
|
43
|
-
width: windowSize.width,
|
|
44
|
-
height: windowSize.height,
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
// ==============================>
|
|
48
|
-
// ## Detect keyboard open
|
|
49
|
-
// ==============================>
|
|
50
|
-
export function useKeyboardOpen() {
|
|
51
|
-
const [isKeyboardOpen, setIsKeyboardOpen] = useState(false);
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
const handleResize = () => {
|
|
54
|
-
if (window.visualViewport) {
|
|
55
|
-
const viewportHeight = window.visualViewport.height;
|
|
56
|
-
const windowHeight = window.innerHeight;
|
|
57
|
-
setIsKeyboardOpen(viewportHeight < windowHeight);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
window.visualViewport?.addEventListener("resize", handleResize);
|
|
61
|
-
return () => window.visualViewport?.removeEventListener("resize", handleResize);
|
|
62
|
-
}, []);
|
|
63
|
-
return isKeyboardOpen;
|
|
64
|
-
}
|
|
65
|
-
// ==============================>
|
|
66
|
-
// ## Search with typing reference
|
|
67
|
-
// ==============================>
|
|
68
|
-
export const useLazySearch = (keyword) => {
|
|
69
|
-
const [keywordSearch, setKeywordSearch] = useState("");
|
|
70
|
-
const [doSearch, setDoSearch] = useState(false);
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (keyword != undefined) {
|
|
73
|
-
const delaySearch = setTimeout(() => setDoSearch(!doSearch), 500);
|
|
74
|
-
return () => clearTimeout(delaySearch);
|
|
75
|
-
}
|
|
76
|
-
}, [keyword]);
|
|
77
|
-
useEffect(() => setKeywordSearch(keyword), [doSearch]);
|
|
78
|
-
return [keywordSearch];
|
|
79
|
-
};
|
|
17
|
+
export * from "./commands/cli";
|
|
18
|
+
export * from "./hooks";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./resource";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./resource";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
|
-
import { useGetApi } from "
|
|
4
|
-
import { registry } from "
|
|
3
|
+
import { useGetApi } from "../api";
|
|
4
|
+
import { registry } from "../registry";
|
|
5
5
|
export function useResource(props) {
|
|
6
6
|
const isApi = "path" in props || "url" in props;
|
|
7
7
|
const apiResult = useGetApi(isApi ? props : {}, !isApi);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./shortcut";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./shortcut";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./table";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./table";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ApiFilterType, ApiParamsType } from "
|
|
2
|
-
import { ResourceParams, UseResourceProps } from "
|
|
1
|
+
import { ApiFilterType, ApiParamsType } from "../api";
|
|
2
|
+
import { ResourceParams, UseResourceProps } from "../resource";
|
|
3
3
|
export type TableStateType = {
|
|
4
4
|
params?: ApiParamsType;
|
|
5
5
|
data?: Record<string, any>[];
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { useRouter, useSearchParams } from "next/navigation";
|
|
4
4
|
import LZString from "lz-string";
|
|
5
|
-
import { conversion } from "
|
|
6
|
-
import { useResource } from "
|
|
5
|
+
import { conversion } from "../conversion";
|
|
6
|
+
import { useResource } from "../resource";
|
|
7
7
|
export const useTable = (fetchControl, id = "", title = "", urlParam) => {
|
|
8
8
|
const [state, setState] = useState({});
|
|
9
9
|
const router = useRouter();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./validation";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./validation";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import validator from "validator";
|
|
4
|
-
import { validationLangs } from "./langs";
|
|
4
|
+
import { validationLangs } from "./validation.langs";
|
|
5
5
|
// ==========================>
|
|
6
6
|
// ## Validation core
|
|
7
7
|
// ==========================>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skalfa/skalfa-app-core",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Core utility
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Core framework engine and foundational utility hook library for the Skalfa Next.js frontend.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"axios": "^1.12.0",
|
|
22
22
|
"clsx": "^2.1.1",
|
|
23
|
+
"commander": "^12.1.0",
|
|
23
24
|
"crypto-js": "^4.2.0",
|
|
24
25
|
"js-cookie": "^3.0.5",
|
|
25
26
|
"lz-string": "^1.5.0",
|
|
@@ -42,6 +43,6 @@
|
|
|
42
43
|
"next": "16.1.1",
|
|
43
44
|
"react": "^19.2.1",
|
|
44
45
|
"react-dom": "^19.2.1",
|
|
45
|
-
"typescript": "^
|
|
46
|
+
"typescript": "^6.0.3"
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/commands/barrels.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import { exec } from "child_process";
|
|
4
|
-
import { logger } from "./logger";
|
|
5
|
-
const rootDir = path.resolve();
|
|
6
|
-
const configText = fs.readFileSync("barrels.json", "utf8");
|
|
7
|
-
const config = JSON.parse(configText);
|
|
8
|
-
const directories = Array.isArray(config.directory) ? config.directory : [config.directory];
|
|
9
|
-
directories.forEach((dir) => {
|
|
10
|
-
const absoluteDir = path.join(rootDir, dir);
|
|
11
|
-
if (!fs.existsSync(absoluteDir)) {
|
|
12
|
-
logger.error(`Barrels error: ${absoluteDir} directory not found`);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
fs.watch(absoluteDir, { recursive: true }, (_, filename) => {
|
|
16
|
-
if (filename && (filename.endsWith(".ts") || filename.endsWith(".tsx")) && filename !== "index.ts") {
|
|
17
|
-
exec("npx barrelsby -c barrels.json", { cwd: rootDir });
|
|
18
|
-
logger.info("Barrels updated " + absoluteDir + "/index.ts");
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
logger.start("Barrels watched " + directories.join(", "));
|
package/dist/commands/light.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/commands/light.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { usePdf } from "./use-pdf";
|
|
3
|
-
import { blueprint } from "./blueprint";
|
|
4
|
-
import { logger } from "./logger";
|
|
5
|
-
const program = new Command();
|
|
6
|
-
program.name("light").description("Next Light CLI").version("1.0.0");
|
|
7
|
-
program.command("use-pdf").description("Copy pdf.worker.min.mjs ke folder public/").action(usePdf);
|
|
8
|
-
program.command("blueprint")
|
|
9
|
-
.option("-o, --only <names...>", "Run only specific blueprints")
|
|
10
|
-
.description("Generate blueprint")
|
|
11
|
-
.action(async (opts) => {
|
|
12
|
-
await blueprint({ only: opts.only });
|
|
13
|
-
logger.info("Success run all blueprints!");
|
|
14
|
-
process.exit(0);
|
|
15
|
-
});
|
|
16
|
-
program.parse();
|
package/dist/langs/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./validation.langs";
|
package/dist/langs/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./validation.langs";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|