@cgi-learning-hub/ui
Version:
@cgi-learning-hub/ui is an open-source React component library that implements UI for HUB's features
198 lines (197 loc) • 5.36 kB
JavaScript
import * as f from "react";
import { P as n } from "./index-B9vkf41S.js";
import { u as V } from "./useTheme-0AkY41zn.js";
import { jsx as W } from "react/jsx-runtime";
import { T as k, g as v, r as B } from "./utils-B_pVp6UZ.js";
import { u as J } from "./useTimeout-CrCYVizI.js";
import { u as M } from "./useForkRef-u29GSuCu.js";
import { g as Q, e as U } from "./elementAcceptingRef-CZLfau9O.js";
function h(m) {
return `scale(${m}, ${m ** 2})`;
}
const X = {
entering: {
opacity: 1,
transform: h(1)
},
entered: {
opacity: 1,
transform: "none"
}
}, E = typeof navigator < "u" && /^((?!chrome|android).)*(safari|mobile)/i.test(navigator.userAgent) && /(os |version\/)15(.|_)4/i.test(navigator.userAgent), y = /* @__PURE__ */ f.forwardRef(function(w, D) {
const {
addEndListener: x,
appear: L = !0,
children: l,
easing: T,
in: R,
onEnter: b,
onEntered: j,
onEntering: H,
onExit: A,
onExited: O,
onExiting: P,
style: p,
timeout: o = "auto",
// eslint-disable-next-line react/prop-types
TransitionComponent: F = k,
...G
} = w, S = J(), g = f.useRef(), s = V(), c = f.useRef(null), C = M(c, Q(l), D), a = (t) => (r) => {
if (t) {
const e = c.current;
r === void 0 ? t(e) : t(e, r);
}
}, N = a(H), _ = a((t, r) => {
B(t);
const {
duration: e,
delay: d,
easing: i
} = v({
style: p,
timeout: o,
easing: T
}, {
mode: "enter"
});
let u;
o === "auto" ? (u = s.transitions.getAutoHeightDuration(t.clientHeight), g.current = u) : u = e, t.style.transition = [s.transitions.create("opacity", {
duration: u,
delay: d
}), s.transitions.create("transform", {
duration: E ? u : u * 0.666,
delay: d,
easing: i
})].join(","), b && b(t, r);
}), $ = a(j), q = a(P), z = a((t) => {
const {
duration: r,
delay: e,
easing: d
} = v({
style: p,
timeout: o,
easing: T
}, {
mode: "exit"
});
let i;
o === "auto" ? (i = s.transitions.getAutoHeightDuration(t.clientHeight), g.current = i) : i = r, t.style.transition = [s.transitions.create("opacity", {
duration: i,
delay: e
}), s.transitions.create("transform", {
duration: E ? i : i * 0.666,
delay: E ? e : e || i * 0.333,
easing: d
})].join(","), t.style.opacity = 0, t.style.transform = h(0.75), A && A(t);
}), K = a(O);
return /* @__PURE__ */ W(F, {
appear: L,
in: R,
nodeRef: c,
onEnter: _,
onEntered: $,
onEntering: N,
onExit: z,
onExited: K,
onExiting: q,
addEndListener: (t) => {
o === "auto" && S.start(g.current || 0, t), x && x(c.current, t);
},
timeout: o === "auto" ? null : o,
...G,
children: (t, {
ownerState: r,
...e
}) => /* @__PURE__ */ f.cloneElement(l, {
style: {
opacity: 0,
transform: h(0.75),
visibility: t === "exited" && !R ? "hidden" : void 0,
...X[t],
...p,
...l.props.style
},
ref: C,
...e
})
});
});
process.env.NODE_ENV !== "production" && (y.propTypes = {
// ┌────────────────────────────── Warning ──────────────────────────────┐
// │ These PropTypes are generated from the TypeScript type definitions. │
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* Add a custom transition end trigger. Called with the transitioning DOM
* node and a done callback. Allows for more fine grained transition end
* logic. Note: Timeouts are still used as a fallback if provided.
*/
addEndListener: n.func,
/**
* Perform the enter transition when it first mounts if `in` is also `true`.
* Set this to `false` to disable this behavior.
* @default true
*/
appear: n.bool,
/**
* A single child content element.
*/
children: U.isRequired,
/**
* The transition timing function.
* You may specify a single easing or a object containing enter and exit values.
*/
easing: n.oneOfType([n.shape({
enter: n.string,
exit: n.string
}), n.string]),
/**
* If `true`, the component will transition in.
*/
in: n.bool,
/**
* @ignore
*/
onEnter: n.func,
/**
* @ignore
*/
onEntered: n.func,
/**
* @ignore
*/
onEntering: n.func,
/**
* @ignore
*/
onExit: n.func,
/**
* @ignore
*/
onExited: n.func,
/**
* @ignore
*/
onExiting: n.func,
/**
* @ignore
*/
style: n.object,
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
*
* Set to 'auto' to automatically calculate transition time based on height.
* @default 'auto'
*/
timeout: n.oneOfType([n.oneOf(["auto"]), n.number, n.shape({
appear: n.number,
enter: n.number,
exit: n.number
})])
});
y && (y.muiSupportAuto = !0);
export {
y as G
};