This commit is contained in:
2026-05-25 17:08:18 +08:00
parent df501f6151
commit f1259b71b5
9178 changed files with 1626125 additions and 0 deletions
@@ -0,0 +1,20 @@
import * as React from 'react';
import useEntities from "./useEntities";
export default function useOptions(mergedFieldNames, options) {
const mergedOptions = React.useMemo(() => options || [], [options]);
// Only used in multiple mode, this fn will not call in single mode
const getPathKeyEntities = useEntities(mergedOptions, mergedFieldNames);
/** Convert path key back to value format */
const getValueByKeyPath = React.useCallback(pathKeys => {
const keyPathEntities = getPathKeyEntities();
return pathKeys.map(pathKey => {
const {
nodes
} = keyPathEntities[pathKey];
return nodes.map(node => node[mergedFieldNames.value]);
});
}, [getPathKeyEntities, mergedFieldNames]);
return [mergedOptions, getPathKeyEntities, getValueByKeyPath];
}