UNPKG

@onesy/ui-react

Version:
164 lines 5.21 kB
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; const _excluded = ["color", "version", "width", "height", "animation", "text", "Component", "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 { classNames, style as styleMethod, useOnesyTheme } from '@onesy/style-react'; import SurfaceElement from '../Surface'; import { staticClassName } from '../utils'; import { jsx as _jsx } from "react/jsx-runtime"; const useStyle = styleMethod(theme => ({ '@keyframes move': { '100%': { transform: 'translateX(100%)' } }, '@keyframes pulse': { '0%': { opacity: '1' }, '50%': { opacity: '0.4' }, '100%': { opacity: '1' } }, '@keyframes pulseDark': { '0%': { opacity: '1' }, '50%': { opacity: '0.7' }, '100%': { opacity: '1' } }, root: { position: 'relative', userSelect: 'none', overflow: 'hidden' }, wrapper: { opacity: theme.palette.light ? '0.07' : '0.14', background: 'currentColor', width: '100%', height: '100%' }, animation_wave: { '&::before': { content: "''", position: 'absolute', inset: '0', background: `linear-gradient(90deg, transparent, ${theme.methods.palette.color.colorToRgb(theme.palette.text.default.primary, 4)}, transparent)`, transform: 'translateX(-100%)', animation: '$move 2.4s infinite' } }, animation_pulse: { animation: `$pulse${theme.palette.light ? '' : 'Dark'} 2.4s 0.4s infinite` }, version_circle: { borderRadius: theme.methods.shape.radius.value(40, 'px') }, version_rounded: { borderRadius: theme.methods.shape.radius.value(1, 'px') }, version_rectangle: { borderRadius: '0px' }, text: { height: '1em' }, children: { visibility: 'hidden' } }), { name: 'onesy-Placeholder' }); const Placeholder = props_ => { const $ = _c(12); const theme = useOnesyTheme(); const props = _objectSpread(_objectSpread(_objectSpread({}, theme?.ui?.elements?.all?.props?.default), theme?.ui?.elements?.onesyPlaceholder?.props?.default), props_); const Surface = theme?.elements?.Surface || SurfaceElement; const { color: t0, version: t1, width, height, animation: t2, text, Component: t3, className, style, children } = props, other = _objectWithoutProperties(props, _excluded); const color = t0 === undefined ? "default" : t0; const version = t1 === undefined ? "rounded" : t1; const animation = t2 === undefined ? "pulse" : t2; const Component = t3 === undefined ? "div" : t3; const { classes } = useStyle(); const styles = { root: {} }; if (width !== undefined) { styles.root.width = width; } if (height !== undefined) { styles.root.height = height; } const t4 = classNames([staticClassName("Placeholder", theme) && ["onesy-Placeholder-root"], className, classes.root, classes[`version_${version}`], animation && animation && classes[`animation_${animation}`], text && classes.text]); let t5; if ($[0] !== classes.wrapper || $[1] !== theme) { t5 = classNames([staticClassName("Placeholder", theme) && ["onesy-Placeholder-wrapper"], classes.wrapper]); $[0] = classes.wrapper; $[1] = theme; $[2] = t5; } else { t5 = $[2]; } let t6; if ($[3] !== children || $[4] !== classes.children || $[5] !== theme) { t6 = children && /*#__PURE__*/_jsx("div", { className: classNames([staticClassName("Placeholder", theme) && ["onesy-Placeholder-children"], classes.children]), children: children }); $[3] = children; $[4] = classes.children; $[5] = theme; $[6] = t6; } else { t6 = $[6]; } let t7; if ($[7] !== Surface || $[8] !== color || $[9] !== t5 || $[10] !== t6) { t7 = /*#__PURE__*/_jsx(Surface, { version: "text", tonal: false, color: color, className: t5, children: t6 }); $[7] = Surface; $[8] = color; $[9] = t5; $[10] = t6; $[11] = t7; } else { t7 = $[11]; } return /*#__PURE__*/_jsx(Component, _objectSpread(_objectSpread({ className: t4, style: _objectSpread(_objectSpread({}, style), styles.root) }, other), {}, { children: t7 })); }; Placeholder.displayName = 'onesy-Placeholder'; export default Placeholder;