@apia/util 0.0.7 → 0.0.9-alpha.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/dist/index.d.ts +752 -0
- package/dist/index.js +75 -2
- package/entries.json +1 -0
- package/package.json +4 -27
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,752 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { EffectCallback, Dispatch, SetStateAction, MutableRefObject, DependencyList } from 'react';
|
|
3
|
+
|
|
4
|
+
declare function arrayOrArray<T>(o: T | T[]): T[];
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This function gets an array of elements of any kind and an array of
|
|
8
|
+
* functions which will be called to test conditions and will return element
|
|
9
|
+
* whose index equals the matching condition's index
|
|
10
|
+
*
|
|
11
|
+
* @param arr An array of elements of any kind
|
|
12
|
+
* @param conditions An array of conditions, which will be tested in order to determine which index of the array will be returned
|
|
13
|
+
* @param defaultIndex The return value in case that no condition matches
|
|
14
|
+
* @returns An element of the array if any of the conditions matches or the defaultIndex otherwise
|
|
15
|
+
*/
|
|
16
|
+
declare function getIndex<T = unknown>(arr: T[], conditions: (boolean | (() => boolean))[], defaultIndex?: number): T;
|
|
17
|
+
|
|
18
|
+
declare const decrypt: (salt: string, iv: string, passPhrase: string, cipherText: string, keySize: number, iterationCount: number) => string;
|
|
19
|
+
|
|
20
|
+
declare const encrypt: (salt: string, iv: string, passPhrase: string, plainText: string, keySize: number, iterationCount: number) => string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Indica si el debugDispatcher fue activado, lo que en muchos casos indica que
|
|
24
|
+
* estamos en ambiente de desarrollo
|
|
25
|
+
*/
|
|
26
|
+
declare function isDebugDispatcherEnabled(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* El debug dispatcher solamente debería activarse en modo desarrollo. Este
|
|
29
|
+
* control solamente puede hacerse desde la aplicación principal, por ello, para
|
|
30
|
+
* activar el debugDispatcher se exporta este método que debe llamarse cuando
|
|
31
|
+
* sea correcto.
|
|
32
|
+
*/
|
|
33
|
+
declare function enableDebugDispatcher(): void;
|
|
34
|
+
type TWindowDDispatch = (action: string, ...parameters: unknown[]) => void;
|
|
35
|
+
type TDispatchCallback = (parameters: unknown[]) => unknown;
|
|
36
|
+
interface IStoredCallback {
|
|
37
|
+
(parameters: unknown[]): unknown;
|
|
38
|
+
help: () => void;
|
|
39
|
+
}
|
|
40
|
+
declare const debugDispatcher: {
|
|
41
|
+
callbacks: Record<string, IStoredCallback[]>;
|
|
42
|
+
actions: Record<string, () => void>;
|
|
43
|
+
on(action: string, cb: TDispatchCallback, help: string | React__default.ReactNode, onlyDevelop?: boolean): () => void;
|
|
44
|
+
off(action: string, cb: TDispatchCallback): void;
|
|
45
|
+
emit: TWindowDDispatch;
|
|
46
|
+
};
|
|
47
|
+
declare global {
|
|
48
|
+
interface Window {
|
|
49
|
+
adt: typeof debugDispatcher;
|
|
50
|
+
dd: typeof debugDispatcher & Record<string, () => unknown>;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type TCallback = (ev: KeyboardEvent) => unknown;
|
|
55
|
+
type TKey = {
|
|
56
|
+
key: string;
|
|
57
|
+
altKey?: boolean;
|
|
58
|
+
ctrlKey?: boolean;
|
|
59
|
+
shiftKey?: boolean;
|
|
60
|
+
};
|
|
61
|
+
type TShortcutBranch = {
|
|
62
|
+
key: TKey;
|
|
63
|
+
children: TShortcutBranch[];
|
|
64
|
+
callbacks: TCallback[];
|
|
65
|
+
fireEvenFromInputs?: boolean;
|
|
66
|
+
};
|
|
67
|
+
declare const shortcutController: {
|
|
68
|
+
history: TKey[];
|
|
69
|
+
candidates: TShortcutBranch[];
|
|
70
|
+
shortcuts: TShortcutBranch;
|
|
71
|
+
shortcutsStrings: string[];
|
|
72
|
+
categories: {
|
|
73
|
+
dev: string[];
|
|
74
|
+
};
|
|
75
|
+
parseKeyToString(key: string | TKey): string;
|
|
76
|
+
parseKey(keyString: string): TKey;
|
|
77
|
+
/**
|
|
78
|
+
* Para setear un shorcut se puede pasar un string representativo con la
|
|
79
|
+
* forma:
|
|
80
|
+
*
|
|
81
|
+
* **alt**?&**ctrl**?&**shift**?&**(\w)**
|
|
82
|
+
*
|
|
83
|
+
* Donde: alt? ctrl? shift? implica que cualquiera de esas palabras pueden o
|
|
84
|
+
* no aparecer y (\w) es una letra, símbolo o número.
|
|
85
|
+
*
|
|
86
|
+
* Puede aparecer cualquier tecla de control o no, pero el símbolo o letra
|
|
87
|
+
* debe aparecer.
|
|
88
|
+
*
|
|
89
|
+
* @param category
|
|
90
|
+
* Agrega un prefijo de teclas que se deben presionar antes del shortcut para
|
|
91
|
+
* que funcione, de forma que por ejemplo, todos los shortcuts de la categoría
|
|
92
|
+
* dev serán ejecutados solamente si antes se presionó shift&D
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
*
|
|
96
|
+
shortcutController.on(['shift&A', 'b', 'ctrl&c', 'alt&d'], (ev) => {
|
|
97
|
+
ev.preventDefault();
|
|
98
|
+
console.log('Abctrl+cd'),
|
|
99
|
+
}); // Este shortcut se ejecuta en desarrollo y producción
|
|
100
|
+
|
|
101
|
+
shortcutController.on('unshortcut'.split(''), (ev) => {
|
|
102
|
+
ev.preventDefault();
|
|
103
|
+
console.log('Abctrl+cd'),
|
|
104
|
+
}, 'dev'); // Este shortcut solo se ejecuta en desarrollo
|
|
105
|
+
*/
|
|
106
|
+
on(keys: (string | TKey)[], callback: TCallback, category?: keyof typeof this$1.categories, fireEvenFromInputs?: boolean): void;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
declare function apiaDateToStandarFormat(date: string): string;
|
|
110
|
+
|
|
111
|
+
declare function dateToApiaFormat(date: string | Date): string;
|
|
112
|
+
|
|
113
|
+
type TDateFormat = 'DD/MM/YYYY' | 'MM/DD/YYYY' | 'YYYY/MM/DD';
|
|
114
|
+
|
|
115
|
+
declare const getDateFormat: () => TDateFormat;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Existen algunos eventos que se disparan en la
|
|
119
|
+
* aplicación con la finalidad de desencadenar
|
|
120
|
+
* un comportamiento específico. Por ello se declaran
|
|
121
|
+
* las siguientes constantes.
|
|
122
|
+
*/
|
|
123
|
+
declare const customEvents: {
|
|
124
|
+
/**
|
|
125
|
+
* Indica que un elemento necesita recibir el foco,
|
|
126
|
+
* de esta forma, elementos que no se están mostrando
|
|
127
|
+
* en pantalla (por display:none por ejemplo), pueden
|
|
128
|
+
* indicar a sus ancestros que deben expandirse.
|
|
129
|
+
*/
|
|
130
|
+
focus: string;
|
|
131
|
+
/**
|
|
132
|
+
* Indica que debe cambiarse el título del modal
|
|
133
|
+
*/
|
|
134
|
+
iframeModalChangeTitle: string;
|
|
135
|
+
/**
|
|
136
|
+
* Indica que un iframe modal debe cerrarse
|
|
137
|
+
*/
|
|
138
|
+
iframeModalClose: string;
|
|
139
|
+
/**
|
|
140
|
+
* Indica que un iframe modal debe cerrarse
|
|
141
|
+
*/
|
|
142
|
+
iframeModalNotify: string;
|
|
143
|
+
/**
|
|
144
|
+
* Indica que un modal debe cerrarse
|
|
145
|
+
*/
|
|
146
|
+
modalClose: string;
|
|
147
|
+
/**
|
|
148
|
+
* Indica que el panel contenedor debe cerrarse porque
|
|
149
|
+
* está vacío
|
|
150
|
+
*/
|
|
151
|
+
hidePanel: string;
|
|
152
|
+
showPanel: string;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Este selector pretende abarcar todos modificadores que en caso de estar
|
|
157
|
+
* presentes hacen que un elemento no sea focusable
|
|
158
|
+
*/
|
|
159
|
+
declare const cantFocusSelector: string;
|
|
160
|
+
/**
|
|
161
|
+
* Este selector pretende abarcar todos los elementos que sean focusables
|
|
162
|
+
*/
|
|
163
|
+
declare const focusSelector: string;
|
|
164
|
+
/**
|
|
165
|
+
* Genera un selector que permitirá seleccionar
|
|
166
|
+
* todos los elementos candidatos a recibir foco,
|
|
167
|
+
* que no cumplan con la condición not pasada
|
|
168
|
+
* como parámetro.
|
|
169
|
+
*
|
|
170
|
+
* @param not Un selector not css, indicando cuáles
|
|
171
|
+
* condiciones deben evitar el foco en un elemento.
|
|
172
|
+
*
|
|
173
|
+
* @returns Una cadena que representa un selector
|
|
174
|
+
* css.
|
|
175
|
+
*/
|
|
176
|
+
declare function getFocusSelector(not?: string): string;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Searches for a specific parent of a element,
|
|
180
|
+
* using a callback function as the source of
|
|
181
|
+
* truth in order to determine which is the correct
|
|
182
|
+
* parent.
|
|
183
|
+
*
|
|
184
|
+
* @param element The element where the process
|
|
185
|
+
* starts.
|
|
186
|
+
*
|
|
187
|
+
* @param checkParent A callback that will be
|
|
188
|
+
* called for each of the ancestors of the element
|
|
189
|
+
* until the desired parent is found.
|
|
190
|
+
* This function should return **true when found**
|
|
191
|
+
* the desired parend was found, **null to cancel**
|
|
192
|
+
* the search or **false to continue searching**.
|
|
193
|
+
*
|
|
194
|
+
* @returns The specific parent or null in case
|
|
195
|
+
* the root parent element is raised.
|
|
196
|
+
*/
|
|
197
|
+
declare function getSpecificParent(element: HTMLElement | null, checkParent: (parent: HTMLElement) => boolean | null): HTMLElement | null;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Permite iterar desde un elemento hacia arriba en el
|
|
201
|
+
* DOM, utilizando una función de comparación para
|
|
202
|
+
* determinar si el elemento actual es el que estamos
|
|
203
|
+
* buscando.
|
|
204
|
+
*
|
|
205
|
+
* Si la función checkParent devuelve true, isChild
|
|
206
|
+
* devuelve true.
|
|
207
|
+
*/
|
|
208
|
+
declare function isChild(element: HTMLElement | null, checkParent: (parent: HTMLElement) => boolean | null): boolean;
|
|
209
|
+
|
|
210
|
+
type TEventMap = Record<string, any>;
|
|
211
|
+
type TEventKey<T extends TEventMap> = string & keyof T;
|
|
212
|
+
type TEventReceiver<T> = (params: T) => unknown;
|
|
213
|
+
type TFun = () => unknown;
|
|
214
|
+
interface IEmitter<T extends TEventMap> {
|
|
215
|
+
on<K extends TEventKey<T>>(eventName: K, fn: TEventReceiver<T[K]>): TFun;
|
|
216
|
+
off<K extends TEventKey<T>>(eventName: K, fn: TEventReceiver<T[K]>): unknown;
|
|
217
|
+
emit<K extends TEventKey<T>>(eventName: K, params?: T[K]): unknown;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* EXISTE UN EVENT EMITTER EN npm QUE ES MANTENIDO POR LA COMUNIDAD
|
|
221
|
+
*
|
|
222
|
+
* Se decidió mantener éste ya que al momento de tomar la decisión, ofrecía
|
|
223
|
+
* un tipeado más sólido (aunque usted no lo crea).
|
|
224
|
+
*
|
|
225
|
+
* Su funcionamiento es muy sencillo, se instancia la clase EventEmitter
|
|
226
|
+
* pasándole como tipo un objeto que contenga la definición de los eventos y
|
|
227
|
+
* el tipo del valor entregado por cada evento. Luego es posible llamar
|
|
228
|
+
* a los métodos on y off de la instancia para ser notificado de un suceso
|
|
229
|
+
* o al método emit para notificar a los suscriptores.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
*
|
|
233
|
+
* const clicksAnnouncer = new EventEmitter<{ clicks: number }>();
|
|
234
|
+
*
|
|
235
|
+
* let clicks = 0;
|
|
236
|
+
* document.addEventListener('click', ()=> {
|
|
237
|
+
* const clicksAmmount = ++clicks;
|
|
238
|
+
* clicksAnnouncer.emit('clicks', clicksAmmount);
|
|
239
|
+
* })
|
|
240
|
+
*
|
|
241
|
+
* clicksAnnouncer.on('clicks', (clicksAmmount) =>
|
|
242
|
+
* console.log(`Se han realizado ${clicksAmmount} clicks.`));
|
|
243
|
+
*/
|
|
244
|
+
declare class EventEmitter<T extends TEventMap> implements IEmitter<T> {
|
|
245
|
+
#private;
|
|
246
|
+
on<K extends TEventKey<T>>(eventName: K, fn: TEventReceiver<T[K]>): () => void;
|
|
247
|
+
off<K extends TEventKey<T>>(eventName: K, fn: TEventReceiver<T[K]>): void;
|
|
248
|
+
emit<K extends TEventKey<T>>(eventName: K, params?: T[K]): void;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Esta clase ofrece la posibilidad de crear una variable que al ser
|
|
253
|
+
* actualizada avisa sobre la actualización.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* const name = new WithEventsValue<string>('Alexis Leite');
|
|
257
|
+
*
|
|
258
|
+
* name.on('update', (newName) => console.log(`El nuevo nombre es ${newName}`));
|
|
259
|
+
*
|
|
260
|
+
* name.value = 'Joel'; // logs "El nuevo nombre es Joel"
|
|
261
|
+
*/
|
|
262
|
+
declare class WithEventsValue<T> extends EventEmitter<{
|
|
263
|
+
update: T | undefined;
|
|
264
|
+
}> {
|
|
265
|
+
#private;
|
|
266
|
+
constructor(value?: T);
|
|
267
|
+
get value(): T | undefined;
|
|
268
|
+
set value(value: T | undefined);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Permite reasignar múltiples referencias desde un mismo componente.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
*
|
|
276
|
+
* const ref1 = useRef(null)
|
|
277
|
+
* const ref2 = useRef(null)
|
|
278
|
+
*
|
|
279
|
+
* const assignRefs = useMultipleRefs(ref1, ref2);
|
|
280
|
+
*
|
|
281
|
+
* return <Box ref={assignRefs} ...
|
|
282
|
+
*/
|
|
283
|
+
declare function useCombinedRefs<RefType = HTMLInputElement>(...refs: (React.ForwardedRef<unknown> | undefined)[]): React.Dispatch<React.SetStateAction<RefType | undefined>>;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Devuelve una referencia que mantiene siempre el último valor del elemento
|
|
287
|
+
* pasado, es especialmente útil para acceder a valores del componente desde
|
|
288
|
+
* dentro de efectos.
|
|
289
|
+
*
|
|
290
|
+
* *Investigar qué es 'react stale state'*
|
|
291
|
+
*/
|
|
292
|
+
declare function useLatest<T>(value: T): React.MutableRefObject<T>;
|
|
293
|
+
|
|
294
|
+
declare function useMount(effect: EffectCallback): void;
|
|
295
|
+
|
|
296
|
+
declare function useUnmount(unmountCallback: () => void): void;
|
|
297
|
+
|
|
298
|
+
declare function usePrevious<T>(value: T): React.MutableRefObject<T | undefined>;
|
|
299
|
+
|
|
300
|
+
declare function useStateRef<T>(initialState: T): [T, Dispatch<SetStateAction<T>>, MutableRefObject<T>];
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Este hook se comporta igual que useEffect, con la diferencia de que en el
|
|
304
|
+
* primer renderizado no se va a ejecutar.
|
|
305
|
+
*/
|
|
306
|
+
declare function useUpdateEffect(effect: EffectCallback, deps?: DependencyList): void;
|
|
307
|
+
|
|
308
|
+
declare global {
|
|
309
|
+
interface Window {
|
|
310
|
+
[key: string]: string;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Dado un nombre de etiqueta, devuelve el texto que esa etiqueta contiene en
|
|
315
|
+
* el idioma actual. En este momento, lo único que hace realmente esta función
|
|
316
|
+
* es devolver la variable del window con el mismo nombre que se está pidiendo.
|
|
317
|
+
*
|
|
318
|
+
* La idea de implementar esta función, es que en un futuro la fuente de la que
|
|
319
|
+
* provienen las labels pueda ser más diversa.
|
|
320
|
+
*/
|
|
321
|
+
declare function getLabel(name: string): string;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Da formato a un mensaje con tokens incrustados.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
*
|
|
328
|
+
* // Dado el siguiente mensaje:
|
|
329
|
+
* var msg = 'El campo <TOK1> es inválido.';
|
|
330
|
+
*
|
|
331
|
+
* console.log(formatMessage(msg, {
|
|
332
|
+
* TOK1: 'nombre',
|
|
333
|
+
* }));
|
|
334
|
+
* // Imprime: El campo nombre es inválido.
|
|
335
|
+
*/
|
|
336
|
+
declare const formatMessage: (str: string, obj: {
|
|
337
|
+
[key: string]: string;
|
|
338
|
+
}) => string;
|
|
339
|
+
|
|
340
|
+
interface ISetBoundary {
|
|
341
|
+
number?: number | string;
|
|
342
|
+
min?: number;
|
|
343
|
+
max?: number;
|
|
344
|
+
loop?: boolean;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Añade límites a un número, impidiendo que sea
|
|
348
|
+
* inferior o superior a los límites establecidos.
|
|
349
|
+
*
|
|
350
|
+
* Si se pasa loop en true, al llegar al valor maximo o minimo regresara al
|
|
351
|
+
* minimo o maximo respectivamente.
|
|
352
|
+
*/
|
|
353
|
+
declare function addBoundary(num: number, min: number, max?: number, loop?: boolean): number;
|
|
354
|
+
declare function addBoundary(definition: ISetBoundary): number;
|
|
355
|
+
/**
|
|
356
|
+
* Esta función acepta un número y devuelve la representaciíon
|
|
357
|
+
* en string de su tamaño en disco. Ej: 1024 => 1kb
|
|
358
|
+
*/
|
|
359
|
+
declare function parseAsSize(num: number): string;
|
|
360
|
+
/**
|
|
361
|
+
* Toma cualquier valor y devuelve siempre un número. En caso de que el valor
|
|
362
|
+
* casteado con la función Number(value) de NaN, devuelve defaultReturn, que por
|
|
363
|
+
* defecto es 0
|
|
364
|
+
*/
|
|
365
|
+
declare function noNaN(number: unknown, defaultReturn?: number): number;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Este método itera sobre un objeto hasta encontrar la ruta especificada
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
*
|
|
372
|
+
const obj = {
|
|
373
|
+
a: {
|
|
374
|
+
b: {
|
|
375
|
+
c: {
|
|
376
|
+
d: "d"
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
console.log(getValueByPath(obj,'a.b.c')) // { d: 'd' }
|
|
383
|
+
console.log(getValueByPath(obj,'a.b.c.d')) // 'd'
|
|
384
|
+
*
|
|
385
|
+
*/
|
|
386
|
+
declare function getValueByPath(obj: Record<string, unknown>, path: string | string[], separator?: string): unknown;
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Permite escribir una propiedad en un objeto, en una ruta especificada. Si
|
|
390
|
+
* dicha ruta no existe dentro del objeto la crea, siempre que sea posible. No
|
|
391
|
+
* será posible en caso de que alguno de los elementos de la ruta contenga una
|
|
392
|
+
* propiedad que no sea de tipo objeto.
|
|
393
|
+
*
|
|
394
|
+
* @param obj El objeto donde se desea escribir la propiedad
|
|
395
|
+
* @param path La ruta en la que se va a escribir
|
|
396
|
+
* @param value El valor que se va a escribir en la ruta especificada
|
|
397
|
+
* @returns Un objeto idéntico del recibido pero co nlos cambios aplicados
|
|
398
|
+
*
|
|
399
|
+
* @throws { Error } En caso de que la ruta especificada contenga algún elemento que no puede ser escrito.
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
*
|
|
403
|
+
* const a = {
|
|
404
|
+
* a: {}
|
|
405
|
+
* };
|
|
406
|
+
*
|
|
407
|
+
* setValueByPath(a, 'a.b.c', 'Hello world');
|
|
408
|
+
* /* Outputs:
|
|
409
|
+
* {
|
|
410
|
+
* a: {
|
|
411
|
+
* b: {
|
|
412
|
+
* c: 'Hello world'
|
|
413
|
+
* }
|
|
414
|
+
* }
|
|
415
|
+
* }
|
|
416
|
+
*/
|
|
417
|
+
declare function setValueByPath(obj: Record<string, unknown>, path: string, value: unknown): Record<string, unknown> | null;
|
|
418
|
+
|
|
419
|
+
declare const persistentStorage: {
|
|
420
|
+
[key: string]: unknown;
|
|
421
|
+
remove(prop: string): unknown;
|
|
422
|
+
};
|
|
423
|
+
declare global {
|
|
424
|
+
interface Window {
|
|
425
|
+
persistentStorage: typeof persistentStorage;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Toma un valor y devuelve true o false según las
|
|
431
|
+
* siguientes condiciones:
|
|
432
|
+
*
|
|
433
|
+
* Si es string, ['',
|
|
434
|
+
* 'false'].includes(value.toLowerCase()) => false, todo lo
|
|
435
|
+
* demás => true.
|
|
436
|
+
*
|
|
437
|
+
* Si es array, [] => false, [...] => true.
|
|
438
|
+
*
|
|
439
|
+
* Todo lo demás !!value
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
*
|
|
443
|
+
* toBoolean('true') // true
|
|
444
|
+
* toBoolean('TrUE') // true
|
|
445
|
+
* toBoolean('FAlSe') // false
|
|
446
|
+
* toBoolean(0) // false
|
|
447
|
+
* toBoolean(1) // true
|
|
448
|
+
* toBoolean([0]) // true
|
|
449
|
+
* toBoolean([]) // false
|
|
450
|
+
*/
|
|
451
|
+
declare function toBoolean(value: unknown): boolean;
|
|
452
|
+
|
|
453
|
+
interface TFncParams {
|
|
454
|
+
type: 'V' | 'P' | 'E';
|
|
455
|
+
value?: string;
|
|
456
|
+
attId?: number;
|
|
457
|
+
}
|
|
458
|
+
type TApiaFormButton = {
|
|
459
|
+
onclick: string;
|
|
460
|
+
text: string;
|
|
461
|
+
id: string;
|
|
462
|
+
type: string;
|
|
463
|
+
};
|
|
464
|
+
interface TApiaSelectPossibleValue {
|
|
465
|
+
value: string | number;
|
|
466
|
+
label: string;
|
|
467
|
+
selected?: boolean;
|
|
468
|
+
}
|
|
469
|
+
interface TApiaMultiplePossibleValue {
|
|
470
|
+
value: string | number;
|
|
471
|
+
label: string;
|
|
472
|
+
selected?: boolean;
|
|
473
|
+
}
|
|
474
|
+
interface TApiaRadioPossibleValue {
|
|
475
|
+
value: string | number;
|
|
476
|
+
label: string;
|
|
477
|
+
selected?: boolean;
|
|
478
|
+
}
|
|
479
|
+
type TApiaPossibleValue = TApiaRadioPossibleValue & TApiaMultiplePossibleValue & TApiaSelectPossibleValue;
|
|
480
|
+
type TFieldEvent = 'onLoad' | 'onReload' | 'onSubmit' | 'onChange' | 'onModalReturn' | 'onClick' | 'onPopulate' | 'populate' | 'gridAdd' | 'gridSort' | 'gridSortUp' | 'gridSortDown' | 'gridDelete' | 'gridColumnSelect' | 'JSApiaUpdate' | 'onSubmit';
|
|
481
|
+
interface TFieldScriptEvent {
|
|
482
|
+
fncName: string;
|
|
483
|
+
evtName: Readonly<TFieldEvent>;
|
|
484
|
+
evtId: number | string;
|
|
485
|
+
fncParams: TFncParams[];
|
|
486
|
+
}
|
|
487
|
+
type TFieldScriptEvents = TFieldScriptEvent[];
|
|
488
|
+
interface TFieldServerEvent {
|
|
489
|
+
evtId: number;
|
|
490
|
+
evtName: Readonly<TFieldEvent>;
|
|
491
|
+
isAjax: boolean;
|
|
492
|
+
}
|
|
493
|
+
type TFieldServerEvents = TFieldServerEvent[];
|
|
494
|
+
interface TApiaFieldPropsObj {
|
|
495
|
+
alignment?: string;
|
|
496
|
+
alt?: string;
|
|
497
|
+
bold?: string;
|
|
498
|
+
checked?: boolean;
|
|
499
|
+
colspan?: number;
|
|
500
|
+
cssClass?: string;
|
|
501
|
+
disabled?: boolean;
|
|
502
|
+
docType?: string;
|
|
503
|
+
dontBreakRadio?: boolean;
|
|
504
|
+
fontColor?: string;
|
|
505
|
+
gridHeight?: number;
|
|
506
|
+
gridColTitle?: string;
|
|
507
|
+
gridTitle?: string;
|
|
508
|
+
height?: string;
|
|
509
|
+
hideAddButton?: boolean;
|
|
510
|
+
hideDelButton?: boolean;
|
|
511
|
+
hideDocMetadata?: boolean;
|
|
512
|
+
hideDocPermissions?: boolean;
|
|
513
|
+
hideGridButtons?: boolean;
|
|
514
|
+
hideIncludeButton?: boolean;
|
|
515
|
+
hideOrderButton?: boolean;
|
|
516
|
+
hideSignButtons?: boolean;
|
|
517
|
+
pagedGridSize?: number;
|
|
518
|
+
paged?: boolean;
|
|
519
|
+
includeFirstRow?: boolean;
|
|
520
|
+
imageUrl?: string;
|
|
521
|
+
inputAsText?: boolean;
|
|
522
|
+
isActuallyReadonly?: boolean;
|
|
523
|
+
multiselect?: boolean;
|
|
524
|
+
name?: string;
|
|
525
|
+
noPrint?: boolean;
|
|
526
|
+
readonly?: boolean;
|
|
527
|
+
readOnly?: boolean;
|
|
528
|
+
regExpMessage?: string;
|
|
529
|
+
reqSign?: boolean;
|
|
530
|
+
reqTrad?: boolean;
|
|
531
|
+
required?: boolean;
|
|
532
|
+
rowspan?: number;
|
|
533
|
+
selParent?: boolean;
|
|
534
|
+
size?: string;
|
|
535
|
+
storeMdlQryResult?: boolean;
|
|
536
|
+
tooltip?: string;
|
|
537
|
+
tooltipHelp?: boolean;
|
|
538
|
+
transient?: boolean;
|
|
539
|
+
underlined?: boolean;
|
|
540
|
+
url?: string;
|
|
541
|
+
value?: unknown;
|
|
542
|
+
updateValueWithoutSynchronize?: unknown;
|
|
543
|
+
valueColor?: string;
|
|
544
|
+
visibilityHidden?: boolean;
|
|
545
|
+
possibleValue?: TApiaSelectPossibleValue[] | TApiaSelectPossibleValue | TApiaRadioPossibleValue[] | TApiaMultiplePossibleValue[] | TApiaMultiplePossibleValue;
|
|
546
|
+
leafIcon?: string;
|
|
547
|
+
parentIcon?: string;
|
|
548
|
+
props?: string;
|
|
549
|
+
id?: string;
|
|
550
|
+
noLock?: boolean;
|
|
551
|
+
noErase?: boolean;
|
|
552
|
+
noModify?: boolean;
|
|
553
|
+
noDownload?: boolean;
|
|
554
|
+
allowEdition?: boolean;
|
|
555
|
+
hideDocDownload?: boolean;
|
|
556
|
+
qryId?: string;
|
|
557
|
+
startIndex?: number;
|
|
558
|
+
curPage?: number;
|
|
559
|
+
pages?: number;
|
|
560
|
+
rowCount?: number;
|
|
561
|
+
maxRecords?: number;
|
|
562
|
+
colWidth?: string;
|
|
563
|
+
gridForm?: string;
|
|
564
|
+
documentMonitorCus?: number;
|
|
565
|
+
fileCollapseFldStrc?: boolean;
|
|
566
|
+
fileCollapseMetadata?: boolean;
|
|
567
|
+
fileCollapsePermission?: boolean;
|
|
568
|
+
fileDefFolder?: number;
|
|
569
|
+
fileDntShwDocMdlOnDrop?: boolean;
|
|
570
|
+
fileExpDate?: boolean;
|
|
571
|
+
fileNoAllwDnD?: boolean;
|
|
572
|
+
fileNotShowDocMon?: boolean;
|
|
573
|
+
fileShowDesc?: boolean;
|
|
574
|
+
fileShwFoldTreeBtn?: boolean;
|
|
575
|
+
fileShwFoldTreeStr?: boolean;
|
|
576
|
+
oneClickUpload?: boolean;
|
|
577
|
+
fieldId?: string;
|
|
578
|
+
hasFinishedLoading?: boolean;
|
|
579
|
+
}
|
|
580
|
+
type TApiaFormElementOption = {
|
|
581
|
+
label: string;
|
|
582
|
+
value: string;
|
|
583
|
+
};
|
|
584
|
+
type TApiaFormElement = {
|
|
585
|
+
class: string;
|
|
586
|
+
disabled: boolean;
|
|
587
|
+
html: boolean;
|
|
588
|
+
id: string;
|
|
589
|
+
mandatory: boolean;
|
|
590
|
+
maxlength?: string;
|
|
591
|
+
modalFunction?: string;
|
|
592
|
+
name: string;
|
|
593
|
+
normalWhiteSpace: boolean;
|
|
594
|
+
onChange: string;
|
|
595
|
+
options: {
|
|
596
|
+
option: TApiaFormElementOption | TApiaFormElementOption[];
|
|
597
|
+
};
|
|
598
|
+
readonly: boolean;
|
|
599
|
+
regExp?: string;
|
|
600
|
+
regExpMessage?: string;
|
|
601
|
+
selected: boolean;
|
|
602
|
+
size: string;
|
|
603
|
+
text: string;
|
|
604
|
+
title: string;
|
|
605
|
+
type: string;
|
|
606
|
+
value: string;
|
|
607
|
+
valueAsAttribute: boolean;
|
|
608
|
+
};
|
|
609
|
+
type TApiaLoadForm = {
|
|
610
|
+
form: {
|
|
611
|
+
multiPart: boolean;
|
|
612
|
+
ajaxNewPanel: boolean;
|
|
613
|
+
showErrors: boolean;
|
|
614
|
+
doEscape: boolean;
|
|
615
|
+
action: string;
|
|
616
|
+
onLoad: string;
|
|
617
|
+
ajaxsubmit: boolean;
|
|
618
|
+
closeAll: boolean;
|
|
619
|
+
title: string;
|
|
620
|
+
autoExpand: boolean;
|
|
621
|
+
titleClass: string;
|
|
622
|
+
addClass: string;
|
|
623
|
+
elements?: {
|
|
624
|
+
label: string;
|
|
625
|
+
element: TApiaFormElement | TApiaFormElement[];
|
|
626
|
+
};
|
|
627
|
+
buttons?: {
|
|
628
|
+
button: TApiaFormButton | TApiaFormButton[];
|
|
629
|
+
};
|
|
630
|
+
};
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
interface TApiaAction {
|
|
634
|
+
toDo?: string;
|
|
635
|
+
param: string | string[];
|
|
636
|
+
}
|
|
637
|
+
interface TApiaActions {
|
|
638
|
+
action: TApiaAction | TApiaAction[];
|
|
639
|
+
}
|
|
640
|
+
interface TApiaMessage {
|
|
641
|
+
text: string;
|
|
642
|
+
label?: string;
|
|
643
|
+
}
|
|
644
|
+
type TApiaComplexCell = {
|
|
645
|
+
label: string;
|
|
646
|
+
classToAdd?: string;
|
|
647
|
+
isHTML?: boolean;
|
|
648
|
+
docName?: string;
|
|
649
|
+
forceTitle?: string;
|
|
650
|
+
[key: string]: unknown;
|
|
651
|
+
};
|
|
652
|
+
type TApiaCellDefinition = TApiaComplexCell | string;
|
|
653
|
+
type TApiaRowDefinition = {
|
|
654
|
+
'data-selected'?: boolean;
|
|
655
|
+
selected?: boolean;
|
|
656
|
+
dblclic: boolean;
|
|
657
|
+
id: string;
|
|
658
|
+
classToAdd?: string;
|
|
659
|
+
rowSeparator?: boolean;
|
|
660
|
+
suspended?: boolean;
|
|
661
|
+
unselectableTR?: boolean;
|
|
662
|
+
headName?: string;
|
|
663
|
+
isLocked?: boolean;
|
|
664
|
+
cell: TApiaCellDefinition | TApiaCellDefinition[];
|
|
665
|
+
boldType?: boolean;
|
|
666
|
+
'expired-doc': true;
|
|
667
|
+
};
|
|
668
|
+
type TApiaFunctionPageInfo = {
|
|
669
|
+
amount: string;
|
|
670
|
+
currentPage: string;
|
|
671
|
+
hasMore: boolean;
|
|
672
|
+
pageCount: string;
|
|
673
|
+
prefix: string;
|
|
674
|
+
reachedMax: boolean;
|
|
675
|
+
selectOnlyOne: boolean;
|
|
676
|
+
totalRecords: string;
|
|
677
|
+
};
|
|
678
|
+
type TApiaSystemMessageObj<Structure = Record<string, unknown>> = Structure & {
|
|
679
|
+
onClose?: string;
|
|
680
|
+
sysMessages?: {
|
|
681
|
+
message: TApiaMessage | TApiaMessage[];
|
|
682
|
+
};
|
|
683
|
+
sysExceptions?: {
|
|
684
|
+
exception: TApiaMessage | TApiaMessage[];
|
|
685
|
+
};
|
|
686
|
+
exceptions?: {
|
|
687
|
+
exception: TApiaMessage | TApiaMessage[];
|
|
688
|
+
};
|
|
689
|
+
actions?: TApiaActions;
|
|
690
|
+
code?: unknown;
|
|
691
|
+
load?: Structure;
|
|
692
|
+
};
|
|
693
|
+
type TApiaTableFunction = {
|
|
694
|
+
result: {
|
|
695
|
+
pageInfo: TApiaFunctionPageInfo;
|
|
696
|
+
table?: {
|
|
697
|
+
row: TApiaRowDefinition | TApiaRowDefinition[];
|
|
698
|
+
};
|
|
699
|
+
};
|
|
700
|
+
};
|
|
701
|
+
type TApiaFunction<T = TApiaTableFunction, HasMessages = true> = HasMessages extends true ? {
|
|
702
|
+
function: {
|
|
703
|
+
dropLastMessage?: boolean;
|
|
704
|
+
name: string;
|
|
705
|
+
messages: T;
|
|
706
|
+
};
|
|
707
|
+
} : {
|
|
708
|
+
function: {
|
|
709
|
+
name: string;
|
|
710
|
+
} & T;
|
|
711
|
+
};
|
|
712
|
+
type TApiaLoadText = {
|
|
713
|
+
text: {
|
|
714
|
+
closeAll: boolean;
|
|
715
|
+
title: string;
|
|
716
|
+
addClass: string;
|
|
717
|
+
label: string;
|
|
718
|
+
};
|
|
719
|
+
};
|
|
720
|
+
type TApiaLoad<T extends Record<string, unknown> = TApiaLoadForm> = {
|
|
721
|
+
canClose: boolean;
|
|
722
|
+
type: string;
|
|
723
|
+
} & T;
|
|
724
|
+
interface TMessage {
|
|
725
|
+
text: string;
|
|
726
|
+
label?: string;
|
|
727
|
+
title?: string;
|
|
728
|
+
type?: string;
|
|
729
|
+
}
|
|
730
|
+
interface TNotificationMessage {
|
|
731
|
+
onClose?: string;
|
|
732
|
+
sysMessages?: {
|
|
733
|
+
message: TMessage | TMessage[];
|
|
734
|
+
};
|
|
735
|
+
sysExceptions?: {
|
|
736
|
+
exception: TMessage | TMessage[];
|
|
737
|
+
};
|
|
738
|
+
exceptions?: {
|
|
739
|
+
exception: TMessage | TMessage[];
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
type TId = string | number;
|
|
744
|
+
type TModify<T, R> = Omit<T, keyof R> & R;
|
|
745
|
+
type TMap<T> = Record<string | number, T>;
|
|
746
|
+
type TRequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
|
|
747
|
+
[K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
|
|
748
|
+
}[Keys];
|
|
749
|
+
|
|
750
|
+
declare const parseXmlAsync: <T>(xml: string) => Promise<T>;
|
|
751
|
+
|
|
752
|
+
export { EventEmitter, ISetBoundary, TApiaAction, TApiaActions, TApiaCellDefinition, TApiaComplexCell, TApiaFieldPropsObj, TApiaFormButton, TApiaFormElement, TApiaFormElementOption, TApiaFunction, TApiaFunctionPageInfo, TApiaLoad, TApiaLoadForm, TApiaLoadText, TApiaMessage, TApiaMultiplePossibleValue, TApiaPossibleValue, TApiaRadioPossibleValue, TApiaRowDefinition, TApiaSelectPossibleValue, TApiaSystemMessageObj, TApiaTableFunction, TCallback, TDateFormat, TDispatchCallback, TFieldEvent, TFieldScriptEvent, TFieldScriptEvents, TFieldServerEvent, TFieldServerEvents, TFncParams, TId, TKey, TMap, TMessage, TModify, TNotificationMessage, TRequireOnlyOne, TShortcutBranch, WithEventsValue, addBoundary, apiaDateToStandarFormat, arrayOrArray, cantFocusSelector, customEvents, dateToApiaFormat, debugDispatcher, decrypt, enableDebugDispatcher, encrypt, focusSelector, formatMessage, getDateFormat, getFocusSelector, getIndex, getLabel, getSpecificParent, getValueByPath, isChild, isDebugDispatcherEnabled, noNaN, parseAsSize, parseXmlAsync, persistentStorage, setValueByPath, shortcutController, toBoolean, useCombinedRefs, useLatest, useMount, usePrevious, useStateRef, useUnmount, useUpdateEffect };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,80 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var lodash = require('lodash');
|
|
4
|
+
var d = require('crypto-js');
|
|
5
|
+
var O = require('dayjs');
|
|
6
|
+
var Y = require('dayjs/plugin/customParseFormat');
|
|
7
|
+
var x = require('react');
|
|
8
|
+
var te = require('xml2js');
|
|
9
|
+
var processors = require('xml2js/lib/processors');
|
|
10
|
+
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
function _interopNamespace(e) {
|
|
14
|
+
if (e && e.__esModule) return e;
|
|
15
|
+
var n = Object.create(null);
|
|
16
|
+
if (e) {
|
|
17
|
+
Object.keys(e).forEach(function (k) {
|
|
18
|
+
if (k !== 'default') {
|
|
19
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return e[k]; }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
n.default = e;
|
|
28
|
+
return Object.freeze(n);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var d__default = /*#__PURE__*/_interopDefault(d);
|
|
32
|
+
var O__default = /*#__PURE__*/_interopDefault(O);
|
|
33
|
+
var Y__default = /*#__PURE__*/_interopDefault(Y);
|
|
34
|
+
var x__namespace = /*#__PURE__*/_interopNamespace(x);
|
|
35
|
+
var te__default = /*#__PURE__*/_interopDefault(te);
|
|
36
|
+
|
|
37
|
+
var S=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var l=(e,t,r)=>(S(e,t,"read from private field"),r?r.call(e):t.get(e)),h=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r);},k=(e,t,r,n)=>(S(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var D=(e,t,r)=>new Promise((n,s)=>{var o=c=>{try{a(r.next(c));}catch(p){s(p);}},i=c=>{try{a(r.throw(c));}catch(p){s(p);}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,i);a((r=r.apply(e,t)).next());});function M(e){return Array.isArray(e)?e:[e]}function N(e,t,r){for(let n=0;n<t.length;n++)if(typeof t[n]=="boolean"&&t[n]||lodash.isFunction(t[n])&&t[n]())return e[n];return e[r!=null?r:-1]}var T=(e,t,r,n)=>d__default.default.PBKDF2(t,d__default.default.enc.Hex.parse(e),{keySize:r/32,iterations:n});var xe=(e,t,r,n,s,o)=>{let i=T(e,r,s,o),a=d__default.default.lib.CipherParams.create({ciphertext:d__default.default.enc.Base64.parse(n)});return d__default.default.AES.decrypt(a,i,{iv:d__default.default.enc.Hex.parse(t)}).toString(d__default.default.enc.Utf8)};var Ke=(e,t,r,n,s,o)=>{let i=T(e,r,s,o);return d__default.default.AES.encrypt(n,i,{iv:d__default.default.enc.Hex.parse(t)}).ciphertext.toString(d__default.default.enc.Base64)};var w=!0;function R(){return w}function De(){w=!0;}var b=new class{constructor(){this.callbacks={};this.actions={shout:()=>{console.log(Object.keys(this.callbacks));}};this.emit=(t,...r)=>{var n,s,o,i;if(this.actions[t])this.actions[t]();else {if(((n=this.callbacks[t])!=null?n:[]).length===1)return (o=(s=this.callbacks[t])==null?void 0:s[0])==null?void 0:o.call(s,r);((i=this.callbacks[t])!=null?i:[]).forEach(a=>a(r));}return null};}on(t,r,n,s=!1){if(!w&&s)return ()=>{};if(Object.keys(this.actions).includes(t))throw new Error(`The action ${t} is a reserved word for the dispatcher.`);this.callbacks[t]||(this.callbacks[t]=[]);let o=Object.assign(r,{help:()=>{typeof n=="string"&&console.info(n);}});return this.callbacks[t].push(o),this[t]=Object.assign((...i)=>{this.emit(t,...i);},{help:()=>{typeof n=="string"&&console.info(n);}}),()=>{this.off(t,r);}}off(t,r){this.callbacks[t]=this.callbacks[t].filter(n=>n!==r);}};window.dd=b;window.adt=b;var Ae=new class{constructor(){this.history=[];this.candidates=[];this.shortcuts={callbacks:[],children:[],key:{key:""}};this.shortcutsStrings=[];this.categories={dev:["shift&D"]};document.addEventListener("keydown",t=>{var r;((r=t.key)==null?void 0:r.length)!==1&&t.key!=="Escape"||(this.candidates=[...this.candidates.reduce((n,s)=>[...n,...s.children.filter(o=>o.key.key===t.key&&o.key.altKey===t.altKey&&o.key.ctrlKey===t.ctrlKey&&o.key.shiftKey===t.shiftKey)],[]),...this.shortcuts.children.filter(n=>n.key.key===t.key&&n.key.altKey===t.altKey&&n.key.ctrlKey===t.ctrlKey&&n.key.shiftKey===t.shiftKey)],this.candidates.forEach(n=>{var s;(n.fireEvenFromInputs||!(!t.key||t.key.length>1||["input","textarea","select"].includes((s=t.target.tagName)==null?void 0:s.toLowerCase())))&&n.callbacks&&n.callbacks.forEach(o=>o(t));}));}),b.on("shortcuts",()=>{console.info(this.shortcutsStrings),console.info(this.shortcuts,this.history);},"Muestra los shortcuts registrados"),this.on("short".split(""),()=>{this.shortcutsStrings.forEach(t=>console.info(t));},"dev");}parseKeyToString(t){return typeof t=="string"?t:`${t.altKey?"alt&":""}${t.ctrlKey?"ctrl&":""}${t.shiftKey?"shift&":""}${t.key}`}parseKey(t){let r=t.split("&"),n=r.includes("alt"),s=r.includes("ctrl"),o=r.includes("shift"),i=r.find(a=>a!=="shift"&&a!=="alt"&&a!=="ctrl");if(!i)throw new Error(`parseKey "${t}" does not have key.`);return {key:i,altKey:n,ctrlKey:s,shiftKey:o}}on(t,r,n,s){if(n==="dev"&&R())return;let o=this.shortcuts,i=n?[...this.categories[n],...t]:t;if(this.shortcutsStrings.includes(i.map(a=>this.parseKeyToString(a)).join(""))){console.warn(`The shortcut ${i.map(a=>this.parseKeyToString(a)).join("")} is being setted twice. The controller wont register more than one instance but this could be a hint if some unexpected behavior.`);return}for(let a of i){let c=typeof a=="string"?this.parseKey(a):a;if(c.key==="")throw new Error("Empty key ('') is not allowed");let p=o.children.find(u=>u.key.key===c.key||u.key.key===""&&u.key.altKey===c.altKey&&u.key.ctrlKey===c.ctrlKey&&u.key.shiftKey===c.shiftKey&&u.fireEvenFromInputs===s);if(p)o=p;else {let u={callbacks:[],children:[],key:c,fireEvenFromInputs:s};o.children.push(u),o=u;}}this.shortcutsStrings.push(i.map(a=>this.parseKeyToString(a)).join("")),o.callbacks.push(r);}};O__default.default.extend(Y__default.default);var $="DD/MM/YYYY",y=()=>{switch(window.DATE_FORMAT){case"m/d/Y":return "MM/DD/YYYY";case"d/m/Y":return $;case"Y/m/d":return "YYYY/MM/DD";default:return "DD/MM/YYYY"}};function B(e){let t=O__default.default(e,y());return t.isValid()?t.format("YYYY-MM-DD"):""}function I(e){return O__default.default(e).format(y())}var _e={focus:"customFocus",iframeModalChangeTitle:"iframeModalChangeTitle",iframeModalClose:"iframeModalClose",iframeModalNotify:"iframeModalNotify",modalClose:"modalClose",hidePanel:"hidePanel",showPanel:"showPanel"};var H=["[disabled]",'[tabIndex="-1"]','[aria-hidden="true"]',"[readonly]","[data-focus-guard]",".modal__closeButton"].map(e=>`:not(${e})`).join(""),We=["input","textarea","select","a","button:not(.toggleAccordionElement)","[contenteditable]","[tabIndex]",'[role="button"]'].map(e=>`${e}${H}`).join(",");function Xe(e){return `input${e!=null?e:""},
|
|
2
38
|
textarea${e!=null?e:""},
|
|
3
39
|
select${e!=null?e:""},
|
|
4
40
|
a${e!=null?e:""},
|
|
5
41
|
button:not(.toggleAccordionElement)${e!=null?e:""},
|
|
6
42
|
[contenteditable]${e!=null?e:""},
|
|
7
|
-
[tabIndex]${e!=null?e:""}`}function
|
|
43
|
+
[tabIndex]${e!=null?e:""}`}function A(e,t){let r=e;for(;e!==document.documentElement&&r;){let n=t(r);if(n===null)return null;if(n)return r;let s=r.parentElement;if(s)r=s;else return null}return null}function Ze(e,t){return !!A(e,t)}function V(){let e={};return {on(t,r){var n;return Array.isArray(e[t])||(e[t]=[]),(n=e[t])==null||n.push(r),()=>{this.off(t,r);}},off(t,r){var n;e[t]=((n=e[t])!=null?n:[]).filter(s=>s!==r);},emit(t,r){var n;((n=e[t])!=null?n:[]).forEach(s=>s(r));}}}var f,g=class{constructor(){h(this,f,V());}on(t,r){return l(this,f).on(t,r),()=>{l(this,f).off(t,r);}}off(t,r){l(this,f).off(t,r);}emit(t,r){l(this,f).emit(t,r);}};f=new WeakMap;var m,K=class extends g{constructor(r){super();h(this,m,void 0);k(this,m,r);}get value(){return l(this,m)}set value(r){k(this,m,r),this.emit("update",r);}};m=new WeakMap;function ut(...e){let[t,r]=x__namespace.useState();return x__namespace.useEffect(()=>{e.forEach(n=>{n&&(typeof n=="function"?n(t):n.current=t);});},[e,t]),r}function pt(e){let t=x.useRef(e);return t.current=e,t}function gt(e){x.useEffect(e,[]);}function bt(e){x.useEffect(()=>e,[]);}function Et(e){let t=x.useRef(void 0),r=x.useRef(void 0);return t.current=r.current,r.current=e,t}function vt(e){let[t,r]=x.useState(e),n=x.useRef(t);return n.current=t,[t,r,n]}function Ct(e,t){let r=x.useRef(!1);x.useEffect(()=>r.current?e():(r.current=!0,()=>{}),t);}function Ot(e){return window[e]}var $t=(e,t)=>{let r=e;return Object.entries(t).forEach(([n,s])=>{let o;s!==""?o=`<${n}>`:o=`"<${n}>"`,r!=null&&r.includes(o)&&(r=r.replace(o,s||" "));}),r};function Bt(e,t,r,n){let s=typeof e=="number"?e:e.number,o=typeof e=="number"?t:e.min,i=typeof e=="number"?r:e.max,a=typeof e=="number"?n:e.loop,c=Number(s!=null?s:0);return o!==void 0&&c<o&&(i!==void 0&&a?c=i:c=o),i!==void 0&&c>i&&(o!==void 0&&a?c=o:c=i),c}var q=["b","kb","mb","gb","tb"];function Lt(e){let t=0,r=e;if(r===1/0)return "1000GB";for(;r>1024;)r/=1024,t++;return `${Math.round(r*10)/10}${q[t]}`}function It(e,t=0){let r=Number(e);return e===null||Number.isNaN(r)?t:r}function Q(e,t,r="."){let n=typeof t=="string"?t.split(r):t;if(typeof e!="object"||!e)return n.length===0?e:void 0;let s=n.shift();return n.length===0?e[s]:Q(e[s],n,r)}function Jt(e,t,r){let n=t.split(".");if(n.length===0)return console.warn(`An empty path was provoided ${t}`),null;let s=lodash.clone(e!=null?e:{}),o=s;for(let i=0;i<n.length-1;i++)if(o[n[i]]||(o[n[i]]={}),typeof o[n[i]]=="object")o=o[n[i]];else throw console.info({originalObject:e,originalPath:t,currentObj:o,currentStep:n[i]}),new Error(`The provided path ${t} cannot be applied due to it is not an object's path.`);return o[n.pop()]=r,s}var P=new Proxy({remove(e){localStorage.removeItem(e);}},{get(e,t){try{let r=localStorage.getItem(String(t));return r?JSON.parse(r):void 0}catch(r){return}},set(e,t,r){return localStorage.setItem(String(t),JSON.stringify(r)),!0}});window.persistentStorage=P;var ee=P;function Gt(e){return typeof e=="string"?!["false",""].includes(e.toLowerCase()):Array.isArray(e)?e.length>0:!!e}var oe=e=>e==="a"?"form":e==="b"?"field":e==="g"?"possibleValues":e==="h"?"item":e==="z"?"focusTo":e==="r"?"reload":e==="p"?"proccess":e==="d"?"valueAttr":e,se=e=>e==="t"?"text":e==="label"?"LABEL":e,ie=(e,t)=>t==="v"&&e==="T"?!0:t==="v"&&e==="F"?!1:e;var ae=(e,t)=>t==="value"&&typeof e=="number"&&Number.isNaN(e)||t==="valueType"&&typeof e=="string"&&e==="null"?"":(t==="cols"||t==="rows"||t==="x"||t==="y"||t==="length")&&typeof e=="string"?processors.parseNumbers(e):e,ce=e=>D(void 0,null,function*(){let t=new te__default.default.Parser({trim:!0,normalize:!0,explicitRoot:!1,mergeAttrs:!0,explicitArray:!1,charkey:"label",attrValueProcessors:[processors.parseBooleans,ae,ie],tagNameProcessors:[oe],attrNameProcessors:[se]});return yield new Promise((n,s)=>{t.parseString(e,(o,i)=>{o?s(o):n(i);});})});
|
|
44
|
+
|
|
45
|
+
exports.EventEmitter = g;
|
|
46
|
+
exports.WithEventsValue = K;
|
|
47
|
+
exports.addBoundary = Bt;
|
|
48
|
+
exports.apiaDateToStandarFormat = B;
|
|
49
|
+
exports.arrayOrArray = M;
|
|
50
|
+
exports.cantFocusSelector = H;
|
|
51
|
+
exports.customEvents = _e;
|
|
52
|
+
exports.dateToApiaFormat = I;
|
|
53
|
+
exports.debugDispatcher = b;
|
|
54
|
+
exports.decrypt = xe;
|
|
55
|
+
exports.enableDebugDispatcher = De;
|
|
56
|
+
exports.encrypt = Ke;
|
|
57
|
+
exports.focusSelector = We;
|
|
58
|
+
exports.formatMessage = $t;
|
|
59
|
+
exports.getDateFormat = y;
|
|
60
|
+
exports.getFocusSelector = Xe;
|
|
61
|
+
exports.getIndex = N;
|
|
62
|
+
exports.getLabel = Ot;
|
|
63
|
+
exports.getSpecificParent = A;
|
|
64
|
+
exports.getValueByPath = Q;
|
|
65
|
+
exports.isChild = Ze;
|
|
66
|
+
exports.isDebugDispatcherEnabled = R;
|
|
67
|
+
exports.noNaN = It;
|
|
68
|
+
exports.parseAsSize = Lt;
|
|
69
|
+
exports.parseXmlAsync = ce;
|
|
70
|
+
exports.persistentStorage = ee;
|
|
71
|
+
exports.setValueByPath = Jt;
|
|
72
|
+
exports.shortcutController = Ae;
|
|
73
|
+
exports.toBoolean = Gt;
|
|
74
|
+
exports.useCombinedRefs = ut;
|
|
75
|
+
exports.useLatest = pt;
|
|
76
|
+
exports.useMount = gt;
|
|
77
|
+
exports.usePrevious = Et;
|
|
78
|
+
exports.useStateRef = vt;
|
|
79
|
+
exports.useUnmount = bt;
|
|
80
|
+
exports.useUpdateEffect = Ct;
|
package/entries.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
["./src/index.ts"]
|
package/package.json
CHANGED
|
@@ -1,45 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apia/util",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9-alpha.0",
|
|
4
4
|
"author": "alexisleite <alexisleite@live.com>",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"engines": {
|
|
8
|
-
"node": ">=14.16"
|
|
9
|
-
},
|
|
10
7
|
"main": "./dist/index.js",
|
|
11
8
|
"types": "./dist/index.d.ts",
|
|
12
9
|
"sideEffects": false,
|
|
13
|
-
"files": [
|
|
14
|
-
"lib"
|
|
15
|
-
],
|
|
16
|
-
"jest": {
|
|
17
|
-
"testEnvironment": "jsdom",
|
|
18
|
-
"testMatch": "**/__tests__/*.test.js",
|
|
19
|
-
"moduleNameMapper": {
|
|
20
|
-
"^@src/(.*)$": "<rootDir>/src/$1"
|
|
21
|
-
},
|
|
22
|
-
"coverageThreshold": {
|
|
23
|
-
"global": {
|
|
24
|
-
"branches": 80,
|
|
25
|
-
"functions": 80,
|
|
26
|
-
"lines": 80,
|
|
27
|
-
"statements": 80
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
10
|
"scripts": {
|
|
32
11
|
"build": "tsup",
|
|
33
|
-
"buildDev": "tsup",
|
|
34
12
|
"test": "node ./__tests__/util.test.js"
|
|
35
13
|
},
|
|
36
14
|
"dependencies": {
|
|
37
|
-
"@apia/notifications": "^0.0.7",
|
|
38
15
|
"@types/crypto-js": "^4.1.1",
|
|
39
16
|
"@types/xml2js": "^0.4.11",
|
|
40
17
|
"crypto-js": "^4.1.1",
|
|
41
18
|
"dayjs": "^1.11.7",
|
|
42
|
-
"lodash
|
|
19
|
+
"lodash": "^4.17.21",
|
|
43
20
|
"node-polyfill-webpack-plugin": "^2.0.1",
|
|
44
21
|
"stream": "^0.0.2",
|
|
45
22
|
"stream-browserify": "^3.0.0",
|
|
@@ -48,7 +25,7 @@
|
|
|
48
25
|
"xml2js": "^0.4.23"
|
|
49
26
|
},
|
|
50
27
|
"devDependencies": {
|
|
51
|
-
"@types/lodash
|
|
28
|
+
"@types/lodash": "^4.14.192",
|
|
52
29
|
"tsup": "^6.6.3",
|
|
53
30
|
"type-fest": "^3.6.1",
|
|
54
31
|
"typescript": "^4.9.5"
|
|
@@ -58,7 +35,7 @@
|
|
|
58
35
|
"react": "^18.2.0",
|
|
59
36
|
"react-dom": "^18.2.0"
|
|
60
37
|
},
|
|
61
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "44a7f4d12bba024c862a7a811b79547c6a8030b1",
|
|
62
39
|
"repository": {
|
|
63
40
|
"type": "git",
|
|
64
41
|
"url": "http://corp-gitlab-01.domst.st.net/products/apia/ApiaNPMPackages.git",
|