@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
122 lines (116 loc) • 5.01 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PopoverAnimationStyled = exports.PopoverStyled = void 0;
const styled_components_1 = __importStar(require("styled-components"));
const breakpoints_1 = require("../../types/breakpoints/breakpoints");
const positions_1 = require("../../types/positions/positions");
const align_1 = require("./types/align");
const MAX_CONTENT = 'max-content';
// Replace width style if exists and add margin left
// It is necessary if we want the popover to grow to the right of the element
const getWidth = (props) => {
let newWidth = props.fullWidth || props[props.device]?.fullWidth ? '100%' : MAX_CONTENT;
if (props.extraWidth && newWidth !== MAX_CONTENT) {
newWidth = `calc(${newWidth} + ${props.extraWidth})`;
}
let marginLeft = '';
if (props.extraWidth) {
const marginDirection = props.extraWidthSide === positions_1.POSITIONS.LEFT ? '-' : '';
marginLeft = `calc(${marginDirection}${props.extraWidth} / 2)`;
}
return (0, styled_components_1.css) `
width: ${newWidth};
margin-left: ${marginLeft};
`;
};
// Get the align styles
const alignProps = (align = positions_1.POSITIONS.CENTER, extraAlignGap = '0px') => {
// It is necessary if we want the popover to grow to the left of the element
return (0, align_1.getAlignStyles)(align, extraAlignGap);
};
exports.PopoverStyled = styled_components_1.default.div `
width: ${props => props.fullWidth || props[breakpoints_1.DeviceBreakpointsType.DESKTOP]?.fullWidth ? '100%' : MAX_CONTENT};
display: inline-block;
background-color: transparent;
position: ${props => props.positionVariant
? props.positionVariant
: props[breakpoints_1.DeviceBreakpointsType.DESKTOP]?.positionVariant};
z-index: ${props => props[breakpoints_1.DeviceBreakpointsType.DESKTOP]?.zIndex || props.zIndex || 'auto'};
${props => props.align
? alignProps(props.align, props.extraAlignGap)
: alignProps(props[breakpoints_1.DeviceBreakpointsType.DESKTOP]?.align)};
${({ theme: { MEDIA_QUERIES: { onlyMobile, onlyTablet, onlyDesktop }, }, zIndex, ...props }) => (0, styled_components_1.css) `
${onlyDesktop} {
${getWidth(props)}
}
top: ${props.top};
bottom: ${props.bottom};
right: ${props.right};
left: ${props.left};
${onlyTablet} {
position: ${!props[breakpoints_1.DeviceBreakpointsType.TABLET]
? props.positionVariant
: props[breakpoints_1.DeviceBreakpointsType.TABLET]?.positionVariant};
${props.align
? alignProps(props.align, props.extraAlignGap)
: alignProps(props[breakpoints_1.DeviceBreakpointsType.TABLET]?.align)};
${getWidth(props)}
top: ${props.top};
bottom: ${props.bottom};
right: ${props.right};
left: ${props.left};
z-index: ${props => props[breakpoints_1.DeviceBreakpointsType.TABLET]?.zIndex || zIndex || 'auto'};
}
${onlyMobile} {
position: ${!props[breakpoints_1.DeviceBreakpointsType.MOBILE]
? props.positionVariant
: props[breakpoints_1.DeviceBreakpointsType.MOBILE]?.positionVariant};
${alignProps(props[breakpoints_1.DeviceBreakpointsType.MOBILE]?.align)};
${getWidth(props)}
top: ${props.top};
bottom: ${props.bottom};
right: ${props.right};
left: ${props.left};
z-index: ${props => props[breakpoints_1.DeviceBreakpointsType.MOBILE]?.zIndex || zIndex || 'auto'};
}
`}
height: auto;
max-height: 100%;
`;
exports.PopoverAnimationStyled = styled_components_1.default.div.withConfig({
shouldForwardProp: () => true,
}) ``;
//# sourceMappingURL=popover.styled.js.map