Skip to content

Commit

Permalink
🤖 Merge PR #68863 [@uswds/uswds]: Fix inaccurate typings for optional…
Browse files Browse the repository at this point in the history
… elements, add new components by @aduth
  • Loading branch information
aduth committed Mar 1, 2024
1 parent 1e70b91 commit 792195d
Show file tree
Hide file tree
Showing 26 changed files with 175 additions and 72 deletions.
4 changes: 2 additions & 2 deletions types/uswds__uswds/js/_usa-password/index.d.ts
@@ -1,6 +1,6 @@
interface Password {
on(el: HTMLElement): void;
off(el: HTMLElement): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
}

declare const password: Password;
Expand Down
4 changes: 4 additions & 0 deletions types/uswds__uswds/js/index.d.ts
@@ -1,6 +1,7 @@
import password from "./_usa-password";
import accordion from "./usa-accordion";
import banner from "./usa-banner";
import button from "./usa-button";
import characterCount from "./usa-character-count";
import comboBox from "./usa-combo-box";
import datePicker from "./usa-date-picker";
Expand All @@ -13,6 +14,7 @@ import inputMask from "./usa-input-mask";
import inputPrefixSuffix from "./usa-input-prefix-suffix";
import languageSelector from "./usa-language-selector";
import modal from "./usa-modal";
import range from "./usa-range";
import search from "./usa-search";
import skipnav from "./usa-skipnav";
import table from "./usa-table";
Expand All @@ -23,6 +25,7 @@ import validator from "./usa-validation";
export {
accordion,
banner,
button,
characterCount,
comboBox,
datePicker,
Expand All @@ -36,6 +39,7 @@ export {
modal,
navigation,
password,
range,
search,
skipnav,
table,
Expand Down
6 changes: 3 additions & 3 deletions types/uswds__uswds/js/usa-accordion/index.d.ts
@@ -1,9 +1,9 @@
interface Accordion {
ACCORDION: string;
BUTTON: string;
init(root: HTMLElement | Document): void;
on(el: HTMLElement): void;
off(el: HTMLElement): void;
init(root?: HTMLElement | Document): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
show(button: HTMLButtonElement): boolean;
hide(button: HTMLButtonElement): boolean;
/**
Expand Down
4 changes: 2 additions & 2 deletions types/uswds__uswds/js/usa-banner/index.d.ts
@@ -1,6 +1,6 @@
interface Banner {
on(el: HTMLElement): void;
off(el: HTMLElement): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
}

declare const banner: Banner;
Expand Down
8 changes: 8 additions & 0 deletions types/uswds__uswds/js/usa-button/index.d.ts
@@ -0,0 +1,8 @@
interface Button {
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
}

declare const button: Button;

export default button;
6 changes: 3 additions & 3 deletions types/uswds__uswds/js/usa-character-count/index.d.ts
@@ -1,12 +1,12 @@
interface CharacterCount {
init(root: HTMLElement | Document): void;
init(root?: HTMLElement | Document): void;
MESSAGE_INVALID_CLASS: string;
VALIDATION_MESSAGE: string;
STATUS_MESSAGE_CLASS: string;
STATUS_MESSAGE_SR_ONLY_CLASS: string;
DEFAULT_STATUS_LABEL: string;
on(el: HTMLElement): void;
off(el: HTMLElement): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
/**
* Create and append status messages for visual and screen readers
*/
Expand Down
6 changes: 3 additions & 3 deletions types/uswds__uswds/js/usa-combo-box/index.d.ts
Expand Up @@ -13,10 +13,10 @@ interface ComboBoxContext {
}

interface ComboBox {
init(root: HTMLElement | Document): void;
init(root?: HTMLElement | Document): void;
COMBO_BOX_CLASS: string;
on(el: HTMLElement): void;
off(el: HTMLElement): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
/**
* Get an object of elements belonging directly to the given
* combo box component.
Expand Down
6 changes: 3 additions & 3 deletions types/uswds__uswds/js/usa-date-picker/index.d.ts
Expand Up @@ -14,9 +14,9 @@ interface DatePickerContext {
}

interface DatePicker {
init(root: HTMLElement | Document): void;
on(el: HTMLElement): void;
off(el: HTMLElement): void;
init(root?: HTMLElement | Document): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
/**
* Get an object of the properties and elements belonging directly to the given
* date picker component.
Expand Down
6 changes: 3 additions & 3 deletions types/uswds__uswds/js/usa-date-range-picker/index.d.ts
@@ -1,7 +1,7 @@
interface DateRangePicker {
init(root: HTMLElement | Document): void;
on(el: HTMLElement): void;
off(el: HTMLElement): void;
init(root?: HTMLElement | Document): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
}

declare const dateRangePicker: DateRangePicker;
Expand Down
8 changes: 4 additions & 4 deletions types/uswds__uswds/js/usa-file-input/index.d.ts
Expand Up @@ -4,10 +4,10 @@ interface FileInputContext {
}

interface FileInput {
init(root: HTMLElement | Document): void;
teardown(root: HTMLElement | Document): void;
on(el: HTMLElement): void;
off(el: HTMLElement): void;
init(root?: HTMLElement | Document): void;
teardown(root?: HTMLElement | Document): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
/**
* Get an object of the properties and elements belonging directly to the given
* file input component.
Expand Down
4 changes: 2 additions & 2 deletions types/uswds__uswds/js/usa-footer/index.d.ts
Expand Up @@ -2,8 +2,8 @@ interface Footer {
HIDE_MAX_WIDTH: number;
init(): void;
teardown(): void;
on(el: HTMLElement): void;
off(el: HTMLElement): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
}

declare const footer: Footer;
Expand Down
6 changes: 3 additions & 3 deletions types/uswds__uswds/js/usa-header/index.d.ts
@@ -1,9 +1,9 @@
interface Navigation {
focusTrap: null;
init(root: HTMLElement | Document): void;
init(root?: HTMLElement | Document): void;
teardown(): void;
on(el: HTMLElement): void;
off(el: HTMLElement): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
toggleNav(active: boolean): boolean;
}

Expand Down
6 changes: 3 additions & 3 deletions types/uswds__uswds/js/usa-in-page-navigation/index.d.ts
@@ -1,7 +1,7 @@
interface InPageNavigation {
init(root: HTMLElement | Document): void;
on(root: HTMLElement | Document): void;
off(root: HTMLElement | Document): void;
init(root?: HTMLElement | Document): void;
on(root?: HTMLElement | Document): void;
off(root?: HTMLElement | Document): void;
}

declare const inPageNavigation: InPageNavigation;
Expand Down
6 changes: 3 additions & 3 deletions types/uswds__uswds/js/usa-input-mask/index.d.ts
@@ -1,7 +1,7 @@
interface InputMask {
init(root: HTMLElement | Document): void;
on(root: HTMLElement | Document): void;
off(root: HTMLElement | Document): void;
init(root?: HTMLElement | Document): void;
on(root?: HTMLElement | Document): void;
off(root?: HTMLElement | Document): void;
}

declare const inputMask: InputMask;
Expand Down
6 changes: 3 additions & 3 deletions types/uswds__uswds/js/usa-input-prefix-suffix/index.d.ts
@@ -1,7 +1,7 @@
interface InputPrefixSuffix {
init(root: HTMLElement | Document): void;
on(el: HTMLElement): void;
off(el: HTMLElement): void;
init(root?: HTMLElement | Document): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
}

declare const inputPrefixSuffix: InputPrefixSuffix;
Expand Down
6 changes: 3 additions & 3 deletions types/uswds__uswds/js/usa-language-selector/index.d.ts
@@ -1,9 +1,9 @@
interface LanguageSelector {
focusTrap: null;
init(root: HTMLElement | Document): void;
init(root?: HTMLElement | Document): void;
teardown(): void;
on(root: HTMLElement | Document): void;
off(root: HTMLElement | Document): void;
on(root?: HTMLElement | Document): void;
off(root?: HTMLElement | Document): void;
}

declare const languageSelector: LanguageSelector;
Expand Down
8 changes: 4 additions & 4 deletions types/uswds__uswds/js/usa-modal/index.d.ts
@@ -1,9 +1,9 @@
interface Modal {
focusTrap: null;
init(root: HTMLElement | Document): void;
teardown(root: HTMLElement | Document): void;
on(root: HTMLElement | Document): void;
off(root: HTMLElement | Document): void;
init(root?: HTMLElement | Document): void;
teardown(root?: HTMLElement | Document): void;
on(root?: HTMLElement | Document): void;
off(root?: HTMLElement | Document): void;
/**
* Toggle the visibility of a modal window
*/
Expand Down
10 changes: 10 additions & 0 deletions types/uswds__uswds/js/usa-range/index.d.ts
@@ -0,0 +1,10 @@
interface Range {
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
init(root?: HTMLElement): void;
updateCallout(targetRange: HTMLInputElement): void;
}

declare const range: Range;

export default range;
6 changes: 3 additions & 3 deletions types/uswds__uswds/js/usa-search/index.d.ts
@@ -1,8 +1,8 @@
interface Search {
init(target: HTMLElement | Document): void;
init(target?: HTMLElement | Document): void;
teardown(): void;
on(el: HTMLElement): void;
off(el: HTMLElement): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
}

declare const search: Search;
Expand Down
4 changes: 2 additions & 2 deletions types/uswds__uswds/js/usa-skipnav/index.d.ts
@@ -1,6 +1,6 @@
interface Skipnav {
on(el: HTMLElement): void;
off(el: HTMLElement): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
}

declare const skipnav: Skipnav;
Expand Down
6 changes: 3 additions & 3 deletions types/uswds__uswds/js/usa-table/index.d.ts
Expand Up @@ -2,9 +2,9 @@ interface Table {
TABLE: string;
SORTABLE_HEADER: string;
SORT_BUTTON: string;
init(root: HTMLElement | Document): void;
on(el: HTMLElement): void;
off(el: HTMLElement): void;
init(root?: HTMLElement | Document): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
}

declare const table: Table;
Expand Down
6 changes: 3 additions & 3 deletions types/uswds__uswds/js/usa-time-picker/index.d.ts
Expand Up @@ -5,9 +5,9 @@ interface TimePicker {
hourQueryFilter: string;
minuteQueryFilter: string;
};
init(root: HTMLElement | Document): void;
on(el: HTMLElement): void;
off(el: HTMLElement): void;
init(root?: HTMLElement | Document): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
}

declare const timePicker: TimePicker;
Expand Down
12 changes: 7 additions & 5 deletions types/uswds__uswds/js/usa-tooltip/index.d.ts
@@ -1,3 +1,5 @@
type TooltipPosition = "top" | "right" | "bottom" | "left";

interface TooltipContext {
tooltipBody: HTMLSpanElement;
position: string;
Expand All @@ -6,9 +8,9 @@ interface TooltipContext {
}

interface Tooltip {
init(root: HTMLElement | Document): void;
on(el: HTMLElement): void;
off(el: HTMLElement): void;
init(root?: HTMLElement | Document): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
/**
* Setup the tooltip component
*/
Expand All @@ -19,14 +21,14 @@ interface Tooltip {
wrapper: HTMLSpanElement;
};
getTooltipElements(trigger: Element): {
trigger: Element;
trigger: HTMLElement;
wrapper: HTMLElement;
body: HTMLElement;
};
/**
* Shows the tooltip
*/
show(tooltipTrigger: HTMLElement): void;
show(tooltipBody: HTMLElement, tooltipTrigger: HTMLElement, position: TooltipPosition): void;
/**
* Removes all the properties to show and position the tooltip,
* and resets the tooltip position to the original intention
Expand Down
6 changes: 3 additions & 3 deletions types/uswds__uswds/js/usa-validation/index.d.ts
@@ -1,7 +1,7 @@
interface Validator {
init(root: HTMLElement | Document): void;
on(el: HTMLElement): void;
off(el: HTMLElement): void;
init(root?: HTMLElement | Document): void;
on(el?: HTMLElement): void;
off(el?: HTMLElement): void;
}

declare const validator: Validator;
Expand Down
6 changes: 5 additions & 1 deletion types/uswds__uswds/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/uswds__uswds",
"version": "3.3.9999",
"version": "3.7.9999",
"projects": [
"https://github.com/uswds/uswds"
],
Expand All @@ -12,6 +12,10 @@
{
"name": "Morgan Spencer",
"githubUsername": "morganmspencer"
},
{
"name": "Andrew Duthie",
"githubUsername": "aduth"
}
]
}

0 comments on commit 792195d

Please sign in to comment.