Skip to content

Commit

Permalink
Compiled the library to .js + separate .d.ts declaration files
Browse files Browse the repository at this point in the history
  • Loading branch information
alexiglesias93 committed Jan 6, 2022
1 parent 46b502b commit b669c51
Show file tree
Hide file tree
Showing 121 changed files with 860 additions and 11 deletions.
26 changes: 26 additions & 0 deletions bin/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Import ESBuild
import esbuild from 'esbuild';
import dotenv from 'dotenv';

dotenv.config({ path: '.env' });

const production = process.env.NODE_ENV === 'production';

/**
* Default Settings
* @type {esbuild.BuildOptions}
*/
const defaultSettings = {
bundle: true,
minify: production,
sourcemap: false,
outdir: production ? 'dist' : process.env.CUSTOM_BUILD_DIRECTORY || '',
target: production ? 'es6' : 'esnext',
};

// Files building
esbuild.buildSync({
...defaultSettings,
entryPoints: ['src/index.ts'],
format: 'esm',
});
1 change: 1 addition & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/types/animations/fade.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare const fadeIn: (element: HTMLElement, display?: string) => Promise<void>;
export declare const fadeOut: (element: HTMLElement) => Promise<void>;
File renamed without changes.
27 changes: 27 additions & 0 deletions dist/types/components/CopyJSONButton.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export declare class CopyJSONButton {
private readonly element;
private readonly hiddenTrigger;
private readonly successCSSClass?;
private readonly textNode;
private copyData;
private successText;
private errorText;
private notificationDuration;
private notificationActive;
private originalText;
constructor({ element, copyData, successText, errorText, notificationDuration, successCSSClass, }: {
element: HTMLElement;
copyData: Record<string, unknown>;
successText?: string;
errorText?: string;
notificationDuration?: number;
successCSSClass?: string;
});
private init;
private createHiddenTrigger;
private handleClick;
private handleCopy;
private triggerNotification;
updateCopyData(newCopyData: Record<string, unknown>): void;
updateTextContent(newText: string): void;
}
6 changes: 6 additions & 0 deletions dist/types/components/Debug.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export declare class Debug {
private static alertsActivated;
static activateAlerts(): void;
static alert(text: string, type: 'info'): void;
static alert<T>(text: string, type: 'error'): T;
}
20 changes: 20 additions & 0 deletions dist/types/components/DisplayController.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { InteractionParams } from './Interaction';
export interface DisplayControllerParams {
element: HTMLElement | string;
interaction?: InteractionParams;
displayProperty?: typeof DisplayController['displayProperties'][number];
noTransition?: boolean;
startsHidden?: boolean;
}
export declare class DisplayController {
private readonly interaction;
private readonly noTransition;
private readonly displayProperty;
private visible;
readonly element: HTMLElement;
static readonly displayProperties: readonly ["block", "flex", "grid", "inline-block", "inline"];
constructor({ element, interaction, displayProperty, noTransition, startsHidden }: DisplayControllerParams);
isVisible: () => boolean;
show(): Promise<void>;
hide(): Promise<void>;
}
19 changes: 19 additions & 0 deletions dist/types/components/Interaction.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export interface InteractionParams {
element: HTMLElement | string;
duration?: number | Partial<Interaction['duration']>;
}
export declare class Interaction {
private readonly element;
private active;
private running;
private runningPromise?;
readonly duration: {
first: number;
second: number;
};
constructor({ element, duration }: InteractionParams);
trigger(click?: 'first' | 'second'): Promise<boolean>;
isActive: () => boolean;
isRunning: () => boolean;
untilFinished: () => Promise<unknown> | undefined;
}
9 changes: 9 additions & 0 deletions dist/types/components/WritableStore.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export declare class WritableStore<T> {
private value;
private subscribeCallbacks;
constructor(value: T);
get(): T;
set(newValue: T): void;
update(callback: (value: T) => T): void;
subscribe(callback: (value: T) => void): () => void;
}
File renamed without changes.
3 changes: 3 additions & 0 deletions dist/types/helpers/clearFormField.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { simulateEvent } from './simulateEvent';
import type { FormField } from '../types';
export declare const clearFormField: (field: FormField, omitEvents?: Parameters<typeof simulateEvent>['1']) => void;
1 change: 1 addition & 0 deletions dist/types/helpers/cloneNode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const cloneNode: <T extends Node>(node: T, deep?: boolean) => T;
2 changes: 2 additions & 0 deletions dist/types/helpers/extractCommaSeparatedValues.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare function extractCommaSeparatedValues(string: string | null | undefined, compareSource?: undefined, defaultValue?: undefined, filterEmpty?: boolean): string[];
export declare function extractCommaSeparatedValues<SourceKey extends string, DefaultKey extends SourceKey>(string: string | null | undefined, compareSource: readonly SourceKey[], defaultValue?: DefaultKey | undefined, filterEmpty?: boolean): SourceKey[];
1 change: 1 addition & 0 deletions dist/types/helpers/extractNumberSuffix.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const extractNumberSuffix: (string: string) => number | undefined;
1 change: 1 addition & 0 deletions dist/types/helpers/findTextNode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const findTextNode: (element: HTMLElement) => ChildNode | undefined;
1 change: 1 addition & 0 deletions dist/types/helpers/getAllParents.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const getAllParents: (element: Element) => HTMLElement[];
1 change: 1 addition & 0 deletions dist/types/helpers/getDistanceFromTop.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const getDistanceFromTop: (element: Element) => number;
2 changes: 2 additions & 0 deletions dist/types/helpers/getFormFieldValue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import type { FormField } from '../types/FormField';
export declare const getFormFieldValue: (input: FormField) => string;
1 change: 1 addition & 0 deletions dist/types/helpers/getHiddenParent.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const getHiddenParent: (element: HTMLElement) => HTMLElement | undefined;
2 changes: 2 additions & 0 deletions dist/types/helpers/getObjectEntries.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import type { Entry } from '../types/Entry';
export declare const getObjectEntries: <T extends Readonly<Record<string, unknown>>>(object: T) => Entry<T>[];
1 change: 1 addition & 0 deletions dist/types/helpers/getObjectKeys.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const getObjectKeys: <T extends Record<string, unknown>>(object: T) => (keyof T)[];
File renamed without changes.
1 change: 1 addition & 0 deletions dist/types/helpers/isScrollable.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const isScrollable: (element: Element) => boolean;
1 change: 1 addition & 0 deletions dist/types/helpers/isVisible.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const isVisible: (element: HTMLElement) => boolean;
2 changes: 2 additions & 0 deletions dist/types/helpers/queryElement.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import type { Instance } from '../types/Instance';
export declare const queryElement: <T extends Element>(selector: string, instance: Instance<T>, scope?: ParentNode) => T | undefined;
1 change: 1 addition & 0 deletions dist/types/helpers/removeChildElements.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const removeChildElements: (element: Element, selector?: string | undefined) => void;
1 change: 1 addition & 0 deletions dist/types/helpers/removeSpaces.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const removeSpaces: (string: string) => string;
1 change: 1 addition & 0 deletions dist/types/helpers/removeTrailingSlash.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const removeTrailingSlash: (value: string) => string;
1 change: 1 addition & 0 deletions dist/types/helpers/sameValues.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const sameValues: (array1: unknown[], array2: unknown[]) => boolean;
1 change: 1 addition & 0 deletions dist/types/helpers/selectInputElement.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const selectInputElement: (element: HTMLInputElement, select?: boolean) => string | boolean;
2 changes: 2 additions & 0 deletions dist/types/helpers/setFormFieldValue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import type { FormField } from '..';
export declare const setFormFieldValue: (element: FormField, value: string | boolean) => void;
1 change: 1 addition & 0 deletions dist/types/helpers/simulateEvent.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const simulateEvent: (target: EventTarget, events: keyof DocumentEventMap | Array<keyof DocumentEventMap>) => boolean;
1 change: 1 addition & 0 deletions dist/types/helpers/throwError.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const throwError: <T>(message: string) => T;
1 change: 1 addition & 0 deletions dist/types/helpers/wait.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const wait: (time: number) => Promise<unknown>;
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions dist/types/type-guards/isFormField.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import type { FormField } from '../types/FormField';
export declare const isFormField: (element: Element | EventTarget | null) => element is FormField;
1 change: 1 addition & 0 deletions dist/types/type-guards/isKeyOf.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const isKeyOf: <T extends string>(key: string | null | undefined, source: readonly T[]) => key is T;
1 change: 1 addition & 0 deletions dist/types/type-guards/isNotEmpty.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const isNotEmpty: <T>(value: T | null | undefined) => value is T;
3 changes: 3 additions & 0 deletions dist/types/types/Entry.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export declare type Entry<T> = {
[K in keyof T]: [K, T[K]];
}[keyof T];
1 change: 1 addition & 0 deletions dist/types/types/FormField.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare type FormField = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
4 changes: 4 additions & 0 deletions dist/types/types/Instance.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export declare type Instance<T> = {
new (): T;
prototype: T;
};
1 change: 1 addition & 0 deletions dist/types/types/MapEntries.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare type MapEntries<MapToConvert> = MapToConvert extends Map<infer Key, infer Value> ? [Key, Value][] : never;
1 change: 1 addition & 0 deletions dist/types/types/PartialExcept.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare type PartialExcept<Original, Keys extends keyof Original> = Partial<Omit<Original, Keys>> & Required<Pick<Original, Keys>>;
1 change: 1 addition & 0 deletions dist/types/types/PickPartial.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare type PickPartial<Original, Keys extends keyof Original> = Omit<Original, Keys> & Partial<Pick<Original, Keys>>;
1 change: 1 addition & 0 deletions dist/types/types/PickRequired.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare type PickRequired<Original, Keys extends keyof Original> = Omit<Original, Keys> & Required<Pick<Original, Keys>>;
1 change: 1 addition & 0 deletions dist/types/types/RequiredExcept.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare type RequiredExcept<Original, Keys extends keyof Original> = Required<Omit<Original, Keys>> & Partial<Pick<Original, Keys>>;
1 change: 1 addition & 0 deletions dist/types/types/UnionToIntersection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare type UnionToIntersection<Union> = (Union extends unknown ? (k: Union) => void : never) extends (k: infer Intersection) => void ? Intersection : never;
File renamed without changes.
Loading

0 comments on commit b669c51

Please sign in to comment.