@headless-adminapp/app 0.0.12-alpha.0 → 0.0.14-alpha.0
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/package.json +8 -16
- package/src/app/context.ts +0 -11
- package/src/app/hooks/index.ts +0 -1
- package/src/app/hooks/useAppContext.ts +0 -13
- package/src/app/index.ts +0 -2
- package/src/appearance/context.ts +0 -13
- package/src/appearance/hooks/index.ts +0 -1
- package/src/appearance/hooks/useAppearanceContext.ts +0 -13
- package/src/appearance/index.ts +0 -6
- package/src/auth/AuthProvider.tsx +0 -118
- package/src/auth/context.ts +0 -41
- package/src/auth/hooks/index.ts +0 -2
- package/src/auth/hooks/useAuthSession.ts +0 -17
- package/src/auth/hooks/useLogout.ts +0 -23
- package/src/auth/index.ts +0 -4
- package/src/auth/types.ts +0 -17
- package/src/builders/CommandBuilder.ts +0 -777
- package/src/builders/SchemaExperienceBuilder.ts +0 -488
- package/src/builders/index.ts +0 -5
- package/src/command/hooks/index.ts +0 -2
- package/src/command/hooks/useBaseCommandHandlerContext.ts +0 -51
- package/src/command/hooks/useCommands.ts +0 -26
- package/src/command/index.ts +0 -2
- package/src/command/types.ts +0 -116
- package/src/command/utils/index.ts +0 -142
- package/src/components/ScrollView/index.tsx +0 -26
- package/src/dataform/DataFormProvider/DataResolver.tsx +0 -186
- package/src/dataform/DataFormProvider/InitialValueResolver.tsx +0 -55
- package/src/dataform/DataFormProvider/ReadonlyInfoResolver.tsx +0 -35
- package/src/dataform/DataFormProvider/index.tsx +0 -102
- package/src/dataform/context.ts +0 -53
- package/src/dataform/hooks/index.ts +0 -12
- package/src/dataform/hooks/useFormInstance.ts +0 -6
- package/src/dataform/hooks/useFormIsDirty.ts +0 -7
- package/src/dataform/hooks/useFormIsReadonly.ts +0 -11
- package/src/dataform/hooks/useFormNotifications.ts +0 -46
- package/src/dataform/hooks/useFormRecord.ts +0 -7
- package/src/dataform/hooks/useFormSave.ts +0 -147
- package/src/dataform/hooks/useFormSchema.ts +0 -13
- package/src/dataform/hooks/useLoadFormGridPage.ts +0 -97
- package/src/dataform/hooks/useMainFormCommands.ts +0 -65
- package/src/dataform/hooks/useRecordId.ts +0 -6
- package/src/dataform/hooks/useRecordTitle.ts +0 -22
- package/src/dataform/hooks/useSelectedForm.ts +0 -14
- package/src/dataform/index.ts +0 -4
- package/src/dataform/utils/index.ts +0 -594
- package/src/datagrid/DataGridProvider/DataResolver.tsx +0 -281
- package/src/datagrid/DataGridProvider/index.tsx +0 -134
- package/src/datagrid/DataGridProvider/transformViewColumns.ts +0 -54
- package/src/datagrid/DataGridProvider/utils.ts +0 -89
- package/src/datagrid/column-filter/constants.ts +0 -493
- package/src/datagrid/column-filter/index.ts +0 -3
- package/src/datagrid/column-filter/types.ts +0 -68
- package/src/datagrid/column-filter/utils.ts +0 -19
- package/src/datagrid/context.ts +0 -66
- package/src/datagrid/hooks/index.ts +0 -20
- package/src/datagrid/hooks/useChangeView.ts +0 -18
- package/src/datagrid/hooks/useGridColumnFilter.ts +0 -28
- package/src/datagrid/hooks/useGridColumns.ts +0 -13
- package/src/datagrid/hooks/useGridCommands.ts +0 -21
- package/src/datagrid/hooks/useGridData.ts +0 -8
- package/src/datagrid/hooks/useGridDataState.ts +0 -8
- package/src/datagrid/hooks/useGridExtraFilter.ts +0 -6
- package/src/datagrid/hooks/useGridOptions.ts +0 -3
- package/src/datagrid/hooks/useGridPagination.ts +0 -3
- package/src/datagrid/hooks/useGridRefresh.ts +0 -19
- package/src/datagrid/hooks/useGridSchema.ts +0 -13
- package/src/datagrid/hooks/useGridSelection.ts +0 -28
- package/src/datagrid/hooks/useGridSorting.ts +0 -23
- package/src/datagrid/hooks/useGridViewLookupData.ts +0 -10
- package/src/datagrid/hooks/useLoadMainGridPage.ts +0 -90
- package/src/datagrid/hooks/useMainGridCommands.ts +0 -255
- package/src/datagrid/hooks/useMaxRecords.ts +0 -6
- package/src/datagrid/hooks/useSearchText.ts +0 -22
- package/src/datagrid/hooks/useSelectedView.ts +0 -14
- package/src/datagrid/hooks/useSubGridCommands.ts +0 -104
- package/src/datagrid/index.ts +0 -14
- package/src/dialog/DialogProvider.tsx +0 -20
- package/src/dialog/context.ts +0 -14
- package/src/dialog/hooks/index.ts +0 -8
- package/src/dialog/hooks/useCloseDialog.ts +0 -36
- package/src/dialog/hooks/useDialogItem.ts +0 -8
- package/src/dialog/hooks/useDialogItems.ts +0 -6
- package/src/dialog/hooks/useOpenAlertDialog.ts +0 -30
- package/src/dialog/hooks/useOpenConfirmDialog.ts +0 -45
- package/src/dialog/hooks/useOpenDialog.ts +0 -39
- package/src/dialog/hooks/useOpenErrorDialog.ts +0 -26
- package/src/dialog/hooks/useOpenPromptDialog.ts +0 -46
- package/src/dialog/index.ts +0 -7
- package/src/form/FormValidationStringContext.ts +0 -30
- package/src/form/index.ts +0 -6
- package/src/hooks/index.ts +0 -5
- package/src/hooks/useDebouncedValue.ts +0 -38
- package/src/hooks/useElementLayout.ts +0 -49
- package/src/hooks/useIsMobile.ts +0 -21
- package/src/hooks/useStorageState.ts +0 -36
- package/src/hooks/useSystemColorScheme.ts +0 -38
- package/src/index.css +0 -4
- package/src/insights/context.ts +0 -5
- package/src/insights/hooks/index.ts +0 -14
- package/src/insights/index.ts +0 -2
- package/src/locale/context.ts +0 -7
- package/src/locale/index.ts +0 -3
- package/src/locale/types.ts +0 -3
- package/src/locale/useLocale.ts +0 -13
- package/src/metadata/MetadataProvider.tsx +0 -51
- package/src/metadata/context.ts +0 -15
- package/src/metadata/hooks/index.ts +0 -8
- package/src/metadata/hooks/useAppStore.ts +0 -6
- package/src/metadata/hooks/useExperienceStore.ts +0 -6
- package/src/metadata/hooks/useExperienceView.ts +0 -36
- package/src/metadata/hooks/useExperienceViewCommands.ts +0 -20
- package/src/metadata/hooks/useExperienceViewLookup.ts +0 -33
- package/src/metadata/hooks/useExperienceViewSubgridCommands.ts +0 -20
- package/src/metadata/hooks/useMetadata.ts +0 -44
- package/src/metadata/hooks/useSchema.ts +0 -11
- package/src/metadata/index.ts +0 -3
- package/src/mutable/context.ts +0 -71
- package/src/mutable/index.ts +0 -14
- package/src/mutable/state.ts +0 -13
- package/src/mutable/type.ts +0 -9
- package/src/mutable/utils.ts +0 -80
- package/src/navigation/hooks/useOpenForm.ts +0 -34
- package/src/progress-indicator/ProgressIndicatorProvider.tsx +0 -77
- package/src/progress-indicator/context.ts +0 -12
- package/src/progress-indicator/hooks/index.ts +0 -1
- package/src/progress-indicator/hooks/useProgressIndicator.ts +0 -15
- package/src/progress-indicator/index.ts +0 -6
- package/src/providers/PageEntityFormProvider/index.tsx +0 -34
- package/src/providers/PageEntityViewProvider/index.tsx +0 -39
- package/src/recordset/RecordSetProvider.tsx +0 -55
- package/src/recordset/context.ts +0 -12
- package/src/recordset/hooks/index.ts +0 -3
- package/src/recordset/hooks/useRecordSetResult.ts +0 -94
- package/src/recordset/hooks/useRecordSetSetter.ts +0 -21
- package/src/recordset/hooks/useRecordSetVisibility.ts +0 -24
- package/src/recordset/index.ts +0 -3
- package/src/route/RouteProvider.tsx +0 -76
- package/src/route/context.ts +0 -39
- package/src/route/hooks/index.ts +0 -5
- package/src/route/hooks/useBasePath.ts +0 -7
- package/src/route/hooks/usePathname.ts +0 -7
- package/src/route/hooks/useRouteResolver.ts +0 -7
- package/src/route/hooks/useRouter.ts +0 -7
- package/src/route/hooks/useSearchParams.ts +0 -7
- package/src/route/index.ts +0 -2
- package/src/route/types.ts +0 -1
- package/src/store/ClientAppStore.ts +0 -20
- package/src/store/ComponentStore.tsx +0 -22
- package/src/store/EventManager.ts +0 -33
- package/src/store/SchemaExperienceStore.ts +0 -374
- package/src/store/index.ts +0 -4
- package/src/toast-notification/ToastNotificationProvider.tsx +0 -23
- package/src/toast-notification/context.ts +0 -17
- package/src/toast-notification/hooks/index.ts +0 -3
- package/src/toast-notification/hooks/useCloseToastNotification.ts +0 -36
- package/src/toast-notification/hooks/useOpenToastNotification.ts +0 -38
- package/src/toast-notification/hooks/useToastNotificationItems.ts +0 -6
- package/src/toast-notification/index.ts +0 -7
- package/src/transport/InMemoryDataService/index.ts +0 -157
- package/src/transport/RestDataService/index.ts +0 -151
- package/src/transport/context.ts +0 -6
- package/src/transport/hooks/index.ts +0 -1
- package/src/transport/hooks/useDataService.ts +0 -13
- package/src/transport/index.ts +0 -2
- package/src/utils/calculateColumnWidths.ts +0 -72
- package/src/utils/index.ts +0 -1
- package/src/widget/context.ts +0 -5
- package/src/widget/hooks/index.ts +0 -11
- package/src/widget/index.ts +0 -1
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
- /package/{dist/app → app}/context.d.ts +0 -0
- /package/{dist/app → app}/context.js +0 -0
- /package/{dist/app → app}/hooks/index.d.ts +0 -0
- /package/{dist/app → app}/hooks/index.js +0 -0
- /package/{dist/app → app}/hooks/useAppContext.d.ts +0 -0
- /package/{dist/app → app}/hooks/useAppContext.js +0 -0
- /package/{dist/app → app}/index.d.ts +0 -0
- /package/{dist/app → app}/index.js +0 -0
- /package/{dist/appearance → appearance}/context.d.ts +0 -0
- /package/{dist/appearance → appearance}/context.js +0 -0
- /package/{dist/appearance → appearance}/hooks/index.d.ts +0 -0
- /package/{dist/appearance → appearance}/hooks/index.js +0 -0
- /package/{dist/appearance → appearance}/hooks/useAppearanceContext.d.ts +0 -0
- /package/{dist/appearance → appearance}/hooks/useAppearanceContext.js +0 -0
- /package/{dist/appearance → appearance}/index.d.ts +0 -0
- /package/{dist/appearance → appearance}/index.js +0 -0
- /package/{dist/auth → auth}/AuthProvider.d.ts +0 -0
- /package/{dist/auth → auth}/AuthProvider.js +0 -0
- /package/{dist/auth → auth}/context.d.ts +0 -0
- /package/{dist/auth → auth}/context.js +0 -0
- /package/{dist/auth → auth}/hooks/index.d.ts +0 -0
- /package/{dist/auth → auth}/hooks/index.js +0 -0
- /package/{dist/auth → auth}/hooks/useAuthSession.d.ts +0 -0
- /package/{dist/auth → auth}/hooks/useAuthSession.js +0 -0
- /package/{dist/auth → auth}/hooks/useLogout.d.ts +0 -0
- /package/{dist/auth → auth}/hooks/useLogout.js +0 -0
- /package/{dist/auth → auth}/index.d.ts +0 -0
- /package/{dist/auth → auth}/index.js +0 -0
- /package/{dist/auth → auth}/types.d.ts +0 -0
- /package/{dist/auth → auth}/types.js +0 -0
- /package/{dist/builders → builders}/CommandBuilder.d.ts +0 -0
- /package/{dist/builders → builders}/CommandBuilder.js +0 -0
- /package/{dist/builders → builders}/SchemaExperienceBuilder.d.ts +0 -0
- /package/{dist/builders → builders}/SchemaExperienceBuilder.js +0 -0
- /package/{dist/builders → builders}/index.d.ts +0 -0
- /package/{dist/builders → builders}/index.js +0 -0
- /package/{dist/command → command}/hooks/index.d.ts +0 -0
- /package/{dist/command → command}/hooks/index.js +0 -0
- /package/{dist/command → command}/hooks/useBaseCommandHandlerContext.d.ts +0 -0
- /package/{dist/command → command}/hooks/useBaseCommandHandlerContext.js +0 -0
- /package/{dist/command → command}/hooks/useCommands.d.ts +0 -0
- /package/{dist/command → command}/hooks/useCommands.js +0 -0
- /package/{dist/command → command}/index.d.ts +0 -0
- /package/{dist/command → command}/index.js +0 -0
- /package/{dist/command → command}/types.d.ts +0 -0
- /package/{dist/command → command}/types.js +0 -0
- /package/{dist/command → command}/utils/index.d.ts +0 -0
- /package/{dist/command → command}/utils/index.js +0 -0
- /package/{dist/components → components}/ScrollView/index.d.ts +0 -0
- /package/{dist/components → components}/ScrollView/index.js +0 -0
- /package/{dist/dataform → dataform}/DataFormProvider/DataResolver.d.ts +0 -0
- /package/{dist/dataform → dataform}/DataFormProvider/DataResolver.js +0 -0
- /package/{dist/dataform → dataform}/DataFormProvider/InitialValueResolver.d.ts +0 -0
- /package/{dist/dataform → dataform}/DataFormProvider/InitialValueResolver.js +0 -0
- /package/{dist/dataform → dataform}/DataFormProvider/ReadonlyInfoResolver.d.ts +0 -0
- /package/{dist/dataform → dataform}/DataFormProvider/ReadonlyInfoResolver.js +0 -0
- /package/{dist/dataform → dataform}/DataFormProvider/index.d.ts +0 -0
- /package/{dist/dataform → dataform}/DataFormProvider/index.js +0 -0
- /package/{dist/dataform → dataform}/context.d.ts +0 -0
- /package/{dist/dataform → dataform}/context.js +0 -0
- /package/{dist/dataform → dataform}/hooks/index.d.ts +0 -0
- /package/{dist/dataform → dataform}/hooks/index.js +0 -0
- /package/{dist/dataform → dataform}/hooks/useFormInstance.d.ts +0 -0
- /package/{dist/dataform → dataform}/hooks/useFormInstance.js +0 -0
- /package/{dist/dataform → dataform}/hooks/useFormIsDirty.d.ts +0 -0
- /package/{dist/dataform → dataform}/hooks/useFormIsDirty.js +0 -0
- /package/{dist/dataform → dataform}/hooks/useFormIsReadonly.d.ts +0 -0
- /package/{dist/dataform → dataform}/hooks/useFormIsReadonly.js +0 -0
- /package/{dist/dataform → dataform}/hooks/useFormNotifications.d.ts +0 -0
- /package/{dist/dataform → dataform}/hooks/useFormNotifications.js +0 -0
- /package/{dist/dataform → dataform}/hooks/useFormRecord.d.ts +0 -0
- /package/{dist/dataform → dataform}/hooks/useFormRecord.js +0 -0
- /package/{dist/dataform → dataform}/hooks/useFormSave.d.ts +0 -0
- /package/{dist/dataform → dataform}/hooks/useFormSave.js +0 -0
- /package/{dist/dataform → dataform}/hooks/useFormSchema.d.ts +0 -0
- /package/{dist/dataform → dataform}/hooks/useFormSchema.js +0 -0
- /package/{dist/dataform → dataform}/hooks/useLoadFormGridPage.d.ts +0 -0
- /package/{dist/dataform → dataform}/hooks/useLoadFormGridPage.js +0 -0
- /package/{dist/dataform → dataform}/hooks/useMainFormCommands.d.ts +0 -0
- /package/{dist/dataform → dataform}/hooks/useMainFormCommands.js +0 -0
- /package/{dist/dataform → dataform}/hooks/useRecordId.d.ts +0 -0
- /package/{dist/dataform → dataform}/hooks/useRecordId.js +0 -0
- /package/{dist/dataform → dataform}/hooks/useRecordTitle.d.ts +0 -0
- /package/{dist/dataform → dataform}/hooks/useRecordTitle.js +0 -0
- /package/{dist/dataform → dataform}/hooks/useSelectedForm.d.ts +0 -0
- /package/{dist/dataform → dataform}/hooks/useSelectedForm.js +0 -0
- /package/{dist/dataform → dataform}/index.d.ts +0 -0
- /package/{dist/dataform → dataform}/index.js +0 -0
- /package/{dist/dataform → dataform}/utils/index.d.ts +0 -0
- /package/{dist/dataform → dataform}/utils/index.js +0 -0
- /package/{dist/datagrid → datagrid}/DataGridProvider/DataResolver.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/DataGridProvider/DataResolver.js +0 -0
- /package/{dist/datagrid → datagrid}/DataGridProvider/index.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/DataGridProvider/index.js +0 -0
- /package/{dist/datagrid → datagrid}/DataGridProvider/transformViewColumns.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/DataGridProvider/transformViewColumns.js +0 -0
- /package/{dist/datagrid → datagrid}/DataGridProvider/utils.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/DataGridProvider/utils.js +0 -0
- /package/{dist/datagrid → datagrid}/column-filter/constants.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/column-filter/constants.js +0 -0
- /package/{dist/datagrid → datagrid}/column-filter/index.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/column-filter/index.js +0 -0
- /package/{dist/datagrid → datagrid}/column-filter/types.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/column-filter/types.js +0 -0
- /package/{dist/datagrid → datagrid}/column-filter/utils.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/column-filter/utils.js +0 -0
- /package/{dist/datagrid → datagrid}/context.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/context.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/index.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/index.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useChangeView.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useChangeView.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridColumnFilter.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridColumnFilter.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridColumns.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridColumns.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridCommands.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridCommands.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridData.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridData.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridDataState.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridDataState.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridExtraFilter.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridExtraFilter.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridOptions.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridOptions.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridPagination.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridPagination.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridRefresh.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridRefresh.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridSchema.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridSchema.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridSelection.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridSelection.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridSorting.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridSorting.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridViewLookupData.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useGridViewLookupData.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useLoadMainGridPage.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useLoadMainGridPage.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useMainGridCommands.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useMainGridCommands.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useMaxRecords.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useMaxRecords.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useSearchText.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useSearchText.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useSelectedView.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useSelectedView.js +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useSubGridCommands.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/hooks/useSubGridCommands.js +0 -0
- /package/{dist/datagrid → datagrid}/index.d.ts +0 -0
- /package/{dist/datagrid → datagrid}/index.js +0 -0
- /package/{dist/dialog → dialog}/DialogProvider.d.ts +0 -0
- /package/{dist/dialog → dialog}/DialogProvider.js +0 -0
- /package/{dist/dialog → dialog}/context.d.ts +0 -0
- /package/{dist/dialog → dialog}/context.js +0 -0
- /package/{dist/dialog → dialog}/hooks/index.d.ts +0 -0
- /package/{dist/dialog → dialog}/hooks/index.js +0 -0
- /package/{dist/dialog → dialog}/hooks/useCloseDialog.d.ts +0 -0
- /package/{dist/dialog → dialog}/hooks/useCloseDialog.js +0 -0
- /package/{dist/dialog → dialog}/hooks/useDialogItem.d.ts +0 -0
- /package/{dist/dialog → dialog}/hooks/useDialogItem.js +0 -0
- /package/{dist/dialog → dialog}/hooks/useDialogItems.d.ts +0 -0
- /package/{dist/dialog → dialog}/hooks/useDialogItems.js +0 -0
- /package/{dist/dialog → dialog}/hooks/useOpenAlertDialog.d.ts +0 -0
- /package/{dist/dialog → dialog}/hooks/useOpenAlertDialog.js +0 -0
- /package/{dist/dialog → dialog}/hooks/useOpenConfirmDialog.d.ts +0 -0
- /package/{dist/dialog → dialog}/hooks/useOpenConfirmDialog.js +0 -0
- /package/{dist/dialog → dialog}/hooks/useOpenDialog.d.ts +0 -0
- /package/{dist/dialog → dialog}/hooks/useOpenDialog.js +0 -0
- /package/{dist/dialog → dialog}/hooks/useOpenErrorDialog.d.ts +0 -0
- /package/{dist/dialog → dialog}/hooks/useOpenErrorDialog.js +0 -0
- /package/{dist/dialog → dialog}/hooks/useOpenPromptDialog.d.ts +0 -0
- /package/{dist/dialog → dialog}/hooks/useOpenPromptDialog.js +0 -0
- /package/{dist/dialog → dialog}/index.d.ts +0 -0
- /package/{dist/dialog → dialog}/index.js +0 -0
- /package/{dist/form → form}/FormValidationStringContext.d.ts +0 -0
- /package/{dist/form → form}/FormValidationStringContext.js +0 -0
- /package/{dist/form → form}/index.d.ts +0 -0
- /package/{dist/form → form}/index.js +0 -0
- /package/{dist/hooks → hooks}/index.d.ts +0 -0
- /package/{dist/hooks → hooks}/index.js +0 -0
- /package/{dist/hooks → hooks}/useDebouncedValue.d.ts +0 -0
- /package/{dist/hooks → hooks}/useDebouncedValue.js +0 -0
- /package/{dist/hooks → hooks}/useElementLayout.d.ts +0 -0
- /package/{dist/hooks → hooks}/useElementLayout.js +0 -0
- /package/{dist/hooks → hooks}/useIsMobile.d.ts +0 -0
- /package/{dist/hooks → hooks}/useIsMobile.js +0 -0
- /package/{dist/hooks → hooks}/useStorageState.d.ts +0 -0
- /package/{dist/hooks → hooks}/useStorageState.js +0 -0
- /package/{dist/hooks → hooks}/useSystemColorScheme.d.ts +0 -0
- /package/{dist/hooks → hooks}/useSystemColorScheme.js +0 -0
- /package/{dist/insights → insights}/context.d.ts +0 -0
- /package/{dist/insights → insights}/context.js +0 -0
- /package/{dist/insights → insights}/hooks/index.d.ts +0 -0
- /package/{dist/insights → insights}/hooks/index.js +0 -0
- /package/{dist/insights → insights}/index.d.ts +0 -0
- /package/{dist/insights → insights}/index.js +0 -0
- /package/{dist/locale → locale}/context.d.ts +0 -0
- /package/{dist/locale → locale}/context.js +0 -0
- /package/{dist/locale → locale}/index.d.ts +0 -0
- /package/{dist/locale → locale}/index.js +0 -0
- /package/{dist/locale → locale}/types.d.ts +0 -0
- /package/{dist/locale → locale}/types.js +0 -0
- /package/{dist/locale → locale}/useLocale.d.ts +0 -0
- /package/{dist/locale → locale}/useLocale.js +0 -0
- /package/{dist/metadata → metadata}/MetadataProvider.d.ts +0 -0
- /package/{dist/metadata → metadata}/MetadataProvider.js +0 -0
- /package/{dist/metadata → metadata}/context.d.ts +0 -0
- /package/{dist/metadata → metadata}/context.js +0 -0
- /package/{dist/metadata → metadata}/hooks/index.d.ts +0 -0
- /package/{dist/metadata → metadata}/hooks/index.js +0 -0
- /package/{dist/metadata → metadata}/hooks/useAppStore.d.ts +0 -0
- /package/{dist/metadata → metadata}/hooks/useAppStore.js +0 -0
- /package/{dist/metadata → metadata}/hooks/useExperienceStore.d.ts +0 -0
- /package/{dist/metadata → metadata}/hooks/useExperienceStore.js +0 -0
- /package/{dist/metadata → metadata}/hooks/useExperienceView.d.ts +0 -0
- /package/{dist/metadata → metadata}/hooks/useExperienceView.js +0 -0
- /package/{dist/metadata → metadata}/hooks/useExperienceViewCommands.d.ts +0 -0
- /package/{dist/metadata → metadata}/hooks/useExperienceViewCommands.js +0 -0
- /package/{dist/metadata → metadata}/hooks/useExperienceViewLookup.d.ts +0 -0
- /package/{dist/metadata → metadata}/hooks/useExperienceViewLookup.js +0 -0
- /package/{dist/metadata → metadata}/hooks/useExperienceViewSubgridCommands.d.ts +0 -0
- /package/{dist/metadata → metadata}/hooks/useExperienceViewSubgridCommands.js +0 -0
- /package/{dist/metadata → metadata}/hooks/useMetadata.d.ts +0 -0
- /package/{dist/metadata → metadata}/hooks/useMetadata.js +0 -0
- /package/{dist/metadata → metadata}/hooks/useSchema.d.ts +0 -0
- /package/{dist/metadata → metadata}/hooks/useSchema.js +0 -0
- /package/{dist/metadata → metadata}/index.d.ts +0 -0
- /package/{dist/metadata → metadata}/index.js +0 -0
- /package/{dist/mutable → mutable}/context.d.ts +0 -0
- /package/{dist/mutable → mutable}/context.js +0 -0
- /package/{dist/mutable → mutable}/index.d.ts +0 -0
- /package/{dist/mutable → mutable}/index.js +0 -0
- /package/{dist/mutable → mutable}/state.d.ts +0 -0
- /package/{dist/mutable → mutable}/state.js +0 -0
- /package/{dist/mutable → mutable}/type.d.ts +0 -0
- /package/{dist/mutable → mutable}/type.js +0 -0
- /package/{dist/mutable → mutable}/utils.d.ts +0 -0
- /package/{dist/mutable → mutable}/utils.js +0 -0
- /package/{dist/navigation → navigation}/hooks/useOpenForm.d.ts +0 -0
- /package/{dist/navigation → navigation}/hooks/useOpenForm.js +0 -0
- /package/{dist/progress-indicator → progress-indicator}/ProgressIndicatorProvider.d.ts +0 -0
- /package/{dist/progress-indicator → progress-indicator}/ProgressIndicatorProvider.js +0 -0
- /package/{dist/progress-indicator → progress-indicator}/context.d.ts +0 -0
- /package/{dist/progress-indicator → progress-indicator}/context.js +0 -0
- /package/{dist/progress-indicator → progress-indicator}/hooks/index.d.ts +0 -0
- /package/{dist/progress-indicator → progress-indicator}/hooks/index.js +0 -0
- /package/{dist/progress-indicator → progress-indicator}/hooks/useProgressIndicator.d.ts +0 -0
- /package/{dist/progress-indicator → progress-indicator}/hooks/useProgressIndicator.js +0 -0
- /package/{dist/progress-indicator → progress-indicator}/index.d.ts +0 -0
- /package/{dist/progress-indicator → progress-indicator}/index.js +0 -0
- /package/{dist/providers → providers}/PageEntityFormProvider/index.d.ts +0 -0
- /package/{dist/providers → providers}/PageEntityFormProvider/index.js +0 -0
- /package/{dist/providers → providers}/PageEntityViewProvider/index.d.ts +0 -0
- /package/{dist/providers → providers}/PageEntityViewProvider/index.js +0 -0
- /package/{dist/recordset → recordset}/RecordSetProvider.d.ts +0 -0
- /package/{dist/recordset → recordset}/RecordSetProvider.js +0 -0
- /package/{dist/recordset → recordset}/context.d.ts +0 -0
- /package/{dist/recordset → recordset}/context.js +0 -0
- /package/{dist/recordset → recordset}/hooks/index.d.ts +0 -0
- /package/{dist/recordset → recordset}/hooks/index.js +0 -0
- /package/{dist/recordset → recordset}/hooks/useRecordSetResult.d.ts +0 -0
- /package/{dist/recordset → recordset}/hooks/useRecordSetResult.js +0 -0
- /package/{dist/recordset → recordset}/hooks/useRecordSetSetter.d.ts +0 -0
- /package/{dist/recordset → recordset}/hooks/useRecordSetSetter.js +0 -0
- /package/{dist/recordset → recordset}/hooks/useRecordSetVisibility.d.ts +0 -0
- /package/{dist/recordset → recordset}/hooks/useRecordSetVisibility.js +0 -0
- /package/{dist/recordset → recordset}/index.d.ts +0 -0
- /package/{dist/recordset → recordset}/index.js +0 -0
- /package/{dist/route → route}/RouteProvider.d.ts +0 -0
- /package/{dist/route → route}/RouteProvider.js +0 -0
- /package/{dist/route → route}/context.d.ts +0 -0
- /package/{dist/route → route}/context.js +0 -0
- /package/{dist/route → route}/hooks/index.d.ts +0 -0
- /package/{dist/route → route}/hooks/index.js +0 -0
- /package/{dist/route → route}/hooks/useBasePath.d.ts +0 -0
- /package/{dist/route → route}/hooks/useBasePath.js +0 -0
- /package/{dist/route → route}/hooks/usePathname.d.ts +0 -0
- /package/{dist/route → route}/hooks/usePathname.js +0 -0
- /package/{dist/route → route}/hooks/useRouteResolver.d.ts +0 -0
- /package/{dist/route → route}/hooks/useRouteResolver.js +0 -0
- /package/{dist/route → route}/hooks/useRouter.d.ts +0 -0
- /package/{dist/route → route}/hooks/useRouter.js +0 -0
- /package/{dist/route → route}/hooks/useSearchParams.d.ts +0 -0
- /package/{dist/route → route}/hooks/useSearchParams.js +0 -0
- /package/{dist/route → route}/index.d.ts +0 -0
- /package/{dist/route → route}/index.js +0 -0
- /package/{dist/route → route}/types.d.ts +0 -0
- /package/{dist/route → route}/types.js +0 -0
- /package/{dist/store → store}/ClientAppStore.d.ts +0 -0
- /package/{dist/store → store}/ClientAppStore.js +0 -0
- /package/{dist/store → store}/ComponentStore.d.ts +0 -0
- /package/{dist/store → store}/ComponentStore.js +0 -0
- /package/{dist/store → store}/EventManager.d.ts +0 -0
- /package/{dist/store → store}/EventManager.js +0 -0
- /package/{dist/store → store}/SchemaExperienceStore.d.ts +0 -0
- /package/{dist/store → store}/SchemaExperienceStore.js +0 -0
- /package/{dist/store → store}/index.d.ts +0 -0
- /package/{dist/store → store}/index.js +0 -0
- /package/{dist/toast-notification → toast-notification}/ToastNotificationProvider.d.ts +0 -0
- /package/{dist/toast-notification → toast-notification}/ToastNotificationProvider.js +0 -0
- /package/{dist/toast-notification → toast-notification}/context.d.ts +0 -0
- /package/{dist/toast-notification → toast-notification}/context.js +0 -0
- /package/{dist/toast-notification → toast-notification}/hooks/index.d.ts +0 -0
- /package/{dist/toast-notification → toast-notification}/hooks/index.js +0 -0
- /package/{dist/toast-notification → toast-notification}/hooks/useCloseToastNotification.d.ts +0 -0
- /package/{dist/toast-notification → toast-notification}/hooks/useCloseToastNotification.js +0 -0
- /package/{dist/toast-notification → toast-notification}/hooks/useOpenToastNotification.d.ts +0 -0
- /package/{dist/toast-notification → toast-notification}/hooks/useOpenToastNotification.js +0 -0
- /package/{dist/toast-notification → toast-notification}/hooks/useToastNotificationItems.d.ts +0 -0
- /package/{dist/toast-notification → toast-notification}/hooks/useToastNotificationItems.js +0 -0
- /package/{dist/toast-notification → toast-notification}/index.d.ts +0 -0
- /package/{dist/toast-notification → toast-notification}/index.js +0 -0
- /package/{dist/transport → transport}/InMemoryDataService/index.d.ts +0 -0
- /package/{dist/transport → transport}/InMemoryDataService/index.js +0 -0
- /package/{dist/transport → transport}/RestDataService/index.d.ts +0 -0
- /package/{dist/transport → transport}/RestDataService/index.js +0 -0
- /package/{dist/transport → transport}/context.d.ts +0 -0
- /package/{dist/transport → transport}/context.js +0 -0
- /package/{dist/transport → transport}/hooks/index.d.ts +0 -0
- /package/{dist/transport → transport}/hooks/index.js +0 -0
- /package/{dist/transport → transport}/hooks/useDataService.d.ts +0 -0
- /package/{dist/transport → transport}/hooks/useDataService.js +0 -0
- /package/{dist/transport → transport}/index.d.ts +0 -0
- /package/{dist/transport → transport}/index.js +0 -0
- /package/{dist/utils → utils}/calculateColumnWidths.d.ts +0 -0
- /package/{dist/utils → utils}/calculateColumnWidths.js +0 -0
- /package/{dist/utils → utils}/index.d.ts +0 -0
- /package/{dist/utils → utils}/index.js +0 -0
- /package/{dist/widget → widget}/context.d.ts +0 -0
- /package/{dist/widget → widget}/context.js +0 -0
- /package/{dist/widget → widget}/hooks/index.d.ts +0 -0
- /package/{dist/widget → widget}/hooks/index.js +0 -0
- /package/{dist/widget → widget}/index.d.ts +0 -0
- /package/{dist/widget → widget}/index.js +0 -0
|
@@ -1,594 +0,0 @@
|
|
|
1
|
-
import type { Attribute } from '@headless-adminapp/core/attributes';
|
|
2
|
-
import {
|
|
3
|
-
Form,
|
|
4
|
-
SectionEditableGridControl,
|
|
5
|
-
} from '@headless-adminapp/core/experience/form';
|
|
6
|
-
import {
|
|
7
|
-
InferredSchemaType,
|
|
8
|
-
Schema,
|
|
9
|
-
SchemaAttributes,
|
|
10
|
-
} from '@headless-adminapp/core/schema';
|
|
11
|
-
import { IDataService } from '@headless-adminapp/core/transport';
|
|
12
|
-
import { Nullable } from '@headless-adminapp/core/types';
|
|
13
|
-
import { yupResolver } from '@hookform/resolvers/yup';
|
|
14
|
-
import { memoize, MemoizedFunction } from 'lodash';
|
|
15
|
-
import { ResolverResult } from 'react-hook-form';
|
|
16
|
-
import * as yup from 'yup';
|
|
17
|
-
|
|
18
|
-
import { localizedLabel } from '../../builders/CommandBuilder';
|
|
19
|
-
import {
|
|
20
|
-
getColumns,
|
|
21
|
-
getControls,
|
|
22
|
-
} from '../../dataform/DataFormProvider/DataResolver';
|
|
23
|
-
import { FormValidationStringSet } from '../../form/FormValidationStringContext';
|
|
24
|
-
|
|
25
|
-
export function getModifiedValues(
|
|
26
|
-
initialValues: any,
|
|
27
|
-
values: any,
|
|
28
|
-
exclude?: string[]
|
|
29
|
-
) {
|
|
30
|
-
const keys = Object.keys(values);
|
|
31
|
-
|
|
32
|
-
return keys.reduce((p, c) => {
|
|
33
|
-
if (c === '_id') {
|
|
34
|
-
return p;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (exclude && exclude.includes(c)) {
|
|
38
|
-
return p;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
JSON.stringify(values[c]) !== JSON.stringify((initialValues as any)[c])
|
|
43
|
-
) {
|
|
44
|
-
p[c] = values[c];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return p;
|
|
48
|
-
}, {} as Record<string, any>);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
type SaveRecordResult =
|
|
52
|
-
| {
|
|
53
|
-
success: true;
|
|
54
|
-
recordId: string;
|
|
55
|
-
}
|
|
56
|
-
| {
|
|
57
|
-
success: false;
|
|
58
|
-
title?: string;
|
|
59
|
-
message: string;
|
|
60
|
-
isError: boolean;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export async function saveRecord({
|
|
64
|
-
values,
|
|
65
|
-
form,
|
|
66
|
-
schema,
|
|
67
|
-
dataService,
|
|
68
|
-
initialValues,
|
|
69
|
-
record,
|
|
70
|
-
getSchema,
|
|
71
|
-
}: {
|
|
72
|
-
values: any;
|
|
73
|
-
form: Form<SchemaAttributes>;
|
|
74
|
-
record: InferredSchemaType<SchemaAttributes> | undefined;
|
|
75
|
-
initialValues: Nullable<InferredSchemaType<SchemaAttributes>>;
|
|
76
|
-
schema: Schema<SchemaAttributes>;
|
|
77
|
-
dataService: IDataService;
|
|
78
|
-
getSchema: (logicalName: string) => Schema<SchemaAttributes>;
|
|
79
|
-
}): Promise<SaveRecordResult> {
|
|
80
|
-
const controls = getControls(form);
|
|
81
|
-
|
|
82
|
-
const editableGridControls = controls.filter(
|
|
83
|
-
(control) => control.type === 'editablegrid'
|
|
84
|
-
) as SectionEditableGridControl[];
|
|
85
|
-
|
|
86
|
-
const modifiedValues = getModifiedValues(
|
|
87
|
-
initialValues,
|
|
88
|
-
values,
|
|
89
|
-
editableGridControls.map((x) => x.attributeName)
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
let recordId: string;
|
|
93
|
-
|
|
94
|
-
if (record) {
|
|
95
|
-
recordId = record[schema.idAttribute] as string;
|
|
96
|
-
interface Operation {
|
|
97
|
-
type: 'create' | 'update' | 'delete';
|
|
98
|
-
logicalName: string;
|
|
99
|
-
data?: any;
|
|
100
|
-
id?: string;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const operations: Operation[] = [];
|
|
104
|
-
|
|
105
|
-
if (Object.keys(modifiedValues).length) {
|
|
106
|
-
operations.push({
|
|
107
|
-
type: 'update',
|
|
108
|
-
logicalName: schema.logicalName,
|
|
109
|
-
data: modifiedValues,
|
|
110
|
-
id: recordId,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
for (const control of editableGridControls) {
|
|
115
|
-
const gridSchema = getSchema(control.logicalName);
|
|
116
|
-
const gridRows = values[control.attributeName] as any[];
|
|
117
|
-
const initialGridRows = (initialValues as any)[
|
|
118
|
-
control.attributeName
|
|
119
|
-
] as any[];
|
|
120
|
-
|
|
121
|
-
const newRows = gridRows.filter((x) => !x[gridSchema.idAttribute]);
|
|
122
|
-
const updatedRows = gridRows.filter((x) => x[gridSchema.idAttribute]);
|
|
123
|
-
const deletedIds = initialGridRows
|
|
124
|
-
?.map((x) => x[gridSchema.idAttribute])
|
|
125
|
-
.filter(
|
|
126
|
-
(id) => !gridRows.find((x) => x[gridSchema.idAttribute] === id)
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
for (const row of newRows) {
|
|
130
|
-
operations.push({
|
|
131
|
-
type: 'create',
|
|
132
|
-
logicalName: control.logicalName,
|
|
133
|
-
data: {
|
|
134
|
-
...row,
|
|
135
|
-
[control.referenceAttribute]: {
|
|
136
|
-
id: recordId,
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
for (const row of updatedRows) {
|
|
143
|
-
const initialRow = initialGridRows.find(
|
|
144
|
-
(x) => x[gridSchema.idAttribute] === row[gridSchema.idAttribute]
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
if (!initialRow) {
|
|
148
|
-
throw new Error('Initial row not found');
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const modifiedRow = getModifiedValues(initialRow, row);
|
|
152
|
-
|
|
153
|
-
if (!Object.keys(modifiedRow).length) {
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
operations.push({
|
|
158
|
-
type: 'update',
|
|
159
|
-
logicalName: control.logicalName,
|
|
160
|
-
data: modifiedRow,
|
|
161
|
-
id: row[gridSchema.idAttribute],
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
for (const id of deletedIds) {
|
|
166
|
-
operations.push({
|
|
167
|
-
type: 'delete',
|
|
168
|
-
logicalName: control.logicalName,
|
|
169
|
-
id,
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (!operations.length) {
|
|
175
|
-
return {
|
|
176
|
-
success: false,
|
|
177
|
-
title: 'No changes',
|
|
178
|
-
message: 'No changes made to the record',
|
|
179
|
-
isError: false,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (operations.length > 0) {
|
|
184
|
-
console.log('operations', operations);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
for (const operation of operations) {
|
|
188
|
-
switch (operation.type) {
|
|
189
|
-
case 'create':
|
|
190
|
-
await dataService.createRecord(operation.logicalName, operation.data);
|
|
191
|
-
break;
|
|
192
|
-
case 'update':
|
|
193
|
-
await dataService.updateRecord(
|
|
194
|
-
operation.logicalName,
|
|
195
|
-
operation.id!,
|
|
196
|
-
operation.data
|
|
197
|
-
);
|
|
198
|
-
break;
|
|
199
|
-
case 'delete':
|
|
200
|
-
await dataService.deleteRecord(operation.logicalName, operation.id!);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
} else {
|
|
204
|
-
const result = await dataService.createRecord(schema.logicalName, values);
|
|
205
|
-
|
|
206
|
-
recordId = (result as any)[schema.idAttribute] as string;
|
|
207
|
-
|
|
208
|
-
for (const control of editableGridControls) {
|
|
209
|
-
const gridRows = values[control.attributeName] as any[];
|
|
210
|
-
|
|
211
|
-
for (const row of gridRows) {
|
|
212
|
-
await dataService.createRecord(control.logicalName, {
|
|
213
|
-
...row,
|
|
214
|
-
[control.referenceAttribute]: {
|
|
215
|
-
id: recordId,
|
|
216
|
-
},
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return {
|
|
223
|
-
success: true,
|
|
224
|
-
recordId,
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export function getInitialValues({
|
|
229
|
-
cloneRecord,
|
|
230
|
-
form,
|
|
231
|
-
record,
|
|
232
|
-
recordId,
|
|
233
|
-
defaultParameters,
|
|
234
|
-
}: {
|
|
235
|
-
cloneRecord: InferredSchemaType<SchemaAttributes> | undefined;
|
|
236
|
-
form: Form<SchemaAttributes>;
|
|
237
|
-
record: InferredSchemaType<SchemaAttributes> | undefined;
|
|
238
|
-
recordId: string | undefined;
|
|
239
|
-
schema: Schema<SchemaAttributes>;
|
|
240
|
-
defaultParameters: Record<string, any>;
|
|
241
|
-
}) {
|
|
242
|
-
const formColumns = getColumns(form);
|
|
243
|
-
const editableGridControls = getControls(form).filter(
|
|
244
|
-
(control) => control.type === 'editablegrid'
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
const allColumns = [
|
|
248
|
-
...formColumns,
|
|
249
|
-
...editableGridControls.map((x) => x.attributeName),
|
|
250
|
-
];
|
|
251
|
-
|
|
252
|
-
if (!recordId && !record && form.experience.cloneAttributes && cloneRecord) {
|
|
253
|
-
const cloneAttributesObj = form.experience.cloneAttributes.reduce(
|
|
254
|
-
(acc, item) => {
|
|
255
|
-
if (typeof item === 'string') {
|
|
256
|
-
acc[item] = item;
|
|
257
|
-
}
|
|
258
|
-
// TODO:
|
|
259
|
-
// else if (isEditableGridCloneAttribute(item)) {
|
|
260
|
-
// acc[item.attributeName] = item;
|
|
261
|
-
// }
|
|
262
|
-
|
|
263
|
-
return acc;
|
|
264
|
-
},
|
|
265
|
-
{} as Record<string, any>
|
|
266
|
-
);
|
|
267
|
-
|
|
268
|
-
return allColumns.reduce((acc, column) => {
|
|
269
|
-
const cloneAttributeInfo = cloneAttributesObj[column] as string;
|
|
270
|
-
// | EditableGridCloneAttribute; // TODO:
|
|
271
|
-
|
|
272
|
-
let value: unknown = null;
|
|
273
|
-
|
|
274
|
-
if (cloneAttributeInfo) {
|
|
275
|
-
if (typeof cloneAttributeInfo === 'string') {
|
|
276
|
-
value = cloneRecord[cloneAttributeInfo];
|
|
277
|
-
}
|
|
278
|
-
// else {
|
|
279
|
-
// const rows = cloneRecord[cloneAttributeInfo.attributeName] as any[];
|
|
280
|
-
|
|
281
|
-
// if (!rows?.length) {
|
|
282
|
-
// value = [];
|
|
283
|
-
// } else {
|
|
284
|
-
// value = rows.map((row) => {
|
|
285
|
-
// return Object.keys(row).reduce((p, c) => {
|
|
286
|
-
// if (c === '_id') {
|
|
287
|
-
// return p;
|
|
288
|
-
// }
|
|
289
|
-
|
|
290
|
-
// if (cloneAttributeInfo.attributes.includes(c)) {
|
|
291
|
-
// p[c] = row[c];
|
|
292
|
-
// } else {
|
|
293
|
-
// p[c] = null;
|
|
294
|
-
// }
|
|
295
|
-
|
|
296
|
-
// return p;
|
|
297
|
-
// }, {} as Record<string, any>);
|
|
298
|
-
// });
|
|
299
|
-
// }
|
|
300
|
-
// }
|
|
301
|
-
} else {
|
|
302
|
-
value = defaultParameters[column] ?? null;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return {
|
|
306
|
-
...acc,
|
|
307
|
-
[column]: value,
|
|
308
|
-
};
|
|
309
|
-
}, {} as Nullable<InferredSchemaType<SchemaAttributes>>);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return allColumns.reduce((acc, column) => {
|
|
313
|
-
const value = record ? record[column] : defaultParameters[column] ?? null;
|
|
314
|
-
return {
|
|
315
|
-
...acc,
|
|
316
|
-
[column]: value,
|
|
317
|
-
};
|
|
318
|
-
}, {} as Nullable<InferredSchemaType<SchemaAttributes>>);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
interface FormValidatorOptions<A extends SchemaAttributes = SchemaAttributes> {
|
|
322
|
-
schema: Schema<A>;
|
|
323
|
-
form: Form<A>;
|
|
324
|
-
language: string;
|
|
325
|
-
formReadOnly?: boolean;
|
|
326
|
-
readonlyAttributes?: string[];
|
|
327
|
-
strings: FormValidationStringSet;
|
|
328
|
-
getSchema: (logicalName: string) => Schema;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
type FormValidator = (<A extends SchemaAttributes = SchemaAttributes>(
|
|
332
|
-
options: FormValidatorOptions<A>
|
|
333
|
-
) => (
|
|
334
|
-
values: Record<string, any>,
|
|
335
|
-
context: any,
|
|
336
|
-
options: any
|
|
337
|
-
) => Promise<ResolverResult<{}>>) &
|
|
338
|
-
MemoizedFunction;
|
|
339
|
-
|
|
340
|
-
export const formValidator: FormValidator = memoize(
|
|
341
|
-
function formValidator<A extends SchemaAttributes = SchemaAttributes>({
|
|
342
|
-
form,
|
|
343
|
-
schema,
|
|
344
|
-
readonlyAttributes,
|
|
345
|
-
formReadOnly,
|
|
346
|
-
getSchema,
|
|
347
|
-
language,
|
|
348
|
-
strings,
|
|
349
|
-
}: FormValidatorOptions<A>) {
|
|
350
|
-
return async (values: Record<string, any>, context: any, options: any) => {
|
|
351
|
-
// console.log('formValidator', values);
|
|
352
|
-
let validator = yup.object().shape({});
|
|
353
|
-
|
|
354
|
-
if (!formReadOnly) {
|
|
355
|
-
const activeControls = form.experience.tabs
|
|
356
|
-
.flatMap((tab) => tab.tabColumns)
|
|
357
|
-
.flatMap((tabColumn) => tabColumn.sections)
|
|
358
|
-
.flatMap((section) => {
|
|
359
|
-
return section.controls;
|
|
360
|
-
})
|
|
361
|
-
.filter((control) => {
|
|
362
|
-
if (control.type === 'standard') {
|
|
363
|
-
const attribute = schema.attributes[control.attributeName];
|
|
364
|
-
if (attribute.readonly) {
|
|
365
|
-
return false;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
return true;
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
const editableGridControls = activeControls.filter(
|
|
372
|
-
(control) => control.type === 'editablegrid'
|
|
373
|
-
);
|
|
374
|
-
|
|
375
|
-
const columns = Array.from(
|
|
376
|
-
new Set([
|
|
377
|
-
schema.primaryAttribute,
|
|
378
|
-
...activeControls
|
|
379
|
-
.filter((control) => control.type === 'standard')
|
|
380
|
-
.map((control) => control.attributeName),
|
|
381
|
-
])
|
|
382
|
-
);
|
|
383
|
-
|
|
384
|
-
validator = generateValidationSchema({
|
|
385
|
-
editableGrids: editableGridControls.map((control) => {
|
|
386
|
-
if (control.type !== 'editablegrid') {
|
|
387
|
-
throw new Error('Invalid control type');
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
const schema = getSchema(control.logicalName);
|
|
391
|
-
|
|
392
|
-
return {
|
|
393
|
-
columns: control.attributes,
|
|
394
|
-
schema: schema,
|
|
395
|
-
attributeName: control.attributeName,
|
|
396
|
-
required: control.required,
|
|
397
|
-
};
|
|
398
|
-
}),
|
|
399
|
-
schema,
|
|
400
|
-
columns: columns as string[],
|
|
401
|
-
language,
|
|
402
|
-
strings,
|
|
403
|
-
readonlyAttributes,
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
const resolver = yupResolver(validator);
|
|
408
|
-
|
|
409
|
-
const result = await resolver(values, context, options);
|
|
410
|
-
|
|
411
|
-
// console.log(result);
|
|
412
|
-
|
|
413
|
-
return result;
|
|
414
|
-
};
|
|
415
|
-
},
|
|
416
|
-
({ form, language, schema, strings, readonlyAttributes, formReadOnly }) =>
|
|
417
|
-
JSON.stringify({
|
|
418
|
-
schema,
|
|
419
|
-
form,
|
|
420
|
-
language,
|
|
421
|
-
strings,
|
|
422
|
-
readonlyAttributes,
|
|
423
|
-
formReadOnly,
|
|
424
|
-
})
|
|
425
|
-
);
|
|
426
|
-
|
|
427
|
-
export const generateValidationSchema = memoize(
|
|
428
|
-
function generateValidationSchema<
|
|
429
|
-
A extends SchemaAttributes = SchemaAttributes
|
|
430
|
-
>({
|
|
431
|
-
columns,
|
|
432
|
-
editableGrids,
|
|
433
|
-
language,
|
|
434
|
-
schema,
|
|
435
|
-
strings,
|
|
436
|
-
readonlyAttributes,
|
|
437
|
-
}: {
|
|
438
|
-
schema: Schema<A>;
|
|
439
|
-
columns: string[];
|
|
440
|
-
readonlyAttributes?: string[];
|
|
441
|
-
editableGrids:
|
|
442
|
-
| Array<{
|
|
443
|
-
schema: Schema;
|
|
444
|
-
columns: string[];
|
|
445
|
-
attributeName: string;
|
|
446
|
-
required?: boolean;
|
|
447
|
-
}>
|
|
448
|
-
| undefined;
|
|
449
|
-
language: string;
|
|
450
|
-
strings: FormValidationStringSet;
|
|
451
|
-
}) {
|
|
452
|
-
return yup.object().shape({
|
|
453
|
-
...(columns.reduce((acc, column) => {
|
|
454
|
-
if (readonlyAttributes?.includes(column)) {
|
|
455
|
-
return acc;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
const attribute = schema.attributes[column];
|
|
459
|
-
|
|
460
|
-
const validationSchema = generateAttributeValidationSchema(
|
|
461
|
-
attribute,
|
|
462
|
-
language,
|
|
463
|
-
strings
|
|
464
|
-
);
|
|
465
|
-
|
|
466
|
-
return {
|
|
467
|
-
...acc,
|
|
468
|
-
[column]: validationSchema,
|
|
469
|
-
};
|
|
470
|
-
}, {} as Record<string, yup.Schema<any>>) as any),
|
|
471
|
-
...editableGrids?.reduce((acc, grid) => {
|
|
472
|
-
let validationSchema = yup
|
|
473
|
-
.array()
|
|
474
|
-
.of(
|
|
475
|
-
yup.object().shape({
|
|
476
|
-
...grid.columns.reduce((acc, column) => {
|
|
477
|
-
const attribute = grid.schema.attributes[column];
|
|
478
|
-
|
|
479
|
-
const validationSchema = generateAttributeValidationSchema(
|
|
480
|
-
attribute,
|
|
481
|
-
language,
|
|
482
|
-
strings
|
|
483
|
-
);
|
|
484
|
-
|
|
485
|
-
return {
|
|
486
|
-
...acc,
|
|
487
|
-
[column]: validationSchema,
|
|
488
|
-
};
|
|
489
|
-
}, {} as Record<string, yup.Schema<any>>),
|
|
490
|
-
})
|
|
491
|
-
)
|
|
492
|
-
.nullable();
|
|
493
|
-
|
|
494
|
-
if (grid.required) {
|
|
495
|
-
validationSchema = validationSchema
|
|
496
|
-
.required(strings.atLeastOneRowRequired)
|
|
497
|
-
.min(1, strings.atLeastOneRowRequired);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
acc[grid.attributeName] = validationSchema;
|
|
501
|
-
|
|
502
|
-
return acc;
|
|
503
|
-
}, {} as Record<string, yup.Schema<any>>),
|
|
504
|
-
});
|
|
505
|
-
},
|
|
506
|
-
({ columns, editableGrids, language, schema, strings, readonlyAttributes }) =>
|
|
507
|
-
JSON.stringify({
|
|
508
|
-
schema,
|
|
509
|
-
columns,
|
|
510
|
-
editableGrids,
|
|
511
|
-
language,
|
|
512
|
-
strings,
|
|
513
|
-
readonlyAttributes,
|
|
514
|
-
})
|
|
515
|
-
);
|
|
516
|
-
|
|
517
|
-
export const generateAttributeValidationSchema = memoize(
|
|
518
|
-
function generateAttributeValidationSchema(
|
|
519
|
-
attribute: Attribute,
|
|
520
|
-
language: string,
|
|
521
|
-
strings: FormValidationStringSet
|
|
522
|
-
) {
|
|
523
|
-
let validationSchema: yup.Schema;
|
|
524
|
-
|
|
525
|
-
switch (attribute.type) {
|
|
526
|
-
case 'string':
|
|
527
|
-
validationSchema = yup.string().nullable();
|
|
528
|
-
break;
|
|
529
|
-
case 'number':
|
|
530
|
-
validationSchema = yup.number().nullable();
|
|
531
|
-
break;
|
|
532
|
-
default:
|
|
533
|
-
validationSchema = yup.mixed().nullable();
|
|
534
|
-
break;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
const label = localizedLabel(language, attribute);
|
|
538
|
-
|
|
539
|
-
if (attribute.required) {
|
|
540
|
-
validationSchema = validationSchema.required(
|
|
541
|
-
`${label}: ${strings.required}`
|
|
542
|
-
);
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
switch (attribute.type) {
|
|
546
|
-
case 'string':
|
|
547
|
-
if (attribute.maxLength) {
|
|
548
|
-
validationSchema = (validationSchema as yup.StringSchema).max(
|
|
549
|
-
attribute.maxLength,
|
|
550
|
-
`${label}: ${strings.maxLength}`
|
|
551
|
-
);
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
if (attribute.minLength) {
|
|
555
|
-
validationSchema = (validationSchema as yup.StringSchema).min(
|
|
556
|
-
attribute.minLength,
|
|
557
|
-
`${label}: ${strings.minLength}`
|
|
558
|
-
);
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
if (attribute.pattern) {
|
|
562
|
-
validationSchema = (validationSchema as yup.StringSchema).matches(
|
|
563
|
-
new RegExp(attribute.pattern),
|
|
564
|
-
`${label}: ${strings.invalidFormat}`
|
|
565
|
-
);
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
if (attribute.format === 'email') {
|
|
569
|
-
validationSchema = (validationSchema as yup.StringSchema).email(
|
|
570
|
-
`${label}: ${strings.invalidEmail}`
|
|
571
|
-
);
|
|
572
|
-
} else if (attribute.format === 'phone') {
|
|
573
|
-
validationSchema = (validationSchema as yup.StringSchema).matches(
|
|
574
|
-
/^(\+\d{1,2}\s?)?\d{10}$/,
|
|
575
|
-
`${label}: ${strings.invalidPhoneNumber}`
|
|
576
|
-
);
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
break;
|
|
580
|
-
default:
|
|
581
|
-
break;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
validationSchema = validationSchema.transform((value) => {
|
|
585
|
-
if (value === '') {
|
|
586
|
-
return null;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
return value;
|
|
590
|
-
});
|
|
591
|
-
|
|
592
|
-
return validationSchema;
|
|
593
|
-
}
|
|
594
|
-
);
|