next-recomponents 1.5.91 → 1.5.93

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 CHANGED
@@ -32293,7 +32293,7 @@ function useResources({
32293
32293
  const [info, setInfo] = (0, import_react28.useState)({});
32294
32294
  const result = (0, import_react28.useMemo)(() => {
32295
32295
  return Object.keys(endpoints).reduce((acc, key) => __async(null, null, function* () {
32296
- var _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
32296
+ var _c, _d, _e, _f, _g, _h, _i;
32297
32297
  const endpoint = endpoints[key];
32298
32298
  const showFunc = (_a) => __async(null, null, function* () {
32299
32299
  var _b = _a, {
@@ -32542,16 +32542,26 @@ function useResources({
32542
32542
  data: ((_h = info[key]) == null ? void 0 : _h.data) || [],
32543
32543
  selectedItem: ((_i = info[key]) == null ? void 0 : _i.selectedItem) || {}
32544
32544
  });
32545
- if (!acc[key].loaded) {
32546
- if ((_j = acc[key]) == null ? void 0 : _j.id) {
32547
- yield acc[key].find(acc[key].id, (_k = acc[key]) == null ? void 0 : _k.defaultParams);
32548
- } else if ((_l = acc[key]) == null ? void 0 : _l.defaultParams) {
32549
- yield acc[key].show(acc[key].defaultParams);
32550
- }
32551
- }
32552
32545
  return acc;
32553
32546
  }), {});
32554
32547
  }, [info, token, endpoints]);
32548
+ function loadAll() {
32549
+ return __async(this, null, function* () {
32550
+ var _a, _b;
32551
+ for (let item in result) {
32552
+ if (((_a = result[item]) == null ? void 0 : _a.id) && !result[item].loaded) {
32553
+ yield result[item].find(result[item].id, __spreadValues({}, result[item].defaultParams));
32554
+ return;
32555
+ } else if (((_b = result[item]) == null ? void 0 : _b.defaultParams) && !result[item].loaded) {
32556
+ yield result[item].show(__spreadValues({}, result[item].defaultParams));
32557
+ return;
32558
+ }
32559
+ }
32560
+ });
32561
+ }
32562
+ (0, import_react28.useEffect)(() => {
32563
+ loadAll();
32564
+ }, []);
32555
32565
  return result;
32556
32566
  }
32557
32567
 
package/dist/index.mjs CHANGED
@@ -32183,7 +32183,7 @@ function TextArea(_a) {
32183
32183
  }
32184
32184
 
32185
32185
  // src/use-resources/index.ts
32186
- import { useMemo as useMemo9, useState as useState8 } from "react";
32186
+ import { useEffect as useEffect8, useMemo as useMemo9, useState as useState8 } from "react";
32187
32187
 
32188
32188
  // src/use-resources/get.token.tsx
32189
32189
  import { useMemo as useMemo8 } from "react";
@@ -32283,7 +32283,7 @@ function useResources({
32283
32283
  const [info, setInfo] = useState8({});
32284
32284
  const result = useMemo9(() => {
32285
32285
  return Object.keys(endpoints).reduce((acc, key) => __async(null, null, function* () {
32286
- var _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
32286
+ var _c, _d, _e, _f, _g, _h, _i;
32287
32287
  const endpoint = endpoints[key];
32288
32288
  const showFunc = (_a) => __async(null, null, function* () {
32289
32289
  var _b = _a, {
@@ -32532,16 +32532,26 @@ function useResources({
32532
32532
  data: ((_h = info[key]) == null ? void 0 : _h.data) || [],
32533
32533
  selectedItem: ((_i = info[key]) == null ? void 0 : _i.selectedItem) || {}
32534
32534
  });
32535
- if (!acc[key].loaded) {
32536
- if ((_j = acc[key]) == null ? void 0 : _j.id) {
32537
- yield acc[key].find(acc[key].id, (_k = acc[key]) == null ? void 0 : _k.defaultParams);
32538
- } else if ((_l = acc[key]) == null ? void 0 : _l.defaultParams) {
32539
- yield acc[key].show(acc[key].defaultParams);
32540
- }
32541
- }
32542
32535
  return acc;
32543
32536
  }), {});
32544
32537
  }, [info, token, endpoints]);
32538
+ function loadAll() {
32539
+ return __async(this, null, function* () {
32540
+ var _a, _b;
32541
+ for (let item in result) {
32542
+ if (((_a = result[item]) == null ? void 0 : _a.id) && !result[item].loaded) {
32543
+ yield result[item].find(result[item].id, __spreadValues({}, result[item].defaultParams));
32544
+ return;
32545
+ } else if (((_b = result[item]) == null ? void 0 : _b.defaultParams) && !result[item].loaded) {
32546
+ yield result[item].show(__spreadValues({}, result[item].defaultParams));
32547
+ return;
32548
+ }
32549
+ }
32550
+ });
32551
+ }
32552
+ useEffect8(() => {
32553
+ loadAll();
32554
+ }, []);
32545
32555
  return result;
32546
32556
  }
32547
32557
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "1.5.91",
3
+ "version": "1.5.93",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -542,32 +542,26 @@ export default function useResources<T extends Record<string, ItemsRecord>>({
542
542
  data: info[key]?.data || [],
543
543
  selectedItem: info[key]?.selectedItem || {},
544
544
  };
545
- if (!acc[key].loaded) {
546
- if (acc[key]?.id) {
547
- await acc[key].find(acc[key].id, acc[key]?.defaultParams);
548
- } else if (acc[key]?.defaultParams) {
549
- await acc[key].show(acc[key].defaultParams);
550
- }
551
- }
545
+
552
546
  return acc;
553
547
  }, {} as EnhancedEndpoints<T>);
554
548
  }, [info, token, endpoints]);
555
549
 
556
- // async function loadAll() {
557
- // for (let item in result) {
558
- // if (result[item]?.id && !result[item].loaded) {
559
- // await result[item].find(result[item].id, {
560
- // ...result[item].defaultParams,
561
- // });
562
- // return;
563
- // } else if (result[item]?.defaultParams && !result[item].loaded) {
564
- // await result[item].show({ ...result[item].defaultParams });
565
- // return;
566
- // }
567
- // }
568
- // }
569
- // useEffect(() => {
570
- // loadAll();
571
- // }, []);
550
+ async function loadAll() {
551
+ for (let item in result) {
552
+ if (result[item]?.id && !result[item].loaded) {
553
+ await result[item].find(result[item].id, {
554
+ ...result[item].defaultParams,
555
+ });
556
+ return;
557
+ } else if (result[item]?.defaultParams && !result[item].loaded) {
558
+ await result[item].show({ ...result[item].defaultParams });
559
+ return;
560
+ }
561
+ }
562
+ }
563
+ useEffect(() => {
564
+ loadAll();
565
+ }, []);
572
566
  return result;
573
567
  }