@tamagui/react-native-web-lite
Version:
React Native for Web
62 lines (61 loc) • 2.71 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, {
ChildListCollection: () => ChildListCollection,
default: () => ChildListCollection_default
});
module.exports = __toCommonJS(ChildListCollection_exports);
var import_react_native_web_internals = require("@tamagui/react-native-web-internals");
class ChildListCollection {
_cellKeyToChildren = /* @__PURE__ */ new Map();
_childrenToCellKey = /* @__PURE__ */ new Map();
add(list, cellKey) {
(0, import_react_native_web_internals.invariant)(
!this._childrenToCellKey.has(list),
"Trying to add already present child list"
);
const cellLists = this._cellKeyToChildren.get(cellKey) ?? /* @__PURE__ */ new Set();
cellLists.add(list), this._cellKeyToChildren.set(cellKey, cellLists), this._childrenToCellKey.set(list, cellKey);
}
remove(list) {
const 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);
const 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);
}
forEach(fn) {
for (const listSet of this._cellKeyToChildren.values())
for (const list of listSet)
fn(list);
}
forEachInCell(cellKey, fn) {
const listSet = this._cellKeyToChildren.get(cellKey) ?? [];
for (const list of listSet)
fn(list);
}
anyInCell(cellKey, fn) {
const listSet = this._cellKeyToChildren.get(cellKey) ?? [];
for (const list of listSet)
if (fn(list))
return !0;
return !1;
}
size() {
return this._childrenToCellKey.size;
}
}
var ChildListCollection_default = ChildListCollection;
//# sourceMappingURL=ChildListCollection.js.map