From fb63b47f076ca1776ce94addfd884c571cb5d875 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Dec 2017 06:58:32 -0800 Subject: [PATCH] extended-listbox: Provides its own types (#22323) --- notNeededPackages.json | 6 + .../extended-listbox-tests.ts | 134 ----------------- types/extended-listbox/index.d.ts | 141 ------------------ types/extended-listbox/tsconfig.json | 24 --- types/extended-listbox/tslint.json | 79 ---------- 5 files changed, 6 insertions(+), 378 deletions(-) delete mode 100644 types/extended-listbox/extended-listbox-tests.ts delete mode 100644 types/extended-listbox/index.d.ts delete mode 100644 types/extended-listbox/tsconfig.json delete mode 100644 types/extended-listbox/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index cab0815f31..51367512db 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -234,6 +234,12 @@ "sourceRepoURL": "https://github.com/ctavan/express-validator", "asOfVersion": "3.0.0" }, + { + "libraryName": "extended-listbox", + "typingsPackageName": "extended-listbox", + "sourceRepoURL": "https://github.com/code-chris/extended-listbox", + "asOfVersion": "4.0.1" + }, { "libraryName": "JSON-Patch", "typingsPackageName": "fast-json-patch", diff --git a/types/extended-listbox/extended-listbox-tests.ts b/types/extended-listbox/extended-listbox-tests.ts deleted file mode 100644 index 571a455300..0000000000 --- a/types/extended-listbox/extended-listbox-tests.ts +++ /dev/null @@ -1,134 +0,0 @@ -const testElement: HTMLElement = document.getElementById("test"); - -// Create Listbox with defaults -let instance: SingleSelectListBox = new SingleSelectListBox(testElement); -instance = new MultiSelectListBox(testElement); - - -// Create with options -let settings = {}; -settings.searchBar = false; -settings.searchBarWatermark = "Search"; -settings.searchBarButton = { icon: "fa fa-search", visible: true, onClick: function () { alert(); } }; -settings.getItems = (): (string|ListBoxItem)[] => { - return ["Test1"]; -}; -settings.onItemsChanged = (event: ListBoxEvent): void => { - console.log(event.eventName); - console.log(event.args); - console.log(event.target); -}; -settings.onFilterChanged = (event: ListBoxEvent): void => { - console.log(event.args); -}; -settings.onValueChanged = (event: ListBoxEvent): void => { - console.log(event.args); -}; -settings.onItemDoubleClicked = (event: ListBoxEvent): void => { - console.log(event.args); -}; -settings.onItemEnterPressed = (event: ListBoxEvent): void => { - console.log(event.args); -}; - -instance = new SingleSelectListBox(testElement, settings); -instance = new MultiSelectListBox(testElement, settings); - - -/////// NEW API /////// - -// Add string item -var id: string = instance.addItem("Test2"); - - -// Add item -var item: ListBoxItem = {}; -item.selected = true; -item.disabled = false; -item.childItems = [{ text: "Test4" }]; -item.groupHeader = false; -item.id = "ouetioreit"; -item.index = 0; -item.text = "Test3"; -id = instance.addItem(item); - - -// Add string items -var ids: string[] = instance.addItems(["Test2", "Test1"]); - - -// Remove item -instance.removeItem(id); - - -// Remove items -instance.removeItems([id, ids[0]]); - - -// Get item -var i: ListBoxItem = instance.getItem(id); - - -// Get items -var allItems: ListBoxItem[] = instance.getItems(); - -// Get selected items -var allItems: ListBoxItem[] = instance.getSelection(); - - -// Move item up -var newIndex: number = instance.moveItemUp(i.id); - - -// Move item down -newIndex = instance.moveItemDown(i.id); - - -// Move item to top -var newIndex: number = instance.moveItemToTop(i.id); - - -// Move item to bottom -newIndex = instance.moveItemToBottom(i.id); - - -// Clear selection -instance.clearSelection(); - - -// Enable -instance.enable(false); - - -// Destroy -instance.destroy(); - - -// onValueChanged -settings.onValueChanged = (event: ListBoxEvent) => { - console.log(event.args); -}; - - -// onItemsChanged -settings.onItemsChanged = (event: ListBoxEvent) => { - console.log(event.args); -}; - - -// onFilterChanged -settings.onFilterChanged = (event: ListBoxEvent) => { - console.log(event.args); -}; - - -// onItemEnterPressed -settings.onItemEnterPressed = (event: ListBoxEvent) => { - console.log(event.args); -}; - - -// onItemDoubleClicked -settings.onItemDoubleClicked = (event: ListBoxEvent) => { - console.log(event.args); -}; diff --git a/types/extended-listbox/index.d.ts b/types/extended-listbox/index.d.ts deleted file mode 100644 index 5d6e7822d5..0000000000 --- a/types/extended-listbox/index.d.ts +++ /dev/null @@ -1,141 +0,0 @@ -// Type definitions for extended-listbox 4.0.x -// Project: https://github.com/code-chris/extended-listbox -// Definitions by: Christian Kotzbauer -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface ListBoxItem { - /** display text */ - text?: string; - - /** unique identifier, if not set it will be generated */ - id?: string; - - /** index position from the item in the list; only used for manual addItem api calls */ - index?: number; - - /** determines if the item should be clickable */ - disabled?: boolean; - - /** determines if the item is selected */ - selected?: boolean; - - /** determines if the item has childItems */ - groupHeader?: boolean; - - /** display text or id of the parent; only used for manual addItem api calls */ - parentGroupId?: string; - - /** list of childItems */ - childItems?: (string | ListBoxItem)[]; -} - -interface ListBoxSearchBarButtonOptions { - /** determines if the button is visible */ - visible?: boolean; - - /** css class for the i-tag of the button */ - icon?: string; - - /** callback for button click */ - onClick?: () => void; -} - -interface ListBoxSettings { - /** determines if the searchBar is visible */ - searchBar?: boolean; - - /** watermark (placeholder) for the searchBar */ - searchBarWatermark?: string; - - /** settings for the searchBar button */ - searchBarButton?: ListBoxSearchBarButtonOptions; - - /** function which returns a array of items */ - getItems?: () => (string | ListBoxItem)[]; - - /** callback for selection changes */ - onValueChanged?: (event: ListBoxEvent) => void; - - /** callback for searchBar text changes */ - onFilterChanged?: (event: ListBoxEvent) => void; - - /** callback for item changes (item added, item removed, item order) */ - onItemsChanged?: (event: ListBoxEvent) => void; - - /** callback for enter keyPress event on an item */ - onItemEnterPressed?: (event: ListBoxEvent) => void; - - /** callback for doubleClick event on an item */ - onItemDoubleClicked?: (event: ListBoxEvent) => void; -} - -interface ListBoxEvent { - /** unique event name */ - eventName: string; - - /** target object for which event is triggered */ - target: Element; - - /** any object */ - args: any; -} - -interface BaseListBox { - /** Adds a new item to the list */ - addItem(item: string | ListBoxItem): string; - - /** Adds new items to the list */ - addItems(items: (string | ListBoxItem)[]): string[]; - - /** Removes a item from the list */ - removeItem(identifier: string): void; - - /** Removes items from the list */ - removeItems(identifiers: string[]): void; - - /** Reverts all changes from the DOM */ - destroy(): void; - - /** Resets the selection state of all items */ - clearSelection(): void; - - /** Returns a item object for the given id or display text */ - getItem(identifier: string): ListBoxItem; - - /** Returns all item objects */ - getItems(): ListBoxItem[]; - - /** Decreases the index of the matching item by one */ - moveItemUp(identifier: string): number; - - /** Increases the index of the matching item by one */ - moveItemDown(identifier: string): number; - - /** Moves item to the bottom of the list */ - moveItemToBottom(identifier: string): number; - - /** Moves item to the top of the list */ - moveItemToTop(identifier: string): number; - - /** Enables or disables the whole list and all childs */ - enable(state: boolean): void; - - /** Returns all ListBoxItem's which are selected */ - getSelection(): ListBoxItem[]; -} - -interface SingleSelectListBox extends BaseListBox { -} - -interface MultiSelectListBox extends BaseListBox { -} - -declare var SingleSelectListBox: { - prototype: SingleSelectListBox; - new(domElement: HTMLElement, options?: ListBoxSettings): SingleSelectListBox; -}; - -declare var MultiSelectListBox: { - prototype: MultiSelectListBox; - new(domElement: HTMLElement, options?: ListBoxSettings): MultiSelectListBox; -}; diff --git a/types/extended-listbox/tsconfig.json b/types/extended-listbox/tsconfig.json deleted file mode 100644 index 38eda11579..0000000000 --- a/types/extended-listbox/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "extended-listbox-tests.ts" - ] -} \ No newline at end of file diff --git a/types/extended-listbox/tslint.json b/types/extended-listbox/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/extended-listbox/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -}