UNPKG

@ozen-ui/kit

Version:

React component library

37 lines (36 loc) 2.15 kB
import { __assign, __rest } from "tslib"; import React, { forwardRef } from 'react'; import { cn } from '../../../../utils/classname'; import { isPlainObject } from '../../../../utils/object'; import { BottomSheetBaseFooter } from '../../../BottomSheetBase'; import { Divider } from '../../../Divider'; import { useDialogContext } from '../../DialogContext'; import { DIALOG_FOOTER_DEFAULT_ALIGN, DIALOG_FOOTER_DEFAULT_EXPAND_ON_DRAG, DIALOG_FOOTER_DEFAULT_MARGIN_TOP, DIALOG_FOOTER_DEFAULT_WITH_DIVIDER, } from './constants'; export var cnDialogFooter = cn('DialogNextFooter'); export var DialogFooter = forwardRef(function (_a, ref) { var children = _a.children, _b = _a.align, alignProp = _b === void 0 ? DIALOG_FOOTER_DEFAULT_ALIGN : _b, className = _a.className, _c = _a.expandOnDrag, expandOnDrag = _c === void 0 ? DIALOG_FOOTER_DEFAULT_EXPAND_ON_DRAG : _c, _d = _a.marginTop, marginTop = _d === void 0 ? DIALOG_FOOTER_DEFAULT_MARGIN_TOP : _d, _e = _a.withDivider, withDivider = _e === void 0 ? DIALOG_FOOTER_DEFAULT_WITH_DIVIDER : _e, other = __rest(_a, ["children", "align", "className", "expandOnDrag", "marginTop", "withDivider"]); var _f = useDialogContext(), size = _f.size, deviceType = _f.deviceType, isBottomSheet = _f.isBottomSheet; var Component = isBottomSheet ? BottomSheetBaseFooter : 'div'; var bottomSheetProps = isBottomSheet ? { expandOnDrag: expandOnDrag, } : undefined; var align = (function () { if (isPlainObject(alignProp)) { return alignProp[deviceType]; } return alignProp; })(); return (React.createElement(Component, __assign({}, other, bottomSheetProps, { ref: ref, className: cnDialogFooter('Container', [className]) }), withDivider && React.createElement(Divider, { className: cnDialogFooter('Divider') }), React.createElement("div", { className: cnDialogFooter({ size: size, align: align, deviceType: deviceType, marginTop: marginTop, }) }, children))); }); DialogFooter.displayName = 'DialogFooter';