import { jsx } from "react/jsx-runtime";
import "react";
import { connect, mapProps, mapReadPretty, useField } from "@tachybase/schema";
import { LoadingOutlined } from "@ant-design/icons";
import { Cascader } from "antd";
import { useRequest } from "../../../api-client/index.mjs";
import { ReadPretty } from "./ReadPretty.mjs";
const useDefDataSource = (options)=>{
    const field = useField();
    return useRequest(()=>Promise.resolve({
            data: field.dataSource || []
        }), options);
};
const useDefLoadData = (props)=>null == props ? void 0 : props.loadData;
const CustomCascader_CustomCascader = connect((props)=>{
    useField();
    const { value, onChange, labelInValue, useDataSource = useDefDataSource, useLoadData = useDefLoadData, changeOnSelect, maxLevel, defaultValue, ...others } = props;
    return /*#__PURE__*/ jsx(Cascader, {
        ...others,
        onChange: onChange,
        style: {
            width: '100%'
        },
        defaultValue: defaultValue,
        changeOnSelect: changeOnSelect
    });
}, mapProps({
    dataSource: 'options'
}, (props, field)=>({
        ...props,
        suffixIcon: (null == field ? void 0 : field['loading']) || (null == field ? void 0 : field['validating']) ? /*#__PURE__*/ jsx(LoadingOutlined, {}) : props.suffixIcon
    })), mapReadPretty(ReadPretty));
const CustomCascader = CustomCascader_CustomCascader;
export { CustomCascader_CustomCascader as CustomCascader, CustomCascader as default };
