86 lines
3.3 KiB
JavaScript
86 lines
3.3 KiB
JavaScript
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
import Trigger from '@rc-component/trigger';
|
|
import { clsx } from 'clsx';
|
|
import * as React from 'react';
|
|
import { getRealPlacement } from "../utils/uiUtil";
|
|
import PickerContext from "../PickerInput/context";
|
|
var BUILT_IN_PLACEMENTS = {
|
|
bottomLeft: {
|
|
points: ['tl', 'bl'],
|
|
offset: [0, 4],
|
|
overflow: {
|
|
adjustX: 1,
|
|
adjustY: 1
|
|
}
|
|
},
|
|
bottomRight: {
|
|
points: ['tr', 'br'],
|
|
offset: [0, 4],
|
|
overflow: {
|
|
adjustX: 1,
|
|
adjustY: 1
|
|
}
|
|
},
|
|
topLeft: {
|
|
points: ['bl', 'tl'],
|
|
offset: [0, -4],
|
|
overflow: {
|
|
adjustX: 0,
|
|
adjustY: 1
|
|
}
|
|
},
|
|
topRight: {
|
|
points: ['br', 'tr'],
|
|
offset: [0, -4],
|
|
overflow: {
|
|
adjustX: 0,
|
|
adjustY: 1
|
|
}
|
|
}
|
|
};
|
|
function PickerTrigger(_ref) {
|
|
var popupElement = _ref.popupElement,
|
|
popupStyle = _ref.popupStyle,
|
|
popupClassName = _ref.popupClassName,
|
|
popupAlign = _ref.popupAlign,
|
|
transitionName = _ref.transitionName,
|
|
getPopupContainer = _ref.getPopupContainer,
|
|
children = _ref.children,
|
|
range = _ref.range,
|
|
placement = _ref.placement,
|
|
_ref$builtinPlacement = _ref.builtinPlacements,
|
|
builtinPlacements = _ref$builtinPlacement === void 0 ? BUILT_IN_PLACEMENTS : _ref$builtinPlacement,
|
|
direction = _ref.direction,
|
|
visible = _ref.visible,
|
|
onClose = _ref.onClose;
|
|
var _React$useContext = React.useContext(PickerContext),
|
|
prefixCls = _React$useContext.prefixCls;
|
|
var dropdownPrefixCls = "".concat(prefixCls, "-dropdown");
|
|
var realPlacement = getRealPlacement(placement, direction === 'rtl');
|
|
return /*#__PURE__*/React.createElement(Trigger, {
|
|
showAction: [],
|
|
hideAction: ['click'],
|
|
popupPlacement: realPlacement,
|
|
builtinPlacements: builtinPlacements,
|
|
prefixCls: dropdownPrefixCls,
|
|
popupMotion: {
|
|
motionName: transitionName
|
|
},
|
|
popup: popupElement,
|
|
popupAlign: popupAlign,
|
|
popupVisible: visible,
|
|
popupClassName: clsx(popupClassName, _defineProperty(_defineProperty({}, "".concat(dropdownPrefixCls, "-range"), range), "".concat(dropdownPrefixCls, "-rtl"), direction === 'rtl')),
|
|
popupStyle: popupStyle,
|
|
stretch: "minWidth",
|
|
getPopupContainer: getPopupContainer,
|
|
onPopupVisibleChange: function onPopupVisibleChange(nextVisible) {
|
|
if (!nextVisible) {
|
|
onClose();
|
|
}
|
|
}
|
|
}, children);
|
|
}
|
|
export default PickerTrigger; |