@snowball-tech/fractal
Version:
Fractal's (Snowball's design system) React component library based on RadixUI and TailwindCSS
2 lines • 2.07 kB
JavaScript
"use client";import{PREFIX as e}from"../../constants.js";import{cj as t,cn as n}from"../../styles/helpers.js";import r from"../Button/Button.js";import i from"../ScrollArea/ScrollArea.js";import a from"../Dialog/Dialog.js";import{GROUP_NAME as o}from"./Confirm.constants.js";import{forwardRef as s,useImperativeHandle as c,useRef as l}from"react";import u from"lodash/fp/isFunction.js";import d from"lodash/fp/isString.js";import f from"lodash/fp/omit.js";import{Fragment as p,jsx as m,jsxs as h}from"react/jsx-runtime";const g=s(({actions:s,cancel:g,children:_,confirm:v,fixedActions:y=!0,fullHeight:b=!1,onCancel:x,onConfirm:S,scrollable:C=!0,...w},T)=>{let E=l(null),D=l(null),O=l(null);c(T,()=>({get container(){return E?.current?.container??null},get content(){return E?.current?.content??null},get trigger(){return E?.current?.trigger??null},get cancel(){return D?.current??null},get confirm(){return O?.current??null}}));let k=e=>{u(x)&&x(e,!0),u(w.onDismiss)&&w.onDismiss(e)},A=m(`div`,{className:t(`${e}-${o}__actions`,`flex h-fit flex-col gap-1 pb-quarter md:flex-row md:justify-end to-md:items-center`,y?w.condensed?`pr-one-and-half`:`pr-[calc(theme(spacing.3)-theme(spacing.half))]`:``),children:s||h(p,{children:[g&&m(r,{ref:D,className:`to-md:w-full`,variant:`secondary`,onClick:e=>x?.(e,!1),...d(g)?{label:g}:g}),m(r,{ref:O,className:`to-md:w-full`,onClick:S,...d(v)?{label:v}:v})]})}),j=h(`div`,{className:t(`${e}-${o}__content`,`flex w-full flex-col gap-5`,b?`flex-1`:``,y?`min-h-0`:``),children:[_,!y&&A]});return h(a,{ref:E,className:n(`${e}-${o}`,w.className),fullHeight:b,...f([`className`,`dismissable`,`modal`,`onDismiss`,`scrollable`],w),dismissable:!0,modal:!0,scrollable:!1,onDismiss:k,children:[C?m(i,{className:b?`flex-1`:``,contentClassName:n(`visible flex flex-col w-full`,b?`h-full`:``,w.condensed?`gap-3 pr-one-and-half`:`gap-5 pr-[calc(theme(spacing.3)-theme(spacing.half))]`,w.contentClassName),scrollbarOnHover:w.scrollbarOnHover,children:j}):j,y&&A]})});g.displayName=`Confirm`;export{g as default};
//# sourceMappingURL=Confirm.js.map