@headless-adminapp/app 0.0.17-alpha.5 → 0.0.17-alpha.52
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 +2 -1
- package/app/AuthWrapper.d.ts +1 -1
- package/app/AuthWrapper.js +4 -1
- package/app/LayoutProvider.d.ts +8 -7
- package/app/LayoutProvider.js +37 -2
- package/auth/AuthProvider.d.ts +1 -1
- package/auth/AuthProvider.js +23 -3
- package/auth/context.d.ts +1 -0
- package/auth/hooks/useIsSkipAuthCheck.d.ts +1 -0
- package/auth/hooks/useIsSkipAuthCheck.js +8 -0
- package/board/BoardColumnDataResolver.d.ts +1 -0
- package/board/BoardColumnDataResolver.js +64 -0
- package/board/BoardColumnProvider.d.ts +7 -0
- package/board/BoardColumnProvider.js +36 -0
- package/board/context.d.ts +19 -0
- package/board/context.js +6 -0
- package/board/hooks/index.d.ts +6 -0
- package/board/hooks/index.js +15 -0
- package/board/hooks/useBoardColumnConfig.d.ts +2 -0
- package/board/hooks/useBoardColumnConfig.js +8 -0
- package/board/hooks/useBoardColumnData.d.ts +1 -0
- package/board/hooks/useBoardColumnData.js +9 -0
- package/board/hooks/useBoardColumnDataState.d.ts +5 -0
- package/board/hooks/useBoardColumnDataState.js +9 -0
- package/board/hooks/useBoardConfig.d.ts +3 -0
- package/board/hooks/useBoardConfig.js +8 -0
- package/board/hooks/useBoardSchema.d.ts +2 -0
- package/board/hooks/useBoardSchema.js +7 -0
- package/board/hooks/useSearchText.d.ts +1 -0
- package/board/hooks/useSearchText.js +14 -0
- package/board/types.d.ts +47 -0
- package/board/utils.d.ts +3 -0
- package/board/utils.js +6 -0
- package/builders/CommandBuilder/CommandBuilder.d.ts +10 -0
- package/builders/CommandBuilder/CommandBuilder.js +14 -0
- package/builders/CommandBuilder/DefaultCommandBuilder.d.ts +88 -0
- package/builders/CommandBuilder/DefaultCommandBuilder.js +191 -0
- package/builders/CommandBuilder/FormCommandBuilder.d.ts +46 -0
- package/builders/CommandBuilder/FormCommandBuilder.js +171 -0
- package/builders/CommandBuilder/SubgridCommandBuilder.d.ts +45 -0
- package/builders/CommandBuilder/SubgridCommandBuilder.js +240 -0
- package/builders/CommandBuilder/ViewCommandBuilder.d.ts +63 -0
- package/builders/CommandBuilder/ViewCommandBuilder.js +242 -0
- package/builders/CommandBuilder/index.d.ts +1 -0
- package/builders/CommandBuilder/index.js +5 -0
- package/builders/CommandBuilder/utils.d.ts +3 -0
- package/builders/CommandBuilder/utils.js +21 -0
- package/builders/SchemaExperienceBuilder.d.ts +5 -8
- package/builders/SchemaExperienceBuilder.js +4 -4
- package/builders/index.d.ts +1 -1
- package/builders/index.js +1 -2
- package/builders/utils.d.ts +28 -0
- package/builders/utils.js +185 -0
- package/command/hooks/useBaseCommandHandlerContext.js +22 -4
- package/command/hooks/useCommands.d.ts +1 -1
- package/command/hooks/useCommands.js +1 -1
- package/components/ScrollbarWithMoreDataRequest/index.d.ts +9 -0
- package/components/ScrollbarWithMoreDataRequest/index.js +33 -0
- package/dataform/DataFormProvider/DataResolver.js +6 -6
- package/dataform/DataFormProvider/InitialValueResolver.js +4 -2
- package/dataform/DataFormProvider/index.js +3 -3
- package/dataform/hooks/index.d.ts +1 -0
- package/dataform/hooks/index.js +1 -0
- package/dataform/hooks/useFormSave.js +9 -2
- package/dataform/hooks/useLoadFormGridPage.js +8 -2
- package/dataform/hooks/useMainFormCommands.d.ts +1 -12
- package/dataform/hooks/useMainFormCommands.js +9 -1
- package/dataform/hooks/useProcessFlowSteps.d.ts +1 -0
- package/dataform/hooks/useProcessFlowSteps.js +44 -0
- package/dataform/hooks/useRecordTitle.d.ts +1 -1
- package/dataform/hooks/useRecordTitle.js +9 -2
- package/dataform/utils/defaultParameters.d.ts +3 -0
- package/dataform/utils/defaultParameters.js +37 -0
- package/dataform/utils/index.d.ts +3 -22
- package/dataform/utils/index.js +88 -134
- package/dataform/utils/saveRecord.d.ts +25 -0
- package/dataform/utils/saveRecord.js +167 -0
- package/datagrid/DataGridProvider/DataResolver.js +25 -149
- package/datagrid/DataGridProvider/index.d.ts +5 -0
- package/datagrid/DataGridProvider/index.js +8 -0
- package/datagrid/DataGridProvider/transformViewColumns.js +4 -4
- package/datagrid/DataGridProvider/utils.d.ts +7 -2
- package/datagrid/DataGridProvider/utils.js +52 -2
- package/datagrid/column-filter/constants.js +38 -3
- package/datagrid/context.d.ts +9 -6
- package/datagrid/hooks/useGridCommands.d.ts +3 -0
- package/datagrid/hooks/useGridCommands.js +3 -0
- package/datagrid/hooks/useLoadMainGridPage.js +1 -1
- package/datagrid/hooks/useMainGridCommands.d.ts +1 -13
- package/datagrid/hooks/useMainGridCommands.js +38 -26
- package/datagrid/hooks/useOpenRecord.d.ts +1 -0
- package/datagrid/hooks/useOpenRecord.js +34 -0
- package/datagrid/hooks/useSubGridCommands.js +25 -65
- package/defaults.d.ts +2 -0
- package/defaults.js +5 -0
- package/dialog/hooks/useCloseDialog.js +17 -15
- package/dialog/hooks/useOpenDialog.js +2 -4
- package/form/FormValidationStringContext.d.ts +1 -0
- package/form/FormValidationStringContext.js +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +3 -0
- package/hooks/useDebouncedValue.js +0 -1
- package/hooks/useElementLayout.js +1 -1
- package/hooks/useIsMobile.js +0 -1
- package/hooks/useItemsWithKey.d.ts +7 -0
- package/hooks/useItemsWithKey.js +13 -0
- package/hooks/useSystemColorScheme.d.ts +1 -1
- package/hooks/useSystemColorScheme.js +0 -1
- package/insights/InsightsProvider.d.ts +8 -0
- package/insights/InsightsProvider.js +27 -0
- package/locale/LocaleProvider.d.ts +2 -1
- package/locale/LocaleProvider.js +3 -3
- package/locale/index.d.ts +1 -0
- package/locale/index.js +1 -0
- package/locale/useCurrencySymbol.d.ts +1 -0
- package/locale/useCurrencySymbol.js +13 -0
- package/locale/utils.d.ts +5 -0
- package/locale/utils.js +7 -0
- package/metadata/MetadataProvider.d.ts +8 -4
- package/metadata/MetadataProvider.js +23 -16
- package/metadata/hooks/useExperienceViewCommands.js +7 -1
- package/metadata/hooks/useExperienceViewSubgridCommands.js +7 -1
- package/metadata/hooks/useMetadata.d.ts +2 -4
- package/metadata/hooks/useMetadata.js +2 -6
- package/metadata/hooks/useSchema.d.ts +1 -1
- package/metadata/hooks/useSchema.js +5 -2
- package/mutable/context.js +1 -1
- package/mutable/utils.js +5 -12
- package/navigation/hooks/index.d.ts +1 -0
- package/{appearance → navigation}/hooks/index.js +1 -1
- package/navigation/hooks/useOpenForm.d.ts +2 -4
- package/navigation/hooks/useOpenForm.js +11 -3
- package/navigation/index.d.ts +1 -0
- package/{appearance → navigation}/index.js +0 -3
- package/package.json +6 -2
- package/recordset/RecordSetProvider.js +1 -1
- package/recordset/hooks/useRecordSetResult.js +1 -1
- package/route/RouteProvider.d.ts +2 -2
- package/route/RouteProvider.js +4 -1
- package/store/ComponentStore.d.ts +1 -1
- package/store/ComponentStore.js +5 -9
- package/store/SchemaExperienceStore.d.ts +3 -3
- package/toast-notification/hooks/useCloseToastNotification.js +17 -15
- package/toast-notification/hooks/useOpenToastNotification.js +2 -4
- package/transport/RestDataService/index.d.ts +1 -1
- package/transport/RestDataService/index.js +17 -16
- package/transport/context.d.ts +3 -1
- package/transport/context.js +16 -1
- package/transport/hooks/index.d.ts +1 -0
- package/transport/hooks/index.js +1 -0
- package/transport/hooks/useFileService.d.ts +1 -0
- package/transport/hooks/useFileService.js +12 -0
- package/transport/hooks/useRetriveRecords.d.ts +32 -0
- package/transport/hooks/useRetriveRecords.js +120 -0
- package/utils/color.d.ts +1 -0
- package/utils/color.js +14 -0
- package/utils/getAttributeFormattedValue.d.ts +3 -1
- package/utils/getAttributeFormattedValue.js +108 -54
- package/appearance/context.d.ts +0 -7
- package/appearance/context.js +0 -5
- package/appearance/hooks/index.d.ts +0 -1
- package/appearance/hooks/useAppearanceContext.d.ts +0 -1
- package/appearance/hooks/useAppearanceContext.js +0 -12
- package/appearance/index.d.ts +0 -2
- package/builders/CommandBuilder.d.ts +0 -176
- package/builders/CommandBuilder.js +0 -474
- package/locale/types.d.ts +0 -2
- /package/{locale → board}/types.js +0 -0
package/app/AppProvider.js
CHANGED
|
@@ -38,12 +38,13 @@ const AppProvider = ({ children, appId, loadingComponent, notFoundComponent, })
|
|
|
38
38
|
return acc;
|
|
39
39
|
}, {})) !== null && _a !== void 0 ? _a : {};
|
|
40
40
|
}, [schemaMetadataList]);
|
|
41
|
+
const contextValue = (0, react_1.useMemo)(() => ({ app, schemaMetadataDic, schemaMetadataList }), [app, schemaMetadataDic, schemaMetadataList]);
|
|
41
42
|
if (isLoading) {
|
|
42
43
|
return loadingComponent;
|
|
43
44
|
}
|
|
44
45
|
if (!app) {
|
|
45
46
|
return notFoundComponent;
|
|
46
47
|
}
|
|
47
|
-
return ((0, jsx_runtime_1.jsx)(context_1.AppContext.Provider, { value:
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(context_1.AppContext.Provider, { value: contextValue, children: children }));
|
|
48
49
|
};
|
|
49
50
|
exports.AppProvider = AppProvider;
|
package/app/AuthWrapper.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from 'react';
|
|
2
2
|
import { AuthProviderPlaceholderProps } from '../auth';
|
|
3
3
|
interface AuthWrapperProps {
|
|
4
|
-
Placeholder
|
|
4
|
+
Placeholder?: FC<AuthProviderPlaceholderProps>;
|
|
5
5
|
}
|
|
6
6
|
export declare const AuthWrapper: FC<PropsWithChildren<AuthWrapperProps>>;
|
|
7
7
|
export {};
|
package/app/AuthWrapper.js
CHANGED
|
@@ -4,7 +4,10 @@ exports.AuthWrapper = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const auth_1 = require("../auth");
|
|
6
6
|
const mutable_1 = require("../mutable");
|
|
7
|
-
const
|
|
7
|
+
const DefaultPlaceHolder = () => {
|
|
8
|
+
return null;
|
|
9
|
+
};
|
|
10
|
+
const AuthWrapper = ({ children, Placeholder = DefaultPlaceHolder, }) => {
|
|
8
11
|
const state = (0, mutable_1.useContextSelector)(auth_1.AuthContext, (state) => state);
|
|
9
12
|
if (state.loadError) {
|
|
10
13
|
return (0, jsx_runtime_1.jsx)(Placeholder, { loadingError: true, retry: state.loadSession });
|
package/app/LayoutProvider.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDataService } from '@headless-adminapp/core/transport';
|
|
1
|
+
import { IDataService, IFileService } from '@headless-adminapp/core/transport';
|
|
2
2
|
import { QueryClient } from '@tanstack/react-query';
|
|
3
3
|
import { FC, PropsWithChildren } from 'react';
|
|
4
4
|
import { AuthProviderPlaceholderProps, AuthProviderProps } from '../auth';
|
|
@@ -7,12 +7,13 @@ import { MetadataProviderProps } from '../metadata/MetadataProvider';
|
|
|
7
7
|
import { RouteProviderProps } from '../route/RouteProvider';
|
|
8
8
|
export interface LayoutProviderProps {
|
|
9
9
|
routeProps: RouteProviderProps;
|
|
10
|
-
queryClient
|
|
11
|
-
localeProps
|
|
12
|
-
dataService
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
queryClient?: QueryClient;
|
|
11
|
+
localeProps?: LocaleProviderProps;
|
|
12
|
+
dataService?: IDataService;
|
|
13
|
+
fileService?: IFileService;
|
|
14
|
+
authProps?: AuthProviderProps;
|
|
15
|
+
authPlaceholder?: FC<AuthProviderPlaceholderProps>;
|
|
16
|
+
metadataProps?: MetadataProviderProps;
|
|
16
17
|
containers: {
|
|
17
18
|
DialogContainer: FC;
|
|
18
19
|
ProgressIndicatorContainer: FC;
|
package/app/LayoutProvider.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.LayoutProvider = void 0;
|
|
4
13
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
14
|
const react_query_1 = require("@tanstack/react-query");
|
|
6
15
|
const auth_1 = require("../auth");
|
|
16
|
+
const defaults_1 = require("../defaults");
|
|
7
17
|
const dialog_1 = require("../dialog");
|
|
8
18
|
const locale_1 = require("../locale");
|
|
9
19
|
const metadata_1 = require("../metadata");
|
|
@@ -12,8 +22,33 @@ const recordset_1 = require("../recordset");
|
|
|
12
22
|
const route_1 = require("../route");
|
|
13
23
|
const toast_notification_1 = require("../toast-notification");
|
|
14
24
|
const transport_1 = require("../transport");
|
|
25
|
+
const context_1 = require("../transport/context");
|
|
15
26
|
const AuthWrapper_1 = require("./AuthWrapper");
|
|
16
|
-
const
|
|
17
|
-
|
|
27
|
+
const dataServiceNotProvidedError = new Error('No data service provided');
|
|
28
|
+
const defaultDataService = {
|
|
29
|
+
createRecord: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
throw dataServiceNotProvidedError;
|
|
31
|
+
}),
|
|
32
|
+
deleteRecord: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
throw dataServiceNotProvidedError;
|
|
34
|
+
}),
|
|
35
|
+
customAction: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
throw dataServiceNotProvidedError;
|
|
37
|
+
}),
|
|
38
|
+
retriveAggregate: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
throw dataServiceNotProvidedError;
|
|
40
|
+
}),
|
|
41
|
+
retriveRecord: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
throw dataServiceNotProvidedError;
|
|
43
|
+
}),
|
|
44
|
+
retriveRecords: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
throw dataServiceNotProvidedError;
|
|
46
|
+
}),
|
|
47
|
+
updateRecord: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
throw dataServiceNotProvidedError;
|
|
49
|
+
}),
|
|
50
|
+
};
|
|
51
|
+
const LayoutProvider = ({ authPlaceholder, authProps, dataService = defaultDataService, fileService, localeProps, metadataProps, queryClient = defaults_1.queryClient, routeProps, children, containers: { DialogContainer, ProgressIndicatorContainer, ToastNotificationContainer, }, }) => {
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(route_1.RouteProvider, Object.assign({}, routeProps, { children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(locale_1.LocaleProvider, Object.assign({}, localeProps, { children: (0, jsx_runtime_1.jsx)(metadata_1.MetadataProvider, Object.assign({}, metadataProps, { children: (0, jsx_runtime_1.jsx)(transport_1.DataServiceContext.Provider, { value: dataService, children: (0, jsx_runtime_1.jsx)(context_1.FileServiceContext.Provider, { value: fileService !== null && fileService !== void 0 ? fileService : context_1.noopFileService, children: (0, jsx_runtime_1.jsx)(dialog_1.DialogProvider, { children: (0, jsx_runtime_1.jsx)(progress_indicator_1.ProgressIndicatorProvider, { children: (0, jsx_runtime_1.jsxs)(toast_notification_1.ToastNotificationProvider, { children: [(0, jsx_runtime_1.jsx)(DialogContainer, {}), (0, jsx_runtime_1.jsx)(ProgressIndicatorContainer, {}), (0, jsx_runtime_1.jsx)(ToastNotificationContainer, {}), (0, jsx_runtime_1.jsx)(auth_1.AuthProvider, Object.assign({}, authProps, { children: (0, jsx_runtime_1.jsx)(AuthWrapper_1.AuthWrapper, { Placeholder: authPlaceholder, children: (0, jsx_runtime_1.jsx)(recordset_1.RecordSetProvider, { children: children }) }) }))] }) }) }) }) }) })) })) }) })));
|
|
18
53
|
};
|
|
19
54
|
exports.LayoutProvider = LayoutProvider;
|
package/auth/AuthProvider.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import { FC, PropsWithChildren } from 'react';
|
|
|
2
2
|
import { SessionResolver, UnauthorizeReason } from './types';
|
|
3
3
|
export interface AuthProviderProps {
|
|
4
4
|
onUnauthenticated?: (reason: UnauthorizeReason) => void;
|
|
5
|
-
sessionResolver
|
|
5
|
+
sessionResolver?: SessionResolver;
|
|
6
6
|
}
|
|
7
7
|
export declare const AuthProvider: FC<PropsWithChildren<AuthProviderProps>>;
|
package/auth/AuthProvider.js
CHANGED
|
@@ -11,20 +11,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.AuthProvider = void 0;
|
|
13
13
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
14
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
14
15
|
const react_1 = require("react");
|
|
15
16
|
const context_1 = require("../mutable/context");
|
|
16
17
|
const context_2 = require("./context");
|
|
17
18
|
const AuthProvider = ({ sessionResolver, onUnauthenticated, children, }) => {
|
|
18
19
|
const onUnauthenticatedRef = (0, react_1.useRef)(onUnauthenticated);
|
|
19
20
|
onUnauthenticatedRef.current = onUnauthenticated;
|
|
21
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
20
22
|
const onUnauthenticatedInternal = (0, react_1.useCallback)((reason) => {
|
|
21
23
|
var _a;
|
|
22
24
|
(_a = onUnauthenticatedRef.current) === null || _a === void 0 ? void 0 : _a.call(onUnauthenticatedRef, reason);
|
|
23
|
-
|
|
25
|
+
queryClient.clear();
|
|
26
|
+
queryClient.removeQueries({
|
|
27
|
+
queryKey: ['data'],
|
|
28
|
+
});
|
|
29
|
+
queryClient
|
|
30
|
+
.invalidateQueries({
|
|
31
|
+
queryKey: ['data'],
|
|
32
|
+
})
|
|
33
|
+
.catch(console.error);
|
|
34
|
+
}, [queryClient]);
|
|
24
35
|
const contextValue = (0, context_1.useCreateContextStore)({
|
|
25
|
-
loading:
|
|
36
|
+
loading: !!sessionResolver,
|
|
26
37
|
loadError: false,
|
|
27
|
-
|
|
38
|
+
authenticated: !sessionResolver,
|
|
39
|
+
initialized: !sessionResolver,
|
|
40
|
+
skipAuthCheck: !sessionResolver,
|
|
28
41
|
loadSession: () => Promise.resolve(),
|
|
29
42
|
onUnauthenticated: onUnauthenticatedInternal,
|
|
30
43
|
});
|
|
@@ -36,6 +49,9 @@ const AuthProvider = ({ sessionResolver, onUnauthenticated, children, }) => {
|
|
|
36
49
|
var _a;
|
|
37
50
|
contextValue.setValue({ loading: true, loadError: false });
|
|
38
51
|
try {
|
|
52
|
+
if (!sessionResolverRef.current) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
39
55
|
const data = yield sessionResolverRef.current();
|
|
40
56
|
if (!data) {
|
|
41
57
|
contextValue.setValue({
|
|
@@ -85,6 +101,10 @@ const AuthProvider = ({ sessionResolver, onUnauthenticated, children, }) => {
|
|
|
85
101
|
(_a = onUnauthenticatedRef.current) === null || _a === void 0 ? void 0 : _a.call(onUnauthenticatedRef, 'sessionExpired');
|
|
86
102
|
return;
|
|
87
103
|
}
|
|
104
|
+
const MAX_TIMEOUT = 2147483647;
|
|
105
|
+
if (timeout > MAX_TIMEOUT) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
88
108
|
const timer = setTimeout(() => {
|
|
89
109
|
var _a;
|
|
90
110
|
contextValue.setValue({
|
package/auth/context.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ interface AuthStoreAuthorizedState<T extends AuthSession = AuthSession> {
|
|
|
16
16
|
export type AuthState = (AuthStoreLoadingState | AuthStoreUnauthorizedState | AuthStoreAuthorizedState) & {
|
|
17
17
|
loading: boolean;
|
|
18
18
|
loadError: boolean;
|
|
19
|
+
skipAuthCheck?: boolean;
|
|
19
20
|
loadSession: () => Promise<void>;
|
|
20
21
|
onUnauthenticated?: (reason: UnauthorizeReason) => void;
|
|
21
22
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsSkipAuthCheck(): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIsSkipAuthCheck = useIsSkipAuthCheck;
|
|
4
|
+
const mutable_1 = require("../../mutable");
|
|
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; });
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function DataResolver(): null;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataResolver = DataResolver;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const hooks_1 = require("../hooks");
|
|
6
|
+
const mutable_1 = require("../mutable");
|
|
7
|
+
const useRetriveRecords_1 = require("../transport/hooks/useRetriveRecords");
|
|
8
|
+
const context_1 = require("./context");
|
|
9
|
+
const useBoardColumnConfig_1 = require("./hooks/useBoardColumnConfig");
|
|
10
|
+
const useBoardConfig_1 = require("./hooks/useBoardConfig");
|
|
11
|
+
const useSearchText_1 = require("./hooks/useSearchText");
|
|
12
|
+
const MAX_RECORDS = 10000;
|
|
13
|
+
function DataResolver() {
|
|
14
|
+
const { schema, sorting, projection: { columns, expand }, } = (0, useBoardConfig_1.useBoardConfig)();
|
|
15
|
+
const [searchText] = (0, useSearchText_1.useSearchText)();
|
|
16
|
+
const { filter, maxRecords = MAX_RECORDS } = (0, useBoardColumnConfig_1.useBoardColumnConfig)();
|
|
17
|
+
const setState = (0, mutable_1.useContextSetValue)(context_1.BoardColumnContext);
|
|
18
|
+
const [search] = (0, hooks_1.useDebouncedValue)(searchText, 500);
|
|
19
|
+
const queryKey = (0, useRetriveRecords_1.useRetrieveRecordsKey)({
|
|
20
|
+
columns,
|
|
21
|
+
expand,
|
|
22
|
+
filter,
|
|
23
|
+
maxRecords,
|
|
24
|
+
schema,
|
|
25
|
+
search,
|
|
26
|
+
sorting,
|
|
27
|
+
});
|
|
28
|
+
(0, useRetriveRecords_1.useClearDataExceptFirstPage)(queryKey);
|
|
29
|
+
const { fetchNextPage, data, hasNextPage, isFetching, isFetchingNextPage } = (0, useRetriveRecords_1.useRetriveRecords)(queryKey, {
|
|
30
|
+
columns,
|
|
31
|
+
expand,
|
|
32
|
+
filter,
|
|
33
|
+
maxRecords,
|
|
34
|
+
schema,
|
|
35
|
+
search,
|
|
36
|
+
sorting,
|
|
37
|
+
});
|
|
38
|
+
(0, react_1.useEffect)(() => {
|
|
39
|
+
setState({
|
|
40
|
+
fetchNextPage: fetchNextPage,
|
|
41
|
+
});
|
|
42
|
+
}, [fetchNextPage, setState]);
|
|
43
|
+
(0, react_1.useEffect)(() => {
|
|
44
|
+
if (!data) {
|
|
45
|
+
setState({
|
|
46
|
+
data: null,
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
setState({
|
|
51
|
+
data,
|
|
52
|
+
});
|
|
53
|
+
}, [data, setState, schema.idAttribute]);
|
|
54
|
+
(0, react_1.useEffect)(() => {
|
|
55
|
+
setState({
|
|
56
|
+
dataState: {
|
|
57
|
+
isFetching,
|
|
58
|
+
hasNextPage,
|
|
59
|
+
isFetchingNextPage,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}, [hasNextPage, isFetching, isFetchingNextPage, setState]);
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { BoardColumnConfig } from './types';
|
|
3
|
+
export declare function invertValueMapping(value: Record<string, string[]>): Record<string, string[]>;
|
|
4
|
+
export interface BoardColumnProviderProps {
|
|
5
|
+
config: BoardColumnConfig;
|
|
6
|
+
}
|
|
7
|
+
export declare function BoardColumnProvider(props: PropsWithChildren<BoardColumnProviderProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.invertValueMapping = invertValueMapping;
|
|
4
|
+
exports.BoardColumnProvider = BoardColumnProvider;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const mutable_1 = require("../mutable");
|
|
7
|
+
const BoardColumnDataResolver_1 = require("./BoardColumnDataResolver");
|
|
8
|
+
const context_1 = require("./context");
|
|
9
|
+
const useBoardConfig_1 = require("./hooks/useBoardConfig");
|
|
10
|
+
function invertValueMapping(value) {
|
|
11
|
+
return Object.keys(value).reduce((acc, key) => {
|
|
12
|
+
const toKeys = value[key];
|
|
13
|
+
toKeys.forEach((toKey) => {
|
|
14
|
+
acc[toKey] = [...(acc[toKey] || []), key];
|
|
15
|
+
});
|
|
16
|
+
return acc;
|
|
17
|
+
}, {});
|
|
18
|
+
}
|
|
19
|
+
function BoardColumnProvider(props) {
|
|
20
|
+
const { schema } = (0, useBoardConfig_1.useBoardConfig)();
|
|
21
|
+
const contextValue = (0, mutable_1.useCreateContextStore)({
|
|
22
|
+
config: props.config,
|
|
23
|
+
data: {
|
|
24
|
+
logicalName: schema.logicalName,
|
|
25
|
+
records: [],
|
|
26
|
+
count: 0,
|
|
27
|
+
},
|
|
28
|
+
dataState: {
|
|
29
|
+
hasNextPage: false,
|
|
30
|
+
isFetching: false,
|
|
31
|
+
isFetchingNextPage: false,
|
|
32
|
+
},
|
|
33
|
+
fetchNextPage: () => { },
|
|
34
|
+
});
|
|
35
|
+
return ((0, jsx_runtime_1.jsxs)(context_1.BoardColumnContext.Provider, { value: contextValue, children: [(0, jsx_runtime_1.jsx)(BoardColumnDataResolver_1.DataResolver, {}), props.children] }));
|
|
36
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { InferredSchemaType, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
2
|
+
import { RetriveRecordsResult } from '@headless-adminapp/core/transport';
|
|
3
|
+
import { BoardColumnConfig, BoardConfig } from './types';
|
|
4
|
+
export interface BoardContextState<S extends SchemaAttributes = SchemaAttributes> {
|
|
5
|
+
config: BoardConfig<S>;
|
|
6
|
+
searchText: string;
|
|
7
|
+
}
|
|
8
|
+
export interface BoardColumnContextState<S extends SchemaAttributes = SchemaAttributes> {
|
|
9
|
+
config: BoardColumnConfig;
|
|
10
|
+
data: RetriveRecordsResult<InferredSchemaType<S>> | null;
|
|
11
|
+
dataState: {
|
|
12
|
+
isFetching: boolean;
|
|
13
|
+
hasNextPage: boolean;
|
|
14
|
+
isFetchingNextPage: boolean;
|
|
15
|
+
};
|
|
16
|
+
fetchNextPage: () => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const BoardContext: import("react").Context<import("../mutable").ContextValue<BoardContextState<SchemaAttributes>>>;
|
|
19
|
+
export declare const BoardColumnContext: import("react").Context<import("../mutable").ContextValue<BoardColumnContextState<SchemaAttributes>>>;
|
package/board/context.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BoardColumnContext = exports.BoardContext = void 0;
|
|
4
|
+
const mutable_1 = require("../mutable");
|
|
5
|
+
exports.BoardContext = (0, mutable_1.createContext)();
|
|
6
|
+
exports.BoardColumnContext = (0, mutable_1.createContext)();
|
|
@@ -0,0 +1,6 @@
|
|
|
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';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSearchText = exports.useBoardSchema = exports.useBoardConfig = exports.useBoardColumnDataState = exports.useBoardColumnData = exports.useBoardColumnConfig = void 0;
|
|
4
|
+
var useBoardColumnConfig_1 = require("./useBoardColumnConfig");
|
|
5
|
+
Object.defineProperty(exports, "useBoardColumnConfig", { enumerable: true, get: function () { return useBoardColumnConfig_1.useBoardColumnConfig; } });
|
|
6
|
+
var useBoardColumnData_1 = require("./useBoardColumnData");
|
|
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; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useBoardColumnConfig = useBoardColumnConfig;
|
|
4
|
+
const context_1 = require("@headless-adminapp/app/mutable/context");
|
|
5
|
+
const context_2 = require("../context");
|
|
6
|
+
function useBoardColumnConfig() {
|
|
7
|
+
return (0, context_1.useContextSelector)(context_2.BoardColumnContext, (context) => context.config);
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useBoardColumnData(): import("@headless-adminapp/core/transport").RetriveRecordsResult<import("@headless-adminapp/core/schema").InferredSchemaType<import("@headless-adminapp/core/schema").SchemaAttributes>> | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useBoardColumnData = useBoardColumnData;
|
|
4
|
+
const context_1 = require("@headless-adminapp/app/mutable/context");
|
|
5
|
+
const context_2 = require("../context");
|
|
6
|
+
function useBoardColumnData() {
|
|
7
|
+
const data = (0, context_1.useContextSelector)(context_2.BoardColumnContext, (state) => state.data);
|
|
8
|
+
return data;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useBoardColumnDataState = useBoardColumnDataState;
|
|
4
|
+
const context_1 = require("@headless-adminapp/app/mutable/context");
|
|
5
|
+
const context_2 = require("../context");
|
|
6
|
+
function useBoardColumnDataState() {
|
|
7
|
+
const data = (0, context_1.useContextSelector)(context_2.BoardColumnContext, (state) => state.dataState);
|
|
8
|
+
return data;
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useBoardConfig = useBoardConfig;
|
|
4
|
+
const context_1 = require("@headless-adminapp/app/mutable/context");
|
|
5
|
+
const context_2 = require("../context");
|
|
6
|
+
function useBoardConfig() {
|
|
7
|
+
return (0, context_1.useContextSelector)(context_2.BoardContext, (context) => context.config);
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useSearchText(): readonly [string, (value: string) => void];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSearchText = useSearchText;
|
|
4
|
+
const context_1 = require("@headless-adminapp/app/mutable/context");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const context_2 = require("../context");
|
|
7
|
+
function useSearchText() {
|
|
8
|
+
const searchText = (0, context_1.useContextSelector)(context_2.BoardContext, (context) => context.searchText);
|
|
9
|
+
const setValue = (0, context_1.useContextSetValue)(context_2.BoardContext);
|
|
10
|
+
const setSearchText = (0, react_1.useCallback)((value) => {
|
|
11
|
+
setValue({ searchText: value });
|
|
12
|
+
}, [setValue]);
|
|
13
|
+
return [searchText, setSearchText];
|
|
14
|
+
}
|
package/board/types.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CommandContextBase } from '@headless-adminapp/core/experience/command';
|
|
2
|
+
import { SortingState, View } from '@headless-adminapp/core/experience/view';
|
|
3
|
+
import { Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
4
|
+
import { Filter } from '@headless-adminapp/core/transport';
|
|
5
|
+
import { FC } from 'react';
|
|
6
|
+
import { UtilityContextState } from '../command';
|
|
7
|
+
export interface ItemUpdateContext extends CommandContextBase {
|
|
8
|
+
primaryControl: {
|
|
9
|
+
logicalName: string;
|
|
10
|
+
id: string;
|
|
11
|
+
schema: Schema;
|
|
12
|
+
};
|
|
13
|
+
utility: UtilityContextState;
|
|
14
|
+
}
|
|
15
|
+
export interface Column {
|
|
16
|
+
view: View<SchemaAttributes>;
|
|
17
|
+
accept: string[];
|
|
18
|
+
update?: (context: ItemUpdateContext) => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export type BoardColumnCardPreviewFC = FC<{
|
|
21
|
+
record: any;
|
|
22
|
+
}>;
|
|
23
|
+
export interface DragItem {
|
|
24
|
+
id: string;
|
|
25
|
+
columnId: string;
|
|
26
|
+
record: any;
|
|
27
|
+
}
|
|
28
|
+
export interface BoardColumnConfig {
|
|
29
|
+
columnId: string;
|
|
30
|
+
title: string;
|
|
31
|
+
maxRecords?: number;
|
|
32
|
+
filter: Filter;
|
|
33
|
+
acceptSourceIds: string[];
|
|
34
|
+
updateFn: (context: ItemUpdateContext) => Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export interface BoardConfig<S extends SchemaAttributes = SchemaAttributes> {
|
|
37
|
+
title: string;
|
|
38
|
+
description: string;
|
|
39
|
+
schema: Schema<S>;
|
|
40
|
+
sorting: SortingState<S>;
|
|
41
|
+
projection: {
|
|
42
|
+
columns: Array<keyof S>;
|
|
43
|
+
expand?: Partial<Record<keyof S, string[]>>;
|
|
44
|
+
};
|
|
45
|
+
columnConfigs: BoardColumnConfig[];
|
|
46
|
+
PreviewComponent: BoardColumnCardPreviewFC;
|
|
47
|
+
}
|
package/board/utils.d.ts
ADDED
package/board/utils.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DefaultCommandBuilder } from './DefaultCommandBuilder';
|
|
2
|
+
import { FormCommandBuilder } from './FormCommandBuilder';
|
|
3
|
+
import { SubgridCommandBuilder } from './SubgridCommandBuilder';
|
|
4
|
+
import { ViewCommandBuilder } from './ViewCommandBuilder';
|
|
5
|
+
export declare namespace CommandBuilder {
|
|
6
|
+
const View: typeof ViewCommandBuilder;
|
|
7
|
+
const Form: typeof FormCommandBuilder;
|
|
8
|
+
const Subgrid: typeof SubgridCommandBuilder;
|
|
9
|
+
const Default: typeof DefaultCommandBuilder;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommandBuilder = void 0;
|
|
4
|
+
const DefaultCommandBuilder_1 = require("./DefaultCommandBuilder");
|
|
5
|
+
const FormCommandBuilder_1 = require("./FormCommandBuilder");
|
|
6
|
+
const SubgridCommandBuilder_1 = require("./SubgridCommandBuilder");
|
|
7
|
+
const ViewCommandBuilder_1 = require("./ViewCommandBuilder");
|
|
8
|
+
var CommandBuilder;
|
|
9
|
+
(function (CommandBuilder) {
|
|
10
|
+
CommandBuilder.View = ViewCommandBuilder_1.ViewCommandBuilder;
|
|
11
|
+
CommandBuilder.Form = FormCommandBuilder_1.FormCommandBuilder;
|
|
12
|
+
CommandBuilder.Subgrid = SubgridCommandBuilder_1.SubgridCommandBuilder;
|
|
13
|
+
CommandBuilder.Default = DefaultCommandBuilder_1.DefaultCommandBuilder;
|
|
14
|
+
})(CommandBuilder || (exports.CommandBuilder = CommandBuilder = {}));
|