Skip to content

Commit

Permalink
fix(types): improve typescript support for dynamic imports (#179) (#180)
Browse files Browse the repository at this point in the history
Co-authored-by: Gareth Cozens <gareth.cozens@amido.com>
  • Loading branch information
cloudratha and Gareth Cozens authored Sep 8, 2021
1 parent ab52443 commit 6c53369
Show file tree
Hide file tree
Showing 13 changed files with 238 additions and 246 deletions.
35 changes: 35 additions & 0 deletions lbh/components/lbh-accordion/accordion.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
export class Accordion {
$module: HTMLElement;
moduleId: string;
$sections: NodeListOf<HTMLElement>;
$openAllButton: string;
browserSupportsSessionStorage: boolean | undefined;

controlsClass: string;
openAllClass: string;
iconClass: string;

sectionHeaderClass: string;
sectionHeaderFocusedClass: string;
sectionHeadingClass: string;
sectionSummaryClass: string;
sectionButtonClass: string;
sectionExpandedClass: string;

constructor($module: HTMLElement);

init(): void;
initControls(): void;
initSectionHeaders(): void;
initHeaderAttributes($headerWrapper: HTMLElement, index: number): void;
onSectionToggle($section: HTMLElement): void;
onOpenOrCloseAllToggle(): void;
setExpanded(expanded: boolean, $section: HTMLElement | null): void;
isExpanded(section: HTMLElement | null): boolean;
checkIfAllSectionsOpen(): boolean;
updateOpenAllButton(expanded: boolean): void;
storeState($section: HTMLElement): void;
setInitialState($section: HTMLElement): void;
}

export default Accordion;
10 changes: 10 additions & 0 deletions lbh/components/lbh-back-to-top/back-to-top.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class BackToTop {
$module: HTMLElement;

constructor($module: HTMLElement);

init(): void;
checkScrollPosition($element: HTMLElement): void;
}

export default BackToTop;
12 changes: 12 additions & 0 deletions lbh/components/lbh-button/button.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Button {
$module: HTMLElement;
debounceFormSubmitTimer: number | null;

constructor($module: HTMLElement);

handleKeyDown(event: KeyboardEvent): void;
debounce(event: MouseEvent): void | false;
init(): void;
}

export default Button;
21 changes: 21 additions & 0 deletions lbh/components/lbh-character-count/character-count.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class CharacterCount {
$module: HTMLElement;
$textarea: HTMLElement | null;
$countMessage: HTMLElement | null;

valueChecker: number | null;

constructor($module: HTMLElement);

init(): void;
sync(): void;
getDataset(): Record<string, string>;
count(text: string): number;
bindChangeEvents(): void;
checkIfValueChanged(): void;
updateCountMessage(): void;
handleFocus(): void;
handleBlur(): void;
}

export default CharacterCount;
15 changes: 15 additions & 0 deletions lbh/components/lbh-checkboxes/checkboxes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Checkboxes {
$module: HTMLElement;
$inputs: NodeListOf<HTMLInputElement>;

constructor($module: HTMLElement);

init(): void;
syncAllConditionalReveals(): void;
syncConditionalRevealWithInputState($input: HTMLInputElement): void;
unCheckAllInputsExcept($input: HTMLInputElement): void;
unCheckExclusiveInputs($input: HTMLInputElement): void;
handleClick(event: MouseEvent): void;
}

export default Checkboxes;
9 changes: 9 additions & 0 deletions lbh/components/lbh-collapsible/collapsible.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Collapsible {
$module: HTMLElement;

constructor($module: HTMLElement);

init(): void;
}

export default Collapsible;
26 changes: 26 additions & 0 deletions lbh/components/lbh-contact-block/contact-block.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Map {
$module: HTMLElement;
moduleId: string;
accessToken: string;
markerLat: number | null;
markerLng: number | null;
centreLat: number;
centreLng: number;
maxZoom: number;
minZoom: number;
initialZoom: number;
showZoomControl: boolean;
minLat: number;
maxLat: number;
maxLng: number;

constructor($module: HTMLElement);

init(): void;
initLeaflet(): void;
setBounds(): void;
initMapboxTiles(): void;
addMarker(): void;
}

export default Map;
13 changes: 13 additions & 0 deletions lbh/components/lbh-cookie-banner/cookie-banner.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class CookieBanner {
$module: HTMLElement;
$button: HTMLElement | null;

constructor($module: HTMLElement);

init(): void;
checkCookies(): string | null;
showCookieBanner(): void;
bindAcceptButton(): void;
}

export default CookieBanner;
12 changes: 12 additions & 0 deletions lbh/components/lbh-details/details.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Details {
$module: HTMLElement;

constructor($module: HTMLElement);

init(): void;
polyfillDetails(): void;
polyfillSetAttributes(): true;
polyfillHandleInputs(node: HTMLElement, callback: Function): void;
}

export default Details;
13 changes: 13 additions & 0 deletions lbh/components/lbh-error-summary/error-summary.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class ErrorSummary {
$module: HTMLElement;

constructor($module: HTMLElement);

init(): void;
handleClick(event: MouseEvent): void;
focusTarget($target: HTMLElement): boolean;
getFragmentFromUrl(url: string): string | false;
getAssociatedLegendOrLabel($input: HTMLElement): HTMLElement | null;
}

export default ErrorSummary;
12 changes: 12 additions & 0 deletions lbh/components/lbh-radios/radios.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Radios {
$module: HTMLElement;
$inputs: NodeListOf<HTMLInputElement>;
constructor($module: HTMLElement);

init(): void;
syncAllConditionalReveals(): void;
syncConditionalRevealWithInputState(): void;
handleClick(event: MouseEvent): void;
}

export default Radios;
33 changes: 33 additions & 0 deletions lbh/components/lbh-tabs/tabs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class Tabs {
$module: HTMLElement;
$tabs: NodeListOf<HTMLElement>;
keys: { left: number; right: number; up: number; down: number };
jsHiddenClass: string;

constructor($module: HTMLElement);

init(): void;
setupResponsiveChecks(): void;
checkMode(): void;
setup(): void;
teardown(): void;
onHashChange(event: HashChangeEvent): void;
hideTab($tab: HTMLElement): void;
showTab($tab: HTMLElement): void;
getTab(hash: string): HTMLElement | null;
setAttributes($tab: HTMLElement): void;
unsetAttributes($tab: HTMLElement): void;
onTabClick(event: MouseEvent): void;
createHistoryEntry($tab: HTMLElement): void;
onTabKeydown(event: KeyboardEvent): void;
activateNextTab(): void;
activatePreviousTab(): void;
getPanel($tab: HTMLElement): HTMLElement | null;
showPanel($tab: HTMLElement): void;
hidePanel($tab: HTMLElement): void;
unhighlightTab($tab: HTMLElement): void;
getCurrentTab(): HTMLElement | null;
getHref($tab: HTMLElement): string;
}

export default Tabs;
Loading

0 comments on commit 6c53369

Please sign in to comment.