import { RegionSelect } from "@/shared/ui/RegionSelect.jsx";
import { createOptionsColumnFilter } from "@/shared/ui/tableFilters.js";

export function RegionFilterControl({
    className = "",
    disabled = false,
    emptyLabel = "全部区域",
    loading = false,
    onChange,
    options = [],
    selectClassName = "",
    value,
    ...props
}) {
    return (
        <div className={["region-filter-control", className].filter(Boolean).join(" ")}>
            <RegionSelect
                {...props}
                className={["region-filter-control__select", selectClassName].filter(Boolean).join(" ")}
                disabled={disabled}
                emptyLabel={emptyLabel}
                loading={loading}
                options={options}
                value={value}
                onChange={onChange}
            />
        </div>
    );
}

export function createRegionColumnFilter({
    activeLabel,
    activeValue,
    emptyLabel = "全部区域",
    loading = false,
    onChange,
    onReset,
    options = [],
    placeholder = "搜索区域",
    value,
}) {
    return createOptionsColumnFilter({
        activeLabel,
        activeValue,
        emptyLabel,
        loading,
        onChange,
        onReset,
        options,
        placeholder,
        value,
    });
}
