@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.js
CHANGED
|
@@ -27770,13 +27770,25 @@ function useLazyDropdown(config) {
|
|
|
27770
27770
|
(0, import_react19.useEffect)(() => {
|
|
27771
27771
|
configRef.current = config;
|
|
27772
27772
|
}, [config]);
|
|
27773
|
+
function getValueByPath2(obj, path) {
|
|
27774
|
+
if (!obj || !path) return void 0;
|
|
27775
|
+
const parts = path.split(/\.|__/);
|
|
27776
|
+
return parts.reduce((acc, key) => acc?.[key], obj);
|
|
27777
|
+
}
|
|
27773
27778
|
const transformToOptions = (0, import_react19.useCallback)((data) => {
|
|
27774
27779
|
if (!data || !Array.isArray(data)) return [];
|
|
27775
27780
|
const cfg = configRef.current;
|
|
27776
|
-
return data.map((item) =>
|
|
27777
|
-
value
|
|
27778
|
-
|
|
27779
|
-
|
|
27781
|
+
return data.map((item) => {
|
|
27782
|
+
const value = getValueByPath2(item, cfg.dataKey) ?? item.id ?? "";
|
|
27783
|
+
let label = "";
|
|
27784
|
+
if (cfg.dataLabel) {
|
|
27785
|
+
label = getValueByPath2(item, cfg.dataLabel) ?? item.name ?? item.label ?? "";
|
|
27786
|
+
}
|
|
27787
|
+
return {
|
|
27788
|
+
value,
|
|
27789
|
+
label
|
|
27790
|
+
};
|
|
27791
|
+
});
|
|
27780
27792
|
}, []);
|
|
27781
27793
|
const fetchApiData = (0, import_react19.useCallback)(async (pageNum, term) => {
|
|
27782
27794
|
if (!configRef.current.apiUrl) return [];
|