@zohodesk/components
Version:
In this Package, we Provide Some Basic Components to Build Web App
91 lines (86 loc) • 2.67 kB
JavaScript
import { useContext } from 'react';
import LibraryContext from "../../../Provider/LibraryContextInit";
import { compileClassNames } from '@zohodesk/utils';
export default function cssJSLogic(_ref) {
let {
props,
style,
customState
} = _ref;
const DropBoxElementContext = useContext(LibraryContext);
const {
boxPosition,
boxDirection,
boxstyle,
needBoxStyle,
isAbsolute
} = customState;
const {
isReducedMotion
} = DropBoxElementContext || {};
const {
isAnimate,
isArrow,
size,
isRadius,
animationStyle,
isActive,
isModel,
isBoxPaddingNeed,
isPadding,
customClass,
positionsOffset,
targetOffset,
zIndexStyle,
customInlineStyle
} = props;
const {
customDropBox = '',
customMobileDropBox = '',
customDropBoxWrap = '',
customMobileDropBoxWrap = ''
} = customClass;
const animationValue = animationStyle === 'default' ? 'fadeInScale' : animationStyle; // const {needBoxStyle,boxstyle} = useDropboxPosCalc(props)
let boxClassName = compileClassNames({
[]: true,
[]: !isActive,
[]: !!isModel,
[]: !!isModel,
[]: !isModel,
[]: isAbsolute && !isModel,
[]]: isAbsolute && !isModel,
[]: !isAbsolute && !isModel,
[]]: size && !isModel,
[]: !isModel && isActive && isArrow,
[]: !isModel && isActive && isArrow && isAbsolute,
[]: !isModel && isActive && !isArrow && isPadding
});
let subContainerClass = compileClassNames({
[]: true,
[]: !!isModel,
[]: !!isModel,
[]: !!isModel && isActive,
[]: !isModel,
[]: !isModel,
[]: !isModel && isBoxPaddingNeed,
[]: !isModel && isRadius,
[]]: !isModel && isAnimate && !isReducedMotion && isActive && !!animationStyle
});
let inlineStyle = !isModel ? isAbsolute ? needBoxStyle && boxstyle : positionsOffset && positionsOffset[boxPosition] || {} : {};
if (zIndexStyle) {
inlineStyle = Object.assign({}, inlineStyle, zIndexStyle);
}
if (!isModel && !isAbsolute && size === 'default' && targetOffset && isActive) {
inlineStyle = Object.assign({}, inlineStyle, {
width: targetOffset.width
});
}
if (customInlineStyle) {
inlineStyle = Object.assign({}, inlineStyle, customInlineStyle);
}
return {
boxClassName,
subContainerClass,
inlineStyle
};
}