@tamagui/react-native-web-lite
Version:
React Native for Web
154 lines (153 loc) • 7.01 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: !0 });
}, __copyProps = (to, from, except, desc) => {
if (from && typeof from == "object" || typeof from == "function")
for (let key of __getOwnPropNames(from))
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
var ChildListCollection_exports = {};
__export(ChildListCollection_exports, {
default: () => ChildListCollection
});
module.exports = __toCommonJS(ChildListCollection_exports);
var import_react_native_web_internals = require("@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) {
(0, import_react_native_web_internals.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);
(0, import_react_native_web_internals.invariant)(cellKey != null, "Trying to remove non-present child list"), this._childrenToCellKey.delete(list);
var cellLists = this._cellKeyToChildren.get(cellKey);
(0, import_react_native_web_internals.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;
}();
//# sourceMappingURL=ChildListCollection.js.map