@textcomplete/core
Advanced tools
Comparing version 0.1.7 to 0.1.8
@@ -68,3 +68,2 @@ import { EventEmitter } from "eventemitter3"; | ||
activate(index: number): this; | ||
deactivateAll(): this; | ||
isShown(): boolean; | ||
@@ -84,3 +83,2 @@ getActiveItem(): DropdownItem | null; | ||
private readonly props; | ||
private readonly activationHandler; | ||
readonly el: HTMLLIElement; | ||
@@ -90,3 +88,3 @@ private active; | ||
private readonly activeClassName; | ||
constructor(dropdown: Dropdown, index: number, searchResult: SearchResult<unknown>, props: DropdownItemOption, activationHandler: any); | ||
constructor(dropdown: Dropdown, index: number, searchResult: SearchResult<unknown>, props: DropdownItemOption); | ||
destroy(): this; | ||
@@ -93,0 +91,0 @@ activate(): this; |
@@ -50,6 +50,3 @@ "use strict"; | ||
.slice(0, this.option.maxCount || exports.DEFAULT_DROPDOWN_MAX_COUNT) | ||
.map((r, index) => { | ||
var _a; | ||
return new DropdownItem(this, index, r, ((_a = this.option) === null || _a === void 0 ? void 0 : _a.item) || {}, this.activate.bind(this, index)); | ||
}); | ||
.map((r, index) => { var _a; return new DropdownItem(this, index, r, ((_a = this.option) === null || _a === void 0 ? void 0 : _a.item) || {}); }); | ||
this.setStrategyId(searchResults[0]) | ||
@@ -152,3 +149,5 @@ .renderEdge(searchResults, "header") | ||
if (this.activeIndex !== index) { | ||
this.deactivateAll(); | ||
if (this.activeIndex != null) { | ||
this.items[this.activeIndex].deactivate(); | ||
} | ||
this.activeIndex = index; | ||
@@ -159,6 +158,2 @@ this.items[index].activate(); | ||
} | ||
deactivateAll() { | ||
this.items.forEach((i) => i.deactivate()); | ||
return this; | ||
} | ||
isShown() { | ||
@@ -254,3 +249,3 @@ return this.shown; | ||
class DropdownItem { | ||
constructor(dropdown, index, searchResult, props, activationHandler) { | ||
constructor(dropdown, index, searchResult, props) { | ||
this.dropdown = dropdown; | ||
@@ -260,3 +255,2 @@ this.index = index; | ||
this.props = props; | ||
this.activationHandler = activationHandler; | ||
this.active = false; | ||
@@ -278,3 +272,2 @@ this.onClick = (e) => { | ||
li.addEventListener("touchstart", this.onClick); | ||
li.addEventListener("mouseenter", activationHandler); | ||
this.el = li; | ||
@@ -281,0 +274,0 @@ } |
{ | ||
"name": "@textcomplete/core", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "Textcomplete core.", | ||
@@ -40,3 +40,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "f5fec92a8e7bbab791409f5129cf2a499ba4d67e" | ||
"gitHead": "92391696179af51f369898e6f666923ac4c93de0" | ||
} |
@@ -81,10 +81,3 @@ import { EventEmitter } from "eventemitter3" | ||
.map( | ||
(r, index) => | ||
new DropdownItem( | ||
this, | ||
index, | ||
r, | ||
this.option?.item || {}, | ||
this.activate.bind(this, index) | ||
) | ||
(r, index) => new DropdownItem(this, index, r, this.option?.item || {}) | ||
) | ||
@@ -194,3 +187,5 @@ this.setStrategyId(searchResults[0]) | ||
if (this.activeIndex !== index) { | ||
this.deactivateAll() | ||
if (this.activeIndex != null) { | ||
this.items[this.activeIndex].deactivate() | ||
} | ||
this.activeIndex = index | ||
@@ -202,7 +197,2 @@ this.items[index].activate() | ||
deactivateAll(): this { | ||
this.items.forEach((i) => i.deactivate()) | ||
return this | ||
} | ||
isShown(): boolean { | ||
@@ -318,4 +308,3 @@ return this.shown | ||
public readonly searchResult: SearchResult<unknown>, | ||
private readonly props: DropdownItemOption, | ||
private readonly activationHandler: any | ||
private readonly props: DropdownItemOption | ||
) { | ||
@@ -336,3 +325,2 @@ this.className = this.props.className || DEFAULT_DROPDOWN_ITEM_CLASS_NAME | ||
li.addEventListener("touchstart", this.onClick) | ||
li.addEventListener("mouseenter", activationHandler) | ||
@@ -339,0 +327,0 @@ this.el = li |
Sorry, the diff of this file is not supported yet
84010
1850