@react-spectrum/s2
Version:
Spectrum 2 UI components in React
105 lines (95 loc) • 4.2 kB
JavaScript
require("./CustomDialog.css");
var $8e678305a8c10028$exports = require("./Modal.cjs");
var $f8dpT$reactjsxruntime = require("react/jsx-runtime");
var $f8dpT$reactariacomponents = require("react-aria-components");
var $f8dpT$react = require("react");
var $f8dpT$reactspectrumutils = require("@react-spectrum/utils");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "CustomDialog", () => $a05aa0b0345f1846$export$82e1fa7406db6ec);
/*
* Copyright 2024 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
const $a05aa0b0345f1846$var$dialogStyle = function anonymous(props, overrides) {
let rules = " ";
let position = false;
let width = false;
let height = false;
let maxWidth = false;
let maxHeight = false;
let matches = (overrides || '').matchAll(/(?:^|\s)(J|G|I|H|_u|_v|_s|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|Z|N|L|F|M|K)[^\s]+/g);
for (let p of matches){
if (p[1] === "_P") position = true;
if (p[1] === "Z") width = true;
if (p[1] === "F") height = true;
if (p[1] === "L") maxWidth = true;
if (p[1] === "K") maxHeight = true;
rules += p[0];
}
if (props.padding === "none") rules += ' Td91';
else if (props.padding === "default") {
rules += ' Th91';
rules += ' Tnk91';
}
if (props.padding === "none") rules += ' Qd91';
else if (props.padding === "default") {
rules += ' Qh91';
rules += ' Qnk91';
}
if (props.padding === "none") rules += ' Sd91';
else if (props.padding === "default") {
rules += ' Sh91';
rules += ' Snk91';
}
if (props.padding === "none") rules += ' Rd91';
else if (props.padding === "default") {
rules += ' Rh91';
rules += ' Rnk91';
}
rules += ' _oa91';
rules += ' _Le91';
rules += ' oi91';
rules += ' ni91';
rules += ' ki91';
rules += ' ji91';
rules += ' _Na91';
rules += ' Pa91';
if (!position) rules += ' _Pc91';
if (!width) rules += ' Za91';
if (!height) rules += ' Fb91';
if (!maxWidth) rules += ' L40ub4c91';
if (!maxHeight) rules += ' K40ub4c91';
return rules;
};
const $a05aa0b0345f1846$export$82e1fa7406db6ec = /*#__PURE__*/ (0, $f8dpT$react.forwardRef)(function CustomDialog(props, ref) {
let { size: size, isDismissible: isDismissible, isKeyboardDismissDisabled: isKeyboardDismissDisabled, padding: padding = 'default' } = props;
let domRef = (0, $f8dpT$reactspectrumutils.useDOMRef)(ref);
return /*#__PURE__*/ (0, $f8dpT$reactjsxruntime.jsx)((0, $8e678305a8c10028$exports.Modal), {
size: size,
isDismissable: isDismissible,
isKeyboardDismissDisabled: isKeyboardDismissDisabled,
children: /*#__PURE__*/ (0, $f8dpT$reactjsxruntime.jsx)((0, $f8dpT$reactariacomponents.Dialog), {
...props,
ref: domRef,
style: props.UNSAFE_style,
className: (props.UNSAFE_className || '') + $a05aa0b0345f1846$var$dialogStyle({
padding: padding
}, props.styles),
children: (0, $f8dpT$reactariacomponents.composeRenderProps)(props.children, (children)=>// Reset OverlayTriggerStateContext so the buttons inside the dialog don't retain their hover state.
/*#__PURE__*/ (0, $f8dpT$reactjsxruntime.jsx)((0, $f8dpT$reactariacomponents.OverlayTriggerStateContext).Provider, {
value: null,
children: children
}))
})
});
});
//# sourceMappingURL=CustomDialog.cjs.map