UNPKG

@onesy/ui-react

Version:
241 lines 7.16 kB
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 Zoom = props_ => { const $ = _c(33); const theme = useOnesyTheme(); const t0 = theme?.ui?.elements?.all?.props?.default; const t1 = theme?.ui?.elements?.onesyZoom?.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; const t3 = React.useRef(undefined); let t4; if ($[4] === Symbol.for("react.memo_cache_sentinel")) { t4 = { root: t3 }; $[4] = t4; } else { t4 = $[4]; } const refs = t4; let addTransition; let children; let className; let inProp; let other; let ref; let style; let timing_function; if ($[5] !== props) { const { ref: t5, in: t6, prefix, run, append, add, enter, exit, enterOnAdd, exitOnAdd, noAbruption, removeOnExited, delay, duration: duration_, timing_function: t7, addTransition: t8, onTransition, onAppended, onAdd, onAdding, onAdded, onEnter, onEntering, onEntered, onExit, onExiting, onExited, onRemoved, className: t9, style: t10, children: t11 } = props, t12 = _objectWithoutProperties(props, _excluded); ref = t5; inProp = t6; timing_function = t7; addTransition = t8; className = t9; style = t10; children = t11; other = t12; $[5] = props; $[6] = addTransition; $[7] = children; $[8] = className; $[9] = inProp; $[10] = other; $[11] = ref; $[12] = style; $[13] = timing_function; } else { addTransition = $[6]; children = $[7]; className = $[8]; inProp = $[9]; other = $[10]; ref = $[11]; style = $[12]; timing_function = $[13]; } let t5; if ($[14] === Symbol.for("react.memo_cache_sentinel")) { t5 = status => { const { transform: t6 } = refs.root.current && window.getComputedStyle(refs.root?.current) || {}; const transform = t6 === undefined ? "scale(1)" : t6; const allStyles = { appended: { visibility: "hidden" }, add: { transition: "none", transform: "scale(0)" }, adding: { transform: "scale(1)" }, added: { transform: "scale(1)" }, enter: { transition: "none", transform: "scale(0)" }, entering: { transform: "scale(1)" }, entered: { transform: "scale(1)" }, exit: { transform }, exiting: { transform: "scale(0.001)" }, exited: { transform: "scale(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 ? "transform" : t6; const properties = { transform: theme.transitions.duration.xs }; 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: `transform ${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), {}, { children: t7 })); $[30] = props; $[31] = t7; $[32] = t8; } else { t8 = $[32]; } return t8; }; Zoom.displayName = 'onesy-Zoom'; export default Zoom;