mj-context-menu
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -9,4 +9,4 @@ import { AbstractPostable } from './abstract_postable.js'; | ||
protected role: string; | ||
protected _items: Item[]; | ||
private _baseMenu; | ||
protected _items: Item[]; | ||
private _focused; | ||
@@ -13,0 +13,0 @@ set baseMenu(menu: Menu); |
@@ -38,4 +38,4 @@ "use strict"; | ||
_this.role = 'menu'; | ||
_this._items = []; | ||
_this._baseMenu = null; | ||
_this._items = []; | ||
return _this; | ||
@@ -42,0 +42,0 @@ } |
@@ -7,2 +7,3 @@ import { AbstractMenu } from './abstract_menu.js'; | ||
factory: ParserFactory; | ||
id: string; | ||
private moving; | ||
@@ -13,3 +14,2 @@ private _frame; | ||
private widgets; | ||
id: string; | ||
static fromJson(factory: ParserFactory, { pool: pool, items: items, id: id }: { | ||
@@ -36,6 +36,6 @@ pool: Array<Object>; | ||
unpostWidgets(): void; | ||
private move_; | ||
toJson(): { | ||
type: string; | ||
}; | ||
private move_; | ||
} |
@@ -26,6 +26,6 @@ "use strict"; | ||
_this.factory = factory; | ||
_this.id = ''; | ||
_this.moving = false; | ||
_this._store = new menu_store_js_1.MenuStore(_this); | ||
_this.widgets = []; | ||
_this.id = ''; | ||
_this.variablePool = new variable_pool_js_1.VariablePool(); | ||
@@ -163,2 +163,5 @@ return _this; | ||
}; | ||
ContextMenu.prototype.toJson = function () { | ||
return { type: '' }; | ||
}; | ||
ContextMenu.prototype.move_ = function (next) { | ||
@@ -172,6 +175,2 @@ if (this.anchor && next !== this.anchor) { | ||
}; | ||
ContextMenu.prototype.toJson = function () { | ||
return { type: '' | ||
}; | ||
}; | ||
return ContextMenu; | ||
@@ -178,0 +177,0 @@ }(abstract_menu_js_1.AbstractMenu)); |
import { Menu } from './menu.js'; | ||
import { ContextMenu } from './context_menu.js'; | ||
import { Item } from './item.js'; | ||
import { SelectionBox } from './selection_box.js'; | ||
import { ParserFactory, ParseMethod } from './parser_factory.js'; | ||
export declare class Parser { | ||
private _initList; | ||
factory: ParserFactory; | ||
private readonly _factory; | ||
constructor(init?: [string, ParseMethod][]); | ||
contextMenu({ menu: menu }: { | ||
menu: { | ||
pool: Array<Object>; | ||
items: Array<Object>; | ||
id: string; | ||
}; | ||
}): ContextMenu; | ||
items(factory: ParserFactory, its: any[], ctxt: Menu): Item[]; | ||
item(factory: ParserFactory, item: any, ctxt: Menu): Item; | ||
selectionBox(json: JSON, ctxt: ContextMenu): SelectionBox; | ||
get factory(): ParserFactory; | ||
items(_factory: ParserFactory, its: any[], ctxt: Menu): Item[]; | ||
parse({ type: kind, ...json }: { | ||
type: string; | ||
[k: string]: any; | ||
}, ...rest: any[]): any; | ||
}, ...rest: any[]): Item; | ||
} |
@@ -29,2 +29,13 @@ "use strict"; | ||
}; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
var __spread = (this && this.__spread) || function () { | ||
@@ -37,3 +48,2 @@ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); | ||
var item_command_js_1 = require("./item_command.js"); | ||
var menu_util_js_1 = require("./menu_util.js"); | ||
var context_menu_js_1 = require("./context_menu.js"); | ||
@@ -68,7 +78,6 @@ var variable_js_1 = require("./variable.js"); | ||
['items', this.items.bind(this)], | ||
['item', this.item.bind(this)], | ||
['selectionMenu', selection_box_js_1.SelectionMenu.fromJson.bind(selection_box_js_1.SelectionMenu)], | ||
['selectionBox', selection_box_js_1.SelectionBox.fromJson.bind(selection_box_js_1.SelectionBox)] | ||
]; | ||
this.factory = new parser_factory_js_1.ParserFactory(this._initList); | ||
this._factory = new parser_factory_js_1.ParserFactory(this._initList); | ||
init.forEach(function (_a) { | ||
@@ -79,31 +88,38 @@ var _b = __read(_a, 2), x = _b[0], y = _b[1]; | ||
} | ||
Parser.prototype.contextMenu = function (_a) { | ||
var menu = _a.menu; | ||
if (!menu) { | ||
menu_util_js_1.MenuUtil.error(null, 'Wrong JSON format for menu.'); | ||
return null; | ||
Object.defineProperty(Parser.prototype, "factory", { | ||
get: function () { | ||
return this._factory; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Parser.prototype.items = function (_factory, its, ctxt) { | ||
var e_1, _a; | ||
var hidden = []; | ||
try { | ||
for (var its_1 = __values(its), its_1_1 = its_1.next(); !its_1_1.done; its_1_1 = its_1.next()) { | ||
var item = its_1_1.value; | ||
var entry = this.parse(item, ctxt); | ||
if (!entry) { | ||
continue; | ||
} | ||
ctxt.items.push(entry); | ||
if (item.disabled) { | ||
entry.disable(); | ||
} | ||
if (item.hidden) { | ||
hidden.push(entry); | ||
} | ||
} | ||
} | ||
return this.factory.get('contextMenu')(this.factory, { menu: menu }); | ||
}; | ||
Parser.prototype.items = function (factory, its, ctxt) { | ||
var _this = this; | ||
var hidden = its.map(function (x) { return [_this.item(factory, x, ctxt), x.hidden]; }); | ||
hidden.forEach(function (x) { return x[1] && x[0].hide(); }); | ||
return hidden.map(function (x) { return x[0]; }); | ||
}; | ||
Parser.prototype.item = function (factory, item, ctxt) { | ||
var func = this.factory.get(item['type']); | ||
if (func) { | ||
var menuItem = func(factory, item, ctxt); | ||
ctxt.items.push(menuItem); | ||
if (item['disabled']) { | ||
menuItem.disable(); | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (its_1_1 && !its_1_1.done && (_a = its_1.return)) _a.call(its_1); | ||
} | ||
return menuItem; | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
return null; | ||
hidden.forEach(function (x) { return x.hide(); }); | ||
return ctxt.items; | ||
}; | ||
Parser.prototype.selectionBox = function (json, ctxt) { | ||
return this.factory.get('selectionBox')(this.factory, json, ctxt); | ||
}; | ||
Parser.prototype.parse = function (_a) { | ||
@@ -115,3 +131,4 @@ var rest = []; | ||
var kind = _a.type, json = __rest(_a, ["type"]); | ||
return this.factory.get(kind).apply(void 0, __spread([this.factory, json], rest)); | ||
var func = this.factory.get(kind); | ||
return func ? func.apply(void 0, __spread([this.factory, json], rest)) : null; | ||
}; | ||
@@ -118,0 +135,0 @@ return Parser; |
{ | ||
"name": "mj-context-menu", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "A generic context menu", | ||
@@ -5,0 +5,0 @@ "main": "dist/ContextMenu.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6885
562980