"use strict";
/* eslint-disable unicorn/explicit-length-check */
/**
 * @desc 表格排序事件hooks
 * @author 邓欢
 */
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = require("react");
function useSortChanged(onSortChanged) {
    return react_1.useCallback((event) => {
        const sortModel = event.api.getSortModel();
        if (sortModel.length) {
            onSortChanged &&
                onSortChanged({
                    fieldName: sortModel[0].colId || '',
                    direction: (sortModel[0].sort && sortModel[0].sort.toUpperCase()) || '',
                });
        }
        else {
            onSortChanged && onSortChanged();
        }
    }, [onSortChanged]);
}
exports.default = useSortChanged;
