@headless-adminapp/app 0.0.8-0.0.9-alpha.1.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/LICENSE +21 -0
- package/dist/app/context.d.ts +8 -0
- package/dist/app/context.js +5 -0
- package/dist/app/hooks/index.d.ts +1 -0
- package/dist/app/hooks/index.js +17 -0
- package/dist/app/hooks/useAppContext.d.ts +2 -0
- package/dist/app/hooks/useAppContext.js +12 -0
- package/dist/app/index.d.ts +2 -0
- package/dist/app/index.js +7 -0
- package/dist/appearance/context.d.ts +7 -0
- package/dist/appearance/context.js +5 -0
- package/dist/appearance/hooks/index.d.ts +1 -0
- package/dist/appearance/hooks/index.js +17 -0
- package/dist/appearance/hooks/useAppearanceContext.d.ts +1 -0
- package/dist/appearance/hooks/useAppearanceContext.js +12 -0
- package/dist/appearance/index.d.ts +2 -0
- package/dist/appearance/index.js +20 -0
- package/dist/auth/AuthProvider.d.ts +7 -0
- package/dist/auth/AuthProvider.js +104 -0
- package/dist/auth/context.d.ts +30 -0
- package/dist/auth/context.js +5 -0
- package/dist/auth/hooks/index.d.ts +2 -0
- package/dist/auth/hooks/index.js +18 -0
- package/dist/auth/hooks/useAuthSession.d.ts +2 -0
- package/dist/auth/hooks/useAuthSession.js +16 -0
- package/dist/auth/hooks/useLogout.d.ts +1 -0
- package/dist/auth/hooks/useLogout.js +19 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.js +23 -0
- package/dist/auth/types.d.ts +10 -0
- package/dist/auth/types.js +2 -0
- package/dist/builders/CommandBuilder.d.ts +176 -0
- package/dist/builders/CommandBuilder.js +474 -0
- package/dist/builders/SchemaExperienceBuilder.d.ts +69 -0
- package/dist/builders/SchemaExperienceBuilder.js +267 -0
- package/dist/builders/index.d.ts +2 -0
- package/dist/builders/index.js +7 -0
- package/dist/command/hooks/index.d.ts +2 -0
- package/dist/command/hooks/index.js +18 -0
- package/dist/command/hooks/useBaseCommandHandlerContext.d.ts +4 -0
- package/dist/command/hooks/useBaseCommandHandlerContext.js +42 -0
- package/dist/command/hooks/useCommands.d.ts +7 -0
- package/dist/command/hooks/useCommands.js +16 -0
- package/dist/command/index.d.ts +2 -0
- package/dist/command/index.js +18 -0
- package/dist/command/types.d.ts +76 -0
- package/dist/command/types.js +2 -0
- package/dist/command/utils/index.d.ts +3 -0
- package/dist/command/utils/index.js +63 -0
- package/dist/components/ScrollView/index.d.ts +10 -0
- package/dist/components/ScrollView/index.js +11 -0
- package/dist/dataform/DataFormProvider/DataResolver.d.ts +5 -0
- package/dist/dataform/DataFormProvider/DataResolver.js +143 -0
- package/dist/dataform/DataFormProvider/InitialValueResolver.d.ts +1 -0
- package/dist/dataform/DataFormProvider/InitialValueResolver.js +44 -0
- package/dist/dataform/DataFormProvider/ReadonlyInfoResolver.d.ts +3 -0
- package/dist/dataform/DataFormProvider/ReadonlyInfoResolver.js +27 -0
- package/dist/dataform/DataFormProvider/index.d.ts +10 -0
- package/dist/dataform/DataFormProvider/index.js +72 -0
- package/dist/dataform/context.d.ts +22 -0
- package/dist/dataform/context.js +5 -0
- package/dist/dataform/hooks/index.d.ts +11 -0
- package/dist/dataform/hooks/index.js +27 -0
- package/dist/dataform/hooks/useFormInstance.d.ts +1 -0
- package/dist/dataform/hooks/useFormInstance.js +8 -0
- package/dist/dataform/hooks/useFormIsDirty.d.ts +1 -0
- package/dist/dataform/hooks/useFormIsDirty.js +8 -0
- package/dist/dataform/hooks/useFormIsReadonly.d.ts +1 -0
- package/dist/dataform/hooks/useFormIsReadonly.js +9 -0
- package/dist/dataform/hooks/useFormNotifications.d.ts +4 -0
- package/dist/dataform/hooks/useFormNotifications.js +34 -0
- package/dist/dataform/hooks/useFormRecord.d.ts +1 -0
- package/dist/dataform/hooks/useFormRecord.js +9 -0
- package/dist/dataform/hooks/useFormSave.d.ts +2 -0
- package/dist/dataform/hooks/useFormSave.js +135 -0
- package/dist/dataform/hooks/useFormSchema.d.ts +2 -0
- package/dist/dataform/hooks/useFormSchema.js +8 -0
- package/dist/dataform/hooks/useLoadFormGridPage.d.ts +18 -0
- package/dist/dataform/hooks/useLoadFormGridPage.js +73 -0
- package/dist/dataform/hooks/useMainFormCommands.d.ts +16 -0
- package/dist/dataform/hooks/useMainFormCommands.js +47 -0
- package/dist/dataform/hooks/useRecordId.d.ts +1 -0
- package/dist/dataform/hooks/useRecordId.js +8 -0
- package/dist/dataform/hooks/useRecordTitle.d.ts +1 -0
- package/dist/dataform/hooks/useRecordTitle.js +20 -0
- package/dist/dataform/hooks/useSelectedForm.d.ts +3 -0
- package/dist/dataform/hooks/useSelectedForm.js +8 -0
- package/dist/dataform/utils/index.d.ts +62 -0
- package/dist/dataform/utils/index.js +356 -0
- package/dist/datagrid/DataGridProvider/DataResolver.d.ts +2 -0
- package/dist/datagrid/DataGridProvider/DataResolver.js +208 -0
- package/dist/datagrid/DataGridProvider/index.d.ts +18 -0
- package/dist/datagrid/DataGridProvider/index.js +77 -0
- package/dist/datagrid/DataGridProvider/transformViewColumns.d.ts +5 -0
- package/dist/datagrid/DataGridProvider/transformViewColumns.js +29 -0
- package/dist/datagrid/DataGridProvider/utils.d.ts +3 -0
- package/dist/datagrid/DataGridProvider/utils.js +74 -0
- package/dist/datagrid/column-filter/constants.d.ts +4 -0
- package/dist/datagrid/column-filter/constants.js +482 -0
- package/dist/datagrid/column-filter/index.d.ts +3 -0
- package/dist/datagrid/column-filter/index.js +7 -0
- package/dist/datagrid/column-filter/types.d.ts +65 -0
- package/dist/datagrid/column-filter/types.js +2 -0
- package/dist/datagrid/column-filter/utils.d.ts +3 -0
- package/dist/datagrid/column-filter/utils.js +8 -0
- package/dist/datagrid/context.d.ts +33 -0
- package/dist/datagrid/context.js +5 -0
- package/dist/datagrid/hooks/index.d.ts +19 -0
- package/dist/datagrid/hooks/index.js +35 -0
- package/dist/datagrid/hooks/useChangeView.d.ts +1 -0
- package/dist/datagrid/hooks/useChangeView.js +12 -0
- package/dist/datagrid/hooks/useGridColumnFilter.d.ts +2 -0
- package/dist/datagrid/hooks/useGridColumnFilter.js +16 -0
- package/dist/datagrid/hooks/useGridColumns.d.ts +3 -0
- package/dist/datagrid/hooks/useGridColumns.js +8 -0
- package/dist/datagrid/hooks/useGridCommands.d.ts +3 -0
- package/dist/datagrid/hooks/useGridCommands.js +9 -0
- package/dist/datagrid/hooks/useGridData.d.ts +1 -0
- package/dist/datagrid/hooks/useGridData.js +9 -0
- package/dist/datagrid/hooks/useGridDataState.d.ts +5 -0
- package/dist/datagrid/hooks/useGridDataState.js +9 -0
- package/dist/datagrid/hooks/useGridExtraFilter.d.ts +1 -0
- package/dist/datagrid/hooks/useGridExtraFilter.js +8 -0
- package/dist/datagrid/hooks/useGridOptions.d.ts +1 -0
- package/dist/datagrid/hooks/useGridOptions.js +6 -0
- package/dist/datagrid/hooks/useGridPagination.d.ts +1 -0
- package/dist/datagrid/hooks/useGridPagination.js +6 -0
- package/dist/datagrid/hooks/useGridRefresh.d.ts +1 -0
- package/dist/datagrid/hooks/useGridRefresh.js +18 -0
- package/dist/datagrid/hooks/useGridSchema.d.ts +2 -0
- package/dist/datagrid/hooks/useGridSchema.js +8 -0
- package/dist/datagrid/hooks/useGridSelection.d.ts +1 -0
- package/dist/datagrid/hooks/useGridSelection.js +21 -0
- package/dist/datagrid/hooks/useGridSorting.d.ts +3 -0
- package/dist/datagrid/hooks/useGridSorting.js +14 -0
- package/dist/datagrid/hooks/useGridViewLookupData.d.ts +1 -0
- package/dist/datagrid/hooks/useGridViewLookupData.js +9 -0
- package/dist/datagrid/hooks/useLoadMainGridPage.d.ts +20 -0
- package/dist/datagrid/hooks/useLoadMainGridPage.js +55 -0
- package/dist/datagrid/hooks/useMainGridCommands.d.ts +19 -0
- package/dist/datagrid/hooks/useMainGridCommands.js +228 -0
- package/dist/datagrid/hooks/useMaxRecords.d.ts +1 -0
- package/dist/datagrid/hooks/useMaxRecords.js +8 -0
- package/dist/datagrid/hooks/useSearchText.d.ts +1 -0
- package/dist/datagrid/hooks/useSearchText.js +14 -0
- package/dist/datagrid/hooks/useSelectedView.d.ts +3 -0
- package/dist/datagrid/hooks/useSelectedView.js +8 -0
- package/dist/datagrid/hooks/useSubGridCommands.d.ts +5 -0
- package/dist/datagrid/hooks/useSubGridCommands.js +87 -0
- package/dist/dialog/DialogProvider.d.ts +5 -0
- package/dist/dialog/DialogProvider.js +13 -0
- package/dist/dialog/context.d.ts +6 -0
- package/dist/dialog/context.js +5 -0
- package/dist/dialog/hooks/index.d.ts +8 -0
- package/dist/dialog/hooks/index.js +24 -0
- package/dist/dialog/hooks/useCloseDialog.d.ts +1 -0
- package/dist/dialog/hooks/useCloseDialog.js +30 -0
- package/dist/dialog/hooks/useDialogItem.d.ts +1 -0
- package/dist/dialog/hooks/useDialogItem.js +8 -0
- package/dist/dialog/hooks/useDialogItems.d.ts +1 -0
- package/dist/dialog/hooks/useDialogItems.js +8 -0
- package/dist/dialog/hooks/useOpenAlertDialog.d.ts +2 -0
- package/dist/dialog/hooks/useOpenAlertDialog.js +20 -0
- package/dist/dialog/hooks/useOpenConfirmDialog.d.ts +2 -0
- package/dist/dialog/hooks/useOpenConfirmDialog.js +26 -0
- package/dist/dialog/hooks/useOpenDialog.d.ts +5 -0
- package/dist/dialog/hooks/useOpenDialog.js +27 -0
- package/dist/dialog/hooks/useOpenErrorDialog.d.ts +2 -0
- package/dist/dialog/hooks/useOpenErrorDialog.js +16 -0
- package/dist/dialog/hooks/useOpenPromptDialog.d.ts +3 -0
- package/dist/dialog/hooks/useOpenPromptDialog.js +26 -0
- package/dist/dialog/index.d.ts +3 -0
- package/dist/dialog/index.js +22 -0
- package/dist/form/FormValidationStringContext.d.ts +12 -0
- package/dist/form/FormValidationStringContext.js +19 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.js +21 -0
- package/dist/hooks/useDebouncedValue.d.ts +3 -0
- package/dist/hooks/useDebouncedValue.js +32 -0
- package/dist/hooks/useElementLayout.d.ts +7 -0
- package/dist/hooks/useElementLayout.js +34 -0
- package/dist/hooks/useIsMobile.d.ts +1 -0
- package/dist/hooks/useIsMobile.js +21 -0
- package/dist/hooks/useStorageState.d.ts +2 -0
- package/dist/hooks/useStorageState.js +26 -0
- package/dist/hooks/useSystemColorScheme.d.ts +1 -0
- package/dist/hooks/useSystemColorScheme.js +27 -0
- package/dist/insights/context.d.ts +2 -0
- package/dist/insights/context.js +5 -0
- package/dist/locale/context.d.ts +2 -0
- package/dist/locale/context.js +5 -0
- package/dist/locale/index.d.ts +3 -0
- package/dist/locale/index.js +21 -0
- package/dist/locale/types.d.ts +2 -0
- package/dist/locale/types.js +2 -0
- package/dist/locale/useLocale.d.ts +1 -0
- package/dist/locale/useLocale.js +12 -0
- package/dist/metadata/MetadataProvider.d.ts +9 -0
- package/dist/metadata/MetadataProvider.js +29 -0
- package/dist/metadata/context.d.ts +7 -0
- package/dist/metadata/context.js +5 -0
- package/dist/metadata/hooks/index.d.ts +8 -0
- package/dist/metadata/hooks/index.js +24 -0
- package/dist/metadata/hooks/useAppStore.d.ts +1 -0
- package/dist/metadata/hooks/useAppStore.js +8 -0
- package/dist/metadata/hooks/useExperienceStore.d.ts +1 -0
- package/dist/metadata/hooks/useExperienceStore.js +8 -0
- package/dist/metadata/hooks/useExperienceView.d.ts +4 -0
- package/dist/metadata/hooks/useExperienceView.js +37 -0
- package/dist/metadata/hooks/useExperienceViewCommands.d.ts +4 -0
- package/dist/metadata/hooks/useExperienceViewCommands.js +28 -0
- package/dist/metadata/hooks/useExperienceViewLookup.d.ts +4 -0
- package/dist/metadata/hooks/useExperienceViewLookup.js +36 -0
- package/dist/metadata/hooks/useExperienceViewSubgridCommands.d.ts +4 -0
- package/dist/metadata/hooks/useExperienceViewSubgridCommands.js +28 -0
- package/dist/metadata/hooks/useMetadata.d.ts +9 -0
- package/dist/metadata/hooks/useMetadata.js +28 -0
- package/dist/metadata/hooks/useSchema.d.ts +2 -0
- package/dist/metadata/hooks/useSchema.js +8 -0
- package/dist/metadata/index.d.ts +3 -0
- package/dist/metadata/index.js +22 -0
- package/dist/mutable/context.d.ts +11 -0
- package/dist/mutable/context.js +46 -0
- package/dist/mutable/index.d.ts +3 -0
- package/dist/mutable/index.js +26 -0
- package/dist/mutable/state.d.ts +6 -0
- package/dist/mutable/state.js +12 -0
- package/dist/mutable/type.d.ts +11 -0
- package/dist/mutable/type.js +2 -0
- package/dist/mutable/utils.d.ts +3 -0
- package/dist/mutable/utils.js +62 -0
- package/dist/navigation/hooks/useOpenForm.d.ts +4 -0
- package/dist/navigation/hooks/useOpenForm.js +20 -0
- package/dist/progress-indicator/ProgressIndicatorProvider.d.ts +2 -0
- package/dist/progress-indicator/ProgressIndicatorProvider.js +54 -0
- package/dist/progress-indicator/context.d.ts +8 -0
- package/dist/progress-indicator/context.js +5 -0
- package/dist/progress-indicator/hooks/index.d.ts +1 -0
- package/dist/progress-indicator/hooks/index.js +17 -0
- package/dist/progress-indicator/hooks/useProgressIndicator.d.ts +1 -0
- package/dist/progress-indicator/hooks/useProgressIndicator.js +12 -0
- package/dist/progress-indicator/index.d.ts +3 -0
- package/dist/progress-indicator/index.js +22 -0
- package/dist/providers/PageEntityFormProvider/index.d.ts +11 -0
- package/dist/providers/PageEntityFormProvider/index.js +8 -0
- package/dist/providers/PageEntityViewProvider/index.d.ts +13 -0
- package/dist/providers/PageEntityViewProvider/index.js +8 -0
- package/dist/recordset/RecordSetProvider.d.ts +2 -0
- package/dist/recordset/RecordSetProvider.js +40 -0
- package/dist/recordset/context.d.ts +8 -0
- package/dist/recordset/context.js +5 -0
- package/dist/recordset/hooks/index.d.ts +3 -0
- package/dist/recordset/hooks/index.js +19 -0
- package/dist/recordset/hooks/useRecordSetResult.d.ts +7 -0
- package/dist/recordset/hooks/useRecordSetResult.js +81 -0
- package/dist/recordset/hooks/useRecordSetSetter.d.ts +1 -0
- package/dist/recordset/hooks/useRecordSetSetter.js +17 -0
- package/dist/recordset/hooks/useRecordSetVisibility.d.ts +1 -0
- package/dist/recordset/hooks/useRecordSetVisibility.js +16 -0
- package/dist/recordset/index.d.ts +3 -0
- package/dist/recordset/index.js +22 -0
- package/dist/route/RouteProvider.d.ts +13 -0
- package/dist/route/RouteProvider.js +24 -0
- package/dist/route/context.d.ts +23 -0
- package/dist/route/context.js +9 -0
- package/dist/route/hooks/index.d.ts +4 -0
- package/dist/route/hooks/index.js +20 -0
- package/dist/route/hooks/useBasePath.d.ts +1 -0
- package/dist/route/hooks/useBasePath.js +8 -0
- package/dist/route/hooks/usePathname.d.ts +1 -0
- package/dist/route/hooks/usePathname.js +8 -0
- package/dist/route/hooks/useRouteResolver.d.ts +1 -0
- package/dist/route/hooks/useRouteResolver.js +8 -0
- package/dist/route/hooks/useRouter.d.ts +1 -0
- package/dist/route/hooks/useRouter.js +8 -0
- package/dist/route/hooks/useSearchParams.d.ts +1 -0
- package/dist/route/hooks/useSearchParams.js +8 -0
- package/dist/route/index.d.ts +2 -0
- package/dist/route/index.js +20 -0
- package/dist/route/types.d.ts +2 -0
- package/dist/route/types.js +2 -0
- package/dist/store/ClientAppStore.d.ts +7 -0
- package/dist/store/ClientAppStore.js +30 -0
- package/dist/store/ComponentStore.d.ts +6 -0
- package/dist/store/ComponentStore.js +23 -0
- package/dist/store/EventManager.d.ts +7 -0
- package/dist/store/EventManager.js +42 -0
- package/dist/store/SchemaExperienceStore.d.ts +32 -0
- package/dist/store/SchemaExperienceStore.js +264 -0
- package/dist/store/index.d.ts +4 -0
- package/dist/store/index.js +20 -0
- package/dist/toast-notification/ToastNotificationProvider.d.ts +5 -0
- package/dist/toast-notification/ToastNotificationProvider.js +13 -0
- package/dist/toast-notification/context.d.ts +15 -0
- package/dist/toast-notification/context.js +5 -0
- package/dist/toast-notification/hooks/index.d.ts +3 -0
- package/dist/toast-notification/hooks/index.js +19 -0
- package/dist/toast-notification/hooks/useCloseToastNotification.d.ts +1 -0
- package/dist/toast-notification/hooks/useCloseToastNotification.js +30 -0
- package/dist/toast-notification/hooks/useOpenToastNotification.d.ts +5 -0
- package/dist/toast-notification/hooks/useOpenToastNotification.js +27 -0
- package/dist/toast-notification/hooks/useToastNotificationItems.d.ts +1 -0
- package/dist/toast-notification/hooks/useToastNotificationItems.js +8 -0
- package/dist/toast-notification/index.d.ts +3 -0
- package/dist/toast-notification/index.js +22 -0
- package/dist/transport/InMemoryDataService/index.d.ts +25 -0
- package/dist/transport/InMemoryDataService/index.js +112 -0
- package/dist/transport/RestDataService/index.d.ts +25 -0
- package/dist/transport/RestDataService/index.js +124 -0
- package/dist/transport/context.d.ts +2 -0
- package/dist/transport/context.js +5 -0
- package/dist/transport/hooks/index.d.ts +1 -0
- package/dist/transport/hooks/index.js +17 -0
- package/dist/transport/hooks/useDataService.d.ts +1 -0
- package/dist/transport/hooks/useDataService.js +12 -0
- package/dist/transport/index.d.ts +2 -0
- package/dist/transport/index.js +20 -0
- package/dist/utils/calculateColumnWidths.d.ts +14 -0
- package/dist/utils/calculateColumnWidths.js +46 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +17 -0
- package/dist/widget/context.d.ts +2 -0
- package/dist/widget/context.js +5 -0
- package/dist/widget/hooks/index.d.ts +3 -0
- package/dist/widget/hooks/index.js +8 -0
- package/dist/widget/index.d.ts +1 -0
- package/dist/widget/index.js +5 -0
- package/package.json +45 -0
- package/src/app/context.ts +11 -0
- package/src/app/hooks/index.ts +1 -0
- package/src/app/hooks/useAppContext.ts +13 -0
- package/src/app/index.ts +2 -0
- package/src/appearance/context.ts +13 -0
- package/src/appearance/hooks/index.ts +1 -0
- package/src/appearance/hooks/useAppearanceContext.ts +13 -0
- package/src/appearance/index.ts +6 -0
- package/src/auth/AuthProvider.tsx +118 -0
- package/src/auth/context.ts +41 -0
- package/src/auth/hooks/index.ts +2 -0
- package/src/auth/hooks/useAuthSession.ts +17 -0
- package/src/auth/hooks/useLogout.ts +23 -0
- package/src/auth/index.ts +4 -0
- package/src/auth/types.ts +17 -0
- package/src/builders/CommandBuilder.ts +777 -0
- package/src/builders/SchemaExperienceBuilder.ts +488 -0
- package/src/builders/index.ts +2 -0
- package/src/command/hooks/index.ts +2 -0
- package/src/command/hooks/useBaseCommandHandlerContext.ts +51 -0
- package/src/command/hooks/useCommands.ts +26 -0
- package/src/command/index.ts +2 -0
- package/src/command/types.ts +116 -0
- package/src/command/utils/index.ts +142 -0
- package/src/components/ScrollView/index.tsx +26 -0
- package/src/dataform/DataFormProvider/DataResolver.tsx +186 -0
- package/src/dataform/DataFormProvider/InitialValueResolver.tsx +55 -0
- package/src/dataform/DataFormProvider/ReadonlyInfoResolver.tsx +35 -0
- package/src/dataform/DataFormProvider/index.tsx +102 -0
- package/src/dataform/context.ts +53 -0
- package/src/dataform/hooks/index.ts +11 -0
- package/src/dataform/hooks/useFormInstance.ts +6 -0
- package/src/dataform/hooks/useFormIsDirty.ts +7 -0
- package/src/dataform/hooks/useFormIsReadonly.ts +11 -0
- package/src/dataform/hooks/useFormNotifications.ts +46 -0
- package/src/dataform/hooks/useFormRecord.ts +7 -0
- package/src/dataform/hooks/useFormSave.ts +147 -0
- package/src/dataform/hooks/useFormSchema.ts +13 -0
- package/src/dataform/hooks/useLoadFormGridPage.ts +97 -0
- package/src/dataform/hooks/useMainFormCommands.ts +65 -0
- package/src/dataform/hooks/useRecordId.ts +6 -0
- package/src/dataform/hooks/useRecordTitle.ts +22 -0
- package/src/dataform/hooks/useSelectedForm.ts +14 -0
- package/src/dataform/utils/index.ts +582 -0
- package/src/datagrid/DataGridProvider/DataResolver.tsx +281 -0
- package/src/datagrid/DataGridProvider/index.tsx +134 -0
- package/src/datagrid/DataGridProvider/transformViewColumns.ts +54 -0
- package/src/datagrid/DataGridProvider/utils.ts +89 -0
- package/src/datagrid/column-filter/constants.ts +493 -0
- package/src/datagrid/column-filter/index.ts +3 -0
- package/src/datagrid/column-filter/types.ts +68 -0
- package/src/datagrid/column-filter/utils.ts +19 -0
- package/src/datagrid/context.ts +66 -0
- package/src/datagrid/hooks/index.ts +19 -0
- package/src/datagrid/hooks/useChangeView.ts +18 -0
- package/src/datagrid/hooks/useGridColumnFilter.ts +28 -0
- package/src/datagrid/hooks/useGridColumns.ts +13 -0
- package/src/datagrid/hooks/useGridCommands.ts +21 -0
- package/src/datagrid/hooks/useGridData.ts +8 -0
- package/src/datagrid/hooks/useGridDataState.ts +8 -0
- package/src/datagrid/hooks/useGridExtraFilter.ts +6 -0
- package/src/datagrid/hooks/useGridOptions.ts +3 -0
- package/src/datagrid/hooks/useGridPagination.ts +3 -0
- package/src/datagrid/hooks/useGridRefresh.ts +19 -0
- package/src/datagrid/hooks/useGridSchema.ts +13 -0
- package/src/datagrid/hooks/useGridSelection.ts +28 -0
- package/src/datagrid/hooks/useGridSorting.ts +23 -0
- package/src/datagrid/hooks/useGridViewLookupData.ts +10 -0
- package/src/datagrid/hooks/useLoadMainGridPage.ts +90 -0
- package/src/datagrid/hooks/useMainGridCommands.ts +255 -0
- package/src/datagrid/hooks/useMaxRecords.ts +6 -0
- package/src/datagrid/hooks/useSearchText.ts +22 -0
- package/src/datagrid/hooks/useSelectedView.ts +14 -0
- package/src/datagrid/hooks/useSubGridCommands.ts +104 -0
- package/src/dialog/DialogProvider.tsx +20 -0
- package/src/dialog/context.ts +14 -0
- package/src/dialog/hooks/index.ts +8 -0
- package/src/dialog/hooks/useCloseDialog.ts +36 -0
- package/src/dialog/hooks/useDialogItem.ts +8 -0
- package/src/dialog/hooks/useDialogItems.ts +6 -0
- package/src/dialog/hooks/useOpenAlertDialog.ts +30 -0
- package/src/dialog/hooks/useOpenConfirmDialog.ts +45 -0
- package/src/dialog/hooks/useOpenDialog.ts +39 -0
- package/src/dialog/hooks/useOpenErrorDialog.ts +26 -0
- package/src/dialog/hooks/useOpenPromptDialog.ts +46 -0
- package/src/dialog/index.ts +7 -0
- package/src/form/FormValidationStringContext.ts +30 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useDebouncedValue.ts +38 -0
- package/src/hooks/useElementLayout.ts +49 -0
- package/src/hooks/useIsMobile.ts +21 -0
- package/src/hooks/useStorageState.ts +36 -0
- package/src/hooks/useSystemColorScheme.ts +38 -0
- package/src/index.css +4 -0
- package/src/insights/context.ts +5 -0
- package/src/locale/context.ts +7 -0
- package/src/locale/index.ts +3 -0
- package/src/locale/types.ts +3 -0
- package/src/locale/useLocale.ts +13 -0
- package/src/metadata/MetadataProvider.tsx +51 -0
- package/src/metadata/context.ts +15 -0
- package/src/metadata/hooks/index.ts +8 -0
- package/src/metadata/hooks/useAppStore.ts +6 -0
- package/src/metadata/hooks/useExperienceStore.ts +6 -0
- package/src/metadata/hooks/useExperienceView.ts +36 -0
- package/src/metadata/hooks/useExperienceViewCommands.ts +20 -0
- package/src/metadata/hooks/useExperienceViewLookup.ts +33 -0
- package/src/metadata/hooks/useExperienceViewSubgridCommands.ts +20 -0
- package/src/metadata/hooks/useMetadata.ts +44 -0
- package/src/metadata/hooks/useSchema.ts +11 -0
- package/src/metadata/index.ts +3 -0
- package/src/mutable/context.ts +71 -0
- package/src/mutable/index.ts +9 -0
- package/src/mutable/state.ts +13 -0
- package/src/mutable/type.ts +9 -0
- package/src/mutable/utils.ts +80 -0
- package/src/navigation/hooks/useOpenForm.ts +34 -0
- package/src/progress-indicator/ProgressIndicatorProvider.tsx +77 -0
- package/src/progress-indicator/context.ts +12 -0
- package/src/progress-indicator/hooks/index.ts +1 -0
- package/src/progress-indicator/hooks/useProgressIndicator.ts +15 -0
- package/src/progress-indicator/index.ts +6 -0
- package/src/providers/PageEntityFormProvider/index.tsx +34 -0
- package/src/providers/PageEntityViewProvider/index.tsx +39 -0
- package/src/recordset/RecordSetProvider.tsx +55 -0
- package/src/recordset/context.ts +12 -0
- package/src/recordset/hooks/index.ts +3 -0
- package/src/recordset/hooks/useRecordSetResult.ts +94 -0
- package/src/recordset/hooks/useRecordSetSetter.ts +21 -0
- package/src/recordset/hooks/useRecordSetVisibility.ts +24 -0
- package/src/recordset/index.ts +3 -0
- package/src/route/RouteProvider.tsx +76 -0
- package/src/route/context.ts +39 -0
- package/src/route/hooks/index.ts +4 -0
- package/src/route/hooks/useBasePath.ts +7 -0
- package/src/route/hooks/usePathname.ts +7 -0
- package/src/route/hooks/useRouteResolver.ts +7 -0
- package/src/route/hooks/useRouter.ts +7 -0
- package/src/route/hooks/useSearchParams.ts +7 -0
- package/src/route/index.ts +2 -0
- package/src/route/types.ts +1 -0
- package/src/store/ClientAppStore.ts +20 -0
- package/src/store/ComponentStore.tsx +22 -0
- package/src/store/EventManager.ts +33 -0
- package/src/store/SchemaExperienceStore.ts +374 -0
- package/src/store/index.ts +4 -0
- package/src/toast-notification/ToastNotificationProvider.tsx +23 -0
- package/src/toast-notification/context.ts +17 -0
- package/src/toast-notification/hooks/index.ts +3 -0
- package/src/toast-notification/hooks/useCloseToastNotification.ts +36 -0
- package/src/toast-notification/hooks/useOpenToastNotification.ts +38 -0
- package/src/toast-notification/hooks/useToastNotificationItems.ts +6 -0
- package/src/toast-notification/index.ts +7 -0
- package/src/transport/InMemoryDataService/index.ts +157 -0
- package/src/transport/RestDataService/index.ts +151 -0
- package/src/transport/context.ts +6 -0
- package/src/transport/hooks/index.ts +1 -0
- package/src/transport/hooks/useDataService.ts +13 -0
- package/src/transport/index.ts +2 -0
- package/src/utils/calculateColumnWidths.ts +72 -0
- package/src/utils/index.ts +1 -0
- package/src/widget/context.ts +5 -0
- package/src/widget/hooks/index.ts +11 -0
- package/src/widget/index.ts +1 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.useLoadFormGridPage = useLoadFormGridPage;
|
|
13
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
14
|
+
const hooks_1 = require("../../metadata/hooks");
|
|
15
|
+
function useLoadFormGridPage(logicalName, formId) {
|
|
16
|
+
const schema = (0, hooks_1.useSchema)(logicalName);
|
|
17
|
+
const experienceStore = (0, hooks_1.useExperienceStore)();
|
|
18
|
+
const { data: form, isFetching: isFetchingForm } = (0, react_query_1.useQuery)({
|
|
19
|
+
queryKey: ['experience-schema-form', logicalName, formId],
|
|
20
|
+
queryFn: () => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
return experienceStore.getForm(logicalName, formId);
|
|
22
|
+
}),
|
|
23
|
+
placeholderData: react_query_1.keepPreviousData,
|
|
24
|
+
});
|
|
25
|
+
const { data: commands } = (0, react_query_1.useQuery)({
|
|
26
|
+
queryKey: ['experience-schema-form-commands', logicalName],
|
|
27
|
+
queryFn: () => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
return experienceStore.getFormCommands(logicalName);
|
|
29
|
+
}),
|
|
30
|
+
initialData: [],
|
|
31
|
+
});
|
|
32
|
+
if (!schema) {
|
|
33
|
+
return {
|
|
34
|
+
loading: false,
|
|
35
|
+
error: true,
|
|
36
|
+
title: 'Schema not found',
|
|
37
|
+
message: 'The schema was not found',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (!form) {
|
|
41
|
+
if (isFetchingForm) {
|
|
42
|
+
return {
|
|
43
|
+
loading: true,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
loading: false,
|
|
48
|
+
error: true,
|
|
49
|
+
title: 'Form not found',
|
|
50
|
+
message: 'The form was not found',
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (form.logicalName !== schema.logicalName) {
|
|
54
|
+
if (isFetchingForm) {
|
|
55
|
+
return {
|
|
56
|
+
loading: true,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
loading: false,
|
|
61
|
+
error: true,
|
|
62
|
+
title: 'Form not found',
|
|
63
|
+
message: 'The form was not found (missmatch)',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
loading: false,
|
|
68
|
+
error: false,
|
|
69
|
+
schema,
|
|
70
|
+
form,
|
|
71
|
+
commands,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EntityFormCommandContext } from '@headless-adminapp/core/experience/form';
|
|
2
|
+
import { CommandItemState } from '../../command';
|
|
3
|
+
export declare function useFormControlContext(): {
|
|
4
|
+
data: any;
|
|
5
|
+
logicalName: string;
|
|
6
|
+
schema: import("@headless-adminapp/core/schema").Schema<import("@headless-adminapp/core/schema").SchemaAttributes>;
|
|
7
|
+
form: import("@headless-adminapp/core/experience/form").Form<import("@headless-adminapp/core/schema").SchemaAttributes>;
|
|
8
|
+
formId: string;
|
|
9
|
+
originalData: import("@headless-adminapp/core/transport").Data<import("@headless-adminapp/core/schema").InferredSchemaType<import("@headless-adminapp/core/schema").SchemaAttributes>> | null;
|
|
10
|
+
recordId: string | number;
|
|
11
|
+
refresh: () => Promise<void>;
|
|
12
|
+
save: (mode?: import("@headless-adminapp/core/experience/form").SaveMode) => Promise<void>;
|
|
13
|
+
readonly: boolean | undefined;
|
|
14
|
+
};
|
|
15
|
+
export declare function useMainFormCommandHandlerContext(): EntityFormCommandContext;
|
|
16
|
+
export declare function useMainFormCommands(): CommandItemState[][];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFormControlContext = useFormControlContext;
|
|
4
|
+
exports.useMainFormCommandHandlerContext = useMainFormCommandHandlerContext;
|
|
5
|
+
exports.useMainFormCommands = useMainFormCommands;
|
|
6
|
+
const command_1 = require("../../command");
|
|
7
|
+
const context_1 = require("../../mutable/context");
|
|
8
|
+
const context_2 = require("../context");
|
|
9
|
+
const useFormInstance_1 = require("./useFormInstance");
|
|
10
|
+
const useFormIsReadonly_1 = require("./useFormIsReadonly");
|
|
11
|
+
const useFormRecord_1 = require("./useFormRecord");
|
|
12
|
+
const useFormSave_1 = require("./useFormSave");
|
|
13
|
+
const useFormSchema_1 = require("./useFormSchema");
|
|
14
|
+
const useRecordId_1 = require("./useRecordId");
|
|
15
|
+
function useFormControlContext() {
|
|
16
|
+
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
17
|
+
const form = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.form);
|
|
18
|
+
const originalData = (0, useFormRecord_1.useFormRecord)();
|
|
19
|
+
const recordId = (0, useRecordId_1.useRecordId)();
|
|
20
|
+
const save = (0, useFormSave_1.useFormSave)();
|
|
21
|
+
const refresh = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.refresh);
|
|
22
|
+
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
23
|
+
const readonly = (0, useFormIsReadonly_1.useFormIsReadonly)();
|
|
24
|
+
const data = formInstance.watch();
|
|
25
|
+
return {
|
|
26
|
+
data,
|
|
27
|
+
logicalName: schema.logicalName,
|
|
28
|
+
schema,
|
|
29
|
+
form,
|
|
30
|
+
formId: form.id,
|
|
31
|
+
originalData: originalData !== null && originalData !== void 0 ? originalData : null,
|
|
32
|
+
recordId,
|
|
33
|
+
refresh,
|
|
34
|
+
save,
|
|
35
|
+
readonly,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function useMainFormCommandHandlerContext() {
|
|
39
|
+
const primaryControl = useFormControlContext();
|
|
40
|
+
const baseHandlerContext = (0, command_1.useBaseCommandHandlerContext)();
|
|
41
|
+
return Object.assign(Object.assign({}, baseHandlerContext), { primaryControl });
|
|
42
|
+
}
|
|
43
|
+
function useMainFormCommands() {
|
|
44
|
+
const commands = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.commands);
|
|
45
|
+
const handlerContext = useMainFormCommandHandlerContext();
|
|
46
|
+
return (0, command_1.useCommands)(commands, handlerContext);
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useRecordId<T extends string | number = string>(): T;
|
|
@@ -0,0 +1,8 @@
|
|
|
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);
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useRecordTitle(): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
var _a;
|
|
9
|
+
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
10
|
+
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
11
|
+
const recordId = (0, useRecordId_1.useRecordId)();
|
|
12
|
+
const primaryAttributeValue = (_a = formInstance.watch(schema.primaryAttribute)) !== null && _a !== void 0 ? _a : '';
|
|
13
|
+
if (primaryAttributeValue) {
|
|
14
|
+
return primaryAttributeValue;
|
|
15
|
+
}
|
|
16
|
+
if (recordId) {
|
|
17
|
+
return '(No name)';
|
|
18
|
+
}
|
|
19
|
+
return `New ${schema.label.toLowerCase()}`;
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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);
|
|
8
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Attribute } from '@headless-adminapp/core/attributes';
|
|
2
|
+
import { Form } from '@headless-adminapp/core/experience/form';
|
|
3
|
+
import { InferredSchemaType, Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
4
|
+
import { IDataService } from '@headless-adminapp/core/transport';
|
|
5
|
+
import { Nullable } from '@headless-adminapp/core/types';
|
|
6
|
+
import * as yup from 'yup';
|
|
7
|
+
import { FormValidationStringSet } from '../../form/FormValidationStringContext';
|
|
8
|
+
export declare function getModifiedValues(initialValues: any, values: any, exclude?: string[]): Record<string, any>;
|
|
9
|
+
type SaveRecordResult = {
|
|
10
|
+
success: true;
|
|
11
|
+
recordId: string;
|
|
12
|
+
} | {
|
|
13
|
+
success: false;
|
|
14
|
+
title?: string;
|
|
15
|
+
message: string;
|
|
16
|
+
isError: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare function saveRecord({ values, form, schema, dataService, initialValues, record, getSchema, }: {
|
|
19
|
+
values: any;
|
|
20
|
+
form: Form<SchemaAttributes>;
|
|
21
|
+
record: InferredSchemaType<SchemaAttributes> | undefined;
|
|
22
|
+
initialValues: Nullable<InferredSchemaType<SchemaAttributes>>;
|
|
23
|
+
schema: Schema<SchemaAttributes>;
|
|
24
|
+
dataService: IDataService;
|
|
25
|
+
getSchema: (logicalName: string) => Schema<SchemaAttributes>;
|
|
26
|
+
}): Promise<SaveRecordResult>;
|
|
27
|
+
export declare function getInitialValues({ cloneRecord, form, record, recordId, defaultParameters, }: {
|
|
28
|
+
cloneRecord: InferredSchemaType<SchemaAttributes> | undefined;
|
|
29
|
+
form: Form<SchemaAttributes>;
|
|
30
|
+
record: InferredSchemaType<SchemaAttributes> | undefined;
|
|
31
|
+
recordId: string | undefined;
|
|
32
|
+
schema: Schema<SchemaAttributes>;
|
|
33
|
+
defaultParameters: Record<string, any>;
|
|
34
|
+
}): Nullable<InferredSchemaType<SchemaAttributes>>;
|
|
35
|
+
export declare const formValidator: (<A extends SchemaAttributes = SchemaAttributes>({ form, schema, readonlyAttributes, formReadOnly, getSchema, language, strings, }: {
|
|
36
|
+
schema: Schema<A>;
|
|
37
|
+
form: Form<A>;
|
|
38
|
+
language: string;
|
|
39
|
+
formReadOnly?: boolean;
|
|
40
|
+
readonlyAttributes?: string[];
|
|
41
|
+
strings: FormValidationStringSet;
|
|
42
|
+
getSchema: (logicalName: string) => Schema;
|
|
43
|
+
}) => (values: Record<string, any>, context: any, options: any) => Promise<import("react-hook-form").ResolverResult<{}>>) & import("lodash").MemoizedFunction;
|
|
44
|
+
export declare const generateValidationSchema: (<A extends SchemaAttributes = SchemaAttributes>({ columns, editableGrids, language, schema, strings, readonlyAttributes, }: {
|
|
45
|
+
schema: Schema<A>;
|
|
46
|
+
columns: string[];
|
|
47
|
+
readonlyAttributes?: string[];
|
|
48
|
+
editableGrids: Array<{
|
|
49
|
+
schema: Schema;
|
|
50
|
+
columns: string[];
|
|
51
|
+
attributeName: string;
|
|
52
|
+
required?: boolean;
|
|
53
|
+
}> | undefined;
|
|
54
|
+
language: string;
|
|
55
|
+
strings: FormValidationStringSet;
|
|
56
|
+
}) => yup.ObjectSchema<{
|
|
57
|
+
[x: string]: any;
|
|
58
|
+
}, yup.AnyObject, {
|
|
59
|
+
[x: string]: any;
|
|
60
|
+
}, "">) & import("lodash").MemoizedFunction;
|
|
61
|
+
export declare const generateAttributeValidationSchema: ((attribute: Attribute, language: string, strings: FormValidationStringSet) => yup.Schema<any, any, any, "">) & import("lodash").MemoizedFunction;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,356 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.generateAttributeValidationSchema = exports.generateValidationSchema = exports.formValidator = void 0;
|
|
36
|
+
exports.getModifiedValues = getModifiedValues;
|
|
37
|
+
exports.saveRecord = saveRecord;
|
|
38
|
+
exports.getInitialValues = getInitialValues;
|
|
39
|
+
const yup_1 = require("@hookform/resolvers/yup");
|
|
40
|
+
const lodash_1 = require("lodash");
|
|
41
|
+
const yup = __importStar(require("yup"));
|
|
42
|
+
const CommandBuilder_1 = require("../../builders/CommandBuilder");
|
|
43
|
+
const DataResolver_1 = require("../../dataform/DataFormProvider/DataResolver");
|
|
44
|
+
function getModifiedValues(initialValues, values, exclude) {
|
|
45
|
+
const keys = Object.keys(values);
|
|
46
|
+
return keys.reduce((p, c) => {
|
|
47
|
+
if (c === '_id') {
|
|
48
|
+
return p;
|
|
49
|
+
}
|
|
50
|
+
if (exclude && exclude.includes(c)) {
|
|
51
|
+
return p;
|
|
52
|
+
}
|
|
53
|
+
if (JSON.stringify(values[c]) !== JSON.stringify(initialValues[c])) {
|
|
54
|
+
p[c] = values[c];
|
|
55
|
+
}
|
|
56
|
+
return p;
|
|
57
|
+
}, {});
|
|
58
|
+
}
|
|
59
|
+
function saveRecord(_a) {
|
|
60
|
+
return __awaiter(this, arguments, void 0, function* ({ values, form, schema, dataService, initialValues, record, getSchema, }) {
|
|
61
|
+
const controls = (0, DataResolver_1.getControls)(form);
|
|
62
|
+
const editableGridControls = controls.filter((control) => control.type === 'editablegrid');
|
|
63
|
+
const modifiedValues = getModifiedValues(initialValues, values, editableGridControls.map((x) => x.attributeName));
|
|
64
|
+
let recordId;
|
|
65
|
+
if (record) {
|
|
66
|
+
recordId = record[schema.idAttribute];
|
|
67
|
+
const operations = [];
|
|
68
|
+
if (Object.keys(modifiedValues).length) {
|
|
69
|
+
operations.push({
|
|
70
|
+
type: 'update',
|
|
71
|
+
logicalName: schema.logicalName,
|
|
72
|
+
data: modifiedValues,
|
|
73
|
+
id: recordId,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
for (const control of editableGridControls) {
|
|
77
|
+
const gridSchema = getSchema(control.logicalName);
|
|
78
|
+
const gridRows = values[control.attributeName];
|
|
79
|
+
const initialGridRows = initialValues[control.attributeName];
|
|
80
|
+
const newRows = gridRows.filter((x) => !x[gridSchema.idAttribute]);
|
|
81
|
+
const updatedRows = gridRows.filter((x) => x[gridSchema.idAttribute]);
|
|
82
|
+
const deletedIds = initialGridRows === null || initialGridRows === void 0 ? void 0 : initialGridRows.map((x) => x[gridSchema.idAttribute]).filter((id) => !gridRows.find((x) => x[gridSchema.idAttribute] === id));
|
|
83
|
+
for (const row of newRows) {
|
|
84
|
+
operations.push({
|
|
85
|
+
type: 'create',
|
|
86
|
+
logicalName: control.logicalName,
|
|
87
|
+
data: Object.assign(Object.assign({}, row), { [control.referenceAttribute]: {
|
|
88
|
+
id: recordId,
|
|
89
|
+
} }),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
for (const row of updatedRows) {
|
|
93
|
+
const initialRow = initialGridRows.find((x) => x[gridSchema.idAttribute] === row[gridSchema.idAttribute]);
|
|
94
|
+
if (!initialRow) {
|
|
95
|
+
throw new Error('Initial row not found');
|
|
96
|
+
}
|
|
97
|
+
const modifiedRow = getModifiedValues(initialRow, row);
|
|
98
|
+
if (!Object.keys(modifiedRow).length) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
operations.push({
|
|
102
|
+
type: 'update',
|
|
103
|
+
logicalName: control.logicalName,
|
|
104
|
+
data: modifiedRow,
|
|
105
|
+
id: row[gridSchema.idAttribute],
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
for (const id of deletedIds) {
|
|
109
|
+
operations.push({
|
|
110
|
+
type: 'delete',
|
|
111
|
+
logicalName: control.logicalName,
|
|
112
|
+
id,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (!operations.length) {
|
|
117
|
+
return {
|
|
118
|
+
success: false,
|
|
119
|
+
title: 'No changes',
|
|
120
|
+
message: 'No changes made to the record',
|
|
121
|
+
isError: false,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (operations.length > 0) {
|
|
125
|
+
console.log('operations', operations);
|
|
126
|
+
}
|
|
127
|
+
for (const operation of operations) {
|
|
128
|
+
switch (operation.type) {
|
|
129
|
+
case 'create':
|
|
130
|
+
yield dataService.createRecord(operation.logicalName, operation.data);
|
|
131
|
+
break;
|
|
132
|
+
case 'update':
|
|
133
|
+
yield dataService.updateRecord(operation.logicalName, operation.id, operation.data);
|
|
134
|
+
break;
|
|
135
|
+
case 'delete':
|
|
136
|
+
yield dataService.deleteRecord(operation.logicalName, operation.id);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
const result = yield dataService.createRecord(schema.logicalName, values);
|
|
142
|
+
recordId = result[schema.idAttribute];
|
|
143
|
+
for (const control of editableGridControls) {
|
|
144
|
+
const gridRows = values[control.attributeName];
|
|
145
|
+
for (const row of gridRows) {
|
|
146
|
+
yield dataService.createRecord(control.logicalName, Object.assign(Object.assign({}, row), { [control.referenceAttribute]: {
|
|
147
|
+
id: recordId,
|
|
148
|
+
} }));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
success: true,
|
|
154
|
+
recordId,
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function getInitialValues({ cloneRecord, form, record, recordId, defaultParameters, }) {
|
|
159
|
+
const formColumns = (0, DataResolver_1.getColumns)(form);
|
|
160
|
+
const editableGridControls = (0, DataResolver_1.getControls)(form).filter((control) => control.type === 'editablegrid');
|
|
161
|
+
const allColumns = [
|
|
162
|
+
...formColumns,
|
|
163
|
+
...editableGridControls.map((x) => x.attributeName),
|
|
164
|
+
];
|
|
165
|
+
if (!recordId && !record && form.experience.cloneAttributes && cloneRecord) {
|
|
166
|
+
const cloneAttributesObj = form.experience.cloneAttributes.reduce((acc, item) => {
|
|
167
|
+
if (typeof item === 'string') {
|
|
168
|
+
acc[item] = item;
|
|
169
|
+
}
|
|
170
|
+
// TODO:
|
|
171
|
+
// else if (isEditableGridCloneAttribute(item)) {
|
|
172
|
+
// acc[item.attributeName] = item;
|
|
173
|
+
// }
|
|
174
|
+
return acc;
|
|
175
|
+
}, {});
|
|
176
|
+
return allColumns.reduce((acc, column) => {
|
|
177
|
+
var _a;
|
|
178
|
+
const cloneAttributeInfo = cloneAttributesObj[column];
|
|
179
|
+
// | EditableGridCloneAttribute; // TODO:
|
|
180
|
+
let value = null;
|
|
181
|
+
if (cloneAttributeInfo) {
|
|
182
|
+
if (typeof cloneAttributeInfo === 'string') {
|
|
183
|
+
value = cloneRecord[cloneAttributeInfo];
|
|
184
|
+
}
|
|
185
|
+
// else {
|
|
186
|
+
// const rows = cloneRecord[cloneAttributeInfo.attributeName] as any[];
|
|
187
|
+
// if (!rows?.length) {
|
|
188
|
+
// value = [];
|
|
189
|
+
// } else {
|
|
190
|
+
// value = rows.map((row) => {
|
|
191
|
+
// return Object.keys(row).reduce((p, c) => {
|
|
192
|
+
// if (c === '_id') {
|
|
193
|
+
// return p;
|
|
194
|
+
// }
|
|
195
|
+
// if (cloneAttributeInfo.attributes.includes(c)) {
|
|
196
|
+
// p[c] = row[c];
|
|
197
|
+
// } else {
|
|
198
|
+
// p[c] = null;
|
|
199
|
+
// }
|
|
200
|
+
// return p;
|
|
201
|
+
// }, {} as Record<string, any>);
|
|
202
|
+
// });
|
|
203
|
+
// }
|
|
204
|
+
// }
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
value = (_a = defaultParameters[column]) !== null && _a !== void 0 ? _a : null;
|
|
208
|
+
}
|
|
209
|
+
return Object.assign(Object.assign({}, acc), { [column]: value });
|
|
210
|
+
}, {});
|
|
211
|
+
}
|
|
212
|
+
return allColumns.reduce((acc, column) => {
|
|
213
|
+
var _a;
|
|
214
|
+
const value = record ? record[column] : (_a = defaultParameters[column]) !== null && _a !== void 0 ? _a : null;
|
|
215
|
+
return Object.assign(Object.assign({}, acc), { [column]: value });
|
|
216
|
+
}, {});
|
|
217
|
+
}
|
|
218
|
+
exports.formValidator = (0, lodash_1.memoize)(function formValidator({ form, schema, readonlyAttributes, formReadOnly, getSchema, language, strings, }) {
|
|
219
|
+
return (values, context, options) => __awaiter(this, void 0, void 0, function* () {
|
|
220
|
+
// console.log('formValidator', values);
|
|
221
|
+
let validator = yup.object().shape({});
|
|
222
|
+
if (!formReadOnly) {
|
|
223
|
+
const activeControls = form.experience.tabs
|
|
224
|
+
.flatMap((tab) => tab.tabColumns)
|
|
225
|
+
.flatMap((tabColumn) => tabColumn.sections)
|
|
226
|
+
.flatMap((section) => {
|
|
227
|
+
return section.controls;
|
|
228
|
+
})
|
|
229
|
+
.filter((control) => {
|
|
230
|
+
if (control.type === 'standard') {
|
|
231
|
+
const attribute = schema.attributes[control.attributeName];
|
|
232
|
+
if (attribute.readonly) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return true;
|
|
237
|
+
});
|
|
238
|
+
const editableGridControls = activeControls.filter((control) => control.type === 'editablegrid');
|
|
239
|
+
const columns = Array.from(new Set([
|
|
240
|
+
schema.primaryAttribute,
|
|
241
|
+
...activeControls
|
|
242
|
+
.filter((control) => control.type === 'standard')
|
|
243
|
+
.map((control) => control.attributeName),
|
|
244
|
+
]));
|
|
245
|
+
validator = (0, exports.generateValidationSchema)({
|
|
246
|
+
editableGrids: editableGridControls.map((control) => {
|
|
247
|
+
if (control.type !== 'editablegrid') {
|
|
248
|
+
throw new Error('Invalid control type');
|
|
249
|
+
}
|
|
250
|
+
const schema = getSchema(control.logicalName);
|
|
251
|
+
return {
|
|
252
|
+
columns: control.attributes,
|
|
253
|
+
schema: schema,
|
|
254
|
+
attributeName: control.attributeName,
|
|
255
|
+
required: control.required,
|
|
256
|
+
};
|
|
257
|
+
}),
|
|
258
|
+
schema,
|
|
259
|
+
columns: columns,
|
|
260
|
+
language,
|
|
261
|
+
strings,
|
|
262
|
+
readonlyAttributes,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
const resolver = (0, yup_1.yupResolver)(validator);
|
|
266
|
+
const result = yield resolver(values, context, options);
|
|
267
|
+
// console.log(result);
|
|
268
|
+
return result;
|
|
269
|
+
});
|
|
270
|
+
}, ({ form, language, schema, strings, readonlyAttributes, formReadOnly }) => JSON.stringify({
|
|
271
|
+
schema,
|
|
272
|
+
form,
|
|
273
|
+
language,
|
|
274
|
+
strings,
|
|
275
|
+
readonlyAttributes,
|
|
276
|
+
formReadOnly,
|
|
277
|
+
}));
|
|
278
|
+
exports.generateValidationSchema = (0, lodash_1.memoize)(function generateValidationSchema({ columns, editableGrids, language, schema, strings, readonlyAttributes, }) {
|
|
279
|
+
return yup.object().shape(Object.assign(Object.assign({}, columns.reduce((acc, column) => {
|
|
280
|
+
if (readonlyAttributes === null || readonlyAttributes === void 0 ? void 0 : readonlyAttributes.includes(column)) {
|
|
281
|
+
return acc;
|
|
282
|
+
}
|
|
283
|
+
const attribute = schema.attributes[column];
|
|
284
|
+
const validationSchema = (0, exports.generateAttributeValidationSchema)(attribute, language, strings);
|
|
285
|
+
return Object.assign(Object.assign({}, acc), { [column]: validationSchema });
|
|
286
|
+
}, {})), editableGrids === null || editableGrids === void 0 ? void 0 : editableGrids.reduce((acc, grid) => {
|
|
287
|
+
let validationSchema = yup
|
|
288
|
+
.array()
|
|
289
|
+
.of(yup.object().shape(Object.assign({}, grid.columns.reduce((acc, column) => {
|
|
290
|
+
const attribute = grid.schema.attributes[column];
|
|
291
|
+
const validationSchema = (0, exports.generateAttributeValidationSchema)(attribute, language, strings);
|
|
292
|
+
return Object.assign(Object.assign({}, acc), { [column]: validationSchema });
|
|
293
|
+
}, {}))))
|
|
294
|
+
.nullable();
|
|
295
|
+
if (grid.required) {
|
|
296
|
+
validationSchema = validationSchema
|
|
297
|
+
.required(strings.atLeastOneRowRequired)
|
|
298
|
+
.min(1, strings.atLeastOneRowRequired);
|
|
299
|
+
}
|
|
300
|
+
acc[grid.attributeName] = validationSchema;
|
|
301
|
+
return acc;
|
|
302
|
+
}, {})));
|
|
303
|
+
}, ({ columns, editableGrids, language, schema, strings, readonlyAttributes }) => JSON.stringify({
|
|
304
|
+
schema,
|
|
305
|
+
columns,
|
|
306
|
+
editableGrids,
|
|
307
|
+
language,
|
|
308
|
+
strings,
|
|
309
|
+
readonlyAttributes,
|
|
310
|
+
}));
|
|
311
|
+
exports.generateAttributeValidationSchema = (0, lodash_1.memoize)(function generateAttributeValidationSchema(attribute, language, strings) {
|
|
312
|
+
let validationSchema;
|
|
313
|
+
switch (attribute.type) {
|
|
314
|
+
case 'string':
|
|
315
|
+
validationSchema = yup.string().nullable();
|
|
316
|
+
break;
|
|
317
|
+
case 'number':
|
|
318
|
+
validationSchema = yup.number().nullable();
|
|
319
|
+
break;
|
|
320
|
+
default:
|
|
321
|
+
validationSchema = yup.mixed().nullable();
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
const label = (0, CommandBuilder_1.localizedLabel)(language, attribute);
|
|
325
|
+
if (attribute.required) {
|
|
326
|
+
validationSchema = validationSchema.required(`${label}: ${strings.required}`);
|
|
327
|
+
}
|
|
328
|
+
switch (attribute.type) {
|
|
329
|
+
case 'string':
|
|
330
|
+
if (attribute.maxLength) {
|
|
331
|
+
validationSchema = validationSchema.max(attribute.maxLength, `${label}: ${strings.maxLength}`);
|
|
332
|
+
}
|
|
333
|
+
if (attribute.minLength) {
|
|
334
|
+
validationSchema = validationSchema.min(attribute.minLength, `${label}: ${strings.minLength}`);
|
|
335
|
+
}
|
|
336
|
+
if (attribute.pattern) {
|
|
337
|
+
validationSchema = validationSchema.matches(new RegExp(attribute.pattern), `${label}: ${strings.invalidFormat}`);
|
|
338
|
+
}
|
|
339
|
+
if (attribute.format === 'email') {
|
|
340
|
+
validationSchema = validationSchema.email(`${label}: ${strings.invalidEmail}`);
|
|
341
|
+
}
|
|
342
|
+
else if (attribute.format === 'phone') {
|
|
343
|
+
validationSchema = validationSchema.matches(/^(\+\d{1,2}\s?)?\d{10}$/, `${label}: ${strings.invalidPhoneNumber}`);
|
|
344
|
+
}
|
|
345
|
+
break;
|
|
346
|
+
default:
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
validationSchema = validationSchema.transform((value) => {
|
|
350
|
+
if (value === '') {
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
return value;
|
|
354
|
+
});
|
|
355
|
+
return validationSchema;
|
|
356
|
+
});
|