@primer/components
Version:
Primer react components
63 lines (48 loc) • 4.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _styledSystem = require("styled-system");
var _constants = require("../constants");
var _sx = _interopRequireDefault(require("../sx"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
const animateModal = (0, _styledComponents.keyframes)(["0%{opacity:0;transform:scale(0.9);}"]);
const modalStyles = (0, _styledComponents.css)(["position:relative;z-index:99;display:flex;", ";max-height:", ";margin:auto 0;", ";overflow:hidden;pointer-events:auto;flex-direction:column;background-color:", ";border-radius:", ";box-shadow:", ";animation:", " 0.12s cubic-bezier(0,0.1,0.1,1) backwards;@media (min-width:", "){height:auto;max-height:350px;margin:", " 0 ", " 0;font-size:", ";border:", " solid ", ";border-radius:", ";box-shadow:", ";}"], props => props.filter ? 'height: 80%' : '', props => props.filter ? 'none' : '66%', props => props.filter ? 'margin-top: 0' : '', (0, _constants.get)('colors.canvas.overlay'), (0, _constants.get)('radii.2'), (0, _constants.get)('shadows.shadow.small'), animateModal, (0, _constants.get)('breakpoints.0'), (0, _constants.get)('space.1'), (0, _constants.get)('space.3'), (0, _constants.get)('fontSizes.0'), (0, _constants.get)('borderWidths.1'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('radii.2'), (0, _constants.get)('shadows.shadow.small'));
const modalWrapperStyles = (0, _styledComponents.css)(["position:fixed;top:0;right:0;bottom:0;left:0;z-index:99;display:flex;padding:", ";pointer-events:none;flex-direction:column;&::before{position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none;content:'';background-color:", ";@media (min-width:", "){display:none;}}@media (min-width:", "){position:absolute;top:auto;right:", ";bottom:auto;left:auto;padding:0;}"], (0, _constants.get)('space.3'), (0, _constants.get)('colors.primer.canvas.backdrop'), (0, _constants.get)('breakpoints.0'), (0, _constants.get)('breakpoints.0'), props => props.align === 'right' ? '0' : 'auto');
const Modal = _styledComponents.default.div.withConfig({
displayName: "SelectMenuModal__Modal",
componentId: "sc-1m5qo55-0"
})(["", " ", ""], modalStyles, _styledSystem.width);
const ModalWrapper = _styledComponents.default.div.withConfig({
displayName: "SelectMenuModal__ModalWrapper",
componentId: "sc-1m5qo55-1"
})(["", " ", " ", ";"], modalWrapperStyles, _constants.COMMON, _sx.default);
const SelectMenuModal = /*#__PURE__*/_react.default.forwardRef(({
children,
theme,
width: widthProp,
...rest
}, forwardedRef) => {
return /*#__PURE__*/_react.default.createElement(ModalWrapper, _extends({
theme: theme
}, rest, {
role: "menu",
ref: forwardedRef
}), /*#__PURE__*/_react.default.createElement(Modal, {
theme: theme,
width: widthProp
}, children));
});
SelectMenuModal.defaultProps = {
align: 'left',
width: '300px'
};
SelectMenuModal.displayName = 'SelectMenu.Modal';
var _default = SelectMenuModal;
exports.default = _default;