@tamagui/animate-presence 1.0.1-beta.21 → 1.0.1-beta.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/AnimatePresence.js +81 -54
- package/dist/cjs/AnimatePresence.js.map +3 -3
- package/dist/cjs/LayoutGroupContext.js +1 -0
- package/dist/cjs/LayoutGroupContext.js.map +1 -1
- package/dist/cjs/PresenceChild.js +43 -38
- package/dist/cjs/PresenceChild.js.map +3 -3
- package/dist/cjs/{AnimatePresenceContext.js → PresenceContext.js} +8 -7
- package/dist/cjs/PresenceContext.js.map +7 -0
- package/dist/cjs/index.js +2 -13
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.js +1 -0
- package/dist/cjs/types.js.map +2 -2
- package/dist/cjs/usePresence.js +52 -0
- package/dist/cjs/usePresence.js.map +7 -0
- package/dist/esm/AnimatePresence.js +79 -57
- package/dist/esm/AnimatePresence.js.map +2 -2
- package/dist/esm/LayoutGroupContext.js +0 -0
- package/dist/esm/LayoutGroupContext.js.map +1 -1
- package/dist/esm/PresenceChild.js +38 -38
- package/dist/esm/PresenceChild.js.map +3 -3
- package/dist/esm/PresenceContext.js +6 -0
- package/dist/esm/PresenceContext.js.map +7 -0
- package/dist/esm/index.js +1 -5
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/types.js +0 -0
- package/dist/esm/types.js.map +0 -0
- package/dist/esm/usePresence.js +26 -0
- package/dist/esm/usePresence.js.map +7 -0
- package/dist/jsx/AnimatePresence.js +56 -38
- package/dist/jsx/AnimatePresence.js.map +7 -0
- package/dist/jsx/LayoutGroupContext.js +1 -0
- package/dist/jsx/LayoutGroupContext.js.map +7 -0
- package/dist/jsx/PresenceChild.js +35 -36
- package/dist/jsx/PresenceChild.js.map +7 -0
- package/dist/jsx/PresenceContext.js +6 -0
- package/dist/jsx/PresenceContext.js.map +7 -0
- package/dist/jsx/index.js +2 -5
- package/dist/jsx/index.js.map +7 -0
- package/dist/jsx/types.js +1 -0
- package/dist/jsx/types.js.map +7 -0
- package/dist/jsx/usePresence.js +26 -0
- package/dist/jsx/usePresence.js.map +7 -0
- package/package.json +10 -5
- package/src/AnimatePresence.tsx +275 -0
- package/src/LayoutGroupContext.tsx +8 -0
- package/src/PresenceChild.tsx +81 -0
- package/src/index.ts +2 -0
- package/src/types.ts +81 -0
- package/types/AnimatePresence.d.ts +34 -8
- package/types/PresenceChild.d.ts +4 -3
- package/types/{AnimatePresenceContext.d.ts → PresenceContext.d.ts} +5 -4
- package/types/index.d.ts +1 -2
- package/types/types.d.ts +63 -0
- package/types/usePresence.d.ts +14 -0
- package/dist/cjs/AnimatePresenceContext.js.map +0 -7
- package/dist/cjs/useEntering.js +0 -57
- package/dist/cjs/useEntering.js.map +0 -7
- package/dist/esm/AnimatePresenceContext.js +0 -6
- package/dist/esm/AnimatePresenceContext.js.map +0 -7
- package/dist/esm/useEntering.js +0 -33
- package/dist/esm/useEntering.js.map +0 -7
- package/dist/jsx/AnimatePresenceContext.js +0 -5
- package/dist/jsx/useEntering.js +0 -32
- package/types/AnimatePresence.d.ts.map +0 -1
- package/types/AnimatePresenceContext.d.ts.map +0 -1
- package/types/LayoutGroupContext.d.ts.map +0 -1
- package/types/PresenceChild.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/types.d.ts.map +0 -1
- package/types/useEntering.d.ts +0 -6
- package/types/useEntering.d.ts.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
8
|
var __export = (target, all) => {
|
|
9
9
|
for (var name in all)
|
|
10
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -17,19 +17,23 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var AnimatePresence_exports = {};
|
|
23
26
|
__export(AnimatePresence_exports, {
|
|
24
27
|
AnimatePresence: () => AnimatePresence
|
|
25
28
|
});
|
|
26
29
|
module.exports = __toCommonJS(AnimatePresence_exports);
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
31
|
var import_core = require("@tamagui/core");
|
|
28
32
|
var import_react = __toESM(require("react"));
|
|
29
33
|
var import_LayoutGroupContext = require("./LayoutGroupContext");
|
|
30
34
|
var import_PresenceChild = require("./PresenceChild");
|
|
31
35
|
import_react.default["keep"];
|
|
32
|
-
const getChildKey =
|
|
36
|
+
const getChildKey = (child) => child.key || "";
|
|
33
37
|
const isDev = process.env.NODE_ENV !== "production";
|
|
34
38
|
function updateChildLookup(children, allChildren) {
|
|
35
39
|
const seenChildren = isDev ? /* @__PURE__ */ new Set() : null;
|
|
@@ -42,17 +46,27 @@ function updateChildLookup(children, allChildren) {
|
|
|
42
46
|
allChildren.set(key, child);
|
|
43
47
|
});
|
|
44
48
|
}
|
|
45
|
-
__name(updateChildLookup, "updateChildLookup");
|
|
46
49
|
function onlyElements(children) {
|
|
47
50
|
const filtered = [];
|
|
48
|
-
import_react.Children.forEach(children, (child) => {
|
|
49
|
-
if ((0, import_react.isValidElement)(child))
|
|
50
|
-
|
|
51
|
+
import_react.Children.forEach(children, (child, index) => {
|
|
52
|
+
if ((0, import_react.isValidElement)(child)) {
|
|
53
|
+
if (!child.key) {
|
|
54
|
+
if (process.env.NODE_ENV === "development") {
|
|
55
|
+
console.warn(`No key given to AnimatePresence child, assigning index as key`);
|
|
56
|
+
}
|
|
57
|
+
filtered.push(
|
|
58
|
+
import_react.default.cloneElement(child, {
|
|
59
|
+
key: index
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
} else {
|
|
63
|
+
filtered.push(child);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
51
66
|
});
|
|
52
67
|
return filtered;
|
|
53
68
|
}
|
|
54
|
-
|
|
55
|
-
const AnimatePresence = /* @__PURE__ */ __name(({
|
|
69
|
+
const AnimatePresence = ({
|
|
56
70
|
children,
|
|
57
71
|
enterVariant,
|
|
58
72
|
exitVariant,
|
|
@@ -65,35 +79,38 @@ const AnimatePresence = /* @__PURE__ */ __name(({
|
|
|
65
79
|
const forceRenderLayoutGroup = (0, import_react.useContext)(import_LayoutGroupContext.LayoutGroupContext).forceRender;
|
|
66
80
|
if (forceRenderLayoutGroup)
|
|
67
81
|
forceRender = forceRenderLayoutGroup;
|
|
68
|
-
const
|
|
69
|
-
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
70
|
-
setIsMounted(true);
|
|
71
|
-
}, []);
|
|
82
|
+
const isMounted = (0, import_react.useRef)(false);
|
|
72
83
|
const filteredChildren = onlyElements(children);
|
|
73
84
|
let childrenToRender = filteredChildren;
|
|
74
85
|
const exiting = /* @__PURE__ */ new Set();
|
|
75
86
|
const presentChildren = (0, import_react.useRef)(childrenToRender);
|
|
76
87
|
const allChildren = (0, import_react.useRef)(/* @__PURE__ */ new Map()).current;
|
|
77
88
|
const isInitialRender = (0, import_react.useRef)(true);
|
|
89
|
+
(0, import_react.useEffect)(() => {
|
|
90
|
+
isMounted.current = true;
|
|
91
|
+
return () => {
|
|
92
|
+
isMounted.current = false;
|
|
93
|
+
isInitialRender.current = true;
|
|
94
|
+
allChildren.clear();
|
|
95
|
+
exiting.clear();
|
|
96
|
+
};
|
|
97
|
+
}, []);
|
|
78
98
|
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
79
99
|
isInitialRender.current = false;
|
|
80
100
|
updateChildLookup(filteredChildren, allChildren);
|
|
81
101
|
presentChildren.current = childrenToRender;
|
|
82
102
|
});
|
|
83
|
-
(0, import_core.useUnmountEffect)(() => {
|
|
84
|
-
isInitialRender.current = true;
|
|
85
|
-
allChildren.clear();
|
|
86
|
-
exiting.clear();
|
|
87
|
-
});
|
|
88
103
|
if (isInitialRender.current) {
|
|
89
|
-
return /* @__PURE__ */
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
105
|
+
children: childrenToRender.map((child) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_PresenceChild.PresenceChild, {
|
|
106
|
+
isPresent: true,
|
|
107
|
+
exitVariant,
|
|
108
|
+
enterVariant,
|
|
109
|
+
initial: initial ? void 0 : false,
|
|
110
|
+
presenceAffectsLayout,
|
|
111
|
+
children: child
|
|
112
|
+
}, getChildKey(child)))
|
|
113
|
+
});
|
|
97
114
|
}
|
|
98
115
|
childrenToRender = [...childrenToRender];
|
|
99
116
|
const presentKeys = presentChildren.current.map(getChildKey);
|
|
@@ -115,42 +132,52 @@ const AnimatePresence = /* @__PURE__ */ __name(({
|
|
|
115
132
|
if (!child)
|
|
116
133
|
return;
|
|
117
134
|
const insertionIndex = presentKeys.indexOf(key);
|
|
118
|
-
childrenToRender.splice(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
childrenToRender.splice(
|
|
136
|
+
insertionIndex,
|
|
137
|
+
0,
|
|
138
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_PresenceChild.PresenceChild, {
|
|
139
|
+
isPresent: false,
|
|
140
|
+
onExitComplete: () => {
|
|
141
|
+
allChildren.delete(key);
|
|
142
|
+
exiting.delete(key);
|
|
143
|
+
const removeIndex = presentChildren.current.findIndex(
|
|
144
|
+
(presentChild) => presentChild.key === key
|
|
145
|
+
);
|
|
146
|
+
presentChildren.current.splice(removeIndex, 1);
|
|
147
|
+
if (!exiting.size) {
|
|
148
|
+
presentChildren.current = filteredChildren;
|
|
149
|
+
if (isMounted.current === false)
|
|
150
|
+
return;
|
|
151
|
+
forceRender();
|
|
152
|
+
onExitComplete == null ? void 0 : onExitComplete();
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
exitVariant,
|
|
156
|
+
enterVariant,
|
|
157
|
+
presenceAffectsLayout,
|
|
158
|
+
children: child
|
|
159
|
+
}, getChildKey(child))
|
|
160
|
+
);
|
|
138
161
|
});
|
|
139
162
|
childrenToRender = childrenToRender.map((child) => {
|
|
140
163
|
const key = child.key;
|
|
141
|
-
return exiting.has(key) ? child : /* @__PURE__ */
|
|
142
|
-
|
|
143
|
-
isEntering: void 0,
|
|
164
|
+
return exiting.has(key) ? child : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_PresenceChild.PresenceChild, {
|
|
165
|
+
isPresent: true,
|
|
144
166
|
exitVariant,
|
|
145
167
|
enterVariant,
|
|
146
|
-
presenceAffectsLayout
|
|
147
|
-
|
|
168
|
+
presenceAffectsLayout,
|
|
169
|
+
children: child
|
|
170
|
+
}, getChildKey(child));
|
|
148
171
|
});
|
|
149
172
|
if (process.env.NODE_ENV !== "production" && exitBeforeEnter && childrenToRender.length > 1) {
|
|
150
|
-
console.warn(
|
|
173
|
+
console.warn(
|
|
174
|
+
`You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This will lead to odd visual behaviour.`
|
|
175
|
+
);
|
|
151
176
|
}
|
|
152
|
-
return /* @__PURE__ */
|
|
153
|
-
|
|
177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
178
|
+
children: exiting.size ? childrenToRender : childrenToRender.map((child) => (0, import_react.cloneElement)(child))
|
|
179
|
+
});
|
|
180
|
+
};
|
|
154
181
|
AnimatePresence.displayName = "AnimatePresence";
|
|
155
182
|
// Annotate the CommonJS export names for ESM import in node:
|
|
156
183
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/AnimatePresence.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useForceUpdate, useIsomorphicLayoutEffect
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { useForceUpdate, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport React, {\n Children,\n ReactElement,\n ReactNode,\n cloneElement,\n isValidElement,\n useContext,\n useEffect,\n useRef,\n} from 'react'\n\nimport { LayoutGroupContext } from './LayoutGroupContext'\nimport { PresenceChild } from './PresenceChild'\nimport { AnimatePresenceProps } from './types'\n\nReact['keep']\n\ntype ComponentKey = string | number\n\nconst getChildKey = (child: ReactElement<any>): ComponentKey => child.key || ''\n\nconst isDev = process.env.NODE_ENV !== 'production'\n\nfunction updateChildLookup(\n children: ReactElement<any>[],\n allChildren: Map<ComponentKey, ReactElement<any>>\n) {\n const seenChildren = isDev ? new Set<ComponentKey>() : null\n\n children.forEach((child) => {\n const key = getChildKey(child)\n\n if (isDev && seenChildren && seenChildren.has(key)) {\n // eslint-disable-next-line no-console\n console.warn(`Children of AnimatePresence require unique keys. \"${key}\" is a duplicate.`)\n\n seenChildren.add(key)\n }\n\n allChildren.set(key, child)\n })\n}\n\nfunction onlyElements(children: ReactNode): ReactElement<any>[] {\n const filtered: ReactElement<any>[] = []\n\n // We use forEach here instead of map as map mutates the component key by preprending `.$`\n Children.forEach(children, (child, index) => {\n if (isValidElement(child)) {\n if (!child.key) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn(`No key given to AnimatePresence child, assigning index as key`)\n }\n filtered.push(\n React.cloneElement(child, {\n key: index,\n })\n )\n } else {\n filtered.push(child)\n }\n }\n })\n\n return filtered\n}\n\n/**\n * `AnimatePresence` enables the animation of components that have been removed from the tree.\n *\n * When adding/removing more than a single child, every child **must** be given a unique `key` prop.\n *\n * Any `motion` components that have an `exit` property defined will animate out when removed from\n * the tree.\n *\n * ```tsx\n * import { motion, AnimatePresence } from 'framer-motion'\n *\n * export const Items = ({ items }) => (\n * <AnimatePresence>\n * {items.map(item => (\n * <motion.div\n * key={item.id}\n * initial={{ opacity: 0 }}\n * animate={{ opacity: 1 }}\n * exit={{ opacity: 0 }}\n * />\n * ))}\n * </AnimatePresence>\n * )\n * ```\n *\n * You can sequence exit animations throughout a tree using variants.\n *\n * If a child contains multiple `motion` components with `exit` props, it will only unmount the child\n * once all `motion` components have finished animating out. Likewise, any components using\n * `usePresence` all need to call `safeToRemove`.\n *\n * @public\n */\nexport const AnimatePresence: React.FunctionComponent<\n React.PropsWithChildren<AnimatePresenceProps>\n> = ({\n children,\n enterVariant,\n exitVariant,\n initial = true,\n onExitComplete,\n exitBeforeEnter,\n presenceAffectsLayout = true,\n}) => {\n // We want to force a re-render once all exiting animations have finished. We\n // either use a local forceRender function, or one from a parent context if it exists.\n let forceRender = useForceUpdate()\n const forceRenderLayoutGroup = useContext(LayoutGroupContext).forceRender\n if (forceRenderLayoutGroup) forceRender = forceRenderLayoutGroup\n\n const isMounted = useRef(false)\n\n // Filter out any children that aren't ReactElements. We can only track ReactElements with a props.key\n const filteredChildren = onlyElements(children)\n let childrenToRender = filteredChildren\n\n const exiting = new Set<ComponentKey>()\n\n // Keep a living record of the children we're actually rendering so we\n // can diff to figure out which are entering and exiting\n const presentChildren = useRef(childrenToRender)\n\n // A lookup table to quickly reference components by key\n const allChildren = useRef(new Map<ComponentKey, ReactElement<any>>()).current\n\n // If this is the initial component render, just deal with logic surrounding whether\n // we play onMount animations or not.\n const isInitialRender = useRef(true)\n\n useEffect(() => {\n isMounted.current = true\n return () => {\n isMounted.current = false\n isInitialRender.current = true\n allChildren.clear()\n exiting.clear()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n useIsomorphicLayoutEffect(() => {\n isInitialRender.current = false\n updateChildLookup(filteredChildren, allChildren)\n presentChildren.current = childrenToRender\n })\n\n if (isInitialRender.current) {\n return (\n <>\n {childrenToRender.map((child) => (\n <PresenceChild\n key={getChildKey(child)}\n isPresent\n exitVariant={exitVariant}\n enterVariant={enterVariant}\n initial={initial ? undefined : false}\n presenceAffectsLayout={presenceAffectsLayout}\n >\n {child}\n </PresenceChild>\n ))}\n </>\n )\n }\n\n // If this is a subsequent render, deal with entering and exiting children\n childrenToRender = [...childrenToRender]\n\n // Diff the keys of the currently-present and target children to update our\n // exiting list.\n const presentKeys = presentChildren.current.map(getChildKey)\n const targetKeys = filteredChildren.map(getChildKey)\n\n // Diff the present children with our target children and mark those that are exiting\n const numPresent = presentKeys.length\n for (let i = 0; i < numPresent; i++) {\n const key = presentKeys[i]\n if (targetKeys.indexOf(key) === -1) {\n exiting.add(key)\n }\n }\n\n // If we currently have exiting children, and we're deferring rendering incoming children\n // until after all current children have exiting, empty the childrenToRender array\n if (exitBeforeEnter && exiting.size) {\n childrenToRender = []\n }\n\n // Loop through all currently exiting components and clone them to overwrite `animate`\n // with any `exit` prop they might have defined.\n exiting.forEach((key) => {\n // If this component is actually entering again, early return\n if (targetKeys.indexOf(key) !== -1) return\n\n const child = allChildren.get(key)\n if (!child) return\n\n const insertionIndex = presentKeys.indexOf(key)\n\n childrenToRender.splice(\n insertionIndex,\n 0,\n <PresenceChild\n key={getChildKey(child)}\n isPresent={false}\n onExitComplete={() => {\n allChildren.delete(key)\n exiting.delete(key)\n\n // Remove this child from the present children\n const removeIndex = presentChildren.current.findIndex(\n (presentChild) => presentChild.key === key\n )\n presentChildren.current.splice(removeIndex, 1)\n\n // Defer re-rendering until all exiting children have indeed left\n if (!exiting.size) {\n presentChildren.current = filteredChildren\n\n if (isMounted.current === false) return\n\n forceRender()\n onExitComplete?.()\n }\n }}\n exitVariant={exitVariant}\n enterVariant={enterVariant}\n presenceAffectsLayout={presenceAffectsLayout}\n >\n {child}\n </PresenceChild>\n )\n })\n\n // Add `MotionContext` even to children that don't need it to ensure we're rendering\n // the same tree between renders\n childrenToRender = childrenToRender.map((child) => {\n const key = child.key as string | number\n return exiting.has(key) ? (\n child\n ) : (\n <PresenceChild\n key={getChildKey(child)}\n isPresent\n exitVariant={exitVariant}\n enterVariant={enterVariant}\n presenceAffectsLayout={presenceAffectsLayout}\n >\n {child}\n </PresenceChild>\n )\n })\n\n if (process.env.NODE_ENV !== 'production' && exitBeforeEnter && childrenToRender.length > 1) {\n // eslint-disable-next-line no-console\n console.warn(\n `You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This will lead to odd visual behaviour.`\n )\n }\n\n return (\n <>{exiting.size ? childrenToRender : childrenToRender.map((child) => cloneElement(child))}</>\n )\n}\n\nAnimatePresence.displayName = 'AnimatePresence'\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/LayoutGroupContext.tsx"],
|
|
4
4
|
"sourcesContent": ["import { createContext } from 'react'\n\nexport interface LayoutGroupContextProps {\n id?: string\n forceRender?: VoidFunction\n}\n\nexport const LayoutGroupContext = createContext<LayoutGroupContextProps>({})\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8B;AAOvB,MAAM,yBAAqB,4BAAuC,CAAC,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
8
|
var __export = (target, all) => {
|
|
9
9
|
for (var name in all)
|
|
10
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -17,65 +17,70 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var PresenceChild_exports = {};
|
|
23
26
|
__export(PresenceChild_exports, {
|
|
24
27
|
PresenceChild: () => PresenceChild
|
|
25
28
|
});
|
|
26
29
|
module.exports = __toCommonJS(PresenceChild_exports);
|
|
27
|
-
var
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var import_use_presence = require("@tamagui/use-presence");
|
|
28
32
|
var React = __toESM(require("react"));
|
|
29
|
-
var
|
|
30
|
-
const PresenceChild =
|
|
33
|
+
var import_react = require("react");
|
|
34
|
+
const PresenceChild = ({
|
|
31
35
|
children,
|
|
32
36
|
initial,
|
|
33
|
-
|
|
37
|
+
isPresent,
|
|
34
38
|
onExitComplete,
|
|
35
39
|
exitVariant,
|
|
36
40
|
enterVariant,
|
|
37
41
|
presenceAffectsLayout
|
|
38
42
|
}) => {
|
|
39
|
-
const presenceChildren = (
|
|
40
|
-
const id = (0,
|
|
41
|
-
const context = React.useMemo(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
const presenceChildren = React.useMemo(newChildrenMap, []);
|
|
44
|
+
const id = (0, import_react.useId)() || "";
|
|
45
|
+
const context = React.useMemo(
|
|
46
|
+
() => {
|
|
47
|
+
return {
|
|
48
|
+
id,
|
|
49
|
+
initial,
|
|
50
|
+
isPresent,
|
|
51
|
+
exitVariant,
|
|
52
|
+
enterVariant,
|
|
53
|
+
onExitComplete: (id2) => {
|
|
54
|
+
presenceChildren.set(id2, true);
|
|
55
|
+
for (const isComplete of presenceChildren.values()) {
|
|
56
|
+
if (!isComplete) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
53
59
|
}
|
|
60
|
+
onExitComplete == null ? void 0 : onExitComplete();
|
|
61
|
+
},
|
|
62
|
+
register: (id2) => {
|
|
63
|
+
presenceChildren.set(id2, false);
|
|
64
|
+
return () => presenceChildren.delete(id2);
|
|
54
65
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return () => presenceChildren.delete(childId);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}, presenceAffectsLayout ? void 0 : [isEntering, onExitComplete, exitVariant, enterVariant]);
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
presenceAffectsLayout ? void 0 : [isPresent, exitVariant, enterVariant]
|
|
69
|
+
);
|
|
63
70
|
React.useMemo(() => {
|
|
64
71
|
presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
|
|
65
|
-
}, [
|
|
72
|
+
}, [isPresent]);
|
|
66
73
|
React.useEffect(() => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}, "PresenceChild");
|
|
74
|
+
!isPresent && !presenceChildren.size && (onExitComplete == null ? void 0 : onExitComplete());
|
|
75
|
+
}, [isPresent]);
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_use_presence.PresenceContext.Provider, {
|
|
77
|
+
value: context,
|
|
78
|
+
children
|
|
79
|
+
});
|
|
80
|
+
};
|
|
75
81
|
function newChildrenMap() {
|
|
76
82
|
return /* @__PURE__ */ new Map();
|
|
77
83
|
}
|
|
78
|
-
__name(newChildrenMap, "newChildrenMap");
|
|
79
84
|
// Annotate the CommonJS export names for ESM import in node:
|
|
80
85
|
0 && (module.exports = {
|
|
81
86
|
PresenceChild
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/PresenceChild.tsx"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { PresenceContext, PresenceContextProps } from '@tamagui/use-presence'\nimport * as React from 'react'\nimport { useId } from 'react'\n\nimport { VariantLabels } from './types'\n\ninterface PresenceChildProps {\n children: React.ReactElement<any>\n isPresent: boolean\n onExitComplete?: () => void\n initial?: false | VariantLabels\n custom?: any\n presenceAffectsLayout: boolean\n exitVariant?: string | null\n enterVariant?: string | null\n}\n\nexport const PresenceChild = ({\n children,\n initial,\n isPresent,\n onExitComplete,\n exitVariant,\n enterVariant,\n presenceAffectsLayout,\n}: PresenceChildProps) => {\n const presenceChildren = React.useMemo(newChildrenMap, [])\n const id = useId() || ''\n\n const context = React.useMemo(\n (): PresenceContextProps => {\n return {\n id,\n initial,\n isPresent,\n exitVariant,\n enterVariant,\n onExitComplete: (id: string) => {\n presenceChildren.set(id, true)\n for (const isComplete of presenceChildren.values()) {\n if (!isComplete) {\n return // can stop searching when any is incomplete\n }\n }\n onExitComplete?.()\n },\n register: (id: string) => {\n presenceChildren.set(id, false)\n return () => presenceChildren.delete(id)\n },\n }\n },\n /**\n * If the presence of a child affects the layout of the components around it,\n * we want to make a new context value to ensure they get re-rendered\n * so they can detect that layout change.\n */\n // eslint-disable-next-line react-hooks/exhaustive-deps\n presenceAffectsLayout ? undefined : [isPresent, exitVariant, enterVariant]\n )\n\n React.useMemo(() => {\n presenceChildren.forEach((_, key) => presenceChildren.set(key, false))\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isPresent])\n\n /**\n * If there's no animated components to fire exit animations, we want to remove this\n * component immediately.\n */\n React.useEffect(() => {\n !isPresent && !presenceChildren.size && onExitComplete?.()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isPresent])\n\n return <PresenceContext.Provider value={context}>{children}</PresenceContext.Provider>\n}\n\nfunction newChildrenMap(): Map<string, boolean> {\n return new Map()\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2ES;AA3ET,0BAAsD;AACtD,YAAuB;AACvB,mBAAsB;AAef,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA0B;AACxB,QAAM,mBAAmB,MAAM,QAAQ,gBAAgB,CAAC,CAAC;AACzD,QAAM,SAAK,oBAAM,KAAK;AAEtB,QAAM,UAAU,MAAM;AAAA,IACpB,MAA4B;AAC1B,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,gBAAgB,CAACA,QAAe;AAC9B,2BAAiB,IAAIA,KAAI,IAAI;AAC7B,qBAAW,cAAc,iBAAiB,OAAO,GAAG;AAClD,gBAAI,CAAC,YAAY;AACf;AAAA,YACF;AAAA,UACF;AACA;AAAA,QACF;AAAA,QACA,UAAU,CAACA,QAAe;AACxB,2BAAiB,IAAIA,KAAI,KAAK;AAC9B,iBAAO,MAAM,iBAAiB,OAAOA,GAAE;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAAA,IAOA,wBAAwB,SAAY,CAAC,WAAW,aAAa,YAAY;AAAA,EAC3E;AAEA,QAAM,QAAQ,MAAM;AAClB,qBAAiB,QAAQ,CAAC,GAAG,QAAQ,iBAAiB,IAAI,KAAK,KAAK,CAAC;AAAA,EAEvE,GAAG,CAAC,SAAS,CAAC;AAMd,QAAM,UAAU,MAAM;AACpB,KAAC,aAAa,CAAC,iBAAiB,SAAQ;AAAA,EAE1C,GAAG,CAAC,SAAS,CAAC;AAEd,SAAO,4CAAC,oCAAgB,UAAhB;AAAA,IAAyB,OAAO;AAAA,IAAU;AAAA,GAAS;AAC7D;AAEA,SAAS,iBAAuC;AAC9C,SAAO,oBAAI,IAAI;AACjB;",
|
|
6
|
+
"names": ["id"]
|
|
7
7
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -15,15 +16,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
16
|
return to;
|
|
16
17
|
};
|
|
17
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
20
|
-
|
|
19
|
+
var PresenceContext_exports = {};
|
|
20
|
+
__export(PresenceContext_exports, {
|
|
21
|
+
PresenceContext: () => PresenceContext
|
|
21
22
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(PresenceContext_exports);
|
|
23
24
|
var import_react = require("react");
|
|
24
|
-
const
|
|
25
|
+
const PresenceContext = (0, import_react.createContext)(null);
|
|
25
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
27
|
0 && (module.exports = {
|
|
27
|
-
|
|
28
|
+
PresenceContext
|
|
28
29
|
});
|
|
29
|
-
//# sourceMappingURL=
|
|
30
|
+
//# sourceMappingURL=PresenceContext.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/PresenceContext.tsx"],
|
|
4
|
+
"sourcesContent": ["import { createContext } from 'react'\n\nimport { VariantLabels } from './types'\n\nexport interface PresenceContextProps {\n id: string\n isPresent: boolean\n register: (id: string) => () => void\n onExitComplete?: (id: string) => void\n initial?: false | VariantLabels\n custom?: any\n exitVariant?: string | null\n enterVariant?: string | null\n}\n\nexport const PresenceContext = createContext<PresenceContextProps | null>(null)\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8B;AAevB,MAAM,sBAAkB,4BAA2C,IAAI;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
6
|
var __copyProps = (to, from, except, desc) => {
|
|
10
7
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
8
|
for (let key of __getOwnPropNames(from))
|
|
@@ -17,15 +14,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
14
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
16
|
var src_exports = {};
|
|
20
|
-
__export(src_exports, {
|
|
21
|
-
AnimatePresenceContext: () => import_AnimatePresenceContext.AnimatePresenceContext
|
|
22
|
-
});
|
|
23
17
|
module.exports = __toCommonJS(src_exports);
|
|
24
18
|
__reExport(src_exports, require("./AnimatePresence"), module.exports);
|
|
25
|
-
__reExport(src_exports, require("
|
|
26
|
-
var import_AnimatePresenceContext = require("./AnimatePresenceContext");
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
AnimatePresenceContext
|
|
30
|
-
});
|
|
19
|
+
__reExport(src_exports, require("@tamagui/use-presence"), module.exports);
|
|
31
20
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './AnimatePresence'\nexport * from '
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["export * from './AnimatePresence'\nexport * from '@tamagui/use-presence'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,8BAAd;AACA,wBAAc,kCADd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/types.js
CHANGED
package/dist/cjs/types.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["export interface Axis {\n min: number\n max: number\n}\n\nexport interface Box {\n x: Axis\n y: Axis\n}\n\nexport type VariantLabels = string | string[]\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["export interface Axis {\n min: number\n max: number\n}\n\nexport interface Box {\n x: Axis\n y: Axis\n}\n\nexport type VariantLabels = string | string[]\n\n/**\n * @public\n */\nexport interface AnimatePresenceProps {\n /**\n * By passing `initial={false}`, `AnimatePresence` will disable any initial animations on children\n * that are present when the component is first rendered.\n *\n * ```jsx\n * <AnimatePresence initial={false}>\n * {isVisible && (\n * <motion.div\n * key=\"modal\"\n * initial={{ opacity: 0 }}\n * animate={{ opacity: 1 }}\n * exit={{ opacity: 0 }}\n * />\n * )}\n * </AnimatePresence>\n * ```\n *\n * @public\n */\n initial?: boolean\n\n /**\n * When a component is removed, there's no longer a chance to update its props. So if a component's `exit`\n * prop is defined as a dynamic variant and you want to pass a new `custom` prop, you can do so via `AnimatePresence`.\n * This will ensure all leaving components animate using the latest data.\n *\n * @public\n */\n custom?: any\n\n /**\n * Fires when all exiting nodes have completed animating out.\n *\n * @public\n */\n onExitComplete?: () => void\n\n /**\n * If set to `true`, `AnimatePresence` will only render one component at a time. The exiting component\n * will finish its exit animation before the entering component is rendered.\n *\n * ```jsx\n * const MyComponent = ({ currentItem }) => (\n * <AnimatePresence exitBeforeEnter>\n * <motion.div key={currentItem} exit={{ opacity: 0 }} />\n * </AnimatePresence>\n * )\n * ```\n *\n * @beta\n */\n exitBeforeEnter?: boolean\n\n /**\n * Used in Framer to flag that sibling children *shouldn't* re-render as a result of a\n * child being removed.\n *\n * @internal\n */\n presenceAffectsLayout?: boolean\n\n exitVariant?: string | null\n\n enterVariant?: string | null\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var usePresence_exports = {};
|
|
20
|
+
__export(usePresence_exports, {
|
|
21
|
+
isPresent: () => isPresent,
|
|
22
|
+
useIsPresent: () => useIsPresent,
|
|
23
|
+
usePresence: () => usePresence
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(usePresence_exports);
|
|
26
|
+
var import_core = require("@tamagui/core");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_PresenceContext = require("./PresenceContext");
|
|
29
|
+
function usePresence() {
|
|
30
|
+
const context = (0, import_react.useContext)(import_PresenceContext.PresenceContext);
|
|
31
|
+
if (context === null) {
|
|
32
|
+
return [true, null];
|
|
33
|
+
}
|
|
34
|
+
const { isPresent: isPresent2, onExitComplete, register } = context;
|
|
35
|
+
const id = (0, import_core.useId)() || "";
|
|
36
|
+
(0, import_react.useEffect)(() => register(id), [id, register]);
|
|
37
|
+
const safeToRemove = () => onExitComplete == null ? void 0 : onExitComplete(id);
|
|
38
|
+
return !isPresent2 && onExitComplete ? [false, safeToRemove] : [true];
|
|
39
|
+
}
|
|
40
|
+
function useIsPresent() {
|
|
41
|
+
return isPresent((0, import_react.useContext)(import_PresenceContext.PresenceContext));
|
|
42
|
+
}
|
|
43
|
+
function isPresent(context) {
|
|
44
|
+
return context === null ? true : context.isPresent;
|
|
45
|
+
}
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
isPresent,
|
|
49
|
+
useIsPresent,
|
|
50
|
+
usePresence
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=usePresence.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/usePresence.ts"],
|
|
4
|
+
"sourcesContent": ["import { useId } from '@tamagui/core'\nimport { useContext, useEffect } from 'react'\n\nimport { PresenceContext, PresenceContextProps } from './PresenceContext'\n\nexport type SafeToRemove = () => void\ntype AlwaysPresent = [true, null]\ntype Present = [true]\ntype NotPresent = [false, SafeToRemove]\n\nexport function usePresence(): AlwaysPresent | Present | NotPresent {\n const context = useContext(PresenceContext)\n\n if (context === null) {\n return [true, null]\n }\n\n const { isPresent, onExitComplete, register } = context\n const id = useId() || ''\n useEffect(() => register(id), [id, register])\n\n const safeToRemove = () => onExitComplete?.(id)\n\n return !isPresent && onExitComplete ? [false, safeToRemove] : [true]\n}\n\n/**\n * Similar to `usePresence`, except `useIsPresent` simply returns whether or not the component is present.\n * There is no `safeToRemove` function. ```\n */\nexport function useIsPresent() {\n return isPresent(useContext(PresenceContext))\n}\n\nexport function isPresent(context: PresenceContextProps | null) {\n return context === null ? true : context.isPresent\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAsB;AACtB,mBAAsC;AAEtC,6BAAsD;AAO/C,SAAS,cAAoD;AAClE,QAAM,cAAU,yBAAW,sCAAe;AAE1C,MAAI,YAAY,MAAM;AACpB,WAAO,CAAC,MAAM,IAAI;AAAA,EACpB;AAEA,QAAM,EAAE,WAAAA,YAAW,gBAAgB,SAAS,IAAI;AAChD,QAAM,SAAK,mBAAM,KAAK;AACtB,8BAAU,MAAM,SAAS,EAAE,GAAG,CAAC,IAAI,QAAQ,CAAC;AAE5C,QAAM,eAAe,MAAM,iDAAiB;AAE5C,SAAO,CAACA,cAAa,iBAAiB,CAAC,OAAO,YAAY,IAAI,CAAC,IAAI;AACrE;AAMO,SAAS,eAAe;AAC7B,SAAO,cAAU,yBAAW,sCAAe,CAAC;AAC9C;AAEO,SAAS,UAAU,SAAsC;AAC9D,SAAO,YAAY,OAAO,OAAO,QAAQ;AAC3C;",
|
|
6
|
+
"names": ["isPresent"]
|
|
7
|
+
}
|