danholibraryjs 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +2 -2
- package/README.md +12 -345
- package/Time.xlsx +0 -0
- package/dist/Classes/{Event.d.ts → Events/Event.d.ts} +9 -8
- package/dist/Classes/{Event.js → Events/Event.js} +17 -9
- package/dist/Classes/{EventCollection.d.ts → Events/EventCollection.d.ts} +9 -10
- package/dist/Classes/{EventCollection.js → Events/EventCollection.js} +27 -29
- package/dist/Classes/{EventEmitter.d.ts → Events/EventEmitter.d.ts} +5 -6
- package/dist/Classes/{EventEmitter.js → Events/EventEmitter.js} +6 -3
- package/dist/Classes/Events/index.d.ts +3 -0
- package/dist/Classes/Events/index.js +19 -0
- package/dist/Classes/Time/Date.d.ts +147 -0
- package/dist/Classes/Time/Date.js +238 -0
- package/dist/Classes/Time/Time.d.ts +65 -0
- package/dist/Classes/Time/Time.js +117 -0
- package/dist/Classes/Time/TimeProperties.d.ts +3 -0
- package/dist/{Interfaces/BaseEventInterface.js → Classes/Time/TimeProperties.js} +0 -0
- package/dist/Classes/Time/TimeSpan.d.ts +123 -0
- package/dist/Classes/Time/TimeSpan.js +179 -0
- package/dist/Classes/Time/index.d.ts +4 -0
- package/dist/Classes/Time/index.js +20 -0
- package/dist/Classes/index.d.ts +2 -3
- package/dist/Classes/index.js +7 -4
- package/dist/Extensions/Array.d.ts +31 -0
- package/dist/Extensions/Array.js +26 -0
- package/dist/Extensions/Map.d.ts +38 -0
- package/dist/Extensions/Map.js +31 -0
- package/dist/Extensions/Object.d.ts +16 -0
- package/dist/Extensions/Object.js +8 -0
- package/dist/Extensions/String.d.ts +26 -0
- package/dist/Extensions/String.js +17 -0
- package/dist/Extensions/index.d.ts +29 -0
- package/dist/Extensions/index.js +71 -0
- package/dist/Functions/GetCSSProperty.d.ts +15 -0
- package/dist/Functions/GetCSSProperty.js +26 -0
- package/dist/Functions/HTMLEvent.d.ts +6 -0
- package/dist/Functions/HTMLEvent.js +6 -0
- package/dist/Functions/SetNavigationSelected.js +2 -0
- package/dist/Functions/index.d.ts +1 -0
- package/dist/Functions/index.js +6 -1
- package/dist/Interfaces/ElementOptions.d.ts +9 -14
- package/dist/Interfaces/IReplacement.d.ts +1 -1
- package/dist/Interfaces/index.d.ts +0 -1
- package/dist/Interfaces/index.js +5 -2
- package/dist/Types/BetterTypes.d.ts +9 -0
- package/dist/{Interfaces/IHTMLEvent.js → Types/BetterTypes.js} +0 -0
- package/dist/Types/Date.d.ts +6 -0
- package/dist/Types/{EventHandler.js → Date.js} +0 -0
- package/dist/Types/Events.d.ts +10 -0
- package/dist/Types/{IElement.js → Events.js} +0 -0
- package/dist/Types/PropertiesWith.d.ts +13 -0
- package/dist/Types/{StringRegex.js → PropertiesWith.js} +0 -0
- package/dist/Types/TransformTypes.d.ts +13 -0
- package/dist/Types/TransformTypes.js +2 -0
- package/dist/Types/index.d.ts +31 -3
- package/dist/Types/index.js +10 -4
- package/dist/index.d.ts +5 -5
- package/dist/index.js +19 -10
- package/docs/Classes.md +455 -0
- package/docs/Extensions.md +146 -0
- package/docs/Functions.md +53 -0
- package/docs/Interfaces.md +34 -0
- package/docs/Types.md +129 -0
- package/docs/index.md +29 -0
- package/package.json +22 -21
- package/src/Classes/{Event.ts → Events/Event.ts} +19 -14
- package/src/Classes/Events/EventCollection.ts +109 -0
- package/src/Classes/{EventEmitter.ts → Events/EventEmitter.ts} +9 -10
- package/src/Classes/Events/index.ts +3 -0
- package/src/Classes/Time/Date.ts +264 -0
- package/src/Classes/Time/Time.ts +134 -0
- package/src/Classes/Time/TimeProperties.ts +3 -0
- package/src/Classes/Time/TimeSpan.ts +195 -0
- package/src/Classes/Time/index.ts +4 -0
- package/src/Classes/index.ts +2 -3
- package/src/Extensions/Array.ts +57 -0
- package/src/Extensions/Map.ts +73 -0
- package/src/Extensions/Object.ts +25 -0
- package/src/Extensions/String.ts +43 -0
- package/src/Extensions/index.ts +83 -0
- package/src/Functions/GetCSSProperty.ts +27 -0
- package/src/Functions/HTMLEvent.ts +6 -0
- package/src/Functions/SetNavigationSelected.ts +1 -0
- package/src/Functions/index.ts +2 -1
- package/src/Interfaces/ElementOptions.ts +15 -12
- package/src/Interfaces/IReplacement.ts +1 -1
- package/src/Interfaces/index.ts +1 -2
- package/src/Types/BetterTypes.ts +10 -0
- package/src/Types/Date.ts +7 -0
- package/src/Types/Events.ts +15 -0
- package/src/Types/PropertiesWith.ts +14 -0
- package/src/Types/TransformTypes.ts +18 -0
- package/src/Types/index.ts +36 -3
- package/src/index.ts +5 -6
- package/tsconfig.json +99 -7
- package/dist/Extensions.d.ts +0 -96
- package/dist/Extensions.js +0 -90
- package/dist/Interfaces/BaseEventInterface.d.ts +0 -7
- package/dist/Interfaces/IHTMLEvent.d.ts +0 -4
- package/dist/Types/EventHandler.d.ts +0 -8
- package/dist/Types/IElement.d.ts +0 -9
- package/dist/Types/StringRegex.d.ts +0 -2
- package/src/Classes/EventCollection.ts +0 -117
- package/src/Extensions.ts +0 -202
- package/src/Interfaces/BaseEventInterface.ts +0 -7
- package/src/Types/EventHandler.ts +0 -13
- package/src/Types/IElement.ts +0 -9
- package/src/Types/StringRegex.ts +0 -2
- package/test.js +0 -20
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetCSSProperty = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Gets the value of "property" in type "type" from query "query"
|
|
6
|
+
* Basically, you can get your --color-primary from :root
|
|
7
|
+
*
|
|
8
|
+
* @param property Name of the property to get
|
|
9
|
+
* @param type Type of the property to parse
|
|
10
|
+
* @param query Query to get the element that has the property
|
|
11
|
+
* @returns Property value converted to type
|
|
12
|
+
*/
|
|
13
|
+
function GetCSSProperty(property, type, query = ":root") {
|
|
14
|
+
const rootEl = document.querySelector(query);
|
|
15
|
+
if (!rootEl)
|
|
16
|
+
throw new Error(`${query} does not exist!`);
|
|
17
|
+
const rootStyles = getComputedStyle(rootEl);
|
|
18
|
+
const cssProp = rootStyles.getPropertyValue(property);
|
|
19
|
+
if (type === 'string')
|
|
20
|
+
return cssProp;
|
|
21
|
+
const numberValue = parseInt(cssProp);
|
|
22
|
+
if (isNaN(numberValue))
|
|
23
|
+
throw new Error(`${property} is not a number!: ${cssProp}`);
|
|
24
|
+
return numberValue;
|
|
25
|
+
}
|
|
26
|
+
exports.GetCSSProperty = GetCSSProperty;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create HTMLEvent object from function
|
|
3
|
+
* @param name Name of the event
|
|
4
|
+
* @param handler Handler for the event
|
|
5
|
+
* @returns Parameters as object
|
|
6
|
+
*/
|
|
1
7
|
export declare function HTMLEvent<Event extends keyof HTMLElementEventMap, ReturnType extends any>(name: Event, handler: (event: HTMLElementEventMap[Event]) => ReturnType): {
|
|
2
8
|
name: Event;
|
|
3
9
|
handler: (event: HTMLElementEventMap[Event]) => ReturnType;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HTMLEvent = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Create HTMLEvent object from function
|
|
6
|
+
* @param name Name of the event
|
|
7
|
+
* @param handler Handler for the event
|
|
8
|
+
* @returns Parameters as object
|
|
9
|
+
*/
|
|
4
10
|
function HTMLEvent(name, handler) {
|
|
5
11
|
return { name, handler };
|
|
6
12
|
}
|
|
@@ -10,6 +10,8 @@ exports.SetNavigationSelected = void 0;
|
|
|
10
10
|
*/
|
|
11
11
|
function SetNavigationSelected(query, ...currentPageClasses) {
|
|
12
12
|
const header = document.querySelector(query);
|
|
13
|
+
if (!header)
|
|
14
|
+
throw { message: `Couldn't find header from query, ${query}` };
|
|
13
15
|
const children = header.children.array().filter(c => c.tagName === 'a');
|
|
14
16
|
const currentPage = document.location.href;
|
|
15
17
|
children.forEach(gc => {
|
package/dist/Functions/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,5 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
17
|
__exportStar(require("./CopyToClipboard"), exports);
|
|
18
|
+
__exportStar(require("./GetCSSProperty"), exports);
|
|
14
19
|
__exportStar(require("./SetNavigationSelected"), exports);
|
|
15
20
|
__exportStar(require("./HTMLEvent"), exports);
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import IElement from "../Types
|
|
1
|
+
import { Arrayable, IElement } from "../Types";
|
|
2
|
+
declare type Events = Record<`on${Capitalize<keyof HTMLElementEventMap>}`, (event: Event) => void>;
|
|
2
3
|
/**
|
|
3
4
|
* Construction options when creating an HTML element using:
|
|
4
5
|
* @see Document.createProperElement
|
|
5
6
|
* @borwwos IElement
|
|
7
|
+
* @borrows Arrayable
|
|
6
8
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
children?: IElement | IElement[];
|
|
14
|
-
/**Events for the element to listen to*/
|
|
15
|
-
events?: Array<{
|
|
16
|
-
name: string;
|
|
17
|
-
handler: (e: Event) => any;
|
|
18
|
-
}>;
|
|
19
|
-
}
|
|
9
|
+
export declare type ElementOptions = Partial<Events & Record<string, any> & {
|
|
10
|
+
id: string;
|
|
11
|
+
class: Arrayable<string>;
|
|
12
|
+
children: Arrayable<IElement>;
|
|
13
|
+
dataset: Record<string, string>;
|
|
14
|
+
}>;
|
|
20
15
|
export default ElementOptions;
|
package/dist/Interfaces/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -12,4 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
17
|
__exportStar(require("./ElementOptions"), exports);
|
|
14
18
|
__exportStar(require("./IReplacement"), exports);
|
|
15
|
-
__exportStar(require("./BaseEventInterface"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Construct a type with the properties of Type except for those in type Properties.
|
|
3
|
+
*/
|
|
4
|
+
export declare type BetterOmit<Type, Properties extends keyof Type> = Omit<Type, Properties>;
|
|
5
|
+
/**
|
|
6
|
+
* Extract from From those types that are assignable to Properties
|
|
7
|
+
*/
|
|
8
|
+
export declare type BetterExtract<From, Properties extends From> = Extract<From, Properties>;
|
|
9
|
+
export declare type PartialExcept<From, Properties extends keyof From> = Partial<From> & Required<Pick<From, Properties>>;
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare type LongMonth = 'Janurary' | 'February' | 'March' | 'April' | 'May' | 'June' | 'July' | 'August' | 'September' | 'October' | 'November' | 'December';
|
|
2
|
+
export declare type ShortMonth = 'Jan' | 'Feb' | 'Mar' | 'Apr' | 'May' | 'Jun' | 'Jul' | 'Aug' | 'Sep' | 'Oct' | 'Nov' | 'Dec';
|
|
3
|
+
export declare type Month = LongMonth | ShortMonth;
|
|
4
|
+
export declare type ShortDay = 'Mon' | 'Tue' | 'Wed' | 'Thu' | 'Fri' | 'Sat' | 'Sun';
|
|
5
|
+
export declare type LongDay = `${'Mon' | 'Tues' | 'Wednes' | 'Thurs' | 'Fri' | 'Satur' | 'Sun'}day`;
|
|
6
|
+
export declare type Day = ShortDay | LongDay;
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default eventhandler mapper. Object with properties that are arrays
|
|
3
|
+
*/
|
|
4
|
+
export declare type BaseEvent<Keys extends string, Types extends Array<any>> = Record<Keys, Types>;
|
|
5
|
+
/**
|
|
6
|
+
* Eventhandler type for:
|
|
7
|
+
* @see EventCollection
|
|
8
|
+
* @borrows BaseEvent
|
|
9
|
+
*/
|
|
10
|
+
export declare type EventHandler<Events extends BaseEvent<string, Array<any>> = BaseEvent<string, Array<any>>, Event extends keyof Events = keyof Events, ReturnType = any> = (...args: Events[Event]) => ReturnType;
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters all properties from From that has the return type of Type
|
|
3
|
+
*/
|
|
4
|
+
export declare type PropertiesWith<Type, From> = {
|
|
5
|
+
[Key in keyof From as From[Key] extends Type ? Key : never]: From[Key];
|
|
6
|
+
};
|
|
7
|
+
export default PropertiesWith;
|
|
8
|
+
/**
|
|
9
|
+
* Fitlers all properties from From that don't have the return type of Type
|
|
10
|
+
*/
|
|
11
|
+
export declare type PropertiesWithout<Type, From> = {
|
|
12
|
+
[Key in keyof From as From[Key] extends Type ? never : Key]: From[Key];
|
|
13
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts Start types to Switch types in From type
|
|
3
|
+
*/
|
|
4
|
+
export declare type TransformType<From, Start, Switch> = {
|
|
5
|
+
[Key in keyof From]: From[Key] extends Start ? Switch : From[Key];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Returns object with properties matching BaseType with types of NewType
|
|
9
|
+
*/
|
|
10
|
+
export declare type TransformTypes<From, BaseType, NewType> = Record<keyof {
|
|
11
|
+
[Key in keyof From as From[Key] extends BaseType ? Key : never]: Key;
|
|
12
|
+
}, NewType>;
|
|
13
|
+
export default TransformTypes;
|
package/dist/Types/index.d.ts
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './BetterTypes';
|
|
2
|
+
export * from './Date';
|
|
3
|
+
export * from './Events';
|
|
4
|
+
export * from './TransformTypes';
|
|
5
|
+
export * from './PropertiesWith';
|
|
6
|
+
/**
|
|
7
|
+
* Item is single or multiple
|
|
8
|
+
*/
|
|
9
|
+
export declare type Arrayable<T> = T | Array<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Used for HTMLElement.append in ElementOptions, Document.createProperElement.
|
|
12
|
+
* IElement accepts HTML Elements or HTMl-like strings.
|
|
13
|
+
*
|
|
14
|
+
* @see HTMLElement.append
|
|
15
|
+
* @see Document.createProperElement
|
|
16
|
+
*/
|
|
17
|
+
export declare type IElement = HTMLElement | string;
|
|
18
|
+
/**
|
|
19
|
+
* Return types of T
|
|
20
|
+
*/
|
|
21
|
+
export declare type ValueOf<T> = T[keyof T];
|
|
22
|
+
/**
|
|
23
|
+
* Type's properties are ReturnType
|
|
24
|
+
*/
|
|
25
|
+
export declare type AllPropsAre<ReturnType> = {
|
|
26
|
+
[key: string]: ReturnType;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* string or RegExp.. pretty self-explanatory
|
|
30
|
+
*/
|
|
31
|
+
export declare type StringRegex = string | RegExp;
|
package/dist/Types/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -10,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./
|
|
14
|
-
__exportStar(require("./
|
|
15
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./BetterTypes"), exports);
|
|
18
|
+
__exportStar(require("./Date"), exports);
|
|
19
|
+
__exportStar(require("./Events"), exports);
|
|
20
|
+
__exportStar(require("./TransformTypes"), exports);
|
|
21
|
+
__exportStar(require("./PropertiesWith"), exports);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export *
|
|
1
|
+
export * from './Classes';
|
|
2
|
+
export * from './Extensions';
|
|
3
|
+
export * from './Functions';
|
|
4
|
+
export * from './Interfaces';
|
|
5
|
+
export * from './Types';
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var Functions_1 = require("./Functions");
|
|
9
|
-
Object.defineProperty(exports, "CopyToClipboard", { enumerable: true, get: function () { return Functions_1.CopyToClipboard; } });
|
|
10
|
-
Object.defineProperty(exports, "SetNavigationSelected", { enumerable: true, get: function () { return Functions_1.SetNavigationSelected; } });
|
|
11
|
-
Object.defineProperty(exports, "HTMLEvent", { enumerable: true, get: function () { return Functions_1.HTMLEvent; } });
|
|
12
|
-
exports.Extensions = require("./Extensions");
|
|
17
|
+
__exportStar(require("./Classes"), exports);
|
|
18
|
+
__exportStar(require("./Extensions"), exports);
|
|
19
|
+
__exportStar(require("./Functions"), exports);
|
|
20
|
+
__exportStar(require("./Interfaces"), exports);
|
|
21
|
+
__exportStar(require("./Types"), exports);
|