@elliemae/ds-hidden 3.0.0-alpha.0 → 3.0.0-alpha.1
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/useHiddenTransition.js +47 -19
- package/dist/cjs/useHiddenTransition.js.map +1 -1
- package/dist/esm/useHiddenTransition.js +49 -19
- package/dist/esm/useHiddenTransition.js.map +1 -1
- package/package.json +2 -1
- package/dist/types/index.d.ts +0 -19
- package/dist/types/useHiddenController.d.ts +0 -7
- package/dist/types/useHiddenProps.d.ts +0 -7
- package/dist/types/useHiddenTransition.d.ts +0 -13
- package/dist/types/useHiddenTrigger.d.ts +0 -8
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
7
24
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
8
37
|
var __export = (target, all) => {
|
|
9
38
|
for (var name in all)
|
|
10
39
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -37,17 +66,20 @@ const growTo = (from, to) => [
|
|
|
37
66
|
{ opacity: 1, transform: `scale(${to})` },
|
|
38
67
|
{ opacity: 0, transform: `scale(${from})` }
|
|
39
68
|
];
|
|
40
|
-
function useHiddenTransition({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
69
|
+
function useHiddenTransition(_a) {
|
|
70
|
+
var _b = _a, {
|
|
71
|
+
animationState = growTo(0, 1),
|
|
72
|
+
visible = false,
|
|
73
|
+
duration = 150
|
|
74
|
+
} = _b, otherProps = __objRest(_b, [
|
|
75
|
+
"animationState",
|
|
76
|
+
"visible",
|
|
77
|
+
"duration"
|
|
78
|
+
]);
|
|
79
|
+
const _a2 = (0, import_useHiddenProps.default)({ visible }), { hidden } = _a2, hiddenProps = __objRest(_a2, ["hidden"]);
|
|
47
80
|
const [resting, setResting] = (0, import_react.useState)(false);
|
|
48
81
|
const [destroyed, setDestroyed] = (0, import_react.useState)(true);
|
|
49
|
-
const [animationStyles, set] = (0, import_web.useSpring)(() => ({
|
|
50
|
-
...animationState[0],
|
|
82
|
+
const [animationStyles, set] = (0, import_web.useSpring)(() => __spreadProps(__spreadValues({}, animationState[0]), {
|
|
51
83
|
config: { duration },
|
|
52
84
|
onStart: () => {
|
|
53
85
|
setResting(false);
|
|
@@ -57,22 +89,18 @@ function useHiddenTransition({
|
|
|
57
89
|
onRest: () => setResting(true)
|
|
58
90
|
}));
|
|
59
91
|
(0, import_react.useEffect)(() => {
|
|
60
|
-
set(visible ? {
|
|
92
|
+
set(visible ? __spreadProps(__spreadValues({}, animationState[0]), { immediate: false }) : __spreadValues({}, animationState[1]));
|
|
61
93
|
}, [visible]);
|
|
62
94
|
(0, import_react.useEffect)(() => {
|
|
63
95
|
if (!visible && resting)
|
|
64
96
|
setDestroyed(true);
|
|
65
97
|
}, [resting]);
|
|
66
|
-
return {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
...otherProps.style,
|
|
71
|
-
pointerEvents: !visible && "none",
|
|
72
|
-
...animationStyles
|
|
73
|
-
},
|
|
98
|
+
return __spreadProps(__spreadValues(__spreadValues({}, otherProps), hiddenProps), {
|
|
99
|
+
style: __spreadValues(__spreadProps(__spreadValues({}, otherProps.style), {
|
|
100
|
+
pointerEvents: !visible && "none"
|
|
101
|
+
}), animationStyles),
|
|
74
102
|
destroyed: destroyed || void 0
|
|
75
|
-
};
|
|
103
|
+
});
|
|
76
104
|
}
|
|
77
105
|
module.exports = __toCommonJS(useHiddenTransition_exports);
|
|
78
106
|
//# sourceMappingURL=useHiddenTransition.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useHiddenTransition.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import { useState, useEffect } from 'react';\nimport { useSpring } from 'react-spring/web';\nimport useHiddenProps from './useHiddenProps';\n\nconst growTo = (from, to) => [\n { opacity: 1, transform: `scale(${to})` },\n { opacity: 0, transform: `scale(${from})` },\n];\n\nexport default function useHiddenTransition({\n animationState = growTo(0, 1),\n visible = false,\n duration = 150,\n ...otherProps\n}) {\n const { hidden, ...hiddenProps } = useHiddenProps({ visible });\n const [resting, setResting] = useState(false);\n const [destroyed, setDestroyed] = useState(true);\n const [animationStyles, set] = useSpring(() => ({\n ...animationState[0],\n config: { duration },\n onStart: () => {\n setResting(false);\n setDestroyed(false);\n },\n immediate: !visible,\n onRest: () => setResting(true),\n }));\n\n useEffect(() => {\n set(\n visible\n ? { ...animationState[0], immediate: false }\n : { ...animationState[1] },\n );\n }, [visible]);\n\n useEffect(() => {\n if (!visible && resting) setDestroyed(true);\n }, [resting]);\n\n // element props\n return {\n ...otherProps,\n ...hiddenProps,\n style: {\n ...otherProps.style,\n pointerEvents: !visible && 'none',\n ...animationStyles,\n },\n destroyed: destroyed || undefined,\n };\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAoC;AACpC,iBAA0B;AAC1B,4BAA2B;AAE3B,MAAM,SAAS,CAAC,MAAM,OAAO;AAAA,EAC3B,EAAE,SAAS,GAAG,WAAW,SAAS;AAAA,EAClC,EAAE,SAAS,GAAG,WAAW,SAAS;AAAA;AAGrB,6BAA6B,IAKzC;AALyC,eAC1C;AAAA,qBAAiB,OAAO,GAAG;AAAA,IAC3B,UAAU;AAAA,IACV,WAAW;AAAA,MAH+B,IAIvC,uBAJuC,IAIvC;AAAA,IAHH;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAmC,yCAAe,EAAE,YAA5C,aAA2B,KAAhB,wBAAgB,KAAhB,CAAX;AACR,QAAM,CAAC,SAAS,cAAc,2BAAS;AACvC,QAAM,CAAC,WAAW,gBAAgB,2BAAS;AAC3C,QAAM,CAAC,iBAAiB,OAAO,0BAAU,MAAO,iCAC3C,eAAe,KAD4B;AAAA,IAE9C,QAAQ,EAAE;AAAA,IACV,SAAS,MAAM;AACb,iBAAW;AACX,mBAAa;AAAA;AAAA,IAEf,WAAW,CAAC;AAAA,IACZ,QAAQ,MAAM,WAAW;AAAA;AAG3B,8BAAU,MAAM;AACd,QACE,UACI,iCAAK,eAAe,KAApB,EAAwB,WAAW,WACnC,mBAAK,eAAe;AAAA,KAEzB,CAAC;AAEJ,8BAAU,MAAM;AACd,QAAI,CAAC,WAAW;AAAS,mBAAa;AAAA,KACrC,CAAC;AAGJ,SAAO,gDACF,aACA,cAFE;AAAA,IAGL,OAAO,gDACF,WAAW,QADT;AAAA,MAEL,eAAe,CAAC,WAAW;AAAA,QACxB;AAAA,IAEL,WAAW,aAAa;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
1
32
|
import * as React from "react";
|
|
2
33
|
import { useState, useEffect } from "react";
|
|
3
34
|
import { useSpring } from "react-spring/web";
|
|
@@ -6,17 +37,20 @@ const growTo = (from, to) => [
|
|
|
6
37
|
{ opacity: 1, transform: `scale(${to})` },
|
|
7
38
|
{ opacity: 0, transform: `scale(${from})` }
|
|
8
39
|
];
|
|
9
|
-
function useHiddenTransition({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
40
|
+
function useHiddenTransition(_a) {
|
|
41
|
+
var _b = _a, {
|
|
42
|
+
animationState = growTo(0, 1),
|
|
43
|
+
visible = false,
|
|
44
|
+
duration = 150
|
|
45
|
+
} = _b, otherProps = __objRest(_b, [
|
|
46
|
+
"animationState",
|
|
47
|
+
"visible",
|
|
48
|
+
"duration"
|
|
49
|
+
]);
|
|
50
|
+
const _a2 = useHiddenProps({ visible }), { hidden } = _a2, hiddenProps = __objRest(_a2, ["hidden"]);
|
|
16
51
|
const [resting, setResting] = useState(false);
|
|
17
52
|
const [destroyed, setDestroyed] = useState(true);
|
|
18
|
-
const [animationStyles, set] = useSpring(() => ({
|
|
19
|
-
...animationState[0],
|
|
53
|
+
const [animationStyles, set] = useSpring(() => __spreadProps(__spreadValues({}, animationState[0]), {
|
|
20
54
|
config: { duration },
|
|
21
55
|
onStart: () => {
|
|
22
56
|
setResting(false);
|
|
@@ -26,22 +60,18 @@ function useHiddenTransition({
|
|
|
26
60
|
onRest: () => setResting(true)
|
|
27
61
|
}));
|
|
28
62
|
useEffect(() => {
|
|
29
|
-
set(visible ? {
|
|
63
|
+
set(visible ? __spreadProps(__spreadValues({}, animationState[0]), { immediate: false }) : __spreadValues({}, animationState[1]));
|
|
30
64
|
}, [visible]);
|
|
31
65
|
useEffect(() => {
|
|
32
66
|
if (!visible && resting)
|
|
33
67
|
setDestroyed(true);
|
|
34
68
|
}, [resting]);
|
|
35
|
-
return {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
...otherProps.style,
|
|
40
|
-
pointerEvents: !visible && "none",
|
|
41
|
-
...animationStyles
|
|
42
|
-
},
|
|
69
|
+
return __spreadProps(__spreadValues(__spreadValues({}, otherProps), hiddenProps), {
|
|
70
|
+
style: __spreadValues(__spreadProps(__spreadValues({}, otherProps.style), {
|
|
71
|
+
pointerEvents: !visible && "none"
|
|
72
|
+
}), animationStyles),
|
|
43
73
|
destroyed: destroyed || void 0
|
|
44
|
-
};
|
|
74
|
+
});
|
|
45
75
|
}
|
|
46
76
|
export {
|
|
47
77
|
useHiddenTransition as default
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/useHiddenTransition.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useState, useEffect } from 'react';\nimport { useSpring } from 'react-spring/web';\nimport useHiddenProps from './useHiddenProps';\n\nconst growTo = (from, to) => [\n { opacity: 1, transform: `scale(${to})` },\n { opacity: 0, transform: `scale(${from})` },\n];\n\nexport default function useHiddenTransition({\n animationState = growTo(0, 1),\n visible = false,\n duration = 150,\n ...otherProps\n}) {\n const { hidden, ...hiddenProps } = useHiddenProps({ visible });\n const [resting, setResting] = useState(false);\n const [destroyed, setDestroyed] = useState(true);\n const [animationStyles, set] = useSpring(() => ({\n ...animationState[0],\n config: { duration },\n onStart: () => {\n setResting(false);\n setDestroyed(false);\n },\n immediate: !visible,\n onRest: () => setResting(true),\n }));\n\n useEffect(() => {\n set(\n visible\n ? { ...animationState[0], immediate: false }\n : { ...animationState[1] },\n );\n }, [visible]);\n\n useEffect(() => {\n if (!visible && resting) setDestroyed(true);\n }, [resting]);\n\n // element props\n return {\n ...otherProps,\n ...hiddenProps,\n style: {\n ...otherProps.style,\n pointerEvents: !visible && 'none',\n ...animationStyles,\n },\n destroyed: destroyed || undefined,\n };\n}\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AAEA,MAAM,SAAS,CAAC,MAAM,OAAO;AAAA,EAC3B,EAAE,SAAS,GAAG,WAAW,SAAS;AAAA,EAClC,EAAE,SAAS,GAAG,WAAW,SAAS;AAAA;AAGrB,6BAA6B;AAAA,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;AAEA,MAAM,SAAS,CAAC,MAAM,OAAO;AAAA,EAC3B,EAAE,SAAS,GAAG,WAAW,SAAS;AAAA,EAClC,EAAE,SAAS,GAAG,WAAW,SAAS;AAAA;AAGrB,6BAA6B,IAKzC;AALyC,eAC1C;AAAA,qBAAiB,OAAO,GAAG;AAAA,IAC3B,UAAU;AAAA,IACV,WAAW;AAAA,MAH+B,IAIvC,uBAJuC,IAIvC;AAAA,IAHH;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAmC,qBAAe,EAAE,YAA5C,aAA2B,KAAhB,wBAAgB,KAAhB,CAAX;AACR,QAAM,CAAC,SAAS,cAAc,SAAS;AACvC,QAAM,CAAC,WAAW,gBAAgB,SAAS;AAC3C,QAAM,CAAC,iBAAiB,OAAO,UAAU,MAAO,iCAC3C,eAAe,KAD4B;AAAA,IAE9C,QAAQ,EAAE;AAAA,IACV,SAAS,MAAM;AACb,iBAAW;AACX,mBAAa;AAAA;AAAA,IAEf,WAAW,CAAC;AAAA,IACZ,QAAQ,MAAM,WAAW;AAAA;AAG3B,YAAU,MAAM;AACd,QACE,UACI,iCAAK,eAAe,KAApB,EAAwB,WAAW,WACnC,mBAAK,eAAe;AAAA,KAEzB,CAAC;AAEJ,YAAU,MAAM;AACd,QAAI,CAAC,WAAW;AAAS,mBAAa;AAAA,KACrC,CAAC;AAGJ,SAAO,gDACF,aACA,cAFE;AAAA,IAGL,OAAO,gDACF,WAAW,QADT;AAAA,MAEL,eAAe,CAAC,WAAW;AAAA,QACxB;AAAA,IAEL,WAAW,aAAa;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-hidden",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Hidden",
|
|
6
6
|
"files": [
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
|
|
65
65
|
"test": "node ../../scripts/testing/test.mjs",
|
|
66
66
|
"lint": "node ../../scripts/lint.mjs",
|
|
67
|
+
"dts": "node ../../scripts/dts.mjs",
|
|
67
68
|
"build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
|
|
68
69
|
}
|
|
69
70
|
}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import useHiddenProps from './useHiddenProps';
|
|
2
|
-
import useHiddenTransition from './useHiddenTransition';
|
|
3
|
-
import useHiddenTrigger from './useHiddenTrigger';
|
|
4
|
-
export { default as useHiddenProps } from './useHiddenProps';
|
|
5
|
-
export { default as useHiddenController } from './useHiddenController';
|
|
6
|
-
export { default as useHiddenTransition } from './useHiddenTransition';
|
|
7
|
-
export { default as useHiddenTrigger } from './useHiddenTrigger';
|
|
8
|
-
declare const _default: {
|
|
9
|
-
useHiddenProps: typeof useHiddenProps;
|
|
10
|
-
useHiddenController: (initialState?: undefined) => {
|
|
11
|
-
onShow: () => void;
|
|
12
|
-
onHide: () => void;
|
|
13
|
-
onToggle: () => void;
|
|
14
|
-
visible: undefined;
|
|
15
|
-
};
|
|
16
|
-
useHiddenTransition: typeof useHiddenTransition;
|
|
17
|
-
useHiddenTrigger: typeof useHiddenTrigger;
|
|
18
|
-
};
|
|
19
|
-
export default _default;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export default function useHiddenTransition({ animationState, visible, duration, ...otherProps }: {
|
|
2
|
-
[x: string]: any;
|
|
3
|
-
animationState?: {
|
|
4
|
-
opacity: number;
|
|
5
|
-
transform: string;
|
|
6
|
-
}[] | undefined;
|
|
7
|
-
visible?: boolean | undefined;
|
|
8
|
-
duration?: number | undefined;
|
|
9
|
-
}): {
|
|
10
|
-
style: any;
|
|
11
|
-
destroyed: true | undefined;
|
|
12
|
-
'aria-hidden': boolean;
|
|
13
|
-
};
|