procode-lowcode-core 1.0.14 → 1.0.15
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/dist/index.esm.js +45 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +57 -24
- package/dist/index.js.map +1 -1
- package/dist/types/Utils/resolveBoundValue.d.ts +10 -0
- package/dist/types/index.d.ts +3 -0
- package/package.json +1 -1
- package/src/Renderer/WidgetRenderer/useWidgetProps.ts +15 -0
- package/src/Services/CentralService.ts +2 -13
- package/src/Utils/resolveBoundValue.ts +49 -0
- package/src/index.ts +3 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ValueReplacePolicy } from "../Action/Types";
|
|
2
|
+
import { ViewModel } from "../DataModel/ViewModel";
|
|
3
|
+
export type BoundOperand<T> = {
|
|
4
|
+
value: T | string;
|
|
5
|
+
valueReplacePolicy: ValueReplacePolicy;
|
|
6
|
+
};
|
|
7
|
+
export type BoundValue<T> = T | BoundOperand<T> | undefined | null;
|
|
8
|
+
export declare const resolveBoundValue: <T>(bound: BoundValue<T>, viewModel: ViewModel) => T | null | undefined;
|
|
9
|
+
export declare const BOUND_PROP_NAMES: readonly ["min", "max", "minDate", "maxDate", "minLength", "maxLength", "minResizeHeight", "maxResizeHeight", "minResizeWidth", "maxResizeWidth", "step", "placeHolder", "disabled"];
|
|
10
|
+
export type BoundPropName = (typeof BOUND_PROP_NAMES)[number];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,5 +8,8 @@ export type { IStorage } from './StorageManager/IStorage';
|
|
|
8
8
|
export type { default as IValidationFactory } from './Validation/IValidationFactory';
|
|
9
9
|
export type { ISchemaReaderProvider } from './UIElement/ISchemaReaderProvider';
|
|
10
10
|
export { resolveAppPath } from './Utils/resolveAppPath';
|
|
11
|
+
export { resolveBoundValue, BOUND_PROP_NAMES } from './Utils/resolveBoundValue';
|
|
12
|
+
export type { BoundValue, BoundOperand, BoundPropName } from './Utils/resolveBoundValue';
|
|
13
|
+
export { ValueReplacePolicy } from './Action/Types';
|
|
11
14
|
export declare const coreStyles = "./Assets/styles/index.scss";
|
|
12
15
|
export declare const getCoreStylesPath: () => string;
|
package/package.json
CHANGED
|
@@ -2,6 +2,10 @@ import { useState, useEffect } from "react";
|
|
|
2
2
|
import { NavigateFunction } from "react-router-dom";
|
|
3
3
|
import ActionInvoker from "../../Action/ActionInvoker";
|
|
4
4
|
import { getValueFromNestedObject } from "../../Utils/getValueFromNestedObject";
|
|
5
|
+
import {
|
|
6
|
+
BOUND_PROP_NAMES,
|
|
7
|
+
resolveBoundValue,
|
|
8
|
+
} from "../../Utils/resolveBoundValue";
|
|
5
9
|
import { ViewModel } from "../../DataModel/ViewModel";
|
|
6
10
|
import { EventService } from "../../Services/EventService";
|
|
7
11
|
import ValidationInvoker from "../../Validation/ValidationInvoker";
|
|
@@ -41,6 +45,7 @@ export const useWidgetProps = (
|
|
|
41
45
|
const events = getEvents();
|
|
42
46
|
setWidgetProps({
|
|
43
47
|
...schemaElementProps,
|
|
48
|
+
...getResolvedBoundProps(),
|
|
44
49
|
id: schemaElementProps?.id,
|
|
45
50
|
value: getScreenDataFieldValue(),
|
|
46
51
|
listData: getSupportiveDataFieldValue(),
|
|
@@ -53,6 +58,16 @@ export const useWidgetProps = (
|
|
|
53
58
|
});
|
|
54
59
|
};
|
|
55
60
|
|
|
61
|
+
const getResolvedBoundProps = () => {
|
|
62
|
+
const resolved: Record<string, unknown> = {};
|
|
63
|
+
BOUND_PROP_NAMES.forEach((name) => {
|
|
64
|
+
if (name in schemaElementProps) {
|
|
65
|
+
resolved[name] = resolveBoundValue(schemaElementProps[name], viewModel);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return resolved;
|
|
69
|
+
};
|
|
70
|
+
|
|
56
71
|
const getEvents = () => {
|
|
57
72
|
if (!schemaElementProps?.events) return {};
|
|
58
73
|
let onActions: Record<string, any> = {};
|
|
@@ -43,19 +43,7 @@ export class CentralService {
|
|
|
43
43
|
) => {
|
|
44
44
|
const statusRelatedConfig = (responseConfig ?? {})[response?.status];
|
|
45
45
|
let errorMessage = "";
|
|
46
|
-
|
|
47
|
-
if (statusRelatedConfig?.alertType === AlertType.FIELDVALIDATION) {
|
|
48
|
-
errorMessage = response?.data?.message;
|
|
49
|
-
if (statusRelatedConfig?.enableMessage) {
|
|
50
|
-
errorMessage =
|
|
51
|
-
statusRelatedConfig?.message ||
|
|
52
|
-
errorMessage ||
|
|
53
|
-
ErrorMessageProvider.get(
|
|
54
|
-
response.config.method as RequestType,
|
|
55
|
-
response?.status,
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
} else if (statusRelatedConfig?.enableMessage) {
|
|
46
|
+
if (statusRelatedConfig?.enableMessage) {
|
|
59
47
|
errorMessage =
|
|
60
48
|
statusRelatedConfig?.message ||
|
|
61
49
|
response?.data?.message ||
|
|
@@ -64,6 +52,7 @@ export class CentralService {
|
|
|
64
52
|
response?.status,
|
|
65
53
|
);
|
|
66
54
|
}
|
|
55
|
+
|
|
67
56
|
return errorMessage;
|
|
68
57
|
};
|
|
69
58
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ValueReplacePolicy } from "../Action/Types";
|
|
2
|
+
import { ViewModel } from "../DataModel/ViewModel";
|
|
3
|
+
import { getValueFromNestedObject } from "./getValueFromNestedObject";
|
|
4
|
+
|
|
5
|
+
export type BoundOperand<T> = {
|
|
6
|
+
value: T | string;
|
|
7
|
+
valueReplacePolicy: ValueReplacePolicy;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type BoundValue<T> = T | BoundOperand<T> | undefined | null;
|
|
11
|
+
|
|
12
|
+
const isBoundOperand = <T>(input: unknown): input is BoundOperand<T> =>
|
|
13
|
+
typeof input === "object" &&
|
|
14
|
+
input !== null &&
|
|
15
|
+
"valueReplacePolicy" in (input as Record<string, unknown>);
|
|
16
|
+
|
|
17
|
+
export const resolveBoundValue = <T>(
|
|
18
|
+
bound: BoundValue<T>,
|
|
19
|
+
viewModel: ViewModel
|
|
20
|
+
): T | undefined | null => {
|
|
21
|
+
if (!isBoundOperand<T>(bound)) return bound as T | undefined | null;
|
|
22
|
+
|
|
23
|
+
switch (bound.valueReplacePolicy) {
|
|
24
|
+
case ValueReplacePolicy.SELF:
|
|
25
|
+
return bound.value as T;
|
|
26
|
+
case ValueReplacePolicy.STATE:
|
|
27
|
+
return getValueFromNestedObject(bound.value as string, viewModel);
|
|
28
|
+
default:
|
|
29
|
+
return bound.value as T;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const BOUND_PROP_NAMES = [
|
|
34
|
+
"min",
|
|
35
|
+
"max",
|
|
36
|
+
"minDate",
|
|
37
|
+
"maxDate",
|
|
38
|
+
"minLength",
|
|
39
|
+
"maxLength",
|
|
40
|
+
"minResizeHeight",
|
|
41
|
+
"maxResizeHeight",
|
|
42
|
+
"minResizeWidth",
|
|
43
|
+
"maxResizeWidth",
|
|
44
|
+
"step",
|
|
45
|
+
"placeHolder",
|
|
46
|
+
"disabled",
|
|
47
|
+
] as const;
|
|
48
|
+
|
|
49
|
+
export type BoundPropName = (typeof BOUND_PROP_NAMES)[number];
|
package/src/index.ts
CHANGED
|
@@ -28,6 +28,9 @@ export type { ISchemaReaderProvider } from './UIElement/ISchemaReaderProvider';
|
|
|
28
28
|
|
|
29
29
|
// Utils
|
|
30
30
|
export { resolveAppPath } from './Utils/resolveAppPath';
|
|
31
|
+
export { resolveBoundValue, BOUND_PROP_NAMES } from './Utils/resolveBoundValue';
|
|
32
|
+
export type { BoundValue, BoundOperand, BoundPropName } from './Utils/resolveBoundValue';
|
|
33
|
+
export { ValueReplacePolicy } from './Action/Types';
|
|
31
34
|
|
|
32
35
|
// Core Styles Path (for SCSS imports)
|
|
33
36
|
export const coreStyles = './Assets/styles/index.scss';
|