eny-ai 1.0.0 → 2.0.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/V2_README.md +414 -0
- package/dist/chunk-2NUS77CI.js +195 -0
- package/dist/chunk-5KPALVCK.js +280 -0
- package/dist/{chunk-2WFUL4XJ.js → chunk-5PZUUNHS.js} +717 -751
- package/dist/{chunk-E4KJZEXX.js → chunk-AJH2I5ZI.js} +5 -0
- package/dist/chunk-LVJ3GJRQ.js +360 -0
- package/dist/{chunk-PNKVD2UK.js → chunk-MXA7TAAG.js} +11 -1
- package/dist/cli.js +5 -4
- package/dist/firebase.cjs +296 -0
- package/dist/firebase.d.cts +136 -0
- package/dist/firebase.d.ts +136 -0
- package/dist/firebase.js +17 -0
- package/dist/hooks.cjs +236 -0
- package/dist/hooks.d.cts +184 -0
- package/dist/hooks.d.ts +184 -0
- package/dist/hooks.js +31 -0
- package/dist/index.cjs +1622 -1092
- package/dist/index.d.cts +16 -195
- package/dist/index.d.ts +16 -195
- package/dist/index.js +68 -262
- package/dist/runtime.cjs +366 -0
- package/dist/runtime.d.cts +229 -0
- package/dist/runtime.d.ts +229 -0
- package/dist/runtime.js +25 -0
- package/dist/symbols.js +2 -2
- package/examples/app-simbolico-completo.tsx +249 -0
- package/examples/nextjs-integration.tsx +446 -0
- package/examples/v2-demo.tsx +377 -0
- package/package.json +23 -11
- package/dist/react/index.cjs +0 -342
- package/dist/react/index.d.cts +0 -751
- package/dist/react/index.d.ts +0 -751
- package/dist/react/index.js +0 -284
package/dist/hooks.cjs
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/react/hooks.tsx
|
|
31
|
+
var hooks_exports = {};
|
|
32
|
+
__export(hooks_exports, {
|
|
33
|
+
EnyContext: () => EnyContext,
|
|
34
|
+
EnyUI: () => EnyUI,
|
|
35
|
+
EnyValidate: () => EnyValidate,
|
|
36
|
+
useCallbackWithDeps: () => useCallbackWithDeps,
|
|
37
|
+
useEnyEffect: () => useEnyEffect,
|
|
38
|
+
useEnyFetch: () => useEnyFetch,
|
|
39
|
+
useEnyState: () => useEnyState,
|
|
40
|
+
useLogger: () => useLogger,
|
|
41
|
+
useMemoWithDeps: () => useMemoWithDeps,
|
|
42
|
+
useNavigation: () => useNavigation,
|
|
43
|
+
usePersistentState: () => usePersistentState,
|
|
44
|
+
useReducerWithState: () => useReducerWithState,
|
|
45
|
+
useValidation: () => useValidation
|
|
46
|
+
});
|
|
47
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
48
|
+
var import_react = __toESM(require("react"), 1);
|
|
49
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
50
|
+
function useEnyState(initialValue) {
|
|
51
|
+
const [value, setValue] = (0, import_react.useState)(initialValue);
|
|
52
|
+
return [value, setValue];
|
|
53
|
+
}
|
|
54
|
+
function useEnyEffect(effect, deps) {
|
|
55
|
+
(0, import_react.useEffect)(effect, deps);
|
|
56
|
+
}
|
|
57
|
+
function useEnyFetch(url) {
|
|
58
|
+
const [data, setData] = (0, import_react.useState)(null);
|
|
59
|
+
const [loading, setLoading] = (0, import_react.useState)(true);
|
|
60
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
61
|
+
(0, import_react.useEffect)(() => {
|
|
62
|
+
fetch(url).then((res) => res.json()).then((data2) => {
|
|
63
|
+
setData(data2);
|
|
64
|
+
setLoading(false);
|
|
65
|
+
}).catch((err) => {
|
|
66
|
+
setError(err);
|
|
67
|
+
setLoading(false);
|
|
68
|
+
});
|
|
69
|
+
}, [url]);
|
|
70
|
+
return [data, loading, error];
|
|
71
|
+
}
|
|
72
|
+
function usePersistentState(key, initialValue) {
|
|
73
|
+
const [value, setValue] = (0, import_react.useState)(() => {
|
|
74
|
+
const stored = localStorage.getItem(key);
|
|
75
|
+
return stored ? JSON.parse(stored) : initialValue;
|
|
76
|
+
});
|
|
77
|
+
const setPersistentValue = (0, import_react.useCallback)((newValue) => {
|
|
78
|
+
setValue(newValue);
|
|
79
|
+
localStorage.setItem(key, JSON.stringify(newValue));
|
|
80
|
+
}, [key]);
|
|
81
|
+
return [value, setPersistentValue];
|
|
82
|
+
}
|
|
83
|
+
function useMemoWithDeps(fn, deps) {
|
|
84
|
+
return (0, import_react.useMemo)(fn, deps);
|
|
85
|
+
}
|
|
86
|
+
function useCallbackWithDeps(fn, deps) {
|
|
87
|
+
return (0, import_react.useCallback)(fn, deps);
|
|
88
|
+
}
|
|
89
|
+
function useReducerWithState(reducer, initialState) {
|
|
90
|
+
return (0, import_react.useReducer)(reducer, initialState);
|
|
91
|
+
}
|
|
92
|
+
function useNavigation() {
|
|
93
|
+
return {
|
|
94
|
+
navigate: (path) => window.location.href = path,
|
|
95
|
+
back: () => window.history.back(),
|
|
96
|
+
forward: () => window.history.forward(),
|
|
97
|
+
reload: () => window.location.reload()
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function useLogger() {
|
|
101
|
+
return {
|
|
102
|
+
info: (msg, data) => console.log(`\u2139\uFE0F ${msg}`, data),
|
|
103
|
+
error: (msg, data) => console.error(`\u274C ${msg}`, data),
|
|
104
|
+
warn: (msg, data) => console.warn(`\u26A0\uFE0F ${msg}`, data)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
var EnyUI = {
|
|
108
|
+
/**
|
|
109
|
+
* EnyUI.card - Card component
|
|
110
|
+
*/
|
|
111
|
+
card: ({ children, className = "" }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `bg-white rounded-lg shadow-lg p-6 ${className}`, children }),
|
|
112
|
+
/**
|
|
113
|
+
* EnyUI.btn - Button component
|
|
114
|
+
*/
|
|
115
|
+
btn: ({
|
|
116
|
+
children,
|
|
117
|
+
onClick,
|
|
118
|
+
type = "primary",
|
|
119
|
+
className = ""
|
|
120
|
+
}) => {
|
|
121
|
+
const baseClass = "px-4 py-2 rounded-lg font-bold transition";
|
|
122
|
+
const typeClass = {
|
|
123
|
+
primary: "bg-blue-600 text-white hover:bg-blue-700",
|
|
124
|
+
danger: "bg-red-600 text-white hover:bg-red-700",
|
|
125
|
+
secondary: "bg-gray-300 text-black hover:bg-gray-400"
|
|
126
|
+
}[type];
|
|
127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: `${baseClass} ${typeClass} ${className}`, onClick, children });
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* EnyUI.input - Input component
|
|
131
|
+
*/
|
|
132
|
+
input: ({
|
|
133
|
+
value,
|
|
134
|
+
onChange,
|
|
135
|
+
placeholder = "",
|
|
136
|
+
type = "text",
|
|
137
|
+
className = ""
|
|
138
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
139
|
+
"input",
|
|
140
|
+
{
|
|
141
|
+
type,
|
|
142
|
+
value,
|
|
143
|
+
onChange: (e) => onChange(e.target.value),
|
|
144
|
+
placeholder,
|
|
145
|
+
className: `w-full px-4 py-2 border rounded-lg focus:outline-none focus:border-blue-600 ${className}`
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
/**
|
|
149
|
+
* EnyUI.grid - Grid component
|
|
150
|
+
*/
|
|
151
|
+
grid: ({ children, cols = 1, className = "" }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `grid grid-cols-${cols} gap-4 ${className}`, children }),
|
|
152
|
+
/**
|
|
153
|
+
* EnyUI.flex - Flexbox component
|
|
154
|
+
*/
|
|
155
|
+
flex: ({ children, className = "" }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `flex ${className}`, children }),
|
|
156
|
+
/**
|
|
157
|
+
* EnyUI.text - Text component
|
|
158
|
+
*/
|
|
159
|
+
text: ({ children, size = "base", className = "" }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: `text-${size} ${className}`, children }),
|
|
160
|
+
/**
|
|
161
|
+
* EnyUI.heading - Heading component
|
|
162
|
+
*/
|
|
163
|
+
h1: ({ children, className = "" }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: `text-4xl font-bold ${className}`, children }),
|
|
164
|
+
h2: ({ children, className = "" }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: `text-3xl font-bold ${className}`, children }),
|
|
165
|
+
h3: ({ children, className = "" }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: `text-2xl font-bold ${className}`, children }),
|
|
166
|
+
/**
|
|
167
|
+
* EnyUI.modal - Modal component
|
|
168
|
+
*/
|
|
169
|
+
modal: ({
|
|
170
|
+
isOpen,
|
|
171
|
+
onClose,
|
|
172
|
+
children,
|
|
173
|
+
title = ""
|
|
174
|
+
}) => {
|
|
175
|
+
if (!isOpen) return null;
|
|
176
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "bg-white rounded-lg p-8 max-w-md w-full", children: [
|
|
177
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "text-2xl font-bold mb-4", children: title }),
|
|
178
|
+
children,
|
|
179
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
180
|
+
"button",
|
|
181
|
+
{
|
|
182
|
+
onClick: onClose,
|
|
183
|
+
className: "mt-4 w-full bg-gray-300 text-black py-2 rounded-lg hover:bg-gray-400",
|
|
184
|
+
children: "Fechar"
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
] }) });
|
|
188
|
+
},
|
|
189
|
+
/**
|
|
190
|
+
* EnyUI.spinner - Loading spinner
|
|
191
|
+
*/
|
|
192
|
+
spinner: ({ className = "" } = {}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `animate-spin inline-block w-6 h-6 border-4 border-blue-600 border-t-transparent rounded-full ${className}` }),
|
|
193
|
+
/**
|
|
194
|
+
* EnyUI.badge - Badge component
|
|
195
|
+
*/
|
|
196
|
+
badge: ({ children, color = "blue", className = "" }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `px-3 py-1 rounded-full text-white bg-${color}-600 ${className}`, children })
|
|
197
|
+
};
|
|
198
|
+
var EnyContext = {
|
|
199
|
+
create: (initialValue) => import_react.default.createContext(initialValue),
|
|
200
|
+
use: (context) => (0, import_react.useContext)(context)
|
|
201
|
+
};
|
|
202
|
+
var EnyValidate = {
|
|
203
|
+
email: (str) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(str),
|
|
204
|
+
min: (len) => (str) => str.length >= len,
|
|
205
|
+
max: (len) => (str) => str.length <= len,
|
|
206
|
+
required: (val) => val != null && val !== "",
|
|
207
|
+
pattern: (regex) => (val) => regex.test(val),
|
|
208
|
+
equals: (expected) => (val) => val === expected
|
|
209
|
+
};
|
|
210
|
+
function useValidation(schema) {
|
|
211
|
+
return (data) => {
|
|
212
|
+
const errors = {};
|
|
213
|
+
for (const [key, validator] of Object.entries(schema)) {
|
|
214
|
+
if (!validator(data[key])) {
|
|
215
|
+
errors[key] = true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return errors;
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
222
|
+
0 && (module.exports = {
|
|
223
|
+
EnyContext,
|
|
224
|
+
EnyUI,
|
|
225
|
+
EnyValidate,
|
|
226
|
+
useCallbackWithDeps,
|
|
227
|
+
useEnyEffect,
|
|
228
|
+
useEnyFetch,
|
|
229
|
+
useEnyState,
|
|
230
|
+
useLogger,
|
|
231
|
+
useMemoWithDeps,
|
|
232
|
+
useNavigation,
|
|
233
|
+
usePersistentState,
|
|
234
|
+
useReducerWithState,
|
|
235
|
+
useValidation
|
|
236
|
+
});
|
package/dist/hooks.d.cts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* useEnyState - useState com sintaxe simplificada
|
|
6
|
+
* const [count, setCount] = useEnyState(0)
|
|
7
|
+
* Alias: Σ(initialValue)
|
|
8
|
+
*/
|
|
9
|
+
declare function useEnyState<T>(initialValue: T): [T, (value: T) => void];
|
|
10
|
+
/**
|
|
11
|
+
* useEnyEffect - useEffect com sintaxe simplificada
|
|
12
|
+
* useEnyEffect(() => { ... }, [deps])
|
|
13
|
+
* Alias: ⚡(effect, deps)
|
|
14
|
+
*/
|
|
15
|
+
declare function useEnyEffect(effect: () => void | (() => void), deps?: React.DependencyList): void;
|
|
16
|
+
/**
|
|
17
|
+
* useEnyFetch - useFetch/async data
|
|
18
|
+
* const [data, loading] = useEnyFetch(url)
|
|
19
|
+
* Alias: ⇄(url)
|
|
20
|
+
*/
|
|
21
|
+
declare function useEnyFetch<T>(url: string): [T | null, boolean, Error | null];
|
|
22
|
+
/**
|
|
23
|
+
* usePersistentState - useState com localStorage
|
|
24
|
+
* const [value, setValue] = usePersistentState('key', defaultValue)
|
|
25
|
+
* Alias: 𝓜('key', defaultValue)
|
|
26
|
+
*/
|
|
27
|
+
declare function usePersistentState<T>(key: string, initialValue: T): [T, (value: T) => void];
|
|
28
|
+
/**
|
|
29
|
+
* useMemoWithDeps - useMemo com sintaxe simplificada
|
|
30
|
+
* useMemoWithDeps(() => complexCalc(), [deps])
|
|
31
|
+
* Alias: λ+(() => complexCalc(), [deps])
|
|
32
|
+
*/
|
|
33
|
+
declare function useMemoWithDeps<T>(fn: () => T, deps: React.DependencyList): T;
|
|
34
|
+
/**
|
|
35
|
+
* useCallbackWithDeps - useCallback com sintaxe simplificada
|
|
36
|
+
* useCallbackWithDeps((args) => {...}, [deps])
|
|
37
|
+
* Alias: λ⇄((args) => {...}, [deps])
|
|
38
|
+
*/
|
|
39
|
+
declare function useCallbackWithDeps<T extends (...args: any[]) => any>(fn: T, deps: React.DependencyList): T;
|
|
40
|
+
/**
|
|
41
|
+
* useReducerWithState - useReducer com sintaxe simbólica
|
|
42
|
+
* Alias: ⇅(reducer, initialState)
|
|
43
|
+
*/
|
|
44
|
+
declare function useReducerWithState<S, A>(reducer: (state: S, action: A) => S, initialState: S): [S, React.Dispatch<A>];
|
|
45
|
+
/**
|
|
46
|
+
* useNavigation - Navigation hook
|
|
47
|
+
* Alias: 🧭()
|
|
48
|
+
*/
|
|
49
|
+
declare function useNavigation(): {
|
|
50
|
+
navigate: (path: string) => string;
|
|
51
|
+
back: () => void;
|
|
52
|
+
forward: () => void;
|
|
53
|
+
reload: () => void;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* useLogger - Console logging hook
|
|
57
|
+
* Alias: 📜()
|
|
58
|
+
*/
|
|
59
|
+
declare function useLogger(): {
|
|
60
|
+
info: (msg: string, data?: any) => void;
|
|
61
|
+
error: (msg: string, data?: any) => void;
|
|
62
|
+
warn: (msg: string, data?: any) => void;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* EnyUI - Componente base com sintaxe simbólica
|
|
66
|
+
* EnyUI.card, EnyUI.btn, EnyUI.input, etc
|
|
67
|
+
* Alias: ☐
|
|
68
|
+
*/
|
|
69
|
+
declare const EnyUI: {
|
|
70
|
+
/**
|
|
71
|
+
* EnyUI.card - Card component
|
|
72
|
+
*/
|
|
73
|
+
card: ({ children, className }: {
|
|
74
|
+
children: React.ReactNode;
|
|
75
|
+
className?: string;
|
|
76
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
77
|
+
/**
|
|
78
|
+
* EnyUI.btn - Button component
|
|
79
|
+
*/
|
|
80
|
+
btn: ({ children, onClick, type, className }: {
|
|
81
|
+
children: React.ReactNode;
|
|
82
|
+
onClick?: () => void;
|
|
83
|
+
type?: "primary" | "danger" | "secondary";
|
|
84
|
+
className?: string;
|
|
85
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
86
|
+
/**
|
|
87
|
+
* EnyUI.input - Input component
|
|
88
|
+
*/
|
|
89
|
+
input: ({ value, onChange, placeholder, type, className }: {
|
|
90
|
+
value: any;
|
|
91
|
+
onChange: (value: any) => void;
|
|
92
|
+
placeholder?: string;
|
|
93
|
+
type?: string;
|
|
94
|
+
className?: string;
|
|
95
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
96
|
+
/**
|
|
97
|
+
* EnyUI.grid - Grid component
|
|
98
|
+
*/
|
|
99
|
+
grid: ({ children, cols, className }: {
|
|
100
|
+
children: React.ReactNode;
|
|
101
|
+
cols?: number;
|
|
102
|
+
className?: string;
|
|
103
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
104
|
+
/**
|
|
105
|
+
* EnyUI.flex - Flexbox component
|
|
106
|
+
*/
|
|
107
|
+
flex: ({ children, className }: {
|
|
108
|
+
children: React.ReactNode;
|
|
109
|
+
className?: string;
|
|
110
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
111
|
+
/**
|
|
112
|
+
* EnyUI.text - Text component
|
|
113
|
+
*/
|
|
114
|
+
text: ({ children, size, className }: {
|
|
115
|
+
children: React.ReactNode;
|
|
116
|
+
size?: string;
|
|
117
|
+
className?: string;
|
|
118
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
119
|
+
/**
|
|
120
|
+
* EnyUI.heading - Heading component
|
|
121
|
+
*/
|
|
122
|
+
h1: ({ children, className }: {
|
|
123
|
+
children: React.ReactNode;
|
|
124
|
+
className?: string;
|
|
125
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
126
|
+
h2: ({ children, className }: {
|
|
127
|
+
children: React.ReactNode;
|
|
128
|
+
className?: string;
|
|
129
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
130
|
+
h3: ({ children, className }: {
|
|
131
|
+
children: React.ReactNode;
|
|
132
|
+
className?: string;
|
|
133
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
134
|
+
/**
|
|
135
|
+
* EnyUI.modal - Modal component
|
|
136
|
+
*/
|
|
137
|
+
modal: ({ isOpen, onClose, children, title }: {
|
|
138
|
+
isOpen: boolean;
|
|
139
|
+
onClose: () => void;
|
|
140
|
+
children: React.ReactNode;
|
|
141
|
+
title?: string;
|
|
142
|
+
}) => react_jsx_runtime.JSX.Element | null;
|
|
143
|
+
/**
|
|
144
|
+
* EnyUI.spinner - Loading spinner
|
|
145
|
+
*/
|
|
146
|
+
spinner: ({ className }?: {
|
|
147
|
+
className?: string;
|
|
148
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
149
|
+
/**
|
|
150
|
+
* EnyUI.badge - Badge component
|
|
151
|
+
*/
|
|
152
|
+
badge: ({ children, color, className }: {
|
|
153
|
+
children: React.ReactNode;
|
|
154
|
+
color?: string;
|
|
155
|
+
className?: string;
|
|
156
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* EnyContext - useContext com sintaxe simplificada
|
|
160
|
+
* Alias: Σ●
|
|
161
|
+
*/
|
|
162
|
+
declare const EnyContext: {
|
|
163
|
+
create: (initialValue: any) => React.Context<any>;
|
|
164
|
+
use: (context: React.Context<any>) => any;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* EnyValidate - Validação helpers
|
|
168
|
+
* Alias: 🛡
|
|
169
|
+
*/
|
|
170
|
+
declare const EnyValidate: {
|
|
171
|
+
email: (str: string) => boolean;
|
|
172
|
+
min: (len: number) => (str: string) => boolean;
|
|
173
|
+
max: (len: number) => (str: string) => boolean;
|
|
174
|
+
required: (val: any) => boolean;
|
|
175
|
+
pattern: (regex: RegExp) => (val: string) => boolean;
|
|
176
|
+
equals: (expected: any) => (val: any) => boolean;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* useValidation - Hook de validação simbólica
|
|
180
|
+
* Alias: 🛡⁻(schema)
|
|
181
|
+
*/
|
|
182
|
+
declare function useValidation(schema: Record<string, (val: any) => boolean>): (data: Record<string, any>) => Record<string, boolean>;
|
|
183
|
+
|
|
184
|
+
export { EnyContext, EnyUI, EnyValidate, useCallbackWithDeps, useEnyEffect, useEnyFetch, useEnyState, useLogger, useMemoWithDeps, useNavigation, usePersistentState, useReducerWithState, useValidation };
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* useEnyState - useState com sintaxe simplificada
|
|
6
|
+
* const [count, setCount] = useEnyState(0)
|
|
7
|
+
* Alias: Σ(initialValue)
|
|
8
|
+
*/
|
|
9
|
+
declare function useEnyState<T>(initialValue: T): [T, (value: T) => void];
|
|
10
|
+
/**
|
|
11
|
+
* useEnyEffect - useEffect com sintaxe simplificada
|
|
12
|
+
* useEnyEffect(() => { ... }, [deps])
|
|
13
|
+
* Alias: ⚡(effect, deps)
|
|
14
|
+
*/
|
|
15
|
+
declare function useEnyEffect(effect: () => void | (() => void), deps?: React.DependencyList): void;
|
|
16
|
+
/**
|
|
17
|
+
* useEnyFetch - useFetch/async data
|
|
18
|
+
* const [data, loading] = useEnyFetch(url)
|
|
19
|
+
* Alias: ⇄(url)
|
|
20
|
+
*/
|
|
21
|
+
declare function useEnyFetch<T>(url: string): [T | null, boolean, Error | null];
|
|
22
|
+
/**
|
|
23
|
+
* usePersistentState - useState com localStorage
|
|
24
|
+
* const [value, setValue] = usePersistentState('key', defaultValue)
|
|
25
|
+
* Alias: 𝓜('key', defaultValue)
|
|
26
|
+
*/
|
|
27
|
+
declare function usePersistentState<T>(key: string, initialValue: T): [T, (value: T) => void];
|
|
28
|
+
/**
|
|
29
|
+
* useMemoWithDeps - useMemo com sintaxe simplificada
|
|
30
|
+
* useMemoWithDeps(() => complexCalc(), [deps])
|
|
31
|
+
* Alias: λ+(() => complexCalc(), [deps])
|
|
32
|
+
*/
|
|
33
|
+
declare function useMemoWithDeps<T>(fn: () => T, deps: React.DependencyList): T;
|
|
34
|
+
/**
|
|
35
|
+
* useCallbackWithDeps - useCallback com sintaxe simplificada
|
|
36
|
+
* useCallbackWithDeps((args) => {...}, [deps])
|
|
37
|
+
* Alias: λ⇄((args) => {...}, [deps])
|
|
38
|
+
*/
|
|
39
|
+
declare function useCallbackWithDeps<T extends (...args: any[]) => any>(fn: T, deps: React.DependencyList): T;
|
|
40
|
+
/**
|
|
41
|
+
* useReducerWithState - useReducer com sintaxe simbólica
|
|
42
|
+
* Alias: ⇅(reducer, initialState)
|
|
43
|
+
*/
|
|
44
|
+
declare function useReducerWithState<S, A>(reducer: (state: S, action: A) => S, initialState: S): [S, React.Dispatch<A>];
|
|
45
|
+
/**
|
|
46
|
+
* useNavigation - Navigation hook
|
|
47
|
+
* Alias: 🧭()
|
|
48
|
+
*/
|
|
49
|
+
declare function useNavigation(): {
|
|
50
|
+
navigate: (path: string) => string;
|
|
51
|
+
back: () => void;
|
|
52
|
+
forward: () => void;
|
|
53
|
+
reload: () => void;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* useLogger - Console logging hook
|
|
57
|
+
* Alias: 📜()
|
|
58
|
+
*/
|
|
59
|
+
declare function useLogger(): {
|
|
60
|
+
info: (msg: string, data?: any) => void;
|
|
61
|
+
error: (msg: string, data?: any) => void;
|
|
62
|
+
warn: (msg: string, data?: any) => void;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* EnyUI - Componente base com sintaxe simbólica
|
|
66
|
+
* EnyUI.card, EnyUI.btn, EnyUI.input, etc
|
|
67
|
+
* Alias: ☐
|
|
68
|
+
*/
|
|
69
|
+
declare const EnyUI: {
|
|
70
|
+
/**
|
|
71
|
+
* EnyUI.card - Card component
|
|
72
|
+
*/
|
|
73
|
+
card: ({ children, className }: {
|
|
74
|
+
children: React.ReactNode;
|
|
75
|
+
className?: string;
|
|
76
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
77
|
+
/**
|
|
78
|
+
* EnyUI.btn - Button component
|
|
79
|
+
*/
|
|
80
|
+
btn: ({ children, onClick, type, className }: {
|
|
81
|
+
children: React.ReactNode;
|
|
82
|
+
onClick?: () => void;
|
|
83
|
+
type?: "primary" | "danger" | "secondary";
|
|
84
|
+
className?: string;
|
|
85
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
86
|
+
/**
|
|
87
|
+
* EnyUI.input - Input component
|
|
88
|
+
*/
|
|
89
|
+
input: ({ value, onChange, placeholder, type, className }: {
|
|
90
|
+
value: any;
|
|
91
|
+
onChange: (value: any) => void;
|
|
92
|
+
placeholder?: string;
|
|
93
|
+
type?: string;
|
|
94
|
+
className?: string;
|
|
95
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
96
|
+
/**
|
|
97
|
+
* EnyUI.grid - Grid component
|
|
98
|
+
*/
|
|
99
|
+
grid: ({ children, cols, className }: {
|
|
100
|
+
children: React.ReactNode;
|
|
101
|
+
cols?: number;
|
|
102
|
+
className?: string;
|
|
103
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
104
|
+
/**
|
|
105
|
+
* EnyUI.flex - Flexbox component
|
|
106
|
+
*/
|
|
107
|
+
flex: ({ children, className }: {
|
|
108
|
+
children: React.ReactNode;
|
|
109
|
+
className?: string;
|
|
110
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
111
|
+
/**
|
|
112
|
+
* EnyUI.text - Text component
|
|
113
|
+
*/
|
|
114
|
+
text: ({ children, size, className }: {
|
|
115
|
+
children: React.ReactNode;
|
|
116
|
+
size?: string;
|
|
117
|
+
className?: string;
|
|
118
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
119
|
+
/**
|
|
120
|
+
* EnyUI.heading - Heading component
|
|
121
|
+
*/
|
|
122
|
+
h1: ({ children, className }: {
|
|
123
|
+
children: React.ReactNode;
|
|
124
|
+
className?: string;
|
|
125
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
126
|
+
h2: ({ children, className }: {
|
|
127
|
+
children: React.ReactNode;
|
|
128
|
+
className?: string;
|
|
129
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
130
|
+
h3: ({ children, className }: {
|
|
131
|
+
children: React.ReactNode;
|
|
132
|
+
className?: string;
|
|
133
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
134
|
+
/**
|
|
135
|
+
* EnyUI.modal - Modal component
|
|
136
|
+
*/
|
|
137
|
+
modal: ({ isOpen, onClose, children, title }: {
|
|
138
|
+
isOpen: boolean;
|
|
139
|
+
onClose: () => void;
|
|
140
|
+
children: React.ReactNode;
|
|
141
|
+
title?: string;
|
|
142
|
+
}) => react_jsx_runtime.JSX.Element | null;
|
|
143
|
+
/**
|
|
144
|
+
* EnyUI.spinner - Loading spinner
|
|
145
|
+
*/
|
|
146
|
+
spinner: ({ className }?: {
|
|
147
|
+
className?: string;
|
|
148
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
149
|
+
/**
|
|
150
|
+
* EnyUI.badge - Badge component
|
|
151
|
+
*/
|
|
152
|
+
badge: ({ children, color, className }: {
|
|
153
|
+
children: React.ReactNode;
|
|
154
|
+
color?: string;
|
|
155
|
+
className?: string;
|
|
156
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* EnyContext - useContext com sintaxe simplificada
|
|
160
|
+
* Alias: Σ●
|
|
161
|
+
*/
|
|
162
|
+
declare const EnyContext: {
|
|
163
|
+
create: (initialValue: any) => React.Context<any>;
|
|
164
|
+
use: (context: React.Context<any>) => any;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* EnyValidate - Validação helpers
|
|
168
|
+
* Alias: 🛡
|
|
169
|
+
*/
|
|
170
|
+
declare const EnyValidate: {
|
|
171
|
+
email: (str: string) => boolean;
|
|
172
|
+
min: (len: number) => (str: string) => boolean;
|
|
173
|
+
max: (len: number) => (str: string) => boolean;
|
|
174
|
+
required: (val: any) => boolean;
|
|
175
|
+
pattern: (regex: RegExp) => (val: string) => boolean;
|
|
176
|
+
equals: (expected: any) => (val: any) => boolean;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* useValidation - Hook de validação simbólica
|
|
180
|
+
* Alias: 🛡⁻(schema)
|
|
181
|
+
*/
|
|
182
|
+
declare function useValidation(schema: Record<string, (val: any) => boolean>): (data: Record<string, any>) => Record<string, boolean>;
|
|
183
|
+
|
|
184
|
+
export { EnyContext, EnyUI, EnyValidate, useCallbackWithDeps, useEnyEffect, useEnyFetch, useEnyState, useLogger, useMemoWithDeps, useNavigation, usePersistentState, useReducerWithState, useValidation };
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EnyContext,
|
|
3
|
+
EnyUI,
|
|
4
|
+
EnyValidate,
|
|
5
|
+
useCallbackWithDeps,
|
|
6
|
+
useEnyEffect,
|
|
7
|
+
useEnyFetch,
|
|
8
|
+
useEnyState,
|
|
9
|
+
useLogger,
|
|
10
|
+
useMemoWithDeps,
|
|
11
|
+
useNavigation,
|
|
12
|
+
usePersistentState,
|
|
13
|
+
useReducerWithState,
|
|
14
|
+
useValidation
|
|
15
|
+
} from "./chunk-2NUS77CI.js";
|
|
16
|
+
import "./chunk-MXA7TAAG.js";
|
|
17
|
+
export {
|
|
18
|
+
EnyContext,
|
|
19
|
+
EnyUI,
|
|
20
|
+
EnyValidate,
|
|
21
|
+
useCallbackWithDeps,
|
|
22
|
+
useEnyEffect,
|
|
23
|
+
useEnyFetch,
|
|
24
|
+
useEnyState,
|
|
25
|
+
useLogger,
|
|
26
|
+
useMemoWithDeps,
|
|
27
|
+
useNavigation,
|
|
28
|
+
usePersistentState,
|
|
29
|
+
useReducerWithState,
|
|
30
|
+
useValidation
|
|
31
|
+
};
|