PickerTrigger.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { createVNode as _createVNode, resolveDirective as _resolveDirective } from "vue";
  2. import Trigger from '../vc-trigger';
  3. import classNames from '../_util/classNames';
  4. import useMergeProps from './hooks/useMergeProps';
  5. const BUILT_IN_PLACEMENTS = {
  6. bottomLeft: {
  7. points: ['tl', 'bl'],
  8. offset: [0, 4],
  9. overflow: {
  10. adjustX: 1,
  11. adjustY: 1
  12. }
  13. },
  14. bottomRight: {
  15. points: ['tr', 'br'],
  16. offset: [0, 4],
  17. overflow: {
  18. adjustX: 1,
  19. adjustY: 1
  20. }
  21. },
  22. topLeft: {
  23. points: ['bl', 'tl'],
  24. offset: [0, -4],
  25. overflow: {
  26. adjustX: 0,
  27. adjustY: 1
  28. }
  29. },
  30. topRight: {
  31. points: ['br', 'tr'],
  32. offset: [0, -4],
  33. overflow: {
  34. adjustX: 0,
  35. adjustY: 1
  36. }
  37. }
  38. };
  39. function PickerTrigger(props, _ref) {
  40. let {
  41. slots
  42. } = _ref;
  43. const {
  44. prefixCls,
  45. popupStyle,
  46. visible,
  47. dropdownClassName,
  48. dropdownAlign,
  49. transitionName,
  50. getPopupContainer,
  51. range,
  52. popupPlacement,
  53. direction
  54. } = useMergeProps(props);
  55. const dropdownPrefixCls = `${prefixCls}-dropdown`;
  56. const getPopupPlacement = () => {
  57. if (popupPlacement !== undefined) {
  58. return popupPlacement;
  59. }
  60. return direction === 'rtl' ? 'bottomRight' : 'bottomLeft';
  61. };
  62. return _createVNode(Trigger, {
  63. "showAction": [],
  64. "hideAction": [],
  65. "popupPlacement": getPopupPlacement(),
  66. "builtinPlacements": BUILT_IN_PLACEMENTS,
  67. "prefixCls": dropdownPrefixCls,
  68. "popupTransitionName": transitionName,
  69. "popupAlign": dropdownAlign,
  70. "popupVisible": visible,
  71. "popupClassName": classNames(dropdownClassName, {
  72. [`${dropdownPrefixCls}-range`]: range,
  73. [`${dropdownPrefixCls}-rtl`]: direction === 'rtl'
  74. }),
  75. "popupStyle": popupStyle,
  76. "getPopupContainer": getPopupContainer
  77. }, {
  78. default: slots.default,
  79. popup: slots.popupElement
  80. });
  81. }
  82. export default PickerTrigger;