@react-spectrum/s2
Version:
Spectrum 2 UI components in React
105 lines (95 loc) • 4.18 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|_6|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 += ' Td1';
else if (props.padding === "default") {
rules += ' Th1';
rules += ' Tnk1';
}
if (props.padding === "none") rules += ' Qd1';
else if (props.padding === "default") {
rules += ' Qh1';
rules += ' Qnk1';
}
if (props.padding === "none") rules += ' Sd1';
else if (props.padding === "default") {
rules += ' Sh1';
rules += ' Snk1';
}
if (props.padding === "none") rules += ' Rd1';
else if (props.padding === "default") {
rules += ' Rh1';
rules += ' Rnk1';
}
rules += ' _oa1';
rules += ' _Le1';
rules += ' oi1';
rules += ' ni1';
rules += ' ki1';
rules += ' ji1';
rules += ' _Na1';
rules += ' Pa1';
if (!position) rules += ' _Pc1';
if (!width) rules += ' Za1';
if (!height) rules += ' Fb1';
if (!maxWidth) rules += ' L40ub4c1';
if (!maxHeight) rules += ' K40ub4c1';
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