@apia/util 2.0.11 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1865 -68
- package/dist/index.js +2650 -62
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/dist/animate/index.d.ts +0 -4
- package/dist/animate/index.d.ts.map +0 -1
- package/dist/animate/index.js +0 -24
- package/dist/animate/index.js.map +0 -1
- package/dist/array/arrayOrArray.d.ts +0 -4
- package/dist/array/arrayOrArray.d.ts.map +0 -1
- package/dist/array/arrayOrArray.js +0 -8
- package/dist/array/arrayOrArray.js.map +0 -1
- package/dist/array/getIndex.d.ts +0 -14
- package/dist/array/getIndex.d.ts.map +0 -1
- package/dist/array/getIndex.js +0 -12
- package/dist/array/getIndex.js.map +0 -1
- package/dist/crypto/decrypt.d.ts +0 -4
- package/dist/crypto/decrypt.d.ts.map +0 -1
- package/dist/crypto/decrypt.js +0 -16
- package/dist/crypto/decrypt.js.map +0 -1
- package/dist/crypto/encrypt.d.ts +0 -4
- package/dist/crypto/encrypt.d.ts.map +0 -1
- package/dist/crypto/encrypt.js +0 -13
- package/dist/crypto/encrypt.js.map +0 -1
- package/dist/crypto/generateKey.js +0 -11
- package/dist/crypto/generateKey.js.map +0 -1
- package/dist/date/apiaDateToStandarFormat.d.ts +0 -4
- package/dist/date/apiaDateToStandarFormat.d.ts.map +0 -1
- package/dist/date/apiaDateToStandarFormat.js +0 -12
- package/dist/date/apiaDateToStandarFormat.js.map +0 -1
- package/dist/date/dateToApiaFormat.d.ts +0 -4
- package/dist/date/dateToApiaFormat.d.ts.map +0 -1
- package/dist/date/dateToApiaFormat.js +0 -9
- package/dist/date/dateToApiaFormat.js.map +0 -1
- package/dist/date/getDateFormat.d.ts +0 -11
- package/dist/date/getDateFormat.d.ts.map +0 -1
- package/dist/date/getDateFormat.js +0 -20
- package/dist/date/getDateFormat.js.map +0 -1
- package/dist/debug/debugDispatcher.d.ts +0 -36
- package/dist/debug/debugDispatcher.d.ts.map +0 -1
- package/dist/debug/debugDispatcher.js +0 -75
- package/dist/debug/debugDispatcher.js.map +0 -1
- package/dist/debug/shortcutController.d.ts +0 -57
- package/dist/debug/shortcutController.d.ts.map +0 -1
- package/dist/debug/shortcutController.js +0 -152
- package/dist/debug/shortcutController.js.map +0 -1
- package/dist/documents/downloadStringAsDoc.d.ts +0 -8
- package/dist/documents/downloadStringAsDoc.d.ts.map +0 -1
- package/dist/documents/downloadStringAsDoc.js +0 -12
- package/dist/documents/downloadStringAsDoc.js.map +0 -1
- package/dist/documents/downloadUrl.d.ts +0 -20
- package/dist/documents/downloadUrl.d.ts.map +0 -1
- package/dist/documents/downloadUrl.js +0 -18
- package/dist/documents/downloadUrl.js.map +0 -1
- package/dist/documents/openAndReadFile.d.ts +0 -4
- package/dist/documents/openAndReadFile.d.ts.map +0 -1
- package/dist/documents/openAndReadFile.js +0 -29
- package/dist/documents/openAndReadFile.js.map +0 -1
- package/dist/dom/autoDisconnectMutationObserver.d.ts +0 -17
- package/dist/dom/autoDisconnectMutationObserver.d.ts.map +0 -1
- package/dist/dom/autoDisconnectMutationObserver.js +0 -35
- package/dist/dom/autoDisconnectMutationObserver.js.map +0 -1
- package/dist/dom/customEvents.d.ts +0 -40
- package/dist/dom/customEvents.d.ts.map +0 -1
- package/dist/dom/customEvents.js +0 -34
- package/dist/dom/customEvents.js.map +0 -1
- package/dist/dom/enableChildrenFocus.d.ts +0 -18
- package/dist/dom/enableChildrenFocus.d.ts.map +0 -1
- package/dist/dom/enableChildrenFocus.js +0 -26
- package/dist/dom/enableChildrenFocus.js.map +0 -1
- package/dist/dom/findOffsetRelativeToScrollParent.d.ts +0 -7
- package/dist/dom/findOffsetRelativeToScrollParent.d.ts.map +0 -1
- package/dist/dom/findOffsetRelativeToScrollParent.js +0 -19
- package/dist/dom/findOffsetRelativeToScrollParent.js.map +0 -1
- package/dist/dom/findScrollContainer.d.ts +0 -8
- package/dist/dom/findScrollContainer.d.ts.map +0 -1
- package/dist/dom/findScrollContainer.js +0 -9
- package/dist/dom/findScrollContainer.js.map +0 -1
- package/dist/dom/getFocusSelector.d.ts +0 -25
- package/dist/dom/getFocusSelector.d.ts.map +0 -1
- package/dist/dom/getFocusSelector.js +0 -30
- package/dist/dom/getFocusSelector.js.map +0 -1
- package/dist/dom/getSpecificParent.d.ts +0 -23
- package/dist/dom/getSpecificParent.d.ts.map +0 -1
- package/dist/dom/getSpecificParent.js +0 -19
- package/dist/dom/getSpecificParent.js.map +0 -1
- package/dist/dom/isChild.d.ts +0 -13
- package/dist/dom/isChild.d.ts.map +0 -1
- package/dist/dom/isChild.js +0 -8
- package/dist/dom/isChild.js.map +0 -1
- package/dist/dom/scrollParentIntoElement.d.ts +0 -9
- package/dist/dom/scrollParentIntoElement.d.ts.map +0 -1
- package/dist/dom/scrollParentIntoElement.js +0 -24
- package/dist/dom/scrollParentIntoElement.js.map +0 -1
- package/dist/dom/url.d.ts +0 -18
- package/dist/dom/url.d.ts.map +0 -1
- package/dist/dom/url.js +0 -52
- package/dist/dom/url.js.map +0 -1
- package/dist/dom/usePanAndZoom.d.ts +0 -14
- package/dist/dom/usePanAndZoom.d.ts.map +0 -1
- package/dist/dom/usePanAndZoom.js +0 -111
- package/dist/dom/usePanAndZoom.js.map +0 -1
- package/dist/encoding/index.d.ts +0 -8
- package/dist/encoding/index.d.ts.map +0 -1
- package/dist/encoding/index.js +0 -12
- package/dist/encoding/index.js.map +0 -1
- package/dist/events/BouncingEmitter.d.ts +0 -67
- package/dist/events/BouncingEmitter.d.ts.map +0 -1
- package/dist/events/BouncingEmitter.js +0 -72
- package/dist/events/BouncingEmitter.js.map +0 -1
- package/dist/events/EventEmitter.d.ts +0 -47
- package/dist/events/EventEmitter.d.ts.map +0 -1
- package/dist/events/EventEmitter.js +0 -75
- package/dist/events/EventEmitter.js.map +0 -1
- package/dist/events/StatefulEmitter.d.ts +0 -44
- package/dist/events/StatefulEmitter.d.ts.map +0 -1
- package/dist/events/StatefulEmitter.js +0 -57
- package/dist/events/StatefulEmitter.js.map +0 -1
- package/dist/events/types.d.ts +0 -29
- package/dist/events/types.d.ts.map +0 -1
- package/dist/focus/focusController.d.ts +0 -108
- package/dist/focus/focusController.d.ts.map +0 -1
- package/dist/focus/focusController.js +0 -295
- package/dist/focus/focusController.js.map +0 -1
- package/dist/focus/globalFocus.d.ts +0 -24
- package/dist/focus/globalFocus.d.ts.map +0 -1
- package/dist/focus/globalFocus.js +0 -87
- package/dist/focus/globalFocus.js.map +0 -1
- package/dist/history/History.d.ts +0 -81
- package/dist/history/History.d.ts.map +0 -1
- package/dist/history/History.js +0 -122
- package/dist/history/History.js.map +0 -1
- package/dist/hooks/useCombinedRefs.d.ts +0 -18
- package/dist/hooks/useCombinedRefs.d.ts.map +0 -1
- package/dist/hooks/useCombinedRefs.js +0 -20
- package/dist/hooks/useCombinedRefs.js.map +0 -1
- package/dist/hooks/useDebouncedCallback.d.ts +0 -7
- package/dist/hooks/useDebouncedCallback.d.ts.map +0 -1
- package/dist/hooks/useDebouncedCallback.js +0 -21
- package/dist/hooks/useDebouncedCallback.js.map +0 -1
- package/dist/hooks/useLatest.d.ts +0 -13
- package/dist/hooks/useLatest.d.ts.map +0 -1
- package/dist/hooks/useLatest.js +0 -10
- package/dist/hooks/useLatest.js.map +0 -1
- package/dist/hooks/useMount.d.ts +0 -6
- package/dist/hooks/useMount.d.ts.map +0 -1
- package/dist/hooks/useMount.js +0 -14
- package/dist/hooks/useMount.js.map +0 -1
- package/dist/hooks/usePrevious.d.ts +0 -6
- package/dist/hooks/usePrevious.d.ts.map +0 -1
- package/dist/hooks/usePrevious.js +0 -12
- package/dist/hooks/usePrevious.js.map +0 -1
- package/dist/hooks/useShallowMemo.d.ts +0 -9
- package/dist/hooks/useShallowMemo.d.ts.map +0 -1
- package/dist/hooks/useShallowMemo.js +0 -42
- package/dist/hooks/useShallowMemo.js.map +0 -1
- package/dist/hooks/useStateRef.d.ts +0 -10
- package/dist/hooks/useStateRef.d.ts.map +0 -1
- package/dist/hooks/useStateRef.js +0 -11
- package/dist/hooks/useStateRef.js.map +0 -1
- package/dist/hooks/useSubscription.d.ts +0 -31
- package/dist/hooks/useSubscription.d.ts.map +0 -1
- package/dist/hooks/useSubscription.js +0 -21
- package/dist/hooks/useSubscription.js.map +0 -1
- package/dist/hooks/useUnmount.d.ts +0 -4
- package/dist/hooks/useUnmount.d.ts.map +0 -1
- package/dist/hooks/useUnmount.js +0 -10
- package/dist/hooks/useUnmount.js.map +0 -1
- package/dist/hooks/useUpdateEffect.d.ts +0 -10
- package/dist/hooks/useUpdateEffect.d.ts.map +0 -1
- package/dist/hooks/useUpdateEffect.js +0 -16
- package/dist/hooks/useUpdateEffect.js.map +0 -1
- package/dist/imperative/makeImperativeComponent.d.ts +0 -56
- package/dist/imperative/makeImperativeComponent.d.ts.map +0 -1
- package/dist/imperative/makeImperativeComponent.js +0 -43
- package/dist/imperative/makeImperativeComponent.js.map +0 -1
- package/dist/imperative/makeSingleImperativeComponent.d.ts +0 -15
- package/dist/imperative/makeSingleImperativeComponent.d.ts.map +0 -1
- package/dist/imperative/makeSingleImperativeComponent.js +0 -31
- package/dist/imperative/makeSingleImperativeComponent.js.map +0 -1
- package/dist/imperative/types.d.ts +0 -22
- package/dist/imperative/types.d.ts.map +0 -1
- package/dist/imperative/types.js +0 -8
- package/dist/imperative/types.js.map +0 -1
- package/dist/imperative/useImperativeComponentEvents.d.ts +0 -6
- package/dist/imperative/useImperativeComponentEvents.d.ts.map +0 -1
- package/dist/imperative/useImperativeComponentEvents.js +0 -35
- package/dist/imperative/useImperativeComponentEvents.js.map +0 -1
- package/dist/imperative/useImperativeIdentifierContext.d.ts +0 -14
- package/dist/imperative/useImperativeIdentifierContext.d.ts.map +0 -1
- package/dist/imperative/useImperativeIdentifierContext.js +0 -10
- package/dist/imperative/useImperativeIdentifierContext.js.map +0 -1
- package/dist/labels/formatMessage.d.ts +0 -19
- package/dist/labels/formatMessage.d.ts.map +0 -1
- package/dist/labels/formatMessage.js +0 -13
- package/dist/labels/formatMessage.js.map +0 -1
- package/dist/labels/getLabel.d.ts +0 -34
- package/dist/labels/getLabel.d.ts.map +0 -1
- package/dist/labels/getLabel.js +0 -18
- package/dist/labels/getLabel.js.map +0 -1
- package/dist/number/index.d.ts +0 -29
- package/dist/number/index.d.ts.map +0 -1
- package/dist/number/index.js +0 -43
- package/dist/number/index.js.map +0 -1
- package/dist/objects/getValueByPath.d.ts +0 -23
- package/dist/objects/getValueByPath.d.ts.map +0 -1
- package/dist/objects/getValueByPath.js +0 -19
- package/dist/objects/getValueByPath.js.map +0 -1
- package/dist/objects/setValueByPath.d.ts +0 -33
- package/dist/objects/setValueByPath.d.ts.map +0 -1
- package/dist/objects/setValueByPath.js +0 -35
- package/dist/objects/setValueByPath.js.map +0 -1
- package/dist/propsStore/propsStore.d.ts +0 -42
- package/dist/propsStore/propsStore.d.ts.map +0 -1
- package/dist/propsStore/propsStore.js +0 -157
- package/dist/propsStore/propsStore.js.map +0 -1
- package/dist/propsStore/types.d.ts +0 -24
- package/dist/propsStore/types.d.ts.map +0 -1
- package/dist/propsStore/usePropsSelector.d.ts +0 -67
- package/dist/propsStore/usePropsSelector.d.ts.map +0 -1
- package/dist/propsStore/usePropsSelector.js +0 -92
- package/dist/propsStore/usePropsSelector.js.map +0 -1
- package/dist/screenLock/screenLocker.d.ts +0 -60
- package/dist/screenLock/screenLocker.d.ts.map +0 -1
- package/dist/screenLock/screenLocker.js +0 -95
- package/dist/screenLock/screenLocker.js.map +0 -1
- package/dist/states/useDebouncedState.d.ts +0 -10
- package/dist/states/useDebouncedState.d.ts.map +0 -1
- package/dist/states/useDebouncedState.js +0 -22
- package/dist/states/useDebouncedState.js.map +0 -1
- package/dist/states/useDomState.d.ts +0 -86
- package/dist/states/useDomState.d.ts.map +0 -1
- package/dist/states/useDomState.js +0 -35
- package/dist/states/useDomState.js.map +0 -1
- package/dist/storage/StatefulStore.d.ts +0 -205
- package/dist/storage/StatefulStore.d.ts.map +0 -1
- package/dist/storage/StatefulStore.js +0 -301
- package/dist/storage/StatefulStore.js.map +0 -1
- package/dist/storage/persistentStorage.d.ts +0 -12
- package/dist/storage/persistentStorage.d.ts.map +0 -1
- package/dist/storage/persistentStorage.js +0 -28
- package/dist/storage/persistentStorage.js.map +0 -1
- package/dist/storage/useLocalStorage.d.ts +0 -7
- package/dist/storage/useLocalStorage.d.ts.map +0 -1
- package/dist/storage/useLocalStorage.js +0 -40
- package/dist/storage/useLocalStorage.js.map +0 -1
- package/dist/string/alignment.d.ts +0 -25
- package/dist/string/alignment.d.ts.map +0 -1
- package/dist/string/alignment.js +0 -26
- package/dist/string/alignment.js.map +0 -1
- package/dist/string/ucfirst.d.ts +0 -4
- package/dist/string/ucfirst.d.ts.map +0 -1
- package/dist/string/ucfirst.js +0 -6
- package/dist/string/ucfirst.js.map +0 -1
- package/dist/typeGuards/toBoolean.d.ts +0 -26
- package/dist/typeGuards/toBoolean.d.ts.map +0 -1
- package/dist/typeGuards/toBoolean.js +0 -11
- package/dist/typeGuards/toBoolean.js.map +0 -1
- package/dist/types/apia/common.d.ts +0 -114
- package/dist/types/apia/common.d.ts.map +0 -1
- package/dist/types/apia/date.d.ts +0 -4
- package/dist/types/apia/date.d.ts.map +0 -1
- package/dist/types/apia/forms.d.ts +0 -221
- package/dist/types/apia/forms.d.ts.map +0 -1
- package/dist/types/misc.d.ts +0 -9
- package/dist/types/misc.d.ts.map +0 -1
- package/dist/xml/parseXmlAsync.d.ts +0 -4
- package/dist/xml/parseXmlAsync.d.ts.map +0 -1
- package/dist/xml/parseXmlAsync.js +0 -58
- package/dist/xml/parseXmlAsync.js.map +0 -1
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { debugDispatcher, isDebugDispatcherEnabled } from './debugDispatcher.js';
|
|
2
|
-
|
|
3
|
-
const shortcutController = new class ShortcutController {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.history = [];
|
|
6
|
-
this.candidates = [];
|
|
7
|
-
this.shortcuts = {
|
|
8
|
-
callbacks: [],
|
|
9
|
-
children: [],
|
|
10
|
-
key: { key: "" }
|
|
11
|
-
};
|
|
12
|
-
this.shortcutsStrings = [];
|
|
13
|
-
this.categories = {
|
|
14
|
-
dev: ["shift&D"]
|
|
15
|
-
};
|
|
16
|
-
document.addEventListener("keydown", (ev) => {
|
|
17
|
-
if (ev.key?.length !== 1 && ev.key !== "Escape")
|
|
18
|
-
return;
|
|
19
|
-
this.candidates = [
|
|
20
|
-
...this.candidates.reduce(
|
|
21
|
-
(accumulated, current) => [
|
|
22
|
-
...accumulated,
|
|
23
|
-
...current.children.filter(
|
|
24
|
-
(child) => child.key.key === ev.key && child.key.altKey === ev.altKey && child.key.ctrlKey === ev.ctrlKey && child.key.shiftKey === ev.shiftKey
|
|
25
|
-
)
|
|
26
|
-
],
|
|
27
|
-
[]
|
|
28
|
-
),
|
|
29
|
-
...this.shortcuts.children.filter(
|
|
30
|
-
(current) => current.key.key === ev.key && current.key.altKey === ev.altKey && current.key.ctrlKey === ev.ctrlKey && current.key.shiftKey === ev.shiftKey
|
|
31
|
-
)
|
|
32
|
-
];
|
|
33
|
-
this.candidates.forEach((current) => {
|
|
34
|
-
if (current.fireEvenFromInputs || !(!ev.key || ev.key.length > 1 || ["input", "textarea", "select"].includes(
|
|
35
|
-
ev.target.tagName?.toLowerCase()
|
|
36
|
-
))) {
|
|
37
|
-
if (current.callbacks)
|
|
38
|
-
current.callbacks.forEach((cb) => cb(ev));
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
debugDispatcher.on(
|
|
43
|
-
"shortcuts",
|
|
44
|
-
() => {
|
|
45
|
-
console.info(this.shortcutsStrings);
|
|
46
|
-
console.info(this.shortcuts, this.history);
|
|
47
|
-
},
|
|
48
|
-
"Muestra los shortcuts registrados"
|
|
49
|
-
);
|
|
50
|
-
this.on(
|
|
51
|
-
"short".split(""),
|
|
52
|
-
() => {
|
|
53
|
-
this.shortcutsStrings.forEach((shortcut) => console.info(shortcut));
|
|
54
|
-
},
|
|
55
|
-
"dev"
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
parseKeyToString(key) {
|
|
59
|
-
if (typeof key === "string")
|
|
60
|
-
return key;
|
|
61
|
-
return `${key.altKey ? "alt&" : ""}${key.ctrlKey ? "ctrl&" : ""}${key.shiftKey ? "shift&" : ""}${key.key}`;
|
|
62
|
-
}
|
|
63
|
-
parseKey(keyString) {
|
|
64
|
-
const elements = keyString.split("&");
|
|
65
|
-
const altKey = elements.includes("alt");
|
|
66
|
-
const ctrlKey = elements.includes("ctrl");
|
|
67
|
-
const shiftKey = elements.includes("shift");
|
|
68
|
-
const key = elements.find(
|
|
69
|
-
(current) => current !== "shift" && current !== "alt" && current !== "ctrl"
|
|
70
|
-
);
|
|
71
|
-
if (!key)
|
|
72
|
-
throw new Error(`parseKey "${keyString}" does not have key.`);
|
|
73
|
-
return {
|
|
74
|
-
key,
|
|
75
|
-
altKey,
|
|
76
|
-
ctrlKey,
|
|
77
|
-
shiftKey
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Para setear un shorcut se puede pasar un string representativo con la
|
|
82
|
-
* forma:
|
|
83
|
-
*
|
|
84
|
-
* **alt**?&**ctrl**?&**shift**?&**(\w)**
|
|
85
|
-
*
|
|
86
|
-
* Donde: alt? ctrl? shift? implica que cualquiera de esas palabras pueden o
|
|
87
|
-
* no aparecer y (\w) es una letra, símbolo o número.
|
|
88
|
-
*
|
|
89
|
-
* Puede aparecer cualquier tecla de control o no, pero el símbolo o letra
|
|
90
|
-
* debe aparecer.
|
|
91
|
-
*
|
|
92
|
-
* @param category
|
|
93
|
-
* Agrega un prefijo de teclas que se deben presionar antes del shortcut para
|
|
94
|
-
* que funcione, de forma que por ejemplo, todos los shortcuts de la categoría
|
|
95
|
-
* dev serán ejecutados solamente si antes se presionó shift&D
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
*
|
|
99
|
-
shortcutController.on(['shift&A', 'b', 'ctrl&c', 'alt&d'], (ev) => {
|
|
100
|
-
ev.preventDefault();
|
|
101
|
-
console.log('Abctrl+cd'),
|
|
102
|
-
}); // Este shortcut se ejecuta en desarrollo y producción
|
|
103
|
-
|
|
104
|
-
shortcutController.on('unshortcut'.split(''), (ev) => {
|
|
105
|
-
ev.preventDefault();
|
|
106
|
-
console.log('Abctrl+cd'),
|
|
107
|
-
}, 'dev'); // Este shortcut solo se ejecuta en desarrollo
|
|
108
|
-
*/
|
|
109
|
-
on(keys, callback, category, fireEvenFromInputs) {
|
|
110
|
-
if (category === "dev" && !isDebugDispatcherEnabled())
|
|
111
|
-
return;
|
|
112
|
-
let container = this.shortcuts;
|
|
113
|
-
const actualKeys = category ? [...this.categories[category], ...keys] : keys;
|
|
114
|
-
if (this.shortcutsStrings.includes(
|
|
115
|
-
actualKeys.map((current) => this.parseKeyToString(current)).join("")
|
|
116
|
-
)) {
|
|
117
|
-
console.warn(
|
|
118
|
-
`The shortcut ${actualKeys.map((current) => this.parseKeyToString(current)).join(
|
|
119
|
-
""
|
|
120
|
-
)} is being setted twice. The controller wont register more than one instance but this could be a hint if some unexpected behavior.`
|
|
121
|
-
);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
for (const key of actualKeys) {
|
|
125
|
-
const actualKey = typeof key === "string" ? this.parseKey(key) : key;
|
|
126
|
-
if (actualKey.key === "")
|
|
127
|
-
throw new Error(`Empty key ('') is not allowed`);
|
|
128
|
-
const keyContainer = container.children.find(
|
|
129
|
-
(current) => current.key.key === actualKey.key || current.key.key === "" && current.key.altKey === actualKey.altKey && current.key.ctrlKey === actualKey.ctrlKey && current.key.shiftKey === actualKey.shiftKey && current.fireEvenFromInputs === fireEvenFromInputs
|
|
130
|
-
);
|
|
131
|
-
if (keyContainer)
|
|
132
|
-
container = keyContainer;
|
|
133
|
-
else {
|
|
134
|
-
const newContainer = {
|
|
135
|
-
callbacks: [],
|
|
136
|
-
children: [],
|
|
137
|
-
key: actualKey,
|
|
138
|
-
fireEvenFromInputs
|
|
139
|
-
};
|
|
140
|
-
container.children.push(newContainer);
|
|
141
|
-
container = newContainer;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
this.shortcutsStrings.push(
|
|
145
|
-
actualKeys.map((current) => this.parseKeyToString(current)).join("")
|
|
146
|
-
);
|
|
147
|
-
container.callbacks.push(callback);
|
|
148
|
-
}
|
|
149
|
-
}();
|
|
150
|
-
|
|
151
|
-
export { shortcutController };
|
|
152
|
-
//# sourceMappingURL=shortcutController.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shortcutController.js","sources":["../../src/debug/shortcutController.ts"],"sourcesContent":["import { debugDispatcher, isDebugDispatcherEnabled } from './debugDispatcher';\r\n\r\nexport type TCallback = (ev: KeyboardEvent) => unknown;\r\n\r\nexport type TKey = {\r\n key: string;\r\n altKey?: boolean;\r\n ctrlKey?: boolean;\r\n shiftKey?: boolean;\r\n};\r\n\r\nexport type TShortcutBranch = {\r\n key: TKey;\r\n children: TShortcutBranch[];\r\n callbacks: TCallback[];\r\n fireEvenFromInputs?: boolean;\r\n};\r\n\r\nexport const shortcutController = new (class ShortcutController {\r\n history: TKey[] = [];\r\n\r\n candidates: TShortcutBranch[] = [];\r\n\r\n shortcuts: TShortcutBranch = {\r\n callbacks: [],\r\n children: [],\r\n key: { key: '' },\r\n };\r\n\r\n shortcutsStrings: string[] = [];\r\n\r\n categories = {\r\n dev: ['shift&D'],\r\n };\r\n\r\n constructor() {\r\n document.addEventListener('keydown', (ev) => {\r\n if (ev.key?.length !== 1 && ev.key !== 'Escape') return;\r\n this.candidates = [\r\n ...this.candidates.reduce<TShortcutBranch[]>(\r\n (accumulated, current) => [\r\n ...accumulated,\r\n ...current.children.filter(\r\n (child) =>\r\n child.key.key === ev.key &&\r\n child.key.altKey === ev.altKey &&\r\n child.key.ctrlKey === ev.ctrlKey &&\r\n child.key.shiftKey === ev.shiftKey,\r\n ),\r\n ],\r\n [],\r\n ),\r\n ...this.shortcuts.children.filter(\r\n (current) =>\r\n current.key.key === ev.key &&\r\n current.key.altKey === ev.altKey &&\r\n current.key.ctrlKey === ev.ctrlKey &&\r\n current.key.shiftKey === ev.shiftKey,\r\n ),\r\n ];\r\n this.candidates.forEach((current) => {\r\n if (\r\n current.fireEvenFromInputs ||\r\n !(\r\n !ev.key ||\r\n ev.key.length > 1 ||\r\n ['input', 'textarea', 'select'].includes(\r\n (ev.target as HTMLElement).tagName?.toLowerCase(),\r\n )\r\n )\r\n ) {\r\n if (current.callbacks) current.callbacks.forEach((cb) => cb(ev));\r\n }\r\n });\r\n });\r\n\r\n debugDispatcher.on(\r\n 'shortcuts',\r\n () => {\r\n console.info(this.shortcutsStrings);\r\n console.info(this.shortcuts, this.history);\r\n },\r\n 'Muestra los shortcuts registrados',\r\n );\r\n this.on(\r\n 'short'.split(''),\r\n () => {\r\n this.shortcutsStrings.forEach((shortcut) => console.info(shortcut));\r\n },\r\n 'dev',\r\n );\r\n }\r\n\r\n parseKeyToString(key: string | TKey) {\r\n if (typeof key === 'string') return key;\r\n\r\n return `${key.altKey ? 'alt&' : ''}${key.ctrlKey ? 'ctrl&' : ''}${\r\n key.shiftKey ? 'shift&' : ''\r\n }${key.key}`;\r\n }\r\n\r\n parseKey(keyString: string): TKey {\r\n const elements = keyString.split('&');\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n const altKey = elements.includes('alt');\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n const ctrlKey = elements.includes('ctrl');\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n const shiftKey = elements.includes('shift');\r\n const key = elements.find(\r\n (current) =>\r\n current !== 'shift' && current !== 'alt' && current !== 'ctrl',\r\n );\r\n if (!key) throw new Error(`parseKey \"${keyString}\" does not have key.`);\r\n\r\n return {\r\n key,\r\n altKey,\r\n ctrlKey,\r\n shiftKey,\r\n };\r\n }\r\n\r\n /**\r\n * Para setear un shorcut se puede pasar un string representativo con la\r\n * forma:\r\n *\r\n * **alt**?&**ctrl**?&**shift**?&**(\\w)**\r\n *\r\n * Donde: alt? ctrl? shift? implica que cualquiera de esas palabras pueden o\r\n * no aparecer y (\\w) es una letra, símbolo o número.\r\n *\r\n * Puede aparecer cualquier tecla de control o no, pero el símbolo o letra\r\n * debe aparecer.\r\n *\r\n * @param category\r\n * Agrega un prefijo de teclas que se deben presionar antes del shortcut para\r\n * que funcione, de forma que por ejemplo, todos los shortcuts de la categoría\r\n * dev serán ejecutados solamente si antes se presionó shift&D\r\n *\r\n * @example\r\n *\r\n shortcutController.on(['shift&A', 'b', 'ctrl&c', 'alt&d'], (ev) => {\r\n ev.preventDefault();\r\n console.log('Abctrl+cd'),\r\n }); // Este shortcut se ejecuta en desarrollo y producción\r\n\r\n shortcutController.on('unshortcut'.split(''), (ev) => {\r\n ev.preventDefault();\r\n console.log('Abctrl+cd'),\r\n }, 'dev'); // Este shortcut solo se ejecuta en desarrollo\r\n */\r\n on(\r\n keys: (string | TKey)[],\r\n callback: TCallback,\r\n category?: keyof typeof this.categories,\r\n fireEvenFromInputs?: boolean,\r\n ) {\r\n if (category === 'dev' && !isDebugDispatcherEnabled()) return;\r\n\r\n let container = this.shortcuts;\r\n const actualKeys = category\r\n ? [...this.categories[category], ...keys]\r\n : keys;\r\n\r\n if (\r\n this.shortcutsStrings.includes(\r\n actualKeys.map((current) => this.parseKeyToString(current)).join(''),\r\n )\r\n ) {\r\n console.warn(\r\n `The shortcut ${actualKeys\r\n .map((current) => this.parseKeyToString(current))\r\n .join(\r\n '',\r\n )} is being setted twice. The controller wont register more than one instance but this could be a hint if some unexpected behavior.`,\r\n );\r\n return;\r\n }\r\n\r\n // eslint-disable-next-line no-restricted-syntax\r\n for (const key of actualKeys) {\r\n const actualKey = typeof key === 'string' ? this.parseKey(key) : key;\r\n if (actualKey.key === '')\r\n throw new Error(`Empty key ('') is not allowed`);\r\n const keyContainer = container.children.find(\r\n (current) =>\r\n current.key.key === actualKey.key ||\r\n (current.key.key === '' &&\r\n current.key.altKey === actualKey.altKey &&\r\n current.key.ctrlKey === actualKey.ctrlKey &&\r\n current.key.shiftKey === actualKey.shiftKey &&\r\n current.fireEvenFromInputs === fireEvenFromInputs),\r\n );\r\n if (keyContainer) container = keyContainer;\r\n else {\r\n const newContainer = {\r\n callbacks: [],\r\n children: [],\r\n key: actualKey,\r\n fireEvenFromInputs,\r\n };\r\n container.children.push(newContainer);\r\n container = newContainer;\r\n }\r\n }\r\n this.shortcutsStrings.push(\r\n actualKeys.map((current) => this.parseKeyToString(current)).join(''),\r\n );\r\n container.callbacks.push(callback);\r\n }\r\n})();\r\n"],"names":[],"mappings":";;AAkBa,MAAA,kBAAA,GAAqB,IAAK,MAAM,kBAAmB,CAAA;AAAA,EAiB9D,WAAc,GAAA;AAhBd,IAAA,IAAA,CAAA,OAAA,GAAkB,EAAC,CAAA;AAEnB,IAAA,IAAA,CAAA,UAAA,GAAgC,EAAC,CAAA;AAEjC,IAA6B,IAAA,CAAA,SAAA,GAAA;AAAA,MAC3B,WAAW,EAAC;AAAA,MACZ,UAAU,EAAC;AAAA,MACX,GAAA,EAAK,EAAE,GAAA,EAAK,EAAG,EAAA;AAAA,KACjB,CAAA;AAEA,IAAA,IAAA,CAAA,gBAAA,GAA6B,EAAC,CAAA;AAE9B,IAAa,IAAA,CAAA,UAAA,GAAA;AAAA,MACX,GAAA,EAAK,CAAC,SAAS,CAAA;AAAA,KACjB,CAAA;AAGE,IAAS,QAAA,CAAA,gBAAA,CAAiB,SAAW,EAAA,CAAC,EAAO,KAAA;AAC3C,MAAA,IAAI,EAAG,CAAA,GAAA,EAAK,MAAW,KAAA,CAAA,IAAK,GAAG,GAAQ,KAAA,QAAA;AAAU,QAAA,OAAA;AACjD,MAAA,IAAA,CAAK,UAAa,GAAA;AAAA,QAChB,GAAG,KAAK,UAAW,CAAA,MAAA;AAAA,UACjB,CAAC,aAAa,OAAY,KAAA;AAAA,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;;;;"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
type DownloadStringAsDocProps = {
|
|
2
|
-
fileName?: string;
|
|
3
|
-
blobProps?: BlobPropertyBag;
|
|
4
|
-
};
|
|
5
|
-
declare function downloadStringAsDoc(content: string, options?: DownloadStringAsDocProps): Promise<void>;
|
|
6
|
-
|
|
7
|
-
export { type DownloadStringAsDocProps, downloadStringAsDoc };
|
|
8
|
-
//# sourceMappingURL=downloadStringAsDoc.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"downloadStringAsDoc.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
async function downloadStringAsDoc(content, options) {
|
|
2
|
-
(await import('file-saver')).default.saveAs(
|
|
3
|
-
new Blob([content], {
|
|
4
|
-
type: "text/plain; charset=utf-8",
|
|
5
|
-
...options?.blobProps
|
|
6
|
-
}),
|
|
7
|
-
options?.fileName
|
|
8
|
-
);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export { downloadStringAsDoc };
|
|
12
|
-
//# sourceMappingURL=downloadStringAsDoc.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"downloadStringAsDoc.js","sources":["../../src/documents/downloadStringAsDoc.ts"],"sourcesContent":["export type DownloadStringAsDocProps = {\r\n fileName?: string;\r\n blobProps?: BlobPropertyBag;\r\n};\r\n\r\nexport async function downloadStringAsDoc(\r\n content: string,\r\n options?: DownloadStringAsDocProps,\r\n) {\r\n (await import('file-saver')).default.saveAs(\r\n new Blob([content], {\r\n type: 'text/plain; charset=utf-8',\r\n ...options?.blobProps,\r\n }),\r\n options?.fileName,\r\n );\r\n}\r\n"],"names":[],"mappings":"AAKsB,eAAA,mBAAA,CACpB,SACA,OACA,EAAA;AACA,EAAA,CAAC,MAAM,OAAO,YAAY,CAAA,EAAG,OAAQ,CAAA,MAAA;AAAA,IACnC,IAAI,IAAA,CAAK,CAAC,OAAO,CAAG,EAAA;AAAA,MAClB,IAAM,EAAA,2BAAA;AAAA,MACN,GAAG,OAAS,EAAA,SAAA;AAAA,KACb,CAAA;AAAA,IACD,OAAS,EAAA,QAAA;AAAA,GACX,CAAA;AACF;;;;"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AxiosResponse } from 'axios';
|
|
2
|
-
|
|
3
|
-
declare function defaultGetNameFromResponse(blob: AxiosResponse): string;
|
|
4
|
-
/**
|
|
5
|
-
* This function gets an URL and a file name and performs a file download.
|
|
6
|
-
*
|
|
7
|
-
* @param url The url to fetch
|
|
8
|
-
* @param getNameFromResponse The name will be given by the 'content-disposition' prop in the headers
|
|
9
|
-
*/
|
|
10
|
-
declare function downloadUrl(url: string, getNameFromResponse?: (blob: AxiosResponse) => string): Promise<void>;
|
|
11
|
-
/**
|
|
12
|
-
* This function gets an URL and a file name and performs a file download.
|
|
13
|
-
*
|
|
14
|
-
* @param url The url to fetch
|
|
15
|
-
* @param fileName The name the file will have as default in the save dialog
|
|
16
|
-
*/
|
|
17
|
-
declare function downloadUrl(url: string, fileName: string): Promise<void>;
|
|
18
|
-
|
|
19
|
-
export { defaultGetNameFromResponse, downloadUrl };
|
|
20
|
-
//# sourceMappingURL=downloadUrl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"downloadUrl.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
function defaultGetNameFromResponse(blob) {
|
|
2
|
-
return blob.headers["content-disposition"]?.match?.(
|
|
3
|
-
/filename=(?:\\?")?([\w,\s-() ]+(?:\.[A-Za-z]+)?)(?:\\?")?;?/
|
|
4
|
-
)?.[1] ?? "noFileName";
|
|
5
|
-
}
|
|
6
|
-
async function downloadUrl(url, secondParameter = defaultGetNameFromResponse) {
|
|
7
|
-
const blob = await (await import('axios')).default.get(url, {
|
|
8
|
-
responseType: "blob"
|
|
9
|
-
});
|
|
10
|
-
const actualFileName = typeof secondParameter === "string" ? secondParameter : secondParameter(blob);
|
|
11
|
-
(await import('file-saver')).default.saveAs(
|
|
12
|
-
new Blob([blob.data]),
|
|
13
|
-
actualFileName
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { defaultGetNameFromResponse, downloadUrl };
|
|
18
|
-
//# sourceMappingURL=downloadUrl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"downloadUrl.js","sources":["../../src/documents/downloadUrl.ts"],"sourcesContent":["import type { AxiosResponse } from 'axios';\r\n\r\nexport function defaultGetNameFromResponse(blob: AxiosResponse) {\r\n return (\r\n (blob.headers['content-disposition'] as string)?.match?.(\r\n /filename=(?:\\\\?\")?([\\w,\\s-() ]+(?:\\.[A-Za-z]+)?)(?:\\\\?\")?;?/,\r\n )?.[1] ?? 'noFileName'\r\n );\r\n}\r\n\r\n/**\r\n * This function gets an URL and a file name and performs a file download.\r\n *\r\n * @param url The url to fetch\r\n * @param getNameFromResponse The name will be given by the 'content-disposition' prop in the headers\r\n */\r\nexport async function downloadUrl(\r\n url: string,\r\n getNameFromResponse?: (blob: AxiosResponse) => string,\r\n): Promise<void>;\r\n/**\r\n * This function gets an URL and a file name and performs a file download.\r\n *\r\n * @param url The url to fetch\r\n * @param fileName The name the file will have as default in the save dialog\r\n */\r\nexport async function downloadUrl(url: string, fileName: string): Promise<void>;\r\nexport async function downloadUrl(\r\n url: string,\r\n secondParameter:\r\n | string\r\n | ((blob: AxiosResponse) => string) = defaultGetNameFromResponse,\r\n): Promise<void> {\r\n const blob = await (\r\n await import('axios')\r\n ).default.get(url, {\r\n responseType: 'blob',\r\n });\r\n\r\n const actualFileName =\r\n typeof secondParameter === 'string'\r\n ? secondParameter\r\n : secondParameter(blob);\r\n\r\n (await import('file-saver')).default.saveAs(\r\n new Blob([blob.data]),\r\n actualFileName,\r\n );\r\n}\r\n"],"names":[],"mappings":"AAEO,SAAS,2BAA2B,IAAqB,EAAA;AAC9D,EACG,OAAA,IAAA,CAAK,OAAQ,CAAA,qBAAqB,CAAc,EAAA,KAAA;AAAA,IAC/C,6DAAA;AAAA,GACF,GAAI,CAAC,CAAK,IAAA,YAAA,CAAA;AAEd,CAAA;AAmBsB,eAAA,WAAA,CACpB,GACA,EAAA,eAAA,GAEwC,0BACzB,EAAA;AACf,EAAM,MAAA,IAAA,GAAO,OACX,MAAM,OAAO,OAAO,CACpB,EAAA,OAAA,CAAQ,IAAI,GAAK,EAAA;AAAA,IACjB,YAAc,EAAA,MAAA;AAAA,GACf,CAAA,CAAA;AAED,EAAA,MAAM,iBACJ,OAAO,eAAA,KAAoB,QACvB,GAAA,eAAA,GACA,gBAAgB,IAAI,CAAA,CAAA;AAE1B,EAAA,CAAC,MAAM,OAAO,YAAY,CAAA,EAAG,OAAQ,CAAA,MAAA;AAAA,IACnC,IAAI,IAAA,CAAK,CAAC,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,IACpB,cAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openAndReadFile.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
function openAndReadFile() {
|
|
2
|
-
return new Promise((resolve) => {
|
|
3
|
-
const input = document.createElement("input");
|
|
4
|
-
input.type = "file";
|
|
5
|
-
input.style.display = "none";
|
|
6
|
-
document.body.append(input);
|
|
7
|
-
input.click();
|
|
8
|
-
input.addEventListener("change", (ev) => {
|
|
9
|
-
const fileInput = ev.target;
|
|
10
|
-
const file = fileInput?.files?.[0];
|
|
11
|
-
if (file) {
|
|
12
|
-
const reader = new FileReader();
|
|
13
|
-
reader.onload = (event) => {
|
|
14
|
-
fileInput.value = "";
|
|
15
|
-
const content = event.target?.result;
|
|
16
|
-
if (content) {
|
|
17
|
-
resolve(content);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
reader.readAsText(file);
|
|
21
|
-
} else {
|
|
22
|
-
resolve(null);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { openAndReadFile };
|
|
29
|
-
//# sourceMappingURL=openAndReadFile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openAndReadFile.js","sources":["../../src/documents/openAndReadFile.ts"],"sourcesContent":["export function openAndReadFile() {\r\n return new Promise<string | ArrayBuffer | null>((resolve) => {\r\n const input = document.createElement('input');\r\n input.type = 'file';\r\n input.style.display = 'none';\r\n document.body.append(input);\r\n input.click();\r\n input.addEventListener('change', (ev) => {\r\n const fileInput = ev.target as HTMLInputElement;\r\n const file = fileInput?.files?.[0];\r\n if (file) {\r\n const reader = new FileReader();\r\n reader.onload = (event) => {\r\n fileInput.value = '';\r\n const content = event.target?.result;\r\n if (content) {\r\n resolve(content);\r\n }\r\n };\r\n reader.readAsText(file);\r\n } else {\r\n resolve(null);\r\n }\r\n });\r\n });\r\n}\r\n"],"names":[],"mappings":"AAAO,SAAS,eAAkB,GAAA;AAChC,EAAO,OAAA,IAAI,OAAqC,CAAA,CAAC,OAAY,KAAA;AAC3D,IAAM,MAAA,KAAA,GAAQ,QAAS,CAAA,aAAA,CAAc,OAAO,CAAA,CAAA;AAC5C,IAAA,KAAA,CAAM,IAAO,GAAA,MAAA,CAAA;AACb,IAAA,KAAA,CAAM,MAAM,OAAU,GAAA,MAAA,CAAA;AACtB,IAAS,QAAA,CAAA,IAAA,CAAK,OAAO,KAAK,CAAA,CAAA;AAC1B,IAAA,KAAA,CAAM,KAAM,EAAA,CAAA;AACZ,IAAM,KAAA,CAAA,gBAAA,CAAiB,QAAU,EAAA,CAAC,EAAO,KAAA;AACvC,MAAA,MAAM,YAAY,EAAG,CAAA,MAAA,CAAA;AACrB,MAAM,MAAA,IAAA,GAAO,SAAW,EAAA,KAAA,GAAQ,CAAC,CAAA,CAAA;AACjC,MAAA,IAAI,IAAM,EAAA;AACR,QAAM,MAAA,MAAA,GAAS,IAAI,UAAW,EAAA,CAAA;AAC9B,QAAO,MAAA,CAAA,MAAA,GAAS,CAAC,KAAU,KAAA;AACzB,UAAA,SAAA,CAAU,KAAQ,GAAA,EAAA,CAAA;AAClB,UAAM,MAAA,OAAA,GAAU,MAAM,MAAQ,EAAA,MAAA,CAAA;AAC9B,UAAA,IAAI,OAAS,EAAA;AACX,YAAA,OAAA,CAAQ,OAAO,CAAA,CAAA;AAAA,WACjB;AAAA,SACF,CAAA;AACA,QAAA,MAAA,CAAO,WAAW,IAAI,CAAA,CAAA;AAAA,OACjB,MAAA;AACL,QAAA,OAAA,CAAQ,IAAI,CAAA,CAAA;AAAA,OACd;AAAA,KACD,CAAA,CAAA;AAAA,GACF,CAAA,CAAA;AACH;;;;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
interface IAutoDisconnectMutationObserverConf {
|
|
2
|
-
/** Por defecto es true */
|
|
3
|
-
runCallbackOnInit?: boolean;
|
|
4
|
-
/** Por defecto es 100 (ms) */
|
|
5
|
-
timeout?: number;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Crea un observer que va a desconectarse automáticamente luego de que pase
|
|
9
|
-
* una determinada cantidad de tiempo sin actividad en el elemento.
|
|
10
|
-
*
|
|
11
|
-
* Se usa especialmente para esperar que un componente termine de renderizar y
|
|
12
|
-
* aplicar cálculos a nivel de layout sobre él.
|
|
13
|
-
*/
|
|
14
|
-
declare function autoDisconnectMutationObserver(element: HTMLElement, callback: () => unknown, conf?: IAutoDisconnectMutationObserverConf): () => void;
|
|
15
|
-
|
|
16
|
-
export { type IAutoDisconnectMutationObserverConf, autoDisconnectMutationObserver };
|
|
17
|
-
//# sourceMappingURL=autoDisconnectMutationObserver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autoDisconnectMutationObserver.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
function autoDisconnectMutationObserver(element, callback, conf) {
|
|
2
|
-
let timeoutRegister = -1;
|
|
3
|
-
let isConnected = false;
|
|
4
|
-
function disconnect() {
|
|
5
|
-
if (isConnected) {
|
|
6
|
-
isConnected = false;
|
|
7
|
-
observer.disconnect();
|
|
8
|
-
clearTimeout(timeoutRegister);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
let shoutCallback;
|
|
12
|
-
const observer = new MutationObserver((...props) => {
|
|
13
|
-
if (props[0]?.[0] && (props[0][0].removedNodes || props[0][0].addedNodes)) {
|
|
14
|
-
clearTimeout(shoutCallback);
|
|
15
|
-
shoutCallback = setTimeout(callback, 100);
|
|
16
|
-
clearTimeout(timeoutRegister);
|
|
17
|
-
timeoutRegister = setTimeout(
|
|
18
|
-
disconnect,
|
|
19
|
-
conf?.timeout ?? 100
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
isConnected = true;
|
|
24
|
-
observer.observe(element, { subtree: true, childList: true });
|
|
25
|
-
timeoutRegister = setTimeout(
|
|
26
|
-
disconnect,
|
|
27
|
-
conf?.timeout ?? 100
|
|
28
|
-
);
|
|
29
|
-
if (conf?.runCallbackOnInit !== false)
|
|
30
|
-
shoutCallback = setTimeout(callback, 100);
|
|
31
|
-
return disconnect;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { autoDisconnectMutationObserver };
|
|
35
|
-
//# sourceMappingURL=autoDisconnectMutationObserver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autoDisconnectMutationObserver.js","sources":["../../src/dom/autoDisconnectMutationObserver.ts"],"sourcesContent":["export interface IAutoDisconnectMutationObserverConf {\r\n /** Por defecto es true */\r\n runCallbackOnInit?: boolean;\r\n /** Por defecto es 100 (ms) */\r\n timeout?: number;\r\n}\r\n\r\n/**\r\n * Crea un observer que va a desconectarse automáticamente luego de que pase\r\n * una determinada cantidad de tiempo sin actividad en el elemento.\r\n *\r\n * Se usa especialmente para esperar que un componente termine de renderizar y\r\n * aplicar cálculos a nivel de layout sobre él.\r\n */\r\nexport function autoDisconnectMutationObserver(\r\n element: HTMLElement,\r\n callback: () => unknown,\r\n conf?: IAutoDisconnectMutationObserverConf,\r\n) {\r\n let timeoutRegister = -1;\r\n let isConnected = false;\r\n function disconnect() {\r\n if (isConnected) {\r\n isConnected = false;\r\n observer.disconnect();\r\n clearTimeout(timeoutRegister);\r\n }\r\n }\r\n let shoutCallback: number;\r\n\r\n const observer = new MutationObserver((...props) => {\r\n if (props[0]?.[0] && (props[0][0].removedNodes || props[0][0].addedNodes)) {\r\n clearTimeout(shoutCallback);\r\n shoutCallback = setTimeout(callback, 100) as unknown as number;\r\n clearTimeout(timeoutRegister);\r\n timeoutRegister = setTimeout(\r\n disconnect,\r\n conf?.timeout ?? 100,\r\n ) as unknown as number;\r\n }\r\n });\r\n isConnected = true;\r\n observer.observe(element, { subtree: true, childList: true });\r\n timeoutRegister = setTimeout(\r\n disconnect,\r\n conf?.timeout ?? 100,\r\n ) as unknown as number;\r\n\r\n if (conf?.runCallbackOnInit !== false)\r\n shoutCallback = setTimeout(callback, 100) as unknown as number;\r\n\r\n return disconnect;\r\n}\r\n"],"names":[],"mappings":"AAcgB,SAAA,8BAAA,CACd,OACA,EAAA,QAAA,EACA,IACA,EAAA;AACA,EAAA,IAAI,eAAkB,GAAA,CAAA,CAAA,CAAA;AACtB,EAAA,IAAI,WAAc,GAAA,KAAA,CAAA;AAClB,EAAA,SAAS,UAAa,GAAA;AACpB,IAAA,IAAI,WAAa,EAAA;AACf,MAAc,WAAA,GAAA,KAAA,CAAA;AACd,MAAA,QAAA,CAAS,UAAW,EAAA,CAAA;AACpB,MAAA,YAAA,CAAa,eAAe,CAAA,CAAA;AAAA,KAC9B;AAAA,GACF;AACA,EAAI,IAAA,aAAA,CAAA;AAEJ,EAAA,MAAM,QAAW,GAAA,IAAI,gBAAiB,CAAA,CAAA,GAAI,KAAU,KAAA;AAClD,IAAA,IAAI,MAAM,CAAC,CAAA,GAAI,CAAC,CAAA,KAAM,MAAM,CAAC,CAAA,CAAE,CAAC,CAAA,CAAE,gBAAgB,KAAM,CAAA,CAAC,CAAE,CAAA,CAAC,EAAE,UAAa,CAAA,EAAA;AACzE,MAAA,YAAA,CAAa,aAAa,CAAA,CAAA;AAC1B,MAAgB,aAAA,GAAA,UAAA,CAAW,UAAU,GAAG,CAAA,CAAA;AACxC,MAAA,YAAA,CAAa,eAAe,CAAA,CAAA;AAC5B,MAAkB,eAAA,GAAA,UAAA;AAAA,QAChB,UAAA;AAAA,QACA,MAAM,OAAW,IAAA,GAAA;AAAA,OACnB,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACD,EAAc,WAAA,GAAA,IAAA,CAAA;AACd,EAAA,QAAA,CAAS,QAAQ,OAAS,EAAA,EAAE,SAAS,IAAM,EAAA,SAAA,EAAW,MAAM,CAAA,CAAA;AAC5D,EAAkB,eAAA,GAAA,UAAA;AAAA,IAChB,UAAA;AAAA,IACA,MAAM,OAAW,IAAA,GAAA;AAAA,GACnB,CAAA;AAEA,EAAA,IAAI,MAAM,iBAAsB,KAAA,KAAA;AAC9B,IAAgB,aAAA,GAAA,UAAA,CAAW,UAAU,GAAG,CAAA,CAAA;AAE1C,EAAO,OAAA,UAAA,CAAA;AACT;;;;"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Existen algunos eventos que se disparan en la
|
|
3
|
-
* aplicación con la finalidad de desencadenar
|
|
4
|
-
* un comportamiento específico. Por ello se declaran
|
|
5
|
-
* las siguientes constantes.
|
|
6
|
-
*/
|
|
7
|
-
declare const customEvents: {
|
|
8
|
-
/**
|
|
9
|
-
* Indica que un elemento necesita recibir el foco,
|
|
10
|
-
* de esta forma, elementos que no se están mostrando
|
|
11
|
-
* en pantalla (por display:none por ejemplo), pueden
|
|
12
|
-
* indicar a sus ancestros que deben expandirse.
|
|
13
|
-
*/
|
|
14
|
-
focus: string;
|
|
15
|
-
/**
|
|
16
|
-
* Indica que debe cambiarse el título del modal
|
|
17
|
-
*/
|
|
18
|
-
iframeModalChangeTitle: string;
|
|
19
|
-
/**
|
|
20
|
-
* Indica que un iframe modal debe cerrarse
|
|
21
|
-
*/
|
|
22
|
-
iframeModalClose: string;
|
|
23
|
-
/**
|
|
24
|
-
* Indica que un iframe modal debe cerrarse
|
|
25
|
-
*/
|
|
26
|
-
iframeModalNotify: string;
|
|
27
|
-
/**
|
|
28
|
-
* Indica que un modal debe cerrarse
|
|
29
|
-
*/
|
|
30
|
-
modalClose: string;
|
|
31
|
-
/**
|
|
32
|
-
* Indica que el panel contenedor debe cerrarse porque
|
|
33
|
-
* está vacío
|
|
34
|
-
*/
|
|
35
|
-
hidePanel: string;
|
|
36
|
-
showPanel: string;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export { customEvents };
|
|
40
|
-
//# sourceMappingURL=customEvents.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customEvents.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/dom/customEvents.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const customEvents = {
|
|
2
|
-
/**
|
|
3
|
-
* Indica que un elemento necesita recibir el foco,
|
|
4
|
-
* de esta forma, elementos que no se están mostrando
|
|
5
|
-
* en pantalla (por display:none por ejemplo), pueden
|
|
6
|
-
* indicar a sus ancestros que deben expandirse.
|
|
7
|
-
*/
|
|
8
|
-
focus: "customFocus",
|
|
9
|
-
/**
|
|
10
|
-
* Indica que debe cambiarse el título del modal
|
|
11
|
-
*/
|
|
12
|
-
iframeModalChangeTitle: "iframeModalChangeTitle",
|
|
13
|
-
/**
|
|
14
|
-
* Indica que un iframe modal debe cerrarse
|
|
15
|
-
*/
|
|
16
|
-
iframeModalClose: "iframeModalClose",
|
|
17
|
-
/**
|
|
18
|
-
* Indica que un iframe modal debe cerrarse
|
|
19
|
-
*/
|
|
20
|
-
iframeModalNotify: "iframeModalNotify",
|
|
21
|
-
/**
|
|
22
|
-
* Indica que un modal debe cerrarse
|
|
23
|
-
*/
|
|
24
|
-
modalClose: "modalClose",
|
|
25
|
-
/**
|
|
26
|
-
* Indica que el panel contenedor debe cerrarse porque
|
|
27
|
-
* está vacío
|
|
28
|
-
*/
|
|
29
|
-
hidePanel: "hidePanel",
|
|
30
|
-
showPanel: "showPanel"
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export { customEvents };
|
|
34
|
-
//# sourceMappingURL=customEvents.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customEvents.js","sources":["../../src/dom/customEvents.ts"],"sourcesContent":["/**\r\n * Existen algunos eventos que se disparan en la\r\n * aplicación con la finalidad de desencadenar\r\n * un comportamiento específico. Por ello se declaran\r\n * las siguientes constantes.\r\n */\r\nexport const customEvents = {\r\n /**\r\n * Indica que un elemento necesita recibir el foco,\r\n * de esta forma, elementos que no se están mostrando\r\n * en pantalla (por display:none por ejemplo), pueden\r\n * indicar a sus ancestros que deben expandirse.\r\n */\r\n focus: 'customFocus',\r\n /**\r\n * Indica que debe cambiarse el título del modal\r\n */\r\n iframeModalChangeTitle: 'iframeModalChangeTitle',\r\n /**\r\n * Indica que un iframe modal debe cerrarse\r\n */\r\n iframeModalClose: 'iframeModalClose',\r\n /**\r\n * Indica que un iframe modal debe cerrarse\r\n */\r\n iframeModalNotify: 'iframeModalNotify',\r\n /**\r\n * Indica que un modal debe cerrarse\r\n */\r\n modalClose: 'modalClose',\r\n /**\r\n * Indica que el panel contenedor debe cerrarse porque\r\n * está vacío\r\n */\r\n hidePanel: 'hidePanel',\r\n showPanel: 'showPanel',\r\n};\r\n"],"names":[],"mappings":"AAMO,MAAM,YAAe,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO1B,KAAO,EAAA,aAAA;AAAA;AAAA;AAAA;AAAA,EAIP,sBAAwB,EAAA,wBAAA;AAAA;AAAA;AAAA;AAAA,EAIxB,gBAAkB,EAAA,kBAAA;AAAA;AAAA;AAAA;AAAA,EAIlB,iBAAmB,EAAA,mBAAA;AAAA;AAAA;AAAA;AAAA,EAInB,UAAY,EAAA,YAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKZ,SAAW,EAAA,WAAA;AAAA,EACX,SAAW,EAAA,WAAA;AACb;;;;"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deshabilita la posibilidad de hacer foco en
|
|
3
|
-
* todos los descendientes de parent. Es
|
|
4
|
-
* especialmente útli cuando se ocultan elementos
|
|
5
|
-
* del DOM sin quitarlos, cuando por accesibilidad
|
|
6
|
-
* es importante que el foco no alcance a dichos
|
|
7
|
-
* métodos.
|
|
8
|
-
*/
|
|
9
|
-
declare function disableChildrenFocus(parent: HTMLElement): void;
|
|
10
|
-
/**
|
|
11
|
-
* Restaura el foco de los hijos de parent a los
|
|
12
|
-
* que previamente se les había quitado el foco
|
|
13
|
-
* con disableChildrenFocus.
|
|
14
|
-
*/
|
|
15
|
-
declare function enableChildrenFocus(parent: HTMLElement): void;
|
|
16
|
-
|
|
17
|
-
export { disableChildrenFocus, enableChildrenFocus };
|
|
18
|
-
//# sourceMappingURL=enableChildrenFocus.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enableChildrenFocus.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { focusSelector } from './getFocusSelector.js';
|
|
2
|
-
|
|
3
|
-
const previousTabIndexLabel = "data-previous-tabindex";
|
|
4
|
-
function disableChildrenFocus(parent) {
|
|
5
|
-
const focusElement = parent.querySelectorAll(focusSelector);
|
|
6
|
-
focusElement.forEach((element) => {
|
|
7
|
-
element.setAttribute(
|
|
8
|
-
previousTabIndexLabel,
|
|
9
|
-
element.getAttribute("tabindex") ?? ""
|
|
10
|
-
);
|
|
11
|
-
element.setAttribute("tabindex", "-1");
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
function enableChildrenFocus(parent) {
|
|
15
|
-
const focusElement = parent.querySelectorAll(`[${previousTabIndexLabel}]`);
|
|
16
|
-
focusElement.forEach((element) => {
|
|
17
|
-
element.setAttribute(
|
|
18
|
-
"tabindex",
|
|
19
|
-
element.getAttribute(previousTabIndexLabel) ?? "0"
|
|
20
|
-
);
|
|
21
|
-
element.removeAttribute(previousTabIndexLabel);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { disableChildrenFocus, enableChildrenFocus };
|
|
26
|
-
//# sourceMappingURL=enableChildrenFocus.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enableChildrenFocus.js","sources":["../../src/dom/enableChildrenFocus.ts"],"sourcesContent":["import { focusSelector } from './getFocusSelector';\r\n\r\nconst previousTabIndexLabel = 'data-previous-tabindex';\r\n\r\n/**\r\n * Deshabilita la posibilidad de hacer foco en\r\n * todos los descendientes de parent. Es\r\n * especialmente útli cuando se ocultan elementos\r\n * del DOM sin quitarlos, cuando por accesibilidad\r\n * es importante que el foco no alcance a dichos\r\n * métodos.\r\n */\r\nexport function disableChildrenFocus(parent: HTMLElement) {\r\n const focusElement = parent.querySelectorAll(focusSelector);\r\n focusElement.forEach((element) => {\r\n element.setAttribute(\r\n previousTabIndexLabel,\r\n element.getAttribute('tabindex') ?? '',\r\n );\r\n element.setAttribute('tabindex', '-1');\r\n });\r\n}\r\n\r\n/**\r\n * Restaura el foco de los hijos de parent a los\r\n * que previamente se les había quitado el foco\r\n * con disableChildrenFocus.\r\n */\r\nexport function enableChildrenFocus(parent: HTMLElement) {\r\n const focusElement = parent.querySelectorAll(`[${previousTabIndexLabel}]`);\r\n focusElement.forEach((element) => {\r\n element.setAttribute(\r\n 'tabindex',\r\n element.getAttribute(previousTabIndexLabel) ?? '0',\r\n );\r\n element.removeAttribute(previousTabIndexLabel);\r\n });\r\n}\r\n"],"names":[],"mappings":";;AAEA,MAAM,qBAAwB,GAAA,wBAAA,CAAA;AAUvB,SAAS,qBAAqB,MAAqB,EAAA;AACxD,EAAM,MAAA,YAAA,GAAe,MAAO,CAAA,gBAAA,CAAiB,aAAa,CAAA,CAAA;AAC1D,EAAa,YAAA,CAAA,OAAA,CAAQ,CAAC,OAAY,KAAA;AAChC,IAAQ,OAAA,CAAA,YAAA;AAAA,MACN,qBAAA;AAAA,MACA,OAAA,CAAQ,YAAa,CAAA,UAAU,CAAK,IAAA,EAAA;AAAA,KACtC,CAAA;AACA,IAAQ,OAAA,CAAA,YAAA,CAAa,YAAY,IAAI,CAAA,CAAA;AAAA,GACtC,CAAA,CAAA;AACH,CAAA;AAOO,SAAS,oBAAoB,MAAqB,EAAA;AACvD,EAAA,MAAM,YAAe,GAAA,MAAA,CAAO,gBAAiB,CAAA,CAAA,CAAA,EAAI,qBAAqB,CAAG,CAAA,CAAA,CAAA,CAAA;AACzE,EAAa,YAAA,CAAA,OAAA,CAAQ,CAAC,OAAY,KAAA;AAChC,IAAQ,OAAA,CAAA,YAAA;AAAA,MACN,UAAA;AAAA,MACA,OAAA,CAAQ,YAAa,CAAA,qBAAqB,CAAK,IAAA,GAAA;AAAA,KACjD,CAAA;AACA,IAAA,OAAA,CAAQ,gBAAgB,qBAAqB,CAAA,CAAA;AAAA,GAC9C,CAAA,CAAA;AACH;;;;"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Esta función calcula el offset que existe entre un elemento y su padre más inmediato que tenga scroll visible
|
|
3
|
-
*/
|
|
4
|
-
declare function findOffsetRelativeToScrollParent(element: HTMLElement, which?: 'Left' | 'Top'): number;
|
|
5
|
-
|
|
6
|
-
export { findOffsetRelativeToScrollParent };
|
|
7
|
-
//# sourceMappingURL=findOffsetRelativeToScrollParent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findOffsetRelativeToScrollParent.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { findScrollContainer } from './findScrollContainer.js';
|
|
2
|
-
|
|
3
|
-
function findOffsetRelativeToScrollParent(element, which = "Top") {
|
|
4
|
-
const scrollParent = findScrollContainer(element);
|
|
5
|
-
let currentElement = element;
|
|
6
|
-
let offset = 0;
|
|
7
|
-
let offsetParent = currentElement;
|
|
8
|
-
while (currentElement && currentElement !== scrollParent && currentElement !== document.body && offsetParent !== scrollParent) {
|
|
9
|
-
if (offsetParent !== currentElement.offsetParent) {
|
|
10
|
-
offset += currentElement[`offset${which}`];
|
|
11
|
-
offsetParent = currentElement.offsetParent;
|
|
12
|
-
}
|
|
13
|
-
currentElement = currentElement.parentElement;
|
|
14
|
-
}
|
|
15
|
-
return offset;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { findOffsetRelativeToScrollParent };
|
|
19
|
-
//# sourceMappingURL=findOffsetRelativeToScrollParent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findOffsetRelativeToScrollParent.js","sources":["../../src/dom/findOffsetRelativeToScrollParent.ts"],"sourcesContent":["import { findScrollContainer } from \"./findScrollContainer\";\r\n\r\n/**\r\n * Esta función calcula el offset que existe entre un elemento y su padre más inmediato que tenga scroll visible\r\n */\r\nexport function findOffsetRelativeToScrollParent(\r\n element: HTMLElement,\r\n which: 'Left' | 'Top' = 'Top',\r\n) {\r\n const scrollParent = findScrollContainer(element);\r\n let currentElement = element;\r\n let offset = 0;\r\n let offsetParent = currentElement;\r\n while (\r\n currentElement &&\r\n currentElement !== scrollParent &&\r\n currentElement !== document.body &&\r\n offsetParent !== scrollParent\r\n ) {\r\n if (offsetParent !== currentElement.offsetParent) {\r\n offset += currentElement[`offset${which}`];\r\n offsetParent = currentElement.offsetParent as HTMLElement;\r\n }\r\n currentElement = currentElement.parentElement as HTMLElement;\r\n }\r\n return offset;\r\n}"],"names":[],"mappings":";;AAKgB,SAAA,gCAAA,CACd,OACA,EAAA,KAAA,GAAwB,KACxB,EAAA;AACA,EAAM,MAAA,YAAA,GAAe,oBAAoB,OAAO,CAAA,CAAA;AAChD,EAAA,IAAI,cAAiB,GAAA,OAAA,CAAA;AACrB,EAAA,IAAI,MAAS,GAAA,CAAA,CAAA;AACb,EAAA,IAAI,YAAe,GAAA,cAAA,CAAA;AACnB,EAAA,OACE,kBACA,cAAmB,KAAA,YAAA,IACnB,mBAAmB,QAAS,CAAA,IAAA,IAC5B,iBAAiB,YACjB,EAAA;AACA,IAAI,IAAA,YAAA,KAAiB,eAAe,YAAc,EAAA;AAChD,MAAU,MAAA,IAAA,cAAA,CAAe,CAAS,MAAA,EAAA,KAAK,CAAE,CAAA,CAAA,CAAA;AACzC,MAAA,YAAA,GAAe,cAAe,CAAA,YAAA,CAAA;AAAA,KAChC;AACA,IAAA,cAAA,GAAiB,cAAe,CAAA,aAAA,CAAA;AAAA,GAClC;AACA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findScrollContainer.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const REGEXP_SCROLL_PARENT = /^(visible|hidden)/;
|
|
2
|
-
function findScrollContainer(el) {
|
|
3
|
-
return !(el instanceof HTMLElement) || typeof window.getComputedStyle !== "function" ? null : el.scrollHeight >= el.clientHeight && !REGEXP_SCROLL_PARENT.test(
|
|
4
|
-
window.getComputedStyle(el).overflowY || "visible"
|
|
5
|
-
) ? el : findScrollContainer(el.parentElement) || document.body;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export { findScrollContainer };
|
|
9
|
-
//# sourceMappingURL=findScrollContainer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findScrollContainer.js","sources":["../../src/dom/findScrollContainer.ts"],"sourcesContent":["const REGEXP_SCROLL_PARENT = /^(visible|hidden)/;\r\n/**\r\n * Encuentra el primer elemento padre del elemento provisto que tenga scroll\r\n * activo.\r\n */\r\nexport function findScrollContainer(el: HTMLElement): HTMLElement | null {\r\n // eslint-disable-next-line no-nested-ternary\r\n return !(el instanceof HTMLElement) ||\r\n typeof window.getComputedStyle !== 'function'\r\n ? null\r\n : el.scrollHeight >= el.clientHeight &&\r\n !REGEXP_SCROLL_PARENT.test(\r\n window.getComputedStyle(el).overflowY || 'visible',\r\n )\r\n ? el\r\n : findScrollContainer(el.parentElement as HTMLElement) || document.body;\r\n}\r\n"],"names":[],"mappings":"AAAA,MAAM,oBAAuB,GAAA,mBAAA,CAAA;AAKtB,SAAS,oBAAoB,EAAqC,EAAA;AAEvE,EAAA,OAAO,EAAE,EAAA,YAAc,WACrB,CAAA,IAAA,OAAO,MAAO,CAAA,gBAAA,KAAqB,UACjC,GAAA,IAAA,GACA,EAAG,CAAA,YAAA,IAAgB,EAAG,CAAA,YAAA,IACtB,CAAC,oBAAqB,CAAA,IAAA;AAAA,IACpB,MAAO,CAAA,gBAAA,CAAiB,EAAE,CAAA,CAAE,SAAa,IAAA,SAAA;AAAA,MAE3C,EACA,GAAA,mBAAA,CAAoB,EAAG,CAAA,aAA4B,KAAK,QAAS,CAAA,IAAA,CAAA;AACvE;;;;"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Este selector pretende abarcar todos modificadores que en caso de estar
|
|
3
|
-
* presentes hacen que un elemento no sea focusable
|
|
4
|
-
*/
|
|
5
|
-
declare const cantFocusSelector: string;
|
|
6
|
-
/**
|
|
7
|
-
* Este selector pretende abarcar todos los elementos que sean focusables
|
|
8
|
-
*/
|
|
9
|
-
declare const focusSelector: string;
|
|
10
|
-
/**
|
|
11
|
-
* Genera un selector que permitirá seleccionar
|
|
12
|
-
* todos los elementos candidatos a recibir foco,
|
|
13
|
-
* que no cumplan con la condición not pasada
|
|
14
|
-
* como parámetro.
|
|
15
|
-
*
|
|
16
|
-
* @param not Un selector not css, indicando cuáles
|
|
17
|
-
* condiciones deben evitar el foco en un elemento.
|
|
18
|
-
*
|
|
19
|
-
* @returns Una cadena que representa un selector
|
|
20
|
-
* css.
|
|
21
|
-
*/
|
|
22
|
-
declare function getFocusSelector(not?: string): string;
|
|
23
|
-
|
|
24
|
-
export { cantFocusSelector, focusSelector, getFocusSelector };
|
|
25
|
-
//# sourceMappingURL=getFocusSelector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getFocusSelector.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|