UNPKG

@tamagui/react-native-web-lite

Version:
137 lines (135 loc) 5.81 kB
import { invariant } from "@tamagui/react-native-web-internals"; function _class_call_check(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor); } } function _create_class(Constructor, protoProps, staticProps) { return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), Constructor; } function _define_property(obj, key, value) { return key in obj ? Object.defineProperty(obj, key, { value, enumerable: !0, configurable: !0, writable: !0 }) : obj[key] = value, obj; } var ChildListCollection = /* @__PURE__ */function () { "use strict"; function ChildListCollection2() { _class_call_check(this, ChildListCollection2), _define_property(this, "_cellKeyToChildren", /* @__PURE__ */new Map()), _define_property(this, "_childrenToCellKey", /* @__PURE__ */new Map()); } return _create_class(ChildListCollection2, [{ key: "add", value: function (list, cellKey) { invariant(!this._childrenToCellKey.has(list), "Trying to add already present child list"); var _this__cellKeyToChildren_get, cellLists = (_this__cellKeyToChildren_get = this._cellKeyToChildren.get(cellKey)) !== null && _this__cellKeyToChildren_get !== void 0 ? _this__cellKeyToChildren_get : /* @__PURE__ */new Set(); cellLists.add(list), this._cellKeyToChildren.set(cellKey, cellLists), this._childrenToCellKey.set(list, cellKey); } }, { key: "remove", value: function (list) { var cellKey = this._childrenToCellKey.get(list); invariant(cellKey != null, "Trying to remove non-present child list"), this._childrenToCellKey.delete(list); var cellLists = this._cellKeyToChildren.get(cellKey); invariant(cellLists, "_cellKeyToChildren should contain cellKey"), cellLists.delete(list), cellLists.size === 0 && this._cellKeyToChildren.delete(cellKey); } }, { key: "forEach", value: function (fn) { var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0; try { for (var _iterator = this._cellKeyToChildren.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) { var listSet = _step.value, _iteratorNormalCompletion1 = !0, _didIteratorError1 = !1, _iteratorError1 = void 0; try { for (var _iterator1 = listSet[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) { var list = _step1.value; fn(list); } } catch (err) { _didIteratorError1 = !0, _iteratorError1 = err; } finally { try { !_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return(); } finally { if (_didIteratorError1) throw _iteratorError1; } } } } catch (err) { _didIteratorError = !0, _iteratorError = err; } finally { try { !_iteratorNormalCompletion && _iterator.return != null && _iterator.return(); } finally { if (_didIteratorError) throw _iteratorError; } } } }, { key: "forEachInCell", value: function (cellKey, fn) { var _this__cellKeyToChildren_get, listSet = (_this__cellKeyToChildren_get = this._cellKeyToChildren.get(cellKey)) !== null && _this__cellKeyToChildren_get !== void 0 ? _this__cellKeyToChildren_get : [], _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0; try { for (var _iterator = listSet[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) { var list = _step.value; fn(list); } } catch (err) { _didIteratorError = !0, _iteratorError = err; } finally { try { !_iteratorNormalCompletion && _iterator.return != null && _iterator.return(); } finally { if (_didIteratorError) throw _iteratorError; } } } }, { key: "anyInCell", value: function (cellKey, fn) { var _this__cellKeyToChildren_get, listSet = (_this__cellKeyToChildren_get = this._cellKeyToChildren.get(cellKey)) !== null && _this__cellKeyToChildren_get !== void 0 ? _this__cellKeyToChildren_get : [], _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0; try { for (var _iterator = listSet[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) { var list = _step.value; if (fn(list)) return !0; } } catch (err) { _didIteratorError = !0, _iteratorError = err; } finally { try { !_iteratorNormalCompletion && _iterator.return != null && _iterator.return(); } finally { if (_didIteratorError) throw _iteratorError; } } return !1; } }, { key: "size", value: function () { return this._childrenToCellKey.size; } }]), ChildListCollection2; }(); export { ChildListCollection as default }; //# sourceMappingURL=ChildListCollection.native.js.map