@onesy/ui-react
Version:
UI for React
240 lines • 7.04 kB
JavaScript
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
const _excluded = ["ref", "in", "prefix", "run", "append", "add", "enter", "exit", "enterOnAdd", "exitOnAdd", "noAbruption", "removeOnExited", "delay", "duration", "timing_function", "addTransition", "onTransition", "onAppended", "onAdd", "onAdding", "onAdded", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "onRemoved", "className", "style", "children"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import { c as _c } from "react/compiler-runtime";
import React from 'react';
import { is } from '@onesy/utils';
import { classNames, useOnesyTheme } from '@onesy/style-react';
import { Transition } from '..';
import { jsx as _jsx } from "react/jsx-runtime";
const Fade = props_ => {
const $ = _c(33);
const theme = useOnesyTheme();
const t0 = theme?.ui?.elements?.all?.props?.default;
const t1 = theme?.ui?.elements?.onesyFade?.props?.default;
let t2;
if ($[0] !== props_ || $[1] !== t0 || $[2] !== t1) {
t2 = _objectSpread(_objectSpread(_objectSpread({}, t0), t1), props_);
$[0] = props_;
$[1] = t0;
$[2] = t1;
$[3] = t2;
} else {
t2 = $[3];
}
const props = t2;
let addTransition;
let children;
let className;
let inProp;
let other;
let ref;
let style;
let timing_function;
if ($[4] !== props) {
const {
ref: t3,
in: t4,
prefix,
run,
append,
add,
enter,
exit,
enterOnAdd,
exitOnAdd,
noAbruption,
removeOnExited,
delay,
duration: duration_,
timing_function: t5,
addTransition: t6,
onTransition,
onAppended,
onAdd,
onAdding,
onAdded,
onEnter,
onEntering,
onEntered,
onExit,
onExiting,
onExited,
onRemoved,
className: t7,
style: t8,
children: t9
} = props,
t10 = _objectWithoutProperties(props, _excluded);
ref = t3;
inProp = t4;
timing_function = t5;
addTransition = t6;
className = t7;
style = t8;
children = t9;
other = t10;
$[4] = props;
$[5] = addTransition;
$[6] = children;
$[7] = className;
$[8] = inProp;
$[9] = other;
$[10] = ref;
$[11] = style;
$[12] = timing_function;
} else {
addTransition = $[5];
children = $[6];
className = $[7];
inProp = $[8];
other = $[9];
ref = $[10];
style = $[11];
timing_function = $[12];
}
const t3 = React.useRef(undefined);
let t4;
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
t4 = {
root: t3
};
$[13] = t4;
} else {
t4 = $[13];
}
const refs = t4;
let t5;
if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
t5 = status => {
const {
opacity: t6
} = refs.root.current && window.getComputedStyle(refs.root?.current) || {};
const opacity = t6 === undefined ? 1 : t6;
const allStyles = {
appended: {
visibility: "hidden"
},
add: {
transition: "none",
opacity: 0
},
adding: {
opacity: 1
},
added: {
opacity: 1
},
enter: {
transition: "none",
opacity: 0
},
entering: {
opacity: 1
},
entered: {},
exit: {
opacity
},
exiting: {
opacity: 0
},
exited: {
opacity: 0
}
};
return allStyles[status];
};
$[14] = t5;
} else {
t5 = $[14];
}
const styles = t5;
let duration;
if ($[15] !== theme) {
duration = (status_0, t6) => {
const property = t6 === undefined ? "opacity" : t6;
const properties = {
opacity: theme.transitions.duration.sm
};
return `${(is("simple", duration) ? duration : duration[status_0]) || properties[property]}ms`;
};
$[15] = theme;
$[16] = duration;
} else {
duration = $[16];
}
let t6;
if ($[17] !== theme || $[18] !== timing_function) {
t6 = status_1 => (is("simple", timing_function) ? timing_function : timing_function[status_1]) || theme.transitions.timing_function.standard;
$[17] = theme;
$[18] = timing_function;
$[19] = t6;
} else {
t6 = $[19];
}
const timingFunction = t6;
let t7;
if ($[20] !== addTransition || $[21] !== children || $[22] !== className || $[23] !== duration || $[24] !== inProp || $[25] !== other || $[26] !== ref || $[27] !== style || $[28] !== timingFunction) {
t7 = (status_2, ref_) => /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, other), {}, {
ref: item => {
refs.root.current = item;
if (ref) {
if (is("function", ref)) {
ref(item);
} else {
ref.current = item;
}
}
if (ref_) {
if (is("function", ref_)) {
ref_(item);
} else {
ref_.current = item;
}
}
if (children.ref) {
if (is("function", children.ref)) {
children.ref(item);
} else {
children.ref.current = item;
}
}
},
className: classNames([className, children?.props?.className]),
style: _objectSpread(_objectSpread(_objectSpread({
visibility: status_2 === "exited" && !inProp ? "hidden" : undefined,
transition: `opacity ${duration(status_2)} ${timingFunction(status_2)} ${addTransition ? `, ${addTransition}` : ""}`
}, styles(status_2)), children?.props?.style), style)
}));
$[20] = addTransition;
$[21] = children;
$[22] = className;
$[23] = duration;
$[24] = inProp;
$[25] = other;
$[26] = ref;
$[27] = style;
$[28] = timingFunction;
$[29] = t7;
} else {
t7 = $[29];
}
let t8;
if ($[30] !== props || $[31] !== t7) {
t8 = /*#__PURE__*/_jsx(Transition, _objectSpread(_objectSpread({}, props), {}, {
name: "fade",
children: t7
}));
$[30] = props;
$[31] = t7;
$[32] = t8;
} else {
t8 = $[32];
}
return t8;
};
Fade.displayName = 'onesy-Fade';
export default Fade;