procode-lowcode-core 1.0.13 → 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.
@@ -17,10 +17,17 @@ type ValidationProps = {
17
17
  screenDataField: string;
18
18
  executeMode: ExecuteMode;
19
19
  };
20
+ export type EffectiveStyle = {
21
+ selector: string;
22
+ target: string;
23
+ important?: boolean;
24
+ };
20
25
  export type Style = {
21
26
  id?: string;
22
27
  className?: string;
23
28
  inline?: React.CSSProperties;
29
+ important?: boolean;
30
+ effectiveStyles?: EffectiveStyle[];
24
31
  };
25
32
  export interface BaseScreenElement {
26
33
  id: number | string;
@@ -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];
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "procode-lowcode-core",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "ProCode Core Library - React framework for low-code applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -32,6 +32,7 @@ const CellRenderer = ({
32
32
  <div
33
33
  id={widgetStyle?.id || ""}
34
34
  className={widgetStyle?.className || ""}
35
+ data-prc-col-important={widgetStyle?.important ? widgetStyle?.className || undefined : undefined}
35
36
  style={styles}
36
37
  >
37
38
  {children.map((element) => (
@@ -16,6 +16,7 @@ export default function Container({
16
16
  <div
17
17
  id={widgetStyle?.id ?? ""}
18
18
  className={`${widgetStyle?.className ?? ""}`}
19
+ data-prc-col-important={widgetStyle?.important ? widgetStyle?.className || undefined : undefined}
19
20
  style={{ ...(widgetStyle?.inline ?? {}) }}
20
21
  >
21
22
  {children.map((element) => (
@@ -19,6 +19,7 @@ const Drawer = ({
19
19
  <div
20
20
  id={widgetStyle?.id ?? ""}
21
21
  className={`prc-drawer ${widgetStyle?.className ?? ""}`}
22
+ data-prc-col-important={widgetStyle?.important ? widgetStyle?.className || undefined : undefined}
22
23
  style={{ ...(widgetStyle?.inline ?? {}) }}
23
24
  >
24
25
  {children?.map((element: ScreenElement) => (
@@ -7,6 +7,7 @@ const DrawerRenderer = (props: DrawerElement) => {
7
7
  id={props.overlay.widgetStyle?.id ?? ""}
8
8
  style={{ ...(props.overlay.widgetStyle?.inline ?? {}) }}
9
9
  className={`prc-drawer-shield ${props.overlay.widgetStyle?.className ?? ""}`}
10
+ data-prc-col-important={props.overlay.widgetStyle?.important ? props.overlay.widgetStyle?.className || undefined : undefined}
10
11
  >
11
12
  <Drawer {...props} />
12
13
  </div>
@@ -23,6 +23,7 @@ const FormRenderer = ({
23
23
  e.preventDefault();
24
24
  }}
25
25
  className={widgetStyle?.className || ""}
26
+ data-prc-col-important={widgetStyle?.important ? widgetStyle?.className || undefined : undefined}
26
27
  id={widgetStyle?.id || ""}
27
28
  style={{ ...(widgetStyle?.inline || {}) }}
28
29
  >
@@ -18,6 +18,7 @@ const LayoutRenderer = ({
18
18
  <div
19
19
  id={widgetStyle?.id || ""}
20
20
  className={`${widgetStyle?.className || ""}`}
21
+ data-prc-col-important={widgetStyle?.important ? widgetStyle?.className || undefined : undefined}
21
22
  style={{
22
23
  ...(widgetStyle?.inline || {}),
23
24
  display: "grid",
@@ -18,6 +18,7 @@ const GenericLayoutRenderer = ({
18
18
  <div
19
19
  id={widgetStyle?.id || ""}
20
20
  className={`${widgetStyle?.className || ""}`}
21
+ data-prc-col-important={widgetStyle?.important ? widgetStyle?.className || undefined : undefined}
21
22
  style={{
22
23
  ...(widgetStyle?.inline || {}),
23
24
  display: "grid",
@@ -39,10 +39,23 @@ const Widget: React.FC<WidgetInjectorProps> = ({
39
39
  .getCustomWidgetProvider()
40
40
  ?.getWidgets();
41
41
 
42
- const WidgetComponent =
43
- customWidgets?.get?.(widgetProps.widgetType) ??
44
- templateWidgets?.get?.(widgetProps.widgetType) ??
45
- standardWidgets?.get?.(widgetProps.widgetType);
42
+ let WidgetComponent: React.FC<any> | undefined;
43
+
44
+ const targetFactory = widgetProps.targetWidgetFactory;
45
+ if (targetFactory === "CUSTOM") {
46
+ WidgetComponent = customWidgets?.get?.(widgetProps.widgetType);
47
+ } else if (targetFactory === "TEMPLATE") {
48
+ WidgetComponent = templateWidgets?.get?.(widgetProps.widgetType);
49
+ } else if (targetFactory === "DEFAULT") {
50
+ WidgetComponent = standardWidgets?.get?.(widgetProps.widgetType);
51
+ }
52
+
53
+ if (!WidgetComponent) {
54
+ WidgetComponent =
55
+ customWidgets?.get?.(widgetProps.widgetType) ??
56
+ templateWidgets?.get?.(widgetProps.widgetType) ??
57
+ standardWidgets?.get?.(widgetProps.widgetType);
58
+ }
46
59
 
47
60
  if (!WidgetComponent) {
48
61
  return (
@@ -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(),
@@ -48,12 +53,21 @@ export const useWidgetProps = (
48
53
  validations: getValidationProperty(),
49
54
  eventService: eventService,
50
55
  viewModel: viewModel,
51
- "sssss":"ss",
52
56
  ...events,
53
57
  dynamicEvents: events,
54
58
  });
55
59
  };
56
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
+
57
71
  const getEvents = () => {
58
72
  if (!schemaElementProps?.events) return {};
59
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
 
@@ -17,10 +17,18 @@ type ValidationProps = {
17
17
  executeMode: ExecuteMode;
18
18
  };
19
19
 
20
+ export type EffectiveStyle = {
21
+ selector: string;
22
+ target: string;
23
+ important?: boolean;
24
+ };
25
+
20
26
  export type Style = {
21
27
  id?: string;
22
28
  className?: string;
23
29
  inline?: React.CSSProperties;
30
+ important?: boolean;
31
+ effectiveStyles?: EffectiveStyle[];
24
32
  };
25
33
 
26
34
  export interface BaseScreenElement {
@@ -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';