@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,281 @@
|
|
|
1
|
+
import { ColumnCondition } from '@headless-adminapp/core/experience/view';
|
|
2
|
+
import {
|
|
3
|
+
InferredSchemaType,
|
|
4
|
+
Schema,
|
|
5
|
+
SchemaAttributes,
|
|
6
|
+
} from '@headless-adminapp/core/schema';
|
|
7
|
+
import { Filter } from '@headless-adminapp/core/transport';
|
|
8
|
+
import { useInfiniteQuery, useQueryClient } from '@tanstack/react-query';
|
|
9
|
+
import { useEffect, useMemo } from 'react';
|
|
10
|
+
|
|
11
|
+
import { useDebouncedValue } from '../../hooks/useDebouncedValue';
|
|
12
|
+
import { useMetadata } from '../../metadata/hooks/useMetadata';
|
|
13
|
+
import { useContextSetValue } from '../../mutable/context';
|
|
14
|
+
import { useDataService } from '../../transport';
|
|
15
|
+
import { GridContext } from '../context';
|
|
16
|
+
import {
|
|
17
|
+
useDataGridSchema,
|
|
18
|
+
useGridColumnFilter,
|
|
19
|
+
useGridColumns,
|
|
20
|
+
useGridExtraFilter,
|
|
21
|
+
useGridSorting,
|
|
22
|
+
useMaxRecords,
|
|
23
|
+
useSearchText,
|
|
24
|
+
useSelectedView,
|
|
25
|
+
} from '../hooks';
|
|
26
|
+
import { transformColumnFilter } from './utils';
|
|
27
|
+
|
|
28
|
+
const ROWS_PER_PAGE = 100;
|
|
29
|
+
const MAX_RECORDS = 10000;
|
|
30
|
+
|
|
31
|
+
function mergeConditions(
|
|
32
|
+
schema: Schema,
|
|
33
|
+
filter: Filter | null | undefined,
|
|
34
|
+
extraFilter: Filter | null | undefined,
|
|
35
|
+
columnFilters: Partial<Record<string, ColumnCondition>> | undefined,
|
|
36
|
+
getSchema: (logicalName: string) => Schema
|
|
37
|
+
): Filter | null {
|
|
38
|
+
const conditions: any[] = [];
|
|
39
|
+
|
|
40
|
+
if (filter) {
|
|
41
|
+
conditions.push(filter);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (extraFilter) {
|
|
45
|
+
conditions.push(extraFilter);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (columnFilters) {
|
|
49
|
+
const transformedColumnFilters = transformColumnFilter(
|
|
50
|
+
columnFilters,
|
|
51
|
+
schema,
|
|
52
|
+
getSchema
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
if (transformedColumnFilters) {
|
|
56
|
+
conditions.push({
|
|
57
|
+
type: 'and',
|
|
58
|
+
conditions: Object.entries(transformedColumnFilters).map(
|
|
59
|
+
([field, condition]) => {
|
|
60
|
+
return {
|
|
61
|
+
field,
|
|
62
|
+
operator: condition!.operator,
|
|
63
|
+
value: condition!.value,
|
|
64
|
+
extendedKey: condition!.extendedKey,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (conditions.length === 0) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (conditions.length === 1) {
|
|
77
|
+
return conditions[0];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
type: 'and',
|
|
82
|
+
conditions,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function DataResolver<S extends SchemaAttributes = SchemaAttributes>() {
|
|
87
|
+
const schema = useDataGridSchema();
|
|
88
|
+
const view = useSelectedView();
|
|
89
|
+
|
|
90
|
+
const dataService = useDataService();
|
|
91
|
+
const [sorting] = useGridSorting();
|
|
92
|
+
const [searchText] = useSearchText();
|
|
93
|
+
const extraFilter = useGridExtraFilter();
|
|
94
|
+
const [columnFilters] = useGridColumnFilter();
|
|
95
|
+
const gridColumns = useGridColumns();
|
|
96
|
+
const maxRecords = useMaxRecords() ?? MAX_RECORDS;
|
|
97
|
+
|
|
98
|
+
const { getSchema } = useMetadata();
|
|
99
|
+
|
|
100
|
+
const setState = useContextSetValue(GridContext);
|
|
101
|
+
|
|
102
|
+
const [search] = useDebouncedValue(searchText, 500);
|
|
103
|
+
|
|
104
|
+
const columns = useMemo(
|
|
105
|
+
() =>
|
|
106
|
+
Array.from(
|
|
107
|
+
new Set([
|
|
108
|
+
...gridColumns.filter((x) => !x.expandedKey).map((x) => x.name),
|
|
109
|
+
schema.primaryAttribute,
|
|
110
|
+
])
|
|
111
|
+
),
|
|
112
|
+
[gridColumns, schema.primaryAttribute]
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const expand = useMemo(
|
|
116
|
+
() =>
|
|
117
|
+
gridColumns
|
|
118
|
+
.filter((x) => x.expandedKey)
|
|
119
|
+
.reduce((acc, x) => {
|
|
120
|
+
if (!acc[x.name]) {
|
|
121
|
+
acc[x.name] = [];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (!acc[x.name].includes(x.expandedKey!)) {
|
|
125
|
+
acc[x.name].push(x.expandedKey!);
|
|
126
|
+
}
|
|
127
|
+
return acc;
|
|
128
|
+
}, {} as Record<string, string[]>),
|
|
129
|
+
[gridColumns]
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const queryKey = useMemo(
|
|
133
|
+
() => [
|
|
134
|
+
'data',
|
|
135
|
+
'retriveRecords',
|
|
136
|
+
schema.logicalName,
|
|
137
|
+
search,
|
|
138
|
+
view.experience.filter,
|
|
139
|
+
extraFilter,
|
|
140
|
+
sorting,
|
|
141
|
+
columnFilters,
|
|
142
|
+
columns,
|
|
143
|
+
expand,
|
|
144
|
+
maxRecords,
|
|
145
|
+
],
|
|
146
|
+
[
|
|
147
|
+
columnFilters,
|
|
148
|
+
columns,
|
|
149
|
+
expand,
|
|
150
|
+
extraFilter,
|
|
151
|
+
schema.logicalName,
|
|
152
|
+
search,
|
|
153
|
+
sorting,
|
|
154
|
+
view.experience.filter,
|
|
155
|
+
maxRecords,
|
|
156
|
+
]
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
const queryClient = useQueryClient();
|
|
160
|
+
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
return () => {
|
|
163
|
+
// Clear all pages except the first one when the component is unmounted
|
|
164
|
+
queryClient.setQueryData(
|
|
165
|
+
queryKey,
|
|
166
|
+
(oldData: { pageParams: unknown[]; pages: unknown[] }) => {
|
|
167
|
+
if (!oldData) {
|
|
168
|
+
return oldData;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (!oldData.pageParams.length || !oldData.pages.length) {
|
|
172
|
+
return oldData;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
pageParams: [oldData.pageParams[0]],
|
|
177
|
+
pages: [oldData.pages[0]],
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
}, [queryClient, queryKey]);
|
|
183
|
+
|
|
184
|
+
const { data, isFetching, hasNextPage, fetchNextPage, isFetchingNextPage } =
|
|
185
|
+
useInfiniteQuery({
|
|
186
|
+
queryKey: queryKey,
|
|
187
|
+
queryFn: async (queryContext) => {
|
|
188
|
+
const params: {
|
|
189
|
+
pageIndex: number;
|
|
190
|
+
} = queryContext.pageParam ?? {
|
|
191
|
+
pageIndex: 0,
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const skip = params.pageIndex * ROWS_PER_PAGE;
|
|
195
|
+
const limit = Math.min(ROWS_PER_PAGE, Math.max(0, maxRecords - skip));
|
|
196
|
+
|
|
197
|
+
if (limit <= 0) {
|
|
198
|
+
return {
|
|
199
|
+
params: params,
|
|
200
|
+
data: {
|
|
201
|
+
logicalName: schema.logicalName,
|
|
202
|
+
count: 0,
|
|
203
|
+
records: [],
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const result = await dataService.retriveRecords<InferredSchemaType<S>>({
|
|
209
|
+
logicalName: schema.logicalName,
|
|
210
|
+
search,
|
|
211
|
+
columns: columns as unknown as Array<keyof InferredSchemaType<S>>,
|
|
212
|
+
expand,
|
|
213
|
+
filter: mergeConditions(
|
|
214
|
+
schema,
|
|
215
|
+
view.experience.filter,
|
|
216
|
+
extraFilter,
|
|
217
|
+
columnFilters,
|
|
218
|
+
getSchema
|
|
219
|
+
),
|
|
220
|
+
skip,
|
|
221
|
+
limit,
|
|
222
|
+
sort: sorting as any,
|
|
223
|
+
});
|
|
224
|
+
return {
|
|
225
|
+
params: params,
|
|
226
|
+
data: result,
|
|
227
|
+
};
|
|
228
|
+
},
|
|
229
|
+
getNextPageParam: (lastPage) => {
|
|
230
|
+
if (
|
|
231
|
+
lastPage.data.count <
|
|
232
|
+
ROWS_PER_PAGE * (lastPage.params.pageIndex + 1)
|
|
233
|
+
) {
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return {
|
|
238
|
+
pageIndex: lastPage.params.pageIndex + 1,
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
initialPageParam: {
|
|
242
|
+
pageIndex: 0,
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
useEffect(() => {
|
|
247
|
+
setState({
|
|
248
|
+
fetchNextPage: fetchNextPage,
|
|
249
|
+
});
|
|
250
|
+
}, [fetchNextPage, setState]);
|
|
251
|
+
|
|
252
|
+
useEffect(() => {
|
|
253
|
+
if (!data?.pages.length) {
|
|
254
|
+
setState({
|
|
255
|
+
data: null,
|
|
256
|
+
});
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const finalData = {
|
|
261
|
+
logicalName: data?.pages?.[0].data.logicalName,
|
|
262
|
+
count: data?.pages?.[0].data.count ?? 0,
|
|
263
|
+
records: data?.pages.map((x) => x.data.records).flat() ?? [],
|
|
264
|
+
};
|
|
265
|
+
setState({
|
|
266
|
+
data: finalData,
|
|
267
|
+
});
|
|
268
|
+
}, [data, setState]);
|
|
269
|
+
|
|
270
|
+
useEffect(() => {
|
|
271
|
+
setState({
|
|
272
|
+
dataState: {
|
|
273
|
+
isFetching,
|
|
274
|
+
hasNextPage,
|
|
275
|
+
isFetchingNextPage,
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
}, [hasNextPage, isFetching, isFetchingNextPage, setState]);
|
|
279
|
+
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { LocalizedDataLookup } from '@headless-adminapp/core/attributes';
|
|
2
|
+
import { CommandItemExperience } from '@headless-adminapp/core/experience/command';
|
|
3
|
+
import {
|
|
4
|
+
EntityMainGridCommandContext,
|
|
5
|
+
EntitySubGridCommandContext,
|
|
6
|
+
View,
|
|
7
|
+
} from '@headless-adminapp/core/experience/view';
|
|
8
|
+
import { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
9
|
+
import { Filter } from '@headless-adminapp/core/transport';
|
|
10
|
+
import { PropsWithChildren, useCallback, useEffect, useRef } from 'react';
|
|
11
|
+
|
|
12
|
+
import { useLocale } from '../../locale/useLocale';
|
|
13
|
+
import { useMetadata } from '../../metadata/hooks/useMetadata';
|
|
14
|
+
import { ContextValue, useCreateContextStore } from '../../mutable/context';
|
|
15
|
+
import { GridContext, GridContextState } from '../context';
|
|
16
|
+
import { DataResolver } from './DataResolver';
|
|
17
|
+
import { transformViewColumns } from './transformViewColumns';
|
|
18
|
+
|
|
19
|
+
export interface DataGridProviderProps<
|
|
20
|
+
S extends SchemaAttributes = SchemaAttributes,
|
|
21
|
+
CommandContext extends
|
|
22
|
+
| EntityMainGridCommandContext
|
|
23
|
+
| EntitySubGridCommandContext = EntityMainGridCommandContext
|
|
24
|
+
> {
|
|
25
|
+
schema: Schema<S>;
|
|
26
|
+
views: LocalizedDataLookup[];
|
|
27
|
+
view: View<S>;
|
|
28
|
+
extraFilter?: Filter;
|
|
29
|
+
commands: CommandItemExperience<CommandContext>[][];
|
|
30
|
+
onChangeView: (viewId: string) => void;
|
|
31
|
+
isSubGrid?: boolean;
|
|
32
|
+
allowViewSelection?: boolean;
|
|
33
|
+
maxRecords?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function DataGridProvider<
|
|
37
|
+
S extends SchemaAttributes = SchemaAttributes,
|
|
38
|
+
CommandContext extends
|
|
39
|
+
| EntityMainGridCommandContext
|
|
40
|
+
| EntitySubGridCommandContext = EntityMainGridCommandContext
|
|
41
|
+
>(props: PropsWithChildren<DataGridProviderProps<S, CommandContext>>) {
|
|
42
|
+
const onChangeViewRef = useRef(props.onChangeView);
|
|
43
|
+
onChangeViewRef.current = props.onChangeView;
|
|
44
|
+
const { schemaStore } = useMetadata();
|
|
45
|
+
const [{ language }] = useLocale();
|
|
46
|
+
|
|
47
|
+
const handleViewChange = useCallback((viewId: string) => {
|
|
48
|
+
onChangeViewRef.current(viewId);
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
51
|
+
const contextValue = useCreateContextStore<
|
|
52
|
+
GridContextState<S, CommandContext>
|
|
53
|
+
>({
|
|
54
|
+
schema: props.schema,
|
|
55
|
+
columnFilters: {},
|
|
56
|
+
data: {
|
|
57
|
+
logicalName: props.schema.logicalName,
|
|
58
|
+
records: [],
|
|
59
|
+
count: 0,
|
|
60
|
+
},
|
|
61
|
+
searchText: '',
|
|
62
|
+
selectedIds: [],
|
|
63
|
+
sorting: props.view.experience.defaultSorting ?? [],
|
|
64
|
+
view: props.view,
|
|
65
|
+
commands: props.commands,
|
|
66
|
+
columns: transformViewColumns(
|
|
67
|
+
props.view.logicalName,
|
|
68
|
+
props.view.experience.grid.columns,
|
|
69
|
+
schemaStore,
|
|
70
|
+
language
|
|
71
|
+
),
|
|
72
|
+
viewLookup: props.views,
|
|
73
|
+
extraFilter: props.extraFilter,
|
|
74
|
+
dataState: {
|
|
75
|
+
hasNextPage: false,
|
|
76
|
+
isFetching: false,
|
|
77
|
+
isFetchingNextPage: false,
|
|
78
|
+
},
|
|
79
|
+
fetchNextPage: () => {},
|
|
80
|
+
onChangeView: handleViewChange,
|
|
81
|
+
isSubGrid: props.isSubGrid ?? false,
|
|
82
|
+
allowViewSelection: props.allowViewSelection ?? false,
|
|
83
|
+
maxRecords: props.maxRecords,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
contextValue.setValue({
|
|
88
|
+
view: props.view,
|
|
89
|
+
searchText: '',
|
|
90
|
+
selectedIds: [],
|
|
91
|
+
sorting: props.view.experience.defaultSorting ?? [],
|
|
92
|
+
columns: transformViewColumns(
|
|
93
|
+
props.view.logicalName,
|
|
94
|
+
props.view.experience.grid.columns,
|
|
95
|
+
schemaStore,
|
|
96
|
+
language
|
|
97
|
+
),
|
|
98
|
+
maxRecords: props.maxRecords,
|
|
99
|
+
});
|
|
100
|
+
}, [props.view, props.maxRecords, contextValue, schemaStore, language]);
|
|
101
|
+
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
contextValue.setValue({
|
|
104
|
+
schema: props.schema,
|
|
105
|
+
searchText: '',
|
|
106
|
+
selectedIds: [],
|
|
107
|
+
});
|
|
108
|
+
}, [props.schema, contextValue]);
|
|
109
|
+
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
contextValue.setValue({
|
|
112
|
+
extraFilter: props.extraFilter,
|
|
113
|
+
});
|
|
114
|
+
}, [props.extraFilter, contextValue]);
|
|
115
|
+
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
contextValue.setValue({
|
|
118
|
+
commands: props.commands,
|
|
119
|
+
});
|
|
120
|
+
}, [props.commands, contextValue]);
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<GridContext.Provider
|
|
124
|
+
value={
|
|
125
|
+
contextValue as unknown as ContextValue<
|
|
126
|
+
GridContextState<SchemaAttributes>
|
|
127
|
+
>
|
|
128
|
+
}
|
|
129
|
+
>
|
|
130
|
+
<DataResolver />
|
|
131
|
+
{props.children}
|
|
132
|
+
</GridContext.Provider>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ViewColumn } from '@headless-adminapp/core/experience/view';
|
|
2
|
+
import { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
+
import { ISchemaStore } from '@headless-adminapp/core/store';
|
|
4
|
+
|
|
5
|
+
import { localizedLabel } from '../../builders/CommandBuilder';
|
|
6
|
+
import { TransformedViewColumn } from '../context';
|
|
7
|
+
|
|
8
|
+
export function transformViewColumns<S extends SchemaAttributes>(
|
|
9
|
+
logicalName: string,
|
|
10
|
+
columns: ViewColumn<S>[],
|
|
11
|
+
schemaStore: ISchemaStore,
|
|
12
|
+
language: string
|
|
13
|
+
): TransformedViewColumn<S>[] {
|
|
14
|
+
const schema = schemaStore.getSchema(logicalName);
|
|
15
|
+
|
|
16
|
+
return columns
|
|
17
|
+
.map((column) => {
|
|
18
|
+
const attribute = schema.attributes[column.name as string];
|
|
19
|
+
|
|
20
|
+
if (!attribute) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const label = localizedLabel(language, attribute);
|
|
25
|
+
|
|
26
|
+
if (column.expandedKey) {
|
|
27
|
+
if (attribute.type !== 'lookup') {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const lookupSchema = schemaStore.getSchema(attribute.entity);
|
|
32
|
+
const lookupAttribute = lookupSchema.attributes[column.expandedKey];
|
|
33
|
+
|
|
34
|
+
if (!lookupAttribute) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const lookupLabel = localizedLabel(language, lookupAttribute);
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
...column,
|
|
42
|
+
id: `${column.name as string}.${column.expandedKey}`,
|
|
43
|
+
label: `${lookupLabel} (${label})`,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
...column,
|
|
49
|
+
id: column.name as string,
|
|
50
|
+
label: label,
|
|
51
|
+
};
|
|
52
|
+
})
|
|
53
|
+
.filter(Boolean) as unknown as TransformedViewColumn<S>[];
|
|
54
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ColumnCondition } from '@headless-adminapp/core/experience/view';
|
|
2
|
+
import { Schema } from '@headless-adminapp/core/schema';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
|
|
5
|
+
export function transformColumnFilter(
|
|
6
|
+
filter: Partial<Record<string, ColumnCondition>>,
|
|
7
|
+
schema: Schema,
|
|
8
|
+
getSchema: (logicalName: string) => Schema
|
|
9
|
+
) {
|
|
10
|
+
const transformedResult = Object.entries(filter).reduce(
|
|
11
|
+
(acc, [id, value]) => {
|
|
12
|
+
const [key, extendedKey] = id.split('.');
|
|
13
|
+
let attribute = schema.attributes[key];
|
|
14
|
+
|
|
15
|
+
if (!attribute) {
|
|
16
|
+
return acc;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (extendedKey) {
|
|
20
|
+
if (attribute.type !== 'lookup') {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`Invalid column filter key: ${id}. Key ${key} is not a lookup column.`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const lookupSchema = getSchema(attribute.entity);
|
|
27
|
+
attribute = lookupSchema.attributes[extendedKey];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!attribute) {
|
|
31
|
+
return acc;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (value) {
|
|
35
|
+
let transformedValue: any = undefined;
|
|
36
|
+
|
|
37
|
+
switch (value.operator) {
|
|
38
|
+
case 'eq':
|
|
39
|
+
case 'ne':
|
|
40
|
+
case 'begins-with':
|
|
41
|
+
case 'not-begin-with':
|
|
42
|
+
case 'like':
|
|
43
|
+
case 'not-like':
|
|
44
|
+
case 'ends-with':
|
|
45
|
+
case 'not-end-with':
|
|
46
|
+
case 'gt':
|
|
47
|
+
case 'gte':
|
|
48
|
+
case 'lt':
|
|
49
|
+
case 'lte':
|
|
50
|
+
case 'last-x-days':
|
|
51
|
+
case 'last-x-hours':
|
|
52
|
+
transformedValue = value.value[0];
|
|
53
|
+
break;
|
|
54
|
+
case 'on':
|
|
55
|
+
case 'on-or-after':
|
|
56
|
+
case 'on-or-before':
|
|
57
|
+
transformedValue = dayjs(value.value[0]).format('YYYY-MM-DD');
|
|
58
|
+
break;
|
|
59
|
+
case 'in':
|
|
60
|
+
case 'not-in':
|
|
61
|
+
if (attribute.type === 'lookup') {
|
|
62
|
+
transformedValue = value.value[0].map((x: any) => x.id);
|
|
63
|
+
} else {
|
|
64
|
+
transformedValue = value.value[0];
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
case 'between':
|
|
68
|
+
transformedValue = value.value;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
acc[key] = {
|
|
73
|
+
operator: value.operator,
|
|
74
|
+
value: transformedValue,
|
|
75
|
+
extendedKey,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return acc;
|
|
80
|
+
},
|
|
81
|
+
{} as Record<string, ColumnCondition>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
if (Object.keys(transformedResult).length === 0) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return transformedResult;
|
|
89
|
+
}
|