impaktapps-ui-builder 0.0.408 → 0.0.409-c

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.
@@ -0,0 +1 @@
1
+ export declare const buildTreeMap: (config: any, componentScope: any) => any;
@@ -1,3 +1,22 @@
1
+ export declare const getRadioInputField: (scope: String, label: String, options: string[]) => {
2
+ type: string;
3
+ scope: string;
4
+ options: {
5
+ widget: string;
6
+ };
7
+ config: {
8
+ layout: {
9
+ xs: number;
10
+ sm: number;
11
+ md: number;
12
+ lg: number;
13
+ };
14
+ main: {
15
+ label: String;
16
+ options: string[];
17
+ };
18
+ };
19
+ };
1
20
  export declare const getTextArea: (scope: string, heading: string, hideButton: boolean, layout?: any) => {
2
21
  type: string;
3
22
  scope: string;
@@ -1,9 +1,10 @@
1
1
  import { handlersProps } from "./interface";
2
- export declare const executeEvents: (params: handlersProps) => Promise<any>;
3
- export declare function executeRefreshHandler(params: handlersProps): Promise<void>;
4
- export declare function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service: any): Promise<{
2
+ export declare const executeEvents: (params: handlersProps) => any;
3
+ export declare function getRefreshElements(eventConfig: any, eventGropus: any): string[];
4
+ export declare function executeRefreshHandler(params: handlersProps): Promise<any[][]>;
5
+ export declare function executeApiRequest(params: any): any;
6
+ export declare function shouldEventExecute(params: handlersProps): any;
7
+ export declare function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service: any): {
5
8
  body: any;
6
9
  headers: any;
7
- }>;
8
- export declare function getRefreshElements(eventConfig: any, eventGropus: any): string[];
9
- export declare function asyncOperation(): Promise<unknown>;
10
+ };
@@ -1,20 +1,18 @@
1
- export declare const extractEvents: (eventConfig: any) => any;
2
1
  interface funcParamsProps {
3
2
  store: any;
4
3
  dynamicData: any;
5
- config: any;
6
- uiSchema: any;
7
- schema: any;
8
4
  service: any;
9
5
  userValue: any;
10
6
  functionsProvider?: Record<string, any>;
11
7
  }
8
+ export declare const extractEvents: (eventConfig: any) => any;
12
9
  declare const _default: (funcParams: funcParamsProps) => {
13
10
  setPage: () => Promise<void>;
14
- onClick: () => Promise<void>;
15
- onMount: () => Promise<void>;
16
- onFileDownload: () => Promise<void>;
17
- onFileUpload: () => Promise<void>;
11
+ onCellRenderer: (cellParams: any) => {};
12
+ onClick: () => void;
13
+ onMount: () => void;
14
+ onFileDownload: () => void;
15
+ onFileUpload: () => void;
18
16
  backHandler: () => void;
19
17
  onPaginationChange: (paginationValues: any) => Promise<any>;
20
18
  getSelectOptions: (param: any) => Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impaktapps-ui-builder",
3
- "version": "0.0.408",
3
+ "version": "0.0.409c",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "tsc && vite build",
@@ -0,0 +1,58 @@
1
+ import { createLayoutFormat } from "./buildConfig";
2
+ import _ from "lodash";
3
+
4
+ const TreeMap = {
5
+ "type": "Control",
6
+ "scope": "#/properties/TreeMap2",
7
+ "config": {
8
+ "main": {
9
+ "layout": "cartsian",
10
+ orientation: "vertical",
11
+ header: "Territory Hierarchy",
12
+ "linkType": "step",
13
+ graphHeight: "500px",
14
+ },
15
+ "style": {
16
+ BoxStyle: {
17
+ borderRadius: "5px",
18
+ }
19
+ }
20
+ },
21
+ "options": {
22
+ "widget": "TreeMap"
23
+ },
24
+ elements: [
25
+
26
+ ]
27
+ }
28
+
29
+
30
+ export const buildTreeMap = (config, componentScope) => {
31
+ const treMap: any = _.cloneDeep(TreeMap);
32
+ treMap.scope = componentScope;
33
+ if (config.label) {
34
+ treMap.config.main.header = config.label;
35
+ }
36
+ if (config.layout) {
37
+ treMap.config.layout = createLayoutFormat(config.layout);
38
+ }
39
+ if (config.orientation) {
40
+ treMap.config.main.orientation = config.orientation;
41
+ }
42
+ if (config.linkType) {
43
+ treMap.config.main.linkType = config.linkType;
44
+ }
45
+ if (config.graphHeight) {
46
+ treMap.config.main.graphHeight = config.graphHeight;
47
+ }
48
+ if (config.graphWidth) {
49
+ treMap.config.main.graphWidth = config.graphWidth;
50
+ }
51
+ if (config.graphZoomHeight) {
52
+ treMap.config.main.graphZoomHeight = config.graphZoomHeight;
53
+ }
54
+ if (config.graphZoomWidth) {
55
+ treMap.config.main.graphZoomWidth = config.graphZoomWidth;
56
+ }
57
+ return treMap;
58
+ }
@@ -38,6 +38,7 @@ import { buildStepper } from "./buildStepper";
38
38
  import { buildPopUp } from "./buildPop";
39
39
  import { buildDataGrid } from "./buildDataGrid";
40
40
  import { buildInputSlider } from "./buildInputSlider";
41
+ import { buildTreeMap } from "./buildTreeMap";
41
42
  export let schema = {
42
43
  type: "object",
43
44
  properties: {},
@@ -168,6 +169,8 @@ const buildUiSchema = (config: any) => {
168
169
  let elements: any = {};
169
170
  const componentScope = `#/properties/${config.name}`;
170
171
  switch (config.type) {
172
+ case "TreeMap":
173
+ elements = buildTreeMap(config,componentScope)
171
174
  case "DateTime":
172
175
  elements = buildDateTime(config, componentScope);
173
176
  break;
@@ -151,7 +151,7 @@ const getInputField = (scope: String, label: String) => {
151
151
  };
152
152
  };
153
153
 
154
- const getRadioInputField = (scope: String, label: String, options: string[]) => {
154
+ export const getRadioInputField = (scope: String, label: String, options: string[]) => {
155
155
  return {
156
156
  type: "Control",
157
157
  scope: `#/properties/${scope}`,
@@ -235,6 +235,15 @@ const GraphSection = {
235
235
  export const buildPropertiesSection = function (type: String) {
236
236
  let uiSchema = _.cloneDeep(GraphSection);
237
237
  switch (type) {
238
+
239
+ case "TreeMap":
240
+ uiSchema.elements = [
241
+ getSelectField("orientation", "orientation",[]),
242
+ getInputField("linkType", "linkType"),
243
+ getInputField("graphHeight", "Graph Height"),
244
+ getInputField("graphWidth", "Graph Width"),
245
+ getInputField("graphZoomHeight", "Zoom Height"),
246
+ ]
238
247
  case "InputSlider":
239
248
  uiSchema.elements = [
240
249
  getInputField("max", "Max Limit"),
@@ -88,7 +88,6 @@ export const PieGraph = {
88
88
  type: "PieGraph",
89
89
  bottomLabel: "Name of Employe",
90
90
  leftLabel: "Value",
91
- // tooltipDataKey: ["HDFC", "SBI", "Kotak","Sbi"],
92
91
  axisLeft: true,
93
92
  axisBottom: true,
94
93
  legendAvailable: true,
@@ -45,6 +45,7 @@ export const ComponentSchema: any = {
45
45
  { title: "Date Column", const: "date" },
46
46
  { title: "DateTime Column", const: "dateTime" },
47
47
  { title: "Amount Column", const: "amount" },
48
+ { title: "TreeMap", const: "TreeMap" },
48
49
  ]
49
50
  },
50
51
  orientation:{
@@ -44,7 +44,7 @@ export const EventSchema = {
44
44
  { title: "Mount Event", const: "onMount" },
45
45
  { title: "Success", const: "Success" },
46
46
  { title: "onStart", const: "onStart" },
47
-
47
+ { title: "Cell Renderer", const: "onCellRenderer" },
48
48
  { title: "File Upload Event", const: "onUpload" },
49
49
  { title: "Back Event", const: "onBack" },
50
50
  { title: "Next Event", const: "onNext" },
@@ -37,6 +37,7 @@ const sectionLabels = {
37
37
  Stepper: ["Core", "Components","Properties","Event", "style"],
38
38
  DataGrid: ["Core", "Components","Properties","Event", "style"],
39
39
  InputSlider:["Core","Properties","style", "Event","Validation"],
40
+ TreeMap:["Core", "Components","Properties","style", "Event"],
40
41
  }
41
42
 
42
43
 
@@ -3,7 +3,7 @@ import { EventUiSchema } from "../elements/UiSchema/event/uiSchema";
3
3
  import Component from "./component";
4
4
  import { okHandler, saveFormdataInLocalStorage, saveHandler } from "./utils";
5
5
  import { APISection } from "../build/uischema/apiSection";
6
- import { getSelectField, getTextArea } from "../build/uischema/buildPropertiesSection";
6
+ import { getRadioInputField, getSelectField, getTextArea } from "../build/uischema/buildPropertiesSection";
7
7
  import { refreshSectionUiSchema } from "../build/uischema/refresh";
8
8
  import _ from "lodash";
9
9
 
@@ -27,7 +27,8 @@ export default (
27
27
  const schema: any = _.cloneDeep(EventSchema)
28
28
  if (handlerType) {
29
29
  if (handlerType === "custom") {
30
- uiSchema.elements[1].elements[0].elements[2] = getTextArea("eventCode", "Write Custom Code", false)
30
+ uiSchema.elements[1].elements[0].elements[2] = getRadioInputField("isSync","Run in Sync",["Yes","No"])
31
+ uiSchema.elements[1].elements[0].elements[3] = getTextArea("eventCode", "Write Custom Code", false)
31
32
  schema.required = ["eventType", "Handler", "eventCode"]
32
33
 
33
34
  } else if (handlerType === "api") {
@@ -29,4 +29,5 @@ export const doDownload = (response: any, service) => {
29
29
  document.body.appendChild(link);
30
30
  link.click();
31
31
  link.parentNode.removeChild(link);
32
- };
32
+ };
33
+
@@ -1,87 +1,126 @@
1
- import _, { cloneDeep } from "lodash";
1
+ import _ from "lodash";
2
2
  import { handlersProps } from "./interface";
3
3
 
4
-
5
- export const executeEvents = async (
6
- params: handlersProps
7
- ) => {
4
+ export const executeEvents = (params: handlersProps) => {
8
5
  let nextEvent = [];
9
6
  let finalResponse = null;
7
+
8
+ if (params.config.isSync !== "Yes") {
9
+ return shouldEventExecute(params)
10
+ .then((shouldExecute) => {
11
+ if (!shouldExecute) {
12
+ return { response: undefined, events: undefined };
13
+ }
14
+ return executeEventsHandler(params);
15
+ })
16
+ .then((response) => {
17
+ finalResponse = response;
18
+ const SuccessEvent = params.config?.events.filter(e => e.eventType === "Success");
19
+ nextEvent = SuccessEvent;
20
+ })
21
+ .catch((err) => {
22
+ const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail");
23
+ const setEvent = FailEvent?.length > 0 ? FailEvent : [];
24
+ nextEvent = setEvent;
25
+ })
26
+ .then(() => {
27
+ if (nextEvent?.length > 0) {
28
+ return nextEvent.reduce((chain, actionConfig) => {
29
+ return chain.then(() => executeEvents({ ...params, config: actionConfig, parentEventOutput: finalResponse }));
30
+ }, Promise.resolve());
31
+ }
32
+ })
33
+ .then(() => finalResponse)
34
+ }
35
+ const shouldExecute = shouldEventExecute(params);
36
+ if (!shouldExecute) {
37
+ return { response: undefined, events: undefined };
38
+ }
10
39
  try {
11
- const shouldExecute = await shouldEventExecute(params)
12
- if (!shouldExecute) {
13
- return { response: undefined, events: undefined };
14
- }
15
- const response = await executeEventsHandler(params)
16
- finalResponse = response;
40
+ const eventsResponse = executeEventsHandler(params);
41
+ finalResponse = eventsResponse;
17
42
  const SuccessEvent = params.config?.events.filter(e => e.eventType === "Success");
18
43
  nextEvent = SuccessEvent;
19
- } catch (err) {
20
- const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail")
21
- const setEvent = FailEvent?.length > 0 ? FailEvent : []
44
+ } catch {
45
+ const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail");
46
+ const setEvent = FailEvent?.length > 0 ? FailEvent : [];
22
47
  nextEvent = setEvent;
23
48
  }
24
49
  if (nextEvent?.length > 0) {
25
50
  for (const actionConfig of nextEvent) {
26
- await executeEvents({ ...params, config: actionConfig, parentEventOutput: finalResponse })
51
+ executeEvents({ ...params, config: actionConfig, parentEventOutput: finalResponse })
27
52
  }
28
53
  }
29
54
  return finalResponse;
30
55
  }
31
-
32
- async function executeEventsHandler(params: handlersProps) {
56
+ function executeEventsHandler(params: handlersProps) {
33
57
  if (params.config.Handler === "api") {
34
- return await executeApiEventHandler(params)
35
- }
36
- else if (params.config.Handler === "inBuiltFunction") {
37
- return await executeInBuiltFunctionHandler(params)
38
- }
39
- else if (params.config.Handler === "custom") {
40
- return await executeCustomHandler(params)
41
- }
42
- else if (params.config.Handler === "refresh") {
43
- return await executeRefreshHandler(params)
44
- }
45
- else if (params.config.Handler === "mergeFormdata") {
46
- const result = await mergeFormdata(
47
- params.parentEventOutput, params.componentName, params.config, params.store, params.service)
48
- return result;
49
- }
50
- else if (params.config.Handler === "onBackHandler") {
51
- return params.store.functionParameters?.handleBack()
52
- }
53
- else if (params.config.Handler === "onNextHandler") {
54
- return params.store.functionParameters?.handleNext()
55
- }
56
- else if (params.config.Handler === "onResetHandler") {
57
- return params.store.functionParameters?.handleReset()
58
+ return executeApiRequest(params);
59
+ } else if (params.config.Handler === "inBuiltFunction") {
60
+ return executeInBuiltFunctionHandler(params);
61
+ } else if (params.config.Handler === "custom") {
62
+ return executeCustomHandler(params);
63
+ } else if (params.config.Handler === "refresh") {
64
+ return executeRefreshHandler(params);
65
+ } else if (params.config.Handler === "mergeFormdata") {
66
+ return mergeFormdata(
67
+ params.parentEventOutput,
68
+ params.componentName,
69
+ params.config,
70
+ params.store,
71
+ params.service
72
+ );
73
+ } else if (params.config.Handler === "onBackHandler") {
74
+ return params.store.functionParameters?.handleBack();
75
+ } else if (params.config.Handler === "onNextHandler") {
76
+ return params.store.functionParameters?.handleNext();
77
+ } else if (params.config.Handler === "onResetHandler") {
78
+ return params.store.functionParameters?.handleReset();
58
79
  }
59
80
  }
60
- export async function executeRefreshHandler(params: handlersProps) {
61
- const compToRefresh: string[] = getRefreshElements(params.config, params.eventGroups)
62
- for (const componentName of compToRefresh) {
63
- for (const compEventConfig of params.eventGroups.onLoad[componentName]) {
64
- await executeEvents({ ...params, config: compEventConfig, componentName });
81
+
82
+ export function getRefreshElements(eventConfig: any, eventGropus: any) {
83
+ let result: string[] = [];
84
+ if (eventConfig?.refreshElements?.length > 0) {
85
+ result = eventConfig.refreshElements.map((e) => {
86
+ return e.value
87
+ })
88
+
89
+ } else {
90
+ if (eventGropus?.onLoad) {
91
+ result = Object.keys(eventGropus?.onLoad)
92
+ result.push(result[0]);
65
93
  }
66
94
  }
95
+ return result;
67
96
  }
68
- async function executeApiEventHandler(params: handlersProps) {
97
+ export function executeRefreshHandler(params: handlersProps) {
98
+ const compToRefresh: string[] = getRefreshElements(params.config, params.eventGroups);
99
+
100
+ return Promise.all(compToRefresh.map(componentName => {
101
+ return Promise.all(params.eventGroups.onLoad[componentName].map(compEventConfig => {
102
+ return executeEvents({ ...params, config: compEventConfig, componentName });
103
+ }));
104
+ }))
105
+ };
106
+ export function executeApiRequest(params: any) {
69
107
  const initialBody = { ...params.userValue?.payload };
70
108
  const initialHeaders = {
71
109
  "X-Requested-With": "XMLHttpRequest",
72
110
  "Access-Control-Allow-Origin": "*"
73
111
  };
74
- const { body, headers } = await buildApiPayload(params.config, initialBody, initialHeaders, params.store, params.dynamicData, params.userValue, params.service)
75
112
 
76
- const response = await params.service[params.config.method](
113
+ const payloadApi = buildApiPayload(params.config, initialBody, initialHeaders, params.store, params.dynamicData, params.userValue, params.service)
114
+ return params.service[params.config.method](
77
115
  params.config.path,
78
- body,
79
- headers && { headers: headers }
80
- );
81
- return response;
82
- }
116
+ payloadApi.body,
117
+ { headers: payloadApi.headers }
118
+ ).then((response) => {
119
+ return response;
120
+ });
121
+ };
83
122
 
84
- async function executeInBuiltFunctionHandler(params: handlersProps) {
123
+ function executeInBuiltFunctionHandler(params: handlersProps) {
85
124
  let parameter = {};
86
125
  if (params.config.funcParametersCode) {
87
126
  const makeFunc = eval(params.config.funcParametersCode)
@@ -92,13 +131,18 @@ async function executeInBuiltFunctionHandler(params: handlersProps) {
92
131
  }
93
132
  }
94
133
 
95
- async function executeCustomHandler(params: handlersProps) {
134
+ function executeCustomHandler(params: handlersProps) {
96
135
  const makeFunc = eval(params.config.eventCode)
97
- const response = await makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName);
98
- return response;
136
+ if (params.config.isSync !== "Yes") {
137
+ makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName).then((res) => res)
138
+ } else {
139
+ const response = makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName)
140
+ return response;
141
+ }
142
+
99
143
  }
100
144
 
101
- async function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any, service: any) {
145
+ function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any, service: any) {
102
146
  if (eventConfig.type === "Select" && !(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)) {
103
147
  store.setSchema((pre) => {
104
148
  return {
@@ -134,7 +178,6 @@ async function mergeFormdata(handlerResponse: any, componentName: string, eventC
134
178
  else {
135
179
  if (handlerResponse) {
136
180
  store.setFormdata((pre) => { return { ...pre, [componentName]: eventConfig.lazyLoading ? handlerResponse?.data?.data : handlerResponse.data } });
137
- const demoData = await asyncOperation();
138
181
  }
139
182
  }
140
183
  }
@@ -176,58 +219,40 @@ const buildHeadersFormat = (headers: any[]) => {
176
219
  return headerObj;
177
220
  }
178
221
 
179
- async function shouldEventExecute(params: handlersProps) {
222
+ export function shouldEventExecute(params: handlersProps) {
180
223
  const startEvent = params.config?.events?.filter(e => e.eventType === "onStart");
224
+
181
225
  if (startEvent?.length > 0) {
182
- const response = await executeEventsHandler({ ...params, config: startEvent[0] });
183
- return response;
226
+ return executeEventsHandler({ ...params, config: startEvent[0] }).then((response) => {
227
+ return response;
228
+ });
184
229
  } else {
185
- return true
230
+ if (params.config.isSync !== "Yes") {
231
+ return Promise.resolve(true)
232
+ } else {
233
+ return true
234
+ }
186
235
  }
187
236
  }
188
237
 
189
- export async function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service) {
190
- if (compConfig?.headers) {
191
- headers = buildHeadersFormat(compConfig.headers)
192
238
 
239
+ export function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service) {
240
+ if (compConfig?.headers) {
241
+ headers = buildHeadersFormat(compConfig.headers);
193
242
  }
243
+
194
244
  if (compConfig.body) {
195
245
  body = { ...buildBodyFormat(compConfig.body, store.newData || store?.ctx?.core?.data || store.formData, userValue) };
196
246
  }
197
- if (compConfig.apiBody) {
198
- const makeFunc = eval(compConfig.apiBody);
199
- const data = await makeFunc(store, dynamicData, userValue, body);
200
- body = data
201
- }
202
- return { body, headers };
203
- }
204
247
 
205
- export function getRefreshElements(eventConfig: any, eventGropus: any) {
206
- let result: string[] = [];
207
- if (eventConfig?.refreshElements?.length > 0) {
208
- result = eventConfig.refreshElements.map((e) => {
209
- return e.value
210
- })
248
+ const promiseChain = { body, headers };
211
249
 
212
- } else {
213
- if (eventGropus?.onLoad) {
214
- result = Object.keys(eventGropus?.onLoad)
215
- result.push(result[0]);
216
- }
217
- }
218
- console.log(result);
219
- return result;
220
- }
221
250
 
251
+ if (compConfig.apiBody) {
252
+ const makeFunc = eval(compConfig.apiBody);
253
+ return { body: makeFunc(store, dynamicData, userValue, promiseChain.body), headers: promiseChain.headers };
254
+ // return result;
222
255
 
223
- export function asyncOperation() {
224
- return new Promise((resolve, reject) => {
225
- setTimeout(() => {
226
- const success = true;
227
- if (success) {
228
- resolve("Operation completed successfully!");
229
- reject(new Error("Operation failed!"));
230
- }
231
- }, 50);
232
- });
256
+ }
257
+ return promiseChain;
233
258
  }