@headless-adminapp/app 0.0.17-alpha.54 → 0.0.17-alpha.55
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 +24 -32
- package/app/AuthWrapper.js +13 -9
- package/app/LayoutProvider.js +34 -39
- package/app/context.js +5 -2
- package/app/hooks/index.js +17 -1
- package/app/hooks/useAppContext.js +7 -4
- package/app/index.js +11 -4
- package/auth/AuthProvider.js +27 -36
- package/auth/context.d.ts +1 -1
- package/auth/context.js +5 -2
- package/auth/hooks/index.js +18 -2
- package/auth/hooks/useAuthSession.js +7 -4
- package/auth/hooks/useIsSkipAuthCheck.js +7 -4
- package/auth/hooks/useLogout.js +11 -8
- package/auth/index.js +23 -4
- package/auth/types.js +2 -1
- package/board/BoardColumnDataResolver.js +23 -20
- package/board/BoardColumnProvider.js +14 -10
- package/board/context.d.ts +2 -2
- package/board/context.js +6 -3
- package/board/hooks/index.js +15 -6
- package/board/hooks/useBoardColumnConfig.js +7 -4
- package/board/hooks/useBoardColumnData.d.ts +3 -1
- package/board/hooks/useBoardColumnData.js +7 -4
- package/board/hooks/useBoardColumnDataState.js +7 -4
- package/board/hooks/useBoardConfig.js +7 -4
- package/board/hooks/useBoardSchema.js +6 -3
- package/board/hooks/useSearchText.js +10 -7
- package/board/types.js +2 -1
- package/board/utils.js +4 -1
- package/builders/CommandBuilder/CommandBuilder.js +13 -10
- package/builders/CommandBuilder/DefaultCommandBuilder.js +30 -23
- package/builders/CommandBuilder/FormCommandBuilder.js +29 -38
- package/builders/CommandBuilder/SubgridCommandBuilder.js +27 -36
- package/builders/CommandBuilder/ViewCommandBuilder.js +29 -38
- package/builders/CommandBuilder/index.js +5 -1
- package/builders/CommandBuilder/utils.js +7 -3
- package/builders/SchemaExperienceBuilder.js +55 -31
- package/builders/index.js +7 -2
- package/builders/utils.js +59 -44
- package/command/hooks/index.js +18 -2
- package/command/hooks/useBaseCommandHandlerContext.js +29 -25
- package/command/hooks/useCommands.js +9 -6
- package/command/index.js +18 -2
- package/command/types.js +2 -1
- package/command/utils/index.js +41 -13
- package/components/ScrollView/index.js +11 -4
- package/components/ScrollbarWithMoreDataRequest/index.js +14 -11
- package/dataform/DataFormProvider/DataResolver.js +81 -89
- package/dataform/DataFormProvider/InitialValueResolver.js +22 -20
- package/dataform/DataFormProvider/ReadonlyInfoResolver.js +14 -12
- package/dataform/DataFormProvider/index.js +26 -32
- package/dataform/context.js +5 -2
- package/dataform/hooks/index.js +29 -13
- package/dataform/hooks/useFormInstance.js +6 -3
- package/dataform/hooks/useFormIsDirty.js +6 -3
- package/dataform/hooks/useFormIsReadonly.js +7 -4
- package/dataform/hooks/useFormNotifications.js +12 -9
- package/dataform/hooks/useFormRecord.js +7 -4
- package/dataform/hooks/useFormSave.js +40 -46
- package/dataform/hooks/useFormSchema.js +7 -4
- package/dataform/hooks/useLoadFormGridPage.js +19 -25
- package/dataform/hooks/useMainFormCommands.js +37 -30
- package/dataform/hooks/useProcessFlowSteps.js +27 -23
- package/dataform/hooks/useRecordId.js +7 -4
- package/dataform/hooks/useRecordTitle.js +12 -9
- package/dataform/hooks/useSelectedForm.js +7 -4
- package/dataform/index.js +23 -4
- package/dataform/utils/defaultParameters.js +16 -6
- package/dataform/utils/index.js +90 -56
- package/dataform/utils/saveRecord.js +99 -104
- package/datagrid/DataGridProvider/DataResolver.js +36 -34
- package/datagrid/DataGridProvider/index.js +31 -32
- package/datagrid/DataGridProvider/transformViewColumns.js +17 -6
- package/datagrid/DataGridProvider/utils.js +13 -5
- package/datagrid/column-filter/constants.js +5 -2
- package/datagrid/column-filter/index.js +7 -2
- package/datagrid/column-filter/types.js +2 -1
- package/datagrid/column-filter/utils.js +13 -3
- package/datagrid/context.d.ts +1 -1
- package/datagrid/context.js +5 -2
- package/datagrid/hooks/index.js +36 -20
- package/datagrid/hooks/useChangeView.js +10 -7
- package/datagrid/hooks/useGridColumnFilter.js +14 -8
- package/datagrid/hooks/useGridColumns.js +7 -4
- package/datagrid/hooks/useGridCommands.js +7 -4
- package/datagrid/hooks/useGridData.js +7 -4
- package/datagrid/hooks/useGridDataState.js +7 -4
- package/datagrid/hooks/useGridExtraFilter.js +7 -4
- package/datagrid/hooks/useGridOptions.js +4 -1
- package/datagrid/hooks/useGridPagination.js +4 -1
- package/datagrid/hooks/useGridRefresh.js +10 -7
- package/datagrid/hooks/useGridSchema.js +7 -4
- package/datagrid/hooks/useGridSelection.js +10 -7
- package/datagrid/hooks/useGridSorting.js +10 -7
- package/datagrid/hooks/useGridViewLookupData.js +7 -4
- package/datagrid/hooks/useLoadMainGridPage.js +12 -9
- package/datagrid/hooks/useMainGridCommands.js +62 -54
- package/datagrid/hooks/useMaxRecords.js +7 -4
- package/datagrid/hooks/useOpenRecord.js +20 -17
- package/datagrid/hooks/useSearchText.js +10 -7
- package/datagrid/hooks/useSelectedView.js +7 -4
- package/datagrid/hooks/useSubGridCommands.js +34 -23
- package/datagrid/index.js +27 -5
- package/defaults.js +5 -2
- package/dialog/DialogProvider.js +10 -6
- package/dialog/context.d.ts +1 -1
- package/dialog/context.js +5 -2
- package/dialog/hooks/index.js +24 -8
- package/dialog/hooks/useCloseDialog.js +10 -7
- package/dialog/hooks/useDialogItem.d.ts +1 -1
- package/dialog/hooks/useDialogItem.js +7 -4
- package/dialog/hooks/useDialogItems.d.ts +1 -1
- package/dialog/hooks/useDialogItems.js +7 -4
- package/dialog/hooks/useOpenAlertDialog.js +16 -8
- package/dialog/hooks/useOpenConfirmDialog.js +18 -9
- package/dialog/hooks/useOpenDialog.js +18 -11
- package/dialog/hooks/useOpenErrorDialog.js +16 -8
- package/dialog/hooks/useOpenPromptDialog.js +18 -9
- package/dialog/index.js +22 -3
- package/form/FormValidationStringContext.js +9 -5
- package/form/index.js +7 -1
- package/hooks/index.js +24 -6
- package/hooks/useDebouncedValue.js +11 -8
- package/hooks/useElementLayout.js +7 -4
- package/hooks/useIsMobile.js +12 -6
- package/hooks/useItemsWithKey.js +8 -5
- package/hooks/useStorageState.js +7 -5
- package/hooks/useSystemColorScheme.js +7 -4
- package/insights/InsightsProvider.js +13 -10
- package/insights/context.d.ts +1 -1
- package/insights/context.js +5 -2
- package/insights/hooks/index.js +7 -4
- package/insights/index.js +20 -2
- package/locale/LocaleProvider.js +12 -8
- package/locale/context.js +5 -2
- package/locale/index.js +23 -4
- package/locale/useCurrencySymbol.js +10 -8
- package/locale/useLocale.js +7 -4
- package/locale/utils.js +8 -3
- package/metadata/MetadataProvider.js +21 -17
- package/metadata/context.d.ts +1 -1
- package/metadata/context.js +5 -2
- package/metadata/hooks/index.js +24 -8
- package/metadata/hooks/useAppStore.js +7 -4
- package/metadata/hooks/useExperienceStore.js +7 -4
- package/metadata/hooks/useExperienceView.js +11 -17
- package/metadata/hooks/useExperienceViewCommands.js +14 -20
- package/metadata/hooks/useExperienceViewLookup.js +10 -16
- package/metadata/hooks/useExperienceViewSubgridCommands.js +14 -20
- package/metadata/hooks/useMetadata.js +11 -8
- package/metadata/hooks/useSchema.js +6 -3
- package/metadata/index.js +22 -3
- package/mutable/context.js +25 -17
- package/mutable/index.js +27 -3
- package/mutable/state.js +10 -6
- package/mutable/type.js +2 -1
- package/mutable/utils.js +12 -8
- package/navigation/hooks/index.js +17 -1
- package/navigation/hooks/useOpenForm.js +14 -11
- package/navigation/index.js +17 -1
- package/package.json +4 -12
- package/progress-indicator/ProgressIndicatorProvider.js +16 -12
- package/progress-indicator/context.js +5 -2
- package/progress-indicator/hooks/index.js +17 -1
- package/progress-indicator/hooks/useProgressIndicator.d.ts +1 -1
- package/progress-indicator/hooks/useProgressIndicator.js +7 -4
- package/progress-indicator/index.js +22 -3
- package/providers/PageEntityFormProvider/index.js +7 -4
- package/providers/PageEntityViewProvider/index.js +7 -4
- package/recordset/RecordSetProvider.js +16 -12
- package/recordset/context.d.ts +1 -1
- package/recordset/context.js +5 -2
- package/recordset/hooks/index.js +19 -3
- package/recordset/hooks/useRecordSetResult.js +22 -29
- package/recordset/hooks/useRecordSetSetter.js +9 -6
- package/recordset/hooks/useRecordSetVisibility.js +10 -7
- package/recordset/index.js +22 -3
- package/route/RouteProvider.js +18 -14
- package/route/context.js +9 -6
- package/route/hooks/index.js +22 -6
- package/route/hooks/useBasePath.js +7 -4
- package/route/hooks/useIsRouteActive.js +7 -4
- package/route/hooks/usePathname.js +7 -4
- package/route/hooks/useRouteResolver.js +7 -4
- package/route/hooks/useRouter.js +7 -4
- package/route/hooks/useSearchParams.js +7 -4
- package/route/index.js +20 -2
- package/route/types.js +2 -1
- package/store/ClientAppStore.js +12 -21
- package/store/ComponentStore.js +6 -4
- package/store/EventManager.js +20 -32
- package/store/SchemaExperienceStore.js +186 -217
- package/store/index.js +20 -4
- package/toast-notification/ToastNotificationProvider.js +10 -6
- package/toast-notification/context.d.ts +1 -1
- package/toast-notification/context.js +5 -2
- package/toast-notification/hooks/index.js +19 -3
- package/toast-notification/hooks/useCloseToastNotification.js +10 -7
- package/toast-notification/hooks/useOpenToastNotification.js +18 -11
- package/toast-notification/hooks/useToastNotificationItems.d.ts +1 -1
- package/toast-notification/hooks/useToastNotificationItems.js +7 -4
- package/toast-notification/index.js +22 -3
- package/transport/InMemoryDataService/index.js +59 -78
- package/transport/RestDataService/index.d.ts +2 -2
- package/transport/RestDataService/index.js +72 -91
- package/transport/context.js +9 -15
- package/transport/hooks/index.js +18 -2
- package/transport/hooks/useDataService.js +7 -4
- package/transport/hooks/useFileService.js +7 -4
- package/transport/hooks/useRetriveRecords.d.ts +1 -1
- package/transport/hooks/useRetriveRecords.js +25 -31
- package/transport/index.js +20 -2
- package/utils/calculateColumnWidths.js +5 -2
- package/utils/color.js +4 -1
- package/utils/getAttributeFormattedValue.js +38 -40
- package/utils/index.js +18 -2
- package/widget/context.js +5 -2
- package/widget/hooks/index.js +7 -4
- package/widget/index.js +5 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Steps
|
|
2
3
|
// 1. Show the loading indicator
|
|
3
4
|
// 2. Extract modified fields from the form
|
|
@@ -5,44 +6,37 @@
|
|
|
5
6
|
// 4. Perform the operations
|
|
6
7
|
// 5. Handle the response (success or error, navigation, clear some cache, etc)
|
|
7
8
|
// 6. Hide the loading indicator
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.useFormSave = useFormSave;
|
|
17
11
|
// Wrapper - Loader, response message
|
|
18
12
|
// Core - Extract modified fields, prepare operations, perform operations
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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();
|
|
13
|
+
const route_1 = require("@headless-adminapp/app/route");
|
|
14
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
15
|
+
const react_1 = require("react");
|
|
16
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
17
|
+
const useMetadata_1 = require("../../metadata/hooks/useMetadata");
|
|
18
|
+
const context_1 = require("../../mutable/context");
|
|
19
|
+
const useProgressIndicator_1 = require("../../progress-indicator/hooks/useProgressIndicator");
|
|
20
|
+
const useOpenToastNotification_1 = require("../../toast-notification/hooks/useOpenToastNotification");
|
|
21
|
+
const transport_1 = require("../../transport");
|
|
22
|
+
const context_2 = require("../context");
|
|
23
|
+
const utils_1 = require("../utils");
|
|
24
|
+
const useFormRecord_1 = require("./useFormRecord");
|
|
25
|
+
const useFormSchema_1 = require("./useFormSchema");
|
|
26
|
+
const useSelectedForm_1 = require("./useSelectedForm");
|
|
27
|
+
function useFormSave() {
|
|
28
|
+
const form = (0, useSelectedForm_1.useSelectedForm)();
|
|
29
|
+
const formInstance = (0, react_hook_form_1.useFormContext)();
|
|
30
|
+
const record = (0, useFormRecord_1.useFormRecord)();
|
|
31
|
+
const { schemaStore } = (0, useMetadata_1.useMetadata)();
|
|
32
|
+
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
33
|
+
const initialValues = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.initialValues);
|
|
34
|
+
const refresh = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.refresh);
|
|
35
|
+
const dataService = (0, transport_1.useDataService)();
|
|
36
|
+
const { showProgressIndicator, hideProgressIndicator } = (0, useProgressIndicator_1.useProgressIndicator)();
|
|
37
|
+
const openToastNotification = (0, useOpenToastNotification_1.useOpenToastNotification)();
|
|
38
|
+
const client = (0, react_query_1.useQueryClient)();
|
|
39
|
+
const router = (0, route_1.useRouter)();
|
|
46
40
|
function showMessageAfterSave({ isCreatedMode }) {
|
|
47
41
|
// Show notification
|
|
48
42
|
if (!isCreatedMode) {
|
|
@@ -60,8 +54,8 @@ export function useFormSave() {
|
|
|
60
54
|
});
|
|
61
55
|
}
|
|
62
56
|
}
|
|
63
|
-
const _save = (mode) =>
|
|
64
|
-
|
|
57
|
+
const _save = async (mode) => {
|
|
58
|
+
await formInstance.handleSubmit(async (values) => {
|
|
65
59
|
if (mode === 'background' && !record) {
|
|
66
60
|
// Background save should not be triggered if there is no record
|
|
67
61
|
return;
|
|
@@ -70,7 +64,7 @@ export function useFormSave() {
|
|
|
70
64
|
showProgressIndicator(undefined, 500);
|
|
71
65
|
}
|
|
72
66
|
try {
|
|
73
|
-
const result =
|
|
67
|
+
const result = await (0, utils_1.saveRecord)({
|
|
74
68
|
values,
|
|
75
69
|
form: form,
|
|
76
70
|
record: record,
|
|
@@ -91,18 +85,18 @@ export function useFormSave() {
|
|
|
91
85
|
// client,
|
|
92
86
|
// });
|
|
93
87
|
if (mode === 'save' && record) {
|
|
94
|
-
|
|
88
|
+
await refresh();
|
|
95
89
|
// client.invalidateQueries({ queryKey: ['data', 'retriveRecord'] });
|
|
96
90
|
}
|
|
97
91
|
else {
|
|
98
|
-
|
|
92
|
+
await client.invalidateQueries({
|
|
99
93
|
queryKey: ['data', 'retriveRecord'],
|
|
100
94
|
});
|
|
101
95
|
if (mode === 'saveandclose') {
|
|
102
96
|
router.back();
|
|
103
97
|
}
|
|
104
98
|
}
|
|
105
|
-
|
|
99
|
+
await client.invalidateQueries({
|
|
106
100
|
queryKey: ['data', 'retriveRecords'],
|
|
107
101
|
});
|
|
108
102
|
// redirectAfterSave({
|
|
@@ -130,10 +124,10 @@ export function useFormSave() {
|
|
|
130
124
|
hideProgressIndicator();
|
|
131
125
|
}
|
|
132
126
|
}
|
|
133
|
-
})
|
|
134
|
-
}
|
|
135
|
-
const _saveRef = useRef(_save);
|
|
127
|
+
})();
|
|
128
|
+
};
|
|
129
|
+
const _saveRef = (0, react_1.useRef)(_save);
|
|
136
130
|
_saveRef.current = _save;
|
|
137
|
-
const save = useCallback((mode) => _saveRef.current(mode), [_saveRef]);
|
|
131
|
+
const save = (0, react_1.useCallback)((mode) => _saveRef.current(mode), [_saveRef]);
|
|
138
132
|
return save;
|
|
139
133
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDataFormSchema = useDataFormSchema;
|
|
4
|
+
const context_1 = require("../../mutable/context");
|
|
5
|
+
const context_2 = require("../context");
|
|
6
|
+
function useDataFormSchema() {
|
|
7
|
+
return (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.schema);
|
|
5
8
|
}
|
|
@@ -1,35 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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({
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLoadFormGridPage = useLoadFormGridPage;
|
|
4
|
+
const app_1 = require("@headless-adminapp/app/app");
|
|
5
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
6
|
+
const hooks_1 = require("../../metadata/hooks");
|
|
7
|
+
function useLoadFormGridPage(logicalName, formId) {
|
|
8
|
+
const schema = (0, hooks_1.useSchema)(logicalName);
|
|
9
|
+
const experienceStore = (0, hooks_1.useExperienceStore)();
|
|
10
|
+
const { data: form, isFetching: isFetchingForm } = (0, react_query_1.useQuery)({
|
|
17
11
|
queryKey: ['experience-schema-form', logicalName, formId],
|
|
18
|
-
queryFn: () =>
|
|
12
|
+
queryFn: async () => {
|
|
19
13
|
return experienceStore.getForm(logicalName, formId);
|
|
20
|
-
}
|
|
21
|
-
placeholderData: keepPreviousData,
|
|
14
|
+
},
|
|
15
|
+
placeholderData: react_query_1.keepPreviousData,
|
|
22
16
|
});
|
|
23
|
-
const { app: { formCommands }, } = useAppContext();
|
|
24
|
-
const { data: commands } = useQuery({
|
|
17
|
+
const { app: { formCommands }, } = (0, app_1.useAppContext)();
|
|
18
|
+
const { data: commands } = (0, react_query_1.useQuery)({
|
|
25
19
|
queryKey: ['experience-schema-form-commands', logicalName],
|
|
26
|
-
queryFn: () =>
|
|
27
|
-
let commands =
|
|
20
|
+
queryFn: async () => {
|
|
21
|
+
let commands = await experienceStore.getFormCommands(logicalName);
|
|
28
22
|
if (!commands) {
|
|
29
23
|
commands = formCommands;
|
|
30
24
|
}
|
|
31
|
-
return commands
|
|
32
|
-
}
|
|
25
|
+
return commands ?? [];
|
|
26
|
+
},
|
|
33
27
|
initialData: [],
|
|
34
28
|
});
|
|
35
29
|
if (!schema) {
|
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFormControlContext = useFormControlContext;
|
|
4
|
+
exports.useMainFormCommandHandlerContext = useMainFormCommandHandlerContext;
|
|
5
|
+
exports.useMainFormCommands = useMainFormCommands;
|
|
6
|
+
const route_1 = require("@headless-adminapp/app/route");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const command_1 = require("../../command");
|
|
9
|
+
const context_1 = require("../../mutable/context");
|
|
10
|
+
const context_2 = require("../context");
|
|
11
|
+
const useFormInstance_1 = require("./useFormInstance");
|
|
12
|
+
const useFormIsReadonly_1 = require("./useFormIsReadonly");
|
|
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() {
|
|
18
|
+
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
19
|
+
const form = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.form);
|
|
20
|
+
const originalData = (0, useFormRecord_1.useFormRecord)();
|
|
21
|
+
const recordId = (0, useRecordId_1.useRecordId)();
|
|
22
|
+
const save = (0, useFormSave_1.useFormSave)();
|
|
23
|
+
const refresh = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.refresh);
|
|
24
|
+
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
25
|
+
const readonly = (0, useFormIsReadonly_1.useFormIsReadonly)() ?? false;
|
|
22
26
|
const data = formInstance.watch();
|
|
23
|
-
const router = useRouter();
|
|
24
|
-
const close = useCallback(() => {
|
|
27
|
+
const router = (0, route_1.useRouter)();
|
|
28
|
+
const close = (0, react_1.useCallback)(() => {
|
|
25
29
|
router.back();
|
|
26
30
|
}, [router]);
|
|
27
31
|
return {
|
|
@@ -30,7 +34,7 @@ export function useFormControlContext() {
|
|
|
30
34
|
schema,
|
|
31
35
|
form,
|
|
32
36
|
formId: form.id,
|
|
33
|
-
originalData: originalData
|
|
37
|
+
originalData: originalData ?? null,
|
|
34
38
|
recordId,
|
|
35
39
|
refresh,
|
|
36
40
|
save,
|
|
@@ -38,13 +42,16 @@ export function useFormControlContext() {
|
|
|
38
42
|
close,
|
|
39
43
|
};
|
|
40
44
|
}
|
|
41
|
-
|
|
45
|
+
function useMainFormCommandHandlerContext() {
|
|
42
46
|
const primaryControl = useFormControlContext();
|
|
43
|
-
const baseHandlerContext = useBaseCommandHandlerContext();
|
|
44
|
-
return
|
|
47
|
+
const baseHandlerContext = (0, command_1.useBaseCommandHandlerContext)();
|
|
48
|
+
return {
|
|
49
|
+
...baseHandlerContext,
|
|
50
|
+
primaryControl,
|
|
51
|
+
};
|
|
45
52
|
}
|
|
46
|
-
|
|
47
|
-
const commands = useContextSelector(DataFormContext, (state) => state.commands);
|
|
53
|
+
function useMainFormCommands() {
|
|
54
|
+
const commands = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.commands);
|
|
48
55
|
const handlerContext = useMainFormCommandHandlerContext();
|
|
49
|
-
return useCommands(commands, handlerContext);
|
|
56
|
+
return (0, command_1.useCommands)(commands, handlerContext);
|
|
50
57
|
}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useProcessFlowSteps = useProcessFlowSteps;
|
|
4
|
+
const command_1 = require("@headless-adminapp/app/command");
|
|
5
|
+
const context_1 = require("../../mutable/context");
|
|
6
|
+
const context_2 = require("../context");
|
|
7
|
+
const useFormInstance_1 = require("./useFormInstance");
|
|
8
|
+
const useFormIsReadonly_1 = require("./useFormIsReadonly");
|
|
9
|
+
const useFormRecord_1 = require("./useFormRecord");
|
|
10
|
+
const useFormSchema_1 = require("./useFormSchema");
|
|
11
|
+
const useRecordId_1 = require("./useRecordId");
|
|
12
|
+
const useSelectedForm_1 = require("./useSelectedForm");
|
|
10
13
|
function useFormControlContext() {
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const readonly = (_a = useFormIsReadonly()) !== null && _a !== void 0 ? _a : false;
|
|
14
|
+
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
15
|
+
const form = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.form);
|
|
16
|
+
const originalData = (0, useFormRecord_1.useFormRecord)();
|
|
17
|
+
const recordId = (0, useRecordId_1.useRecordId)();
|
|
18
|
+
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
19
|
+
const readonly = (0, useFormIsReadonly_1.useFormIsReadonly)() ?? false;
|
|
18
20
|
const data = formInstance.watch();
|
|
19
21
|
return {
|
|
20
22
|
data,
|
|
@@ -22,20 +24,22 @@ function useFormControlContext() {
|
|
|
22
24
|
schema,
|
|
23
25
|
form,
|
|
24
26
|
formId: form.id,
|
|
25
|
-
originalData: originalData
|
|
27
|
+
originalData: originalData ?? null,
|
|
26
28
|
recordId,
|
|
27
29
|
readonly,
|
|
28
30
|
};
|
|
29
31
|
}
|
|
30
32
|
function useProcessFlowInfoContext() {
|
|
31
33
|
const primaryControl = useFormControlContext();
|
|
32
|
-
const baseHandlerContext = useBaseCommandHandlerContext();
|
|
33
|
-
return
|
|
34
|
+
const baseHandlerContext = (0, command_1.useBaseCommandHandlerContext)();
|
|
35
|
+
return {
|
|
36
|
+
...baseHandlerContext,
|
|
37
|
+
primaryControl,
|
|
38
|
+
};
|
|
34
39
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const formConfig = useSelectedForm();
|
|
40
|
+
function useProcessFlowSteps() {
|
|
41
|
+
const formConfig = (0, useSelectedForm_1.useSelectedForm)();
|
|
38
42
|
const context = useProcessFlowInfoContext();
|
|
39
|
-
const steps =
|
|
43
|
+
const steps = formConfig.experience.processFlow?.getSteps(context);
|
|
40
44
|
return steps;
|
|
41
45
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRecordId = useRecordId;
|
|
4
|
+
const context_1 = require("../../mutable/context");
|
|
5
|
+
const context_2 = require("../context");
|
|
6
|
+
function useRecordId() {
|
|
7
|
+
return (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.recordId);
|
|
5
8
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRecordTitle = useRecordTitle;
|
|
4
|
+
const useFormInstance_1 = require("./useFormInstance");
|
|
5
|
+
const useFormSchema_1 = require("./useFormSchema");
|
|
6
|
+
const useRecordId_1 = require("./useRecordId");
|
|
7
|
+
function useRecordTitle() {
|
|
8
|
+
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
9
|
+
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
10
|
+
const recordId = (0, useRecordId_1.useRecordId)();
|
|
8
11
|
let primaryAttributeValue = formInstance.watch(schema.primaryAttribute);
|
|
9
12
|
const primaryAttribute = schema.attributes[schema.primaryAttribute];
|
|
10
|
-
if (
|
|
13
|
+
if (primaryAttribute?.type === 'lookup') {
|
|
11
14
|
// Handle lookup attribute as primary
|
|
12
|
-
primaryAttributeValue = primaryAttributeValue
|
|
15
|
+
primaryAttributeValue = primaryAttributeValue?.name;
|
|
13
16
|
}
|
|
14
17
|
if (primaryAttributeValue && typeof primaryAttributeValue !== 'string') {
|
|
15
18
|
return [String(primaryAttributeValue), false];
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSelectedForm = useSelectedForm;
|
|
4
|
+
const context_1 = require("../../mutable/context");
|
|
5
|
+
const context_2 = require("../context");
|
|
6
|
+
function useSelectedForm() {
|
|
7
|
+
return (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.form);
|
|
5
8
|
}
|
package/dataform/index.js
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
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,7 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFormDefaultParameters = getFormDefaultParameters;
|
|
4
|
+
exports.setFormDefaultParameters = setFormDefaultParameters;
|
|
1
5
|
let formDefaultParameters = null;
|
|
2
|
-
|
|
3
|
-
const _values = formDefaultParameters
|
|
4
|
-
const _logicalName = formDefaultParameters
|
|
6
|
+
function getFormDefaultParameters(schema) {
|
|
7
|
+
const _values = formDefaultParameters?.values;
|
|
8
|
+
const _logicalName = formDefaultParameters?.logicalName;
|
|
5
9
|
const schemaDefaultValues = Object.keys(schema.attributes).reduce((acc, key) => {
|
|
6
10
|
const attribute = schema.attributes[key];
|
|
7
11
|
let defaultValue = attribute.default;
|
|
@@ -11,15 +15,21 @@ export function getFormDefaultParameters(schema) {
|
|
|
11
15
|
if (defaultValue instanceof Date) {
|
|
12
16
|
defaultValue = defaultValue.toISOString();
|
|
13
17
|
}
|
|
14
|
-
return
|
|
18
|
+
return {
|
|
19
|
+
...acc,
|
|
20
|
+
[key]: defaultValue,
|
|
21
|
+
};
|
|
15
22
|
}, {});
|
|
16
23
|
if (_logicalName === schema.logicalName) {
|
|
17
|
-
return
|
|
24
|
+
return {
|
|
25
|
+
...schemaDefaultValues,
|
|
26
|
+
..._values,
|
|
27
|
+
};
|
|
18
28
|
}
|
|
19
29
|
return schemaDefaultValues;
|
|
20
30
|
}
|
|
21
31
|
let defaultParamsTimeout = null;
|
|
22
|
-
|
|
32
|
+
function setFormDefaultParameters(logicalName, values) {
|
|
23
33
|
formDefaultParameters = {
|
|
24
34
|
logicalName,
|
|
25
35
|
values,
|