@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,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BasicDialogProps,
|
|
3
|
+
DialogOptions,
|
|
4
|
+
} from '@headless-adminapp/core/experience/dialog';
|
|
5
|
+
|
|
6
|
+
import { createContext } from '../mutable/context';
|
|
7
|
+
|
|
8
|
+
export type DialogItemState = BasicDialogProps & DialogOptions;
|
|
9
|
+
|
|
10
|
+
export interface DialogContextState {
|
|
11
|
+
items: DialogItemState[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const DialogContext = createContext<DialogContextState>();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './useCloseDialog';
|
|
2
|
+
export * from './useDialogItem';
|
|
3
|
+
export * from './useDialogItems';
|
|
4
|
+
export * from './useOpenAlertDialog';
|
|
5
|
+
export * from './useOpenConfirmDialog';
|
|
6
|
+
export * from './useOpenDialog';
|
|
7
|
+
export * from './useOpenErrorDialog';
|
|
8
|
+
export * from './useOpenPromptDialog';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useContextSetValue } from '../../mutable/context';
|
|
4
|
+
import { DialogContext } from '../context';
|
|
5
|
+
|
|
6
|
+
export function useCloseDialog() {
|
|
7
|
+
const setValue = useContextSetValue(DialogContext);
|
|
8
|
+
|
|
9
|
+
const closeDialog = useCallback(
|
|
10
|
+
(id: string) => {
|
|
11
|
+
setValue((state) => {
|
|
12
|
+
return {
|
|
13
|
+
items: state.items.map((item) => {
|
|
14
|
+
if (item.id === id) {
|
|
15
|
+
return { ...item, isOpen: false };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return item;
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Simulate a delay to show the dialog closing animation
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
setValue((state) => {
|
|
26
|
+
return {
|
|
27
|
+
items: state.items.filter((item) => item.id !== id),
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}, 1000);
|
|
31
|
+
},
|
|
32
|
+
[setValue]
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return closeDialog;
|
|
36
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AlertDialogOptions } from '@headless-adminapp/core/experience/dialog';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
import { useOpenDialog } from './useOpenDialog';
|
|
5
|
+
|
|
6
|
+
export function useOpenAlertDialog() {
|
|
7
|
+
const openDialog = useOpenDialog();
|
|
8
|
+
|
|
9
|
+
const openAlertDialog = useCallback(
|
|
10
|
+
(options: Omit<AlertDialogOptions, 'type' | 'onConfirm' | 'onClose'>) => {
|
|
11
|
+
return new Promise<void>((resolve) => {
|
|
12
|
+
const { close } = openDialog({
|
|
13
|
+
type: 'alert',
|
|
14
|
+
...options,
|
|
15
|
+
onDismiss: () => {
|
|
16
|
+
close();
|
|
17
|
+
resolve();
|
|
18
|
+
},
|
|
19
|
+
onConfirm: () => {
|
|
20
|
+
close();
|
|
21
|
+
resolve();
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
[openDialog]
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
return openAlertDialog;
|
|
30
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfirmDialogOptions,
|
|
3
|
+
ConfirmResult,
|
|
4
|
+
} from '@headless-adminapp/core/experience/dialog';
|
|
5
|
+
import { useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
import { useOpenDialog } from './useOpenDialog';
|
|
8
|
+
|
|
9
|
+
export function useOpenConfirmDialog() {
|
|
10
|
+
const openDialog = useOpenDialog();
|
|
11
|
+
|
|
12
|
+
const openConfirmDialog = useCallback(
|
|
13
|
+
(
|
|
14
|
+
options: Omit<
|
|
15
|
+
ConfirmDialogOptions,
|
|
16
|
+
'type' | 'onConfirm' | 'onDismiss' | 'onCancel'
|
|
17
|
+
>
|
|
18
|
+
) => {
|
|
19
|
+
return new Promise<ConfirmResult | null>((resolve) => {
|
|
20
|
+
const { close } = openDialog({
|
|
21
|
+
type: 'confirm',
|
|
22
|
+
...options,
|
|
23
|
+
onDismiss: () => {
|
|
24
|
+
if (!options.allowDismiss) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
close();
|
|
28
|
+
resolve(null);
|
|
29
|
+
},
|
|
30
|
+
onConfirm: () => {
|
|
31
|
+
close();
|
|
32
|
+
resolve({ confirmed: true });
|
|
33
|
+
},
|
|
34
|
+
onCancel: () => {
|
|
35
|
+
close();
|
|
36
|
+
resolve({ confirmed: false });
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
[openDialog]
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return openConfirmDialog;
|
|
45
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DialogOptions } from '@headless-adminapp/core/experience/dialog';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
import { useContextSetValue } from '../../mutable/context';
|
|
5
|
+
import { DialogContext, DialogItemState } from '../context';
|
|
6
|
+
import { useCloseDialog } from './useCloseDialog';
|
|
7
|
+
|
|
8
|
+
function randomId() {
|
|
9
|
+
return Math.random().toString(36).substring(2);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useOpenDialog() {
|
|
13
|
+
const setValue = useContextSetValue(DialogContext);
|
|
14
|
+
const closeDialog = useCloseDialog();
|
|
15
|
+
|
|
16
|
+
const openDialog = useCallback(
|
|
17
|
+
(options: DialogOptions) => {
|
|
18
|
+
const id = randomId();
|
|
19
|
+
|
|
20
|
+
setValue((state) => {
|
|
21
|
+
return {
|
|
22
|
+
items: [
|
|
23
|
+
...state.items,
|
|
24
|
+
{
|
|
25
|
+
id,
|
|
26
|
+
isOpen: true,
|
|
27
|
+
...options,
|
|
28
|
+
} as DialogItemState,
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return { id, close: () => closeDialog(id) };
|
|
34
|
+
},
|
|
35
|
+
[setValue, closeDialog]
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return openDialog;
|
|
39
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AlertDialogOptions } from '@headless-adminapp/core/experience/dialog';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
import { useOpenDialog } from './useOpenDialog';
|
|
5
|
+
|
|
6
|
+
export function useOpenErrorDialog() {
|
|
7
|
+
const openDialog = useOpenDialog();
|
|
8
|
+
|
|
9
|
+
const openErrorDialog = useCallback(
|
|
10
|
+
(options: Omit<AlertDialogOptions, 'type' | 'onConfirm' | 'onClose'>) => {
|
|
11
|
+
const { close } = openDialog({
|
|
12
|
+
type: 'error',
|
|
13
|
+
...options,
|
|
14
|
+
onDismiss: () => {
|
|
15
|
+
close();
|
|
16
|
+
},
|
|
17
|
+
onConfirm: () => {
|
|
18
|
+
close();
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
[openDialog]
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return openErrorDialog;
|
|
26
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { PromptDialogOptions } from '@headless-adminapp/core/experience/dialog';
|
|
2
|
+
import {
|
|
3
|
+
InferredSchemaType,
|
|
4
|
+
SchemaAttributes,
|
|
5
|
+
} from '@headless-adminapp/core/schema';
|
|
6
|
+
import { useCallback } from 'react';
|
|
7
|
+
|
|
8
|
+
import { useOpenDialog } from './useOpenDialog';
|
|
9
|
+
|
|
10
|
+
export function useOpenPromptDialog() {
|
|
11
|
+
const openDialog = useOpenDialog();
|
|
12
|
+
|
|
13
|
+
const openPromptDialog = useCallback(
|
|
14
|
+
<SA extends SchemaAttributes = SchemaAttributes>(
|
|
15
|
+
options: Omit<
|
|
16
|
+
PromptDialogOptions<SA>,
|
|
17
|
+
'type' | 'onConfirm' | 'onClose' | 'onCancel'
|
|
18
|
+
>
|
|
19
|
+
) => {
|
|
20
|
+
return new Promise<InferredSchemaType<SA> | null>((resolve) => {
|
|
21
|
+
const { close } = openDialog({
|
|
22
|
+
type: 'prompt',
|
|
23
|
+
...options,
|
|
24
|
+
onDismiss: () => {
|
|
25
|
+
if (!options.allowDismiss) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
close();
|
|
29
|
+
resolve(null);
|
|
30
|
+
},
|
|
31
|
+
onConfirm: (result) => {
|
|
32
|
+
close();
|
|
33
|
+
resolve(result as InferredSchemaType<SA>);
|
|
34
|
+
},
|
|
35
|
+
onCancel: () => {
|
|
36
|
+
close();
|
|
37
|
+
resolve(null);
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
[openDialog]
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return openPromptDialog;
|
|
46
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface FormValidationStringSet {
|
|
4
|
+
required: string;
|
|
5
|
+
maxLength: string;
|
|
6
|
+
minLength: string;
|
|
7
|
+
invalidFormat: string;
|
|
8
|
+
invalidEmail: string;
|
|
9
|
+
invalidPhoneNumber: string;
|
|
10
|
+
atLeastOneRowRequired: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const defaultFormValidationStrings: FormValidationStringSet = {
|
|
14
|
+
required: 'Required field must be filled in.',
|
|
15
|
+
maxLength: 'Maximum length exceeded.',
|
|
16
|
+
minLength: 'Minimum length not met.',
|
|
17
|
+
invalidFormat: 'Invalid format.',
|
|
18
|
+
invalidEmail: 'Invalid email.',
|
|
19
|
+
invalidPhoneNumber: 'Invalid phone number.',
|
|
20
|
+
atLeastOneRowRequired: 'At least one row required.',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const FormValidationStringContext =
|
|
24
|
+
createContext<FormValidationStringSet>(defaultFormValidationStrings);
|
|
25
|
+
|
|
26
|
+
export function useFormValidationStrings() {
|
|
27
|
+
const context = useContext(FormValidationStringContext);
|
|
28
|
+
|
|
29
|
+
return context;
|
|
30
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
export function useDebouncedValue<T = any>(
|
|
6
|
+
value: T,
|
|
7
|
+
wait: number,
|
|
8
|
+
options = { leading: false }
|
|
9
|
+
) {
|
|
10
|
+
const [_value, setValue] = useState(value);
|
|
11
|
+
const mountedRef = useRef(false);
|
|
12
|
+
const timeoutRef = useRef<number | null>(null);
|
|
13
|
+
const cooldownRef = useRef(false);
|
|
14
|
+
|
|
15
|
+
const cancel = () => window.clearTimeout(timeoutRef.current!);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (mountedRef.current) {
|
|
19
|
+
if (!cooldownRef.current && options.leading) {
|
|
20
|
+
cooldownRef.current = true;
|
|
21
|
+
setValue(value);
|
|
22
|
+
} else {
|
|
23
|
+
cancel();
|
|
24
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
25
|
+
cooldownRef.current = false;
|
|
26
|
+
setValue(value);
|
|
27
|
+
}, wait);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}, [value, options.leading, wait]);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
mountedRef.current = true;
|
|
34
|
+
return cancel;
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
return [_value, cancel] as const;
|
|
38
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { RefObject, useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
interface Size {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function useElementSize(
|
|
9
|
+
elementRef: RefObject<HTMLElement>,
|
|
10
|
+
interval?: number
|
|
11
|
+
) {
|
|
12
|
+
const [size, setSize] = useState<Size>({ width: 0, height: 0 });
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
function updateSize() {
|
|
16
|
+
if (elementRef.current) {
|
|
17
|
+
const element = elementRef.current;
|
|
18
|
+
const rect = element.getBoundingClientRect();
|
|
19
|
+
setSize((size) => {
|
|
20
|
+
if (size.width === rect.width && size.height === rect.height) {
|
|
21
|
+
return size;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return { width: rect.width, height: rect.height };
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
updateSize();
|
|
30
|
+
|
|
31
|
+
let intervalId: NodeJS.Timeout;
|
|
32
|
+
|
|
33
|
+
if (interval) {
|
|
34
|
+
intervalId = setInterval(updateSize, interval);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
window.addEventListener('resize', updateSize);
|
|
38
|
+
|
|
39
|
+
return () => {
|
|
40
|
+
window.removeEventListener('resize', updateSize);
|
|
41
|
+
|
|
42
|
+
if (intervalId) {
|
|
43
|
+
clearInterval(intervalId);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}, [elementRef, interval]);
|
|
47
|
+
|
|
48
|
+
return size;
|
|
49
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import debounce from 'lodash/debounce';
|
|
4
|
+
import { useLayoutEffect, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
export function useIsMobile() {
|
|
7
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
8
|
+
|
|
9
|
+
useLayoutEffect(() => {
|
|
10
|
+
const updateSize = (): void => {
|
|
11
|
+
setIsMobile(window.innerWidth < 768);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
window.addEventListener('resize', debounce(updateSize, 250));
|
|
15
|
+
updateSize();
|
|
16
|
+
|
|
17
|
+
return () => window.removeEventListener('resize', updateSize);
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
return isMobile;
|
|
21
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction, useCallback, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
function getStorageValue<S>(key: string, store: Storage): S | undefined {
|
|
4
|
+
const value = store.getItem(key);
|
|
5
|
+
if (value) {
|
|
6
|
+
return JSON.parse(value);
|
|
7
|
+
}
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function setStorageValue<S>(key: string, value: S, store: Storage): void {
|
|
12
|
+
store.setItem(key, JSON.stringify(value));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function useStorageState<S = undefined>(
|
|
16
|
+
initialState: S,
|
|
17
|
+
key: string,
|
|
18
|
+
store: Storage = localStorage
|
|
19
|
+
): [S, Dispatch<SetStateAction<S>>] {
|
|
20
|
+
const [state, setState] = useState(
|
|
21
|
+
getStorageValue(key, store) ?? initialState
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const setStoredState: Dispatch<SetStateAction<S>> = useCallback(
|
|
25
|
+
(value) => {
|
|
26
|
+
setState((prevState) => {
|
|
27
|
+
const finalState = value instanceof Function ? value(prevState) : value;
|
|
28
|
+
setStorageValue(key, finalState, store);
|
|
29
|
+
return finalState;
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
[key, store]
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return [state, setStoredState];
|
|
36
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
const isSystemDarkMode = () => {
|
|
6
|
+
if (typeof window === 'undefined') {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
window.matchMedia &&
|
|
12
|
+
window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function useSystemColorScheme() {
|
|
17
|
+
const [systemColorScheme, setSystemColorScheme] = useState<'dark' | 'light'>(
|
|
18
|
+
isSystemDarkMode() ? 'dark' : 'light'
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setSystemColorScheme(isSystemDarkMode() ? 'dark' : 'light');
|
|
23
|
+
|
|
24
|
+
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
25
|
+
|
|
26
|
+
const handleChange = (e: MediaQueryListEvent) => {
|
|
27
|
+
setSystemColorScheme(e.matches ? 'dark' : 'light');
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
mediaQuery.addEventListener('change', handleChange);
|
|
31
|
+
|
|
32
|
+
return () => {
|
|
33
|
+
mediaQuery.removeEventListener('change', handleChange);
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
return systemColorScheme;
|
|
38
|
+
}
|
package/src/index.css
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import { LocaleContext } from './context';
|
|
4
|
+
|
|
5
|
+
export function useLocale() {
|
|
6
|
+
const context = useContext(LocaleContext);
|
|
7
|
+
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error('useLocale must be used within a LocaleProvider');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return context;
|
|
13
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IClientAppStore,
|
|
3
|
+
ISchemaExperienceStore,
|
|
4
|
+
ISchemaStore,
|
|
5
|
+
} from '@headless-adminapp/core/store';
|
|
6
|
+
import { FC, PropsWithChildren } from 'react';
|
|
7
|
+
|
|
8
|
+
import { useCreateContextStore } from '../mutable/context';
|
|
9
|
+
import { MetadataContext, MetadataContextState } from './context';
|
|
10
|
+
|
|
11
|
+
interface MetadataProviderProps {
|
|
12
|
+
schemaStore: ISchemaStore;
|
|
13
|
+
experienceStore: ISchemaExperienceStore;
|
|
14
|
+
appStore: IClientAppStore;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const MetadataProvider: FC<PropsWithChildren<MetadataProviderProps>> = ({
|
|
18
|
+
children,
|
|
19
|
+
experienceStore,
|
|
20
|
+
schemaStore,
|
|
21
|
+
appStore,
|
|
22
|
+
}) => {
|
|
23
|
+
const contextValue = useCreateContextStore<MetadataContextState>({
|
|
24
|
+
// schemas: {},
|
|
25
|
+
// schemaLoading: true,
|
|
26
|
+
experienceStore,
|
|
27
|
+
schemaStore,
|
|
28
|
+
appStore,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// const [loading, setLoading] = useState(true);
|
|
32
|
+
|
|
33
|
+
// useEffect(() => {
|
|
34
|
+
// const schemas = schemaStore.getSchemas();
|
|
35
|
+
// contextValue.setValue({
|
|
36
|
+
// schemas,
|
|
37
|
+
// schemaLoading: false,
|
|
38
|
+
// });
|
|
39
|
+
// setLoading(false);
|
|
40
|
+
// }, [contextValue, schemaStore]);
|
|
41
|
+
|
|
42
|
+
// if (loading) {
|
|
43
|
+
// return null;
|
|
44
|
+
// }
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<MetadataContext.Provider value={contextValue}>
|
|
48
|
+
{children}
|
|
49
|
+
</MetadataContext.Provider>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IClientAppStore,
|
|
3
|
+
ISchemaExperienceStore,
|
|
4
|
+
ISchemaStore,
|
|
5
|
+
} from '@headless-adminapp/core/store';
|
|
6
|
+
|
|
7
|
+
import { createContext } from '../mutable/context';
|
|
8
|
+
|
|
9
|
+
export interface MetadataContextState {
|
|
10
|
+
appStore: IClientAppStore;
|
|
11
|
+
schemaStore: ISchemaStore;
|
|
12
|
+
experienceStore: ISchemaExperienceStore;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const MetadataContext = createContext<MetadataContextState>();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './useAppStore';
|
|
2
|
+
export * from './useExperienceStore';
|
|
3
|
+
export * from './useExperienceView';
|
|
4
|
+
export * from './useExperienceViewCommands';
|
|
5
|
+
export * from './useExperienceViewLookup';
|
|
6
|
+
export * from './useExperienceViewSubgridCommands';
|
|
7
|
+
export * from './useMetadata';
|
|
8
|
+
export * from './useSchema';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
|
2
|
+
|
|
3
|
+
import { useExperienceStore } from './useExperienceStore';
|
|
4
|
+
|
|
5
|
+
export function useExperienceView(
|
|
6
|
+
logicalName: string,
|
|
7
|
+
viewId?: string,
|
|
8
|
+
associated?: boolean,
|
|
9
|
+
viewIds?: string[]
|
|
10
|
+
) {
|
|
11
|
+
const experienceStore = useExperienceStore();
|
|
12
|
+
|
|
13
|
+
const { data, isPending } = useQuery({
|
|
14
|
+
queryKey: [
|
|
15
|
+
'experience-schema-view',
|
|
16
|
+
logicalName,
|
|
17
|
+
viewId,
|
|
18
|
+
associated,
|
|
19
|
+
viewIds,
|
|
20
|
+
],
|
|
21
|
+
queryFn: async () => {
|
|
22
|
+
if (associated) {
|
|
23
|
+
return experienceStore.getAssociatedView(logicalName, viewId, viewIds);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return experienceStore.getPublicView(logicalName, viewId, viewIds);
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
placeholderData: keepPreviousData,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
view: data,
|
|
34
|
+
isLoadingView: isPending,
|
|
35
|
+
};
|
|
36
|
+
}
|