@react-spectrum/s2
Version:
Spectrum 2 UI components in React
100 lines (92 loc) • 4.05 kB
JavaScript
import "./CustomDialog.css";
import {Modal as $c46d159bd615e407$export$2b77a92f1a5ad772} from "./Modal.mjs";
import {jsx as $4wOFe$jsx} from "react/jsx-runtime";
import {Dialog as $4wOFe$Dialog, composeRenderProps as $4wOFe$composeRenderProps, OverlayTriggerStateContext as $4wOFe$OverlayTriggerStateContext} from "react-aria-components";
import {forwardRef as $4wOFe$forwardRef} from "react";
import {useDOMRef as $4wOFe$useDOMRef} from "@react-spectrum/utils";
/*
* 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 $6e8e8fdd66697ef1$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 $6e8e8fdd66697ef1$export$82e1fa7406db6ec = /*#__PURE__*/ (0, $4wOFe$forwardRef)(function CustomDialog(props, ref) {
let { size: size, isDismissible: isDismissible, isKeyboardDismissDisabled: isKeyboardDismissDisabled, padding: padding = 'default' } = props;
let domRef = (0, $4wOFe$useDOMRef)(ref);
return /*#__PURE__*/ (0, $4wOFe$jsx)((0, $c46d159bd615e407$export$2b77a92f1a5ad772), {
size: size,
isDismissable: isDismissible,
isKeyboardDismissDisabled: isKeyboardDismissDisabled,
children: /*#__PURE__*/ (0, $4wOFe$jsx)((0, $4wOFe$Dialog), {
...props,
ref: domRef,
style: props.UNSAFE_style,
className: (props.UNSAFE_className || '') + $6e8e8fdd66697ef1$var$dialogStyle({
padding: padding
}, props.styles),
children: (0, $4wOFe$composeRenderProps)(props.children, (children)=>// Reset OverlayTriggerStateContext so the buttons inside the dialog don't retain their hover state.
/*#__PURE__*/ (0, $4wOFe$jsx)((0, $4wOFe$OverlayTriggerStateContext).Provider, {
value: null,
children: children
}))
})
});
});
export {$6e8e8fdd66697ef1$export$82e1fa7406db6ec as CustomDialog};
//# sourceMappingURL=CustomDialog.mjs.map