tool-shack 0.0.13 → 0.0.16
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/browser/index.d.ts +7 -6
- package/dist/browser/index.js +7 -6
- package/dist/browser/isScrollBehaviorSupported.d.ts +6 -0
- package/dist/browser/isScrollBehaviorSupported.js +7 -0
- package/dist/browser/tabFocusListener.d.ts +1 -1
- package/dist/browser/tabFocusListener.js +3 -3
- package/dist/dateTime/index.d.ts +3 -3
- package/dist/dateTime/index.js +3 -3
- package/dist/dateTime/interfaces/index.d.ts +1 -1
- package/dist/dateTime/interfaces/index.js +1 -1
- package/dist/dateTime/parseDuration.d.ts +1 -1
- package/dist/dom/appendAfter.js +1 -1
- package/dist/dom/appendBefore.js +1 -1
- package/dist/dom/createElement.d.ts +1 -1
- package/dist/dom/index.d.ts +8 -8
- package/dist/dom/index.js +8 -8
- package/dist/dom/interfaces/index.d.ts +1 -1
- package/dist/dom/interfaces/index.js +1 -1
- package/dist/general/index.d.ts +3 -3
- package/dist/general/index.js +3 -3
- package/dist/general/isEmpty.js +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/schedule/index.d.ts +2 -2
- package/dist/schedule/index.js +2 -2
- package/dist/string/index.d.ts +5 -5
- package/dist/string/index.js +5 -5
- package/dist/string/slugify.js +1 -1
- package/package.json +29 -10
- package/src/browser/index.ts +7 -6
- package/src/browser/isPushNotificationSupported.ts +7 -7
- package/src/browser/isScrollBehaviorSupported.ts +7 -0
- package/src/browser/isShareSupported.ts +7 -7
- package/src/browser/isTouchSupported.ts +1 -1
- package/src/browser/preferColorScheme.ts +23 -23
- package/src/browser/tabFocusListener.ts +1 -1
- package/src/dateTime/dateAsIso.ts +24 -24
- package/src/dateTime/index.ts +4 -4
- package/src/dateTime/interfaces/index.ts +1 -1
- package/src/dateTime/parseDuration.ts +1 -1
- package/src/dom/addAsyncEventListener.ts +34 -34
- package/src/dom/addEventListener.ts +32 -32
- package/src/dom/createElement.ts +55 -55
- package/src/dom/fireEvent.ts +9 -9
- package/src/dom/index.ts +9 -9
- package/src/dom/interfaces/index.ts +1 -1
- package/src/general/index.ts +3 -3
- package/src/general/isEmpty.ts +21 -21
- package/src/index.ts +6 -6
- package/src/schedule/index.ts +2 -2
- package/src/schedule/runAsync.ts +21 -21
- package/src/string/byteSize.ts +7 -7
- package/src/string/escapeHTML.ts +12 -12
- package/src/string/index.ts +5 -5
- package/src/string/slugify.ts +17 -17
- package/.editorconfig +0 -16
- package/dist/browser/index.js.map +0 -1
- package/dist/browser/interfaces/isTouchSupported.js.map +0 -1
- package/dist/browser/isPushNotificationSupported.js.map +0 -1
- package/dist/browser/isShareSupported.js.map +0 -1
- package/dist/browser/isTabFocused.js.map +0 -1
- package/dist/browser/isTouchSupported.js.map +0 -1
- package/dist/browser/preferColorScheme.js.map +0 -1
- package/dist/browser/tabFocusListener.js.map +0 -1
- package/dist/dateTime/dateAsIso.js.map +0 -1
- package/dist/dateTime/index.js.map +0 -1
- package/dist/dateTime/interfaces/index.js.map +0 -1
- package/dist/dateTime/interfaces/parseDuration.js.map +0 -1
- package/dist/dateTime/parseDuration.js.map +0 -1
- package/dist/dom/addAsyncEventListener.js.map +0 -1
- package/dist/dom/addClickOutsideListener.js.map +0 -1
- package/dist/dom/addEventListener.js.map +0 -1
- package/dist/dom/appendAfter.js.map +0 -1
- package/dist/dom/appendBefore.js.map +0 -1
- package/dist/dom/createElement.js.map +0 -1
- package/dist/dom/fireEvent.js.map +0 -1
- package/dist/dom/index.js.map +0 -1
- package/dist/dom/interfaces/createElement.js.map +0 -1
- package/dist/dom/interfaces/index.js.map +0 -1
- package/dist/general/index.js.map +0 -1
- package/dist/general/isEmpty.js.map +0 -1
- package/dist/general/isNil.js.map +0 -1
- package/dist/general/isValidJson.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/schedule/index.js.map +0 -1
- package/dist/schedule/runAnimation.js.map +0 -1
- package/dist/schedule/runAsync.js.map +0 -1
- package/dist/string/byteSize.js.map +0 -1
- package/dist/string/escapeHTML.js.map +0 -1
- package/dist/string/index.js.map +0 -1
- package/dist/string/removeDiacritics.js.map +0 -1
- package/dist/string/slugify.js.map +0 -1
- package/dist/string/truncate.js.map +0 -1
- package/dist/var/www/imeteo.local/public_html/resources/assets/ts/components/regioweather.d.ts +0 -14
- package/dist/var/www/imeteo.local/public_html/resources/assets/ts/pages/forecast.d.ts +0 -1
- package/dist/var/www/imeteo.local/public_html/resources/assets/ts/pages/homepage.d.ts +0 -1
- package/dist/var/www/imeteo.local/public_html/resources/assets/ts/pages/regioweather.d.ts +0 -1
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -22
- package/docs/assets/icons.css +0 -1043
- package/docs/assets/icons.png +0 -0
- package/docs/assets/icons@2x.png +0 -0
- package/docs/assets/main.js +0 -52
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1413
- package/docs/assets/widgets.png +0 -0
- package/docs/assets/widgets@2x.png +0 -0
- package/docs/index.html +0 -5
- package/docs/interfaces/dateTime.IDuration.html +0 -1
- package/docs/interfaces/dom.IExtendingElementProps.html +0 -1
- package/docs/modules/browser.html +0 -29
- package/docs/modules/dateTime.html +0 -11
- package/docs/modules/dom.html +0 -52
- package/docs/modules/general.html +0 -16
- package/docs/modules/schedule.html +0 -13
- package/docs/modules/string.html +0 -32
- package/docs/modules.html +0 -1
- package/tsconfig.json +0 -19
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export * from './isPushNotificationSupported';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
1
|
+
export * from './isPushNotificationSupported.js';
|
|
2
|
+
export * from './isScrollBehaviorSupported.js';
|
|
3
|
+
export * from './isShareSupported.js';
|
|
4
|
+
export * from './isTabFocused.js';
|
|
5
|
+
export * from './isTouchSupported.js';
|
|
6
|
+
export * from './preferColorScheme.js';
|
|
7
|
+
export * from './tabFocusListener.js';
|
package/dist/browser/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export * from './isPushNotificationSupported';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
1
|
+
export * from './isPushNotificationSupported.js';
|
|
2
|
+
export * from './isScrollBehaviorSupported.js';
|
|
3
|
+
export * from './isShareSupported.js';
|
|
4
|
+
export * from './isTabFocused.js';
|
|
5
|
+
export * from './isTouchSupported.js';
|
|
6
|
+
export * from './preferColorScheme.js';
|
|
7
|
+
export * from './tabFocusListener.js';
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if user's browser supports setting scroll behavior
|
|
3
|
+
*
|
|
4
|
+
* @returns Boolean indicating if user's browser supports setting scroll behavior
|
|
5
|
+
*/
|
|
6
|
+
export const isScrollBehaviorSupported = () => !!('scrollBehavior' in document.documentElement.style);
|
|
7
|
+
//# sourceMappingURL=isScrollBehaviorSupported.js.map
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* @param blurCallback Function to be called when current browser tab goes out of focus
|
|
6
6
|
* @returns void
|
|
7
7
|
*/
|
|
8
|
-
export declare const tabFocusListener: (focusCallback?: (
|
|
8
|
+
export declare const tabFocusListener: (focusCallback?: () => void, blurCallback?: () => void) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isTabFocused } from './isTabFocused';
|
|
1
|
+
import { isTabFocused } from './isTabFocused.js';
|
|
2
2
|
/**
|
|
3
3
|
* Set callbacks for if current browser tab is in focus
|
|
4
4
|
*
|
|
@@ -9,10 +9,10 @@ import { isTabFocused } from './isTabFocused';
|
|
|
9
9
|
export const tabFocusListener = (focusCallback, blurCallback) => {
|
|
10
10
|
document.addEventListener('visibilitychange', () => {
|
|
11
11
|
if (isTabFocused()) {
|
|
12
|
-
focusCallback
|
|
12
|
+
focusCallback?.call(this);
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
|
-
blurCallback
|
|
15
|
+
blurCallback?.call(this);
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
};
|
package/dist/dateTime/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './interfaces';
|
|
2
|
-
export * from './dateAsIso';
|
|
3
|
-
export * from './parseDuration';
|
|
1
|
+
export * from './interfaces/index.js';
|
|
2
|
+
export * from './dateAsIso.js';
|
|
3
|
+
export * from './parseDuration.js';
|
package/dist/dateTime/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './interfaces';
|
|
2
|
-
export * from './dateAsIso';
|
|
3
|
-
export * from './parseDuration';
|
|
1
|
+
export * from './interfaces/index.js';
|
|
2
|
+
export * from './dateAsIso.js';
|
|
3
|
+
export * from './parseDuration.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './parseDuration';
|
|
1
|
+
export * from './parseDuration.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './parseDuration';
|
|
1
|
+
export * from './parseDuration.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/dom/appendAfter.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* @param referenceNode Reference node element
|
|
6
6
|
* @returns Result of the action
|
|
7
7
|
*/
|
|
8
|
-
export const appendAfter = (newNode, referenceNode) =>
|
|
8
|
+
export const appendAfter = (newNode, referenceNode) => !!referenceNode.parentElement?.insertBefore(newNode, referenceNode.nextSibling);
|
|
9
9
|
//# sourceMappingURL=appendAfter.js.map
|
package/dist/dom/appendBefore.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* @param referenceNode Reference node element
|
|
6
6
|
* @returns Result of the action
|
|
7
7
|
*/
|
|
8
|
-
export const appendBefore = (newNode, referenceNode) =>
|
|
8
|
+
export const appendBefore = (newNode, referenceNode) => !!referenceNode.parentElement?.insertBefore(newNode, referenceNode);
|
|
9
9
|
//# sourceMappingURL=appendBefore.js.map
|
package/dist/dom/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './interfaces';
|
|
2
|
-
export * from './addAsyncEventListener';
|
|
3
|
-
export * from './addClickOutsideListener';
|
|
4
|
-
export * from './addEventListener';
|
|
5
|
-
export * from './appendAfter';
|
|
6
|
-
export * from './appendBefore';
|
|
7
|
-
export * from './createElement';
|
|
8
|
-
export * from './fireEvent';
|
|
1
|
+
export * from './interfaces/index.js';
|
|
2
|
+
export * from './addAsyncEventListener.js';
|
|
3
|
+
export * from './addClickOutsideListener.js';
|
|
4
|
+
export * from './addEventListener.js';
|
|
5
|
+
export * from './appendAfter.js';
|
|
6
|
+
export * from './appendBefore.js';
|
|
7
|
+
export * from './createElement.js';
|
|
8
|
+
export * from './fireEvent.js';
|
package/dist/dom/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './interfaces';
|
|
2
|
-
export * from './addAsyncEventListener';
|
|
3
|
-
export * from './addClickOutsideListener';
|
|
4
|
-
export * from './addEventListener';
|
|
5
|
-
export * from './appendAfter';
|
|
6
|
-
export * from './appendBefore';
|
|
7
|
-
export * from './createElement';
|
|
8
|
-
export * from './fireEvent';
|
|
1
|
+
export * from './interfaces/index.js';
|
|
2
|
+
export * from './addAsyncEventListener.js';
|
|
3
|
+
export * from './addClickOutsideListener.js';
|
|
4
|
+
export * from './addEventListener.js';
|
|
5
|
+
export * from './appendAfter.js';
|
|
6
|
+
export * from './appendBefore.js';
|
|
7
|
+
export * from './createElement.js';
|
|
8
|
+
export * from './fireEvent.js';
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './createElement';
|
|
1
|
+
export * from './createElement.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './createElement';
|
|
1
|
+
export * from './createElement.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/general/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './isEmpty';
|
|
2
|
-
export * from './isNil';
|
|
3
|
-
export * from './isValidJson';
|
|
1
|
+
export * from './isEmpty.js';
|
|
2
|
+
export * from './isNil.js';
|
|
3
|
+
export * from './isValidJson.js';
|
package/dist/general/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './isEmpty';
|
|
2
|
-
export * from './isNil';
|
|
3
|
-
export * from './isValidJson';
|
|
1
|
+
export * from './isEmpty.js';
|
|
2
|
+
export * from './isNil.js';
|
|
3
|
+
export * from './isValidJson.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/general/isEmpty.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './browser';
|
|
2
|
-
export * from './dateTime';
|
|
3
|
-
export * from './dom';
|
|
4
|
-
export * from './general';
|
|
5
|
-
export * from './schedule';
|
|
6
|
-
export * from './string';
|
|
1
|
+
export * from './browser/index.js';
|
|
2
|
+
export * from './dateTime/index.js';
|
|
3
|
+
export * from './dom/index.js';
|
|
4
|
+
export * from './general/index.js';
|
|
5
|
+
export * from './schedule/index.js';
|
|
6
|
+
export * from './string/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './browser';
|
|
2
|
-
export * from './dateTime';
|
|
3
|
-
export * from './dom';
|
|
4
|
-
export * from './general';
|
|
5
|
-
export * from './schedule';
|
|
6
|
-
export * from './string';
|
|
1
|
+
export * from './browser/index.js';
|
|
2
|
+
export * from './dateTime/index.js';
|
|
3
|
+
export * from './dom/index.js';
|
|
4
|
+
export * from './general/index.js';
|
|
5
|
+
export * from './schedule/index.js';
|
|
6
|
+
export * from './string/index.js';
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/schedule/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './runAnimation';
|
|
2
|
-
export * from './runAsync';
|
|
1
|
+
export * from './runAnimation.js';
|
|
2
|
+
export * from './runAsync.js';
|
package/dist/schedule/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './runAnimation';
|
|
2
|
-
export * from './runAsync';
|
|
1
|
+
export * from './runAnimation.js';
|
|
2
|
+
export * from './runAsync.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/string/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './byteSize';
|
|
2
|
-
export * from './escapeHTML';
|
|
3
|
-
export * from './removeDiacritics';
|
|
4
|
-
export * from './slugify';
|
|
5
|
-
export * from './truncate';
|
|
1
|
+
export * from './byteSize.js';
|
|
2
|
+
export * from './escapeHTML.js';
|
|
3
|
+
export * from './removeDiacritics.js';
|
|
4
|
+
export * from './slugify.js';
|
|
5
|
+
export * from './truncate.js';
|
package/dist/string/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './byteSize';
|
|
2
|
-
export * from './escapeHTML';
|
|
3
|
-
export * from './removeDiacritics';
|
|
4
|
-
export * from './slugify';
|
|
5
|
-
export * from './truncate';
|
|
1
|
+
export * from './byteSize.js';
|
|
2
|
+
export * from './escapeHTML.js';
|
|
3
|
+
export * from './removeDiacritics.js';
|
|
4
|
+
export * from './slugify.js';
|
|
5
|
+
export * from './truncate.js';
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/string/slugify.js
CHANGED
package/package.json
CHANGED
|
@@ -1,29 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tool-shack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "Collection of usefull functions to ease work",
|
|
5
|
-
"
|
|
6
|
-
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "David Myška",
|
|
7
|
+
"url": "https://www.davidmyska.com/"
|
|
8
|
+
},
|
|
7
9
|
"license": "MIT",
|
|
8
10
|
"bugs": {
|
|
9
11
|
"url": "https://github.com/miskith/tool-shack/issues"
|
|
10
12
|
},
|
|
11
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://www.davidmyska.com/tool-shack/",
|
|
12
14
|
"repository": {
|
|
13
15
|
"type": "git",
|
|
14
16
|
"url": "git+https://github.com/miskith/tool-shack.git"
|
|
15
17
|
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"module": "dist/index.js",
|
|
20
|
+
"main": "dist/index.js",
|
|
21
|
+
"exports": {
|
|
22
|
+
"./package.json": {
|
|
23
|
+
"default": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist/**/*.js",
|
|
32
|
+
"dist/**/*.d.ts",
|
|
33
|
+
"src/**/*.ts"
|
|
34
|
+
],
|
|
16
35
|
"scripts": {
|
|
17
|
-
"build": "tsc -
|
|
36
|
+
"build": "rm -rf dist && tsc -b .",
|
|
18
37
|
"format": "pretty-quick",
|
|
19
|
-
"generate-docs": "typedoc --name \"Tool-Shack\" --readme README.md src/*/index.ts",
|
|
38
|
+
"generate-docs": "rm -rf docs && typedoc --name \"Tool-Shack\" --readme README.md src/*/index.ts",
|
|
20
39
|
"prepare": "husky install"
|
|
21
40
|
},
|
|
22
41
|
"devDependencies": {
|
|
23
|
-
"husky": "^
|
|
24
|
-
"prettier": "^2.
|
|
42
|
+
"husky": "^8.0.1",
|
|
43
|
+
"prettier": "^2.7.1",
|
|
25
44
|
"pretty-quick": "^3.1.3",
|
|
26
|
-
"typedoc": "^0.
|
|
27
|
-
"typescript": "^4.
|
|
45
|
+
"typedoc": "^0.23.5",
|
|
46
|
+
"typescript": "^4.7.4"
|
|
28
47
|
}
|
|
29
48
|
}
|
package/src/browser/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export * from './isPushNotificationSupported';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
1
|
+
export * from './isPushNotificationSupported.js';
|
|
2
|
+
export * from './isScrollBehaviorSupported.js';
|
|
3
|
+
export * from './isShareSupported.js';
|
|
4
|
+
export * from './isTabFocused.js';
|
|
5
|
+
export * from './isTouchSupported.js';
|
|
6
|
+
export * from './preferColorScheme.js';
|
|
7
|
+
export * from './tabFocusListener.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if user's browser supports push notifications
|
|
3
|
-
*
|
|
4
|
-
* @returns Boolean indicating if user's browser supports push notifications
|
|
5
|
-
*/
|
|
6
|
-
export const isPushNotificationSupported = (): boolean =>
|
|
7
|
-
!!(window.Notification || 'webkitNotifications' in window);
|
|
1
|
+
/**
|
|
2
|
+
* Check if user's browser supports push notifications
|
|
3
|
+
*
|
|
4
|
+
* @returns Boolean indicating if user's browser supports push notifications
|
|
5
|
+
*/
|
|
6
|
+
export const isPushNotificationSupported = (): boolean =>
|
|
7
|
+
!!(window.Notification || 'webkitNotifications' in window);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if user's browser supports setting scroll behavior
|
|
3
|
+
*
|
|
4
|
+
* @returns Boolean indicating if user's browser supports setting scroll behavior
|
|
5
|
+
*/
|
|
6
|
+
export const isScrollBehaviorSupported = (): boolean =>
|
|
7
|
+
!!('scrollBehavior' in document.documentElement.style);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if user's browser supports navigator share
|
|
3
|
-
*
|
|
4
|
-
* @returns Boolean indicating if user's browser supports navigator share
|
|
5
|
-
*/
|
|
6
|
-
export const isShareSupported = (): boolean =>
|
|
7
|
-
!!('navigator' in window && 'share' in window.navigator && !!navigator.share);
|
|
1
|
+
/**
|
|
2
|
+
* Check if user's browser supports navigator share
|
|
3
|
+
*
|
|
4
|
+
* @returns Boolean indicating if user's browser supports navigator share
|
|
5
|
+
*/
|
|
6
|
+
export const isShareSupported = (): boolean =>
|
|
7
|
+
!!('navigator' in window && 'share' in window.navigator && !!navigator.share);
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if user prefers light color scheme
|
|
3
|
-
*
|
|
4
|
-
* @returns Boolean indicating if user prefers light color scheme
|
|
5
|
-
*/
|
|
6
|
-
export const preferLightColorScheme = (): boolean =>
|
|
7
|
-
!!window.matchMedia('(prefers-color-scheme: light)').matches;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Check if user prefers dark color scheme
|
|
11
|
-
*
|
|
12
|
-
* @returns Boolean indicating if user prefers dark color scheme
|
|
13
|
-
*/
|
|
14
|
-
export const preferDarkColorScheme = (): boolean =>
|
|
15
|
-
!!window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Check what color scheme (light or dark) is prefered by user
|
|
19
|
-
*
|
|
20
|
-
* @returns String indicating prefered light color scheme ('light') or dark color scheme ('dark')
|
|
21
|
-
*/
|
|
22
|
-
export const preferColorScheme = (): 'light' | 'dark' =>
|
|
23
|
-
preferLightColorScheme() ? 'light' : 'dark';
|
|
1
|
+
/**
|
|
2
|
+
* Check if user prefers light color scheme
|
|
3
|
+
*
|
|
4
|
+
* @returns Boolean indicating if user prefers light color scheme
|
|
5
|
+
*/
|
|
6
|
+
export const preferLightColorScheme = (): boolean =>
|
|
7
|
+
!!window.matchMedia('(prefers-color-scheme: light)').matches;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Check if user prefers dark color scheme
|
|
11
|
+
*
|
|
12
|
+
* @returns Boolean indicating if user prefers dark color scheme
|
|
13
|
+
*/
|
|
14
|
+
export const preferDarkColorScheme = (): boolean =>
|
|
15
|
+
!!window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Check what color scheme (light or dark) is prefered by user
|
|
19
|
+
*
|
|
20
|
+
* @returns String indicating prefered light color scheme ('light') or dark color scheme ('dark')
|
|
21
|
+
*/
|
|
22
|
+
export const preferColorScheme = (): 'light' | 'dark' =>
|
|
23
|
+
preferLightColorScheme() ? 'light' : 'dark';
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Return date in ISO format with timezone
|
|
3
|
-
*
|
|
4
|
-
* @param date Date to be converted
|
|
5
|
-
* @returns ISO format with timezone
|
|
6
|
-
*/
|
|
7
|
-
export const dateAsIso = (date: Date) => {
|
|
8
|
-
const timezoneOffset = date.getTimezoneOffset();
|
|
9
|
-
|
|
10
|
-
let isoFormat = '';
|
|
11
|
-
isoFormat += `${date.getFullYear()}-${padNumber(date.getMonth() + 1)}-${padNumber(
|
|
12
|
-
date.getDate(),
|
|
13
|
-
)}`;
|
|
14
|
-
isoFormat += `T${padNumber(date.getHours())}:${padNumber(date.getMinutes())}:${padNumber(
|
|
15
|
-
date.getSeconds(),
|
|
16
|
-
)}`;
|
|
17
|
-
isoFormat += `${timezoneOffset <= 0 ? '+' : '-'}${padNumber(
|
|
18
|
-
Math.floor(Math.abs(timezoneOffset) / 60),
|
|
19
|
-
)}:${padNumber(Math.abs(timezoneOffset) % 60)}`;
|
|
20
|
-
|
|
21
|
-
return isoFormat;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const padNumber = (number: number): string => `${number}`.padStart(2, '0');
|
|
1
|
+
/**
|
|
2
|
+
* Return date in ISO format with timezone
|
|
3
|
+
*
|
|
4
|
+
* @param date Date to be converted
|
|
5
|
+
* @returns ISO format with timezone
|
|
6
|
+
*/
|
|
7
|
+
export const dateAsIso = (date: Date) => {
|
|
8
|
+
const timezoneOffset = date.getTimezoneOffset();
|
|
9
|
+
|
|
10
|
+
let isoFormat = '';
|
|
11
|
+
isoFormat += `${date.getFullYear()}-${padNumber(date.getMonth() + 1)}-${padNumber(
|
|
12
|
+
date.getDate(),
|
|
13
|
+
)}`;
|
|
14
|
+
isoFormat += `T${padNumber(date.getHours())}:${padNumber(date.getMinutes())}:${padNumber(
|
|
15
|
+
date.getSeconds(),
|
|
16
|
+
)}`;
|
|
17
|
+
isoFormat += `${timezoneOffset <= 0 ? '+' : '-'}${padNumber(
|
|
18
|
+
Math.floor(Math.abs(timezoneOffset) / 60),
|
|
19
|
+
)}:${padNumber(Math.abs(timezoneOffset) % 60)}`;
|
|
20
|
+
|
|
21
|
+
return isoFormat;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const padNumber = (number: number): string => `${number}`.padStart(2, '0');
|
package/src/dateTime/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './interfaces';
|
|
2
|
-
|
|
3
|
-
export * from './dateAsIso';
|
|
4
|
-
export * from './parseDuration';
|
|
1
|
+
export * from './interfaces/index.js';
|
|
2
|
+
|
|
3
|
+
export * from './dateAsIso.js';
|
|
4
|
+
export * from './parseDuration.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './parseDuration';
|
|
1
|
+
export * from './parseDuration.js';
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Listen to events fired on elements that may currently not exist in the DOM
|
|
3
|
-
*
|
|
4
|
-
* @param elementSelector Selector for element(s) to match event target
|
|
5
|
-
* @param listeners List of event types and related callback(s)
|
|
6
|
-
* @param acceptBubbling Boolean switch to allow bubbling or accept only direct element match
|
|
7
|
-
* @returns void
|
|
8
|
-
*/
|
|
9
|
-
export const addAsyncEventListener = (
|
|
10
|
-
elementSelector: string,
|
|
11
|
-
listeners: Record<string, EventListener | EventListener[]>,
|
|
12
|
-
acceptBubbling = true,
|
|
13
|
-
): void => {
|
|
14
|
-
for (let eventName in listeners) {
|
|
15
|
-
const functionList = (
|
|
16
|
-
listeners[eventName] instanceof Array ? listeners[eventName] : [listeners[eventName]]
|
|
17
|
-
) as EventListener[];
|
|
18
|
-
|
|
19
|
-
functionList.forEach((fn: EventListener) =>
|
|
20
|
-
document.addEventListener(eventName, (event: Event) => {
|
|
21
|
-
const target = event.target as HTMLElement;
|
|
22
|
-
if (!target) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (!acceptBubbling && target.matches(elementSelector)) {
|
|
27
|
-
fn.call(this, event);
|
|
28
|
-
} else if (acceptBubbling && target.closest(elementSelector)) {
|
|
29
|
-
fn.call(this, event);
|
|
30
|
-
}
|
|
31
|
-
}),
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Listen to events fired on elements that may currently not exist in the DOM
|
|
3
|
+
*
|
|
4
|
+
* @param elementSelector Selector for element(s) to match event target
|
|
5
|
+
* @param listeners List of event types and related callback(s)
|
|
6
|
+
* @param acceptBubbling Boolean switch to allow bubbling or accept only direct element match
|
|
7
|
+
* @returns void
|
|
8
|
+
*/
|
|
9
|
+
export const addAsyncEventListener = (
|
|
10
|
+
elementSelector: string,
|
|
11
|
+
listeners: Record<string, EventListener | EventListener[]>,
|
|
12
|
+
acceptBubbling = true,
|
|
13
|
+
): void => {
|
|
14
|
+
for (let eventName in listeners) {
|
|
15
|
+
const functionList = (
|
|
16
|
+
listeners[eventName] instanceof Array ? listeners[eventName] : [listeners[eventName]]
|
|
17
|
+
) as EventListener[];
|
|
18
|
+
|
|
19
|
+
functionList.forEach((fn: EventListener) =>
|
|
20
|
+
document.addEventListener(eventName, (event: Event) => {
|
|
21
|
+
const target = event.target as HTMLElement;
|
|
22
|
+
if (!target) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!acceptBubbling && target.matches(elementSelector)) {
|
|
27
|
+
fn.call(this, event);
|
|
28
|
+
} else if (acceptBubbling && target.closest(elementSelector)) {
|
|
29
|
+
fn.call(this, event);
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
};
|