UNPKG

@chayns-components/core

Version:

A set of beautiful React components for developing your own applications with chayns.

270 lines (258 loc) • 8.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StyledComboBoxTopic = exports.StyledComboBoxPrefixAndPlaceholderWrapper = exports.StyledComboBoxPrefix = exports.StyledComboBoxPlaceholderText = exports.StyledComboBoxPlaceholderImage = exports.StyledComboBoxPlaceholder = exports.StyledComboBoxInput = exports.StyledComboBoxIconWrapper = exports.StyledComboBoxHeader = exports.StyledComboBoxClearIconWrapper = exports.StyledComboBoxBody = exports.StyledComboBox = void 0; var _styledComponents = _interopRequireWildcard(require("styled-components")); var _dropdown = require("../../types/dropdown"); var _ComboBox = require("./ComboBox.types"); var _keyboardFocusHighlighting = require("../../utils/keyboardFocusHighlighting.styles"); 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` min-width: 0; user-select: none; position: relative; ${({ $shouldUseFullWidth, $minWidth }) => { if ($shouldUseFullWidth) { return (0, _styledComponents.css)` width: 100%; max-width: 100%; min-width: ${typeof $minWidth === 'number' ? `${$minWidth}px` : '0'}; `; } if (typeof $minWidth === 'number') { return (0, _styledComponents.css)` width: fit-content; max-width: 100%; min-width: ${$minWidth}px; `; } return (0, _styledComponents.css)` width: fit-content; max-width: 100%; `; }} `; const StyledComboBoxHeader = exports.StyledComboBoxHeader = _styledComponents.default.div` display: flex; min-width: 0; border: 1px solid transparent; cursor: ${({ $isDisabled }) => !$isDisabled ? 'pointer' : 'default'}; justify-content: space-between; opacity: ${({ $isDisabled }) => $isDisabled ? 0.5 : 1}; transition: background-color 0.2s ease-in-out; ${({ $size }) => { switch ($size) { case _ComboBox.ComboBoxSize.SMALL: return (0, _styledComponents.css)` height: 34px; `; case _ComboBox.ComboBoxSize.NORMAL: default: return (0, _styledComponents.css)` min-height: 42px; `; } }} ${({ theme, $shouldShowTransparentBackground, $shouldChangeColor }) => { if ($shouldShowTransparentBackground) { if (theme.colorMode === 'dark') { return (0, _styledComponents.css)` border-color: rgba(255, 255, 255, 0.5); background-color: transparent; `; } return (0, _styledComponents.css)` border-color: rgba(0, 0, 0, 0.5); background-color: transparent; `; } return (0, _styledComponents.css)` border-color: rgba(160, 160, 160, 0.3); background-color: ${theme.colorMode === 'classic' || $shouldChangeColor ? theme['000'] : theme['100']}; `; }} ${({ $shouldShowBigImage }) => $shouldShowBigImage && (0, _styledComponents.css)` height: 42px; `} ${({ $isOpen, $direction }) => { if ($isOpen) { return [_dropdown.DropdownDirection.BOTTOM, _dropdown.DropdownDirection.BOTTOM_LEFT, _dropdown.DropdownDirection.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']}; } `} ${({ $shouldShowKeyboardHighlighting }) => $shouldShowKeyboardHighlighting && (0, _styledComponents.css)` &:focus-visible, &:focus-within { transition: none; ${_keyboardFocusHighlighting.keyboardFocusHighlightingRingCss} } `} `; 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: ${({ $prefixMinWidth }) => $prefixMinWidth ?? 0}px; padding-right: 5px; `; const StyledComboBoxInput = exports.StyledComboBoxInput = _styledComponents.default.input` color: ${({ theme }) => theme.text}; border: none; background-color: transparent; width: 100%; min-width: 0; `; 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: ${({ $isDisabled }) => !$isDisabled ? 'pointer' : 'default'}; 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: ${({ $isDisabled }) => !$isDisabled ? 'pointer' : 'default'}; display: flex; flex: 0 0 auto; justify-content: center; width: 40px; ${({ $size }) => { switch ($size) { case _ComboBox.ComboBoxSize.SMALL: return (0, _styledComponents.css)` height: 30px; `; case _ComboBox.ComboBoxSize.NORMAL: default: return (0, _styledComponents.css)` height: 40px; `; } }} `; const StyledComboBoxBody = exports.StyledComboBoxBody = _styledComponents.default.div` display: flex; flex-direction: column; cursor: pointer; min-width: ${({ $minWidth }) => $minWidth}px; overflow-x: hidden; overflow-y: auto; max-height: ${({ $maxHeight }) => $maxHeight}px; `; const StyledComboBoxTopic = exports.StyledComboBoxTopic = _styledComponents.default.div` align-items: center; background-color: ${({ theme }) => theme['secondary-102']}; color: rgba(${({ theme }) => theme['text-rgb']}, 0.65); cursor: default; display: flex; flex: 0 0 auto; font-weight: bold; min-height: 38px; line-height: normal; padding: 8px 10px; position: sticky; top: 0; z-index: 10; `; //# sourceMappingURL=ComboBox.styles.js.map