UNPKG

@beisen-phoenix/select

Version:

## 概述

245 lines (199 loc) 9.72 kB
"use strict"; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); Object.defineProperty(exports, "__esModule", { value: true }); exports.getHeightStyle = getHeightStyle; exports.getPaddingStyle = getPaddingStyle; exports.TipsSapn = exports.StyledTagSpan = exports.StyledDeleteIcon = exports.StyledHiddenSpan = exports.StyledWrapper = exports.StyledSpan = exports.Wrapper = exports.StyledUl = exports.SelectIconWrapper = exports.StyledInput = exports.InputWrapper = exports.IconWrapper = exports.Chosen = exports.PlaceHolder = void 0; var _styledComponents = _interopRequireWildcard(require("styled-components")); var _styleToken = require("@beisen-phoenix/style-token"); function getHeightStyle(size) { if (size === 'large') { return '32px'; } if (size === 'small') { return '26px;'; } if (size === 'normal') { return '30px'; } return 'auto'; } function getPaddingStyle(size) { if (size === 'large') { return (0, _styledComponents.css)(["padding-top:5px;padding-bottom:1px;"]); } if (size === 'small') { return (0, _styledComponents.css)(["padding-top:2px;padding-bottom:0px;"]); } if (size === 'normal') { return (0, _styledComponents.css)(["padding-top:4px;padding-bottom:0px;"]); } return (0, _styledComponents.css)(["padding-top:4px;padding-bottom:0px;"]); } var PlaceHolder = /*#__PURE__*/ _styledComponents.default.div(["position:absolute;top:50%;left:8px;max-width:calc(100% - 32px);height:20px;margin-top:-10px;overflow:hidden;color:", ";", " line-height:20px;white-space:nowrap;text-align:left;display:", ";", ";text-overflow:", ";"], _styleToken.$M5, _styleToken.$Fs1, function (props) { return props.isShowPlaceHolder ? 'block' : 'none'; }, function (props) { return props.size === 'large' ? "".concat(_styleToken.$Fs2) : "".concat(_styleToken.$Fs1); }, function (props) { return props.isFocus ? '' : 'ellipsis'; }); exports.PlaceHolder = PlaceHolder; var Chosen = /*#__PURE__*/ _styledComponents.default.li(["box-sizing:border-box;height:20px;line-height:20px;position:relative;float:left;max-width:99%;margin:0 ", " ", " 0;padding:0 ", " 0 ", ";overflow:hidden;", " background-color:", ";border-radius:", ";cursor:default;", ";", ";", ";"], _styleToken.$Sp2, _styleToken.$Sp2, _styleToken.$Sp3, _styleToken.$Sp3, _styleToken.$Fs1, _styleToken.$M7, _styleToken.$Ra2, function (props) { if (props.itemDisabled) { return (0, _styledComponents.css)(["padding-right:", ";cursor:not-allowed;"], _styleToken.$Sp3); } }, function (props) { if (props.selectDisabled) { return (0, _styledComponents.css)(["color:", ";cursor:not-allowed;"], _styleToken.$M2); } }, function (props) { if (props.size === 'small') { return (0, _styledComponents.css)(["margin-bottom:3px;"]); } }); exports.Chosen = Chosen; var IconWrapper = /*#__PURE__*/ _styledComponents.default.span(["margin-left:", ";padding-top:2px;float:right;cursor:pointer;", ";"], _styleToken.$Sp2, function (props) { if (props.selectDisabled) { return (0, _styledComponents.css)(["cursor:not-allowed;"]); } }); exports.IconWrapper = IconWrapper; var InputWrapper = /*#__PURE__*/ _styledComponents.default.li(["position:relative;float:left;overflow:hidden;max-width:100%;width:auto;", ";", ";"], _styleToken.$Fs1, function (props) { if (!props.multiValueLength) { return (0, _styledComponents.css)(["height:26px;width:99%;"]); } }); exports.InputWrapper = InputWrapper; var StyledInput = /*#__PURE__*/ _styledComponents.default.input(["display:inline-block;font-family:", ";padding:0;margin:0;max-width:100%;background:transparent;border-width:0;outline:0;border:none;min-width:10px;&::-ms-clear{display:none;}color:", ";height:26px;", ";line-height:26px;", ";", ";", ";"], _styleToken.$family, _styleToken.$M1, function (props) { return props.size === 'large' ? "".concat(_styleToken.$Fs2) : "".concat(_styleToken.$Fs1); }, function (props) { if (!props.isSearch) { return (0, _styledComponents.css)(["cursor:pointer;color:transparent;text-shadow:0 0 0 ", ";"], _styleToken.$M1); } }, function (props) { if (props.disabled) { return (0, _styledComponents.css)(["&[disabled]{cursor:not-allowed;}"]); } }, function (props) { var propsValue = props.propsValue; if (props.isMultiSelect && Array.isArray(propsValue) && propsValue.length) { return (0, _styledComponents.css)(["width:10px;height:20px;"]); } return (0, _styledComponents.css)(["width:100%;"]); }); exports.StyledInput = StyledInput; var SelectIconWrapper = /*#__PURE__*/ _styledComponents.default.div(["", ";font-size:12px;height:12px;margin-left:", ";position:absolute;right:", ";top:50%;transform:translateY(-50%);"], function (props) { if (props.disabled) { return (0, _styledComponents.css)(["cursor:not-allowed;"]); } }, _styleToken.$Sp2, _styleToken.$Sp3); exports.SelectIconWrapper = SelectIconWrapper; var StyledUl = /*#__PURE__*/ _styledComponents.default.ul(["margin:0;width:100%;box-sizing:border-box;position:relative;max-height:120px;overflow-y:auto;overflow-x:hidden;padding:0 ", " 0 8px;", ";"], _styleToken.$Sp8, _styleToken.$scrollBar); exports.StyledUl = StyledUl; var Wrapper = /*#__PURE__*/ _styledComponents.default.div(["font-family:", ";position:relative;box-sizing:border-box;display:flex;align-items:center;background-color:", ";background:", ";min-height:26px;min-width:100px;margin-bottom:", ";overflow:hidden;box-sizing:border-box;&::before{position:absolute;top:0;left:0;display:block;width:100%;height:100%;border-radius:", ";border:1px solid ", ";box-sizing:border-box;content:'';", ";", ";", ";}", ";", ";", ";&:hover{&::before{cursor:pointer;", ";", ";}.SwitchArrow{cursor:pointer;", ";}.DeleteInputTxt{", ";}}&:active::before,&:focus::before{", ";}"], _styleToken.$family, _styleToken.$M9, _styleToken.$M9, _styleToken.$Sp2, _styleToken.$Ra2, _styleToken.$M6, function (props) { if (!props.isMultiSelect) { return (0, _styledComponents.css)(["z-index:1;"]); } }, function (props) { if (props.error) { return (0, _styledComponents.css)(["border-color:", ";"], _styleToken.$red); } }, function (props) { if ((props.isFocus || props.isActive) && !props.error) { return (0, _styledComponents.css)(["border-color:", ";"], _styleToken.$S4); } }, function (props) { var multiValueLength = props.multiValueLength, size = props.size; if (multiValueLength) { return getPaddingStyle(size); } }, function (props) { if (props.multiValueLength && !props.isSingleLine) { return (0, _styledComponents.css)(["min-height:", ";height:auto;"], getHeightStyle(props.size)); } return (0, _styledComponents.css)(["height:", ";"], getHeightStyle(props.size)); }, function (props) { if (props.disabled) { return (0, _styledComponents.css)(["color:", ";background-color:", ";cursor:not-allowed;"], _styleToken.$M5, (0, _styleToken.$alpha)(_styleToken.$M6, '0.3')); } }, function (props) { if (!props.disabled && !props.error) { return (0, _styledComponents.css)(["border-color:", ";"], _styleToken.$S5); } }, function (props) { if (props.disabled) { return (0, _styledComponents.css)(["cursor:not-allowed;"]); } }, function (props) { if (props.disabled) { return (0, _styledComponents.css)(["cursor:not-allowed;"]); } if (props.isShowDeleteIcon) { return (0, _styledComponents.css)(["display:none;"]); } }, function (props) { if (props.isShowDeleteIcon) { return (0, _styledComponents.css)(["display:block;"]); } }, function (props) { if (!props.disabled && !props.error) { return (0, _styledComponents.css)(["border-color:", ";"], _styleToken.$S4); } }); exports.Wrapper = Wrapper; var StyledSpan = /*#__PURE__*/ _styledComponents.default.span(["display:flex;align-items:center;font-family:", ";box-sizing:border-box;color:", ";width:100%;background-color:#fff;pointer-events:none;padding-right:", ";padding-left:", ";left:0;position:absolute;height:100%;opacity:", ";", ";cursor:", ";", ";"], _styleToken.$family, _styleToken.$M1, _styleToken.$Sp8, _styleToken.$Sp3, function (props) { return props.visibleTxt ? 1 : 0; }, function (props) { return props.size === 'large' ? "".concat(_styleToken.$Fs2) : "".concat(_styleToken.$Fs1); }, function (props) { return props.isSearch ? 'text' : 'pointer'; }, function (props) { if (props.disabled) { return (0, _styledComponents.css)(["color:", ";background-color:transparent;"], _styleToken.$M2); } if (props.isFocus && props.isSearch) { return "color:".concat(_styleToken.$M5); } }); exports.StyledSpan = StyledSpan; var StyledWrapper = /*#__PURE__*/ _styledComponents.default.div(["position:relative;zoom:1;cursor:text;"]); exports.StyledWrapper = StyledWrapper; var StyledHiddenSpan = /*#__PURE__*/ _styledComponents.default.span(["display:inline-block;opacity:0;z-index:-1;position:absolute;font-size:12px;"]); exports.StyledHiddenSpan = StyledHiddenSpan; var StyledDeleteIcon = /*#__PURE__*/ _styledComponents.default.div(["z-index:1;display:none;font-size:12px;height:12px;margin-left:", ";position:absolute;right:", ";top:47%;transform:translateY(-50%);&:hover{cursor:pointer;}"], _styleToken.$Sp2, _styleToken.$Sp3); exports.StyledDeleteIcon = StyledDeleteIcon; var StyledTagSpan = /*#__PURE__*/ _styledComponents.default.span(["max-width:120px;display:inline-block;text-overflow:ellipsis;word-break:keep-all;white-space:nowrap;overflow:hidden;color:", ";"], _styleToken.$M2); exports.StyledTagSpan = StyledTagSpan; var TipsSapn = /*#__PURE__*/ _styledComponents.default.span(["text-overflow:ellipsis;word-break:keep-all;white-space:nowrap;overflow:hidden;"]); exports.TipsSapn = TipsSapn;