UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

52 lines (51 loc) 1.39 kB
/** * DevExtreme (esm/__internal/ui/html_editor/modules/m_widget_collector.js) * Version: 24.2.7 * Build date: Mon Apr 28 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import { each } from "../../../../core/utils/iterator"; export default class WidgetCollector { constructor() { this._collection = [] } clear() { this._collection = [] } add(name, instance) { this._collection.push({ name: name, instance: instance }) } remove(name) { this._collection = this._collection.filter((item => item.name !== name)) } getByName(widgetName) { let widget = null; each(this._collection, ((index, _ref) => { let { name: name, instance: instance } = _ref; if (name === widgetName) { widget = instance; return false } })); return widget } each(handler) { this._collection.forEach((_ref2 => { let { name: name, instance: instance } = _ref2; return instance && handler(name, instance) })) } }