@etdt/etdt-e-comps 0.0.0-stage → 1.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/LICENSE +21 -0
- package/README.md +130 -2
- package/dist/AuthContext.d.ts +33 -0
- package/dist/AuthContext.d.ts.map +1 -0
- package/dist/AuthContext.js +155 -0
- package/dist/PFooter.d.ts +15 -0
- package/dist/PFooter.d.ts.map +1 -0
- package/dist/PFooter.js +27 -0
- package/dist/PForm/PForm.d.ts +14 -0
- package/dist/PForm/PForm.d.ts.map +1 -0
- package/dist/PForm/PForm.js +47 -0
- package/dist/PForm/PForm.types.d.ts +34 -0
- package/dist/PForm/PForm.types.d.ts.map +1 -0
- package/dist/PForm/PForm.types.js +1 -0
- package/dist/PInput/PInput.d.ts +5 -0
- package/dist/PInput/PInput.d.ts.map +1 -0
- package/dist/PInput/PInput.js +50 -0
- package/dist/PInput/PInput.types.d.ts +24 -0
- package/dist/PInput/PInput.types.d.ts.map +1 -0
- package/dist/PInput/PInput.types.js +1 -0
- package/dist/PRecordList.d.ts +38 -0
- package/dist/PRecordList.d.ts.map +1 -0
- package/dist/PRecordList.js +12 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/package.json +59 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ETDT
|
|
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
CHANGED
|
@@ -1,3 +1,131 @@
|
|
|
1
|
-
#
|
|
1
|
+
# etdt-e-comps
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Instalar
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @etdt/etdt-e-comps
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Componentes
|
|
10
|
+
|
|
11
|
+
Componentes reutilizables para aplicaciones React con Ionic:
|
|
12
|
+
|
|
13
|
+
- `PForm`: formulario con campos Ionic y validación de `react-hook-form`.
|
|
14
|
+
- `PInput`: campo Ionic controlado por `react-hook-form`.
|
|
15
|
+
- `PFooter`: pie de página Ionic con texto opcional.
|
|
16
|
+
- `PRecordList`: lista de registros con acciones opcionales.
|
|
17
|
+
|
|
18
|
+
### Utilizar los componentes
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { PFooter, PForm, PInput, PRecordList } from '@etdt/etdt-e-comps';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
> La aplicación que utilice estos componentes debe tener instaladas las dependencias
|
|
25
|
+
peer declaradas en `package.json`.
|
|
26
|
+
|
|
27
|
+
## Contexto de autenticación (AuthContext.tsx)
|
|
28
|
+
|
|
29
|
+
Contexto de autenticación para compartir el estado del usuario y las operaciones de inicio y
|
|
30
|
+
cierre de sesión entre los componentes de la aplicación, delegando la comunicación con el
|
|
31
|
+
servidor en un adaptador configurable.
|
|
32
|
+
|
|
33
|
+
`createAuthContext<TUser, TLoginInput>(options)` crea un proveedor y un hook tipados.
|
|
34
|
+
`TUser` es el tipo del usuario y `TLoginInput` el tipo de los datos necesarios para iniciar
|
|
35
|
+
sesión.
|
|
36
|
+
|
|
37
|
+
El almacenamiento se configura mediante un objeto `AuthStorage` que permite proporcionar una
|
|
38
|
+
implementación propia de `getItem`, `setItem` y `removeItem` o con los siguientes `storage`:
|
|
39
|
+
|
|
40
|
+
- `local`: usa `localStorage`.
|
|
41
|
+
- `session`: usa `sessionStorage`.
|
|
42
|
+
- `memory`: usa un `Map` en memoria; los datos se pierden al recargar o cerrar la pestaña.
|
|
43
|
+
|
|
44
|
+
> Por defecto se tiene `storage: 'localStorage'` y `storageKey: 'user'`.
|
|
45
|
+
|
|
46
|
+
La autenticación se conecta mediante un `AuthAdapter<TUser, TLoginInput>`, que debe
|
|
47
|
+
implementar `login` y `logout`. Puede implementar también `restoreSession` para recuperar
|
|
48
|
+
la sesión al iniciar o cuando se llame a `refreshSession`. Por ejemplo, para una aplicación
|
|
49
|
+
que autentica mediante cookies:
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import {
|
|
53
|
+
createAuthContext,
|
|
54
|
+
type AuthAdapter,
|
|
55
|
+
} from '@etdt/etdt-e-comps';
|
|
56
|
+
|
|
57
|
+
interface User {
|
|
58
|
+
id: number;
|
|
59
|
+
name: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface LoginInput {
|
|
63
|
+
username: string;
|
|
64
|
+
password: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const authAdapter: AuthAdapter<User, LoginInput> = {
|
|
68
|
+
async login(input) {
|
|
69
|
+
const response = await fetch('/api/login', {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers: { 'Content-Type': 'application/json' },
|
|
72
|
+
credentials: 'include',
|
|
73
|
+
body: JSON.stringify(input),
|
|
74
|
+
});
|
|
75
|
+
if (!response.ok) {
|
|
76
|
+
throw new Error(`Login failed (${response.status})`);
|
|
77
|
+
}
|
|
78
|
+
return (await response.json()) as User;
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
async restoreSession() {
|
|
82
|
+
const response = await fetch('/api/get_user', {
|
|
83
|
+
credentials: 'include',
|
|
84
|
+
});
|
|
85
|
+
if (response.status === 401) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
if (!response.ok) {
|
|
89
|
+
throw new Error(`Session restore failed (${response.status})`);
|
|
90
|
+
}
|
|
91
|
+
return (await response.json()) as User;
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
async logout() {
|
|
95
|
+
const response = await fetch('/api/logout', {
|
|
96
|
+
method: 'POST',
|
|
97
|
+
credentials: 'include',
|
|
98
|
+
});
|
|
99
|
+
if (!response.ok) {
|
|
100
|
+
throw new Error(`Logout failed (${response.status})`);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const { AuthProvider, useAuth } = createAuthContext<User, LoginInput>({
|
|
106
|
+
storage: 'local',
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
const UserProvider = ({ children }: { children: React.ReactNode }) => (
|
|
111
|
+
<AuthProvider adapter={authAdapter}>{children}</AuthProvider>
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
export default UserProvider
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`restoreSession` devuelve el usuario si la sesión sigue activa o `null` si no lo está.
|
|
118
|
+
El ejemplo supone que `/api/get_user` responde directamente con el usuario y devuelve
|
|
119
|
+
HTTP 401 cuando no hay sesión; adapta el manejo de la respuesta al contrato de tu API.
|
|
120
|
+
El paquete no gestiona ni almacena el token o la cookie de sesión: eso corresponde a la
|
|
121
|
+
aplicación y al servidor.
|
|
122
|
+
|
|
123
|
+
El hook expone `user`, `isLoading`, `restoreError`, `login`, `logout`, `updateUser` y
|
|
124
|
+
`refreshSession`. `login` y `logout` delegan en el adaptador. `updateUser` combina los
|
|
125
|
+
cambios indicados con el usuario actual. `refreshSession` vuelve a llamar a
|
|
126
|
+
`adapter.restoreSession`; si no se ha proporcionado ese método, lanza un error. El hook
|
|
127
|
+
debe usarse dentro de su `AuthProvider`.
|
|
128
|
+
|
|
129
|
+
El usuario guardado se serializa como JSON y se parsea al leerlo. El paquete no valida la
|
|
130
|
+
forma de los datos leídos; valida la respuesta del servidor y cualquier dato almacenado si
|
|
131
|
+
no confías en su origen.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
export interface AuthAdapter<TUser, TLoginInput> {
|
|
3
|
+
login: (input: TLoginInput) => Promise<TUser>;
|
|
4
|
+
logout: () => Promise<void>;
|
|
5
|
+
restoreSession?: () => Promise<TUser | null>;
|
|
6
|
+
}
|
|
7
|
+
export interface AuthContextValue<TUser, TLoginInput> {
|
|
8
|
+
user: TUser | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
restoreError: unknown | null;
|
|
11
|
+
login: (input: TLoginInput) => Promise<void>;
|
|
12
|
+
logout: () => Promise<void>;
|
|
13
|
+
updateUser: (data: Partial<TUser>) => void;
|
|
14
|
+
refreshSession: () => Promise<TUser | null>;
|
|
15
|
+
}
|
|
16
|
+
export interface AuthStorage {
|
|
17
|
+
getItem: (key: string) => string | null;
|
|
18
|
+
setItem: (key: string, value: string) => void;
|
|
19
|
+
removeItem: (key: string) => void;
|
|
20
|
+
}
|
|
21
|
+
export interface AuthContextOptions {
|
|
22
|
+
storage?: 'local' | 'session' | 'memory' | AuthStorage;
|
|
23
|
+
storageKey?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface AuthProviderProps<TUser, TLoginInput> {
|
|
26
|
+
adapter: AuthAdapter<TUser, TLoginInput>;
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
export declare function createAuthContext<TUser, TLoginInput>(options?: AuthContextOptions): {
|
|
30
|
+
AuthProvider: ({ adapter, children, }: AuthProviderProps<TUser, TLoginInput>) => ReactElement;
|
|
31
|
+
useAuth: () => AuthContextValue<TUser, TLoginInput>;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=AuthContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../src/AuthContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,MAAM,WAAW,WAAW,CAAC,KAAK,EAAE,WAAW;IAC7C,KAAK,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,gBAAgB,CAAC,KAAK,EAAE,WAAW;IAClD,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,KAAK,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,UAAU,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC3C,cAAc,EAAE,MAAM,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACxC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB,CAAC,KAAK,EAAE,WAAW;IACnD,OAAO,EAAE,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACzC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAeD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAClD,OAAO,GAAE,kBAAuB;2CA8B7B,iBAAiB,CAAC,KAAK,EAAE,WAAW,CAAC,KAAG,YAAY;mBAqInC,gBAAgB,CAAC,KAAK,EAAE,WAAW,CAAC;EASzD"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useEffect, useRef, useState, } from 'react';
|
|
3
|
+
function createMemoryStorage() {
|
|
4
|
+
const values = new Map();
|
|
5
|
+
return {
|
|
6
|
+
getItem: (key) => values.get(key) ?? null,
|
|
7
|
+
setItem: (key, value) => {
|
|
8
|
+
values.set(key, value);
|
|
9
|
+
},
|
|
10
|
+
removeItem: (key) => {
|
|
11
|
+
values.delete(key);
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function createAuthContext(options = {}) {
|
|
16
|
+
const AuthContext = createContext(undefined);
|
|
17
|
+
const memoryStorage = createMemoryStorage();
|
|
18
|
+
const storageKey = options.storageKey ?? 'user';
|
|
19
|
+
const getStorage = () => {
|
|
20
|
+
if (typeof options.storage === 'object') {
|
|
21
|
+
return options.storage;
|
|
22
|
+
}
|
|
23
|
+
if (options.storage === 'memory') {
|
|
24
|
+
return memoryStorage;
|
|
25
|
+
}
|
|
26
|
+
if (typeof window === 'undefined') {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
if (options.storage === 'local') {
|
|
30
|
+
return window.localStorage;
|
|
31
|
+
}
|
|
32
|
+
if (options.storage === 'session') {
|
|
33
|
+
return window.sessionStorage;
|
|
34
|
+
}
|
|
35
|
+
return window.localStorage;
|
|
36
|
+
};
|
|
37
|
+
function AuthProvider({ adapter, children, }) {
|
|
38
|
+
const [user, setUser] = useState(() => {
|
|
39
|
+
const storage = getStorage();
|
|
40
|
+
if (!storage) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const storedUser = storage.getItem(storageKey);
|
|
45
|
+
return storedUser === null ? null : JSON.parse(storedUser);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
49
|
+
throw new Error(`Unable to read auth user from storage key "${storageKey}": ${detail}`);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const shouldRestoreSession = useRef(user === null);
|
|
53
|
+
const [isLoading, setIsLoading] = useState(adapter.restoreSession !== undefined && user === null);
|
|
54
|
+
const [restoreError, setRestoreError] = useState(null);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const storage = getStorage();
|
|
57
|
+
if (!storage) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
if (user === null) {
|
|
62
|
+
storage.removeItem(storageKey);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
storage.setItem(storageKey, JSON.stringify(user));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
70
|
+
throw new Error(`Unable to persist auth user to storage key "${storageKey}": ${detail}`);
|
|
71
|
+
}
|
|
72
|
+
}, [storageKey, user]);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
const restoreSession = adapter.restoreSession;
|
|
75
|
+
if (!restoreSession || !shouldRestoreSession.current) {
|
|
76
|
+
setIsLoading(false);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
let cancelled = false;
|
|
80
|
+
setIsLoading(true);
|
|
81
|
+
setRestoreError(null);
|
|
82
|
+
const restore = async () => {
|
|
83
|
+
try {
|
|
84
|
+
const restoredUser = await restoreSession();
|
|
85
|
+
if (!cancelled) {
|
|
86
|
+
setUser(restoredUser);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (!cancelled) {
|
|
91
|
+
setRestoreError(error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
if (!cancelled) {
|
|
96
|
+
setIsLoading(false);
|
|
97
|
+
shouldRestoreSession.current = false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
void restore();
|
|
102
|
+
return () => {
|
|
103
|
+
cancelled = true;
|
|
104
|
+
};
|
|
105
|
+
}, [adapter]);
|
|
106
|
+
const refreshSession = async () => {
|
|
107
|
+
if (!adapter.restoreSession) {
|
|
108
|
+
throw new Error('Refreshing the session requires a restoreSession adapter.');
|
|
109
|
+
}
|
|
110
|
+
setIsLoading(true);
|
|
111
|
+
setRestoreError(null);
|
|
112
|
+
try {
|
|
113
|
+
const restoredUser = await adapter.restoreSession();
|
|
114
|
+
setUser(restoredUser);
|
|
115
|
+
return restoredUser;
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
setRestoreError(error);
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
setIsLoading(false);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const login = async (input) => {
|
|
126
|
+
const authenticatedUser = await adapter.login(input);
|
|
127
|
+
setUser(authenticatedUser);
|
|
128
|
+
setRestoreError(null);
|
|
129
|
+
};
|
|
130
|
+
const logout = async () => {
|
|
131
|
+
await adapter.logout();
|
|
132
|
+
setUser(null);
|
|
133
|
+
};
|
|
134
|
+
const updateUser = (data) => {
|
|
135
|
+
setUser((currentUser) => currentUser === null ? null : { ...currentUser, ...data });
|
|
136
|
+
};
|
|
137
|
+
return (_jsx(AuthContext.Provider, { value: {
|
|
138
|
+
user,
|
|
139
|
+
isLoading,
|
|
140
|
+
restoreError,
|
|
141
|
+
login,
|
|
142
|
+
logout,
|
|
143
|
+
updateUser,
|
|
144
|
+
refreshSession,
|
|
145
|
+
}, children: children }));
|
|
146
|
+
}
|
|
147
|
+
function useAuth() {
|
|
148
|
+
const context = useContext(AuthContext);
|
|
149
|
+
if (!context) {
|
|
150
|
+
throw new Error('useAuth must be used within its AuthProvider');
|
|
151
|
+
}
|
|
152
|
+
return context;
|
|
153
|
+
}
|
|
154
|
+
return { AuthProvider, useAuth };
|
|
155
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Usage:
|
|
3
|
+
|
|
4
|
+
import PFooter from '../e_comps/PFooter'
|
|
5
|
+
|
|
6
|
+
<PFooter comp_name="Footer" footer_text={footer_text} color={color}/>
|
|
7
|
+
|
|
8
|
+
*/
|
|
9
|
+
interface PFooterProps {
|
|
10
|
+
footer_text?: string;
|
|
11
|
+
color?: string;
|
|
12
|
+
}
|
|
13
|
+
declare const PFooter: React.FC<PFooterProps>;
|
|
14
|
+
export default PFooter;
|
|
15
|
+
//# sourceMappingURL=PFooter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PFooter.d.ts","sourceRoot":"","sources":["../src/PFooter.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,UAAU,YAAY;IAEpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAG,MAAM,CAAA;CAGhB;AAGD,QAAA,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAyBnC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/dist/PFooter.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
Usage:
|
|
4
|
+
|
|
5
|
+
import PFooter from '../e_comps/PFooter'
|
|
6
|
+
|
|
7
|
+
<PFooter comp_name="Footer" footer_text={footer_text} color={color}/>
|
|
8
|
+
|
|
9
|
+
*/
|
|
10
|
+
// Ionic
|
|
11
|
+
import { IonFooter, IonToolbar } from '@ionic/react';
|
|
12
|
+
// Component
|
|
13
|
+
const PFooter = ({
|
|
14
|
+
// comp_name,
|
|
15
|
+
footer_text, color = "tertiary",
|
|
16
|
+
// test_h,
|
|
17
|
+
// test_click_h,
|
|
18
|
+
}) => {
|
|
19
|
+
// Could be undefined
|
|
20
|
+
// const on_click_h = test_h ? () => test_h ({comp_data:comp_name}) : undefined
|
|
21
|
+
// const on_test_click_h = test_click_h ? (e : React.MouseEvent<HTMLIonButtonElement, MouseEvent>) => test_click_h (e) : undefined
|
|
22
|
+
/** Part renders **/
|
|
23
|
+
// Small centered note
|
|
24
|
+
const opt_part = footer_text ? (_jsx("div", { className: "ion-padding ion-text-center", children: _jsx("small", { children: footer_text }) })) : null;
|
|
25
|
+
return (_jsx(IonFooter, { children: _jsx(IonToolbar, { color: color, children: opt_part }) }));
|
|
26
|
+
};
|
|
27
|
+
export default PFooter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Usage
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
Custom validation fn
|
|
7
|
+
- returns true or false
|
|
8
|
+
|
|
9
|
+
*/
|
|
10
|
+
import type { FC } from "react";
|
|
11
|
+
import type { PFormProps } from './PForm.types.js';
|
|
12
|
+
declare const PForm: FC<PFormProps>;
|
|
13
|
+
export default PForm;
|
|
14
|
+
//# sourceMappingURL=PForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PForm.d.ts","sourceRoot":"","sources":["../../src/PForm/PForm.tsx"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AA8B/B,OAAO,KAAK,EACV,UAAU,EACX,MAAM,kBAAkB,CAAC;AAG1B,QAAA,MAAM,KAAK,EAAE,EAAE,CAAC,UAAU,CAgIzB,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Hooks
|
|
3
|
+
import { useForm } from "react-hook-form";
|
|
4
|
+
// Ionic
|
|
5
|
+
import { IonContent, IonButton, IonTitle, IonItem, IonLabel, IonText, IonToolbar, IonButtons, IonIcon, } from '@ionic/react';
|
|
6
|
+
// Icons
|
|
7
|
+
import { chevronBackOutline } from 'ionicons/icons';
|
|
8
|
+
// Components
|
|
9
|
+
import PInput from '../PInput/PInput.js';
|
|
10
|
+
// Component
|
|
11
|
+
const PForm = ({ form_title, form_fields, fixed_fields, custom_validate_h, submit_handler, submit_btn_text = "Submit", submit_disabled, submit_btn_color = "secondary", on_back, pre_submit_btn, after_submit_content, debug = false }) => {
|
|
12
|
+
// react-hook-form
|
|
13
|
+
const { control, handleSubmit, getValues, formState: { errors, isValid }, } = useForm({
|
|
14
|
+
defaultValues: {}
|
|
15
|
+
});
|
|
16
|
+
// Customize onChange event - just log
|
|
17
|
+
const common_on_change = (e) => {
|
|
18
|
+
debug && console.debug(`common_on_change :: ${e.target.name} : ${e.target.value}`);
|
|
19
|
+
};
|
|
20
|
+
if (fixed_fields) {
|
|
21
|
+
debug && console.debug(`fixed_fields passed : `, fixed_fields);
|
|
22
|
+
}
|
|
23
|
+
// Could be more performant ?
|
|
24
|
+
const val_h = custom_validate_h && (() => {
|
|
25
|
+
if (custom_validate_h) {
|
|
26
|
+
const vals = getValues();
|
|
27
|
+
debug && console.debug("PForm : getValues: ", vals);
|
|
28
|
+
// Pass values down
|
|
29
|
+
return custom_validate_h(vals);
|
|
30
|
+
// Validate its actually a boolean ?
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
});
|
|
34
|
+
// console.og("Render : isValid :", isValid)
|
|
35
|
+
// debug bar
|
|
36
|
+
const debug_status = debug &&
|
|
37
|
+
_jsxs(IonText, { children: ["IsValid : ", `${isValid}`] });
|
|
38
|
+
const back_btn = on_back ? (_jsx(IonButtons, { slot: "start", children: _jsx(IonButton, { onClick: on_back, children: _jsx(IonIcon, { icon: chevronBackOutline }) }) })) : null;
|
|
39
|
+
return (_jsxs(IonContent, { children: [form_title &&
|
|
40
|
+
_jsxs(IonToolbar, { children: [back_btn, _jsx(IonTitle, { children: form_title })] }), _jsxs("form", { onSubmit: handleSubmit(submit_handler), style: { padding: "1em" }, children: [fixed_fields?.map((f, index) => {
|
|
41
|
+
debug && console.debug(`Fixed field`, f);
|
|
42
|
+
return (_jsxs(IonItem, { children: [_jsx(IonLabel, { position: "stacked", children: f.label }), _jsx(IonText, { className: "ion-padding-top ion-padding-bottom", children: f.fixed_value })] }, index));
|
|
43
|
+
}), form_fields.map((field, index) => {
|
|
44
|
+
return (_jsx(PInput, { input_name: field.name, ion_label: field.label, input_type: field.type, control: control, readonly: field.readonly ?? false, on_change_h: field.custom_on_change || common_on_change, init_value: field.init_value, validate_h: val_h, options: field.options, modal_title: field.modal_title, ion_input_props: field.ion_input_props }, index));
|
|
45
|
+
}), pre_submit_btn, _jsx(IonButton, { color: submit_btn_color, expand: "block", type: "submit", disabled: submit_disabled || !isValid, children: submit_btn_text }), after_submit_content, debug_status] })] }));
|
|
46
|
+
};
|
|
47
|
+
export default PForm;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { TextFieldTypes } from '@ionic/core';
|
|
3
|
+
import type { FieldValues, SubmitHandler } from 'react-hook-form';
|
|
4
|
+
import type { PInputOption } from '../PInput/PInput.types.js';
|
|
5
|
+
export interface PFormProps {
|
|
6
|
+
form_title?: string;
|
|
7
|
+
form_fields: PFormField[];
|
|
8
|
+
fixed_fields?: PFixedField[];
|
|
9
|
+
custom_validate_h?: (values: FieldValues) => boolean;
|
|
10
|
+
submit_handler: SubmitHandler<FieldValues>;
|
|
11
|
+
submit_btn_text?: string;
|
|
12
|
+
submit_disabled?: boolean;
|
|
13
|
+
submit_btn_color?: string;
|
|
14
|
+
on_back?: () => void;
|
|
15
|
+
pre_submit_btn?: ReactNode;
|
|
16
|
+
after_submit_content?: ReactNode;
|
|
17
|
+
debug?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface PFormField {
|
|
20
|
+
name: string;
|
|
21
|
+
type?: TextFieldTypes | 'select';
|
|
22
|
+
label: string;
|
|
23
|
+
init_value?: unknown;
|
|
24
|
+
readonly?: boolean;
|
|
25
|
+
options?: PInputOption[];
|
|
26
|
+
modal_title?: string;
|
|
27
|
+
custom_on_change?: (event: unknown) => void;
|
|
28
|
+
ion_input_props?: Object;
|
|
29
|
+
}
|
|
30
|
+
export interface PFixedField {
|
|
31
|
+
label: string;
|
|
32
|
+
fixed_value: ReactNode;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=PForm.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PForm.types.d.ts","sourceRoot":"","sources":["../../src/PForm/PForm.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D,MAAM,WAAW,UAAU;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,YAAY,CAAC,EAAE,WAAW,EAAE,CAAA;IAC5B,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAA;IACpD,cAAc,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;IAC1C,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,OAAO,CAAC,EAAG,MAAM,IAAI,CAAA;IACrB,cAAc,CAAC,EAAE,SAAS,CAAA;IAC1B,oBAAoB,CAAC,EAAE,SAAS,CAAA;IAChC,KAAK,CAAC,EAAG,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,cAAc,GAAG,QAAQ,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,SAAS,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PInput.d.ts","sourceRoot":"","sources":["../../src/PInput/PInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAkBhC,OAAO,KAAK,EACV,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAG3B,QAAA,MAAM,MAAM,EAAE,EAAE,CAAC,WAAW,CA0H3B,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import moment from 'moment';
|
|
3
|
+
// Hooks
|
|
4
|
+
import { Controller } from "react-hook-form";
|
|
5
|
+
// Ionic
|
|
6
|
+
import { IonItem, IonLabel, IonInput, IonSelect, IonIcon, IonBadge, IonSelectOption, } from '@ionic/react';
|
|
7
|
+
// Component
|
|
8
|
+
const PInput = ({ input_name, input_type, ion_label, init_value, readonly, options, control, on_change_h, validate_h, ion_input_props, modal_title, debug = false }) => {
|
|
9
|
+
debug && console.debug(`PInput - type : ${input_type}; label: ${ion_label};name : (${input_name}) : init: ${init_value}`);
|
|
10
|
+
// Example: Default date to today
|
|
11
|
+
let default_value;
|
|
12
|
+
if (input_type === 'date' && !init_value) {
|
|
13
|
+
default_value = moment().format('YYYY-MM-DD');
|
|
14
|
+
debug && console.debug(`Default date set : ${moment(default_value).format('YYYY-MM-DD')}`);
|
|
15
|
+
}
|
|
16
|
+
if (init_value) {
|
|
17
|
+
default_value = init_value;
|
|
18
|
+
debug && console.debug(`Init value present for ${input_name} :: ${init_value}`);
|
|
19
|
+
}
|
|
20
|
+
// Compare function for objects
|
|
21
|
+
const compareWith = (o1, o2) => {
|
|
22
|
+
return o1 && o2 ? o1.id === o2.id : o1 === o2;
|
|
23
|
+
};
|
|
24
|
+
return (_jsxs(IonItem, { children: [ion_label && (_jsx(IonLabel, { position: "stacked", children: ion_label })), _jsx(Controller, { name: input_name, control: control, defaultValue: default_value, rules: {
|
|
25
|
+
validate: validate_h
|
|
26
|
+
}, render: ({ field: { name, onChange, value } }) => {
|
|
27
|
+
// Render IonSelect...
|
|
28
|
+
if (input_type === 'select') {
|
|
29
|
+
// console.info ("Select options:", options)
|
|
30
|
+
// console.debug ("Value is here:", value) // Undefined
|
|
31
|
+
return (_jsx(IonSelect, { interface: "modal", name: name, placeholder: "Seleccionar", selectedText: value?.disp, interfaceOptions: { header: modal_title }, onIonChange: (e) => {
|
|
32
|
+
debug && console.debug("onIonChange select! ");
|
|
33
|
+
on_change_h(e);
|
|
34
|
+
onChange(e.detail.value); // h will return the event
|
|
35
|
+
}, compareWith: compareWith, value: value, children: options?.map((o, index) => (_jsxs(IonSelectOption, { value: o, children: [o.badge && _jsx(IonIcon, { color: "warning", icon: o.badge.icon, slot: "start" }), o.disp, o.badge && _jsx(IonBadge, { color: "warning", slot: "end", children: o.badge.title })] }, index))) }));
|
|
36
|
+
}
|
|
37
|
+
// Or render IonInput
|
|
38
|
+
else {
|
|
39
|
+
// console.log ("Rendering IonInput : ", input_type, name)
|
|
40
|
+
if (readonly) {
|
|
41
|
+
debug && console.debug("Got readonly!! ", readonly);
|
|
42
|
+
}
|
|
43
|
+
return (_jsx(IonInput, { ...ion_input_props, name: name, type: input_type, readonly: readonly, onIonInput: (e) => {
|
|
44
|
+
on_change_h?.(e);
|
|
45
|
+
onChange(e.detail.value);
|
|
46
|
+
}, value: value }));
|
|
47
|
+
}
|
|
48
|
+
} })] }));
|
|
49
|
+
};
|
|
50
|
+
export default PInput;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TextFieldTypes } from '@ionic/core';
|
|
2
|
+
import type { Control, FieldValues, Validate } from 'react-hook-form';
|
|
3
|
+
export interface PInputOption {
|
|
4
|
+
disp: string;
|
|
5
|
+
badge?: {
|
|
6
|
+
icon: string;
|
|
7
|
+
title: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface PInputProps {
|
|
11
|
+
input_name: string;
|
|
12
|
+
input_type?: TextFieldTypes | 'select';
|
|
13
|
+
ion_label?: string;
|
|
14
|
+
init_value?: unknown;
|
|
15
|
+
readonly?: boolean;
|
|
16
|
+
options?: PInputOption[];
|
|
17
|
+
control: Control<FieldValues>;
|
|
18
|
+
on_change_h: Function;
|
|
19
|
+
validate_h?: Validate<FieldValues, FieldValues>;
|
|
20
|
+
ion_input_props?: Object;
|
|
21
|
+
modal_title?: string;
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=PInput.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PInput.types.d.ts","sourceRoot":"","sources":["../../src/PInput/PInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEtE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,cAAc,GAAG,QAAQ,CAAA;IACtC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;IACxB,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAC7B,WAAW,EAAE,QAAQ,CAAA;IACrB,UAAU,CAAC,EAAE,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,CAAA;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
Basic "table"
|
|
4
|
+
|
|
5
|
+
IonList with Edit and Delete icons
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
|
|
9
|
+
import PRecordList from '../e_comps/PRecordList'
|
|
10
|
+
|
|
11
|
+
// Render:
|
|
12
|
+
|
|
13
|
+
<PRecordList
|
|
14
|
+
rec_array={rec_array}
|
|
15
|
+
list_name="Footer"
|
|
16
|
+
opt_prop={footer_text}/>
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
import type { FC, MouseEventHandler } from 'react';
|
|
20
|
+
export interface PRecordAction {
|
|
21
|
+
icon?: string;
|
|
22
|
+
click_h?: MouseEventHandler<HTMLIonButtonElement>;
|
|
23
|
+
}
|
|
24
|
+
export interface PRecord {
|
|
25
|
+
id?: string | number;
|
|
26
|
+
name: string;
|
|
27
|
+
note?: string;
|
|
28
|
+
icon?: string;
|
|
29
|
+
edit_params?: PRecordAction;
|
|
30
|
+
delete_params?: PRecordAction;
|
|
31
|
+
}
|
|
32
|
+
export interface PRecordListProps {
|
|
33
|
+
rec_array: PRecord[];
|
|
34
|
+
list_name?: string;
|
|
35
|
+
}
|
|
36
|
+
declare const PRecordList: FC<PRecordListProps>;
|
|
37
|
+
export default PRecordList;
|
|
38
|
+
//# sourceMappingURL=PRecordList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PRecordList.d.ts","sourceRoot":"","sources":["../src/PRecordList.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAgBnD,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA0CrC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Ionic
|
|
3
|
+
import { IonList, IonListHeader, IonItem, IonLabel, IonIcon, IonButton, IonButtons, } from '@ionic/react';
|
|
4
|
+
// Icons
|
|
5
|
+
import { closeCircleOutline } from 'ionicons/icons';
|
|
6
|
+
const PRecordList = ({ rec_array, list_name }) => {
|
|
7
|
+
if (rec_array.length === 0) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return (_jsxs(IonList, { children: [_jsx(IonListHeader, { color: "tertiary", lines: "full", children: list_name }), /* Records */ rec_array.map((r, key) => (_jsxs(IonItem, { children: [r.note && _jsx(IonLabel, { children: r.note }), _jsx(IonLabel, { children: r.name }), _jsxs(IonButtons, { slot: "end", children: [r.icon && (_jsx(IonIcon, { color: "secondary", size: "large", icon: r.icon })), r.edit_params && (_jsx(IonButton, { onClick: r.edit_params.click_h, children: _jsx(IonIcon, { color: "success", size: "large", icon: r.edit_params.icon }) })), r.delete_params && (_jsx(IonButton, { onClick: r.delete_params.click_h, children: _jsx(IonIcon, { color: "danger", size: "large", icon: closeCircleOutline }) }))] })] }, key)))] }));
|
|
11
|
+
};
|
|
12
|
+
export default PRecordList;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as PForm } from './PForm/PForm.js';
|
|
2
|
+
export type { PFixedField, PFormField, PFormProps, } from './PForm/PForm.types.js';
|
|
3
|
+
export { default as PInput } from './PInput/PInput.js';
|
|
4
|
+
export type { PInputOption, PInputProps, } from './PInput/PInput.types.js';
|
|
5
|
+
export { default as PFooter } from './PFooter.js';
|
|
6
|
+
export { default as PRecordList } from './PRecordList.js';
|
|
7
|
+
export type { PRecord, PRecordAction, PRecordListProps, } from './PRecordList.js';
|
|
8
|
+
export { createAuthContext } from './AuthContext.js';
|
|
9
|
+
export type { AuthAdapter, AuthContextValue, AuthContextOptions, AuthProviderProps, AuthStorage, } from './AuthContext.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EACV,WAAW,EACX,UAAU,EACV,UAAU,GACX,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,YAAY,EACV,OAAO,EACP,aAAa,EACb,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,GACZ,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as PForm } from './PForm/PForm.js';
|
|
2
|
+
export { default as PInput } from './PInput/PInput.js';
|
|
3
|
+
export { default as PFooter } from './PFooter.js';
|
|
4
|
+
export { default as PRecordList } from './PRecordList.js';
|
|
5
|
+
export { createAuthContext } from './AuthContext.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etdt/etdt-e-comps",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Reusable Ionic React form components",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"typescript",
|
|
8
|
+
"ionic"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://gitlab.com/etdt/etdt-e-comps#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://gitlab.com/etdt/etdt-e-comps/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+ssh://git@gitlab.com/etdt/etdt-e-comps.git"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "ETDT",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc --project tsconfig.json",
|
|
38
|
+
"prepack": "npm run build"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"moment": "^2.30.1",
|
|
42
|
+
"ionicons": "^7.0.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@capacitor/core": "^7.0.0",
|
|
46
|
+
"@ionic/react": "^9.0.0",
|
|
47
|
+
"react": "^18.2.0",
|
|
48
|
+
"react-dom": "^18.2.0",
|
|
49
|
+
"react-hook-form": "^7.53.2"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@capacitor/core": "^7.0.0",
|
|
53
|
+
"@ionic/react": "^9.0.0",
|
|
54
|
+
"@types/react": "^18.0.27",
|
|
55
|
+
"@types/react-dom": "^18.0.10",
|
|
56
|
+
"react": "^18.0.0",
|
|
57
|
+
"react-dom": "^18.0.0",
|
|
58
|
+
"react-hook-form": "^7.0.0",
|
|
59
|
+
"typescript": "^5.4.0"
|
|
60
|
+
}
|
|
61
|
+
}
|