@hanzogui/animate-presence 7.0.0 → 7.3.0
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/LICENSE +40 -19
- package/dist/cjs/AnimatePresence.cjs +149 -0
- package/dist/cjs/AnimatePresence.native.js +166 -0
- package/dist/cjs/AnimatePresence.native.js.map +1 -0
- package/dist/cjs/LayoutGroupContext.cjs +40 -0
- package/dist/cjs/LayoutGroupContext.native.js +43 -0
- package/dist/cjs/LayoutGroupContext.native.js.map +1 -0
- package/dist/cjs/PresenceChild.cjs +101 -0
- package/dist/cjs/PresenceChild.native.js +128 -0
- package/dist/cjs/PresenceChild.native.js.map +1 -0
- package/dist/cjs/index.cjs +23 -0
- package/dist/cjs/index.native.js +26 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/types.cjs +18 -0
- package/dist/cjs/types.native.js +21 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/esm/AnimatePresence.mjs +124 -0
- package/dist/esm/AnimatePresence.mjs.map +1 -0
- package/dist/esm/AnimatePresence.native.js +138 -0
- package/dist/esm/AnimatePresence.native.js.map +1 -0
- package/dist/esm/LayoutGroupContext.mjs +4 -0
- package/dist/esm/LayoutGroupContext.mjs.map +1 -0
- package/dist/esm/LayoutGroupContext.native.js +4 -0
- package/dist/esm/LayoutGroupContext.native.js.map +1 -0
- package/dist/esm/PresenceChild.mjs +65 -0
- package/dist/esm/PresenceChild.mjs.map +1 -0
- package/dist/esm/PresenceChild.native.js +89 -0
- package/dist/esm/PresenceChild.native.js.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +5 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +5 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +2 -0
- package/dist/esm/types.native.js.map +1 -0
- package/package.json +16 -15
- package/src/AnimatePresence.tsx +1 -1
- package/types/AnimatePresence.d.ts.map +1 -0
- package/types/LayoutGroupContext.d.ts.map +1 -0
- package/types/PresenceChild.d.ts +1 -1
- package/types/PresenceChild.d.ts.map +1 -0
- package/types/index.d.ts.map +1 -0
- package/types/types.d.ts.map +1 -0
- package/LICENSE.md +0 -9
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useConstant } from "@hanzogui/use-constant";
|
|
3
|
+
import { PresenceContext } from "@hanzogui/use-presence";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { useId } from "react";
|
|
6
|
+
var PresenceChild = /* @__PURE__ */React.memo(function (param) {
|
|
7
|
+
var {
|
|
8
|
+
children,
|
|
9
|
+
initial,
|
|
10
|
+
isPresent,
|
|
11
|
+
onExitComplete,
|
|
12
|
+
exitVariant,
|
|
13
|
+
enterVariant,
|
|
14
|
+
enterExitVariant,
|
|
15
|
+
presenceAffectsLayout,
|
|
16
|
+
custom
|
|
17
|
+
} = param;
|
|
18
|
+
var presenceChildren = useConstant(newChildrenMap);
|
|
19
|
+
var id = useId() || "";
|
|
20
|
+
var context = React.useMemo(function () {
|
|
21
|
+
return {
|
|
22
|
+
id,
|
|
23
|
+
initial,
|
|
24
|
+
isPresent,
|
|
25
|
+
custom,
|
|
26
|
+
exitVariant,
|
|
27
|
+
enterVariant,
|
|
28
|
+
enterExitVariant,
|
|
29
|
+
onExitComplete: function () {
|
|
30
|
+
presenceChildren.set(id, true);
|
|
31
|
+
var _iteratorNormalCompletion = true,
|
|
32
|
+
_didIteratorError = false,
|
|
33
|
+
_iteratorError = void 0;
|
|
34
|
+
try {
|
|
35
|
+
for (var _iterator = presenceChildren.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
36
|
+
var isComplete = _step.value;
|
|
37
|
+
if (!isComplete) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} catch (err) {
|
|
42
|
+
_didIteratorError = true;
|
|
43
|
+
_iteratorError = err;
|
|
44
|
+
} finally {
|
|
45
|
+
try {
|
|
46
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
47
|
+
_iterator.return();
|
|
48
|
+
}
|
|
49
|
+
} finally {
|
|
50
|
+
if (_didIteratorError) {
|
|
51
|
+
throw _iteratorError;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
|
|
56
|
+
},
|
|
57
|
+
register: function () {
|
|
58
|
+
presenceChildren.set(id, false);
|
|
59
|
+
return function () {
|
|
60
|
+
return presenceChildren.delete(id);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* If the presence of a child affects the layout of the components around it,
|
|
67
|
+
* we want to make a new context value to ensure they get re-rendered
|
|
68
|
+
* so they can detect that layout change.
|
|
69
|
+
*/
|
|
70
|
+
// @ts-expect-error its ok
|
|
71
|
+
presenceAffectsLayout ? void 0 : [isPresent, exitVariant, enterVariant]);
|
|
72
|
+
React.useMemo(function () {
|
|
73
|
+
presenceChildren.forEach(function (_, key) {
|
|
74
|
+
return presenceChildren.set(key, false);
|
|
75
|
+
});
|
|
76
|
+
}, [isPresent]);
|
|
77
|
+
React.useEffect(function () {
|
|
78
|
+
!isPresent && !presenceChildren.size && (onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete());
|
|
79
|
+
}, [isPresent]);
|
|
80
|
+
return /* @__PURE__ */_jsx(PresenceContext.Provider, {
|
|
81
|
+
value: context,
|
|
82
|
+
children
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
function newChildrenMap() {
|
|
86
|
+
return /* @__PURE__ */new Map();
|
|
87
|
+
}
|
|
88
|
+
export { PresenceChild };
|
|
89
|
+
//# sourceMappingURL=PresenceChild.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","useConstant","PresenceContext","React","useId","PresenceChild","memo","param","children","initial","isPresent","onExitComplete","exitVariant","enterVariant","enterExitVariant","presenceAffectsLayout","custom","presenceChildren","newChildrenMap","id","context","useMemo","set","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","values","Symbol","iterator","_step","next","done","isComplete","value","err","return","register","delete"],"sources":["../../src/PresenceChild.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,GAAA,IAAAC,IAAA,QAAmB;AAC5B,SAASC,WAAA,gCAAuB;AAEhC,SAAAC,eAAuB;AACvB,YAASC,KAAA,MAAa;AA+EX,SAAAC,KAAA;AA9DJ,IAAAC,aAAM,kBAAsBF,KAAA,CAAAG,IAAA,WAAAC,KAAA;EACjC,IAAC;IAAAC,QAAA;IAAAC,OAAA;IAAAC,SAAA;IAAAC,cAAA;IAAAC,WAAA;IAAAC,YAAA;IAAAC,gBAAA;IAAAC,qBAAA;IAAAC;EAAA,IAAAT,KAAA;EAAA,IACCU,gBAAA,GAAAhB,WAAA,CAAAiB,cAAA;EAAA,IACAC,EAAA,GAAAf,KAAA;EAAA,IACAgB,OAAA,GAAAjB,KAAA,CAAAkB,OAAA,CACA;IACA;MACAF,EAAA;MACAV,OAAA;MACAC,SAAA;MACAM,MAAA;MACwBJ,WAAA;MACxBC,YAAM;MACNC,gBAAiB;MAEjBH,cAAgB,WAAAA,CAAA,EAAM;QACpBM,gBAA4B,CAAAK,GAAA,CAAAH,EAAA;QAC1B,IAAAI,yBAAO;UAAAC,iBAAA;UAAAC,cAAA;QACL;UACA,SAAAC,SAAA,GAAAT,gBAAA,CAAAU,MAAA,GAAAC,MAAA,CAAAC,QAAA,KAAAC,KAAA,IAAAP,yBAAA,IAAAO,KAAA,GAAAJ,SAAA,CAAAK,IAAA,IAAAC,IAAA,GAAAT,yBAAA;YACA,IAAAU,UAAA,GAAAH,KAAA,CAAAI,KAAA;YACA,KAAAD,UAAA;cACA;YACA;UACA;QACA,SAAAE,GAAA;UACEX,iBAAiB,OAAI;UACrBC,cAAW,GAAAU,GAAA;QACT,UAAK;UACH;YACF,KAAAZ,yBAAA,IAAAG,SAAA,CAAAU,MAAA;cACFV,SAAA,CAAAU,MAAA;YACA;UACF;YACA,IAAAZ,iBAAgB;cACd,MAAAC,cAAqB;YACrB;UACF;QACF;QACFd,cAAA,aAAAA,cAAA,uBAAAA,cAAA;MAAA;MAAA0B,QAAA,WAAAA,CAAA;QAAApB,gBAAA,CAAAK,GAAA,CAAAH,EAAA;QAAA;UAAA,OAAAF,gBAAA,CAAAqB,MAAA,CAAAnB,EAAA;QAAA;MAQA;IACF;EAEA;EACE;AAAqE;AAOvE;AACE;AAAyD;EAG3D;EACFJ,qBAAA,aACFL,SAAA,EAEAE,WAAS,EACPC,YAAO,C","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzogui/animate-presence",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "BSD-3-Clause",
|
|
6
6
|
"source": "src/index.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"src",
|
|
@@ -32,24 +32,25 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "
|
|
36
|
-
"watch": "
|
|
37
|
-
"clean": "
|
|
38
|
-
"clean:build": "
|
|
35
|
+
"build": "gui-build",
|
|
36
|
+
"watch": "gui-build --watch",
|
|
37
|
+
"clean": "gui-build clean",
|
|
38
|
+
"clean:build": "gui-build clean:build"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@hanzogui/constants": "
|
|
42
|
-
"@hanzogui/helpers": "
|
|
43
|
-
"@hanzogui/use-constant": "
|
|
44
|
-
"@hanzogui/use-force-update": "
|
|
45
|
-
"@hanzogui/use-presence": "
|
|
46
|
-
"@hanzogui/web": "
|
|
41
|
+
"@hanzogui/constants": "7.3.0",
|
|
42
|
+
"@hanzogui/helpers": "7.3.0",
|
|
43
|
+
"@hanzogui/use-constant": "7.3.0",
|
|
44
|
+
"@hanzogui/use-force-update": "7.3.0",
|
|
45
|
+
"@hanzogui/use-presence": "7.3.0",
|
|
46
|
+
"@hanzogui/web": "7.3.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@hanzogui/build": "
|
|
49
|
+
"@hanzogui/build": "7.3.0",
|
|
50
50
|
"react": ">=19"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": ">=19"
|
|
54
|
-
}
|
|
55
|
-
|
|
54
|
+
},
|
|
55
|
+
"author": "Hanzo AI <dev@hanzo.ai>"
|
|
56
|
+
}
|
package/src/AnimatePresence.tsx
CHANGED
|
@@ -13,7 +13,7 @@ const getChildKey = (child: ReactElement<any>): ComponentKey => {
|
|
|
13
13
|
return (
|
|
14
14
|
child.key ||
|
|
15
15
|
(() => {
|
|
16
|
-
// we can help a bit by falling back to
|
|
16
|
+
// we can help a bit by falling back to gui name or component name
|
|
17
17
|
const ct = child.type
|
|
18
18
|
const defaultName = ct['displayName'] || ct['name'] || ''
|
|
19
19
|
if (ct && typeof ct === 'object' && 'staticConfig' in ct) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimatePresence.d.ts","sourceRoot":"","sources":["../src/AnimatePresence.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAA2B,MAAM,OAAO,CAAA;AAI1F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AA6BnD,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAC7C,iBAAiB,CAAC,oBAAoB,CAAC,CAmLxC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LayoutGroupContext.d.ts","sourceRoot":"","sources":["../src/LayoutGroupContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,WAAW,uBAAuB;IACtC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,WAAW,CAAC,EAAE,YAAY,CAAA;CAC3B;AAED,eAAO,MAAM,kBAAkB,wCAAmD,CAAA"}
|
package/types/PresenceChild.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ interface PresenceChildProps {
|
|
|
11
11
|
enterVariant?: string | null;
|
|
12
12
|
enterExitVariant?: string | null;
|
|
13
13
|
}
|
|
14
|
-
export declare const PresenceChild: React.MemoExoticComponent<({ children, initial, isPresent, onExitComplete, exitVariant, enterVariant, enterExitVariant, presenceAffectsLayout, custom, }: PresenceChildProps) =>
|
|
14
|
+
export declare const PresenceChild: React.MemoExoticComponent<({ children, initial, isPresent, onExitComplete, exitVariant, enterVariant, enterExitVariant, presenceAffectsLayout, custom, }: PresenceChildProps) => React.JSX.Element>;
|
|
15
15
|
export {};
|
|
16
16
|
//# sourceMappingURL=PresenceChild.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresenceChild.d.ts","sourceRoot":"","sources":["../src/PresenceChild.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;IACjC,SAAS,EAAE,OAAO,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;IAC3B,OAAO,CAAC,EAAE,KAAK,GAAG,aAAa,CAAA;IAC/B,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC;AAGD,eAAO,MAAM,aAAa,4JAWrB,kBAAkB,uBAqDtB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,IAAI,CAAA;IACP,CAAC,EAAE,IAAI,CAAA;CACR;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;AAE7C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAEtB;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;IAE3B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAE/B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAE3B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAE5B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAEhC,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB"}
|
package/LICENSE.md
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Framer B.V.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|