import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React, { useMemo } from "react";
import { ActionSheetContent } from "../../sheet/actionSheet/actionSheetContent";
import { Sheet, SheetContent, SheetTrigger } from "../../sheet";
export const ActionSheet = (props)=>{
    // create actionSheet items
    const items = useMemo(()=>{
        const items = [];
        if (Array.isArray(props.actionSheets)) {
            for (const action of props.actionSheets){
                if (typeof action === "string") {
                    if (action === "Cancel") {
                        items.push({
                            label: "Cancel",
                            value: "cancel",
                            onClick: ()=>{
                                props.onClose?.();
                            }
                        });
                    } else if (action === "Confirm") {
                        items.push({
                            label: "Confirm",
                            value: "confirm"
                        });
                    } else if (action.startsWith("---")) {
                        items.push({
                            label: "---",
                            value: "---",
                            type: "division"
                        });
                    }
                } else {
                    items.push(action);
                }
            }
        }
        return items;
    }, [
        props.actionSheets
    ]);
    return /*#__PURE__*/ _jsxs(Sheet, {
        open: props.open,
        onOpenChange: props.onOpenChange,
        children: [
            typeof props.children !== "undefined" && /*#__PURE__*/ _jsx(SheetTrigger, {
                asChild: true,
                children: props.children
            }),
            /*#__PURE__*/ _jsx(SheetContent, {
                closeable: false,
                className: "orderly-action-sheet-content orderly-p-0",
                onOpenAutoFocus: (event)=>event.preventDefault(),
                children: /*#__PURE__*/ _jsx(ActionSheetContent, {
                    actionSheets: items,
                    onClose: props.onClose,
                    onValueChange: props.onValueChange,
                    value: props.value
                })
            })
        ]
    });
};

//# sourceMappingURL=actionSheet.js.map