tool-shack 0.0.22 → 0.0.24
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/README.md +0 -0
- package/dist/browser/preferColorScheme.d.ts +1 -1
- package/dist/dom/createElement.d.ts +1 -1
- package/dist/dom/createElement.js +15 -10
- package/dist/dom/interfaces/createElement.d.ts +1 -1
- package/package.json +7 -7
- package/src/browser/interfaces/isTouchSupported.ts +0 -0
- package/src/browser/isPushNotificationSupported.ts +0 -0
- package/src/browser/isScrollBehaviorSupported.ts +0 -0
- package/src/browser/isShareSupported.ts +0 -0
- package/src/browser/isTabFocused.ts +0 -0
- package/src/browser/isTouchSupported.ts +0 -0
- package/src/browser/preferColorScheme.ts +0 -0
- package/src/browser/tabFocusListener.ts +0 -0
- package/src/dateTime/dateAsIso.ts +0 -0
- package/src/dateTime/index.ts +0 -0
- package/src/dateTime/interfaces/index.ts +0 -0
- package/src/dateTime/interfaces/parseDuration.ts +0 -0
- package/src/dateTime/parseDuration.ts +0 -0
- package/src/dom/addAsyncEventListener.ts +0 -0
- package/src/dom/addClickOutsideListener.ts +0 -0
- package/src/dom/addEventListener.ts +0 -0
- package/src/dom/appendAfter.ts +0 -0
- package/src/dom/appendBefore.ts +0 -0
- package/src/dom/createElement.ts +14 -10
- package/src/dom/fireEvent.ts +0 -0
- package/src/dom/interfaces/createElement.ts +1 -1
- package/src/dom/interfaces/index.ts +0 -0
- package/src/general/index.ts +0 -0
- package/src/general/isEmpty.ts +0 -0
- package/src/general/isNil.ts +0 -0
- package/src/general/isValidJson.ts +0 -0
- package/src/index.ts +0 -0
- package/src/schedule/index.ts +0 -0
- package/src/schedule/runAnimation.ts +0 -0
- package/src/schedule/runAsync.ts +0 -0
- package/src/string/byteSize.ts +0 -0
- package/src/string/escapeHTML.ts +0 -0
- package/src/string/index.ts +0 -0
- package/src/string/removeDiacritics.ts +0 -0
- package/src/string/slugify.ts +0 -0
- package/src/string/truncate.ts +0 -0
package/README.md
CHANGED
|
File without changes
|
|
@@ -15,4 +15,4 @@ export declare const preferDarkColorScheme: () => boolean;
|
|
|
15
15
|
*
|
|
16
16
|
* @returns String indicating prefered light color scheme ('light') or dark color scheme ('dark')
|
|
17
17
|
*/
|
|
18
|
-
export declare const preferColorScheme: () =>
|
|
18
|
+
export declare const preferColorScheme: () => "light" | "dark";
|
|
@@ -6,4 +6,4 @@ import { IExtendingElementProps } from './interfaces/createElement.js';
|
|
|
6
6
|
* @param props List of attributes, event listeners or/and children to assign to the newly created element
|
|
7
7
|
* @returns Resulting Node element
|
|
8
8
|
*/
|
|
9
|
-
export declare const createElement: <T = HTMLElement>(tagName: string, props?:
|
|
9
|
+
export declare const createElement: <T = HTMLElement>(tagName: string, props?: Partial<Omit<T, "children" | "dataset" | "style">> & IExtendingElementProps) => T;
|
|
@@ -14,17 +14,24 @@ export const createElement = (tagName, props) => {
|
|
|
14
14
|
element.setAttribute(key, value);
|
|
15
15
|
}
|
|
16
16
|
else if (key === 'aria') {
|
|
17
|
-
for (
|
|
18
|
-
element.setAttribute(`aria-${ariaKey}`,
|
|
17
|
+
for (const [ariaKey, ariaValue] of Object.entries(props.aria)) {
|
|
18
|
+
element.setAttribute(`aria-${ariaKey}`, ariaValue);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
else if (
|
|
22
|
-
|
|
23
|
-
element.style[styleKey] = value[styleKey];
|
|
24
|
-
}
|
|
21
|
+
else if (props.style) {
|
|
22
|
+
Object.assign(element.style, props.style);
|
|
25
23
|
}
|
|
26
24
|
else if (key === 'children') {
|
|
27
|
-
|
|
25
|
+
const fragment = document.createDocumentFragment();
|
|
26
|
+
for (const child of props.children) {
|
|
27
|
+
if (typeof child === 'string') {
|
|
28
|
+
fragment.appendChild(document.createTextNode(child));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
fragment.appendChild(child);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
element.appendChild(fragment);
|
|
28
35
|
}
|
|
29
36
|
else if (key === 'listeners') {
|
|
30
37
|
for (let eventName in props.listeners) {
|
|
@@ -35,9 +42,7 @@ export const createElement = (tagName, props) => {
|
|
|
35
42
|
}
|
|
36
43
|
}
|
|
37
44
|
else if (key === 'dataset') {
|
|
38
|
-
|
|
39
|
-
element.dataset[datasetKey] = props.dataset[datasetKey];
|
|
40
|
-
}
|
|
45
|
+
Object.assign(element.dataset, props.dataset);
|
|
41
46
|
}
|
|
42
47
|
else {
|
|
43
48
|
element[key] = value;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type TAriaLabelKey = 'atomic' | 'busy' | 'controls' | 'current' | 'describedby' | 'details' | 'disables' | 'dropeffect' | 'errormessage' | 'expanded' | 'flowto' | 'grabbed' | 'haspopup' | 'hidden' | 'invalid' | 'keyshortcuts' | 'label' | 'labelledby' | 'live' | 'modal' | 'owns' | 'relevant' | 'roledescription';
|
|
2
2
|
export interface IExtendingElementProps {
|
|
3
|
-
children?: HTMLElement[];
|
|
3
|
+
children?: (HTMLElement | string)[];
|
|
4
4
|
listeners?: Record<string, EventListenerOrEventListenerObject | EventListenerOrEventListenerObject[]>;
|
|
5
5
|
role?: string;
|
|
6
6
|
aria?: Partial<Record<TAriaLabelKey, string>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tool-shack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "Collection of usefull functions to ease work",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "David Myška",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"build": "rm -rf dist && tsc -b .",
|
|
38
38
|
"format": "pretty-quick",
|
|
39
39
|
"generate-docs": "rm -rf docs && typedoc --name \"Tool-Shack\" --readme README.md src/*/index.ts",
|
|
40
|
-
"prepare": "husky
|
|
40
|
+
"prepare": "husky"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"husky": "^
|
|
44
|
-
"prettier": "^
|
|
45
|
-
"pretty-quick": "^
|
|
46
|
-
"typedoc": "^0.
|
|
47
|
-
"typescript": "^5.
|
|
43
|
+
"husky": "^9.1.7",
|
|
44
|
+
"prettier": "^3.3.3",
|
|
45
|
+
"pretty-quick": "^4.0.0",
|
|
46
|
+
"typedoc": "^0.26.11",
|
|
47
|
+
"typescript": "^5.6.3"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/dateTime/index.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/dom/appendAfter.ts
CHANGED
|
File without changes
|
package/src/dom/appendBefore.ts
CHANGED
|
File without changes
|
package/src/dom/createElement.ts
CHANGED
|
@@ -20,15 +20,21 @@ export const createElement = <T = HTMLElement>(
|
|
|
20
20
|
if (key === 'role') {
|
|
21
21
|
element.setAttribute(key, value);
|
|
22
22
|
} else if (key === 'aria') {
|
|
23
|
-
for (
|
|
24
|
-
element.setAttribute(`aria-${ariaKey}`,
|
|
25
|
-
}
|
|
26
|
-
} else if (key === 'style') {
|
|
27
|
-
for (let styleKey in props.style!) {
|
|
28
|
-
(element.style as any)[styleKey] = value[styleKey];
|
|
23
|
+
for (const [ariaKey, ariaValue] of Object.entries(props.aria!)) {
|
|
24
|
+
element.setAttribute(`aria-${ariaKey}`, ariaValue);
|
|
29
25
|
}
|
|
26
|
+
} else if (props.style) {
|
|
27
|
+
Object.assign(element.style, props.style);
|
|
30
28
|
} else if (key === 'children') {
|
|
31
|
-
|
|
29
|
+
const fragment = document.createDocumentFragment();
|
|
30
|
+
for (const child of props.children!) {
|
|
31
|
+
if (typeof child === 'string') {
|
|
32
|
+
fragment.appendChild(document.createTextNode(child));
|
|
33
|
+
} else {
|
|
34
|
+
fragment.appendChild(child);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
element.appendChild(fragment);
|
|
32
38
|
} else if (key === 'listeners') {
|
|
33
39
|
for (let eventName in props.listeners!) {
|
|
34
40
|
const functionList = (
|
|
@@ -42,9 +48,7 @@ export const createElement = <T = HTMLElement>(
|
|
|
42
48
|
);
|
|
43
49
|
}
|
|
44
50
|
} else if (key === 'dataset') {
|
|
45
|
-
|
|
46
|
-
element.dataset[datasetKey] = props.dataset[datasetKey];
|
|
47
|
-
}
|
|
51
|
+
Object.assign(element.dataset, props.dataset);
|
|
48
52
|
} else {
|
|
49
53
|
(element as any)[key] = value;
|
|
50
54
|
}
|
package/src/dom/fireEvent.ts
CHANGED
|
File without changes
|
|
@@ -24,7 +24,7 @@ export type TAriaLabelKey =
|
|
|
24
24
|
| 'roledescription';
|
|
25
25
|
|
|
26
26
|
export interface IExtendingElementProps {
|
|
27
|
-
children?: HTMLElement[];
|
|
27
|
+
children?: (HTMLElement | string)[];
|
|
28
28
|
listeners?: Record<
|
|
29
29
|
string,
|
|
30
30
|
EventListenerOrEventListenerObject | EventListenerOrEventListenerObject[]
|
|
File without changes
|
package/src/general/index.ts
CHANGED
|
File without changes
|
package/src/general/isEmpty.ts
CHANGED
|
File without changes
|
package/src/general/isNil.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/src/index.ts
CHANGED
|
File without changes
|
package/src/schedule/index.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/src/schedule/runAsync.ts
CHANGED
|
File without changes
|
package/src/string/byteSize.ts
CHANGED
|
File without changes
|
package/src/string/escapeHTML.ts
CHANGED
|
File without changes
|
package/src/string/index.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/src/string/slugify.ts
CHANGED
|
File without changes
|
package/src/string/truncate.ts
CHANGED
|
File without changes
|