aq-fe-framework 0.1.515 → 0.1.517

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.
@@ -3,6 +3,50 @@ import {
3
3
  __spreadValues
4
4
  } from "./chunk-FWCSY2DS.mjs";
5
5
 
6
+ // src/hooks/useMutationForm.ts
7
+ import { useForm } from "@mantine/form";
8
+ import { useDisclosure } from "@mantine/hooks";
9
+ import { useEffect } from "react";
10
+ function useCreateUpdate({
11
+ initValues,
12
+ createFn,
13
+ updateFn,
14
+ mapInitToForm,
15
+ mapFormToMutateValue,
16
+ validate
17
+ }) {
18
+ const disclosure = useDisclosure();
19
+ const form = useForm({
20
+ mode: "uncontrolled",
21
+ validate
22
+ });
23
+ const mutation = useMyReactMutation({
24
+ axiosFn: (values) => initValues ? updateFn(values) : createFn(values),
25
+ mutationType: initValues ? "update" : "create",
26
+ options: {
27
+ onSuccess: () => {
28
+ disclosure[1].close();
29
+ form.reset();
30
+ }
31
+ }
32
+ });
33
+ useEffect(() => {
34
+ if (initValues) {
35
+ form.initialize(mapInitToForm(initValues));
36
+ }
37
+ }, [initValues]);
38
+ const handleSubmit = (formValues) => {
39
+ const entity = mapFormToMutateValue(formValues, initValues);
40
+ mutation.mutate(entity);
41
+ };
42
+ return {
43
+ form,
44
+ disclosure,
45
+ mutation,
46
+ handleSubmit
47
+ };
48
+ }
49
+
6
50
  // src/hooks/useMyDevice.ts
7
51
  import { useMediaQuery } from "@mantine/hooks";
8
52
  function useMyDevice() {
@@ -119,13 +163,13 @@ baseAxios.interceptors.request.use(
119
163
  var baseAxios_default = baseAxios;
120
164
 
121
165
  // src/hooks/custom-hooks/useLoadAxiosConfig.ts
122
- import { useEffect, useState } from "react";
166
+ import { useEffect as useEffect2, useState } from "react";
123
167
  var useLoadAxiosConfig = ({
124
168
  axiosInstance = baseAxios_default,
125
169
  url
126
170
  }) => {
127
171
  const [flag, setFlag] = useState(false);
128
- useEffect(() => {
172
+ useEffect2(() => {
129
173
  const loadConfig = async () => {
130
174
  try {
131
175
  const res = await fetch("/config.json");
@@ -267,6 +311,7 @@ function useQ_SkillCenter_GetAll() {
267
311
  }
268
312
 
269
313
  export {
314
+ useCreateUpdate,
270
315
  useMyDevice,
271
316
  useMyRouter,
272
317
  createBaseApi,
@@ -1,6 +1,3 @@
1
- import {
2
- createGenericStore
3
- } from "./chunk-U62R2QKJ.mjs";
4
1
  import {
5
2
  utils_pdf_download
6
3
  } from "./chunk-5U2JSHSJ.mjs";
@@ -11,10 +8,13 @@ import {
11
8
  baseAxios_default,
12
9
  useMyReactMutation,
13
10
  useQ_AQ_GetAQModule
14
- } from "./chunk-OIIBQARW.mjs";
11
+ } from "./chunk-3XSLM5GI.mjs";
15
12
  import {
16
13
  utils_notification_show
17
14
  } from "./chunk-7ZCOFATU.mjs";
15
+ import {
16
+ createGenericStore
17
+ } from "./chunk-U62R2QKJ.mjs";
18
18
  import {
19
19
  __objRest,
20
20
  __spreadProps,
@@ -2,7 +2,7 @@ import {
2
2
  MyDataTable,
3
3
  MyFlexColumn,
4
4
  MyFlexRow
5
- } from "./chunk-AKZQQ7BT.mjs";
5
+ } from "./chunk-CHSXCM2D.mjs";
6
6
  import {
7
7
  const_object_colors
8
8
  } from "./chunk-OMJJAHOC.mjs";
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  useMyReactMutation,
14
14
  useMyReactQuery
15
- } from "./chunk-OIIBQARW.mjs";
15
+ } from "./chunk-3XSLM5GI.mjs";
16
16
  import {
17
17
  utils_notification_show
18
18
  } from "./chunk-7ZCOFATU.mjs";
@@ -78,7 +78,8 @@ var getActionConfig = (colorScheme) => ({
78
78
  children: /* @__PURE__ */ jsx(IconX, {})
79
79
  },
80
80
  select: {},
81
- check: {}
81
+ check: {},
82
+ find: {}
82
83
  });
83
84
  function MyActionIcon(_a) {
84
85
  var _b = _a, { children, actionType } = _b, rest = __objRest(_b, ["children", "actionType"]);
@@ -106,6 +107,7 @@ import {
106
107
  IconEdit as IconEdit2,
107
108
  IconPlus as IconPlus2,
108
109
  IconPrinter as IconPrinter2,
110
+ IconSearch,
109
111
  IconTrash as IconTrash2,
110
112
  IconUpload,
111
113
  IconX as IconX2
@@ -166,6 +168,11 @@ var getActionConfig2 = (colorScheme) => ({
166
168
  },
167
169
  check: {
168
170
  children: "Ch\u1ECDn"
171
+ },
172
+ find: {
173
+ color: "green",
174
+ leftSection: /* @__PURE__ */ jsx2(IconSearch, {}),
175
+ children: "T\xECm"
169
176
  }
170
177
  });
171
178
  function MyButton(_a) {
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React__default, { ReactNode, ComponentProps } from 'react';
3
- import { t as type_action, a as type_mantineSize } from '../types-DI2fdq_c.mjs';
3
+ import { t as type_action, a as type_mantineSize } from '../types-DbltiEAP.mjs';
4
4
  import { ActionIconProps, ButtonProps, useModalsStack, CheckboxProps, SelectProps, NumberFormatterProps, FieldsetProps, FileInputProps, NumberInputProps, TextareaProps, MantineSize, InputWrapperProps, TextInputProps, ContainerProps, FlexProps, GroupProps, TypographyStylesProviderProps, TabsProps, SkeletonProps } from '@mantine/core';
5
- import { M as MyApiResponse } from '../createBaseApi-75GHCO22.mjs';
6
5
  import { AxiosResponse } from 'axios';
6
+ import { M as MyApiResponse } from '../createBaseApi-75GHCO22.mjs';
7
7
  import { useDisclosure, useListState } from '@mantine/hooks';
8
8
  import { UseFormReturnType, useForm } from '@mantine/form';
9
9
  import { I as I_BasicAppShell_LinkItem } from '../BasicAppShell-BOu5-Gvr.mjs';
@@ -67,12 +67,12 @@ import {
67
67
  useS_BasicAppShell,
68
68
  useS_ButtonImport,
69
69
  utils_layout_getItemsWithoutLinks
70
- } from "../chunk-AKZQQ7BT.mjs";
71
- import "../chunk-U62R2QKJ.mjs";
70
+ } from "../chunk-CHSXCM2D.mjs";
72
71
  import "../chunk-5U2JSHSJ.mjs";
73
72
  import "../chunk-OMJJAHOC.mjs";
74
- import "../chunk-OIIBQARW.mjs";
73
+ import "../chunk-3XSLM5GI.mjs";
75
74
  import "../chunk-7ZCOFATU.mjs";
75
+ import "../chunk-U62R2QKJ.mjs";
76
76
  import "../chunk-FWCSY2DS.mjs";
77
77
  export {
78
78
  AQButtonCreateByImportFile,
@@ -1,10 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { t as type_action } from '../types-DI2fdq_c.mjs';
2
+ import { t as type_action } from '../types-DbltiEAP.mjs';
3
3
  import { ActionIconProps, ButtonProps, ModalProps, ScrollAreaAutosizeProps, TextProps, PaperProps, GroupProps, ThemeIconProps, InputWrapperProps, SelectProps, TextInputProps, FlexProps } from '@mantine/core';
4
4
  import { ReactNode, ButtonHTMLAttributes } from 'react';
5
- import { M as MyApiResponse } from '../createBaseApi-75GHCO22.mjs';
6
- import { AxiosResponse } from 'axios';
7
5
  import { UseFormReturnType } from '@mantine/form';
6
+ import { AxiosResponse } from 'axios';
7
+ import { M as MyApiResponse } from '../createBaseApi-75GHCO22.mjs';
8
8
  import { useDisclosure } from '@mantine/hooks';
9
9
  import { UseReactToPrintOptions } from 'react-to-print';
10
10
  import { UseQueryResult, QueryKey, UseQueryOptions } from '@tanstack/react-query';
@@ -18,15 +18,15 @@ import {
18
18
  MyStatsCard,
19
19
  MyTextInput,
20
20
  MyWeeklySessionSchedulerPicker
21
- } from "../chunk-GCEO6HDO.mjs";
22
- import "../chunk-AKZQQ7BT.mjs";
23
- import "../chunk-U62R2QKJ.mjs";
21
+ } from "../chunk-NVM7HSI6.mjs";
22
+ import "../chunk-CHSXCM2D.mjs";
24
23
  import "../chunk-5U2JSHSJ.mjs";
25
24
  import "../chunk-GFEMKKFH.mjs";
26
25
  import "../chunk-OMJJAHOC.mjs";
27
26
  import "../chunk-K6S7R6LU.mjs";
28
- import "../chunk-OIIBQARW.mjs";
27
+ import "../chunk-3XSLM5GI.mjs";
29
28
  import "../chunk-7ZCOFATU.mjs";
29
+ import "../chunk-U62R2QKJ.mjs";
30
30
  import "../chunk-FWCSY2DS.mjs";
31
31
  export {
32
32
  MyActionIcon,
@@ -1,13 +1,34 @@
1
- import * as next_dist_shared_lib_app_router_context_shared_runtime from 'next/dist/shared/lib/app-router-context.shared-runtime';
1
+ import * as _tanstack_react_query from '@tanstack/react-query';
2
+ import { UseMutationOptions, QueryKey, UseQueryOptions } from '@tanstack/react-query';
3
+ import * as _mantine_form from '@mantine/form';
4
+ import { FormValidateInput } from '@mantine/form';
5
+ import { AxiosResponse, AxiosInstance } from 'axios';
2
6
  import { M as MyApiResponse } from '../createBaseApi-75GHCO22.mjs';
3
7
  export { I as IPagingParams, c as createBaseApi } from '../createBaseApi-75GHCO22.mjs';
8
+ import * as next_dist_shared_lib_app_router_context_shared_runtime from 'next/dist/shared/lib/app-router-context.shared-runtime';
4
9
  import * as React from 'react';
5
- import { AxiosInstance, AxiosResponse } from 'axios';
6
- import * as _tanstack_react_query from '@tanstack/react-query';
7
- import { UseMutationOptions, QueryKey, UseQueryOptions } from '@tanstack/react-query';
8
10
  import { I as IAQModule } from '../IAQModule-4U3n2emx.mjs';
9
11
  import '../IBaseEntity-ChMy9RzQ.mjs';
10
12
 
13
+ interface UseCreateUpdateProps<TForm extends Record<string, any>, TEntity> {
14
+ initValues?: TEntity;
15
+ createFn: (initData: TEntity) => Promise<AxiosResponse<MyApiResponse<TEntity>>>;
16
+ updateFn: (initData: TEntity) => Promise<AxiosResponse<MyApiResponse<TEntity>>>;
17
+ mapInitToForm: (initData: TEntity) => TForm;
18
+ mapFormToMutateValue: (formData: TForm, initData?: TEntity) => TEntity;
19
+ validate?: FormValidateInput<TForm>;
20
+ }
21
+ declare function useCreateUpdate<TForm extends Record<string, any>, TEntity>({ initValues, createFn, updateFn, mapInitToForm, mapFormToMutateValue, validate, }: UseCreateUpdateProps<TForm, TEntity>): {
22
+ form: _mantine_form.UseFormReturnType<TForm, (values: TForm) => TForm>;
23
+ disclosure: readonly [boolean, {
24
+ readonly open: () => void;
25
+ readonly close: () => void;
26
+ readonly toggle: () => void;
27
+ }];
28
+ mutation: _tanstack_react_query.UseMutationResult<TEntity, Error, TEntity, unknown>;
29
+ handleSubmit: (formValues: TForm) => void;
30
+ };
31
+
11
32
  declare function useMyDevice(): {
12
33
  isMobile: boolean | undefined;
13
34
  isTablet: boolean | undefined;
@@ -64,4 +85,4 @@ declare function useMyReactQuery<IRes, IBody>({ queryKey, axiosFn, options, mock
64
85
 
65
86
  declare function useQ_AQ_GetAQModule(): _tanstack_react_query.UseQueryResult<IAQModule, Error>;
66
87
 
67
- export { MyApiResponse, type MyReactQueryProps, createBaseUrl, useLoadAxiosConfig, useMyDevice, useMyReactMutation, useMyReactQuery, useMyRouter, useQ_AQ_GetAQModule };
88
+ export { MyApiResponse, type MyReactQueryProps, createBaseUrl, useCreateUpdate, useLoadAxiosConfig, useMyDevice, useMyReactMutation, useMyReactQuery, useMyRouter, useQ_AQ_GetAQModule };
@@ -1,18 +1,20 @@
1
1
  import {
2
2
  createBaseApi,
3
3
  createBaseUrl,
4
+ useCreateUpdate,
4
5
  useLoadAxiosConfig,
5
6
  useMyDevice,
6
7
  useMyReactMutation,
7
8
  useMyReactQuery,
8
9
  useMyRouter,
9
10
  useQ_AQ_GetAQModule
10
- } from "../chunk-OIIBQARW.mjs";
11
+ } from "../chunk-3XSLM5GI.mjs";
11
12
  import "../chunk-7ZCOFATU.mjs";
12
13
  import "../chunk-FWCSY2DS.mjs";
13
14
  export {
14
15
  createBaseApi,
15
16
  createBaseUrl,
17
+ useCreateUpdate,
16
18
  useLoadAxiosConfig,
17
19
  useMyDevice,
18
20
  useMyReactMutation,
@@ -12,14 +12,11 @@ import {
12
12
  import {
13
13
  U0DateToDDMMYYYString
14
14
  } from "../chunk-EWDS5IOF.mjs";
15
- import {
16
- enum_emailConfigModule
17
- } from "../chunk-VH4ZAD6M.mjs";
18
15
  import {
19
16
  MyButton as MyButton2,
20
17
  MyDataTableSelectOne,
21
18
  MyTextInput as MyTextInput2
22
- } from "../chunk-GCEO6HDO.mjs";
19
+ } from "../chunk-NVM7HSI6.mjs";
23
20
  import {
24
21
  F_authenticate_Logout,
25
22
  MyActionIconDelete,
@@ -45,10 +42,7 @@ import {
45
42
  groupToTwoLevels,
46
43
  useS_authenticate,
47
44
  utils_layout_getItemsWithoutLinks
48
- } from "../chunk-AKZQQ7BT.mjs";
49
- import {
50
- createGenericStore
51
- } from "../chunk-U62R2QKJ.mjs";
45
+ } from "../chunk-CHSXCM2D.mjs";
52
46
  import "../chunk-5U2JSHSJ.mjs";
53
47
  import {
54
48
  const_object_documentTypes
@@ -56,6 +50,9 @@ import {
56
50
  import {
57
51
  const_object_colors
58
52
  } from "../chunk-OMJJAHOC.mjs";
53
+ import {
54
+ enum_emailConfigModule
55
+ } from "../chunk-VH4ZAD6M.mjs";
59
56
  import "../chunk-K6S7R6LU.mjs";
60
57
  import {
61
58
  baseAxios_default,
@@ -66,10 +63,13 @@ import {
66
63
  useMyRouter,
67
64
  useQ_AQ_GetAQModule,
68
65
  useQ_SkillCenter_GetAll
69
- } from "../chunk-OIIBQARW.mjs";
66
+ } from "../chunk-3XSLM5GI.mjs";
70
67
  import {
71
68
  utils_notification_show
72
69
  } from "../chunk-7ZCOFATU.mjs";
70
+ import {
71
+ createGenericStore
72
+ } from "../chunk-U62R2QKJ.mjs";
73
73
  import {
74
74
  __objRest,
75
75
  __spreadProps,
@@ -86,7 +86,7 @@ var service_account = __spreadProps(__spreadValues({}, createBaseApi(CONTROLLER,
86
86
  }
87
87
  });
88
88
 
89
- // src/module/Account/adapter/Account_Table.tsx
89
+ // src/module/Account/adapter/Adapter_AccountTable.tsx
90
90
  import { useEffect } from "react";
91
91
 
92
92
  // src/module/Account/usecase/UseCase_AccountTable.tsx
@@ -109,8 +109,7 @@ function UseCase_AccountTable(_a) {
109
109
  {
110
110
  header: "Email",
111
111
  accessorKey: "email"
112
- },
113
- ...baseColumns
112
+ }
114
113
  ], []);
115
114
  const columns = useMemo(() => {
116
115
  return utils_mantineDataTable_filterColumns(allColumns, visibleFields);
@@ -124,7 +123,7 @@ function UseCase_AccountTable(_a) {
124
123
  );
125
124
  }
126
125
 
127
- // src/module/Account/adapter/Account_Table.tsx
126
+ // src/module/Account/adapter/Adapter_AccountTable.tsx
128
127
  import { jsx as jsx2 } from "react/jsx-runtime";
129
128
  function Account_Table(_a) {
130
129
  var rest = __objRest(_a, []);
@@ -1,6 +1,6 @@
1
1
  import { MantineSize } from '@mantine/core';
2
2
 
3
3
  type type_mantineSize = number | MantineSize | (string & {}) | undefined;
4
- type type_action = "default" | "create" | "update" | "delete" | "save" | "createMultiple" | "check" | "import" | "print" | "cancel" | "export" | "select";
4
+ type type_action = "default" | "create" | "update" | "delete" | "save" | "createMultiple" | "check" | "import" | "print" | "cancel" | "export" | "select" | "find";
5
5
 
6
6
  export type { type_mantineSize as a, type_action as t };
package/package.json CHANGED
@@ -42,7 +42,7 @@
42
42
  "types": "./dist/columns/index.d.mts"
43
43
  }
44
44
  },
45
- "version": "0.1.515",
45
+ "version": "0.1.517",
46
46
  "private": false,
47
47
  "files": [
48
48
  "dist"