@algorithm-shift/design-system 1.2.959 → 1.2.960
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -27675,13 +27675,25 @@ function useLazyDropdown(config) {
|
|
|
27675
27675
|
useEffect13(() => {
|
|
27676
27676
|
configRef.current = config;
|
|
27677
27677
|
}, [config]);
|
|
27678
|
+
function getValueByPath2(obj, path) {
|
|
27679
|
+
if (!obj || !path) return void 0;
|
|
27680
|
+
const parts = path.split(/\.|__/);
|
|
27681
|
+
return parts.reduce((acc, key) => acc?.[key], obj);
|
|
27682
|
+
}
|
|
27678
27683
|
const transformToOptions = useCallback2((data) => {
|
|
27679
27684
|
if (!data || !Array.isArray(data)) return [];
|
|
27680
27685
|
const cfg = configRef.current;
|
|
27681
|
-
return data.map((item) =>
|
|
27682
|
-
value
|
|
27683
|
-
|
|
27684
|
-
|
|
27686
|
+
return data.map((item) => {
|
|
27687
|
+
const value = getValueByPath2(item, cfg.dataKey) ?? item.id ?? "";
|
|
27688
|
+
let label = "";
|
|
27689
|
+
if (cfg.dataLabel) {
|
|
27690
|
+
label = getValueByPath2(item, cfg.dataLabel) ?? item.name ?? item.label ?? "";
|
|
27691
|
+
}
|
|
27692
|
+
return {
|
|
27693
|
+
value,
|
|
27694
|
+
label
|
|
27695
|
+
};
|
|
27696
|
+
});
|
|
27685
27697
|
}, []);
|
|
27686
27698
|
const fetchApiData = useCallback2(async (pageNum, term) => {
|
|
27687
27699
|
if (!configRef.current.apiUrl) return [];
|