@headless-adminapp/app 0.0.17-alpha.52 → 0.0.17-alpha.53
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/app/AppProvider.js +13 -17
- package/app/AuthWrapper.js +9 -13
- package/app/LayoutProvider.js +16 -20
- package/app/context.js +2 -5
- package/app/hooks/index.js +1 -17
- package/app/hooks/useAppContext.js +4 -7
- package/app/index.js +4 -11
- package/auth/AuthProvider.js +17 -21
- package/auth/context.d.ts +1 -1
- package/auth/context.js +2 -5
- package/auth/hooks/index.js +2 -18
- package/auth/hooks/useAuthSession.js +4 -7
- package/auth/hooks/useIsSkipAuthCheck.js +4 -7
- package/auth/hooks/useLogout.js +7 -10
- package/auth/index.js +4 -23
- package/auth/types.js +1 -2
- package/board/BoardColumnDataResolver.js +20 -23
- package/board/BoardColumnProvider.js +10 -14
- package/board/context.js +3 -6
- package/board/hooks/index.js +6 -15
- package/board/hooks/useBoardColumnConfig.js +4 -7
- package/board/hooks/useBoardColumnData.js +4 -7
- package/board/hooks/useBoardColumnDataState.js +4 -7
- package/board/hooks/useBoardConfig.js +4 -7
- package/board/hooks/useBoardSchema.js +3 -6
- package/board/hooks/useSearchText.js +7 -10
- package/board/types.js +1 -2
- package/board/utils.js +1 -4
- package/builders/CommandBuilder/CommandBuilder.js +10 -13
- package/builders/CommandBuilder/DefaultCommandBuilder.js +22 -25
- package/builders/CommandBuilder/FormCommandBuilder.js +9 -12
- package/builders/CommandBuilder/SubgridCommandBuilder.js +11 -14
- package/builders/CommandBuilder/ViewCommandBuilder.js +14 -17
- package/builders/CommandBuilder/index.js +1 -5
- package/builders/CommandBuilder/utils.js +2 -6
- package/builders/SchemaExperienceBuilder.js +1 -5
- package/builders/index.js +2 -7
- package/builders/utils.js +12 -41
- package/command/hooks/index.js +2 -18
- package/command/hooks/useBaseCommandHandlerContext.js +25 -29
- package/command/hooks/useCommands.js +6 -9
- package/command/index.js +2 -18
- package/command/types.js +1 -2
- package/command/utils/index.js +4 -7
- package/components/ScrollView/index.js +4 -11
- package/components/ScrollbarWithMoreDataRequest/index.js +9 -13
- package/dataform/DataFormProvider/DataResolver.d.ts +2 -2
- package/dataform/DataFormProvider/DataResolver.js +31 -32
- package/dataform/DataFormProvider/InitialValueResolver.js +19 -22
- package/dataform/DataFormProvider/ReadonlyInfoResolver.js +9 -12
- package/dataform/DataFormProvider/index.js +22 -25
- package/dataform/context.js +2 -5
- package/dataform/hooks/index.js +13 -29
- package/dataform/hooks/useFormInstance.js +3 -6
- package/dataform/hooks/useFormIsDirty.js +3 -6
- package/dataform/hooks/useFormIsReadonly.js +4 -7
- package/dataform/hooks/useFormNotifications.js +7 -10
- package/dataform/hooks/useFormRecord.js +4 -7
- package/dataform/hooks/useFormSave.js +30 -33
- package/dataform/hooks/useFormSchema.js +4 -7
- package/dataform/hooks/useLoadFormGridPage.js +10 -13
- package/dataform/hooks/useMainFormCommands.js +27 -32
- package/dataform/hooks/useProcessFlowSteps.js +18 -21
- package/dataform/hooks/useRecordId.js +4 -7
- package/dataform/hooks/useRecordTitle.d.ts +3 -1
- package/dataform/hooks/useRecordTitle.js +11 -14
- package/dataform/hooks/useSelectedForm.js +4 -7
- package/dataform/index.js +4 -23
- package/dataform/utils/defaultParameters.js +2 -6
- package/dataform/utils/index.d.ts +1 -1
- package/dataform/utils/index.js +17 -45
- package/dataform/utils/saveRecord.js +5 -9
- package/datagrid/DataGridProvider/DataResolver.js +42 -39
- package/datagrid/DataGridProvider/index.js +22 -25
- package/datagrid/DataGridProvider/transformViewColumns.js +4 -7
- package/datagrid/DataGridProvider/utils.js +5 -13
- package/datagrid/column-filter/constants.js +2 -5
- package/datagrid/column-filter/index.js +2 -7
- package/datagrid/column-filter/types.js +1 -2
- package/datagrid/column-filter/utils.js +3 -7
- package/datagrid/context.d.ts +1 -1
- package/datagrid/context.js +2 -5
- package/datagrid/hooks/index.js +20 -36
- package/datagrid/hooks/useChangeView.js +6 -9
- package/datagrid/hooks/useGridColumnFilter.js +7 -10
- package/datagrid/hooks/useGridColumns.js +4 -7
- package/datagrid/hooks/useGridCommands.js +4 -7
- package/datagrid/hooks/useGridData.js +4 -7
- package/datagrid/hooks/useGridDataState.js +4 -7
- package/datagrid/hooks/useGridExtraFilter.js +4 -7
- package/datagrid/hooks/useGridOptions.js +1 -4
- package/datagrid/hooks/useGridPagination.js +1 -4
- package/datagrid/hooks/useGridRefresh.js +7 -10
- package/datagrid/hooks/useGridSchema.js +4 -7
- package/datagrid/hooks/useGridSelection.js +7 -10
- package/datagrid/hooks/useGridSorting.js +7 -10
- package/datagrid/hooks/useGridViewLookupData.js +4 -7
- package/datagrid/hooks/useLoadMainGridPage.js +9 -12
- package/datagrid/hooks/useMainGridCommands.js +50 -57
- package/datagrid/hooks/useMaxRecords.js +4 -7
- package/datagrid/hooks/useOpenRecord.js +15 -18
- package/datagrid/hooks/useSearchText.js +7 -10
- package/datagrid/hooks/useSelectedView.js +4 -7
- package/datagrid/hooks/useSubGridCommands.js +19 -24
- package/datagrid/index.js +5 -27
- package/defaults.js +2 -5
- package/dialog/DialogProvider.js +6 -10
- package/dialog/context.d.ts +1 -1
- package/dialog/context.js +2 -5
- package/dialog/hooks/index.js +8 -24
- package/dialog/hooks/useCloseDialog.js +6 -9
- package/dialog/hooks/useDialogItem.d.ts +1 -1
- package/dialog/hooks/useDialogItem.js +4 -7
- package/dialog/hooks/useDialogItems.d.ts +1 -1
- package/dialog/hooks/useDialogItems.js +4 -7
- package/dialog/hooks/useOpenAlertDialog.js +5 -8
- package/dialog/hooks/useOpenConfirmDialog.js +5 -8
- package/dialog/hooks/useOpenDialog.js +10 -13
- package/dialog/hooks/useOpenErrorDialog.js +5 -8
- package/dialog/hooks/useOpenPromptDialog.js +5 -8
- package/dialog/index.js +3 -22
- package/form/FormValidationStringContext.js +5 -9
- package/form/index.js +1 -7
- package/hooks/index.js +6 -24
- package/hooks/useDebouncedValue.js +8 -11
- package/hooks/useElementLayout.js +4 -7
- package/hooks/useIsMobile.js +6 -12
- package/hooks/useItemsWithKey.js +5 -8
- package/hooks/useStorageState.js +4 -7
- package/hooks/useSystemColorScheme.js +4 -7
- package/insights/InsightsProvider.js +10 -13
- package/insights/context.d.ts +1 -1
- package/insights/context.js +2 -5
- package/insights/hooks/index.js +4 -7
- package/insights/index.js +2 -20
- package/locale/LocaleProvider.js +8 -12
- package/locale/context.js +2 -5
- package/locale/index.js +4 -23
- package/locale/useCurrencySymbol.js +7 -10
- package/locale/useLocale.js +4 -7
- package/locale/utils.js +1 -4
- package/metadata/MetadataProvider.js +17 -21
- package/metadata/context.d.ts +1 -1
- package/metadata/context.js +2 -5
- package/metadata/hooks/index.js +8 -24
- package/metadata/hooks/useAppStore.js +4 -7
- package/metadata/hooks/useExperienceStore.js +4 -7
- package/metadata/hooks/useExperienceView.js +6 -9
- package/metadata/hooks/useExperienceViewCommands.js +7 -10
- package/metadata/hooks/useExperienceViewLookup.js +5 -8
- package/metadata/hooks/useExperienceViewSubgridCommands.js +7 -10
- package/metadata/hooks/useMetadata.js +8 -11
- package/metadata/hooks/useSchema.js +3 -6
- package/metadata/index.js +3 -22
- package/mutable/context.js +17 -25
- package/mutable/index.js +3 -27
- package/mutable/state.js +6 -10
- package/mutable/type.js +1 -2
- package/mutable/utils.js +7 -11
- package/navigation/hooks/index.js +1 -17
- package/navigation/hooks/useOpenForm.js +11 -14
- package/navigation/index.js +1 -17
- package/package.json +3 -2
- package/progress-indicator/ProgressIndicatorProvider.js +12 -16
- package/progress-indicator/context.js +2 -5
- package/progress-indicator/hooks/index.js +1 -17
- package/progress-indicator/hooks/useProgressIndicator.d.ts +1 -1
- package/progress-indicator/hooks/useProgressIndicator.js +4 -7
- package/progress-indicator/index.js +3 -22
- package/providers/PageEntityFormProvider/index.js +4 -7
- package/providers/PageEntityViewProvider/index.js +4 -7
- package/recordset/RecordSetProvider.js +12 -16
- package/recordset/context.d.ts +1 -1
- package/recordset/context.js +2 -5
- package/recordset/hooks/index.js +3 -19
- package/recordset/hooks/useRecordSetResult.js +15 -18
- package/recordset/hooks/useRecordSetSetter.js +6 -9
- package/recordset/hooks/useRecordSetVisibility.js +7 -10
- package/recordset/index.js +3 -22
- package/route/RouteProvider.js +14 -18
- package/route/context.js +6 -9
- package/route/hooks/index.js +6 -22
- package/route/hooks/useBasePath.js +4 -7
- package/route/hooks/useIsRouteActive.js +4 -7
- package/route/hooks/usePathname.js +4 -7
- package/route/hooks/useRouteResolver.js +4 -7
- package/route/hooks/useRouter.js +4 -7
- package/route/hooks/useSearchParams.js +4 -7
- package/route/index.js +2 -20
- package/route/types.js +1 -2
- package/store/ClientAppStore.js +1 -5
- package/store/ComponentStore.js +1 -5
- package/store/EventManager.js +1 -5
- package/store/SchemaExperienceStore.js +2 -7
- package/store/index.js +4 -20
- package/toast-notification/ToastNotificationProvider.js +6 -10
- package/toast-notification/context.d.ts +1 -1
- package/toast-notification/context.js +2 -5
- package/toast-notification/hooks/index.js +3 -19
- package/toast-notification/hooks/useCloseToastNotification.js +6 -9
- package/toast-notification/hooks/useOpenToastNotification.js +10 -13
- package/toast-notification/hooks/useToastNotificationItems.d.ts +1 -1
- package/toast-notification/hooks/useToastNotificationItems.js +4 -7
- package/toast-notification/index.js +3 -22
- package/transport/InMemoryDataService/index.js +1 -5
- package/transport/RestDataService/index.js +5 -10
- package/transport/context.js +4 -7
- package/transport/hooks/index.js +2 -18
- package/transport/hooks/useDataService.js +4 -7
- package/transport/hooks/useFileService.js +4 -7
- package/transport/hooks/useRetriveRecords.d.ts +1 -1
- package/transport/hooks/useRetriveRecords.js +12 -17
- package/transport/index.js +2 -20
- package/utils/calculateColumnWidths.js +1 -4
- package/utils/color.js +1 -4
- package/utils/getAttributeFormattedValue.js +12 -18
- package/utils/index.js +2 -18
- package/widget/context.js +2 -5
- package/widget/hooks/index.js +4 -7
- package/widget/index.js +1 -5
package/app/AppProvider.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,43 +7,40 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const appStore = (0, hooks_1.useAppStore)();
|
|
21
|
-
const { data: schemaMetadataList } = (0, react_query_1.useQuery)({
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { useQuery } from '@tanstack/react-query';
|
|
12
|
+
import { useMemo } from 'react';
|
|
13
|
+
import { useAppStore, useExperienceStore } from '../metadata/hooks';
|
|
14
|
+
import { AppContext } from './context';
|
|
15
|
+
export const AppProvider = ({ children, appId, loadingComponent, notFoundComponent, }) => {
|
|
16
|
+
const experienceStore = useExperienceStore();
|
|
17
|
+
const appStore = useAppStore();
|
|
18
|
+
const { data: schemaMetadataList } = useQuery({
|
|
22
19
|
queryKey: ['experience-schema-metadata-list'],
|
|
23
20
|
queryFn: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
21
|
return experienceStore.getExperienceSchemaMetadatList();
|
|
25
22
|
}),
|
|
26
23
|
initialData: [],
|
|
27
24
|
});
|
|
28
|
-
const { data: app, isLoading } =
|
|
25
|
+
const { data: app, isLoading } = useQuery({
|
|
29
26
|
queryKey: ['experience-app', appId],
|
|
30
27
|
queryFn: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
28
|
return appStore.getApp(appId);
|
|
32
29
|
}),
|
|
33
30
|
});
|
|
34
|
-
const schemaMetadataDic =
|
|
31
|
+
const schemaMetadataDic = useMemo(() => {
|
|
35
32
|
var _a;
|
|
36
33
|
return (_a = schemaMetadataList === null || schemaMetadataList === void 0 ? void 0 : schemaMetadataList.reduce((acc, item) => {
|
|
37
34
|
acc[item.logicalName] = item;
|
|
38
35
|
return acc;
|
|
39
36
|
}, {})) !== null && _a !== void 0 ? _a : {};
|
|
40
37
|
}, [schemaMetadataList]);
|
|
41
|
-
const contextValue =
|
|
38
|
+
const contextValue = useMemo(() => ({ app, schemaMetadataDic, schemaMetadataList }), [app, schemaMetadataDic, schemaMetadataList]);
|
|
42
39
|
if (isLoading) {
|
|
43
40
|
return loadingComponent;
|
|
44
41
|
}
|
|
45
42
|
if (!app) {
|
|
46
43
|
return notFoundComponent;
|
|
47
44
|
}
|
|
48
|
-
return ((
|
|
45
|
+
return (_jsx(AppContext.Provider, { value: contextValue, children: children }));
|
|
49
46
|
};
|
|
50
|
-
exports.AppProvider = AppProvider;
|
package/app/AuthWrapper.js
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const auth_1 = require("../auth");
|
|
6
|
-
const mutable_1 = require("../mutable");
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AuthContext } from '../auth';
|
|
3
|
+
import { useContextSelector } from '../mutable';
|
|
7
4
|
const DefaultPlaceHolder = () => {
|
|
8
5
|
return null;
|
|
9
6
|
};
|
|
10
|
-
const AuthWrapper = ({ children, Placeholder = DefaultPlaceHolder, }) => {
|
|
11
|
-
const state =
|
|
7
|
+
export const AuthWrapper = ({ children, Placeholder = DefaultPlaceHolder, }) => {
|
|
8
|
+
const state = useContextSelector(AuthContext, (state) => state);
|
|
12
9
|
if (state.loadError) {
|
|
13
|
-
return (
|
|
10
|
+
return _jsx(Placeholder, { loadingError: true, retry: state.loadSession });
|
|
14
11
|
}
|
|
15
12
|
if (!state.initialized || state.loading) {
|
|
16
|
-
return (
|
|
13
|
+
return _jsx(Placeholder, { loading: true, retry: state.loadSession });
|
|
17
14
|
}
|
|
18
15
|
if (!state.authenticated) {
|
|
19
16
|
if (state.sessionExpired) {
|
|
20
|
-
return (
|
|
17
|
+
return _jsx(Placeholder, { sessionExpired: true, retry: state.loadSession });
|
|
21
18
|
}
|
|
22
|
-
return (
|
|
19
|
+
return _jsx(Placeholder, { unauthorized: true, retry: state.loadSession });
|
|
23
20
|
}
|
|
24
21
|
return children;
|
|
25
22
|
};
|
|
26
|
-
exports.AuthWrapper = AuthWrapper;
|
package/app/LayoutProvider.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,22 +7,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const context_1 = require("../transport/context");
|
|
26
|
-
const AuthWrapper_1 = require("./AuthWrapper");
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { QueryClientProvider } from '@tanstack/react-query';
|
|
12
|
+
import { AuthProvider, } from '../auth';
|
|
13
|
+
import { queryClient as defaultQueryClient } from '../defaults';
|
|
14
|
+
import { DialogProvider } from '../dialog';
|
|
15
|
+
import { LocaleProvider } from '../locale';
|
|
16
|
+
import { MetadataProvider } from '../metadata';
|
|
17
|
+
import { ProgressIndicatorProvider } from '../progress-indicator';
|
|
18
|
+
import { RecordSetProvider } from '../recordset';
|
|
19
|
+
import { RouteProvider } from '../route';
|
|
20
|
+
import { ToastNotificationProvider } from '../toast-notification';
|
|
21
|
+
import { DataServiceContext } from '../transport';
|
|
22
|
+
import { FileServiceContext, noopFileService } from '../transport/context';
|
|
23
|
+
import { AuthWrapper } from './AuthWrapper';
|
|
27
24
|
const dataServiceNotProvidedError = new Error('No data service provided');
|
|
28
25
|
const defaultDataService = {
|
|
29
26
|
createRecord: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -48,7 +45,6 @@ const defaultDataService = {
|
|
|
48
45
|
throw dataServiceNotProvidedError;
|
|
49
46
|
}),
|
|
50
47
|
};
|
|
51
|
-
const LayoutProvider = ({ authPlaceholder, authProps, dataService = defaultDataService, fileService, localeProps, metadataProps, queryClient =
|
|
52
|
-
return ((
|
|
48
|
+
export const LayoutProvider = ({ authPlaceholder, authProps, dataService = defaultDataService, fileService, localeProps, metadataProps, queryClient = defaultQueryClient, routeProps, children, containers: { DialogContainer, ProgressIndicatorContainer, ToastNotificationContainer, }, }) => {
|
|
49
|
+
return (_jsx(RouteProvider, Object.assign({}, routeProps, { children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(LocaleProvider, Object.assign({}, localeProps, { children: _jsx(MetadataProvider, Object.assign({}, metadataProps, { children: _jsx(DataServiceContext.Provider, { value: dataService, children: _jsx(FileServiceContext.Provider, { value: fileService !== null && fileService !== void 0 ? fileService : noopFileService, children: _jsx(DialogProvider, { children: _jsx(ProgressIndicatorProvider, { children: _jsxs(ToastNotificationProvider, { children: [_jsx(DialogContainer, {}), _jsx(ProgressIndicatorContainer, {}), _jsx(ToastNotificationContainer, {}), _jsx(AuthProvider, Object.assign({}, authProps, { children: _jsx(AuthWrapper, { Placeholder: authPlaceholder, children: _jsx(RecordSetProvider, { children: children }) }) }))] }) }) }) }) }) })) })) }) })));
|
|
53
50
|
};
|
|
54
|
-
exports.LayoutProvider = LayoutProvider;
|
package/app/context.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.AppContext = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
exports.AppContext = (0, react_1.createContext)(null);
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
export const AppContext = createContext(null);
|
package/app/hooks/index.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
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("./useAppContext"), exports);
|
|
1
|
+
export * from './useAppContext';
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const context_1 = require("../context");
|
|
6
|
-
function useAppContext() {
|
|
7
|
-
const context = (0, react_1.useContext)(context_1.AppContext);
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { AppContext } from '../context';
|
|
3
|
+
export function useAppContext() {
|
|
4
|
+
const context = useContext(AppContext);
|
|
8
5
|
if (!context) {
|
|
9
6
|
throw new Error('useAppContext must be used within a AppContextProvider');
|
|
10
7
|
}
|
package/app/index.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "AppContext", { enumerable: true, get: function () { return context_1.AppContext; } });
|
|
6
|
-
var hooks_1 = require("./hooks");
|
|
7
|
-
Object.defineProperty(exports, "useAppContext", { enumerable: true, get: function () { return hooks_1.useAppContext; } });
|
|
8
|
-
var AppProvider_1 = require("./AppProvider");
|
|
9
|
-
Object.defineProperty(exports, "AppProvider", { enumerable: true, get: function () { return AppProvider_1.AppProvider; } });
|
|
10
|
-
var LayoutProvider_1 = require("./LayoutProvider");
|
|
11
|
-
Object.defineProperty(exports, "LayoutProvider", { enumerable: true, get: function () { return LayoutProvider_1.LayoutProvider; } });
|
|
1
|
+
export { AppContext } from './context';
|
|
2
|
+
export { useAppContext } from './hooks';
|
|
3
|
+
export { AppProvider } from './AppProvider';
|
|
4
|
+
export { LayoutProvider } from './LayoutProvider';
|
package/auth/AuthProvider.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,18 +7,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const AuthProvider = ({ sessionResolver, onUnauthenticated, children, }) => {
|
|
19
|
-
const onUnauthenticatedRef = (0, react_1.useRef)(onUnauthenticated);
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
12
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
13
|
+
import { useContextSelectorInternal, useCreateContextStore, } from '../mutable/context';
|
|
14
|
+
import { AuthContext } from './context';
|
|
15
|
+
export const AuthProvider = ({ sessionResolver, onUnauthenticated, children, }) => {
|
|
16
|
+
const onUnauthenticatedRef = useRef(onUnauthenticated);
|
|
20
17
|
onUnauthenticatedRef.current = onUnauthenticated;
|
|
21
|
-
const queryClient =
|
|
22
|
-
const onUnauthenticatedInternal =
|
|
18
|
+
const queryClient = useQueryClient();
|
|
19
|
+
const onUnauthenticatedInternal = useCallback((reason) => {
|
|
23
20
|
var _a;
|
|
24
21
|
(_a = onUnauthenticatedRef.current) === null || _a === void 0 ? void 0 : _a.call(onUnauthenticatedRef, reason);
|
|
25
22
|
queryClient.clear();
|
|
@@ -32,7 +29,7 @@ const AuthProvider = ({ sessionResolver, onUnauthenticated, children, }) => {
|
|
|
32
29
|
})
|
|
33
30
|
.catch(console.error);
|
|
34
31
|
}, [queryClient]);
|
|
35
|
-
const contextValue =
|
|
32
|
+
const contextValue = useCreateContextStore({
|
|
36
33
|
loading: !!sessionResolver,
|
|
37
34
|
loadError: false,
|
|
38
35
|
authenticated: !sessionResolver,
|
|
@@ -41,11 +38,11 @@ const AuthProvider = ({ sessionResolver, onUnauthenticated, children, }) => {
|
|
|
41
38
|
loadSession: () => Promise.resolve(),
|
|
42
39
|
onUnauthenticated: onUnauthenticatedInternal,
|
|
43
40
|
});
|
|
44
|
-
const state =
|
|
41
|
+
const state = useContextSelectorInternal(contextValue, (state) => state);
|
|
45
42
|
const session = state.initialized && state.authenticated && state.session;
|
|
46
|
-
const sessionResolverRef =
|
|
43
|
+
const sessionResolverRef = useRef(sessionResolver);
|
|
47
44
|
sessionResolverRef.current = sessionResolver;
|
|
48
|
-
const loadSession =
|
|
45
|
+
const loadSession = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
46
|
var _a;
|
|
50
47
|
contextValue.setValue({ loading: true, loadError: false });
|
|
51
48
|
try {
|
|
@@ -78,13 +75,13 @@ const AuthProvider = ({ sessionResolver, onUnauthenticated, children, }) => {
|
|
|
78
75
|
contextValue.setValue({ loading: false });
|
|
79
76
|
}
|
|
80
77
|
}), [contextValue]);
|
|
81
|
-
|
|
78
|
+
useEffect(() => {
|
|
82
79
|
contextValue.setValue({ loadSession });
|
|
83
80
|
}, [contextValue, loadSession]);
|
|
84
|
-
|
|
81
|
+
useEffect(() => {
|
|
85
82
|
loadSession().catch(console.error);
|
|
86
83
|
}, [loadSession]);
|
|
87
|
-
|
|
84
|
+
useEffect(() => {
|
|
88
85
|
var _a;
|
|
89
86
|
if (!session) {
|
|
90
87
|
return;
|
|
@@ -119,6 +116,5 @@ const AuthProvider = ({ sessionResolver, onUnauthenticated, children, }) => {
|
|
|
119
116
|
clearTimeout(timer);
|
|
120
117
|
};
|
|
121
118
|
}, [contextValue, session]);
|
|
122
|
-
return ((
|
|
119
|
+
return (_jsx(AuthContext.Provider, { value: contextValue, children: children }));
|
|
123
120
|
};
|
|
124
|
-
exports.AuthProvider = AuthProvider;
|
package/auth/context.d.ts
CHANGED
|
@@ -27,5 +27,5 @@ export interface AuthSession {
|
|
|
27
27
|
profilePicture?: string;
|
|
28
28
|
data?: Record<string, any>;
|
|
29
29
|
}
|
|
30
|
-
export declare const AuthContext: import("react").Context<import("../mutable
|
|
30
|
+
export declare const AuthContext: import("react").Context<import("../mutable").ContextValue<AuthState>>;
|
|
31
31
|
export {};
|
package/auth/context.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.AuthContext = void 0;
|
|
4
|
-
const context_1 = require("../mutable/context");
|
|
5
|
-
exports.AuthContext = (0, context_1.createContext)();
|
|
1
|
+
import { createContext } from '../mutable/context';
|
|
2
|
+
export const AuthContext = createContext();
|
package/auth/hooks/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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("./useAuthSession"), exports);
|
|
18
|
-
__exportStar(require("./useLogout"), exports);
|
|
1
|
+
export * from './useAuthSession';
|
|
2
|
+
export * from './useLogout';
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const context_1 = require("../context");
|
|
6
|
-
function useAuthSession() {
|
|
7
|
-
return (0, mutable_1.useContextSelector)(context_1.AuthContext, (state) => {
|
|
1
|
+
import { useContextSelector } from '../../mutable';
|
|
2
|
+
import { AuthContext } from '../context';
|
|
3
|
+
export function useAuthSession() {
|
|
4
|
+
return useContextSelector(AuthContext, (state) => {
|
|
8
5
|
if (!state.initialized) {
|
|
9
6
|
return null;
|
|
10
7
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const context_1 = require("../context");
|
|
6
|
-
function useIsSkipAuthCheck() {
|
|
7
|
-
return (0, mutable_1.useContextSelector)(context_1.AuthContext, (state) => { var _a; return (_a = state.skipAuthCheck) !== null && _a !== void 0 ? _a : false; });
|
|
1
|
+
import { useContextSelector } from '../../mutable';
|
|
2
|
+
import { AuthContext } from '../context';
|
|
3
|
+
export function useIsSkipAuthCheck() {
|
|
4
|
+
return useContextSelector(AuthContext, (state) => { var _a; return (_a = state.skipAuthCheck) !== null && _a !== void 0 ? _a : false; });
|
|
8
5
|
}
|
package/auth/hooks/useLogout.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const setValue = (0, context_1.useContextSetValue)(context_2.AuthContext);
|
|
9
|
-
const onUnauthenticated = (0, context_1.useContextSelector)(context_2.AuthContext, (state) => state.onUnauthenticated);
|
|
10
|
-
const logout = (0, react_1.useCallback)(() => {
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useContextSelector, useContextSetValue } from '../../mutable/context';
|
|
3
|
+
import { AuthContext } from '../context';
|
|
4
|
+
export function useLogout() {
|
|
5
|
+
const setValue = useContextSetValue(AuthContext);
|
|
6
|
+
const onUnauthenticated = useContextSelector(AuthContext, (state) => state.onUnauthenticated);
|
|
7
|
+
const logout = useCallback(() => {
|
|
11
8
|
setValue({
|
|
12
9
|
initialized: true,
|
|
13
10
|
authenticated: false,
|
package/auth/index.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
exports.AuthProvider = exports.AuthContext = void 0;
|
|
18
|
-
var context_1 = require("./context");
|
|
19
|
-
Object.defineProperty(exports, "AuthContext", { enumerable: true, get: function () { return context_1.AuthContext; } });
|
|
20
|
-
var AuthProvider_1 = require("./AuthProvider");
|
|
21
|
-
Object.defineProperty(exports, "AuthProvider", { enumerable: true, get: function () { return AuthProvider_1.AuthProvider; } });
|
|
22
|
-
__exportStar(require("./types"), exports);
|
|
23
|
-
__exportStar(require("./hooks"), exports);
|
|
1
|
+
export { AuthContext } from './context';
|
|
2
|
+
export { AuthProvider } from './AuthProvider';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export * from './hooks';
|
package/auth/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const useBoardColumnConfig_1 = require("./hooks/useBoardColumnConfig");
|
|
10
|
-
const useBoardConfig_1 = require("./hooks/useBoardConfig");
|
|
11
|
-
const useSearchText_1 = require("./hooks/useSearchText");
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useDebouncedValue } from '../hooks';
|
|
3
|
+
import { useContextSetValue } from '../mutable';
|
|
4
|
+
import { useClearDataExceptFirstPage, useRetrieveRecordsKey, useRetriveRecords, } from '../transport/hooks/useRetriveRecords';
|
|
5
|
+
import { BoardColumnContext } from './context';
|
|
6
|
+
import { useBoardColumnConfig } from './hooks/useBoardColumnConfig';
|
|
7
|
+
import { useBoardConfig } from './hooks/useBoardConfig';
|
|
8
|
+
import { useSearchText } from './hooks/useSearchText';
|
|
12
9
|
const MAX_RECORDS = 10000;
|
|
13
|
-
function DataResolver() {
|
|
14
|
-
const { schema, sorting, projection: { columns, expand }, } =
|
|
15
|
-
const [searchText] =
|
|
16
|
-
const { filter, maxRecords = MAX_RECORDS } =
|
|
17
|
-
const setState =
|
|
18
|
-
const [search] =
|
|
19
|
-
const queryKey =
|
|
10
|
+
export function DataResolver() {
|
|
11
|
+
const { schema, sorting, projection: { columns, expand }, } = useBoardConfig();
|
|
12
|
+
const [searchText] = useSearchText();
|
|
13
|
+
const { filter, maxRecords = MAX_RECORDS } = useBoardColumnConfig();
|
|
14
|
+
const setState = useContextSetValue(BoardColumnContext);
|
|
15
|
+
const [search] = useDebouncedValue(searchText, 500);
|
|
16
|
+
const queryKey = useRetrieveRecordsKey({
|
|
20
17
|
columns,
|
|
21
18
|
expand,
|
|
22
19
|
filter,
|
|
@@ -25,8 +22,8 @@ function DataResolver() {
|
|
|
25
22
|
search,
|
|
26
23
|
sorting,
|
|
27
24
|
});
|
|
28
|
-
|
|
29
|
-
const { fetchNextPage, data, hasNextPage, isFetching, isFetchingNextPage } =
|
|
25
|
+
useClearDataExceptFirstPage(queryKey);
|
|
26
|
+
const { fetchNextPage, data, hasNextPage, isFetching, isFetchingNextPage } = useRetriveRecords(queryKey, {
|
|
30
27
|
columns,
|
|
31
28
|
expand,
|
|
32
29
|
filter,
|
|
@@ -35,12 +32,12 @@ function DataResolver() {
|
|
|
35
32
|
search,
|
|
36
33
|
sorting,
|
|
37
34
|
});
|
|
38
|
-
|
|
35
|
+
useEffect(() => {
|
|
39
36
|
setState({
|
|
40
37
|
fetchNextPage: fetchNextPage,
|
|
41
38
|
});
|
|
42
39
|
}, [fetchNextPage, setState]);
|
|
43
|
-
|
|
40
|
+
useEffect(() => {
|
|
44
41
|
if (!data) {
|
|
45
42
|
setState({
|
|
46
43
|
data: null,
|
|
@@ -51,7 +48,7 @@ function DataResolver() {
|
|
|
51
48
|
data,
|
|
52
49
|
});
|
|
53
50
|
}, [data, setState, schema.idAttribute]);
|
|
54
|
-
|
|
51
|
+
useEffect(() => {
|
|
55
52
|
setState({
|
|
56
53
|
dataState: {
|
|
57
54
|
isFetching,
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const BoardColumnDataResolver_1 = require("./BoardColumnDataResolver");
|
|
8
|
-
const context_1 = require("./context");
|
|
9
|
-
const useBoardConfig_1 = require("./hooks/useBoardConfig");
|
|
10
|
-
function invertValueMapping(value) {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCreateContextStore } from '../mutable';
|
|
3
|
+
import { DataResolver } from './BoardColumnDataResolver';
|
|
4
|
+
import { BoardColumnContext } from './context';
|
|
5
|
+
import { useBoardConfig } from './hooks/useBoardConfig';
|
|
6
|
+
export function invertValueMapping(value) {
|
|
11
7
|
return Object.keys(value).reduce((acc, key) => {
|
|
12
8
|
const toKeys = value[key];
|
|
13
9
|
toKeys.forEach((toKey) => {
|
|
@@ -16,9 +12,9 @@ function invertValueMapping(value) {
|
|
|
16
12
|
return acc;
|
|
17
13
|
}, {});
|
|
18
14
|
}
|
|
19
|
-
function BoardColumnProvider(props) {
|
|
20
|
-
const { schema } =
|
|
21
|
-
const contextValue =
|
|
15
|
+
export function BoardColumnProvider(props) {
|
|
16
|
+
const { schema } = useBoardConfig();
|
|
17
|
+
const contextValue = useCreateContextStore({
|
|
22
18
|
config: props.config,
|
|
23
19
|
data: {
|
|
24
20
|
logicalName: schema.logicalName,
|
|
@@ -32,5 +28,5 @@ function BoardColumnProvider(props) {
|
|
|
32
28
|
},
|
|
33
29
|
fetchNextPage: () => { },
|
|
34
30
|
});
|
|
35
|
-
return ((
|
|
31
|
+
return (_jsxs(BoardColumnContext.Provider, { value: contextValue, children: [_jsx(DataResolver, {}), props.children] }));
|
|
36
32
|
}
|
package/board/context.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const mutable_1 = require("../mutable");
|
|
5
|
-
exports.BoardContext = (0, mutable_1.createContext)();
|
|
6
|
-
exports.BoardColumnContext = (0, mutable_1.createContext)();
|
|
1
|
+
import { createContext } from '../mutable';
|
|
2
|
+
export const BoardContext = createContext();
|
|
3
|
+
export const BoardColumnContext = createContext();
|
package/board/hooks/index.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "useBoardColumnData", { enumerable: true, get: function () { return useBoardColumnData_1.useBoardColumnData; } });
|
|
8
|
-
var useBoardColumnDataState_1 = require("./useBoardColumnDataState");
|
|
9
|
-
Object.defineProperty(exports, "useBoardColumnDataState", { enumerable: true, get: function () { return useBoardColumnDataState_1.useBoardColumnDataState; } });
|
|
10
|
-
var useBoardConfig_1 = require("./useBoardConfig");
|
|
11
|
-
Object.defineProperty(exports, "useBoardConfig", { enumerable: true, get: function () { return useBoardConfig_1.useBoardConfig; } });
|
|
12
|
-
var useBoardSchema_1 = require("./useBoardSchema");
|
|
13
|
-
Object.defineProperty(exports, "useBoardSchema", { enumerable: true, get: function () { return useBoardSchema_1.useBoardSchema; } });
|
|
14
|
-
var useSearchText_1 = require("./useSearchText");
|
|
15
|
-
Object.defineProperty(exports, "useSearchText", { enumerable: true, get: function () { return useSearchText_1.useSearchText; } });
|
|
1
|
+
export { useBoardColumnConfig } from './useBoardColumnConfig';
|
|
2
|
+
export { useBoardColumnData } from './useBoardColumnData';
|
|
3
|
+
export { useBoardColumnDataState } from './useBoardColumnDataState';
|
|
4
|
+
export { useBoardConfig } from './useBoardConfig';
|
|
5
|
+
export { useBoardSchema } from './useBoardSchema';
|
|
6
|
+
export { useSearchText } from './useSearchText';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const context_2 = require("../context");
|
|
6
|
-
function useBoardColumnConfig() {
|
|
7
|
-
return (0, context_1.useContextSelector)(context_2.BoardColumnContext, (context) => context.config);
|
|
1
|
+
import { useContextSelector } from '@headless-adminapp/app/mutable/context';
|
|
2
|
+
import { BoardColumnContext } from '../context';
|
|
3
|
+
export function useBoardColumnConfig() {
|
|
4
|
+
return useContextSelector(BoardColumnContext, (context) => context.config);
|
|
8
5
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const context_2 = require("../context");
|
|
6
|
-
function useBoardColumnData() {
|
|
7
|
-
const data = (0, context_1.useContextSelector)(context_2.BoardColumnContext, (state) => state.data);
|
|
1
|
+
import { useContextSelector } from '@headless-adminapp/app/mutable/context';
|
|
2
|
+
import { BoardColumnContext } from '../context';
|
|
3
|
+
export function useBoardColumnData() {
|
|
4
|
+
const data = useContextSelector(BoardColumnContext, (state) => state.data);
|
|
8
5
|
return data;
|
|
9
6
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const context_2 = require("../context");
|
|
6
|
-
function useBoardColumnDataState() {
|
|
7
|
-
const data = (0, context_1.useContextSelector)(context_2.BoardColumnContext, (state) => state.dataState);
|
|
1
|
+
import { useContextSelector } from '@headless-adminapp/app/mutable/context';
|
|
2
|
+
import { BoardColumnContext } from '../context';
|
|
3
|
+
export function useBoardColumnDataState() {
|
|
4
|
+
const data = useContextSelector(BoardColumnContext, (state) => state.dataState);
|
|
8
5
|
return data;
|
|
9
6
|
}
|