aq-fe-framework 0.1.425 → 0.1.426

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.
@@ -625,7 +625,7 @@ function MySelect(_a) {
625
625
  }
626
626
 
627
627
  // src/core/input/MySelectFromAPI.tsx
628
- import { useEffect as useEffect3, useMemo as useMemo2 } from "react";
628
+ import { useEffect as useEffect3, useMemo as useMemo2, useRef } from "react";
629
629
  import { jsx as jsx12 } from "react/jsx-runtime";
630
630
  function MySelectFromAPI(_a) {
631
631
  var _b = _a, {
@@ -660,9 +660,10 @@ function MySelectFromAPI(_a) {
660
660
  };
661
661
  })) != null ? _a2 : [];
662
662
  }, [query.data]);
663
- const handleChange = (value2, options2) => {
663
+ const hasAutoSelected = useRef(false);
664
+ const handleChange = (value2, option) => {
664
665
  var _a2;
665
- onChange == null ? void 0 : onChange(value2, options2);
666
+ onChange == null ? void 0 : onChange(value2, option);
666
667
  if (setObjectData) {
667
668
  const selected = (_a2 = query.data) == null ? void 0 : _a2.find((item) => {
668
669
  var _a3;
@@ -673,30 +674,22 @@ function MySelectFromAPI(_a) {
673
674
  };
674
675
  useEffect3(() => {
675
676
  var _a2, _b2, _c;
676
- if (autoSelectFirstItem && query.data && query.data.length > 0) {
677
+ if (autoSelectFirstItem && !hasAutoSelected.current && query.data && query.data.length > 0 && (value === void 0 || value === null || value === "")) {
677
678
  const firstItem = query.data[0];
678
- const value2 = (_b2 = (_a2 = firstItem.id) == null ? void 0 : _a2.toString()) != null ? _b2 : "";
679
+ const val = (_b2 = (_a2 = firstItem.id) == null ? void 0 : _a2.toString()) != null ? _b2 : "";
679
680
  const label = labelWithCode ? `${firstItem.code} - ${firstItem.name}` : (_c = firstItem.name) != null ? _c : "";
680
- onChange == null ? void 0 : onChange(value2, { value: value2, label });
681
+ onChange == null ? void 0 : onChange(val, { value: val, label });
681
682
  setObjectData == null ? void 0 : setObjectData(firstItem);
683
+ hasAutoSelected.current = true;
682
684
  }
683
- }, [query.data, autoSelectFirstItem]);
684
- useEffect3(() => {
685
- if (value && setObjectData && query.data) {
686
- const selected = query.data.find((item) => {
687
- var _a2;
688
- return ((_a2 = item.id) == null ? void 0 : _a2.toString()) === value;
689
- });
690
- setObjectData(selected);
691
- }
692
- }, [value, query.data]);
685
+ }, [autoSelectFirstItem, query.data, labelWithCode, onChange, setObjectData, value]);
693
686
  return /* @__PURE__ */ jsx12(
694
687
  MySelect,
695
688
  __spreadValues({
696
689
  isLoading: query.isLoading,
697
690
  isError: query.isError,
698
691
  data: options,
699
- onChange: (value2, options2) => handleChange == null ? void 0 : handleChange(value2, options2),
692
+ onChange: (value2, option) => handleChange(value2, option),
700
693
  value
701
694
  }, rest)
702
695
  );
@@ -13,7 +13,7 @@ import {
13
13
  MyStatsCard,
14
14
  MyTextInput,
15
15
  MyWeeklySessionSchedulerPicker
16
- } from "../chunk-MAFELZRY.mjs";
16
+ } from "../chunk-KYVHHB4Q.mjs";
17
17
  import "../chunk-GEYCGM75.mjs";
18
18
  import "../chunk-GFEMKKFH.mjs";
19
19
  import "../chunk-OMJJAHOC.mjs";
@@ -42,7 +42,7 @@ import {
42
42
  MyButton as MyButton2,
43
43
  MyDataTableSelectOne,
44
44
  MyTextInput as MyTextInput2
45
- } from "../chunk-MAFELZRY.mjs";
45
+ } from "../chunk-KYVHHB4Q.mjs";
46
46
  import {
47
47
  MyDataTable,
48
48
  MyFlexColumn,
package/package.json CHANGED
@@ -42,7 +42,7 @@
42
42
  "types": "./dist/columns/index.d.mts"
43
43
  }
44
44
  },
45
- "version": "0.1.425",
45
+ "version": "0.1.426",
46
46
  "private": false,
47
47
  "files": [
48
48
  "dist"