multiple.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _cssinjs = require("@ant-design/cssinjs");
  7. var _multiple = require("../../select/style/multiple");
  8. var _internal = require("../../theme/internal");
  9. const genSize = (token, suffix) => {
  10. const {
  11. componentCls,
  12. controlHeight
  13. } = token;
  14. const suffixCls = suffix ? `${componentCls}-${suffix}` : '';
  15. const multipleSelectorUnit = (0, _multiple.getMultipleSelectorUnit)(token);
  16. return [
  17. // genSelectionStyle(token, suffix),
  18. {
  19. [`${componentCls}-multiple${suffixCls}`]: {
  20. paddingBlock: multipleSelectorUnit.containerPadding,
  21. paddingInlineStart: multipleSelectorUnit.basePadding,
  22. minHeight: controlHeight,
  23. // ======================== Selections ========================
  24. [`${componentCls}-selection-item`]: {
  25. height: multipleSelectorUnit.itemHeight,
  26. lineHeight: (0, _cssinjs.unit)(multipleSelectorUnit.itemLineHeight)
  27. }
  28. }
  29. }];
  30. };
  31. const genPickerMultipleStyle = token => {
  32. const {
  33. componentCls,
  34. calc,
  35. lineWidth
  36. } = token;
  37. const smallToken = (0, _internal.mergeToken)(token, {
  38. fontHeight: token.fontSize,
  39. selectHeight: token.controlHeightSM,
  40. multipleSelectItemHeight: token.multipleItemHeightSM,
  41. borderRadius: token.borderRadiusSM,
  42. borderRadiusSM: token.borderRadiusXS,
  43. controlHeight: token.controlHeightSM
  44. });
  45. const largeToken = (0, _internal.mergeToken)(token, {
  46. fontHeight: calc(token.multipleItemHeightLG).sub(calc(lineWidth).mul(2).equal()).equal(),
  47. fontSize: token.fontSizeLG,
  48. selectHeight: token.controlHeightLG,
  49. multipleSelectItemHeight: token.multipleItemHeightLG,
  50. borderRadius: token.borderRadiusLG,
  51. borderRadiusSM: token.borderRadius,
  52. controlHeight: token.controlHeightLG
  53. });
  54. return [
  55. // ======================== Size ========================
  56. genSize(smallToken, 'small'), genSize(token), genSize(largeToken, 'large'),
  57. // ====================== Selection ======================
  58. {
  59. [`${componentCls}${componentCls}-multiple`]: Object.assign(Object.assign({
  60. width: '100%',
  61. cursor: 'text',
  62. // ==================== Selector =====================
  63. [`${componentCls}-selector`]: {
  64. flex: 'auto',
  65. padding: 0,
  66. position: 'relative',
  67. '&:after': {
  68. margin: 0
  69. },
  70. // ================== placeholder ==================
  71. [`${componentCls}-selection-placeholder`]: {
  72. position: 'absolute',
  73. top: '50%',
  74. insetInlineStart: token.inputPaddingHorizontalBase,
  75. insetInlineEnd: 0,
  76. transform: 'translateY(-50%)',
  77. transition: `all ${token.motionDurationSlow}`,
  78. overflow: 'hidden',
  79. whiteSpace: 'nowrap',
  80. textOverflow: 'ellipsis',
  81. flex: 1,
  82. color: token.colorTextPlaceholder,
  83. pointerEvents: 'none'
  84. }
  85. }
  86. }, (0, _multiple.genOverflowStyle)(token)), {
  87. // ====================== Input ======================
  88. // Input is `readonly`, which is used for a11y only
  89. [`${componentCls}-multiple-input`]: {
  90. width: 0,
  91. height: 0,
  92. border: 0,
  93. visibility: 'hidden',
  94. position: 'absolute',
  95. zIndex: -1
  96. }
  97. })
  98. }];
  99. };
  100. var _default = exports.default = genPickerMultipleStyle;