tool-shack 0.0.27 → 0.0.28

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.
Files changed (39) hide show
  1. package/README.md +0 -0
  2. package/dist/dom/interfaces/createElement.d.ts +1 -1
  3. package/package.json +3 -2
  4. package/src/browser/interfaces/isTouchSupported.ts +0 -0
  5. package/src/browser/isPushNotificationSupported.ts +0 -0
  6. package/src/browser/isScrollBehaviorSupported.ts +0 -0
  7. package/src/browser/isShareSupported.ts +0 -0
  8. package/src/browser/isTabFocused.ts +0 -0
  9. package/src/browser/isTouchSupported.ts +0 -0
  10. package/src/browser/preferColorScheme.ts +0 -0
  11. package/src/browser/tabFocusListener.ts +0 -0
  12. package/src/dateTime/dateAsIso.ts +0 -0
  13. package/src/dateTime/index.ts +0 -0
  14. package/src/dateTime/interfaces/index.ts +0 -0
  15. package/src/dateTime/interfaces/parseDuration.ts +0 -0
  16. package/src/dateTime/parseDuration.ts +0 -0
  17. package/src/dom/addAsyncEventListener.ts +0 -0
  18. package/src/dom/addClickOutsideListener.ts +0 -0
  19. package/src/dom/addEventListener.ts +0 -0
  20. package/src/dom/appendAfter.ts +0 -0
  21. package/src/dom/appendBefore.ts +0 -0
  22. package/src/dom/createElement.ts +59 -59
  23. package/src/dom/fireEvent.ts +0 -0
  24. package/src/dom/interfaces/createElement.ts +36 -36
  25. package/src/dom/interfaces/index.ts +0 -0
  26. package/src/general/index.ts +0 -0
  27. package/src/general/isEmpty.ts +0 -0
  28. package/src/general/isNil.ts +0 -0
  29. package/src/general/isValidJson.ts +0 -0
  30. package/src/index.ts +0 -0
  31. package/src/schedule/index.ts +0 -0
  32. package/src/schedule/runAnimation.ts +0 -0
  33. package/src/schedule/runAsync.ts +0 -0
  34. package/src/string/byteSize.ts +0 -0
  35. package/src/string/escapeHTML.ts +0 -0
  36. package/src/string/index.ts +0 -0
  37. package/src/string/removeDiacritics.ts +0 -0
  38. package/src/string/slugify.ts +0 -0
  39. package/src/string/truncate.ts +0 -0
package/README.md CHANGED
File without changes
@@ -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 | string)[];
3
+ children?: (HTMLElement | string | SVGElement)[];
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.27",
3
+ "version": "0.0.28",
4
4
  "description": "Collection of usefull functions to ease work",
5
5
  "author": {
6
6
  "name": "David Myška",
@@ -45,5 +45,6 @@
45
45
  "pretty-quick": "^4.0.0",
46
46
  "typedoc": "^0.26.11",
47
47
  "typescript": "^5.6.3"
48
- }
48
+ },
49
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
49
50
  }
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
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
@@ -1,59 +1,59 @@
1
- import { IExtendingElementProps } from './interfaces/createElement.js';
2
-
3
- /**
4
- * Method for creating Node element and assigning multiple parameters, event listeners & children in one method call
5
- *
6
- * @param tagName Node tag name
7
- * @param props List of attributes, event listeners or/and children to assign to the newly created element
8
- * @returns Resulting Node element
9
- */
10
- export const createElement = <T = HTMLElement>(
11
- tagName: string,
12
- props?: Partial<Omit<T, 'children' | 'dataset' | 'style'>> & IExtendingElementProps,
13
- ): T => {
14
- const element: HTMLElement = document.createElement(tagName);
15
-
16
- if (props) {
17
- for (let key in props) {
18
- const value = (props as any)[key];
19
-
20
- if (key === 'role') {
21
- element.setAttribute(key, value);
22
- } else if (key === 'aria') {
23
- for (const [ariaKey, ariaValue] of Object.entries(props.aria!)) {
24
- element.setAttribute(`aria-${ariaKey}`, ariaValue);
25
- }
26
- } else if (key === 'style') {
27
- Object.assign(element.style, props.style);
28
- } else if (key === 'children') {
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);
38
- } else if (key === 'listeners') {
39
- for (let eventName in props.listeners!) {
40
- const functionList = (
41
- props.listeners![eventName] instanceof Array
42
- ? props.listeners![eventName]
43
- : [props.listeners![eventName]]
44
- ) as EventListenerOrEventListenerObject[];
45
-
46
- functionList.forEach((fn: EventListenerOrEventListenerObject) =>
47
- element.addEventListener(eventName, fn),
48
- );
49
- }
50
- } else if (key === 'dataset') {
51
- Object.assign(element.dataset, props.dataset);
52
- } else {
53
- (element as any)[key] = value;
54
- }
55
- }
56
- }
57
-
58
- return element as unknown as T;
59
- };
1
+ import { IExtendingElementProps } from './interfaces/createElement.js';
2
+
3
+ /**
4
+ * Method for creating Node element and assigning multiple parameters, event listeners & children in one method call
5
+ *
6
+ * @param tagName Node tag name
7
+ * @param props List of attributes, event listeners or/and children to assign to the newly created element
8
+ * @returns Resulting Node element
9
+ */
10
+ export const createElement = <T = HTMLElement>(
11
+ tagName: string,
12
+ props?: Partial<Omit<T, 'children' | 'dataset' | 'style'>> & IExtendingElementProps,
13
+ ): T => {
14
+ const element: HTMLElement = document.createElement(tagName);
15
+
16
+ if (props) {
17
+ for (let key in props) {
18
+ const value = (props as any)[key];
19
+
20
+ if (key === 'role') {
21
+ element.setAttribute(key, value);
22
+ } else if (key === 'aria') {
23
+ for (const [ariaKey, ariaValue] of Object.entries(props.aria!)) {
24
+ element.setAttribute(`aria-${ariaKey}`, ariaValue);
25
+ }
26
+ } else if (key === 'style') {
27
+ Object.assign(element.style, props.style);
28
+ } else if (key === 'children') {
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);
38
+ } else if (key === 'listeners') {
39
+ for (let eventName in props.listeners!) {
40
+ const functionList = (
41
+ props.listeners![eventName] instanceof Array
42
+ ? props.listeners![eventName]
43
+ : [props.listeners![eventName]]
44
+ ) as EventListenerOrEventListenerObject[];
45
+
46
+ functionList.forEach((fn: EventListenerOrEventListenerObject) =>
47
+ element.addEventListener(eventName, fn),
48
+ );
49
+ }
50
+ } else if (key === 'dataset') {
51
+ Object.assign(element.dataset, props.dataset);
52
+ } else {
53
+ (element as any)[key] = value;
54
+ }
55
+ }
56
+ }
57
+
58
+ return element as unknown as T;
59
+ };
File without changes
@@ -1,36 +1,36 @@
1
- export type TAriaLabelKey =
2
- | 'atomic'
3
- | 'busy'
4
- | 'controls'
5
- | 'current'
6
- | 'describedby'
7
- | 'details'
8
- | 'disables'
9
- | 'dropeffect'
10
- | 'errormessage'
11
- | 'expanded'
12
- | 'flowto'
13
- | 'grabbed'
14
- | 'haspopup'
15
- | 'hidden'
16
- | 'invalid'
17
- | 'keyshortcuts'
18
- | 'label'
19
- | 'labelledby'
20
- | 'live'
21
- | 'modal'
22
- | 'owns'
23
- | 'relevant'
24
- | 'roledescription';
25
-
26
- export interface IExtendingElementProps {
27
- children?: (HTMLElement | string)[];
28
- listeners?: Record<
29
- string,
30
- EventListenerOrEventListenerObject | EventListenerOrEventListenerObject[]
31
- >;
32
- role?: string;
33
- aria?: Partial<Record<TAriaLabelKey, string>>;
34
- dataset?: Record<string, string>;
35
- style?: Record<string, string | number>;
36
- }
1
+ export type TAriaLabelKey =
2
+ | 'atomic'
3
+ | 'busy'
4
+ | 'controls'
5
+ | 'current'
6
+ | 'describedby'
7
+ | 'details'
8
+ | 'disables'
9
+ | 'dropeffect'
10
+ | 'errormessage'
11
+ | 'expanded'
12
+ | 'flowto'
13
+ | 'grabbed'
14
+ | 'haspopup'
15
+ | 'hidden'
16
+ | 'invalid'
17
+ | 'keyshortcuts'
18
+ | 'label'
19
+ | 'labelledby'
20
+ | 'live'
21
+ | 'modal'
22
+ | 'owns'
23
+ | 'relevant'
24
+ | 'roledescription';
25
+
26
+ export interface IExtendingElementProps {
27
+ children?: (HTMLElement | string | SVGElement)[];
28
+ listeners?: Record<
29
+ string,
30
+ EventListenerOrEventListenerObject | EventListenerOrEventListenerObject[]
31
+ >;
32
+ role?: string;
33
+ aria?: Partial<Record<TAriaLabelKey, string>>;
34
+ dataset?: Record<string, string>;
35
+ style?: Record<string, string | number>;
36
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
package/src/index.ts CHANGED
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
File without changes