@headless-adminapp/app 0.0.17-alpha.52 → 0.0.17-alpha.53
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/app/AppProvider.js +13 -17
- package/app/AuthWrapper.js +9 -13
- package/app/LayoutProvider.js +16 -20
- package/app/context.js +2 -5
- package/app/hooks/index.js +1 -17
- package/app/hooks/useAppContext.js +4 -7
- package/app/index.js +4 -11
- package/auth/AuthProvider.js +17 -21
- package/auth/context.d.ts +1 -1
- package/auth/context.js +2 -5
- package/auth/hooks/index.js +2 -18
- package/auth/hooks/useAuthSession.js +4 -7
- package/auth/hooks/useIsSkipAuthCheck.js +4 -7
- package/auth/hooks/useLogout.js +7 -10
- package/auth/index.js +4 -23
- package/auth/types.js +1 -2
- package/board/BoardColumnDataResolver.js +20 -23
- package/board/BoardColumnProvider.js +10 -14
- package/board/context.js +3 -6
- package/board/hooks/index.js +6 -15
- package/board/hooks/useBoardColumnConfig.js +4 -7
- package/board/hooks/useBoardColumnData.js +4 -7
- package/board/hooks/useBoardColumnDataState.js +4 -7
- package/board/hooks/useBoardConfig.js +4 -7
- package/board/hooks/useBoardSchema.js +3 -6
- package/board/hooks/useSearchText.js +7 -10
- package/board/types.js +1 -2
- package/board/utils.js +1 -4
- package/builders/CommandBuilder/CommandBuilder.js +10 -13
- package/builders/CommandBuilder/DefaultCommandBuilder.js +22 -25
- package/builders/CommandBuilder/FormCommandBuilder.js +9 -12
- package/builders/CommandBuilder/SubgridCommandBuilder.js +11 -14
- package/builders/CommandBuilder/ViewCommandBuilder.js +14 -17
- package/builders/CommandBuilder/index.js +1 -5
- package/builders/CommandBuilder/utils.js +2 -6
- package/builders/SchemaExperienceBuilder.js +1 -5
- package/builders/index.js +2 -7
- package/builders/utils.js +12 -41
- package/command/hooks/index.js +2 -18
- package/command/hooks/useBaseCommandHandlerContext.js +25 -29
- package/command/hooks/useCommands.js +6 -9
- package/command/index.js +2 -18
- package/command/types.js +1 -2
- package/command/utils/index.js +4 -7
- package/components/ScrollView/index.js +4 -11
- package/components/ScrollbarWithMoreDataRequest/index.js +9 -13
- package/dataform/DataFormProvider/DataResolver.d.ts +2 -2
- package/dataform/DataFormProvider/DataResolver.js +31 -32
- package/dataform/DataFormProvider/InitialValueResolver.js +19 -22
- package/dataform/DataFormProvider/ReadonlyInfoResolver.js +9 -12
- package/dataform/DataFormProvider/index.js +22 -25
- package/dataform/context.js +2 -5
- package/dataform/hooks/index.js +13 -29
- package/dataform/hooks/useFormInstance.js +3 -6
- package/dataform/hooks/useFormIsDirty.js +3 -6
- package/dataform/hooks/useFormIsReadonly.js +4 -7
- package/dataform/hooks/useFormNotifications.js +7 -10
- package/dataform/hooks/useFormRecord.js +4 -7
- package/dataform/hooks/useFormSave.js +30 -33
- package/dataform/hooks/useFormSchema.js +4 -7
- package/dataform/hooks/useLoadFormGridPage.js +10 -13
- package/dataform/hooks/useMainFormCommands.js +27 -32
- package/dataform/hooks/useProcessFlowSteps.js +18 -21
- package/dataform/hooks/useRecordId.js +4 -7
- package/dataform/hooks/useRecordTitle.d.ts +3 -1
- package/dataform/hooks/useRecordTitle.js +11 -14
- package/dataform/hooks/useSelectedForm.js +4 -7
- package/dataform/index.js +4 -23
- package/dataform/utils/defaultParameters.js +2 -6
- package/dataform/utils/index.d.ts +1 -1
- package/dataform/utils/index.js +17 -45
- package/dataform/utils/saveRecord.js +5 -9
- package/datagrid/DataGridProvider/DataResolver.js +42 -39
- package/datagrid/DataGridProvider/index.js +22 -25
- package/datagrid/DataGridProvider/transformViewColumns.js +4 -7
- package/datagrid/DataGridProvider/utils.js +5 -13
- package/datagrid/column-filter/constants.js +2 -5
- package/datagrid/column-filter/index.js +2 -7
- package/datagrid/column-filter/types.js +1 -2
- package/datagrid/column-filter/utils.js +3 -7
- package/datagrid/context.d.ts +1 -1
- package/datagrid/context.js +2 -5
- package/datagrid/hooks/index.js +20 -36
- package/datagrid/hooks/useChangeView.js +6 -9
- package/datagrid/hooks/useGridColumnFilter.js +7 -10
- package/datagrid/hooks/useGridColumns.js +4 -7
- package/datagrid/hooks/useGridCommands.js +4 -7
- package/datagrid/hooks/useGridData.js +4 -7
- package/datagrid/hooks/useGridDataState.js +4 -7
- package/datagrid/hooks/useGridExtraFilter.js +4 -7
- package/datagrid/hooks/useGridOptions.js +1 -4
- package/datagrid/hooks/useGridPagination.js +1 -4
- package/datagrid/hooks/useGridRefresh.js +7 -10
- package/datagrid/hooks/useGridSchema.js +4 -7
- package/datagrid/hooks/useGridSelection.js +7 -10
- package/datagrid/hooks/useGridSorting.js +7 -10
- package/datagrid/hooks/useGridViewLookupData.js +4 -7
- package/datagrid/hooks/useLoadMainGridPage.js +9 -12
- package/datagrid/hooks/useMainGridCommands.js +50 -57
- package/datagrid/hooks/useMaxRecords.js +4 -7
- package/datagrid/hooks/useOpenRecord.js +15 -18
- package/datagrid/hooks/useSearchText.js +7 -10
- package/datagrid/hooks/useSelectedView.js +4 -7
- package/datagrid/hooks/useSubGridCommands.js +19 -24
- package/datagrid/index.js +5 -27
- package/defaults.js +2 -5
- package/dialog/DialogProvider.js +6 -10
- package/dialog/context.d.ts +1 -1
- package/dialog/context.js +2 -5
- package/dialog/hooks/index.js +8 -24
- package/dialog/hooks/useCloseDialog.js +6 -9
- package/dialog/hooks/useDialogItem.d.ts +1 -1
- package/dialog/hooks/useDialogItem.js +4 -7
- package/dialog/hooks/useDialogItems.d.ts +1 -1
- package/dialog/hooks/useDialogItems.js +4 -7
- package/dialog/hooks/useOpenAlertDialog.js +5 -8
- package/dialog/hooks/useOpenConfirmDialog.js +5 -8
- package/dialog/hooks/useOpenDialog.js +10 -13
- package/dialog/hooks/useOpenErrorDialog.js +5 -8
- package/dialog/hooks/useOpenPromptDialog.js +5 -8
- package/dialog/index.js +3 -22
- package/form/FormValidationStringContext.js +5 -9
- package/form/index.js +1 -7
- package/hooks/index.js +6 -24
- package/hooks/useDebouncedValue.js +8 -11
- package/hooks/useElementLayout.js +4 -7
- package/hooks/useIsMobile.js +6 -12
- package/hooks/useItemsWithKey.js +5 -8
- package/hooks/useStorageState.js +4 -7
- package/hooks/useSystemColorScheme.js +4 -7
- package/insights/InsightsProvider.js +10 -13
- package/insights/context.d.ts +1 -1
- package/insights/context.js +2 -5
- package/insights/hooks/index.js +4 -7
- package/insights/index.js +2 -20
- package/locale/LocaleProvider.js +8 -12
- package/locale/context.js +2 -5
- package/locale/index.js +4 -23
- package/locale/useCurrencySymbol.js +7 -10
- package/locale/useLocale.js +4 -7
- package/locale/utils.js +1 -4
- package/metadata/MetadataProvider.js +17 -21
- package/metadata/context.d.ts +1 -1
- package/metadata/context.js +2 -5
- package/metadata/hooks/index.js +8 -24
- package/metadata/hooks/useAppStore.js +4 -7
- package/metadata/hooks/useExperienceStore.js +4 -7
- package/metadata/hooks/useExperienceView.js +6 -9
- package/metadata/hooks/useExperienceViewCommands.js +7 -10
- package/metadata/hooks/useExperienceViewLookup.js +5 -8
- package/metadata/hooks/useExperienceViewSubgridCommands.js +7 -10
- package/metadata/hooks/useMetadata.js +8 -11
- package/metadata/hooks/useSchema.js +3 -6
- package/metadata/index.js +3 -22
- package/mutable/context.js +17 -25
- package/mutable/index.js +3 -27
- package/mutable/state.js +6 -10
- package/mutable/type.js +1 -2
- package/mutable/utils.js +7 -11
- package/navigation/hooks/index.js +1 -17
- package/navigation/hooks/useOpenForm.js +11 -14
- package/navigation/index.js +1 -17
- package/package.json +3 -2
- package/progress-indicator/ProgressIndicatorProvider.js +12 -16
- package/progress-indicator/context.js +2 -5
- package/progress-indicator/hooks/index.js +1 -17
- package/progress-indicator/hooks/useProgressIndicator.d.ts +1 -1
- package/progress-indicator/hooks/useProgressIndicator.js +4 -7
- package/progress-indicator/index.js +3 -22
- package/providers/PageEntityFormProvider/index.js +4 -7
- package/providers/PageEntityViewProvider/index.js +4 -7
- package/recordset/RecordSetProvider.js +12 -16
- package/recordset/context.d.ts +1 -1
- package/recordset/context.js +2 -5
- package/recordset/hooks/index.js +3 -19
- package/recordset/hooks/useRecordSetResult.js +15 -18
- package/recordset/hooks/useRecordSetSetter.js +6 -9
- package/recordset/hooks/useRecordSetVisibility.js +7 -10
- package/recordset/index.js +3 -22
- package/route/RouteProvider.js +14 -18
- package/route/context.js +6 -9
- package/route/hooks/index.js +6 -22
- package/route/hooks/useBasePath.js +4 -7
- package/route/hooks/useIsRouteActive.js +4 -7
- package/route/hooks/usePathname.js +4 -7
- package/route/hooks/useRouteResolver.js +4 -7
- package/route/hooks/useRouter.js +4 -7
- package/route/hooks/useSearchParams.js +4 -7
- package/route/index.js +2 -20
- package/route/types.js +1 -2
- package/store/ClientAppStore.js +1 -5
- package/store/ComponentStore.js +1 -5
- package/store/EventManager.js +1 -5
- package/store/SchemaExperienceStore.js +2 -7
- package/store/index.js +4 -20
- package/toast-notification/ToastNotificationProvider.js +6 -10
- package/toast-notification/context.d.ts +1 -1
- package/toast-notification/context.js +2 -5
- package/toast-notification/hooks/index.js +3 -19
- package/toast-notification/hooks/useCloseToastNotification.js +6 -9
- package/toast-notification/hooks/useOpenToastNotification.js +10 -13
- package/toast-notification/hooks/useToastNotificationItems.d.ts +1 -1
- package/toast-notification/hooks/useToastNotificationItems.js +4 -7
- package/toast-notification/index.js +3 -22
- package/transport/InMemoryDataService/index.js +1 -5
- package/transport/RestDataService/index.js +5 -10
- package/transport/context.js +4 -7
- package/transport/hooks/index.js +2 -18
- package/transport/hooks/useDataService.js +4 -7
- package/transport/hooks/useFileService.js +4 -7
- package/transport/hooks/useRetriveRecords.d.ts +1 -1
- package/transport/hooks/useRetriveRecords.js +12 -17
- package/transport/index.js +2 -20
- package/utils/calculateColumnWidths.js +1 -4
- package/utils/color.js +1 -4
- package/utils/getAttributeFormattedValue.js +12 -18
- package/utils/index.js +2 -18
- package/widget/context.js +2 -5
- package/widget/hooks/index.js +4 -7
- package/widget/index.js +1 -5
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,29 +7,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const [formReadOnly, setFormReadOnly] = (0, react_1.useState)(false); // A trick to provide readOnly info to formInstance
|
|
30
|
-
const formInstance = (0, react_hook_form_1.useForm)({
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useEffect, useState } from 'react';
|
|
12
|
+
import { FormProvider, useForm } from 'react-hook-form';
|
|
13
|
+
import { useFormValidationStrings } from '../../form/FormValidationStringContext';
|
|
14
|
+
import { useLocale } from '../../locale/useLocale';
|
|
15
|
+
import { useMetadata } from '../../metadata/hooks/useMetadata';
|
|
16
|
+
import { useCreateContextStore } from '../../mutable';
|
|
17
|
+
import { DataFormContext } from '../context';
|
|
18
|
+
import { formValidator } from '../utils';
|
|
19
|
+
import { DataResolver } from './DataResolver';
|
|
20
|
+
import { InitialValueResolver } from './InitialValueResolver';
|
|
21
|
+
import { ReadonlyInfoResolver } from './ReadonlyInfoResolver';
|
|
22
|
+
export function DataFormProvider(props) {
|
|
23
|
+
const { schemaStore } = useMetadata();
|
|
24
|
+
const { language } = useLocale();
|
|
25
|
+
const formValidationStrings = useFormValidationStrings();
|
|
26
|
+
const [formReadOnly, setFormReadOnly] = useState(false); // A trick to provide readOnly info to formInstance
|
|
27
|
+
const formInstance = useForm({
|
|
31
28
|
mode: 'all',
|
|
32
29
|
defaultValues: {},
|
|
33
|
-
resolver:
|
|
30
|
+
resolver: formValidator({
|
|
34
31
|
form: props.form,
|
|
35
32
|
schemaStore,
|
|
36
33
|
language,
|
|
@@ -40,7 +37,7 @@ function DataFormProvider(props) {
|
|
|
40
37
|
}),
|
|
41
38
|
shouldUnregister: false,
|
|
42
39
|
});
|
|
43
|
-
const contextValue =
|
|
40
|
+
const contextValue = useCreateContextStore({
|
|
44
41
|
schema: props.schema,
|
|
45
42
|
form: props.form,
|
|
46
43
|
commands: props.commands,
|
|
@@ -52,7 +49,7 @@ function DataFormProvider(props) {
|
|
|
52
49
|
// formInstanceRenderCount: 0,
|
|
53
50
|
initialValues: {},
|
|
54
51
|
});
|
|
55
|
-
|
|
52
|
+
useEffect(() => {
|
|
56
53
|
contextValue.setValue({
|
|
57
54
|
form: props.form,
|
|
58
55
|
schema: props.schema,
|
|
@@ -68,5 +65,5 @@ function DataFormProvider(props) {
|
|
|
68
65
|
schemaStore,
|
|
69
66
|
props.commands,
|
|
70
67
|
]);
|
|
71
|
-
return ((
|
|
68
|
+
return (_jsx(DataFormContext.Provider, { value: contextValue, children: _jsxs(FormProvider, Object.assign({}, formInstance, { children: [_jsx(DataResolver, {}), _jsx(InitialValueResolver, {}), _jsx(ReadonlyInfoResolver, { setFormReadOnly: setFormReadOnly }), props.children] })) }));
|
|
72
69
|
}
|
package/dataform/context.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.DataFormContext = void 0;
|
|
4
|
-
const mutable_1 = require("../mutable");
|
|
5
|
-
exports.DataFormContext = (0, mutable_1.createContext)();
|
|
1
|
+
import { createContext } from '../mutable';
|
|
2
|
+
export const DataFormContext = createContext();
|
package/dataform/hooks/index.js
CHANGED
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./useFormInstance"), exports);
|
|
18
|
-
__exportStar(require("./useFormIsDirty"), exports);
|
|
19
|
-
__exportStar(require("./useFormIsReadonly"), exports);
|
|
20
|
-
__exportStar(require("./useFormNotifications"), exports);
|
|
21
|
-
__exportStar(require("./useFormRecord"), exports);
|
|
22
|
-
__exportStar(require("./useFormSave"), exports);
|
|
23
|
-
__exportStar(require("./useFormSchema"), exports);
|
|
24
|
-
__exportStar(require("./useMainFormCommands"), exports);
|
|
25
|
-
__exportStar(require("./useRecordId"), exports);
|
|
26
|
-
__exportStar(require("./useRecordTitle"), exports);
|
|
27
|
-
__exportStar(require("./useSelectedForm"), exports);
|
|
28
|
-
__exportStar(require("./useLoadFormGridPage"), exports);
|
|
29
|
-
__exportStar(require("./useProcessFlowSteps"), exports);
|
|
1
|
+
export * from './useFormInstance';
|
|
2
|
+
export * from './useFormIsDirty';
|
|
3
|
+
export * from './useFormIsReadonly';
|
|
4
|
+
export * from './useFormNotifications';
|
|
5
|
+
export * from './useFormRecord';
|
|
6
|
+
export * from './useFormSave';
|
|
7
|
+
export * from './useFormSchema';
|
|
8
|
+
export * from './useMainFormCommands';
|
|
9
|
+
export * from './useRecordId';
|
|
10
|
+
export * from './useRecordTitle';
|
|
11
|
+
export * from './useSelectedForm';
|
|
12
|
+
export * from './useLoadFormGridPage';
|
|
13
|
+
export * from './useProcessFlowSteps';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
5
|
-
function useFormInstance() {
|
|
6
|
-
const formInstance = (0, react_hook_form_1.useFormContext)();
|
|
1
|
+
import { useFormContext } from 'react-hook-form';
|
|
2
|
+
export function useFormInstance() {
|
|
3
|
+
const formInstance = useFormContext();
|
|
7
4
|
return formInstance;
|
|
8
5
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const useFormInstance_1 = require("./useFormInstance");
|
|
5
|
-
function useFormIsDirty() {
|
|
6
|
-
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
1
|
+
import { useFormInstance } from './useFormInstance';
|
|
2
|
+
export function useFormIsDirty() {
|
|
3
|
+
const formInstance = useFormInstance();
|
|
7
4
|
return Object.keys(formInstance.formState.dirtyFields).length > 0;
|
|
8
5
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const context_1 = require("../context");
|
|
6
|
-
function useFormIsReadonly() {
|
|
7
|
-
const readonly = (0, mutable_1.useContextSelector)(context_1.DataFormContext, (state) => state.isReadonly);
|
|
1
|
+
import { useContextSelector } from '../../mutable';
|
|
2
|
+
import { DataFormContext } from '../context';
|
|
3
|
+
export function useFormIsReadonly() {
|
|
4
|
+
const readonly = useContextSelector(DataFormContext, (state) => state.isReadonly);
|
|
8
5
|
return readonly;
|
|
9
6
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
function useFormNotifications() {
|
|
8
|
-
const readonly = (0, useFormIsReadonly_1.useFormIsReadonly)();
|
|
9
|
-
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useFormInstance } from './useFormInstance';
|
|
3
|
+
import { useFormIsReadonly } from './useFormIsReadonly';
|
|
4
|
+
export function useFormNotifications() {
|
|
5
|
+
const readonly = useFormIsReadonly();
|
|
6
|
+
const formInstance = useFormInstance();
|
|
10
7
|
const formInstanceAvailable = !!formInstance;
|
|
11
|
-
return
|
|
8
|
+
return useMemo(() => {
|
|
12
9
|
const notifications = [];
|
|
13
10
|
if (readonly) {
|
|
14
11
|
notifications.push({
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const context_1 = require("../context");
|
|
6
|
-
function useFormRecord() {
|
|
7
|
-
const record = (0, mutable_1.useContextSelector)(context_1.DataFormContext, (state) => state.record);
|
|
1
|
+
import { useContextSelector } from '../../mutable';
|
|
2
|
+
import { DataFormContext } from '../context';
|
|
3
|
+
export function useFormRecord() {
|
|
4
|
+
const record = useContextSelector(DataFormContext, (state) => state.record);
|
|
8
5
|
return record;
|
|
9
6
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Steps
|
|
3
2
|
// 1. Show the loading indicator
|
|
4
3
|
// 2. Extract modified fields from the form
|
|
@@ -15,37 +14,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
15
14
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
16
15
|
});
|
|
17
16
|
};
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.useFormSave = useFormSave;
|
|
20
17
|
// Wrapper - Loader, response message
|
|
21
18
|
// Core - Extract modified fields, prepare operations, perform operations
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function useFormSave() {
|
|
37
|
-
const form =
|
|
38
|
-
const formInstance =
|
|
39
|
-
const record =
|
|
40
|
-
const { schemaStore } =
|
|
41
|
-
const schema =
|
|
42
|
-
const initialValues =
|
|
43
|
-
const refresh =
|
|
44
|
-
const dataService =
|
|
45
|
-
const { showProgressIndicator, hideProgressIndicator } =
|
|
46
|
-
const openToastNotification =
|
|
47
|
-
const client =
|
|
48
|
-
const router =
|
|
19
|
+
import { useRouter } from '@headless-adminapp/app/route';
|
|
20
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
21
|
+
import { useCallback, useRef } from 'react';
|
|
22
|
+
import { useFormContext } from 'react-hook-form';
|
|
23
|
+
import { useMetadata } from '../../metadata/hooks/useMetadata';
|
|
24
|
+
import { useContextSelector } from '../../mutable/context';
|
|
25
|
+
import { useProgressIndicator } from '../../progress-indicator/hooks/useProgressIndicator';
|
|
26
|
+
import { useOpenToastNotification } from '../../toast-notification/hooks/useOpenToastNotification';
|
|
27
|
+
import { useDataService } from '../../transport';
|
|
28
|
+
import { DataFormContext } from '../context';
|
|
29
|
+
import { saveRecord } from '../utils';
|
|
30
|
+
import { useFormRecord } from './useFormRecord';
|
|
31
|
+
import { useDataFormSchema } from './useFormSchema';
|
|
32
|
+
import { useSelectedForm } from './useSelectedForm';
|
|
33
|
+
export function useFormSave() {
|
|
34
|
+
const form = useSelectedForm();
|
|
35
|
+
const formInstance = useFormContext();
|
|
36
|
+
const record = useFormRecord();
|
|
37
|
+
const { schemaStore } = useMetadata();
|
|
38
|
+
const schema = useDataFormSchema();
|
|
39
|
+
const initialValues = useContextSelector(DataFormContext, (state) => state.initialValues);
|
|
40
|
+
const refresh = useContextSelector(DataFormContext, (state) => state.refresh);
|
|
41
|
+
const dataService = useDataService();
|
|
42
|
+
const { showProgressIndicator, hideProgressIndicator } = useProgressIndicator();
|
|
43
|
+
const openToastNotification = useOpenToastNotification();
|
|
44
|
+
const client = useQueryClient();
|
|
45
|
+
const router = useRouter();
|
|
49
46
|
function showMessageAfterSave({ isCreatedMode }) {
|
|
50
47
|
// Show notification
|
|
51
48
|
if (!isCreatedMode) {
|
|
@@ -73,7 +70,7 @@ function useFormSave() {
|
|
|
73
70
|
showProgressIndicator(undefined, 500);
|
|
74
71
|
}
|
|
75
72
|
try {
|
|
76
|
-
const result = yield
|
|
73
|
+
const result = yield saveRecord({
|
|
77
74
|
values,
|
|
78
75
|
form: form,
|
|
79
76
|
record: record,
|
|
@@ -135,8 +132,8 @@ function useFormSave() {
|
|
|
135
132
|
}
|
|
136
133
|
}))();
|
|
137
134
|
});
|
|
138
|
-
const _saveRef =
|
|
135
|
+
const _saveRef = useRef(_save);
|
|
139
136
|
_saveRef.current = _save;
|
|
140
|
-
const save =
|
|
137
|
+
const save = useCallback((mode) => _saveRef.current(mode), [_saveRef]);
|
|
141
138
|
return save;
|
|
142
139
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const context_2 = require("../context");
|
|
6
|
-
function useDataFormSchema() {
|
|
7
|
-
return (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.schema);
|
|
1
|
+
import { useContextSelector } from '../../mutable/context';
|
|
2
|
+
import { DataFormContext } from '../context';
|
|
3
|
+
export function useDataFormSchema() {
|
|
4
|
+
return useContextSelector(DataFormContext, (state) => state.schema);
|
|
8
5
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,23 +7,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const experienceStore = (0, hooks_1.useExperienceStore)();
|
|
19
|
-
const { data: form, isFetching: isFetchingForm } = (0, react_query_1.useQuery)({
|
|
10
|
+
import { useAppContext } from '@headless-adminapp/app/app';
|
|
11
|
+
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
|
12
|
+
import { useExperienceStore, useSchema } from '../../metadata/hooks';
|
|
13
|
+
export function useLoadFormGridPage(logicalName, formId) {
|
|
14
|
+
const schema = useSchema(logicalName);
|
|
15
|
+
const experienceStore = useExperienceStore();
|
|
16
|
+
const { data: form, isFetching: isFetchingForm } = useQuery({
|
|
20
17
|
queryKey: ['experience-schema-form', logicalName, formId],
|
|
21
18
|
queryFn: () => __awaiter(this, void 0, void 0, function* () {
|
|
22
19
|
return experienceStore.getForm(logicalName, formId);
|
|
23
20
|
}),
|
|
24
|
-
placeholderData:
|
|
21
|
+
placeholderData: keepPreviousData,
|
|
25
22
|
});
|
|
26
|
-
const { app: { formCommands }, } =
|
|
27
|
-
const { data: commands } =
|
|
23
|
+
const { app: { formCommands }, } = useAppContext();
|
|
24
|
+
const { data: commands } = useQuery({
|
|
28
25
|
queryKey: ['experience-schema-form-commands', logicalName],
|
|
29
26
|
queryFn: () => __awaiter(this, void 0, void 0, function* () {
|
|
30
27
|
let commands = yield experienceStore.getFormCommands(logicalName);
|
|
@@ -1,32 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const useFormRecord_1 = require("./useFormRecord");
|
|
14
|
-
const useFormSave_1 = require("./useFormSave");
|
|
15
|
-
const useFormSchema_1 = require("./useFormSchema");
|
|
16
|
-
const useRecordId_1 = require("./useRecordId");
|
|
17
|
-
function useFormControlContext() {
|
|
1
|
+
import { useRouter } from '@headless-adminapp/app/route';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { useBaseCommandHandlerContext, useCommands, } from '../../command';
|
|
4
|
+
import { useContextSelector } from '../../mutable/context';
|
|
5
|
+
import { DataFormContext } from '../context';
|
|
6
|
+
import { useFormInstance } from './useFormInstance';
|
|
7
|
+
import { useFormIsReadonly } from './useFormIsReadonly';
|
|
8
|
+
import { useFormRecord } from './useFormRecord';
|
|
9
|
+
import { useFormSave } from './useFormSave';
|
|
10
|
+
import { useDataFormSchema } from './useFormSchema';
|
|
11
|
+
import { useRecordId } from './useRecordId';
|
|
12
|
+
export function useFormControlContext() {
|
|
18
13
|
var _a;
|
|
19
|
-
const schema =
|
|
20
|
-
const form =
|
|
21
|
-
const originalData =
|
|
22
|
-
const recordId =
|
|
23
|
-
const save =
|
|
24
|
-
const refresh =
|
|
25
|
-
const formInstance =
|
|
26
|
-
const readonly = (_a =
|
|
14
|
+
const schema = useDataFormSchema();
|
|
15
|
+
const form = useContextSelector(DataFormContext, (state) => state.form);
|
|
16
|
+
const originalData = useFormRecord();
|
|
17
|
+
const recordId = useRecordId();
|
|
18
|
+
const save = useFormSave();
|
|
19
|
+
const refresh = useContextSelector(DataFormContext, (state) => state.refresh);
|
|
20
|
+
const formInstance = useFormInstance();
|
|
21
|
+
const readonly = (_a = useFormIsReadonly()) !== null && _a !== void 0 ? _a : false;
|
|
27
22
|
const data = formInstance.watch();
|
|
28
|
-
const router =
|
|
29
|
-
const close =
|
|
23
|
+
const router = useRouter();
|
|
24
|
+
const close = useCallback(() => {
|
|
30
25
|
router.back();
|
|
31
26
|
}, [router]);
|
|
32
27
|
return {
|
|
@@ -43,13 +38,13 @@ function useFormControlContext() {
|
|
|
43
38
|
close,
|
|
44
39
|
};
|
|
45
40
|
}
|
|
46
|
-
function useMainFormCommandHandlerContext() {
|
|
41
|
+
export function useMainFormCommandHandlerContext() {
|
|
47
42
|
const primaryControl = useFormControlContext();
|
|
48
|
-
const baseHandlerContext =
|
|
43
|
+
const baseHandlerContext = useBaseCommandHandlerContext();
|
|
49
44
|
return Object.assign(Object.assign({}, baseHandlerContext), { primaryControl });
|
|
50
45
|
}
|
|
51
|
-
function useMainFormCommands() {
|
|
52
|
-
const commands =
|
|
46
|
+
export function useMainFormCommands() {
|
|
47
|
+
const commands = useContextSelector(DataFormContext, (state) => state.commands);
|
|
53
48
|
const handlerContext = useMainFormCommandHandlerContext();
|
|
54
|
-
return
|
|
49
|
+
return useCommands(commands, handlerContext);
|
|
55
50
|
}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const useFormSchema_1 = require("./useFormSchema");
|
|
11
|
-
const useRecordId_1 = require("./useRecordId");
|
|
12
|
-
const useSelectedForm_1 = require("./useSelectedForm");
|
|
1
|
+
import { useBaseCommandHandlerContext } from '@headless-adminapp/app/command';
|
|
2
|
+
import { useContextSelector } from '../../mutable/context';
|
|
3
|
+
import { DataFormContext } from '../context';
|
|
4
|
+
import { useFormInstance } from './useFormInstance';
|
|
5
|
+
import { useFormIsReadonly } from './useFormIsReadonly';
|
|
6
|
+
import { useFormRecord } from './useFormRecord';
|
|
7
|
+
import { useDataFormSchema } from './useFormSchema';
|
|
8
|
+
import { useRecordId } from './useRecordId';
|
|
9
|
+
import { useSelectedForm } from './useSelectedForm';
|
|
13
10
|
function useFormControlContext() {
|
|
14
11
|
var _a;
|
|
15
|
-
const schema =
|
|
16
|
-
const form =
|
|
17
|
-
const originalData =
|
|
18
|
-
const recordId =
|
|
19
|
-
const formInstance =
|
|
20
|
-
const readonly = (_a =
|
|
12
|
+
const schema = useDataFormSchema();
|
|
13
|
+
const form = useContextSelector(DataFormContext, (state) => state.form);
|
|
14
|
+
const originalData = useFormRecord();
|
|
15
|
+
const recordId = useRecordId();
|
|
16
|
+
const formInstance = useFormInstance();
|
|
17
|
+
const readonly = (_a = useFormIsReadonly()) !== null && _a !== void 0 ? _a : false;
|
|
21
18
|
const data = formInstance.watch();
|
|
22
19
|
return {
|
|
23
20
|
data,
|
|
@@ -32,12 +29,12 @@ function useFormControlContext() {
|
|
|
32
29
|
}
|
|
33
30
|
function useProcessFlowInfoContext() {
|
|
34
31
|
const primaryControl = useFormControlContext();
|
|
35
|
-
const baseHandlerContext =
|
|
32
|
+
const baseHandlerContext = useBaseCommandHandlerContext();
|
|
36
33
|
return Object.assign(Object.assign({}, baseHandlerContext), { primaryControl });
|
|
37
34
|
}
|
|
38
|
-
function useProcessFlowSteps() {
|
|
35
|
+
export function useProcessFlowSteps() {
|
|
39
36
|
var _a;
|
|
40
|
-
const formConfig =
|
|
37
|
+
const formConfig = useSelectedForm();
|
|
41
38
|
const context = useProcessFlowInfoContext();
|
|
42
39
|
const steps = (_a = formConfig.experience.processFlow) === null || _a === void 0 ? void 0 : _a.getSteps(context);
|
|
43
40
|
return steps;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const context_2 = require("../context");
|
|
6
|
-
function useRecordId() {
|
|
7
|
-
return (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.recordId);
|
|
1
|
+
import { useContextSelector } from '../../mutable/context';
|
|
2
|
+
import { DataFormContext } from '../context';
|
|
3
|
+
export function useRecordId() {
|
|
4
|
+
return useContextSelector(DataFormContext, (state) => state.recordId);
|
|
8
5
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
9
|
-
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
10
|
-
const recordId = (0, useRecordId_1.useRecordId)();
|
|
1
|
+
import { useFormInstance } from './useFormInstance';
|
|
2
|
+
import { useDataFormSchema } from './useFormSchema';
|
|
3
|
+
import { useRecordId } from './useRecordId';
|
|
4
|
+
export function useRecordTitle() {
|
|
5
|
+
const formInstance = useFormInstance();
|
|
6
|
+
const schema = useDataFormSchema();
|
|
7
|
+
const recordId = useRecordId();
|
|
11
8
|
let primaryAttributeValue = formInstance.watch(schema.primaryAttribute);
|
|
12
9
|
const primaryAttribute = schema.attributes[schema.primaryAttribute];
|
|
13
10
|
if ((primaryAttribute === null || primaryAttribute === void 0 ? void 0 : primaryAttribute.type) === 'lookup') {
|
|
@@ -15,13 +12,13 @@ function useRecordTitle() {
|
|
|
15
12
|
primaryAttributeValue = primaryAttributeValue === null || primaryAttributeValue === void 0 ? void 0 : primaryAttributeValue.name;
|
|
16
13
|
}
|
|
17
14
|
if (primaryAttributeValue && typeof primaryAttributeValue !== 'string') {
|
|
18
|
-
return String(primaryAttributeValue);
|
|
15
|
+
return [String(primaryAttributeValue), false];
|
|
19
16
|
}
|
|
20
17
|
if (primaryAttributeValue) {
|
|
21
|
-
return primaryAttributeValue;
|
|
18
|
+
return [primaryAttributeValue, false];
|
|
22
19
|
}
|
|
23
20
|
if (recordId) {
|
|
24
|
-
return '(No name)';
|
|
21
|
+
return ['(No name)', true];
|
|
25
22
|
}
|
|
26
|
-
return `New ${schema.label.toLowerCase()}
|
|
23
|
+
return [`New ${schema.label.toLowerCase()}`, true];
|
|
27
24
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const context_2 = require("../context");
|
|
6
|
-
function useSelectedForm() {
|
|
7
|
-
return (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.form);
|
|
1
|
+
import { useContextSelector } from '../../mutable/context';
|
|
2
|
+
import { DataFormContext } from '../context';
|
|
3
|
+
export function useSelectedForm() {
|
|
4
|
+
return useContextSelector(DataFormContext, (state) => state.form);
|
|
8
5
|
}
|
package/dataform/index.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.DataFormProvider = exports.DataFormContext = void 0;
|
|
18
|
-
var context_1 = require("./context");
|
|
19
|
-
Object.defineProperty(exports, "DataFormContext", { enumerable: true, get: function () { return context_1.DataFormContext; } });
|
|
20
|
-
__exportStar(require("./hooks"), exports);
|
|
21
|
-
__exportStar(require("./utils"), exports);
|
|
22
|
-
var DataFormProvider_1 = require("./DataFormProvider");
|
|
23
|
-
Object.defineProperty(exports, "DataFormProvider", { enumerable: true, get: function () { return DataFormProvider_1.DataFormProvider; } });
|
|
1
|
+
export { DataFormContext } from './context';
|
|
2
|
+
export * from './hooks';
|
|
3
|
+
export * from './utils';
|
|
4
|
+
export { DataFormProvider } from './DataFormProvider';
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFormDefaultParameters = getFormDefaultParameters;
|
|
4
|
-
exports.setFormDefaultParameters = setFormDefaultParameters;
|
|
5
1
|
let formDefaultParameters = null;
|
|
6
|
-
function getFormDefaultParameters(schema) {
|
|
2
|
+
export function getFormDefaultParameters(schema) {
|
|
7
3
|
const _values = formDefaultParameters === null || formDefaultParameters === void 0 ? void 0 : formDefaultParameters.values;
|
|
8
4
|
const _logicalName = formDefaultParameters === null || formDefaultParameters === void 0 ? void 0 : formDefaultParameters.logicalName;
|
|
9
5
|
const schemaDefaultValues = Object.keys(schema.attributes).reduce((acc, key) => {
|
|
@@ -23,7 +19,7 @@ function getFormDefaultParameters(schema) {
|
|
|
23
19
|
return schemaDefaultValues;
|
|
24
20
|
}
|
|
25
21
|
let defaultParamsTimeout = null;
|
|
26
|
-
function setFormDefaultParameters(logicalName, values) {
|
|
22
|
+
export function setFormDefaultParameters(logicalName, values) {
|
|
27
23
|
formDefaultParameters = {
|
|
28
24
|
logicalName,
|
|
29
25
|
values,
|