aq-fe-framework 0.1.421 → 0.1.423

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 { useMemo as useMemo2 } from "react";
628
+ import { useEffect as useEffect3, useMemo as useMemo2 } from "react";
629
629
  import { jsx as jsx12 } from "react/jsx-runtime";
630
630
  function MySelectFromAPI(_a) {
631
631
  var _b = _a, {
@@ -633,13 +633,15 @@ function MySelectFromAPI(_a) {
633
633
  axiosFn,
634
634
  labelWithCode,
635
635
  onChange,
636
- setObjectData
636
+ setObjectData,
637
+ autoSelectFirstItem
637
638
  } = _b, rest = __objRest(_b, [
638
639
  "queryKey",
639
640
  "axiosFn",
640
641
  "labelWithCode",
641
642
  "onChange",
642
- "setObjectData"
643
+ "setObjectData",
644
+ "autoSelectFirstItem"
643
645
  ]);
644
646
  const query = useMyReactQuery({
645
647
  queryKey,
@@ -667,6 +669,16 @@ function MySelectFromAPI(_a) {
667
669
  setObjectData(selected);
668
670
  }
669
671
  };
672
+ useEffect3(() => {
673
+ var _a2, _b2, _c;
674
+ if (autoSelectFirstItem && query.data && query.data.length > 0) {
675
+ const firstItem = query.data[0];
676
+ const value = (_b2 = (_a2 = firstItem.id) == null ? void 0 : _a2.toString()) != null ? _b2 : "";
677
+ const label = labelWithCode ? `${firstItem.code} - ${firstItem.name}` : (_c = firstItem.name) != null ? _c : "";
678
+ onChange == null ? void 0 : onChange(value, { value, label });
679
+ setObjectData == null ? void 0 : setObjectData(firstItem);
680
+ }
681
+ }, [query.data, autoSelectFirstItem]);
670
682
  return /* @__PURE__ */ jsx12(
671
683
  MySelect,
672
684
  __spreadValues({
@@ -231,6 +231,23 @@ function updateEnableList(oldList, selectedIds, getId, createNew) {
231
231
  return result;
232
232
  }
233
233
 
234
+ // src/utils/utils_list.ts
235
+ function utils_list_isTotalEqual(list, field, total) {
236
+ const totalValue = list.reduce((sum, item) => sum + Number(item[field]), 0);
237
+ return totalValue === total;
238
+ }
239
+ function utils_list_isFieldUnique(list, field) {
240
+ const seen = /* @__PURE__ */ new Set();
241
+ for (const item of list) {
242
+ const value = item[field];
243
+ if (seen.has(value)) {
244
+ return false;
245
+ }
246
+ seen.add(value);
247
+ }
248
+ return true;
249
+ }
250
+
234
251
  // src/utils/utils_reactQuery.ts
235
252
  function utils_reactQuery_updateListItemInQuery({
236
253
  queryClient,
@@ -309,6 +326,8 @@ export {
309
326
  utils_currency_formatWithSuffix,
310
327
  utils_excel_exportExcel,
311
328
  utils_excel_download,
329
+ utils_list_isTotalEqual,
330
+ utils_list_isFieldUnique,
312
331
  utils_reactQuery_updateListItemInQuery,
313
332
  utils_text_getNormalizedTextFromHtml,
314
333
  utils_time_convertTimeStringToSeconds,
@@ -110,8 +110,9 @@ interface MySelectFromAPIProps<IRes extends IBaseEntity, IBody = any> extends Om
110
110
  axiosFn: () => Promise<AxiosResponse<MyApiResponse<IRes[]>, IBody>>;
111
111
  labelWithCode?: boolean;
112
112
  setObjectData?: (item: IRes | undefined) => void;
113
+ autoSelectFirstItem?: boolean;
113
114
  }
114
- declare function MySelectFromAPI<IRes extends IBaseEntity, IBody = any>({ queryKey, axiosFn, labelWithCode, onChange, setObjectData, ...rest }: MySelectFromAPIProps<IRes, IBody>): react_jsx_runtime.JSX.Element;
115
+ declare function MySelectFromAPI<IRes extends IBaseEntity, IBody = any>({ queryKey, axiosFn, labelWithCode, onChange, setObjectData, autoSelectFirstItem, ...rest }: MySelectFromAPIProps<IRes, IBody>): react_jsx_runtime.JSX.Element;
115
116
 
116
117
  interface CoreTextInputProps extends TextInputProps {
117
118
  label?: string;
@@ -13,7 +13,7 @@ import {
13
13
  MyStatsCard,
14
14
  MyTextInput,
15
15
  MyWeeklySessionSchedulerPicker
16
- } from "../chunk-DO3NAJIP.mjs";
16
+ } from "../chunk-AQDTIRC5.mjs";
17
17
  import "../chunk-GFEMKKFH.mjs";
18
18
  import "../chunk-GEYCGM75.mjs";
19
19
  import "../chunk-OMJJAHOC.mjs";
@@ -4,7 +4,7 @@ import {
4
4
  utils_config_getBaseUrl,
5
5
  utils_converter_enumToSelectOptions,
6
6
  utils_file_fileToAQDocumentType
7
- } from "../chunk-P3IR7UL7.mjs";
7
+ } from "../chunk-NRTOFI27.mjs";
8
8
  import {
9
9
  baseColumns
10
10
  } from "../chunk-2SBUKAGS.mjs";
@@ -42,7 +42,7 @@ import {
42
42
  MyButton as MyButton2,
43
43
  MyDataTableSelectOne,
44
44
  MyTextInput as MyTextInput2
45
- } from "../chunk-DO3NAJIP.mjs";
45
+ } from "../chunk-AQDTIRC5.mjs";
46
46
  import {
47
47
  const_object_documentTypes
48
48
  } from "../chunk-GFEMKKFH.mjs";
@@ -35,6 +35,9 @@ declare function utils_date_getHHmm(date: Date): string;
35
35
  */
36
36
  declare function updateEnableList<T>(oldList: T[], selectedIds: number[], getId: (item: T) => number | undefined, createNew: (id: number) => T): T[];
37
37
 
38
+ declare function utils_list_isTotalEqual<T>(list: T[], field: keyof T, total: number): boolean;
39
+ declare function utils_list_isFieldUnique<T>(list: T[], field: keyof T): boolean;
40
+
38
41
  interface I {
39
42
  crudType?: "delete" | "update" | "create" | "error" | "importSucess";
40
43
  message?: string;
@@ -63,4 +66,4 @@ declare function U0MyValidateEmpty(message?: string): (value: unknown) => React.
63
66
  declare function U0MyValidateEmail(value?: string): "Email không đúng định dạng" | null;
64
67
  declare const utils_validator_validateCode: (value?: string) => "Không được để trống" | "Chỉ được nhập chữ, số và dấu '-' (không bắt đầu bằng '-')" | null;
65
68
 
66
- export { U0DateToDDMMYYYString, U0MyValidateEmail, U0MyValidateEmpty, updateEnableList, utils_converter_enumToSelectOptions, utils_converter_getKeyByValue, utils_converter_getLabelByValue, utils_converter_mapEnumToSelectData, utils_currency_formatWithSuffix, utils_date_dateToDDMMYYYString, utils_date_formatToDateTimeStartEnd, utils_date_getHHmm, utils_notification_show, utils_pdf_download, utils_reactQuery_updateListItemInQuery, utils_text_getNormalizedTextFromHtml, utils_time_convertTimeStringToSeconds, utils_time_extractHourMinute, utils_time_getCurrentTimeString, utils_validator_validateCode };
69
+ export { U0DateToDDMMYYYString, U0MyValidateEmail, U0MyValidateEmpty, updateEnableList, utils_converter_enumToSelectOptions, utils_converter_getKeyByValue, utils_converter_getLabelByValue, utils_converter_mapEnumToSelectData, utils_currency_formatWithSuffix, utils_date_dateToDDMMYYYString, utils_date_formatToDateTimeStartEnd, utils_date_getHHmm, utils_list_isFieldUnique, utils_list_isTotalEqual, utils_notification_show, utils_pdf_download, utils_reactQuery_updateListItemInQuery, utils_text_getNormalizedTextFromHtml, utils_time_convertTimeStringToSeconds, utils_time_extractHourMinute, utils_time_getCurrentTimeString, utils_validator_validateCode };
@@ -12,13 +12,15 @@ import {
12
12
  utils_file_AQDocumentTypeToFile,
13
13
  utils_file_docxtemplaterDownload,
14
14
  utils_file_fileToAQDocumentType,
15
+ utils_list_isFieldUnique,
16
+ utils_list_isTotalEqual,
15
17
  utils_reactQuery_updateListItemInQuery,
16
18
  utils_text_getNormalizedTextFromHtml,
17
19
  utils_time_convertTimeStringToSeconds,
18
20
  utils_time_extractHourMinute,
19
21
  utils_time_getCurrentTimeString,
20
22
  utils_validator_validateCode
21
- } from "../chunk-P3IR7UL7.mjs";
23
+ } from "../chunk-NRTOFI27.mjs";
22
24
  import {
23
25
  U0DateToDDMMYYYString,
24
26
  utils_date_dateToDDMMYYYString,
@@ -50,6 +52,8 @@ export {
50
52
  utils_file_AQDocumentTypeToFile,
51
53
  utils_file_docxtemplaterDownload,
52
54
  utils_file_fileToAQDocumentType,
55
+ utils_list_isFieldUnique,
56
+ utils_list_isTotalEqual,
53
57
  utils_notification_show,
54
58
  utils_pdf_download,
55
59
  utils_reactQuery_updateListItemInQuery,
package/package.json CHANGED
@@ -42,7 +42,7 @@
42
42
  "types": "./dist/columns/index.d.mts"
43
43
  }
44
44
  },
45
- "version": "0.1.421",
45
+ "version": "0.1.423",
46
46
  "private": false,
47
47
  "files": [
48
48
  "dist"