@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,143 @@
|
|
|
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.getControls = getControls;
|
|
13
|
+
exports.getColumns = getColumns;
|
|
14
|
+
exports.DataResolver = DataResolver;
|
|
15
|
+
const transport_1 = require("@headless-adminapp/core/transport");
|
|
16
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
17
|
+
const react_1 = require("react");
|
|
18
|
+
const hooks_1 = require("../../metadata/hooks");
|
|
19
|
+
const mutable_1 = require("../../mutable");
|
|
20
|
+
const transport_2 = require("../../transport");
|
|
21
|
+
const context_1 = require("../context");
|
|
22
|
+
const hooks_2 = require("../hooks");
|
|
23
|
+
function getControls(form) {
|
|
24
|
+
const controls = form.experience.tabs
|
|
25
|
+
.flatMap((tab) => tab.tabColumns)
|
|
26
|
+
.flatMap((tabColumn) => tabColumn.sections)
|
|
27
|
+
.flatMap((section) => section.controls);
|
|
28
|
+
return controls;
|
|
29
|
+
}
|
|
30
|
+
function getColumns(form) {
|
|
31
|
+
var _a;
|
|
32
|
+
const columns = Array.from(new Set([
|
|
33
|
+
...((_a = form.experience.includeAttributes) !== null && _a !== void 0 ? _a : []),
|
|
34
|
+
...form.experience.headerControls,
|
|
35
|
+
...getControls(form)
|
|
36
|
+
.filter((control) => control.type === 'standard')
|
|
37
|
+
.map((control) => control.attributeName),
|
|
38
|
+
]));
|
|
39
|
+
return columns;
|
|
40
|
+
}
|
|
41
|
+
function getRecord(_a) {
|
|
42
|
+
return __awaiter(this, arguments, void 0, function* ({ recordId, dataService, form, schema, columns, getSchema, }) {
|
|
43
|
+
var _b;
|
|
44
|
+
let record = null;
|
|
45
|
+
try {
|
|
46
|
+
record = yield dataService.retriveRecord(schema.logicalName, recordId, columns);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (error instanceof transport_1.HttpError && error.status === 404) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
if (!record) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const controls = getControls(form);
|
|
58
|
+
const editableGridControls = controls.filter((control) => control.type === 'editablegrid');
|
|
59
|
+
for (const control of editableGridControls) {
|
|
60
|
+
if (control.type !== 'editablegrid') {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const controlSchema = getSchema(control.logicalName);
|
|
64
|
+
const records = yield dataService.retriveRecords({
|
|
65
|
+
logicalName: controlSchema.logicalName,
|
|
66
|
+
filter: {
|
|
67
|
+
type: 'and',
|
|
68
|
+
conditions: [
|
|
69
|
+
{
|
|
70
|
+
field: control.referenceAttribute,
|
|
71
|
+
operator: 'eq',
|
|
72
|
+
value: recordId,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
sort: [
|
|
77
|
+
{
|
|
78
|
+
field: (_b = controlSchema.createdAtAttribute) !== null && _b !== void 0 ? _b : controlSchema.idAttribute,
|
|
79
|
+
order: 'asc',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
limit: 5000,
|
|
83
|
+
search: '',
|
|
84
|
+
columns: [
|
|
85
|
+
controlSchema.idAttribute,
|
|
86
|
+
control.referenceAttribute,
|
|
87
|
+
...control.attributes,
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
record[control.attributeName] = records.records;
|
|
91
|
+
}
|
|
92
|
+
return record;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function DataResolver() {
|
|
96
|
+
const schema = (0, hooks_2.useDataFormSchema)();
|
|
97
|
+
const form = (0, hooks_2.useSelectedForm)();
|
|
98
|
+
const dataService = (0, transport_2.useDataService)();
|
|
99
|
+
const recordId = (0, hooks_2.useRecordId)();
|
|
100
|
+
const { getSchema } = (0, hooks_1.useMetadata)();
|
|
101
|
+
const setState = (0, mutable_1.useContextSetValue)(context_1.DataFormContext);
|
|
102
|
+
const columns = (0, react_1.useMemo)(() => getColumns(form), [form]);
|
|
103
|
+
const queryKey = (0, react_1.useMemo)(() => ['data', 'retriveRecord', schema.logicalName, recordId, columns], [columns, recordId, schema.logicalName]);
|
|
104
|
+
const { data, refetch, isPending } = (0, react_query_1.useQuery)({
|
|
105
|
+
queryKey,
|
|
106
|
+
queryFn: () => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
if (!recordId) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const record = getRecord({
|
|
111
|
+
columns,
|
|
112
|
+
dataService,
|
|
113
|
+
form,
|
|
114
|
+
recordId,
|
|
115
|
+
schema,
|
|
116
|
+
getSchema,
|
|
117
|
+
});
|
|
118
|
+
return record;
|
|
119
|
+
}),
|
|
120
|
+
placeholderData: react_query_1.keepPreviousData,
|
|
121
|
+
staleTime: 1000 * 60 * 5, // 5 minutes
|
|
122
|
+
});
|
|
123
|
+
(0, react_1.useEffect)(() => {
|
|
124
|
+
setState({
|
|
125
|
+
record: data,
|
|
126
|
+
});
|
|
127
|
+
}, [data, setState]);
|
|
128
|
+
(0, react_1.useEffect)(() => {
|
|
129
|
+
setState({
|
|
130
|
+
dataState: {
|
|
131
|
+
isFetching: isPending,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}, [isPending, setState]);
|
|
135
|
+
(0, react_1.useEffect)(() => {
|
|
136
|
+
setState({
|
|
137
|
+
refresh: () => __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
yield refetch();
|
|
139
|
+
}),
|
|
140
|
+
});
|
|
141
|
+
}, [refetch, setState]);
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function InitialValueResolver(): null;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InitialValueResolver = InitialValueResolver;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const mutable_1 = require("../../mutable");
|
|
6
|
+
const context_1 = require("../context");
|
|
7
|
+
const hooks_1 = require("../hooks");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
function InitialValueResolver() {
|
|
10
|
+
const formConfig = (0, hooks_1.useSelectedForm)();
|
|
11
|
+
const schema = (0, hooks_1.useDataFormSchema)();
|
|
12
|
+
const recordId = (0, hooks_1.useRecordId)();
|
|
13
|
+
const record = (0, mutable_1.useContextSelector)(context_1.DataFormContext, (state) => state.record);
|
|
14
|
+
const formInstance = (0, hooks_1.useFormInstance)();
|
|
15
|
+
const initialValues = (0, react_1.useMemo)(() => {
|
|
16
|
+
return (0, utils_1.getInitialValues)({
|
|
17
|
+
cloneRecord: undefined,
|
|
18
|
+
form: formConfig,
|
|
19
|
+
record: record,
|
|
20
|
+
recordId: recordId,
|
|
21
|
+
schema: schema,
|
|
22
|
+
defaultParameters: {},
|
|
23
|
+
// defaultParameters,
|
|
24
|
+
});
|
|
25
|
+
}, [formConfig, record, recordId, schema]);
|
|
26
|
+
const setValue = (0, mutable_1.useContextSetValue)(context_1.DataFormContext);
|
|
27
|
+
(0, react_1.useEffect)(() => {
|
|
28
|
+
setValue({
|
|
29
|
+
initialValues,
|
|
30
|
+
});
|
|
31
|
+
}, [setValue, initialValues]);
|
|
32
|
+
const formInstanceRef = (0, react_1.useRef)(formInstance);
|
|
33
|
+
formInstanceRef.current = formInstance;
|
|
34
|
+
(0, react_1.useEffect)(() => {
|
|
35
|
+
const timer = setTimeout(() => {
|
|
36
|
+
// console.log('resetting form', initialValues);
|
|
37
|
+
formInstanceRef.current.reset(initialValues);
|
|
38
|
+
});
|
|
39
|
+
return () => {
|
|
40
|
+
clearTimeout(timer);
|
|
41
|
+
};
|
|
42
|
+
}, [initialValues]);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReadonlyInfoResolver = ReadonlyInfoResolver;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const mutable_1 = require("../../mutable");
|
|
6
|
+
const context_1 = require("../context");
|
|
7
|
+
const hooks_1 = require("../hooks");
|
|
8
|
+
function ReadonlyInfoResolver({ setFormReadOnly, }) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
const schema = (0, hooks_1.useDataFormSchema)();
|
|
11
|
+
const recordId = (0, hooks_1.useRecordId)();
|
|
12
|
+
let readonly = false;
|
|
13
|
+
if (((_a = schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableCreate) && !recordId) {
|
|
14
|
+
readonly = true;
|
|
15
|
+
}
|
|
16
|
+
if (((_b = schema.restrictions) === null || _b === void 0 ? void 0 : _b.disableUpdate) && recordId) {
|
|
17
|
+
readonly = true;
|
|
18
|
+
}
|
|
19
|
+
const setValue = (0, mutable_1.useContextSetValue)(context_1.DataFormContext);
|
|
20
|
+
(0, react_1.useEffect)(() => {
|
|
21
|
+
setValue({
|
|
22
|
+
isReadonly: readonly,
|
|
23
|
+
});
|
|
24
|
+
setFormReadOnly(readonly);
|
|
25
|
+
}, [setValue, setFormReadOnly, readonly]);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EntityMainFormCommandItemExperience, Form } from '@headless-adminapp/core/experience/form';
|
|
2
|
+
import { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
4
|
+
export interface DataFormProviderProps<S extends SchemaAttributes = SchemaAttributes> {
|
|
5
|
+
schema: Schema<S>;
|
|
6
|
+
form: Form<S>;
|
|
7
|
+
recordId?: string;
|
|
8
|
+
commands: EntityMainFormCommandItemExperience[][];
|
|
9
|
+
}
|
|
10
|
+
export declare function DataFormProvider<S extends SchemaAttributes = SchemaAttributes>(props: PropsWithChildren<DataFormProviderProps<S>>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,72 @@
|
|
|
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.DataFormProvider = DataFormProvider;
|
|
13
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
14
|
+
const react_1 = require("react");
|
|
15
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
16
|
+
const FormValidationStringContext_1 = require("../../form/FormValidationStringContext");
|
|
17
|
+
const useLocale_1 = require("../../locale/useLocale");
|
|
18
|
+
const useMetadata_1 = require("../../metadata/hooks/useMetadata");
|
|
19
|
+
const mutable_1 = require("../../mutable");
|
|
20
|
+
const context_1 = require("../context");
|
|
21
|
+
const utils_1 = require("../utils");
|
|
22
|
+
const DataResolver_1 = require("./DataResolver");
|
|
23
|
+
const InitialValueResolver_1 = require("./InitialValueResolver");
|
|
24
|
+
const ReadonlyInfoResolver_1 = require("./ReadonlyInfoResolver");
|
|
25
|
+
function DataFormProvider(props) {
|
|
26
|
+
const { getSchema } = (0, useMetadata_1.useMetadata)();
|
|
27
|
+
const [{ language }] = (0, useLocale_1.useLocale)();
|
|
28
|
+
const formValidationStrings = (0, FormValidationStringContext_1.useFormValidationStrings)();
|
|
29
|
+
const [formReadOnly, setFormReadOnly] = (0, react_1.useState)(false); // A trick to provide readOnly info to formInstance
|
|
30
|
+
const formInstance = (0, react_hook_form_1.useForm)({
|
|
31
|
+
mode: 'all',
|
|
32
|
+
defaultValues: {},
|
|
33
|
+
resolver: (0, utils_1.formValidator)({
|
|
34
|
+
form: props.form,
|
|
35
|
+
getSchema,
|
|
36
|
+
language,
|
|
37
|
+
schema: props.schema,
|
|
38
|
+
strings: formValidationStrings,
|
|
39
|
+
formReadOnly,
|
|
40
|
+
}),
|
|
41
|
+
shouldUnregister: false,
|
|
42
|
+
});
|
|
43
|
+
const contextValue = (0, mutable_1.useCreateContextStore)({
|
|
44
|
+
schema: props.schema,
|
|
45
|
+
form: props.form,
|
|
46
|
+
commands: props.commands,
|
|
47
|
+
dataState: { isFetching: false },
|
|
48
|
+
recordId: props.recordId,
|
|
49
|
+
refresh: () => __awaiter(this, void 0, void 0, function* () { }), // Initial value, will be overridden
|
|
50
|
+
cloneId: undefined,
|
|
51
|
+
// formInstance,
|
|
52
|
+
// formInstanceRenderCount: 0,
|
|
53
|
+
initialValues: {},
|
|
54
|
+
});
|
|
55
|
+
(0, react_1.useEffect)(() => {
|
|
56
|
+
contextValue.setValue({
|
|
57
|
+
form: props.form,
|
|
58
|
+
schema: props.schema,
|
|
59
|
+
recordId: props.recordId,
|
|
60
|
+
cloneId: undefined,
|
|
61
|
+
commands: props.commands,
|
|
62
|
+
});
|
|
63
|
+
}, [
|
|
64
|
+
props.form,
|
|
65
|
+
props.schema,
|
|
66
|
+
props.recordId,
|
|
67
|
+
contextValue,
|
|
68
|
+
getSchema,
|
|
69
|
+
props.commands,
|
|
70
|
+
]);
|
|
71
|
+
return ((0, jsx_runtime_1.jsx)(context_1.DataFormContext.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsxs)(react_hook_form_1.FormProvider, Object.assign({}, formInstance, { children: [(0, jsx_runtime_1.jsx)(DataResolver_1.DataResolver, {}), (0, jsx_runtime_1.jsx)(InitialValueResolver_1.InitialValueResolver, {}), (0, jsx_runtime_1.jsx)(ReadonlyInfoResolver_1.ReadonlyInfoResolver, { setFormReadOnly: setFormReadOnly }), props.children] })) }));
|
|
72
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EntityMainFormCommandItemExperience, Form } from '@headless-adminapp/core/experience/form';
|
|
2
|
+
import { InferredSchemaType, Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
+
import { Data } from '@headless-adminapp/core/transport';
|
|
4
|
+
import { Nullable } from '@headless-adminapp/core/types';
|
|
5
|
+
export type DataFormContextState<SA extends SchemaAttributes = SchemaAttributes> = {
|
|
6
|
+
schema: Schema<SA>;
|
|
7
|
+
form: Form<SA>;
|
|
8
|
+
recordId?: string | number;
|
|
9
|
+
cloneId?: string | number;
|
|
10
|
+
commands: EntityMainFormCommandItemExperience[][];
|
|
11
|
+
activeTab?: string;
|
|
12
|
+
record?: Data<InferredSchemaType<SA>>;
|
|
13
|
+
cloneRecord?: Data<InferredSchemaType<SA>>;
|
|
14
|
+
isReadonly?: boolean;
|
|
15
|
+
dataState: {
|
|
16
|
+
isFetching: boolean;
|
|
17
|
+
isError?: boolean;
|
|
18
|
+
};
|
|
19
|
+
refresh: () => Promise<void>;
|
|
20
|
+
initialValues: Nullable<InferredSchemaType<SA>>;
|
|
21
|
+
};
|
|
22
|
+
export declare const DataFormContext: import("react").Context<import("../mutable").ContextValue<DataFormContextState<SchemaAttributes>>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './useFormInstance';
|
|
2
|
+
export * from './useFormIsDirty';
|
|
3
|
+
export * from './useFormIsReadonly';
|
|
4
|
+
export * from './useFormNotifications';
|
|
5
|
+
export * from './useFormRecord';
|
|
6
|
+
export * from './useFormSave';
|
|
7
|
+
export * from './useFormSchema';
|
|
8
|
+
export * from './useMainFormCommands';
|
|
9
|
+
export * from './useRecordId';
|
|
10
|
+
export * from './useRecordTitle';
|
|
11
|
+
export * from './useSelectedForm';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useFormInstance"), exports);
|
|
18
|
+
__exportStar(require("./useFormIsDirty"), exports);
|
|
19
|
+
__exportStar(require("./useFormIsReadonly"), exports);
|
|
20
|
+
__exportStar(require("./useFormNotifications"), exports);
|
|
21
|
+
__exportStar(require("./useFormRecord"), exports);
|
|
22
|
+
__exportStar(require("./useFormSave"), exports);
|
|
23
|
+
__exportStar(require("./useFormSchema"), exports);
|
|
24
|
+
__exportStar(require("./useMainFormCommands"), exports);
|
|
25
|
+
__exportStar(require("./useRecordId"), exports);
|
|
26
|
+
__exportStar(require("./useRecordTitle"), exports);
|
|
27
|
+
__exportStar(require("./useSelectedForm"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useFormInstance(): import("react-hook-form").UseFormReturn<import("react-hook-form").FieldValues, any, undefined>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFormInstance = useFormInstance;
|
|
4
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
5
|
+
function useFormInstance() {
|
|
6
|
+
const formInstance = (0, react_hook_form_1.useFormContext)();
|
|
7
|
+
return formInstance;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useFormIsDirty(): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFormIsDirty = useFormIsDirty;
|
|
4
|
+
const useFormInstance_1 = require("./useFormInstance");
|
|
5
|
+
function useFormIsDirty() {
|
|
6
|
+
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
7
|
+
return Object.keys(formInstance.formState.dirtyFields).length > 0;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useFormIsReadonly(): boolean | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFormIsReadonly = useFormIsReadonly;
|
|
4
|
+
const mutable_1 = require("../../mutable");
|
|
5
|
+
const context_1 = require("../context");
|
|
6
|
+
function useFormIsReadonly() {
|
|
7
|
+
const readonly = (0, mutable_1.useContextSelector)(context_1.DataFormContext, (state) => state.isReadonly);
|
|
8
|
+
return readonly;
|
|
9
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFormNotifications = useFormNotifications;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useFormInstance_1 = require("./useFormInstance");
|
|
6
|
+
const useFormIsReadonly_1 = require("./useFormIsReadonly");
|
|
7
|
+
function useFormNotifications() {
|
|
8
|
+
const readonly = (0, useFormIsReadonly_1.useFormIsReadonly)();
|
|
9
|
+
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
10
|
+
const formInstanceAvailable = !!formInstance;
|
|
11
|
+
return (0, react_1.useMemo)(() => {
|
|
12
|
+
const notifications = [];
|
|
13
|
+
if (readonly) {
|
|
14
|
+
notifications.push({
|
|
15
|
+
level: 'warning',
|
|
16
|
+
message: 'This record is read only',
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (formInstanceAvailable &&
|
|
20
|
+
formInstance.formState.isSubmitted &&
|
|
21
|
+
Object.keys(formInstance.formState.errors).length > 0) {
|
|
22
|
+
notifications.push({
|
|
23
|
+
level: 'error',
|
|
24
|
+
message: 'Please fill in the required fields',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return notifications;
|
|
28
|
+
}, [
|
|
29
|
+
formInstanceAvailable,
|
|
30
|
+
formInstance === null || formInstance === void 0 ? void 0 : formInstance.formState.errors,
|
|
31
|
+
formInstance === null || formInstance === void 0 ? void 0 : formInstance.formState.isSubmitted,
|
|
32
|
+
readonly,
|
|
33
|
+
]);
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useFormRecord(): import("@headless-adminapp/core/transport").Data<import("@headless-adminapp/core/schema").InferredSchemaType<import("@headless-adminapp/core/schema").SchemaAttributes>> | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFormRecord = useFormRecord;
|
|
4
|
+
const mutable_1 = require("../../mutable");
|
|
5
|
+
const context_1 = require("../context");
|
|
6
|
+
function useFormRecord() {
|
|
7
|
+
const record = (0, mutable_1.useContextSelector)(context_1.DataFormContext, (state) => state.record);
|
|
8
|
+
return record;
|
|
9
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Steps
|
|
3
|
+
// 1. Show the loading indicator
|
|
4
|
+
// 2. Extract modified fields from the form
|
|
5
|
+
// 3. Preapre operations
|
|
6
|
+
// 4. Perform the operations
|
|
7
|
+
// 5. Handle the response (success or error, navigation, clear some cache, etc)
|
|
8
|
+
// 6. Hide the loading indicator
|
|
9
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
10
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
13
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
14
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
15
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.useFormSave = useFormSave;
|
|
20
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
21
|
+
const react_1 = require("react");
|
|
22
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
23
|
+
const useMetadata_1 = require("../../metadata/hooks/useMetadata");
|
|
24
|
+
const context_1 = require("../../mutable/context");
|
|
25
|
+
const useProgressIndicator_1 = require("../../progress-indicator/hooks/useProgressIndicator");
|
|
26
|
+
const useOpenToastNotification_1 = require("../../toast-notification/hooks/useOpenToastNotification");
|
|
27
|
+
const transport_1 = require("../../transport");
|
|
28
|
+
const context_2 = require("../context");
|
|
29
|
+
const utils_1 = require("../utils");
|
|
30
|
+
const useFormRecord_1 = require("./useFormRecord");
|
|
31
|
+
const useFormSchema_1 = require("./useFormSchema");
|
|
32
|
+
const useSelectedForm_1 = require("./useSelectedForm");
|
|
33
|
+
function useFormSave() {
|
|
34
|
+
const form = (0, useSelectedForm_1.useSelectedForm)();
|
|
35
|
+
const formInstance = (0, react_hook_form_1.useFormContext)();
|
|
36
|
+
const record = (0, useFormRecord_1.useFormRecord)();
|
|
37
|
+
const { getSchema } = (0, useMetadata_1.useMetadata)();
|
|
38
|
+
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
39
|
+
const initialValues = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.initialValues);
|
|
40
|
+
const refresh = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.refresh);
|
|
41
|
+
const dataService = (0, transport_1.useDataService)();
|
|
42
|
+
const { showProgressIndicator, hideProgressIndicator } = (0, useProgressIndicator_1.useProgressIndicator)();
|
|
43
|
+
const openToastNotification = (0, useOpenToastNotification_1.useOpenToastNotification)();
|
|
44
|
+
const client = (0, react_query_1.useQueryClient)();
|
|
45
|
+
function showMessageAfterSave({ isCreatedMode }) {
|
|
46
|
+
// Show notification
|
|
47
|
+
if (!isCreatedMode) {
|
|
48
|
+
openToastNotification({
|
|
49
|
+
type: 'success',
|
|
50
|
+
title: 'Record updated',
|
|
51
|
+
text: 'Record updated successfully',
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
openToastNotification({
|
|
56
|
+
type: 'success',
|
|
57
|
+
title: 'Record created',
|
|
58
|
+
text: 'Record created successfully',
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const _save = (mode) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
yield formInstance.handleSubmit((values) => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
if (mode === 'background' && !record) {
|
|
65
|
+
// Background save should not be triggered if there is no record
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (mode !== 'background') {
|
|
69
|
+
showProgressIndicator(undefined, 500);
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const result = yield (0, utils_1.saveRecord)({
|
|
73
|
+
values,
|
|
74
|
+
form: form,
|
|
75
|
+
record: record,
|
|
76
|
+
initialValues: initialValues,
|
|
77
|
+
dataService,
|
|
78
|
+
schema: schema,
|
|
79
|
+
getSchema,
|
|
80
|
+
});
|
|
81
|
+
if (!result.success) {
|
|
82
|
+
openToastNotification({
|
|
83
|
+
type: result.isError ? 'error' : 'info',
|
|
84
|
+
title: 'Error',
|
|
85
|
+
text: result.message,
|
|
86
|
+
});
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// invalidateQueriesAfterSave({
|
|
90
|
+
// client,
|
|
91
|
+
// });
|
|
92
|
+
if (mode === 'save' && record) {
|
|
93
|
+
yield refresh();
|
|
94
|
+
// client.invalidateQueries({ queryKey: ['data', 'retriveRecord'] });
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
yield client.invalidateQueries({
|
|
98
|
+
queryKey: ['data', 'retriveRecord'],
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
yield client.invalidateQueries({
|
|
102
|
+
queryKey: ['data', 'retriveRecords'],
|
|
103
|
+
});
|
|
104
|
+
// redirectAfterSave({
|
|
105
|
+
// navigation,
|
|
106
|
+
// isCreatedMode: !context.state.record,
|
|
107
|
+
// recordId: result.recordId,
|
|
108
|
+
// reset: form.reset,
|
|
109
|
+
// logicalName: schema.logicalName,
|
|
110
|
+
// mode,
|
|
111
|
+
// });
|
|
112
|
+
showMessageAfterSave({
|
|
113
|
+
isCreatedMode: !record,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
openToastNotification({
|
|
118
|
+
type: 'error',
|
|
119
|
+
title: 'Error',
|
|
120
|
+
text: err.message,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
if (mode !== 'background') {
|
|
125
|
+
// Hide the loading indicator
|
|
126
|
+
hideProgressIndicator();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}))();
|
|
130
|
+
});
|
|
131
|
+
const _saveRef = (0, react_1.useRef)(_save);
|
|
132
|
+
_saveRef.current = _save;
|
|
133
|
+
const save = (0, react_1.useCallback)((mode) => _saveRef.current(mode), [_saveRef]);
|
|
134
|
+
return save;
|
|
135
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDataFormSchema = useDataFormSchema;
|
|
4
|
+
const context_1 = require("../../mutable/context");
|
|
5
|
+
const context_2 = require("../context");
|
|
6
|
+
function useDataFormSchema() {
|
|
7
|
+
return (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.schema);
|
|
8
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EntityMainFormCommandItemExperience, Form } from '@headless-adminapp/core/experience/form';
|
|
2
|
+
import { Schema } from '@headless-adminapp/core/schema';
|
|
3
|
+
type UseLoadMainFormPageResult = {
|
|
4
|
+
loading: true;
|
|
5
|
+
} | {
|
|
6
|
+
loading: false;
|
|
7
|
+
error: true;
|
|
8
|
+
title: string;
|
|
9
|
+
message: string;
|
|
10
|
+
} | {
|
|
11
|
+
loading: false;
|
|
12
|
+
error: false;
|
|
13
|
+
schema: Schema;
|
|
14
|
+
form: Form;
|
|
15
|
+
commands: EntityMainFormCommandItemExperience[][];
|
|
16
|
+
};
|
|
17
|
+
export declare function useLoadFormGridPage(logicalName: string, formId: string | undefined): UseLoadMainFormPageResult;
|
|
18
|
+
export {};
|