impaktapps-ui-builder 0.0.304 → 0.0.306

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impaktapps-ui-builder",
3
- "version": "0.0.304",
3
+ "version": "0.0.306",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "tsc && vite build",
@@ -3,45 +3,38 @@ import _ from "lodash";
3
3
  import { createLayoutFormat } from "./buildConfig";
4
4
 
5
5
 
6
- const TextField = {
7
- type: "Control",
8
- scope: "#/properties/text",
9
-
10
- options: {
11
- widget: "InputField",
12
- },
13
- config: {
14
- layout: {
15
- xs: 11,
16
- sm: 11,
17
- md: 5.5,
18
- lg: 5.5,
19
- },
20
- main: {
21
- label:"Aadhaar No.",
22
- max:2000,
23
- step:200,
24
- autoFormat:true,
25
- // patternRegex:"^[A-Z]{5}[0-9]{4}[A-Z]$",
26
- patternRegex:"^[0-9\\s]*$",
27
- // valueLength:14,
28
- spaceIndex:4,
29
- autoMaskLength:4,
30
- autoMask:true,
31
- defaultStyle:true
32
- },
33
- style:{}
6
+ const TextField = {
7
+ "type": "Control",
8
+ "scope": "#/properties/AAdhar",
9
+ "layout": 12,
10
+ "options": {
11
+ "widget": "InputField"
34
12
  },
13
+ config:{
14
+ main:{
15
+ label:"Adhaar Card",
16
+ max:2000,
17
+ step:200,
18
+ placeholder:"XXXX XXXX XXXX",
19
+ autoFormat:true,
20
+ patternRegex:"^[0-9\\s]*$",
21
+ valueLength:14,
22
+ spaceIndex:4,
23
+ autoMaskLength:4,
24
+ autoMask:true,
25
+ defaultStyle:true
26
+ }
35
27
  }
28
+ };
36
29
 
37
- export const buildAdhaarField = (config:any,componentScope:string) =>{
30
+ export const buildAdhaarField = (config: any, componentScope: string) => {
38
31
  const inputField: any = _.cloneDeep(TextField);
39
32
  inputField.config.main.label = config.label;
40
33
  if (config.style) {
41
- inputField.config.style = JSON.parse(config.style)
34
+ inputField.config.style = JSON.parse(config.style)
42
35
  }
43
36
  if (config.layout) {
44
- inputField.config.layout = createLayoutFormat(config.layout)
37
+ inputField.config.layout = createLayoutFormat(config.layout)
45
38
  }
46
39
  inputField.config.main.errorMessage = `${config.name} is empty or invalid`;
47
40
  inputField.scope = componentScope;
@@ -49,45 +42,35 @@ export const buildAdhaarField = (config:any,componentScope:string) =>{
49
42
  }
50
43
 
51
44
 
52
- const PanField = {
53
- type: "Control",
54
- scope: "#/properties/text",
55
-
56
- options: {
57
- widget: "InputField",
58
- },
59
- config: {
60
- layout: {
61
- xs: 11,
62
- sm: 11,
63
- md: 5.5,
64
- lg: 5.5,
65
- },
66
- main: {
67
- label:"Aadhaar No.",
68
- max:2000,
69
- step:200,
70
- // autoFormat:true,
71
- patternRegex:"^[A-Z]{5}[0-9]{4}[A-Z]$",
72
- // patternRegex:"^[0-9\\s]*$",
73
- // valueLength:14,
74
- spaceIndex:4,
75
- autoMaskLength:4,
76
- // autoMask:true,
77
- defaultStyle:true
78
- },
79
- style:{}
45
+ const PanField = {
46
+ "type": "Control",
47
+ "scope": "#/properties/pan",
48
+ "layout": 12,
49
+ "options": {
50
+ "widget": "InputField"
80
51
  },
52
+ config:{
53
+ main:{
54
+ label:"Pan Card",
55
+ placeholder:"Enter Pan card",
56
+ patternRegex:"^[A-Z]{0,5}\\d{0,4}[A-Z]?$",
57
+ valueLength:10,
58
+ spaceIndex:4,
59
+ autoMaskLength:5,
60
+ autoMask:true,
61
+ defaultStyle:true
62
+ }
81
63
  }
64
+ };
82
65
 
83
- export const buildPanField = (config:any,componentScope:string) =>{
66
+ export const buildPanField = (config: any, componentScope: string) => {
84
67
  const inputField: any = _.cloneDeep(PanField);
85
68
  inputField.config.main.label = config.label;
86
69
  if (config.style) {
87
- inputField.config.style = JSON.parse(config.style)
70
+ inputField.config.style = JSON.parse(config.style)
88
71
  }
89
72
  if (config.layout) {
90
- inputField.config.layout = createLayoutFormat(config.layout)
73
+ inputField.config.layout = createLayoutFormat(config.layout)
91
74
  }
92
75
  inputField.config.main.errorMessage = `${config.name} is empty or invalid`;
93
76
  inputField.scope = componentScope;
@@ -3,32 +3,32 @@ import { handlersProps } from "./interface";
3
3
 
4
4
 
5
5
  export const executeEvents = async (
6
- params:handlersProps
6
+ params: handlersProps
7
7
  ) => {
8
8
  let nextEvent = [];
9
9
  let finalResponse = null;
10
- try{
10
+ try {
11
11
  if (!shouldEventExecute(params)) {
12
12
  return { response: undefined, events: undefined };
13
13
  }
14
- const response = await executeEventsHandler(params)
14
+ const response = await executeEventsHandler(params)
15
15
  finalResponse = response;
16
16
  const SuccessEvent = params.config?.events.filter(e => e.eventType === "Success");
17
17
  nextEvent = SuccessEvent;
18
18
  } catch (err) {
19
19
  const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail")
20
20
  const setEvent = FailEvent?.length > 0 ? FailEvent : []
21
- nextEvent = setEvent;
21
+ nextEvent = setEvent;
22
22
  }
23
23
  if (nextEvent?.length > 0) {
24
24
  for (const actionConfig of nextEvent) {
25
- await executeEvents({...params,config:actionConfig,parentEventOutput:finalResponse})
25
+ await executeEvents({ ...params, config: actionConfig, parentEventOutput: finalResponse })
26
26
  }
27
27
  }
28
28
  return finalResponse;
29
29
  }
30
30
 
31
- async function executeEventsHandler(params:handlersProps) {
31
+ async function executeEventsHandler(params: handlersProps) {
32
32
  if (params.config.Handler === "api") {
33
33
  return await executeApiEventHandler(params)
34
34
  }
@@ -42,26 +42,27 @@ async function executeEventsHandler(params:handlersProps) {
42
42
  return await executeRefreshHandler(params)
43
43
  }
44
44
  else if (params.config.Handler === "mergeFormdata") {
45
- return await mergeFormdata(
46
- params.parentEventOutput, params.componentName, params.config, params.store)
45
+ const result = mergeFormdata(
46
+ params.parentEventOutput, params.componentName, params.config, params.store)
47
+ return result;
47
48
  }
48
49
  }
49
- export async function executeRefreshHandler(params:handlersProps) {
50
+ export async function executeRefreshHandler(params: handlersProps) {
50
51
  const compToRefresh: string[] = getRefreshElements(params.config, params.eventGroups)
51
52
  for (const componentName of compToRefresh) {
52
53
  for (const compEventConfig of params.eventGroups.onLoad[componentName]) {
53
- await executeEvents({...params,config:compEventConfig,componentName});
54
+ await executeEvents({ ...params, config: compEventConfig, componentName });
54
55
  }
55
56
  }
56
57
  }
57
- async function executeApiEventHandler(params:handlersProps) {
58
+ async function executeApiEventHandler(params: handlersProps) {
58
59
  const initialBody = { ...params.userValue?.payload };
59
60
  const initialHeaders = {
60
61
  "X-Requested-With": "XMLHttpRequest",
61
62
  "Access-Control-Allow-Origin": "*"
62
63
  };
63
64
  const { body, headers } = await buildApiPayload(params.config, initialBody, initialHeaders, params.store, params.dynamicData, params.userValue, params.service)
64
-
65
+
65
66
  const response = await params.service[params.config.method](
66
67
  params.config.path,
67
68
  body,
@@ -70,7 +71,7 @@ async function executeApiEventHandler(params:handlersProps) {
70
71
  return response;
71
72
  }
72
73
 
73
- async function executeInBuiltFunctionHandler(params:handlersProps) {
74
+ async function executeInBuiltFunctionHandler(params: handlersProps) {
74
75
  let parameter = {};
75
76
  if (params.config.funcParametersCode) {
76
77
  const makeFunc = eval(params.config.funcParametersCode)
@@ -79,13 +80,13 @@ async function executeInBuiltFunctionHandler(params:handlersProps) {
79
80
  params.serviceHolder[params.config.inBuiltFunctionType](parameter)
80
81
  }
81
82
 
82
- async function executeCustomHandler(params:handlersProps) {
83
+ async function executeCustomHandler(params: handlersProps) {
83
84
  const makeFunc = eval(params.config.eventCode)
84
85
  const response = await makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName);
85
86
  return response;
86
87
  }
87
88
 
88
- async function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any) {
89
+ function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any) {
89
90
  if (eventConfig.type === "Select" && !(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)) {
90
91
  store.setSchema((pre) => {
91
92
  return {
@@ -98,15 +99,15 @@ async function mergeFormdata(handlerResponse: any, componentName: string, eventC
98
99
  }
99
100
  })
100
101
  }
101
- else if(eventConfig.type === "MultipleSelect" && !(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)){
102
+ else if (eventConfig.type === "MultipleSelect" && !(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)) {
102
103
  store.setSchema((pre) => {
103
104
  return {
104
105
  ...pre, properties: {
105
106
  ...pre.properties, [componentName]: {
106
107
  ...pre.properties?.[componentName],
107
- type:"array",
108
- items:{
109
- oneOf: handlerResponse.data
108
+ type: "array",
109
+ items: {
110
+ oneOf: handlerResponse.data
110
111
  }
111
112
  }
112
113
  }
@@ -114,11 +115,13 @@ async function mergeFormdata(handlerResponse: any, componentName: string, eventC
114
115
  })
115
116
  }
116
117
  else if (eventConfig.type === "page") {
117
- store.setFormdata((pre: any) => { return { ...pre, ...handlerResponse?.data } })
118
+ if (!(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)) {
119
+ store.setFormdata((pre: any) => { return { ...pre, ...handlerResponse?.data } })
120
+ }
118
121
  }
119
122
  else {
120
123
  if (handlerResponse) {
121
- store.setFormdata((pre) => { return { ...pre, [componentName]:eventConfig.lazyLoading?handlerResponse.data.data: handlerResponse.data } });
124
+ store.setFormdata((pre) => { return { ...pre, [componentName]: eventConfig.lazyLoading ? handlerResponse.data.data : handlerResponse.data } });
122
125
  }
123
126
  }
124
127
  }
@@ -126,7 +129,7 @@ async function mergeFormdata(handlerResponse: any, componentName: string, eventC
126
129
  const buildBodyFormat = (body: any[], formData: any, userValue: any) => {
127
130
  const finalBody = { ...userValue?.payload };
128
131
  body.map((elem) => {
129
- if(typeof elem?.value !== "string") {
132
+ if (typeof elem?.value !== "string") {
130
133
  finalBody[elem.key] = elem.value;
131
134
  } else {
132
135
  if (elem?.value?.startsWith("$userValue")) {
@@ -155,10 +158,10 @@ const buildHeadersFormat = (headers: any[]) => {
155
158
  return headerObj;
156
159
  }
157
160
 
158
- async function shouldEventExecute(params:handlersProps) {
161
+ async function shouldEventExecute(params: handlersProps) {
159
162
  const startEvent = params.config?.events?.filter(e => e.eventType === "onStart");
160
163
  if (startEvent?.length > 0) {
161
- const response = await executeEventsHandler({...params,config:startEvent[0]});
164
+ const response = await executeEventsHandler({ ...params, config: startEvent[0] });
162
165
  return response;
163
166
  }
164
167
  }