UNPKG

@jengaui/alert-dialog

Version:

Jenga UI Alert Dialog component in React

16 lines (11 loc) 1.69 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var react = require('react'); var button = require('@jengaui/button'); var buttonGroup = require('@jengaui/button-group'); var dialog = require('@jengaui/dialog'); var content = require('@jengaui/content'); var utils = require('@react-aria/utils'); var jsxRuntime = require('react/jsx-runtime'); var _={label:"Ok",type:"primary"},x={label:"Cancel"};function N(c,f){let{onClose:o}=dialog.useDialogContext(),{danger:d,actions:P,title:u,styles:T,noActions:m,content:i,...D}=c,{confirm:e,secondary:r,cancel:t}=P??{};return e=e!==!1?{..._,...typeof e=="object"?e:null}:void 0,t=t?{...x,...typeof t=="object"?t:null}:void 0,jsxRuntime.jsxs(dialog.Dialog,{ref:f,role:"alertdialog",isDismissable:!1,...D,children:[u?jsxRuntime.jsx(content.Header,{children:jsxRuntime.jsx(content.Title,{children:u})}):null,i?jsxRuntime.jsx(content.Content,{children:typeof i=="string"?jsxRuntime.jsx(content.Paragraph,{children:i}):i}):null,m?null:jsxRuntime.jsx(content.Footer,{children:jsxRuntime.jsxs(buttonGroup.ButtonGroup,{align:"end",children:[jsxRuntime.jsx(button.Button,{autoFocus:!0,theme:d?"danger":void 0,...e,onPress:l=>{var n;return utils.chain((n=e==null?void 0:e.onPress)==null?void 0:n.call(e,l),o==null?void 0:o("confirm"))}}),r&&jsxRuntime.jsx(button.Button,{...r,onPress:l=>{var n;return utils.chain((n=r==null?void 0:r.onPress)==null?void 0:n.call(r,l),o==null?void 0:o("secondary"))}}),t&&jsxRuntime.jsx(button.Button,{...t,onPress:l=>{var n;return utils.chain((n=t==null?void 0:t.onPress)==null?void 0:n.call(t,l),o==null?void 0:o("cancel"))}})]})})]})}var w=react.forwardRef(N); exports.AlertDialog = w;