impaktapps-ui-builder 0.0.382-alpha.329 → 0.0.382-alpha.330

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.382-alpha.329",
3
+ "version": "0.0.382-alpha.330",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "tsc && vite build",
@@ -1,10 +1,7 @@
1
- import _, { isEmpty, throttle } from "lodash";
1
+ import _, { isEmpty, debounce } from "lodash";
2
2
  import { doDownload, downloadFile } from "./downloadFile";
3
3
  import { executeEvents, executeRefreshHandler } from "./events";
4
4
  import { handlersProps } from "./interface";
5
-
6
- import { debounce } from "lodash";
7
-
8
5
  let compType: string;
9
6
  let eventGroups: any = {};
10
7
  const notifyUiSchema = {
@@ -30,20 +27,38 @@ export const extractEvents = (eventConfig: any) => {
30
27
  eventGroups[event.eventType][eventConfigObj.name] = [];
31
28
  }
32
29
  const SuccessEvent = event?.events?.find((elem) => {
33
- return elem.eventType === "Success"
34
- })
30
+ return elem.eventType === "Success";
31
+ });
35
32
  if (!(!!SuccessEvent) && event.eventType === "onLoad") {
36
- event.events.push({ Handler: "mergeFormdata", eventType: "Success", type: compType, lazyLoading: eventConfig.lazyLoading === "YES" ? true : false })
33
+ event.events.push({
34
+ Handler: "mergeFormdata",
35
+ eventType: "Success",
36
+ type: compType,
37
+ lazyLoading: eventConfig.lazyLoading === "YES" ? true : false,
38
+ });
37
39
  }
38
- if (!(!!SuccessEvent) && (event.eventType === "onBack" || event.eventType === "onNext"|| event.eventType === "onReset")) {
39
- event.events.push({ Handler: `${event.eventType}Handler`, eventType: "Success", type: compType, lazyLoading: eventConfig.lazyLoading === "YES" ? true : false })
40
+ if (
41
+ !(!!SuccessEvent) &&
42
+ (event.eventType === "onBack" ||
43
+ event.eventType === "onNext" ||
44
+ event.eventType === "onReset")
45
+ ) {
46
+ event.events.push({
47
+ Handler: `${event.eventType}Handler`,
48
+ eventType: "Success",
49
+ type: compType,
50
+ lazyLoading: eventConfig.lazyLoading === "YES" ? true : false,
51
+ });
40
52
  }
41
- eventGroups[event.eventType][eventConfigObj.name].push({ ...event, type: compType })
53
+ eventGroups[event.eventType][eventConfigObj.name].push({
54
+ ...event,
55
+ type: compType,
56
+ });
42
57
  });
43
58
  }
44
59
  }
45
60
 
46
- extractsConfigEvents(eventConfig)
61
+ extractsConfigEvents(eventConfig);
47
62
  if (eventConfig?.elements) {
48
63
  eventConfig.elements.forEach(extractEvents);
49
64
  }
@@ -51,71 +66,77 @@ export const extractEvents = (eventConfig: any) => {
51
66
  };
52
67
 
53
68
  interface funcParamsProps {
54
- store: any,
55
- dynamicData: any,
56
- config: any,
57
- uiSchema: any,
58
- schema: any,
59
- service: any,
60
- userValue: any,
69
+ store: any;
70
+ dynamicData: any;
71
+ config: any;
72
+ uiSchema: any;
73
+ schema: any;
74
+ service: any;
75
+ userValue: any;
61
76
  }
62
77
  export default (funcParams: funcParamsProps) => {
63
- eventGroups = {}
64
- eventGroups = extractEvents(funcParams.config)
78
+ eventGroups = {};
79
+ eventGroups = extractEvents(funcParams.config);
65
80
  let executeEventsParameters: handlersProps = {
66
- config: {}, componentName: "",
67
- store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
68
- serviceHolder: { downloadFile,download:doDownload }, eventGroups
81
+ config: {},
82
+ componentName: "",
83
+ store: funcParams.store,
84
+ dynamicData: funcParams.dynamicData,
85
+ userValue: funcParams.userValue,
86
+ service: funcParams.service,
87
+ serviceHolder: { downloadFile, download: doDownload },
88
+ eventGroups,
69
89
  };
70
- const handleButtonClick = debounce(async function() {
71
- await this.callHandler("onClick");
72
- }, 300); // adjust the delay as needed
73
90
 
74
- const throttledExecuteEvents = throttle(async (executeEventsParams) => {
75
- await executeEvents(executeEventsParams);
76
- }, 1000); // Adjust the time window as needed
91
+ // Create a debounced version of executeEvents
92
+ const debouncedExecuteEvents = debounce(async (eventConfig: any, componentName: string) => {
93
+ await executeEvents({
94
+ ...executeEventsParameters,
95
+ config: eventConfig,
96
+ componentName,
97
+ });
98
+ }, 300); // Adjust the debounce delay (300ms) as needed
77
99
 
78
100
  return {
79
101
  setPage: async function () {
80
102
  funcParams.store.setFormdata({});
81
103
  executeEventsParameters = {
82
- config: {}, componentName: "",
83
- store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
84
- serviceHolder: this, eventGroups
85
- }
86
- // funcParams.store.setSchema(
87
- // (pre: any) => {
88
- // return {
89
- // ...funcParams.schema, properties:
90
- // { ...funcParams.schema.properties, ...pre.properties, }
91
- // }
92
- // }
93
- // )
94
- funcParams.store.setFormdata({ testKey: 'testValue' });
95
- console.log("After Setting Specific Value:", funcParams.store.formData);
96
-
97
- funcParams.store.setSchema(funcParams.schema);
104
+ config: {},
105
+ componentName: "",
106
+ store: funcParams.store,
107
+ dynamicData: funcParams.dynamicData,
108
+ userValue: funcParams.userValue,
109
+ service: funcParams.service,
110
+ serviceHolder: this,
111
+ eventGroups,
112
+ };
113
+ funcParams.store.setSchema((pre: any) => {
114
+ return {
115
+ ...funcParams.schema,
116
+ properties: { ...funcParams.schema.properties, ...pre.properties },
117
+ };
118
+ });
98
119
  funcParams.uiSchema.elements.push(notifyUiSchema);
99
120
  funcParams.store.setUiSchema(funcParams.uiSchema);
100
-
101
-
102
121
  await executeRefreshHandler({
103
- config: {}, componentName: "",
104
- store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
105
- serviceHolder: this, eventGroups
106
- })
122
+ config: {},
123
+ componentName: "",
124
+ store: funcParams.store,
125
+ dynamicData: funcParams.dynamicData,
126
+ userValue: funcParams.userValue,
127
+ service: funcParams.service,
128
+ serviceHolder: this,
129
+ eventGroups,
130
+ });
107
131
  },
108
132
  onClick: async function () {
109
- await this.callHandler("onClick")
133
+ await this.callHandler("onClick");
110
134
  },
111
- // onClick: async function () {
112
- // handleButtonClick();
113
- // },
114
135
  onFileDownload: async function () {
115
- await this.callHandler("onDownload")
136
+ await this.callHandler("onDownload");
116
137
  },
117
138
  onFileUpload: async function () {
118
- await this.callHandler("onUpload")
139
+ await this.callHandler("onUpload");
119
140
  },
120
141
  onPaginationChange: async function (paginationValues) {
121
142
  const apiBody = [
@@ -123,8 +144,8 @@ export default (funcParams: funcParamsProps) => {
123
144
  { key: "pageIndex", value: paginationValues.pagination.pageIndex },
124
145
  { key: "sorting", value: paginationValues.sorting || [] },
125
146
  { key: "filters", value: paginationValues.columnFilters || [] },
126
- { key: "globalFilter", value: paginationValues.globalFilter ?? '' }
127
- ]
147
+ { key: "globalFilter", value: paginationValues.globalFilter ?? "" },
148
+ ];
128
149
  const response = await this.updateConfigApiBody(paginationValues, apiBody);
129
150
  return response?.data;
130
151
  },
@@ -132,118 +153,87 @@ export default (funcParams: funcParamsProps) => {
132
153
  if (param.serachValue !== "" && param.serachValue !== undefined) {
133
154
  const apiBody = [
134
155
  { key: "searchValue", value: param.serachValue },
135
- { key: "currentValue", value: param.currentValue }
136
- ]
137
- return await this.updateConfigApiBody(param, apiBody)
156
+ { key: "currentValue", value: param.currentValue },
157
+ ];
158
+ return await this.updateConfigApiBody(param, apiBody);
138
159
  }
139
160
  },
140
161
  onChange: async function () {
141
162
  if (eventGroups.onChange) {
142
163
  const ChangeEventsKeysArray = Object.keys(eventGroups.onChange);
143
- Promise.all(ChangeEventsKeysArray.map(async (componentName: string) => {
144
- if (
145
- funcParams.store?.formData[componentName] !== funcParams.store.newData[componentName] &&
146
- funcParams.store?.newData[componentName] !== undefined
147
- ) {
148
- for (const eventConfig of eventGroups.onChange[componentName]) {
149
- await executeEvents({
150
- ...executeEventsParameters,
151
- config: eventConfig,
152
- componentName
153
- })
164
+ await Promise.all(
165
+ ChangeEventsKeysArray.map(async (componentName: string) => {
166
+ if (
167
+ funcParams.store?.formData[componentName] !== funcParams.store.newData[componentName] &&
168
+ funcParams.store?.newData[componentName] !== undefined
169
+ ) {
170
+ for (const eventConfig of eventGroups.onChange[componentName]) {
171
+ await debouncedExecuteEvents(eventConfig, componentName);
172
+ }
154
173
  }
155
- }
156
- }))
174
+ })
175
+ );
157
176
  }
158
177
  },
159
178
  updateConfigApiBody: async function (paramValue, apiBody) {
160
179
  let LastCallResponse = undefined;
161
180
  for (const eventConfig of eventGroups?.onLoad[paramValue.path]) {
162
181
  if (eventConfig.body) {
163
- eventConfig.body = [
164
- ...eventConfig.body,
165
- ...apiBody
166
- ]
167
- } else { eventConfig.body = apiBody; };
182
+ eventConfig.body = [...eventConfig.body, ...apiBody];
183
+ } else {
184
+ eventConfig.body = apiBody;
185
+ }
168
186
  const responseEvent = eventConfig?.events?.filter((elem) => {
169
- return elem.Handler !== "mergeFormdata"
170
- })
171
- eventConfig.events = responseEvent ?? []
187
+ return elem.Handler !== "mergeFormdata";
188
+ });
189
+ eventConfig.events = responseEvent ?? [];
172
190
  LastCallResponse = await executeEvents({
173
191
  ...executeEventsParameters,
174
192
  config: eventConfig,
175
- componentName: paramValue.path
176
- })
193
+ componentName: paramValue.path,
194
+ });
177
195
  }
178
- return LastCallResponse
196
+ return LastCallResponse;
179
197
  },
180
198
  onBack: async function (functionParameters) {
181
- const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
182
- await this.callHandler("onBack", functionParameters)
199
+ const path =
200
+ funcParams.dynamicData?.tableButtonPath ||
201
+ funcParams.dynamicData.path.split(".")[0];
202
+ await this.callHandler("onBack", functionParameters);
183
203
  if (eventGroups?.["onBack"]?.[path] === undefined) {
184
- functionParameters?.handleBack()
204
+ functionParameters?.handleBack();
185
205
  }
186
206
  },
187
207
  onNext: async function (functionParameters) {
188
- const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
189
- await this.callHandler("onNext", functionParameters)
208
+ const path =
209
+ funcParams.dynamicData?.tableButtonPath ||
210
+ funcParams.dynamicData.path.split(".")[0];
211
+ await this.callHandler("onNext", functionParameters);
190
212
  if (eventGroups?.["onNext"]?.[path] === undefined) {
191
- functionParameters?.handleNext()
213
+ functionParameters?.handleNext();
192
214
  }
193
215
  },
194
216
  onReset: async function (functionParameters) {
195
- const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
196
- await this.callHandler("onReset", functionParameters)
217
+ const path =
218
+ funcParams.dynamicData?.tableButtonPath ||
219
+ funcParams.dynamicData.path.split(".")[0];
220
+ await this.callHandler("onReset", functionParameters);
197
221
  if (eventGroups?.["onReset"]?.[path] === undefined) {
198
- functionParameters?.handleReset()
222
+ functionParameters?.handleReset();
199
223
  }
200
224
  },
201
- // callHandler: async function (eventType: string, functionParameters?: any) {
202
- // const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
203
- // if (eventGroups?.[eventType]?.[path] !== undefined) {
204
- // for (const eventConfig of eventGroups?.[eventType]?.[path]) {
205
- // executeEventsParameters.store.functionParameters = functionParameters
206
- // await executeEvents({
207
- // ...executeEventsParameters,
208
- // config: eventConfig,
209
- // componentName: path
210
- // })
211
- // }
212
- // }
213
- // },
214
225
  callHandler: async function (eventType: string, functionParameters?: any) {
215
- const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
216
-
217
- // Create a throttled version of executeEvents inside callHandler
218
- const throttledExecuteEvents = throttle(async (eventConfig) => {
219
- executeEventsParameters.store.functionParameters = functionParameters;
220
- await executeEvents({
221
- ...executeEventsParameters,
222
- config: eventConfig,
223
- componentName: path,
224
- });
225
- }, 1000); // Adjust the delay as needed
226
-
226
+ const path =
227
+ funcParams.dynamicData?.tableButtonPath ||
228
+ funcParams.dynamicData.path.split(".")[0];
227
229
  if (eventGroups?.[eventType]?.[path] !== undefined) {
228
230
  for (const eventConfig of eventGroups?.[eventType]?.[path]) {
229
- // Use the throttled function for each eventConfig
230
- await throttledExecuteEvents(eventConfig);
231
+ executeEventsParameters.store.functionParameters = functionParameters;
232
+ await debouncedExecuteEvents(eventConfig, path);
231
233
  }
232
234
  }
233
235
  },
234
-
235
236
  downloadFile: downloadFile,
236
- download:doDownload,
237
+ download: doDownload,
237
238
  };
238
239
  };
239
-
240
-
241
-
242
-
243
-
244
-
245
-
246
-
247
-
248
-
249
-