perspective-layered-ui 1.0.9 → 1.0.10
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/LayeredScene.d.ts +3 -3
- package/dist/LayeredScene.d.ts.map +1 -1
- package/dist/index.es.js +96 -97
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/LayeredScene.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './LayeredScene.css';
|
|
2
|
-
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import { type CSSProperties, type HTMLAttributes, type ReactNode } from 'react';
|
|
3
3
|
export type LayeredSceneProps = {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
className?: string;
|
|
@@ -22,8 +22,8 @@ export type LayeredSceneRef = {
|
|
|
22
22
|
goToFirst: () => void;
|
|
23
23
|
};
|
|
24
24
|
export declare const LayeredScene: import("react").ForwardRefExoticComponent<LayeredSceneProps & import("react").RefAttributes<LayeredSceneRef>>;
|
|
25
|
-
export interface LayerProps {
|
|
25
|
+
export interface LayerProps extends HTMLAttributes<HTMLDivElement> {
|
|
26
26
|
children: ReactNode;
|
|
27
27
|
}
|
|
28
|
-
export declare
|
|
28
|
+
export declare const Layer: import("react").ForwardRefExoticComponent<LayerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
29
29
|
//# sourceMappingURL=LayeredScene.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayeredScene.d.ts","sourceRoot":"","sources":["../src/LayeredScene.tsx"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAE3B,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,SAAS,EAQf,MAAM,OAAO,CAAA;AAEd,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wBAAwB,CAAC,EAAE,OAAO,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,YAAY,+GAgPvB,CAAA;AAEF,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"LayeredScene.d.ts","sourceRoot":"","sources":["../src/LayeredScene.tsx"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAE3B,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,cAAc,EACnB,KAAK,SAAS,EAQf,MAAM,OAAO,CAAA;AAEd,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wBAAwB,CAAC,EAAE,OAAO,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,YAAY,+GAgPvB,CAAA;AAEF,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,cAAc,CAAC;IAChE,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,KAAK,uGAMhB,CAAA"}
|
package/dist/index.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
var Z = { exports: {} },
|
|
1
|
+
import me, { forwardRef as oe, useMemo as de, Children as ge, useState as P, useRef as Q, useCallback as Ee, useEffect as H, useImperativeHandle as pe, isValidElement as ee } from "react";
|
|
2
|
+
var Z = { exports: {} }, D = {};
|
|
3
3
|
var re;
|
|
4
4
|
function ve() {
|
|
5
|
-
if (re) return
|
|
5
|
+
if (re) return D;
|
|
6
6
|
re = 1;
|
|
7
|
-
var
|
|
8
|
-
function
|
|
7
|
+
var f = /* @__PURE__ */ Symbol.for("react.transitional.element"), g = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
|
+
function E(m, l, s) {
|
|
9
9
|
var k = null;
|
|
10
10
|
if (s !== void 0 && (k = "" + s), l.key !== void 0 && (k = "" + l.key), "key" in l) {
|
|
11
11
|
s = {};
|
|
@@ -13,20 +13,20 @@ function ve() {
|
|
|
13
13
|
w !== "key" && (s[w] = l[w]);
|
|
14
14
|
} else s = l;
|
|
15
15
|
return l = s.ref, {
|
|
16
|
-
$$typeof:
|
|
17
|
-
type:
|
|
16
|
+
$$typeof: f,
|
|
17
|
+
type: m,
|
|
18
18
|
key: k,
|
|
19
19
|
ref: l !== void 0 ? l : null,
|
|
20
20
|
props: s
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return D.Fragment = g, D.jsx = E, D.jsxs = E, D;
|
|
24
24
|
}
|
|
25
|
-
var
|
|
25
|
+
var F = {};
|
|
26
26
|
var te;
|
|
27
27
|
function _e() {
|
|
28
28
|
return te || (te = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
29
|
-
function
|
|
29
|
+
function f(e) {
|
|
30
30
|
if (e == null) return null;
|
|
31
31
|
if (typeof e == "function")
|
|
32
32
|
return e.$$typeof === V ? null : e.displayName || e.name || null;
|
|
@@ -49,7 +49,7 @@ function _e() {
|
|
|
49
49
|
switch (typeof e.tag == "number" && console.error(
|
|
50
50
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
51
51
|
), e.$$typeof) {
|
|
52
|
-
case
|
|
52
|
+
case v:
|
|
53
53
|
return "Portal";
|
|
54
54
|
case I:
|
|
55
55
|
return e.displayName || "Context";
|
|
@@ -59,22 +59,22 @@ function _e() {
|
|
|
59
59
|
var r = e.render;
|
|
60
60
|
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
61
61
|
case S:
|
|
62
|
-
return r = e.displayName || null, r !== null ? r :
|
|
62
|
+
return r = e.displayName || null, r !== null ? r : f(e.type) || "Memo";
|
|
63
63
|
case O:
|
|
64
64
|
r = e._payload, e = e._init;
|
|
65
65
|
try {
|
|
66
|
-
return
|
|
66
|
+
return f(e(r));
|
|
67
67
|
} catch {
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function g(e) {
|
|
73
73
|
return "" + e;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function E(e) {
|
|
76
76
|
try {
|
|
77
|
-
|
|
77
|
+
g(e);
|
|
78
78
|
var r = !1;
|
|
79
79
|
} catch {
|
|
80
80
|
r = !0;
|
|
@@ -86,29 +86,29 @@ function _e() {
|
|
|
86
86
|
r,
|
|
87
87
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
88
88
|
n
|
|
89
|
-
),
|
|
89
|
+
), g(e);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function m(e) {
|
|
93
93
|
if (e === x) return "<>";
|
|
94
94
|
if (typeof e == "object" && e !== null && e.$$typeof === O)
|
|
95
95
|
return "<...>";
|
|
96
96
|
try {
|
|
97
|
-
var r =
|
|
97
|
+
var r = f(e);
|
|
98
98
|
return r ? "<" + r + ">" : "<...>";
|
|
99
99
|
} catch {
|
|
100
100
|
return "<...>";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
function l() {
|
|
104
|
-
var e =
|
|
104
|
+
var e = T.A;
|
|
105
105
|
return e === null ? null : e.getOwner();
|
|
106
106
|
}
|
|
107
107
|
function s() {
|
|
108
108
|
return Error("react-stack-top-frame");
|
|
109
109
|
}
|
|
110
110
|
function k(e) {
|
|
111
|
-
if (
|
|
111
|
+
if (i.call(e, "key")) {
|
|
112
112
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
113
113
|
if (r && r.isReactWarning) return !1;
|
|
114
114
|
}
|
|
@@ -127,12 +127,12 @@ function _e() {
|
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
function L() {
|
|
130
|
-
var e =
|
|
131
|
-
return
|
|
130
|
+
var e = f(this.type);
|
|
131
|
+
return _[e] || (_[e] = !0, console.error(
|
|
132
132
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
133
133
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
134
134
|
}
|
|
135
|
-
function X(e, r, t, n, c,
|
|
135
|
+
function X(e, r, t, n, c, h) {
|
|
136
136
|
var o = t.ref;
|
|
137
137
|
return e = {
|
|
138
138
|
$$typeof: U,
|
|
@@ -162,14 +162,14 @@ function _e() {
|
|
|
162
162
|
configurable: !1,
|
|
163
163
|
enumerable: !1,
|
|
164
164
|
writable: !0,
|
|
165
|
-
value:
|
|
165
|
+
value: h
|
|
166
166
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
167
167
|
}
|
|
168
|
-
function W(e, r, t, n, c,
|
|
168
|
+
function W(e, r, t, n, c, h) {
|
|
169
169
|
var o = r.children;
|
|
170
170
|
if (o !== void 0)
|
|
171
171
|
if (n)
|
|
172
|
-
if (
|
|
172
|
+
if (Y(o)) {
|
|
173
173
|
for (n = 0; n < o.length; n++)
|
|
174
174
|
j(o[n]);
|
|
175
175
|
Object.freeze && Object.freeze(o);
|
|
@@ -178,8 +178,8 @@ function _e() {
|
|
|
178
178
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
179
179
|
);
|
|
180
180
|
else j(o);
|
|
181
|
-
if (
|
|
182
|
-
o =
|
|
181
|
+
if (i.call(r, "key")) {
|
|
182
|
+
o = f(e);
|
|
183
183
|
var b = Object.keys(r).filter(function(K) {
|
|
184
184
|
return K !== "key";
|
|
185
185
|
});
|
|
@@ -196,7 +196,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
196
196
|
o
|
|
197
197
|
), G[o + n] = !0);
|
|
198
198
|
}
|
|
199
|
-
if (o = null, t !== void 0 && (
|
|
199
|
+
if (o = null, t !== void 0 && (E(t), o = "" + t), k(r) && (E(r.key), o = "" + r.key), "key" in r) {
|
|
200
200
|
t = {};
|
|
201
201
|
for (var C in r)
|
|
202
202
|
C !== "key" && (t[C] = r[C]);
|
|
@@ -210,7 +210,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
210
210
|
t,
|
|
211
211
|
l(),
|
|
212
212
|
c,
|
|
213
|
-
|
|
213
|
+
h
|
|
214
214
|
);
|
|
215
215
|
}
|
|
216
216
|
function j(e) {
|
|
@@ -219,51 +219,51 @@ React keys must be passed directly to JSX without using spread:
|
|
|
219
219
|
function $(e) {
|
|
220
220
|
return typeof e == "object" && e !== null && e.$$typeof === U;
|
|
221
221
|
}
|
|
222
|
-
var
|
|
222
|
+
var p = me, U = /* @__PURE__ */ Symbol.for("react.transitional.element"), v = /* @__PURE__ */ Symbol.for("react.portal"), x = /* @__PURE__ */ Symbol.for("react.fragment"), q = /* @__PURE__ */ Symbol.for("react.strict_mode"), z = /* @__PURE__ */ Symbol.for("react.profiler"), a = /* @__PURE__ */ Symbol.for("react.consumer"), I = /* @__PURE__ */ Symbol.for("react.context"), B = /* @__PURE__ */ Symbol.for("react.forward_ref"), M = /* @__PURE__ */ Symbol.for("react.suspense"), J = /* @__PURE__ */ Symbol.for("react.suspense_list"), S = /* @__PURE__ */ Symbol.for("react.memo"), O = /* @__PURE__ */ Symbol.for("react.lazy"), A = /* @__PURE__ */ Symbol.for("react.activity"), V = /* @__PURE__ */ Symbol.for("react.client.reference"), T = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, i = Object.prototype.hasOwnProperty, Y = Array.isArray, d = console.createTask ? console.createTask : function() {
|
|
223
223
|
return null;
|
|
224
224
|
};
|
|
225
|
-
|
|
225
|
+
p = {
|
|
226
226
|
react_stack_bottom_frame: function(e) {
|
|
227
227
|
return e();
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
|
-
var N,
|
|
231
|
-
|
|
230
|
+
var N, _ = {}, y = p.react_stack_bottom_frame.bind(
|
|
231
|
+
p,
|
|
232
232
|
s
|
|
233
|
-
)(),
|
|
234
|
-
|
|
235
|
-
var n = 1e4 >
|
|
233
|
+
)(), u = d(m(s)), G = {};
|
|
234
|
+
F.Fragment = x, F.jsx = function(e, r, t) {
|
|
235
|
+
var n = 1e4 > T.recentlyCreatedOwnerStacks++;
|
|
236
236
|
return W(
|
|
237
237
|
e,
|
|
238
238
|
r,
|
|
239
239
|
t,
|
|
240
240
|
!1,
|
|
241
|
-
n ? Error("react-stack-top-frame") :
|
|
242
|
-
n ? m(
|
|
241
|
+
n ? Error("react-stack-top-frame") : y,
|
|
242
|
+
n ? d(m(e)) : u
|
|
243
243
|
);
|
|
244
|
-
},
|
|
245
|
-
var n = 1e4 >
|
|
244
|
+
}, F.jsxs = function(e, r, t) {
|
|
245
|
+
var n = 1e4 > T.recentlyCreatedOwnerStacks++;
|
|
246
246
|
return W(
|
|
247
247
|
e,
|
|
248
248
|
r,
|
|
249
249
|
t,
|
|
250
250
|
!0,
|
|
251
|
-
n ? Error("react-stack-top-frame") :
|
|
252
|
-
n ? m(
|
|
251
|
+
n ? Error("react-stack-top-frame") : y,
|
|
252
|
+
n ? d(m(e)) : u
|
|
253
253
|
);
|
|
254
254
|
};
|
|
255
|
-
})()),
|
|
255
|
+
})()), F;
|
|
256
256
|
}
|
|
257
257
|
var ne;
|
|
258
|
-
function
|
|
258
|
+
function ye() {
|
|
259
259
|
return ne || (ne = 1, process.env.NODE_ENV === "production" ? Z.exports = ve() : Z.exports = _e()), Z.exports;
|
|
260
260
|
}
|
|
261
|
-
var
|
|
262
|
-
const Pe =
|
|
263
|
-
children:
|
|
264
|
-
className:
|
|
265
|
-
style:
|
|
266
|
-
transitionMs:
|
|
261
|
+
var R = ye();
|
|
262
|
+
const Pe = oe(({
|
|
263
|
+
children: f,
|
|
264
|
+
className: g,
|
|
265
|
+
style: E,
|
|
266
|
+
transitionMs: m = 250,
|
|
267
267
|
easing: l = "linear",
|
|
268
268
|
depthSpacingPx: s = 200,
|
|
269
269
|
perspectivePx: k = 3e3,
|
|
@@ -273,53 +273,53 @@ const Pe = me(({
|
|
|
273
273
|
opacityAt2: W = 0.45,
|
|
274
274
|
minVisibleOpacity: j = 0.2,
|
|
275
275
|
initialIndex: $ = 0,
|
|
276
|
-
disableNavigationButtons:
|
|
276
|
+
disableNavigationButtons: p = !1
|
|
277
277
|
}, U) => {
|
|
278
|
-
const
|
|
279
|
-
if (
|
|
278
|
+
const v = de(() => ge.toArray(f), [f]), x = (r) => Math.max(0, Math.min(1, r)), q = (r, t, n) => r + (t - r) * n, z = (r, t, n, c) => r <= 0 ? t : r >= 2 ? c : r <= 1 ? q(t, n, x(r)) : q(n, c, x(r - 1)), [a, I] = P(() => Number.isNaN($) ? 0 : Math.max(0, Math.min(v.length - 1, $))), [B, M] = P(null), [J, S] = P(null), [O, A] = P(1), [V, T] = P(1), [i, Y] = P(!1), [d, N] = P(1), _ = Q(null), y = Q(null), u = Ee((r) => {
|
|
279
|
+
if (i || r < 0 || r >= v.length || r === a) return;
|
|
280
280
|
const t = r > a ? 1 : -1;
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}),
|
|
284
|
-
|
|
285
|
-
},
|
|
286
|
-
}, [
|
|
281
|
+
Y(!0), M(a), T(0), N(t), t === -1 ? (S(r), A(0)) : (S(null), A(1)), I(r), y.current !== null && window.cancelAnimationFrame(y.current), y.current = window.requestAnimationFrame(() => {
|
|
282
|
+
T(1), t === -1 && A(1), y.current = null;
|
|
283
|
+
}), _.current !== null && window.clearTimeout(_.current), _.current = window.setTimeout(() => {
|
|
284
|
+
Y(!1), M(null), S(null), A(1), T(1), N(1), _.current = null;
|
|
285
|
+
}, m + 60);
|
|
286
|
+
}, [i, a, v.length, m, Y, M, T, N, S, A, I]);
|
|
287
287
|
H(() => () => {
|
|
288
|
-
|
|
288
|
+
_.current !== null && window.clearTimeout(_.current), y.current !== null && window.cancelAnimationFrame(y.current);
|
|
289
289
|
}, []), H(() => {
|
|
290
|
-
I((r) => Math.max(0, Math.min(
|
|
291
|
-
}, [
|
|
292
|
-
if (
|
|
290
|
+
I((r) => Math.max(0, Math.min(v.length - 1, r)));
|
|
291
|
+
}, [v.length]), H(() => {
|
|
292
|
+
if (p) return;
|
|
293
293
|
const r = (t) => {
|
|
294
|
-
t.key === "PageUp" ?
|
|
294
|
+
t.key === "PageUp" ? u(a - 1) : t.key === "PageDown" && u(a + 1);
|
|
295
295
|
};
|
|
296
296
|
return window.addEventListener("keydown", r), () => {
|
|
297
297
|
window.removeEventListener("keydown", r);
|
|
298
298
|
};
|
|
299
|
-
}, [
|
|
300
|
-
goToPrev: () =>
|
|
301
|
-
goToNext: () =>
|
|
302
|
-
goToFirst: () =>
|
|
303
|
-
}), [a,
|
|
304
|
-
const G =
|
|
305
|
-
return /* @__PURE__ */
|
|
299
|
+
}, [p, a, u]), pe(U, () => ({
|
|
300
|
+
goToPrev: () => u(a - 1),
|
|
301
|
+
goToNext: () => u(a + 1),
|
|
302
|
+
goToFirst: () => u(0)
|
|
303
|
+
}), [a, u]);
|
|
304
|
+
const G = i, e = s * a;
|
|
305
|
+
return /* @__PURE__ */ R.jsx(
|
|
306
306
|
"div",
|
|
307
307
|
{
|
|
308
|
-
className: `layeredScene ${G ? "is-transitioning" : ""}${
|
|
308
|
+
className: `layeredScene ${G ? "is-transitioning" : ""}${g ? ` ${g}` : ""}`,
|
|
309
309
|
"aria-label": "3D layered scene",
|
|
310
310
|
style: {
|
|
311
311
|
"--camera-z": `${e}px`,
|
|
312
|
-
"--transition-ms": `${
|
|
312
|
+
"--transition-ms": `${m}ms`,
|
|
313
313
|
"--transition-easing": l,
|
|
314
314
|
"--perspective": `${k}px`,
|
|
315
|
-
...
|
|
315
|
+
...E
|
|
316
316
|
},
|
|
317
|
-
children:
|
|
318
|
-
const n = Math.abs(t - a), c = B !== null && t === B,
|
|
319
|
-
if (o + b + e + C > 0 && !c && !(
|
|
317
|
+
children: v.map((r, t) => {
|
|
318
|
+
const n = Math.abs(t - a), c = B !== null && t === B, h = J !== null && t === J, o = -s * t, b = c && d === 1 ? s * 2 : 0, C = h && d === -1 && O === 0 ? s * 2 : 0;
|
|
319
|
+
if (o + b + e + C > 0 && !c && !(h && i && d === -1))
|
|
320
320
|
return null;
|
|
321
|
-
const
|
|
322
|
-
return /* @__PURE__ */
|
|
321
|
+
const ae = z(n, 1, X, W), se = c && i ? d === -1 ? V === 0 ? 1 : j : V === 0 ? 1 : j : h && i && d === -1 ? O === 0 ? 0 : 1 : t === a ? 1 : ae, le = z(n, 0, w, L), ce = h && i && d === -1 ? O === 0 ? L : 0 : le, ie = 1e4 - Math.round(n * 10) + (c ? 1e3 : 0), ue = ee(r) ? r : /* @__PURE__ */ R.jsx(R.Fragment, { children: r }), fe = (ee(r) ? r.key : null) ?? t;
|
|
322
|
+
return /* @__PURE__ */ R.jsx(
|
|
323
323
|
"div",
|
|
324
324
|
{
|
|
325
325
|
className: `layeredLayer ${n === 0 ? "is-focused" : ""} ${t === a ? "is-active" : ""} ${c ? "is-outgoing" : ""}`,
|
|
@@ -327,45 +327,44 @@ const Pe = me(({
|
|
|
327
327
|
"--z": `${o}px`,
|
|
328
328
|
"--outgoing-offset": `${b}px`,
|
|
329
329
|
"--incoming-offset": `${C}px`,
|
|
330
|
-
"--stack":
|
|
331
|
-
"--layer-blur": `${
|
|
332
|
-
opacity: Math.max(j,
|
|
330
|
+
"--stack": ie,
|
|
331
|
+
"--layer-blur": `${ce}px`,
|
|
332
|
+
opacity: Math.max(j, se)
|
|
333
333
|
},
|
|
334
|
-
children: /* @__PURE__ */
|
|
335
|
-
|
|
336
|
-
/* @__PURE__ */
|
|
337
|
-
!
|
|
334
|
+
children: /* @__PURE__ */ R.jsxs("div", { className: "layeredLayerInner", children: [
|
|
335
|
+
ue,
|
|
336
|
+
/* @__PURE__ */ R.jsxs("div", { className: "layeredControls", children: [
|
|
337
|
+
!p && t !== 0 ? /* @__PURE__ */ R.jsx(
|
|
338
338
|
"button",
|
|
339
339
|
{
|
|
340
340
|
type: "button",
|
|
341
341
|
className: "layeredBtn",
|
|
342
|
-
onClick: () =>
|
|
343
|
-
disabled:
|
|
342
|
+
onClick: () => u(a - 1),
|
|
343
|
+
disabled: i || t !== a,
|
|
344
344
|
children: "Previous"
|
|
345
345
|
}
|
|
346
346
|
) : null,
|
|
347
|
-
!
|
|
347
|
+
!p && t !== v.length - 1 ? /* @__PURE__ */ R.jsx(
|
|
348
348
|
"button",
|
|
349
349
|
{
|
|
350
350
|
type: "button",
|
|
351
351
|
className: "layeredBtn",
|
|
352
|
-
onClick: () =>
|
|
353
|
-
disabled:
|
|
352
|
+
onClick: () => u(a + 1),
|
|
353
|
+
disabled: i || t !== a,
|
|
354
354
|
children: "Next"
|
|
355
355
|
}
|
|
356
356
|
) : null
|
|
357
357
|
] })
|
|
358
358
|
] })
|
|
359
359
|
},
|
|
360
|
-
|
|
360
|
+
fe
|
|
361
361
|
);
|
|
362
362
|
})
|
|
363
363
|
}
|
|
364
364
|
);
|
|
365
|
+
}), je = oe(function({ children: g, ...E }, m) {
|
|
366
|
+
return /* @__PURE__ */ R.jsx("div", { ref: m, ...E, children: g });
|
|
365
367
|
});
|
|
366
|
-
function je({ children: i }) {
|
|
367
|
-
return /* @__PURE__ */ d.jsx(d.Fragment, { children: i });
|
|
368
|
-
}
|
|
369
368
|
export {
|
|
370
369
|
je as Layer,
|
|
371
370
|
Pe as LayeredScene
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react");var Z={exports:{}},Y={};var K;function le(){if(K)return Y;K=1;var m=Symbol.for("react.transitional.element"),E=Symbol.for("react.fragment");function v(d,l,c){var k=null;if(c!==void 0&&(k=""+c),l.key!==void 0&&(k=""+l.key),"key"in l){c={};for(var O in l)O!=="key"&&(c[O]=l[O])}else c=l;return l=c.ref,{$$typeof:m,type:d,key:k,ref:l!==void 0?l:null,props:c}}return Y.Fragment=E,Y.jsx=v,Y.jsxs=v,Y}var D={};var Q;function ue(){return Q||(Q=1,process.env.NODE_ENV!=="production"&&(function(){function m(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===V?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case j:return"Fragment";case z:return"Profiler";case q:return"StrictMode";case M:return"Suspense";case J:return"SuspenseList";case P:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case y:return"Portal";case I:return e.displayName||"Context";case s:return(e._context.displayName||"Context")+".Consumer";case B:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case x:return r=e.displayName||null,r!==null?r:m(e.type)||"Memo";case S:r=e._payload,e=e._init;try{return m(e(r))}catch{}}return null}function E(e){return""+e}function v(e){try{E(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),E(e)}}function d(e){if(e===j)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===S)return"<...>";try{var r=m(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function l(){var e=h.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function k(e){if(i.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function O(e,r){function t(){N||(N=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function F(){var e=m(this.type);return _[e]||(_[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function X(e,r,t,n,u,w){var o=t.ref;return e={$$typeof:U,type:e,key:r,props:t,_owner:n},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:F}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:u}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:w}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function W(e,r,t,n,u,w){var o=r.children;if(o!==void 0)if(n)if(L(o)){for(n=0;n<o.length;n++)A(o[n]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else A(o);if(i.call(r,"key")){o=m(e);var R=Object.keys(r).filter(function(H){return H!=="key"});n=0<R.length?"{key: someKey, "+R.join(": ..., ")+": ...}":"{key: someKey}",G[o+n]||(R=0<R.length?"{"+R.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,n,o,
|
|
6
|
+
<%s key={someKey} {...props} />`,n,o,R,o),G[o+n]=!0)}if(o=null,t!==void 0&&(v(t),o=""+t),k(r)&&(v(r.key),o=""+r.key),"key"in r){t={};for(var C in r)C!=="key"&&(t[C]=r[C])}else t=r;return o&&O(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),X(e,o,t,l(),u,w)}function A(e){$(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===S&&(e._payload.status==="fulfilled"?$(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function $(e){return typeof e=="object"&&e!==null&&e.$$typeof===U}var p=a,U=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),I=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),J=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),V=Symbol.for("react.client.reference"),h=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,i=Object.prototype.hasOwnProperty,L=Array.isArray,g=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(e){return e()}};var N,_={},b=p.react_stack_bottom_frame.bind(p,c)(),f=g(d(c)),G={};D.Fragment=j,D.jsx=function(e,r,t){var n=1e4>h.recentlyCreatedOwnerStacks++;return W(e,r,t,!1,n?Error("react-stack-top-frame"):b,n?g(d(e)):f)},D.jsxs=function(e,r,t){var n=1e4>h.recentlyCreatedOwnerStacks++;return W(e,r,t,!0,n?Error("react-stack-top-frame"):b,n?g(d(e)):f)}})()),D}var ee;function ie(){return ee||(ee=1,process.env.NODE_ENV==="production"?Z.exports=le():Z.exports=ue()),Z.exports}var T=ie();const fe=a.forwardRef(({children:m,className:E,style:v,transitionMs:d=250,easing:l="linear",depthSpacingPx:c=200,perspectivePx:k=3e3,blurAt1Px:O=6,blurAt2Px:F=10,opacityAt1:X=.7,opacityAt2:W=.45,minVisibleOpacity:A=.2,initialIndex:$=0,disableNavigationButtons:p=!1},U)=>{const y=a.useMemo(()=>a.Children.toArray(m),[m]),j=r=>Math.max(0,Math.min(1,r)),q=(r,t,n)=>r+(t-r)*n,z=(r,t,n,u)=>r<=0?t:r>=2?u:r<=1?q(t,n,j(r)):q(n,u,j(r-1)),[s,I]=a.useState(()=>Number.isNaN($)?0:Math.max(0,Math.min(y.length-1,$))),[B,M]=a.useState(null),[J,x]=a.useState(null),[S,P]=a.useState(1),[V,h]=a.useState(1),[i,L]=a.useState(!1),[g,N]=a.useState(1),_=a.useRef(null),b=a.useRef(null),f=a.useCallback(r=>{if(i||r<0||r>=y.length||r===s)return;const t=r>s?1:-1;L(!0),M(s),h(0),N(t),t===-1?(x(r),P(0)):(x(null),P(1)),I(r),b.current!==null&&window.cancelAnimationFrame(b.current),b.current=window.requestAnimationFrame(()=>{h(1),t===-1&&P(1),b.current=null}),_.current!==null&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>{L(!1),M(null),x(null),P(1),h(1),N(1),_.current=null},d+60)},[i,s,y.length,d,L,M,h,N,x,P,I]);a.useEffect(()=>()=>{_.current!==null&&window.clearTimeout(_.current),b.current!==null&&window.cancelAnimationFrame(b.current)},[]),a.useEffect(()=>{I(r=>Math.max(0,Math.min(y.length-1,r)))},[y.length]),a.useEffect(()=>{if(p)return;const r=t=>{t.key==="PageUp"?f(s-1):t.key==="PageDown"&&f(s+1)};return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[p,s,f]),a.useImperativeHandle(U,()=>({goToPrev:()=>f(s-1),goToNext:()=>f(s+1),goToFirst:()=>f(0)}),[s,f]);const G=i,e=c*s;return T.jsx("div",{className:`layeredScene ${G?"is-transitioning":""}${E?` ${E}`:""}`,"aria-label":"3D layered scene",style:{"--camera-z":`${e}px`,"--transition-ms":`${d}ms`,"--transition-easing":l,"--perspective":`${k}px`,...v},children:y.map((r,t)=>{const n=Math.abs(t-s),u=B!==null&&t===B,w=J!==null&&t===J,o=-c*t,R=u&&g===1?c*2:0,C=w&&g===-1&&S===0?c*2:0;if(o+R+e+C>0&&!u&&!(w&&i&&g===-1))return null;const re=z(n,1,X,W),te=u&&i?g===-1?V===0?1:A:V===0?1:A:w&&i&&g===-1?S===0?0:1:t===s?1:re,ne=z(n,0,O,F),oe=w&&i&&g===-1?S===0?F:0:ne,ae=1e4-Math.round(n*10)+(u?1e3:0),se=a.isValidElement(r)?r:T.jsx(T.Fragment,{children:r}),ce=(a.isValidElement(r)?r.key:null)??t;return T.jsx("div",{className:`layeredLayer ${n===0?"is-focused":""} ${t===s?"is-active":""} ${u?"is-outgoing":""}`,style:{"--z":`${o}px`,"--outgoing-offset":`${R}px`,"--incoming-offset":`${C}px`,"--stack":ae,"--layer-blur":`${oe}px`,opacity:Math.max(A,te)},children:T.jsxs("div",{className:"layeredLayerInner",children:[se,T.jsxs("div",{className:"layeredControls",children:[!p&&t!==0?T.jsx("button",{type:"button",className:"layeredBtn",onClick:()=>f(s-1),disabled:i||t!==s,children:"Previous"}):null,!p&&t!==y.length-1?T.jsx("button",{type:"button",className:"layeredBtn",onClick:()=>f(s+1),disabled:i||t!==s,children:"Next"}):null]})]})},ce)})})}),me=a.forwardRef(function({children:E,...v},d){return T.jsx("div",{ref:d,...v,children:E})});exports.Layer=me;exports.LayeredScene=fe;
|