Skip to content

Commit

Permalink
include typescript definitions in npm package
Browse files Browse the repository at this point in the history
  • Loading branch information
mynamesleon committed Jul 5, 2020
1 parent 2916c03 commit 50f286b
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## [1.1.4] - 2020-07-05

### Fixed

- TypeScript definitions not included in npm package

## [1.1.3] - 2020-02-04

### Fixed
Expand Down
8 changes: 8 additions & 0 deletions copy-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const fs = require('fs');
const src = 'src/aria-autocomplete-types.d.ts';
const dest = 'dist/index.d.ts';

fs.copyFile(src, dest, (err) => {
if (err) throw err;
console.log(`${src} was copied to ${dest}`);
});
59 changes: 59 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export interface IAriaAutocompleteOptions {
name?: string;
source?: string | string[] | any[] | Function;
sourceMapping?: any;
alsoSearchIn?: string[];
delay?: number;
minLength?: number;
maxResults?: number;
showAllControl?: boolean;
confirmOnBlur?: boolean;
multiple?: boolean;
autoGrow?: boolean;
maxItems?: number;
multipleSeparator?: string;
deleteOnBackspace?: boolean;
asyncQueryParam?: string;
asyncMaxResultsParam?: string;
placeholder?: string;
noResultsText?: string;
cssNameSpace?: string;
listClassName?: string;
inputClassName?: string;
wrapperClassName?: string;
srDeleteText?: string;
srDeletedText?: string;
srShowAllText?: string;
srSelectedText?: string;
srListLabelText?: string;
srAssistiveText?: string;
srResultsText?(length: number): string | void;
onSearch?(value: string): string | void;
onAsyncPrep?(url: string): string | void;
onAsyncSuccess?(query: string, xhr: XMLHttpRequest): any[] | void;
onAsyncError?(query: string, xhr: XMLHttpRequest): void;
onResponse?(options: any[]): any[] | void;
onItemRender?(sourceEntry: any): string | void;
onConfirm?(selected: any): void;
onDelete?(deleted: any): void;
onReady?(wrapper: HTMLDivElement): void;
onClose?(list: HTMLUListElement): void;
onOpen?(list: HTMLUListElement): void;
}

export interface IAriaAutocompleteApi {
list: HTMLUListElement;
input: HTMLInputElement;
wrapper: HTMLDivElement;
options: IAriaAutocompleteOptions;
selected: any[];
open(): void;
close(): void;
enable(): void;
disable(): void;
filter(val: string): void;
destroy(): void;
}

declare function AriaAutocomplete(element: HTMLElement, options?: IAriaAutocompleteOptions): IAriaAutocompleteApi;
export default AriaAutocomplete;
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ <h2>Key features</h2>
<pre><code class="lang-bash">npm install aria-autocomplete</code></pre>
<pre><code class="lang-html">&lt;script src="https://unpkg.com/aria-autocomplete"&gt;&lt;/script&gt;</code></pre>
<p>And call with an element and options:</p>
<pre><code class="lang-javascript">new AriaAutocomplete(element, options);</code></pre>
<pre><code class="lang-javascript">AriaAutocomplete(element, options);</code></pre>
</div>
</section>
<script>
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "aria-autocomplete",
"version": "1.1.3",
"version": "1.1.4",
"description": "Accessible, extensible, JavaScript autocomplete with multi-select",
"main": "dist/aria-autocomplete.min.js",
"style": "dist/aria-autocomplete.css",
"types": "dist/index.d.ts",
"scripts": {
"build": "webpack",
"build": "webpack && node copy-types.js",
"css": "lessc src/aria-autocomplete.less dist/aria-autocomplete.css"
},
"repository": {
Expand Down
1 change: 1 addition & 0 deletions src/aria-autocomplete-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ export interface IAriaAutocompleteApi {
}

declare function AriaAutocomplete(element: HTMLElement, options?: IAriaAutocompleteOptions): IAriaAutocompleteApi;
export default AriaAutocomplete;

0 comments on commit 50f286b

Please sign in to comment.