@chayns-components/emoji-input
Version:
Input field that supports HTML elements and emojis
131 lines (123 loc) • 4.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StyledMotionEmojiInputProgress = exports.StyledMotionEmojiInputEditor = exports.StyledEmojiInputRightWrapper = exports.StyledEmojiInputLabel = exports.StyledEmojiInputContent = exports.StyledEmojiInput = void 0;
var _react = require("motion/react");
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _font = require("../../utils/font");
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 StyledEmojiInput = exports.StyledEmojiInput = _styledComponents.default.div`
align-items: center;
background-color: ${({
theme,
$shouldChangeColor
}) => theme.colorMode === 'classic' || $shouldChangeColor ? theme['000'] : theme['100']};
border-radius: 3px;
display: flex;
border: 1px solid rgba(160, 160, 160, 0.3);
min-height: 42px;
opacity: ${({
$isDisabled
}) => $isDisabled ? 0.5 : 1};
pointer-events: ${({
$isDisabled
}) => $isDisabled ? 'none' : 'initial'};
position: relative;
transition: opacity 0.3s ease;
`;
const StyledMotionEmojiInputProgress = exports.StyledMotionEmojiInputProgress = (0, _styledComponents.default)(_react.motion.div)`
background-color: ${({
theme
}) => theme['402']};
height: 100%;
position: absolute;
z-index: 2;
border-radius: 3px;
`;
const StyledEmojiInputContent = exports.StyledEmojiInputContent = _styledComponents.default.div`
align-items: end;
border-radius: 3px;
display: flex;
flex: 1 1 auto;
gap: 10px;
padding: 8px 10px;
z-index: 3;
`;
const StyledMotionEmojiInputEditor = exports.StyledMotionEmojiInputEditor = (0, _styledComponents.default)(_react.motion.div)`
color: ${({
theme,
$shouldShowContent
}) => $shouldShowContent ? theme.text : theme['100']};
flex: 1 1 auto;
font-family: ${_font.getFontFamily};
overflow-y: scroll;
overflow-x: hidden;
word-break: break-word;
// This fixes a bug where the field is not editable in certain browsers.
// This is for example the case on iOS 15 or older.
-webkit-user-modify: read-write;
-webkit-user-select: text;
lc_mention,
nerIgnore,
nerReplace {
font-weight: bold;
span {
opacity: 0.5;
}
}
// 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 StyledEmojiInputRightWrapper = exports.StyledEmojiInputRightWrapper = _styledComponents.default.div`
align-self: stretch;
border-bottom-right-radius: 3px;
border-top-right-radius: 3px;
flex: 0 0 auto;
overflow: hidden;
`;
const StyledEmojiInputLabel = exports.StyledEmojiInputLabel = _styledComponents.default.label`
color: rgba(${({
theme
}) => theme['text-rgb']}, 0.45);
left: ${({
$offsetWidth
}) => $offsetWidth ? `${$offsetWidth + 10}px` : '10px'};
top: 12px;
align-items: baseline;
display: flex;
flex: 0 0 auto;
gap: 4px;
line-height: 1.3;
pointer-events: none;
position: absolute;
user-select: none;
white-space: nowrap;
max-width: ${({
$maxWidth,
$offsetWidth
}) => `${$maxWidth - ($offsetWidth ?? 0)}px`};
overflow: hidden;
`;
//# sourceMappingURL=EmojiInput.styles.js.map