@headless-adminapp/app 0.0.17-alpha.50 → 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 -15
- 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.d.ts +1 -0
- package/hooks/index.js +6 -21
- package/hooks/useDebouncedValue.js +8 -11
- package/hooks/useElementLayout.js +4 -7
- package/hooks/useIsMobile.js +6 -12
- package/hooks/useItemsWithKey.d.ts +7 -0
- package/hooks/useItemsWithKey.js +10 -0
- 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 +12 -23
- package/navigation/hooks/index.js +1 -17
- package/navigation/hooks/useOpenForm.js +11 -14
- package/navigation/index.js +1 -17
- package/package.json +4 -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 -15
- 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/locale/useLocale.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const context_1 = require("./context");
|
|
6
|
-
function useLocale() {
|
|
7
|
-
const context = (0, react_1.useContext)(context_1.LocaleContext);
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { LocaleContext } from './context';
|
|
3
|
+
export function useLocale() {
|
|
4
|
+
const context = useContext(LocaleContext);
|
|
8
5
|
if (!context) {
|
|
9
6
|
throw new Error('useLocale must be used within a LocaleProvider');
|
|
10
7
|
}
|
package/locale/utils.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.localizedLabel = localizedLabel;
|
|
4
|
-
function localizedLabel(language, value, fallback) {
|
|
1
|
+
export function localizedLabel(language, value, fallback) {
|
|
5
2
|
var _a, _b, _c, _d, _e;
|
|
6
3
|
return ((_e = (_d = (_b = (_a = value.localizedLabels) === null || _a === void 0 ? void 0 : _a[language]) !== null && _b !== void 0 ? _b : (_c = fallback === null || fallback === void 0 ? void 0 : fallback.localizedLabels) === null || _c === void 0 ? void 0 : _c[language]) !== null && _d !== void 0 ? _d : value.label) !== null && _e !== void 0 ? _e : fallback === null || fallback === void 0 ? void 0 : fallback.label);
|
|
7
4
|
}
|
|
@@ -1,36 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
exports.defaultSchemaStore = new store_1.SchemaStore();
|
|
13
|
-
exports.defaultExperienceStore = new store_2.SchemaExperienceStore({
|
|
14
|
-
schemaStore: exports.defaultSchemaStore,
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PageType } from '@headless-adminapp/core/experience/app';
|
|
3
|
+
import { SchemaStore, } from '@headless-adminapp/core/store';
|
|
4
|
+
import { IconPlaceholder } from '@headless-adminapp/icons';
|
|
5
|
+
import { useCreateContextStore } from '../mutable/context';
|
|
6
|
+
import { ClientAppStore, SchemaExperienceStore } from '../store';
|
|
7
|
+
import { MetadataContext } from './context';
|
|
8
|
+
export const defaultAppStore = new ClientAppStore();
|
|
9
|
+
export const defaultSchemaStore = new SchemaStore();
|
|
10
|
+
export const defaultExperienceStore = new SchemaExperienceStore({
|
|
11
|
+
schemaStore: defaultSchemaStore,
|
|
15
12
|
});
|
|
16
|
-
|
|
13
|
+
defaultAppStore.register({
|
|
17
14
|
id: 'default',
|
|
18
15
|
title: 'Demo App',
|
|
19
16
|
navItems: [],
|
|
20
17
|
defaultPage: {
|
|
21
18
|
label: 'Home',
|
|
22
19
|
link: '/home',
|
|
23
|
-
type:
|
|
24
|
-
icon:
|
|
20
|
+
type: PageType.Custom,
|
|
21
|
+
icon: IconPlaceholder,
|
|
25
22
|
},
|
|
26
23
|
logo: {},
|
|
27
24
|
});
|
|
28
|
-
const MetadataProvider = ({ children, experienceStore =
|
|
29
|
-
const contextValue =
|
|
25
|
+
export const MetadataProvider = ({ children, experienceStore = defaultExperienceStore, schemaStore = defaultSchemaStore, appStore = defaultAppStore, }) => {
|
|
26
|
+
const contextValue = useCreateContextStore({
|
|
30
27
|
experienceStore,
|
|
31
28
|
schemaStore,
|
|
32
29
|
appStore,
|
|
33
30
|
});
|
|
34
|
-
return ((
|
|
31
|
+
return (_jsx(MetadataContext.Provider, { value: contextValue, children: children }));
|
|
35
32
|
};
|
|
36
|
-
exports.MetadataProvider = MetadataProvider;
|
package/metadata/context.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export interface MetadataContextState {
|
|
|
4
4
|
schemaStore: ISchemaStore;
|
|
5
5
|
experienceStore: ISchemaExperienceStore;
|
|
6
6
|
}
|
|
7
|
-
export declare const MetadataContext: import("react").Context<import("../mutable
|
|
7
|
+
export declare const MetadataContext: import("react").Context<import("../mutable").ContextValue<MetadataContextState>>;
|
package/metadata/context.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MetadataContext = void 0;
|
|
4
|
-
const context_1 = require("../mutable/context");
|
|
5
|
-
exports.MetadataContext = (0, context_1.createContext)();
|
|
1
|
+
import { createContext } from '../mutable/context';
|
|
2
|
+
export const MetadataContext = createContext();
|
package/metadata/hooks/index.js
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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("./useAppStore"), exports);
|
|
18
|
-
__exportStar(require("./useExperienceStore"), exports);
|
|
19
|
-
__exportStar(require("./useExperienceView"), exports);
|
|
20
|
-
__exportStar(require("./useExperienceViewCommands"), exports);
|
|
21
|
-
__exportStar(require("./useExperienceViewLookup"), exports);
|
|
22
|
-
__exportStar(require("./useExperienceViewSubgridCommands"), exports);
|
|
23
|
-
__exportStar(require("./useMetadata"), exports);
|
|
24
|
-
__exportStar(require("./useSchema"), exports);
|
|
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';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const context_2 = require("../context");
|
|
6
|
-
function useAppStore() {
|
|
7
|
-
return (0, context_1.useContextSelector)(context_2.MetadataContext, (state) => state.appStore);
|
|
1
|
+
import { useContextSelector } from '../../mutable/context';
|
|
2
|
+
import { MetadataContext } from '../context';
|
|
3
|
+
export function useAppStore() {
|
|
4
|
+
return useContextSelector(MetadataContext, (state) => state.appStore);
|
|
8
5
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const context_2 = require("../context");
|
|
6
|
-
function useExperienceStore() {
|
|
7
|
-
return (0, context_1.useContextSelector)(context_2.MetadataContext, (state) => state.experienceStore);
|
|
1
|
+
import { useContextSelector } from '../../mutable/context';
|
|
2
|
+
import { MetadataContext } from '../context';
|
|
3
|
+
export function useExperienceStore() {
|
|
4
|
+
return useContextSelector(MetadataContext, (state) => state.experienceStore);
|
|
8
5
|
}
|
|
@@ -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,13 +7,11 @@ 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
|
-
const
|
|
15
|
-
|
|
16
|
-
const experienceStore = (0, useExperienceStore_1.useExperienceStore)();
|
|
17
|
-
const { data, isPending } = (0, react_query_1.useQuery)({
|
|
10
|
+
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
|
11
|
+
import { useExperienceStore } from './useExperienceStore';
|
|
12
|
+
export function useExperienceView(logicalName, viewId, associated, viewIds) {
|
|
13
|
+
const experienceStore = useExperienceStore();
|
|
14
|
+
const { data, isPending } = useQuery({
|
|
18
15
|
queryKey: [
|
|
19
16
|
'experience-schema-view',
|
|
20
17
|
logicalName,
|
|
@@ -28,7 +25,7 @@ function useExperienceView(logicalName, viewId, associated, viewIds) {
|
|
|
28
25
|
}
|
|
29
26
|
return experienceStore.getPublicView(logicalName, viewId, viewIds);
|
|
30
27
|
}),
|
|
31
|
-
placeholderData:
|
|
28
|
+
placeholderData: keepPreviousData,
|
|
32
29
|
});
|
|
33
30
|
return {
|
|
34
31
|
view: data,
|
|
@@ -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,16 +7,14 @@ 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
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
15
|
-
const useExperienceStore_1 = require("./useExperienceStore");
|
|
10
|
+
import { useAppContext } from '@headless-adminapp/app/app';
|
|
11
|
+
import { useQuery } from '@tanstack/react-query';
|
|
12
|
+
import { useExperienceStore } from './useExperienceStore';
|
|
16
13
|
/** @todo move in different dir */
|
|
17
|
-
function useExperienceViewCommands(logicalName) {
|
|
18
|
-
const experienceStore =
|
|
19
|
-
const { app: { viewCommands }, } =
|
|
20
|
-
const { data: commands } =
|
|
14
|
+
export function useExperienceViewCommands(logicalName) {
|
|
15
|
+
const experienceStore = useExperienceStore();
|
|
16
|
+
const { app: { viewCommands }, } = useAppContext();
|
|
17
|
+
const { data: commands } = useQuery({
|
|
21
18
|
queryKey: ['experience-schema-view-commands', logicalName],
|
|
22
19
|
queryFn: () => __awaiter(this, void 0, void 0, function* () {
|
|
23
20
|
let commands = yield experienceStore.getViewCommands(logicalName);
|
|
@@ -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,14 +7,12 @@ 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
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
14
|
-
const useExperienceStore_1 = require("./useExperienceStore");
|
|
10
|
+
import { useQuery } from '@tanstack/react-query';
|
|
11
|
+
import { useExperienceStore } from './useExperienceStore';
|
|
15
12
|
/** @todo move in different dir */
|
|
16
|
-
function useExperienceViewLookup(logicalName, associated, viewIds) {
|
|
17
|
-
const experienceStore =
|
|
18
|
-
const { data: viewLookup } =
|
|
13
|
+
export function useExperienceViewLookup(logicalName, associated, viewIds) {
|
|
14
|
+
const experienceStore = useExperienceStore();
|
|
15
|
+
const { data: viewLookup } = useQuery({
|
|
19
16
|
queryKey: [
|
|
20
17
|
'experience-schema-view-lookup',
|
|
21
18
|
logicalName,
|
|
@@ -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,16 +7,14 @@ 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
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
15
|
-
const useExperienceStore_1 = require("./useExperienceStore");
|
|
10
|
+
import { useAppContext } from '@headless-adminapp/app/app';
|
|
11
|
+
import { useQuery } from '@tanstack/react-query';
|
|
12
|
+
import { useExperienceStore } from './useExperienceStore';
|
|
16
13
|
/** @todo move in different dir */
|
|
17
|
-
function useExperienceViewSubgridCommands(logicalName) {
|
|
18
|
-
const experienceStore =
|
|
19
|
-
const { app: { subgridCommands }, } =
|
|
20
|
-
const { data: commands } =
|
|
14
|
+
export function useExperienceViewSubgridCommands(logicalName) {
|
|
15
|
+
const experienceStore = useExperienceStore();
|
|
16
|
+
const { app: { subgridCommands }, } = useAppContext();
|
|
17
|
+
const { data: commands } = useQuery({
|
|
21
18
|
queryKey: ['experience-schema-view-subgrid-commands', logicalName],
|
|
22
19
|
queryFn: () => __awaiter(this, void 0, void 0, function* () {
|
|
23
20
|
let commands = yield experienceStore.getSubgridCommands(logicalName);
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const schemaStore = (0, context_1.useContextSelector)(context_2.MetadataContext, (state) => state.schemaStore);
|
|
9
|
-
const appStore = (0, context_1.useContextSelector)(context_2.MetadataContext, (state) => state.appStore);
|
|
10
|
-
const experienceStore = (0, context_1.useContextSelector)(context_2.MetadataContext, (state) => state.experienceStore);
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useContextSelector } from '../../mutable/context';
|
|
3
|
+
import { MetadataContext } from '../context';
|
|
4
|
+
export function useMetadata() {
|
|
5
|
+
const schemaStore = useContextSelector(MetadataContext, (state) => state.schemaStore);
|
|
6
|
+
const appStore = useContextSelector(MetadataContext, (state) => state.appStore);
|
|
7
|
+
const experienceStore = useContextSelector(MetadataContext, (state) => state.experienceStore);
|
|
11
8
|
// const schemaLoading = useContextSelector(
|
|
12
9
|
// MetadataContext,
|
|
13
10
|
// (state) => state.schemaLoading
|
|
14
11
|
// );
|
|
15
12
|
const schemaLoading = false;
|
|
16
13
|
const schemas = schemaStore.getAllSchema();
|
|
17
|
-
return
|
|
14
|
+
return useMemo(() => ({
|
|
18
15
|
schemas,
|
|
19
16
|
schemaLoading,
|
|
20
17
|
schemaStore,
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const useMetadata_1 = require("./useMetadata");
|
|
5
|
-
function useSchema(logicalName) {
|
|
6
|
-
const { schemaStore } = (0, useMetadata_1.useMetadata)();
|
|
1
|
+
import { useMetadata } from './useMetadata';
|
|
2
|
+
export function useSchema(logicalName) {
|
|
3
|
+
const { schemaStore } = useMetadata();
|
|
7
4
|
if (!schemaStore.hasSchema(logicalName)) {
|
|
8
5
|
return null;
|
|
9
6
|
}
|
package/metadata/index.js
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
exports.MetadataContext = exports.MetadataProvider = void 0;
|
|
18
|
-
var MetadataProvider_1 = require("./MetadataProvider");
|
|
19
|
-
Object.defineProperty(exports, "MetadataProvider", { enumerable: true, get: function () { return MetadataProvider_1.MetadataProvider; } });
|
|
20
|
-
var context_1 = require("./context");
|
|
21
|
-
Object.defineProperty(exports, "MetadataContext", { enumerable: true, get: function () { return context_1.MetadataContext; } });
|
|
22
|
-
__exportStar(require("./hooks"), exports);
|
|
1
|
+
export { MetadataProvider } from './MetadataProvider';
|
|
2
|
+
export { MetadataContext } from './context';
|
|
3
|
+
export * from './hooks';
|
package/mutable/context.js
CHANGED
|
@@ -1,45 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.useContextSetValue = useContextSetValue;
|
|
8
|
-
exports.useContextValueSetter = useContextValueSetter;
|
|
9
|
-
const react_1 = require("react");
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
const createContextValue = utils_1.createMutableValue;
|
|
12
|
-
exports.useContextSelectorInternal = utils_1.useMutableValueSelector;
|
|
13
|
-
function createContext() {
|
|
14
|
-
const context = (0, react_1.createContext)(null);
|
|
1
|
+
import { createContext as createReactContext, useCallback, useContext, useRef, useState, } from 'react';
|
|
2
|
+
import { createMutableValue, useMutableValueSelector } from './utils';
|
|
3
|
+
const createContextValue = createMutableValue;
|
|
4
|
+
export const useContextSelectorInternal = useMutableValueSelector;
|
|
5
|
+
export function createContext() {
|
|
6
|
+
const context = createReactContext(null);
|
|
15
7
|
return context;
|
|
16
8
|
}
|
|
17
|
-
function useCreateContextStore(initialValue) {
|
|
18
|
-
const [state] =
|
|
9
|
+
export function useCreateContextStore(initialValue) {
|
|
10
|
+
const [state] = useState(() => createContextValue(initialValue));
|
|
19
11
|
return state;
|
|
20
12
|
}
|
|
21
|
-
function useContextSelector(context, selector) {
|
|
22
|
-
const contextValue =
|
|
13
|
+
export function useContextSelector(context, selector) {
|
|
14
|
+
const contextValue = useContext(context);
|
|
23
15
|
if (!contextValue) {
|
|
24
16
|
throw new Error('useContextSelector must be used within a Provider');
|
|
25
17
|
}
|
|
26
|
-
return
|
|
18
|
+
return useContextSelectorInternal(contextValue, selector);
|
|
27
19
|
}
|
|
28
|
-
function useContextSetValue(context) {
|
|
29
|
-
const contextValue =
|
|
20
|
+
export function useContextSetValue(context) {
|
|
21
|
+
const contextValue = useContext(context);
|
|
30
22
|
if (!contextValue) {
|
|
31
23
|
throw new Error('useContextSetValue must be used within a Provider');
|
|
32
24
|
}
|
|
33
25
|
return contextValue.setValue;
|
|
34
26
|
}
|
|
35
|
-
function useContextValueSetter(context, setter) {
|
|
36
|
-
const contextValue =
|
|
27
|
+
export function useContextValueSetter(context, setter) {
|
|
28
|
+
const contextValue = useContext(context);
|
|
37
29
|
if (!contextValue) {
|
|
38
30
|
throw new Error('useContextValueSetter must be used within a Provider');
|
|
39
31
|
}
|
|
40
|
-
const setterRef =
|
|
32
|
+
const setterRef = useRef(setter);
|
|
41
33
|
setterRef.current = setter;
|
|
42
|
-
const setterWrapper =
|
|
34
|
+
const setterWrapper = useCallback((...args) => {
|
|
43
35
|
return setterRef.current(contextValue.setValue)(...args);
|
|
44
36
|
}, [contextValue.setValue]);
|
|
45
37
|
return setterWrapper;
|
package/mutable/index.js
CHANGED
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
exports.useMutableStateSelector = exports.useMutableState = exports.useContextValueSetter = exports.useCreateContextStore = exports.useContextSetValue = exports.useContextSelector = exports.createContext = void 0;
|
|
18
|
-
var context_1 = require("./context");
|
|
19
|
-
Object.defineProperty(exports, "createContext", { enumerable: true, get: function () { return context_1.createContext; } });
|
|
20
|
-
Object.defineProperty(exports, "useContextSelector", { enumerable: true, get: function () { return context_1.useContextSelector; } });
|
|
21
|
-
Object.defineProperty(exports, "useContextSetValue", { enumerable: true, get: function () { return context_1.useContextSetValue; } });
|
|
22
|
-
Object.defineProperty(exports, "useCreateContextStore", { enumerable: true, get: function () { return context_1.useCreateContextStore; } });
|
|
23
|
-
Object.defineProperty(exports, "useContextValueSetter", { enumerable: true, get: function () { return context_1.useContextValueSetter; } });
|
|
24
|
-
var state_1 = require("./state");
|
|
25
|
-
Object.defineProperty(exports, "useMutableState", { enumerable: true, get: function () { return state_1.useMutableState; } });
|
|
26
|
-
Object.defineProperty(exports, "useMutableStateSelector", { enumerable: true, get: function () { return state_1.useMutableStateSelector; } });
|
|
27
|
-
__exportStar(require("./type"), exports);
|
|
1
|
+
export { createContext, useContextSelector, useContextSetValue, useCreateContextStore, useContextValueSetter, } from './context';
|
|
2
|
+
export { useMutableState, useMutableStateSelector, } from './state';
|
|
3
|
+
export * from './type';
|
package/mutable/state.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
exports.createMutableState = utils_1.createMutableValue;
|
|
8
|
-
exports.useMutableStateSelector = utils_1.useMutableValueSelector;
|
|
9
|
-
function useMutableState(initialValue, isArray) {
|
|
10
|
-
const [state] = (0, react_1.useState)(() => (0, exports.createMutableState)(initialValue, isArray));
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { createMutableValue, useMutableValueSelector } from './utils';
|
|
3
|
+
export const createMutableState = createMutableValue;
|
|
4
|
+
export const useMutableStateSelector = useMutableValueSelector;
|
|
5
|
+
export function useMutableState(initialValue, isArray) {
|
|
6
|
+
const [state] = useState(() => createMutableState(initialValue, isArray));
|
|
11
7
|
return state;
|
|
12
8
|
}
|
package/mutable/type.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/mutable/utils.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.createMutableValue = createMutableValue;
|
|
4
|
-
exports.useMutableValueSelector = useMutableValueSelector;
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
function createMutableValue(initialValue, isArray) {
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
export function createMutableValue(initialValue, isArray) {
|
|
7
3
|
let storeValue = {
|
|
8
4
|
current: initialValue,
|
|
9
5
|
};
|
|
@@ -12,20 +8,13 @@ function createMutableValue(initialValue, isArray) {
|
|
|
12
8
|
value: storeValue,
|
|
13
9
|
setValue: (value) => {
|
|
14
10
|
if (typeof value === 'function') {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
storeValue.current = Object.assign(Object.assign({}, storeValue.current), value(storeValue.current));
|
|
20
|
-
}
|
|
11
|
+
value = value(storeValue.current);
|
|
12
|
+
}
|
|
13
|
+
if (isArray) {
|
|
14
|
+
storeValue.current = value;
|
|
21
15
|
}
|
|
22
16
|
else {
|
|
23
|
-
|
|
24
|
-
storeValue.current = value;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
storeValue.current = Object.assign(Object.assign({}, storeValue.current), value);
|
|
28
|
-
}
|
|
17
|
+
storeValue.current = Object.assign(Object.assign({}, storeValue.current), value);
|
|
29
18
|
}
|
|
30
19
|
listeners.forEach((listener) => listener(storeValue.current));
|
|
31
20
|
},
|
|
@@ -34,15 +23,15 @@ function createMutableValue(initialValue, isArray) {
|
|
|
34
23
|
removeListener: (listener) => listeners.delete(listener),
|
|
35
24
|
};
|
|
36
25
|
}
|
|
37
|
-
function useMutableValueSelector(mutableValue, selector) {
|
|
38
|
-
const selectorRef =
|
|
26
|
+
export function useMutableValueSelector(mutableValue, selector) {
|
|
27
|
+
const selectorRef = useRef(selector);
|
|
39
28
|
selectorRef.current = selector;
|
|
40
|
-
const [value, setValue] =
|
|
29
|
+
const [value, setValue] = useState({
|
|
41
30
|
innerValue: selectorRef.current(mutableValue.value.current),
|
|
42
31
|
});
|
|
43
|
-
const valueRef =
|
|
32
|
+
const valueRef = useRef(value);
|
|
44
33
|
valueRef.current = value;
|
|
45
|
-
|
|
34
|
+
useEffect(() => {
|
|
46
35
|
const listener = (state) => {
|
|
47
36
|
const newValue = selectorRef.current(state);
|
|
48
37
|
if (newValue !== valueRef.current.innerValue) {
|
|
@@ -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("./useOpenForm"), exports);
|
|
1
|
+
export * from './useOpenForm';
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const routeResolver = (0, useRouteResolver_1.useRouteResolver)();
|
|
11
|
-
const router = (0, hooks_1.useRouter)();
|
|
12
|
-
return (0, react_1.useCallback)((options) => {
|
|
1
|
+
import { setFormDefaultParameters } from '@headless-adminapp/app/dataform/utils/defaultParameters';
|
|
2
|
+
import { PageType } from '@headless-adminapp/core/experience/app';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { useRouter } from '../../route/hooks/';
|
|
5
|
+
import { useRouteResolver } from '../../route/hooks/useRouteResolver';
|
|
6
|
+
export function useOpenForm() {
|
|
7
|
+
const routeResolver = useRouteResolver();
|
|
8
|
+
const router = useRouter();
|
|
9
|
+
return useCallback((options) => {
|
|
13
10
|
const path = routeResolver({
|
|
14
11
|
logicalName: options.logicalName,
|
|
15
|
-
type:
|
|
12
|
+
type: PageType.EntityForm,
|
|
16
13
|
id: options.id,
|
|
17
14
|
});
|
|
18
15
|
if (options.parameters) {
|
|
19
|
-
|
|
16
|
+
setFormDefaultParameters(options.logicalName, options.parameters);
|
|
20
17
|
}
|
|
21
18
|
if (options.replace) {
|
|
22
19
|
router.replace(path);
|
package/navigation/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("./hooks"), exports);
|
|
1
|
+
export * from './hooks';
|