@chayns-components/core
Version:
A set of beautiful React components for developing your own applications with chayns.
262 lines (250 loc) • 8.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StyledMotionComboBoxBody = exports.StyledComboBoxTopic = exports.StyledComboBoxPrefixAndPlaceholderWrapper = exports.StyledComboBoxPrefix = exports.StyledComboBoxPlaceholderText = exports.StyledComboBoxPlaceholderImage = exports.StyledComboBoxPlaceholder = exports.StyledComboBoxInput = exports.StyledComboBoxIconWrapper = exports.StyledComboBoxHeader = exports.StyledComboBoxClearIconWrapper = exports.StyledComboBox = void 0;
var _react = require("motion/react");
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _comboBox = require("../../types/comboBox");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const StyledComboBox = exports.StyledComboBox = _styledComponents.default.div`
user-select: none;
position: relative;
${({
$shouldUseFullWidth,
$minWidth,
$shouldUseCurrentItemWidth
}) => {
if (typeof $minWidth !== 'number') {
return (0, _styledComponents.css)`
width: fit-content;
`;
}
if ($shouldUseFullWidth) {
return (0, _styledComponents.css)`
min-width: ${$minWidth}px;
width: 100%;
`;
}
if ($shouldUseCurrentItemWidth) {
return '';
}
return (0, _styledComponents.css)`
min-width: ${$minWidth}px;
max-width: ${$minWidth}px;
`;
}}
`;
const StyledComboBoxHeader = exports.StyledComboBoxHeader = _styledComponents.default.div`
display: flex;
background-color: ${({
theme,
$shouldChangeColor
}) => theme.colorMode === 'classic' || $shouldChangeColor ? theme['000'] : theme['100']};
border: 1px solid rgba(160, 160, 160, 0.3);
cursor: ${({
$isDisabled
}) => !$isDisabled ? 'pointer' : 'default'};
justify-content: space-between;
opacity: ${({
$isDisabled
}) => $isDisabled ? 0.5 : 1};
transition: background-color 0.2s ease-in-out;
${({
$shouldShowBigImage
}) => $shouldShowBigImage && (0, _styledComponents.css)`
height: 42px;
`}
${({
$isOpen,
$direction
}) => {
if ($isOpen) {
return [_comboBox.ComboBoxDirection.BOTTOM, _comboBox.ComboBoxDirection.BOTTOM_LEFT, _comboBox.ComboBoxDirection.BOTTOM_RIGHT].includes($direction) ? (0, _styledComponents.css)`
border-top-left-radius: 3px;
border-top-right-radius: 3px;
` : (0, _styledComponents.css)`
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
`;
}
return (0, _styledComponents.css)`
border-radius: 3px;
`;
}}
${({
$isTouch,
$isDisabled,
theme
}) => !$isTouch && !$isDisabled && (0, _styledComponents.css)`
&:hover {
background-color: ${theme['secondary-102']};
}
`}
`;
const StyledComboBoxPlaceholder = exports.StyledComboBoxPlaceholder = _styledComponents.default.div`
align-items: center;
color: ${({
theme
}) => theme.text};
display: flex;
flex: 1 1 auto;
gap: 10px;
min-width: 0;
opacity: ${({
$shouldReduceOpacity
}) => $shouldReduceOpacity ? 0.5 : 1};
`;
const StyledComboBoxPlaceholderText = exports.StyledComboBoxPlaceholderText = _styledComponents.default.div`
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;
const StyledComboBoxPrefixAndPlaceholderWrapper = exports.StyledComboBoxPrefixAndPlaceholderWrapper = _styledComponents.default.div`
align-items: center;
display: flex;
flex: 1 1 auto;
min-width: 0;
padding: 4px 10px;
`;
const StyledComboBoxPrefix = exports.StyledComboBoxPrefix = _styledComponents.default.div`
flex: 0 0 auto;
min-width: 32px;
padding-right: 5px;
`;
const StyledComboBoxInput = exports.StyledComboBoxInput = _styledComponents.default.input`
color: ${({
theme
}) => theme.text};
border: none;
background-color: transparent;
width: 100%;
`;
const StyledComboBoxPlaceholderImage = exports.StyledComboBoxPlaceholderImage = _styledComponents.default.img`
box-shadow: 0 0 0 1px
rgba(${({
theme
}) => theme['009-rgb']}, 0.15);
height: ${({
$shouldShowBigImage
}) => $shouldShowBigImage ? '32px' : '22px'};
width: ${({
$shouldShowBigImage
}) => $shouldShowBigImage ? '32px' : '22px'};
${({
$shouldShowRoundImage
}) => $shouldShowRoundImage && (0, _styledComponents.css)`
border-radius: 50%;
`}
`;
const StyledComboBoxClearIconWrapper = exports.StyledComboBoxClearIconWrapper = _styledComponents.default.div`
align-items: center;
cursor: pointer;
display: flex;
flex: 0 0 auto;
height: 40px;
justify-content: center;
width: 40px;
`;
const StyledComboBoxIconWrapper = exports.StyledComboBoxIconWrapper = _styledComponents.default.div`
align-items: center;
border-left: ${({
$shouldShowBorderLeft
}) => $shouldShowBorderLeft ? '1px solid rgba(160, 160, 160, 0.3)' : 'none'};
cursor: pointer;
display: flex;
flex: 0 0 auto;
height: 40px;
justify-content: center;
width: 40px;
`;
const StyledMotionComboBoxBody = exports.StyledMotionComboBoxBody = (0, _styledComponents.default)(_react.motion.div)`
background: ${({
theme
}) => theme['000']};
display: flex;
position: absolute;
z-index: 4;
flex-direction: column;
border: 1px solid rgba(160, 160, 160, 0.3);
cursor: pointer;
max-height: ${({
$maxHeight
}) => $maxHeight};
overflow-y: ${({
$overflowY
}) => $overflowY};
overflow-x: hidden;
transform: ${({
$translateX,
$translateY
}) => `translate(${$translateX}, ${$translateY})`};
min-width: ${({
$minWidth
}) => $minWidth}px;
${({
$minWidth,
$overflowY,
$shouldUseCurrentItemWidth
}) => !$shouldUseCurrentItemWidth && (0, _styledComponents.css)`
max-width: ${$minWidth - ($overflowY === 'scroll' ? 5 : 0)}px;
`}
${({
$direction
}) => {
if ([_comboBox.ComboBoxDirection.BOTTOM, _comboBox.ComboBoxDirection.BOTTOM_LEFT, _comboBox.ComboBoxDirection.BOTTOM_RIGHT].includes($direction)) {
return (0, _styledComponents.css)`
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.2);
`;
}
return (0, _styledComponents.css)`
border-top-left-radius: 3px;
border-top-right-radius: 3px;
box-shadow: 0 -3px 10px 0 rgba(0, 0, 0, 0.2);
`;
}}
// Styles for custom scrollbar
${({
$browser,
theme
}) => $browser === 'firefox' ? (0, _styledComponents.css)`
scrollbar-color: rgba(${theme['text-rgb']}, 0.15) transparent;
scrollbar-width: thin;
` : (0, _styledComponents.css)`
&::-webkit-scrollbar {
width: 5px;
}
&::-webkit-scrollbar-track {
background-color: transparent;
}
&::-webkit-scrollbar-button {
background-color: transparent;
height: 5px;
}
&::-webkit-scrollbar-thumb {
background-color: rgba(${theme['text-rgb']}, 0.15);
border-radius: 20px;
}
`}
`;
const StyledComboBoxTopic = exports.StyledComboBoxTopic = _styledComponents.default.div`
align-items: center;
color: rgba(${({
theme
}) => theme['text-rgb']}, 0.65);
position: sticky;
top: 0;
border: black 5px;
cursor: default;
font-weight: bold;
display: flex;
gap: 10px;
z-index: 10;
padding: 4px 10px;
background-color: ${({
theme
}) => theme['secondary-101']};
`;
//# sourceMappingURL=ComboBox.styles.js.map