@headless-adminapp/app 0.0.17-alpha.53 → 0.0.17-alpha.55
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 +24 -32
- package/app/AuthWrapper.js +13 -9
- package/app/LayoutProvider.js +34 -39
- package/app/context.js +5 -2
- package/app/hooks/index.js +17 -1
- package/app/hooks/useAppContext.js +7 -4
- package/app/index.js +11 -4
- package/auth/AuthProvider.js +27 -36
- package/auth/context.d.ts +1 -1
- package/auth/context.js +5 -2
- package/auth/hooks/index.js +18 -2
- package/auth/hooks/useAuthSession.js +7 -4
- package/auth/hooks/useIsSkipAuthCheck.js +7 -4
- package/auth/hooks/useLogout.js +11 -8
- package/auth/index.js +23 -4
- package/auth/types.js +2 -1
- package/board/BoardColumnDataResolver.js +23 -20
- package/board/BoardColumnProvider.js +14 -10
- package/board/context.d.ts +2 -2
- package/board/context.js +6 -3
- package/board/hooks/index.js +15 -6
- package/board/hooks/useBoardColumnConfig.js +7 -4
- package/board/hooks/useBoardColumnData.d.ts +3 -1
- package/board/hooks/useBoardColumnData.js +7 -4
- package/board/hooks/useBoardColumnDataState.js +7 -4
- package/board/hooks/useBoardConfig.js +7 -4
- package/board/hooks/useBoardSchema.js +6 -3
- package/board/hooks/useSearchText.js +10 -7
- package/board/types.js +2 -1
- package/board/utils.js +4 -1
- package/builders/CommandBuilder/CommandBuilder.js +13 -10
- package/builders/CommandBuilder/DefaultCommandBuilder.js +30 -23
- package/builders/CommandBuilder/FormCommandBuilder.js +29 -38
- package/builders/CommandBuilder/SubgridCommandBuilder.js +27 -36
- package/builders/CommandBuilder/ViewCommandBuilder.js +29 -38
- package/builders/CommandBuilder/index.js +5 -1
- package/builders/CommandBuilder/utils.js +7 -3
- package/builders/SchemaExperienceBuilder.js +55 -31
- package/builders/index.js +7 -2
- package/builders/utils.js +59 -44
- package/command/hooks/index.js +18 -2
- package/command/hooks/useBaseCommandHandlerContext.js +29 -25
- package/command/hooks/useCommands.js +9 -6
- package/command/index.js +18 -2
- package/command/types.js +2 -1
- package/command/utils/index.js +41 -13
- package/components/ScrollView/index.d.ts +1 -1
- package/components/ScrollView/index.js +11 -4
- package/components/ScrollbarWithMoreDataRequest/index.js +14 -11
- package/dataform/DataFormProvider/DataResolver.js +81 -89
- package/dataform/DataFormProvider/InitialValueResolver.js +22 -20
- package/dataform/DataFormProvider/ReadonlyInfoResolver.js +14 -12
- package/dataform/DataFormProvider/index.js +26 -32
- package/dataform/context.js +5 -2
- package/dataform/hooks/index.js +29 -13
- package/dataform/hooks/useFormInstance.js +6 -3
- package/dataform/hooks/useFormIsDirty.js +6 -3
- package/dataform/hooks/useFormIsReadonly.js +7 -4
- package/dataform/hooks/useFormNotifications.js +12 -9
- package/dataform/hooks/useFormRecord.js +7 -4
- package/dataform/hooks/useFormSave.js +40 -46
- package/dataform/hooks/useFormSchema.js +7 -4
- package/dataform/hooks/useLoadFormGridPage.js +19 -25
- package/dataform/hooks/useMainFormCommands.js +37 -30
- package/dataform/hooks/useProcessFlowSteps.js +27 -23
- package/dataform/hooks/useRecordId.js +7 -4
- package/dataform/hooks/useRecordTitle.js +12 -9
- package/dataform/hooks/useSelectedForm.js +7 -4
- package/dataform/index.js +23 -4
- package/dataform/utils/defaultParameters.js +16 -6
- package/dataform/utils/index.js +90 -56
- package/dataform/utils/saveRecord.js +99 -104
- package/datagrid/DataGridProvider/DataResolver.js +36 -34
- package/datagrid/DataGridProvider/index.js +31 -32
- package/datagrid/DataGridProvider/transformViewColumns.js +17 -6
- package/datagrid/DataGridProvider/utils.js +13 -5
- package/datagrid/column-filter/constants.js +5 -2
- package/datagrid/column-filter/index.js +7 -2
- package/datagrid/column-filter/types.js +2 -1
- package/datagrid/column-filter/utils.js +13 -3
- package/datagrid/context.d.ts +1 -1
- package/datagrid/context.js +5 -2
- package/datagrid/hooks/index.js +36 -20
- package/datagrid/hooks/useChangeView.js +10 -7
- package/datagrid/hooks/useGridColumnFilter.js +14 -8
- package/datagrid/hooks/useGridColumns.js +7 -4
- package/datagrid/hooks/useGridCommands.js +7 -4
- package/datagrid/hooks/useGridData.js +7 -4
- package/datagrid/hooks/useGridDataState.js +7 -4
- package/datagrid/hooks/useGridExtraFilter.js +7 -4
- package/datagrid/hooks/useGridOptions.js +4 -1
- package/datagrid/hooks/useGridPagination.js +4 -1
- package/datagrid/hooks/useGridRefresh.js +10 -7
- package/datagrid/hooks/useGridSchema.js +7 -4
- package/datagrid/hooks/useGridSelection.js +10 -7
- package/datagrid/hooks/useGridSorting.js +10 -7
- package/datagrid/hooks/useGridViewLookupData.js +7 -4
- package/datagrid/hooks/useLoadMainGridPage.js +12 -9
- package/datagrid/hooks/useMainGridCommands.js +62 -54
- package/datagrid/hooks/useMaxRecords.js +7 -4
- package/datagrid/hooks/useOpenRecord.js +20 -17
- package/datagrid/hooks/useSearchText.js +10 -7
- package/datagrid/hooks/useSelectedView.js +7 -4
- package/datagrid/hooks/useSubGridCommands.js +34 -23
- package/datagrid/index.js +27 -5
- package/defaults.js +5 -2
- package/dialog/DialogProvider.js +10 -6
- package/dialog/context.d.ts +1 -1
- package/dialog/context.js +5 -2
- package/dialog/hooks/index.js +24 -8
- package/dialog/hooks/useCloseDialog.js +10 -7
- package/dialog/hooks/useDialogItem.d.ts +1 -1
- package/dialog/hooks/useDialogItem.js +7 -4
- package/dialog/hooks/useDialogItems.d.ts +1 -1
- package/dialog/hooks/useDialogItems.js +7 -4
- package/dialog/hooks/useOpenAlertDialog.js +16 -8
- package/dialog/hooks/useOpenConfirmDialog.js +18 -9
- package/dialog/hooks/useOpenDialog.js +18 -11
- package/dialog/hooks/useOpenErrorDialog.js +16 -8
- package/dialog/hooks/useOpenPromptDialog.js +18 -9
- package/dialog/index.js +22 -3
- package/form/FormValidationStringContext.js +9 -5
- package/form/index.js +7 -1
- package/hooks/index.js +24 -6
- package/hooks/useDebouncedValue.js +11 -8
- package/hooks/useElementLayout.js +7 -4
- package/hooks/useIsMobile.js +12 -6
- package/hooks/useItemsWithKey.js +8 -5
- package/hooks/useStorageState.js +7 -5
- package/hooks/useSystemColorScheme.js +7 -4
- package/insights/InsightsProvider.js +13 -10
- package/insights/context.d.ts +1 -1
- package/insights/context.js +5 -2
- package/insights/hooks/index.js +7 -4
- package/insights/index.js +20 -2
- package/locale/LocaleProvider.js +12 -8
- package/locale/context.js +5 -2
- package/locale/index.js +23 -4
- package/locale/useCurrencySymbol.js +10 -8
- package/locale/useLocale.js +7 -4
- package/locale/utils.js +8 -3
- package/metadata/MetadataProvider.js +21 -17
- package/metadata/context.d.ts +1 -1
- package/metadata/context.js +5 -2
- package/metadata/hooks/index.js +24 -8
- package/metadata/hooks/useAppStore.js +7 -4
- package/metadata/hooks/useExperienceStore.js +7 -4
- package/metadata/hooks/useExperienceView.js +11 -17
- package/metadata/hooks/useExperienceViewCommands.js +14 -20
- package/metadata/hooks/useExperienceViewLookup.js +10 -16
- package/metadata/hooks/useExperienceViewSubgridCommands.js +14 -20
- package/metadata/hooks/useMetadata.js +11 -8
- package/metadata/hooks/useSchema.js +6 -3
- package/metadata/index.js +22 -3
- package/mutable/context.js +25 -17
- package/mutable/index.js +27 -3
- package/mutable/state.js +10 -6
- package/mutable/type.js +2 -1
- package/mutable/utils.js +12 -8
- package/navigation/hooks/index.js +17 -1
- package/navigation/hooks/useOpenForm.js +14 -11
- package/navigation/index.js +17 -1
- package/package.json +4 -12
- package/progress-indicator/ProgressIndicatorProvider.js +16 -12
- package/progress-indicator/context.js +5 -2
- package/progress-indicator/hooks/index.js +17 -1
- package/progress-indicator/hooks/useProgressIndicator.d.ts +1 -1
- package/progress-indicator/hooks/useProgressIndicator.js +7 -4
- package/progress-indicator/index.js +22 -3
- package/providers/PageEntityFormProvider/index.js +7 -4
- package/providers/PageEntityViewProvider/index.js +7 -4
- package/recordset/RecordSetProvider.js +16 -12
- package/recordset/context.d.ts +1 -1
- package/recordset/context.js +5 -2
- package/recordset/hooks/index.js +19 -3
- package/recordset/hooks/useRecordSetResult.js +22 -29
- package/recordset/hooks/useRecordSetSetter.js +9 -6
- package/recordset/hooks/useRecordSetVisibility.js +10 -7
- package/recordset/index.js +22 -3
- package/route/RouteProvider.js +18 -14
- package/route/context.js +9 -6
- package/route/hooks/index.js +22 -6
- package/route/hooks/useBasePath.js +7 -4
- package/route/hooks/useIsRouteActive.js +7 -4
- package/route/hooks/usePathname.js +7 -4
- package/route/hooks/useRouteResolver.js +7 -4
- package/route/hooks/useRouter.js +7 -4
- package/route/hooks/useSearchParams.js +7 -4
- package/route/index.js +20 -2
- package/route/types.js +2 -1
- package/store/ClientAppStore.js +12 -21
- package/store/ComponentStore.js +6 -4
- package/store/EventManager.js +20 -32
- package/store/SchemaExperienceStore.js +186 -217
- package/store/index.js +20 -4
- package/toast-notification/ToastNotificationProvider.js +10 -6
- package/toast-notification/context.d.ts +1 -1
- package/toast-notification/context.js +5 -2
- package/toast-notification/hooks/index.js +19 -3
- package/toast-notification/hooks/useCloseToastNotification.js +10 -7
- package/toast-notification/hooks/useOpenToastNotification.js +18 -11
- package/toast-notification/hooks/useToastNotificationItems.d.ts +1 -1
- package/toast-notification/hooks/useToastNotificationItems.js +7 -4
- package/toast-notification/index.js +22 -3
- package/transport/InMemoryDataService/index.js +59 -78
- package/transport/RestDataService/index.d.ts +2 -2
- package/transport/RestDataService/index.js +72 -91
- package/transport/context.js +9 -15
- package/transport/hooks/index.js +18 -2
- package/transport/hooks/useDataService.js +7 -4
- package/transport/hooks/useFileService.js +7 -4
- package/transport/hooks/useRetriveRecords.d.ts +1 -1
- package/transport/hooks/useRetriveRecords.js +25 -31
- package/transport/index.js +20 -2
- package/utils/calculateColumnWidths.js +5 -2
- package/utils/color.js +4 -1
- package/utils/getAttributeFormattedValue.js +38 -40
- package/utils/index.js +18 -2
- package/widget/context.js +5 -2
- package/widget/hooks/index.js +7 -4
- package/widget/index.js +5 -1
package/app/AppProvider.js
CHANGED
|
@@ -1,46 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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({
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const hooks_1 = require("../metadata/hooks");
|
|
8
|
+
const context_1 = require("./context");
|
|
9
|
+
const AppProvider = ({ children, appId, loadingComponent, notFoundComponent, }) => {
|
|
10
|
+
const experienceStore = (0, hooks_1.useExperienceStore)();
|
|
11
|
+
const appStore = (0, hooks_1.useAppStore)();
|
|
12
|
+
const { data: schemaMetadataList } = (0, react_query_1.useQuery)({
|
|
19
13
|
queryKey: ['experience-schema-metadata-list'],
|
|
20
|
-
queryFn: () =>
|
|
14
|
+
queryFn: async () => {
|
|
21
15
|
return experienceStore.getExperienceSchemaMetadatList();
|
|
22
|
-
}
|
|
16
|
+
},
|
|
23
17
|
initialData: [],
|
|
24
18
|
});
|
|
25
|
-
const { data: app, isLoading } = useQuery({
|
|
19
|
+
const { data: app, isLoading } = (0, react_query_1.useQuery)({
|
|
26
20
|
queryKey: ['experience-app', appId],
|
|
27
|
-
queryFn: () =>
|
|
21
|
+
queryFn: async () => {
|
|
28
22
|
return appStore.getApp(appId);
|
|
29
|
-
}
|
|
23
|
+
},
|
|
30
24
|
});
|
|
31
|
-
const schemaMetadataDic = useMemo(() => {
|
|
32
|
-
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, {})) !== null && _a !== void 0 ? _a : {};
|
|
37
|
-
}, [schemaMetadataList]);
|
|
38
|
-
const contextValue = useMemo(() => ({ app, schemaMetadataDic, schemaMetadataList }), [app, schemaMetadataDic, schemaMetadataList]);
|
|
25
|
+
const schemaMetadataDic = (0, react_1.useMemo)(() => schemaMetadataList?.reduce((acc, item) => {
|
|
26
|
+
acc[item.logicalName] = item;
|
|
27
|
+
return acc;
|
|
28
|
+
}, {}) ?? {}, [schemaMetadataList]);
|
|
29
|
+
const contextValue = (0, react_1.useMemo)(() => ({ app, schemaMetadataDic, schemaMetadataList }), [app, schemaMetadataDic, schemaMetadataList]);
|
|
39
30
|
if (isLoading) {
|
|
40
31
|
return loadingComponent;
|
|
41
32
|
}
|
|
42
33
|
if (!app) {
|
|
43
34
|
return notFoundComponent;
|
|
44
35
|
}
|
|
45
|
-
return (
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(context_1.AppContext.Provider, { value: contextValue, children: children }));
|
|
46
37
|
};
|
|
38
|
+
exports.AppProvider = AppProvider;
|
package/app/AuthWrapper.js
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthWrapper = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const auth_1 = require("../auth");
|
|
6
|
+
const mutable_1 = require("../mutable");
|
|
4
7
|
const DefaultPlaceHolder = () => {
|
|
5
8
|
return null;
|
|
6
9
|
};
|
|
7
|
-
|
|
8
|
-
const state = useContextSelector(AuthContext, (state) => state);
|
|
10
|
+
const AuthWrapper = ({ children, Placeholder = DefaultPlaceHolder, }) => {
|
|
11
|
+
const state = (0, mutable_1.useContextSelector)(auth_1.AuthContext, (state) => state);
|
|
9
12
|
if (state.loadError) {
|
|
10
|
-
return
|
|
13
|
+
return (0, jsx_runtime_1.jsx)(Placeholder, { loadingError: true, retry: state.loadSession });
|
|
11
14
|
}
|
|
12
15
|
if (!state.initialized || state.loading) {
|
|
13
|
-
return
|
|
16
|
+
return (0, jsx_runtime_1.jsx)(Placeholder, { loading: true, retry: state.loadSession });
|
|
14
17
|
}
|
|
15
18
|
if (!state.authenticated) {
|
|
16
19
|
if (state.sessionExpired) {
|
|
17
|
-
return
|
|
20
|
+
return (0, jsx_runtime_1.jsx)(Placeholder, { sessionExpired: true, retry: state.loadSession });
|
|
18
21
|
}
|
|
19
|
-
return
|
|
22
|
+
return (0, jsx_runtime_1.jsx)(Placeholder, { unauthorized: true, retry: state.loadSession });
|
|
20
23
|
}
|
|
21
24
|
return children;
|
|
22
25
|
};
|
|
26
|
+
exports.AuthWrapper = AuthWrapper;
|
package/app/LayoutProvider.js
CHANGED
|
@@ -1,50 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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';
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LayoutProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const defaults_1 = require("../defaults");
|
|
8
|
+
const dialog_1 = require("../dialog");
|
|
9
|
+
const locale_1 = require("../locale");
|
|
10
|
+
const metadata_1 = require("../metadata");
|
|
11
|
+
const progress_indicator_1 = require("../progress-indicator");
|
|
12
|
+
const recordset_1 = require("../recordset");
|
|
13
|
+
const route_1 = require("../route");
|
|
14
|
+
const toast_notification_1 = require("../toast-notification");
|
|
15
|
+
const transport_1 = require("../transport");
|
|
16
|
+
const context_1 = require("../transport/context");
|
|
17
|
+
const AuthWrapper_1 = require("./AuthWrapper");
|
|
24
18
|
const dataServiceNotProvidedError = new Error('No data service provided');
|
|
25
19
|
const defaultDataService = {
|
|
26
|
-
createRecord: () =>
|
|
20
|
+
createRecord: async () => {
|
|
27
21
|
throw dataServiceNotProvidedError;
|
|
28
|
-
}
|
|
29
|
-
deleteRecord: () =>
|
|
22
|
+
},
|
|
23
|
+
deleteRecord: async () => {
|
|
30
24
|
throw dataServiceNotProvidedError;
|
|
31
|
-
}
|
|
32
|
-
customAction: () =>
|
|
25
|
+
},
|
|
26
|
+
customAction: async () => {
|
|
33
27
|
throw dataServiceNotProvidedError;
|
|
34
|
-
}
|
|
35
|
-
retriveAggregate: () =>
|
|
28
|
+
},
|
|
29
|
+
retriveAggregate: async () => {
|
|
36
30
|
throw dataServiceNotProvidedError;
|
|
37
|
-
}
|
|
38
|
-
retriveRecord: () =>
|
|
31
|
+
},
|
|
32
|
+
retriveRecord: async () => {
|
|
39
33
|
throw dataServiceNotProvidedError;
|
|
40
|
-
}
|
|
41
|
-
retriveRecords: () =>
|
|
34
|
+
},
|
|
35
|
+
retriveRecords: async () => {
|
|
42
36
|
throw dataServiceNotProvidedError;
|
|
43
|
-
}
|
|
44
|
-
updateRecord: () =>
|
|
37
|
+
},
|
|
38
|
+
updateRecord: async () => {
|
|
45
39
|
throw dataServiceNotProvidedError;
|
|
46
|
-
}
|
|
40
|
+
},
|
|
47
41
|
};
|
|
48
|
-
|
|
49
|
-
return (
|
|
42
|
+
const LayoutProvider = ({ authPlaceholder, authProps, dataService = defaultDataService, fileService, localeProps, metadataProps, queryClient = defaults_1.queryClient, routeProps, children, containers: { DialogContainer, ProgressIndicatorContainer, ToastNotificationContainer, }, }) => {
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)(route_1.RouteProvider, { ...routeProps, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(locale_1.LocaleProvider, { ...localeProps, children: (0, jsx_runtime_1.jsx)(metadata_1.MetadataProvider, { ...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 ?? 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, { ...authProps, children: (0, jsx_runtime_1.jsx)(AuthWrapper_1.AuthWrapper, { Placeholder: authPlaceholder, children: (0, jsx_runtime_1.jsx)(recordset_1.RecordSetProvider, { children: children }) }) })] }) }) }) }) }) }) }) }) }));
|
|
50
44
|
};
|
|
45
|
+
exports.LayoutProvider = LayoutProvider;
|
package/app/context.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
exports.AppContext = (0, react_1.createContext)(null);
|
package/app/hooks/index.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
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,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAppContext = useAppContext;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const context_1 = require("../context");
|
|
6
|
+
function useAppContext() {
|
|
7
|
+
const context = (0, react_1.useContext)(context_1.AppContext);
|
|
5
8
|
if (!context) {
|
|
6
9
|
throw new Error('useAppContext must be used within a AppContextProvider');
|
|
7
10
|
}
|
package/app/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LayoutProvider = exports.AppProvider = exports.useAppContext = exports.AppContext = void 0;
|
|
4
|
+
var context_1 = require("./context");
|
|
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; } });
|
package/auth/AuthProvider.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
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);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const context_1 = require("../mutable/context");
|
|
8
|
+
const context_2 = require("./context");
|
|
9
|
+
const AuthProvider = ({ sessionResolver, onUnauthenticated, children, }) => {
|
|
10
|
+
const onUnauthenticatedRef = (0, react_1.useRef)(onUnauthenticated);
|
|
17
11
|
onUnauthenticatedRef.current = onUnauthenticated;
|
|
18
|
-
const queryClient = useQueryClient();
|
|
19
|
-
const onUnauthenticatedInternal = useCallback((reason) => {
|
|
20
|
-
|
|
21
|
-
(_a = onUnauthenticatedRef.current) === null || _a === void 0 ? void 0 : _a.call(onUnauthenticatedRef, reason);
|
|
12
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
13
|
+
const onUnauthenticatedInternal = (0, react_1.useCallback)((reason) => {
|
|
14
|
+
onUnauthenticatedRef.current?.(reason);
|
|
22
15
|
queryClient.clear();
|
|
23
16
|
queryClient.removeQueries({
|
|
24
17
|
queryKey: ['data'],
|
|
@@ -29,7 +22,7 @@ export const AuthProvider = ({ sessionResolver, onUnauthenticated, children, })
|
|
|
29
22
|
})
|
|
30
23
|
.catch(console.error);
|
|
31
24
|
}, [queryClient]);
|
|
32
|
-
const contextValue = useCreateContextStore({
|
|
25
|
+
const contextValue = (0, context_1.useCreateContextStore)({
|
|
33
26
|
loading: !!sessionResolver,
|
|
34
27
|
loadError: false,
|
|
35
28
|
authenticated: !sessionResolver,
|
|
@@ -38,18 +31,17 @@ export const AuthProvider = ({ sessionResolver, onUnauthenticated, children, })
|
|
|
38
31
|
loadSession: () => Promise.resolve(),
|
|
39
32
|
onUnauthenticated: onUnauthenticatedInternal,
|
|
40
33
|
});
|
|
41
|
-
const state = useContextSelectorInternal(contextValue, (state) => state);
|
|
34
|
+
const state = (0, context_1.useContextSelectorInternal)(contextValue, (state) => state);
|
|
42
35
|
const session = state.initialized && state.authenticated && state.session;
|
|
43
|
-
const sessionResolverRef = useRef(sessionResolver);
|
|
36
|
+
const sessionResolverRef = (0, react_1.useRef)(sessionResolver);
|
|
44
37
|
sessionResolverRef.current = sessionResolver;
|
|
45
|
-
const loadSession =
|
|
46
|
-
var _a;
|
|
38
|
+
const loadSession = (0, react_1.useCallback)(async () => {
|
|
47
39
|
contextValue.setValue({ loading: true, loadError: false });
|
|
48
40
|
try {
|
|
49
41
|
if (!sessionResolverRef.current) {
|
|
50
42
|
return;
|
|
51
43
|
}
|
|
52
|
-
const data =
|
|
44
|
+
const data = await sessionResolverRef.current();
|
|
53
45
|
if (!data) {
|
|
54
46
|
contextValue.setValue({
|
|
55
47
|
initialized: true,
|
|
@@ -57,7 +49,7 @@ export const AuthProvider = ({ sessionResolver, onUnauthenticated, children, })
|
|
|
57
49
|
sessionExpired: false,
|
|
58
50
|
session: null,
|
|
59
51
|
});
|
|
60
|
-
|
|
52
|
+
onUnauthenticatedRef.current?.('load');
|
|
61
53
|
}
|
|
62
54
|
else {
|
|
63
55
|
contextValue.setValue({
|
|
@@ -74,15 +66,14 @@ export const AuthProvider = ({ sessionResolver, onUnauthenticated, children, })
|
|
|
74
66
|
finally {
|
|
75
67
|
contextValue.setValue({ loading: false });
|
|
76
68
|
}
|
|
77
|
-
}
|
|
78
|
-
useEffect(() => {
|
|
69
|
+
}, [contextValue]);
|
|
70
|
+
(0, react_1.useEffect)(() => {
|
|
79
71
|
contextValue.setValue({ loadSession });
|
|
80
72
|
}, [contextValue, loadSession]);
|
|
81
|
-
useEffect(() => {
|
|
73
|
+
(0, react_1.useEffect)(() => {
|
|
82
74
|
loadSession().catch(console.error);
|
|
83
75
|
}, [loadSession]);
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
var _a;
|
|
76
|
+
(0, react_1.useEffect)(() => {
|
|
86
77
|
if (!session) {
|
|
87
78
|
return;
|
|
88
79
|
}
|
|
@@ -95,7 +86,7 @@ export const AuthProvider = ({ sessionResolver, onUnauthenticated, children, })
|
|
|
95
86
|
sessionExpired: true,
|
|
96
87
|
session: null,
|
|
97
88
|
});
|
|
98
|
-
|
|
89
|
+
onUnauthenticatedRef.current?.('sessionExpired');
|
|
99
90
|
return;
|
|
100
91
|
}
|
|
101
92
|
const MAX_TIMEOUT = 2147483647;
|
|
@@ -103,18 +94,18 @@ export const AuthProvider = ({ sessionResolver, onUnauthenticated, children, })
|
|
|
103
94
|
return;
|
|
104
95
|
}
|
|
105
96
|
const timer = setTimeout(() => {
|
|
106
|
-
var _a;
|
|
107
97
|
contextValue.setValue({
|
|
108
98
|
initialized: true,
|
|
109
99
|
authenticated: false,
|
|
110
100
|
sessionExpired: true,
|
|
111
101
|
session: null,
|
|
112
102
|
});
|
|
113
|
-
|
|
103
|
+
onUnauthenticatedRef.current?.('sessionExpired');
|
|
114
104
|
}, timeout);
|
|
115
105
|
return () => {
|
|
116
106
|
clearTimeout(timer);
|
|
117
107
|
};
|
|
118
108
|
}, [contextValue, session]);
|
|
119
|
-
return (
|
|
109
|
+
return ((0, jsx_runtime_1.jsx)(context_2.AuthContext.Provider, { value: contextValue, children: children }));
|
|
120
110
|
};
|
|
111
|
+
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").ContextValue<AuthState>>;
|
|
30
|
+
export declare const AuthContext: import("react").Context<import("../mutable/context").ContextValue<AuthState>>;
|
|
31
31
|
export {};
|
package/auth/context.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthContext = void 0;
|
|
4
|
+
const context_1 = require("../mutable/context");
|
|
5
|
+
exports.AuthContext = (0, context_1.createContext)();
|
package/auth/hooks/index.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
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("./useAuthSession"), exports);
|
|
18
|
+
__exportStar(require("./useLogout"), exports);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAuthSession = useAuthSession;
|
|
4
|
+
const mutable_1 = require("../../mutable");
|
|
5
|
+
const context_1 = require("../context");
|
|
6
|
+
function useAuthSession() {
|
|
7
|
+
return (0, mutable_1.useContextSelector)(context_1.AuthContext, (state) => {
|
|
5
8
|
if (!state.initialized) {
|
|
6
9
|
return null;
|
|
7
10
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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) => state.skipAuthCheck ?? false);
|
|
5
8
|
}
|
package/auth/hooks/useLogout.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLogout = useLogout;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const context_1 = require("../../mutable/context");
|
|
6
|
+
const context_2 = require("../context");
|
|
7
|
+
function useLogout() {
|
|
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)(() => {
|
|
8
11
|
setValue({
|
|
9
12
|
initialized: true,
|
|
10
13
|
authenticated: false,
|
|
11
14
|
session: null,
|
|
12
15
|
});
|
|
13
|
-
onUnauthenticated
|
|
16
|
+
onUnauthenticated?.('logout');
|
|
14
17
|
}, [setValue, onUnauthenticated]);
|
|
15
18
|
return logout;
|
|
16
19
|
}
|
package/auth/index.js
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
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
|
+
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);
|
package/auth/types.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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");
|
|
9
12
|
const MAX_RECORDS = 10000;
|
|
10
|
-
|
|
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({
|
|
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)({
|
|
17
20
|
columns,
|
|
18
21
|
expand,
|
|
19
22
|
filter,
|
|
@@ -22,8 +25,8 @@ export function DataResolver() {
|
|
|
22
25
|
search,
|
|
23
26
|
sorting,
|
|
24
27
|
});
|
|
25
|
-
useClearDataExceptFirstPage(queryKey);
|
|
26
|
-
const { fetchNextPage, data, hasNextPage, isFetching, isFetchingNextPage } = useRetriveRecords(queryKey, {
|
|
28
|
+
(0, useRetriveRecords_1.useClearDataExceptFirstPage)(queryKey);
|
|
29
|
+
const { fetchNextPage, data, hasNextPage, isFetching, isFetchingNextPage } = (0, useRetriveRecords_1.useRetriveRecords)(queryKey, {
|
|
27
30
|
columns,
|
|
28
31
|
expand,
|
|
29
32
|
filter,
|
|
@@ -32,12 +35,12 @@ export function DataResolver() {
|
|
|
32
35
|
search,
|
|
33
36
|
sorting,
|
|
34
37
|
});
|
|
35
|
-
useEffect(() => {
|
|
38
|
+
(0, react_1.useEffect)(() => {
|
|
36
39
|
setState({
|
|
37
40
|
fetchNextPage: fetchNextPage,
|
|
38
41
|
});
|
|
39
42
|
}, [fetchNextPage, setState]);
|
|
40
|
-
useEffect(() => {
|
|
43
|
+
(0, react_1.useEffect)(() => {
|
|
41
44
|
if (!data) {
|
|
42
45
|
setState({
|
|
43
46
|
data: null,
|
|
@@ -48,7 +51,7 @@ export function DataResolver() {
|
|
|
48
51
|
data,
|
|
49
52
|
});
|
|
50
53
|
}, [data, setState, schema.idAttribute]);
|
|
51
|
-
useEffect(() => {
|
|
54
|
+
(0, react_1.useEffect)(() => {
|
|
52
55
|
setState({
|
|
53
56
|
dataState: {
|
|
54
57
|
isFetching,
|