@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
53 lines • 1.9 kB
JavaScript
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
var SpotlightHandler = /** @class */ (function () {
function SpotlightHandler(_handlerFactory) {
this._handlerFactory = _handlerFactory;
this._data = new Map();
}
SpotlightHandler.prototype.showSpotlight = function (items, options) {
var _this = this;
items.forEach(function (item) {
var data = {
item: item,
handler: _this._handlerFactory.get(item),
options: options
};
_this._data.set(item.id, data);
});
};
SpotlightHandler.prototype.hideSpotlight = function (items) {
var _this = this;
if (items == null) {
items = __spread(this._data.values()).map(function (data) { return data === null || data === void 0 ? void 0 : data.item; });
}
items.forEach(function (item) {
if (_this._data.has(item.id))
_this._data.delete(item.id);
});
};
SpotlightHandler.prototype.getSpotlightItems = function () {
return __spread(this._data.values());
};
return SpotlightHandler;
}());
export { SpotlightHandler };
//# sourceMappingURL=SpotlightHandler.js.map