@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useOpenForm = useOpenForm;
|
|
4
|
+
const defaultParameters_1 = require("@headless-adminapp/app/dataform/utils/defaultParameters");
|
|
4
5
|
const app_1 = require("@headless-adminapp/core/experience/app");
|
|
5
6
|
const react_1 = require("react");
|
|
6
7
|
const hooks_1 = require("../../route/hooks/");
|
|
@@ -8,9 +9,16 @@ const useRouteResolver_1 = require("../../route/hooks/useRouteResolver");
|
|
|
8
9
|
function useOpenForm() {
|
|
9
10
|
const routeResolver = (0, useRouteResolver_1.useRouteResolver)();
|
|
10
11
|
const router = (0, hooks_1.useRouter)();
|
|
11
|
-
return (0, react_1.useCallback)((
|
|
12
|
-
const path = routeResolver(
|
|
13
|
-
|
|
12
|
+
return (0, react_1.useCallback)((options) => {
|
|
13
|
+
const path = routeResolver({
|
|
14
|
+
logicalName: options.logicalName,
|
|
15
|
+
type: app_1.PageType.EntityForm,
|
|
16
|
+
id: options.id,
|
|
17
|
+
});
|
|
18
|
+
if (options.parameters) {
|
|
19
|
+
(0, defaultParameters_1.setFormDefaultParameters)(options.logicalName, options.parameters);
|
|
20
|
+
}
|
|
21
|
+
if (options.replace) {
|
|
14
22
|
router.replace(path);
|
|
15
23
|
}
|
|
16
24
|
else {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hooks';
|
|
@@ -14,7 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.AppearanceContext = void 0;
|
|
18
|
-
var context_1 = require("./context");
|
|
19
|
-
Object.defineProperty(exports, "AppearanceContext", { enumerable: true, get: function () { return context_1.AppearanceContext; } });
|
|
20
17
|
__exportStar(require("./hooks"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/app",
|
|
3
|
-
"version": "0.0.17-alpha.
|
|
3
|
+
"version": "0.0.17-alpha.52",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tsc",
|
|
21
|
+
"clean": "rm -rf dist && rm -f tsconfig.tsbuildinfo",
|
|
21
22
|
"ts-check": "tsc --noEmit",
|
|
22
23
|
"copy-files": "cp package.json dist && cp src/index.css dist",
|
|
23
24
|
"prepublishOnly": "pnpm run build && pnpm run copy-files",
|
|
@@ -31,10 +32,13 @@
|
|
|
31
32
|
"@tanstack/react-query": "5.51.1",
|
|
32
33
|
"clsx": "2.1.1",
|
|
33
34
|
"dayjs": "^1.11.13",
|
|
35
|
+
"exceljs": "^4.4.0",
|
|
36
|
+
"json-to-csv-export": "^2.1.1",
|
|
34
37
|
"lodash": "^4.17.21",
|
|
35
38
|
"react-custom-scrollbars-2": "^4.5.0",
|
|
36
39
|
"react-hook-form": "7.52.2",
|
|
40
|
+
"uuid": "11.0.3",
|
|
37
41
|
"yup": "^1.4.0"
|
|
38
42
|
},
|
|
39
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "d51866b6ef09087e30a44a6a63f099075c6aea89"
|
|
40
44
|
}
|
|
@@ -26,7 +26,7 @@ function useRecordSetResult() {
|
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
28
|
return schemaStore.getSchema(context.logicalName);
|
|
29
|
-
}, [context.logicalName]);
|
|
29
|
+
}, [context.logicalName, schemaStore]);
|
|
30
30
|
const cardView = context.cardView;
|
|
31
31
|
const columns = (0, react_1.useMemo)(() => {
|
|
32
32
|
var _a;
|
package/route/RouteProvider.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface RouteProviderProps {
|
|
|
7
7
|
pathname: string;
|
|
8
8
|
searchParams: ReadonlyURLSearchParams;
|
|
9
9
|
basePath?: string;
|
|
10
|
-
routeResolver
|
|
11
|
-
isRouteActive
|
|
10
|
+
routeResolver?: RouteResolver;
|
|
11
|
+
isRouteActive?: IsRouteActive;
|
|
12
12
|
}
|
|
13
13
|
export declare const RouteProvider: FC<PropsWithChildren<RouteProviderProps>>;
|
package/route/RouteProvider.js
CHANGED
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RouteProvider = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const route_1 = require("@headless-adminapp/core/experience/route");
|
|
5
6
|
const react_1 = require("react");
|
|
6
7
|
const context_1 = require("./context");
|
|
7
|
-
const
|
|
8
|
+
const defaultRouteResolver = (0, route_1.createRouteResolver)(route_1.defaultRouteInfo);
|
|
9
|
+
const defaultIsRouteActive = (0, route_1.createIsRouteActive)(route_1.defaultRouteInfo);
|
|
10
|
+
const RouteProvider = ({ children, pathname, router, searchParams, basePath, routeResolver = defaultRouteResolver, isRouteActive = defaultIsRouteActive, }) => {
|
|
8
11
|
const basePathRef = (0, react_1.useRef)(basePath);
|
|
9
12
|
basePathRef.current = basePath;
|
|
10
13
|
const routeResolverRef = (0, react_1.useRef)(routeResolver);
|
|
@@ -2,5 +2,5 @@ import { IComponentStore } from '@headless-adminapp/core/store';
|
|
|
2
2
|
export declare class ComponentStore implements IComponentStore {
|
|
3
3
|
private components;
|
|
4
4
|
registerComponent<T>(name: string, component: T): void;
|
|
5
|
-
|
|
5
|
+
getComponent<T>(name: string): T | null;
|
|
6
6
|
}
|
package/store/ComponentStore.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ComponentStore = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
4
|
class ComponentStore {
|
|
6
5
|
constructor() {
|
|
7
6
|
this.components = {};
|
|
@@ -9,15 +8,12 @@ class ComponentStore {
|
|
|
9
8
|
registerComponent(name, component) {
|
|
10
9
|
this.components[name] = component;
|
|
11
10
|
}
|
|
12
|
-
|
|
11
|
+
getComponent(name) {
|
|
13
12
|
const self = this;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const Component = self.components[name];
|
|
19
|
-
return (0, jsx_runtime_1.jsx)(Component, Object.assign({}, props));
|
|
20
|
-
};
|
|
13
|
+
if (!self.components[name]) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return self.components[name];
|
|
21
17
|
}
|
|
22
18
|
}
|
|
23
19
|
exports.ComponentStore = ComponentStore;
|
|
@@ -23,9 +23,9 @@ export declare class SchemaExperienceStore implements ISchemaExperienceStore {
|
|
|
23
23
|
getDefaultViewLookupId(logicalName: string): Promise<string>;
|
|
24
24
|
getForm<S extends SchemaAttributes = SchemaAttributes>(logicalName: string, formId: string): Promise<Form<S>>;
|
|
25
25
|
getQuickCreateForm<S extends SchemaAttributes = SchemaAttributes>(logicalName: string, formId: string): Promise<QuickCreateForm<S>>;
|
|
26
|
-
getViewCommands(logicalName: string): Promise<EntityMainGridCommandItemExperience[][]>;
|
|
27
|
-
getFormCommands(logicalName: string): Promise<EntityMainFormCommandItemExperience[][]>;
|
|
28
|
-
getSubgridCommands(logicalName: string): Promise<SubGridCommandItemExperience[][]>;
|
|
26
|
+
getViewCommands(logicalName: string): Promise<EntityMainGridCommandItemExperience[][] | undefined>;
|
|
27
|
+
getFormCommands(logicalName: string): Promise<EntityMainFormCommandItemExperience[][] | undefined>;
|
|
28
|
+
getSubgridCommands(logicalName: string): Promise<SubGridCommandItemExperience[][] | undefined>;
|
|
29
29
|
getSchemaMetadataList(): SchemaMetadata[];
|
|
30
30
|
getExperienceSchemaMetadatList(): Promise<SchemaExperienceMetadata[]>;
|
|
31
31
|
}
|
|
@@ -4,26 +4,28 @@ exports.useCloseToastNotification = useCloseToastNotification;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const context_1 = require("../../mutable/context");
|
|
6
6
|
const context_2 = require("../context");
|
|
7
|
+
function markToastNotificationAsClosed(items, id) {
|
|
8
|
+
return items.map((item) => {
|
|
9
|
+
if (item.id === id) {
|
|
10
|
+
return Object.assign(Object.assign({}, item), { isOpen: false });
|
|
11
|
+
}
|
|
12
|
+
return item;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function excludeToastNotificationItemById(items, id) {
|
|
16
|
+
return items.filter((item) => item.id !== id);
|
|
17
|
+
}
|
|
7
18
|
function useCloseToastNotification() {
|
|
8
19
|
const setValue = (0, context_1.useContextSetValue)(context_2.ToastNotificationContext);
|
|
9
20
|
const closeDialog = (0, react_1.useCallback)((id) => {
|
|
10
|
-
setValue((state) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (item.id === id) {
|
|
14
|
-
return Object.assign(Object.assign({}, item), { isOpen: false });
|
|
15
|
-
}
|
|
16
|
-
return item;
|
|
17
|
-
}),
|
|
18
|
-
};
|
|
19
|
-
});
|
|
21
|
+
setValue((state) => ({
|
|
22
|
+
items: markToastNotificationAsClosed(state.items, id),
|
|
23
|
+
}));
|
|
20
24
|
// Simulate a delay to show the dialog closing animation
|
|
21
25
|
setTimeout(() => {
|
|
22
|
-
setValue((state) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
});
|
|
26
|
+
setValue((state) => ({
|
|
27
|
+
items: excludeToastNotificationItemById(state.items, id),
|
|
28
|
+
}));
|
|
27
29
|
}, 1000);
|
|
28
30
|
}, [setValue]);
|
|
29
31
|
return closeDialog;
|
|
@@ -2,17 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useOpenToastNotification = useOpenToastNotification;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
5
6
|
const context_1 = require("../../mutable/context");
|
|
6
7
|
const context_2 = require("../context");
|
|
7
8
|
const useCloseToastNotification_1 = require("./useCloseToastNotification");
|
|
8
|
-
function randomId() {
|
|
9
|
-
return Math.random().toString(36).substring(2);
|
|
10
|
-
}
|
|
11
9
|
function useOpenToastNotification() {
|
|
12
10
|
const setValue = (0, context_1.useContextSetValue)(context_2.ToastNotificationContext);
|
|
13
11
|
const closeDialog = (0, useCloseToastNotification_1.useCloseToastNotification)();
|
|
14
12
|
const openToastNotification = (0, react_1.useCallback)((options) => {
|
|
15
|
-
const id =
|
|
13
|
+
const id = (0, uuid_1.v4)();
|
|
16
14
|
setValue((state) => {
|
|
17
15
|
return {
|
|
18
16
|
items: [
|
|
@@ -3,11 +3,11 @@ import { RetriveRecordsFnOptions, RetriveRecordsResult } from '@headless-adminap
|
|
|
3
3
|
interface RestDataServiceOptions {
|
|
4
4
|
endpoint: string;
|
|
5
5
|
}
|
|
6
|
+
export declare function handleResponseError(response: Response): Promise<void>;
|
|
6
7
|
export declare class RestDataService implements IDataService {
|
|
7
8
|
protected readonly options: RestDataServiceOptions;
|
|
8
9
|
constructor(options: RestDataServiceOptions);
|
|
9
10
|
protected readonly headers: Record<string, string>;
|
|
10
|
-
protected handleResponseError(response: Response): Promise<void>;
|
|
11
11
|
private getHeaders;
|
|
12
12
|
setHeader(name: string, value: string): void;
|
|
13
13
|
removeHeader(name: string): void;
|
|
@@ -10,27 +10,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.RestDataService = void 0;
|
|
13
|
+
exports.handleResponseError = handleResponseError;
|
|
13
14
|
const transport_1 = require("@headless-adminapp/core/transport");
|
|
15
|
+
function handleResponseError(response) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
var _a;
|
|
18
|
+
if (response.ok) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
|
|
22
|
+
const data = yield response.json();
|
|
23
|
+
if (data.error) {
|
|
24
|
+
throw new transport_1.HttpError(response.status, data.error);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
throw new transport_1.HttpError(response.status, response.statusText);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
14
30
|
class RestDataService {
|
|
15
31
|
constructor(options) {
|
|
16
32
|
this.options = options;
|
|
17
33
|
this.headers = {};
|
|
18
34
|
}
|
|
19
|
-
handleResponseError(response) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
var _a;
|
|
22
|
-
if (response.ok) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
|
|
26
|
-
const data = yield response.json();
|
|
27
|
-
if (data.error) {
|
|
28
|
-
throw new transport_1.HttpError(response.status, data.error);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
throw new transport_1.HttpError(response.status, response.statusText);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
35
|
getHeaders() {
|
|
35
36
|
return Object.assign({ 'content-type': 'application/json' }, this.headers);
|
|
36
37
|
}
|
|
@@ -47,7 +48,7 @@ class RestDataService {
|
|
|
47
48
|
method: 'POST',
|
|
48
49
|
body: JSON.stringify(data),
|
|
49
50
|
});
|
|
50
|
-
yield
|
|
51
|
+
yield handleResponseError(response);
|
|
51
52
|
return response.json();
|
|
52
53
|
});
|
|
53
54
|
}
|
package/transport/context.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import { IDataService } from '@headless-adminapp/core/transport';
|
|
1
|
+
import { IDataService, IFileService } from '@headless-adminapp/core/transport';
|
|
2
2
|
export declare const DataServiceContext: import("react").Context<IDataService | undefined>;
|
|
3
|
+
export declare const noopFileService: IFileService;
|
|
4
|
+
export declare const FileServiceContext: import("react").Context<IFileService>;
|
package/transport/context.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
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
|
-
exports.DataServiceContext = void 0;
|
|
12
|
+
exports.FileServiceContext = exports.noopFileService = exports.DataServiceContext = void 0;
|
|
4
13
|
const react_1 = require("react");
|
|
5
14
|
exports.DataServiceContext = (0, react_1.createContext)(undefined);
|
|
15
|
+
exports.noopFileService = {
|
|
16
|
+
uploadFile: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
throw new Error('File service not implemented');
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
exports.FileServiceContext = (0, react_1.createContext)(exports.noopFileService);
|
package/transport/hooks/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useFileService(): import("@headless-adminapp/core/transport").IFileService;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFileService = useFileService;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const context_1 = require("../context");
|
|
6
|
+
function useFileService() {
|
|
7
|
+
const context = (0, react_1.useContext)(context_1.FileServiceContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error('FileServiceContext must be used within a FileServiceProvider');
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SortingState } from '@headless-adminapp/core/experience/view';
|
|
2
|
+
import { InferredSchemaType, Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
+
import { Filter } from '@headless-adminapp/core/transport';
|
|
4
|
+
import { QueryKey } from '@tanstack/react-query';
|
|
5
|
+
interface UseRetriveRecordProps<S extends SchemaAttributes = SchemaAttributes> {
|
|
6
|
+
schema: Schema<S>;
|
|
7
|
+
search: string;
|
|
8
|
+
filter: Filter | null;
|
|
9
|
+
sorting: SortingState<S>;
|
|
10
|
+
columns: string[];
|
|
11
|
+
expand?: Partial<Record<string, string[]>>;
|
|
12
|
+
maxRecords: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function useRetrieveRecordsKey<S extends SchemaAttributes = SchemaAttributes>({ schema, search, filter, sorting, columns, expand, maxRecords, }: UseRetriveRecordProps<S>): (string | number | string[] | Filter | Partial<Record<string, string[]>> | SortingState<S> | null | undefined)[];
|
|
15
|
+
export declare function useClearDataExceptFirstPage(queryKey: QueryKey): void;
|
|
16
|
+
export declare function useRetriveRecords<S extends SchemaAttributes = SchemaAttributes>(queryKey: QueryKey, { columns, expand, filter, maxRecords, schema, search, sorting, }: UseRetriveRecordProps): {
|
|
17
|
+
data: {
|
|
18
|
+
logicalName: string;
|
|
19
|
+
count: number;
|
|
20
|
+
records: import("@headless-adminapp/core/transport").Data<InferredSchemaType<S>>[];
|
|
21
|
+
} | null;
|
|
22
|
+
isFetching: boolean;
|
|
23
|
+
hasNextPage: boolean;
|
|
24
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<{
|
|
25
|
+
params: {
|
|
26
|
+
pageIndex: number;
|
|
27
|
+
};
|
|
28
|
+
data: import("@headless-adminapp/core/transport").RetriveRecordsResult<InferredSchemaType<S>>;
|
|
29
|
+
}, unknown>, Error>>;
|
|
30
|
+
isFetchingNextPage: boolean;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.useRetrieveRecordsKey = useRetrieveRecordsKey;
|
|
13
|
+
exports.useClearDataExceptFirstPage = useClearDataExceptFirstPage;
|
|
14
|
+
exports.useRetriveRecords = useRetriveRecords;
|
|
15
|
+
const transport_1 = require("@headless-adminapp/app/transport");
|
|
16
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
17
|
+
const react_1 = require("react");
|
|
18
|
+
const ROWS_PER_PAGE = 100;
|
|
19
|
+
function useRetrieveRecordsKey({ schema, search, filter, sorting, columns, expand, maxRecords, }) {
|
|
20
|
+
const queryKey = (0, react_1.useMemo)(() => [
|
|
21
|
+
'data',
|
|
22
|
+
'retriveRecords',
|
|
23
|
+
schema.logicalName,
|
|
24
|
+
search,
|
|
25
|
+
filter,
|
|
26
|
+
sorting,
|
|
27
|
+
columns,
|
|
28
|
+
expand,
|
|
29
|
+
maxRecords,
|
|
30
|
+
], [schema.logicalName, search, filter, sorting, columns, expand, maxRecords]);
|
|
31
|
+
return queryKey;
|
|
32
|
+
}
|
|
33
|
+
function useClearDataExceptFirstPage(queryKey) {
|
|
34
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
35
|
+
(0, react_1.useEffect)(() => {
|
|
36
|
+
return () => {
|
|
37
|
+
// Clear all pages except the first one when the component is unmounted
|
|
38
|
+
queryClient.setQueryData(queryKey, (oldData) => {
|
|
39
|
+
if (!oldData) {
|
|
40
|
+
return oldData;
|
|
41
|
+
}
|
|
42
|
+
if (!oldData.pageParams.length || !oldData.pages.length) {
|
|
43
|
+
return oldData;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
pageParams: [oldData.pageParams[0]],
|
|
47
|
+
pages: [oldData.pages[0]],
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
}, [queryClient, queryKey]);
|
|
52
|
+
}
|
|
53
|
+
function useRetriveRecords(queryKey, { columns, expand, filter, maxRecords, schema, search, sorting, }) {
|
|
54
|
+
const dataService = (0, transport_1.useDataService)();
|
|
55
|
+
const { data, isFetching, hasNextPage, fetchNextPage, isFetchingNextPage } = (0, react_query_1.useInfiniteQuery)({
|
|
56
|
+
queryKey: queryKey,
|
|
57
|
+
queryFn: (queryContext) => __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
var _a;
|
|
59
|
+
const params = (_a = queryContext.pageParam) !== null && _a !== void 0 ? _a : {
|
|
60
|
+
pageIndex: 0,
|
|
61
|
+
};
|
|
62
|
+
const skip = params.pageIndex * ROWS_PER_PAGE;
|
|
63
|
+
const limit = Math.min(ROWS_PER_PAGE, Math.max(0, maxRecords - skip));
|
|
64
|
+
if (limit <= 0) {
|
|
65
|
+
return {
|
|
66
|
+
params: params,
|
|
67
|
+
data: {
|
|
68
|
+
logicalName: schema.logicalName,
|
|
69
|
+
count: 0,
|
|
70
|
+
records: [],
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const result = yield dataService.retriveRecords({
|
|
75
|
+
logicalName: schema.logicalName,
|
|
76
|
+
search,
|
|
77
|
+
columns: columns,
|
|
78
|
+
expand,
|
|
79
|
+
filter,
|
|
80
|
+
skip,
|
|
81
|
+
limit,
|
|
82
|
+
sort: sorting,
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
params: params,
|
|
86
|
+
data: result,
|
|
87
|
+
};
|
|
88
|
+
}),
|
|
89
|
+
getNextPageParam: (lastPage) => {
|
|
90
|
+
if (lastPage.data.count <
|
|
91
|
+
ROWS_PER_PAGE * (lastPage.params.pageIndex + 1)) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
pageIndex: lastPage.params.pageIndex + 1,
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
initialPageParam: {
|
|
99
|
+
pageIndex: 0,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
const finalData = (0, react_1.useMemo)(() => {
|
|
103
|
+
var _a, _b, _c, _d;
|
|
104
|
+
if (!(data === null || data === void 0 ? void 0 : data.pages.length)) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
logicalName: (_a = data === null || data === void 0 ? void 0 : data.pages) === null || _a === void 0 ? void 0 : _a[0].data.logicalName,
|
|
109
|
+
count: (_c = (_b = data === null || data === void 0 ? void 0 : data.pages) === null || _b === void 0 ? void 0 : _b[0].data.count) !== null && _c !== void 0 ? _c : 0,
|
|
110
|
+
records: (_d = data === null || data === void 0 ? void 0 : data.pages.map((x) => x.data.records).flat()) !== null && _d !== void 0 ? _d : [],
|
|
111
|
+
};
|
|
112
|
+
}, [data]);
|
|
113
|
+
return {
|
|
114
|
+
data: finalData,
|
|
115
|
+
isFetching,
|
|
116
|
+
hasNextPage,
|
|
117
|
+
fetchNextPage,
|
|
118
|
+
isFetchingNextPage,
|
|
119
|
+
};
|
|
120
|
+
}
|
package/utils/color.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isColorDark(color: string): boolean;
|
package/utils/color.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isColorDark = isColorDark;
|
|
4
|
+
function isColorDark(color) {
|
|
5
|
+
if (color.startsWith('#')) {
|
|
6
|
+
color = color.substring(1);
|
|
7
|
+
}
|
|
8
|
+
const rgb = parseInt(color, 16);
|
|
9
|
+
const r = (rgb >> 16) & 0xff;
|
|
10
|
+
const g = (rgb >> 8) & 0xff;
|
|
11
|
+
const b = (rgb >> 0) & 0xff;
|
|
12
|
+
const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
13
|
+
return luma < 128;
|
|
14
|
+
}
|
|
@@ -7,9 +7,11 @@ export declare function getAttributeFormattedValue<A extends Attribute = Attribu
|
|
|
7
7
|
maxCount?: number;
|
|
8
8
|
strings?: AttributeFormattedValueStringsSet;
|
|
9
9
|
dateFormat?: string;
|
|
10
|
+
timeFormat?: string;
|
|
10
11
|
locale?: string;
|
|
11
12
|
currency?: string;
|
|
12
13
|
currencySign?: 'accounting' | 'standard';
|
|
13
14
|
currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code';
|
|
14
|
-
|
|
15
|
+
timezone?: string;
|
|
16
|
+
}): string | null;
|
|
15
17
|
export {};
|