impaktapps-ui-builder 0.0.347 → 0.0.350

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.
Files changed (24) hide show
  1. package/dist/impaktapps-ui-builder.es.js +153 -170
  2. package/dist/impaktapps-ui-builder.es.js.map +1 -1
  3. package/dist/impaktapps-ui-builder.umd.js +10 -10
  4. package/dist/impaktapps-ui-builder.umd.js.map +1 -1
  5. package/dist/src/impaktapps-ui-builder/builder/services/component.d.ts +1 -1
  6. package/dist/src/impaktapps-ui-builder/builder/services/event.d.ts +2 -2
  7. package/dist/src/impaktapps-ui-builder/builder/services/pageMaster.d.ts +1 -3
  8. package/dist/src/impaktapps-ui-builder/builder/services/utils.d.ts +10 -0
  9. package/dist/src/impaktapps-ui-builder/lib/index.d.ts +1 -1
  10. package/package.json +1 -1
  11. package/src/impaktapps-ui-builder/builder/elements/UiSchema/Component/uiSchema.ts +1 -1
  12. package/src/impaktapps-ui-builder/builder/elements/UiSchema/PageMaster/uiSchema.ts +1 -1
  13. package/src/impaktapps-ui-builder/builder/elements/UiSchema/event/uiSchema.ts +1 -1
  14. package/src/impaktapps-ui-builder/builder/services/component.ts +3 -29
  15. package/src/impaktapps-ui-builder/builder/services/event.ts +14 -24
  16. package/src/impaktapps-ui-builder/builder/services/pageMaster.ts +2 -37
  17. package/src/impaktapps-ui-builder/builder/services/utils.ts +109 -0
  18. package/src/impaktapps-ui-builder/lib/index.ts +1 -1
  19. package/dist/src/impaktapps-ui-builder/builder/services/clearLocalStorage.d.ts +0 -2
  20. package/dist/src/impaktapps-ui-builder/builder/services/getNavigationHistory.d.ts +0 -3
  21. package/dist/src/impaktapps-ui-builder/builder/services/saveHandler.d.ts +0 -2
  22. package/src/impaktapps-ui-builder/builder/services/clearLocalStorage.ts +0 -3
  23. package/src/impaktapps-ui-builder/builder/services/getNavigationHistory.ts +0 -27
  24. package/src/impaktapps-ui-builder/builder/services/saveHandler.ts +0 -29
@@ -400,7 +400,7 @@ const PageMasterUiSchema = {
400
400
  variant: "contained",
401
401
  color: "info",
402
402
  type: "text",
403
- onClick: "savePageHandler",
403
+ onClick: "saveHandler",
404
404
  size: "small"
405
405
  },
406
406
  style: {
@@ -6372,7 +6372,7 @@ const componentBasicUiSchema = {
6372
6372
  variant: "contained",
6373
6373
  color: "info",
6374
6374
  type: "text",
6375
- onClick: "savePageHandler",
6375
+ onClick: "saveHandler",
6376
6376
  size: "small"
6377
6377
  },
6378
6378
  style: {
@@ -6391,97 +6391,6 @@ const componentBasicUiSchema = {
6391
6391
  }
6392
6392
  ]
6393
6393
  };
6394
- var buildConfig = (FormData) => {
6395
- const formData = _.cloneDeep(FormData);
6396
- let component = {};
6397
- if (formData.pageName) {
6398
- delete formData.pageName;
6399
- }
6400
- if (formData.eventsSelected) {
6401
- delete formData.eventsSelected;
6402
- }
6403
- if (formData.type === "Table" || formData.type === "WrapperSection" || formData.type === "TabSection") {
6404
- component.elements = formData.elements || [];
6405
- if (formData.elements) {
6406
- delete formData.elements;
6407
- }
6408
- }
6409
- component.events = formData.events || [];
6410
- if (formData.events) {
6411
- delete formData.events;
6412
- }
6413
- component = { ...formData, ...component };
6414
- return component;
6415
- };
6416
- const createLayoutFormat = (config) => {
6417
- if (_.isEmpty(config)) {
6418
- return {
6419
- xs: 11,
6420
- sm: 11,
6421
- md: 5.5,
6422
- lg: 5.5
6423
- };
6424
- }
6425
- let data2 = {};
6426
- config.map((e) => {
6427
- data2[e.key || "xs"] = +e.value || 5.5;
6428
- });
6429
- return data2;
6430
- };
6431
- const flatObjectValueInArray = (config) => {
6432
- const keyName = Object.keys(config[0])[0];
6433
- const data2 = config.map((e) => {
6434
- return e[keyName];
6435
- });
6436
- return data2;
6437
- };
6438
- const getNavigationHistory = (config, path) => {
6439
- if (path) {
6440
- let urlRoutes = config.name;
6441
- const pathArrayAll = path.split(".");
6442
- const arr = [];
6443
- pathArrayAll.map((e, i) => {
6444
- if (i === 0) {
6445
- arr.push(e);
6446
- return;
6447
- }
6448
- arr.push(`${arr[i - 1]}.${e}`);
6449
- });
6450
- arr.map((e) => {
6451
- const data2 = _.get(config, e);
6452
- if (data2) {
6453
- urlRoutes = urlRoutes + ` > ${(data2 == null ? void 0 : data2.name) || (data2 == null ? void 0 : data2.eventType)}`;
6454
- } else {
6455
- urlRoutes = urlRoutes + " > NewComponent";
6456
- }
6457
- });
6458
- return { pageName: urlRoutes };
6459
- }
6460
- return void 0;
6461
- };
6462
- const saveFormdataInLocalStorage = (formData, path) => {
6463
- let updatedFormdata;
6464
- if (path) {
6465
- const pageFormdata = getFormdataFromLocalStorage();
6466
- updatedFormdata = _.set(pageFormdata, path, buildConfig(formData));
6467
- } else {
6468
- updatedFormdata = buildConfig(formData);
6469
- }
6470
- localStorage.setItem("pageFormdata", JSON.stringify(updatedFormdata));
6471
- return updatedFormdata;
6472
- };
6473
- const getFormdataFromLocalStorage = (path) => {
6474
- const pageFormdata = localStorage.getItem("pageFormdata") ? JSON.parse(localStorage.getItem("pageFormdata")) : void 0;
6475
- let returnValue;
6476
- if (path) {
6477
- returnValue = _.get(pageFormdata, path);
6478
- returnValue = { ...returnValue, ...getNavigationHistory(pageFormdata, path) };
6479
- }
6480
- if (!returnValue) {
6481
- returnValue = getNavigationHistory(pageFormdata, path);
6482
- }
6483
- return returnValue || pageFormdata;
6484
- };
6485
6394
  const CoreSection = {
6486
6395
  type: "HorizontalLayout",
6487
6396
  elements: [
@@ -7249,6 +7158,150 @@ const ValidationSection = {
7249
7158
  }
7250
7159
  ]
7251
7160
  };
7161
+ var buildConfig = (FormData) => {
7162
+ const formData = _.cloneDeep(FormData);
7163
+ let component = {};
7164
+ if (formData.pageName) {
7165
+ delete formData.pageName;
7166
+ }
7167
+ if (formData.eventsSelected) {
7168
+ delete formData.eventsSelected;
7169
+ }
7170
+ if (formData.type === "Table" || formData.type === "WrapperSection" || formData.type === "TabSection") {
7171
+ component.elements = formData.elements || [];
7172
+ if (formData.elements) {
7173
+ delete formData.elements;
7174
+ }
7175
+ }
7176
+ component.events = formData.events || [];
7177
+ if (formData.events) {
7178
+ delete formData.events;
7179
+ }
7180
+ component = { ...formData, ...component };
7181
+ return component;
7182
+ };
7183
+ const createLayoutFormat = (config) => {
7184
+ if (_.isEmpty(config)) {
7185
+ return {
7186
+ xs: 11,
7187
+ sm: 11,
7188
+ md: 5.5,
7189
+ lg: 5.5
7190
+ };
7191
+ }
7192
+ let data2 = {};
7193
+ config.map((e) => {
7194
+ data2[e.key || "xs"] = +e.value || 5.5;
7195
+ });
7196
+ return data2;
7197
+ };
7198
+ const flatObjectValueInArray = (config) => {
7199
+ const keyName = Object.keys(config[0])[0];
7200
+ const data2 = config.map((e) => {
7201
+ return e[keyName];
7202
+ });
7203
+ return data2;
7204
+ };
7205
+ const clearFromLocalStorage = () => {
7206
+ localStorage.removeItem("pageFormdata");
7207
+ };
7208
+ const getNavigationHistory = (config, path) => {
7209
+ if (path) {
7210
+ let urlRoutes = config.name;
7211
+ const pathArrayAll = path.split(".");
7212
+ const arr = [];
7213
+ pathArrayAll.map((e, i) => {
7214
+ if (i === 0) {
7215
+ arr.push(e);
7216
+ return;
7217
+ }
7218
+ arr.push(`${arr[i - 1]}.${e}`);
7219
+ });
7220
+ arr.map((e) => {
7221
+ const data2 = _.get(config, e);
7222
+ if (data2) {
7223
+ urlRoutes = urlRoutes + ` > ${(data2 == null ? void 0 : data2.name) || (data2 == null ? void 0 : data2.eventType)}`;
7224
+ } else {
7225
+ urlRoutes = urlRoutes + " > NewComponent";
7226
+ }
7227
+ });
7228
+ return { pageName: urlRoutes };
7229
+ }
7230
+ return void 0;
7231
+ };
7232
+ const saveFormdataInLocalStorage = (formData, path) => {
7233
+ let updatedFormdata;
7234
+ if (path) {
7235
+ const pageFormdata = getFormdataFromLocalStorage();
7236
+ updatedFormdata = _.set(pageFormdata, path, buildConfig(formData));
7237
+ } else {
7238
+ updatedFormdata = buildConfig(formData);
7239
+ }
7240
+ localStorage.setItem("pageFormdata", JSON.stringify(updatedFormdata));
7241
+ return updatedFormdata;
7242
+ };
7243
+ const getFormdataFromLocalStorage = (path) => {
7244
+ const pageFormdata = localStorage.getItem("pageFormdata") ? JSON.parse(localStorage.getItem("pageFormdata")) : void 0;
7245
+ let returnValue;
7246
+ if (path) {
7247
+ returnValue = _.get(pageFormdata, path);
7248
+ returnValue = { ...returnValue, ...getNavigationHistory(pageFormdata, path) };
7249
+ }
7250
+ if (!returnValue) {
7251
+ returnValue = getNavigationHistory(pageFormdata, path);
7252
+ }
7253
+ return returnValue || pageFormdata;
7254
+ };
7255
+ async function saveHandler(store2, service2, submitHandler, pageName) {
7256
+ var _a, _b;
7257
+ const id = (_a = store2.searchParams) == null ? void 0 : _a.get("id");
7258
+ const path = (_b = store2.searchParams) == null ? void 0 : _b.get("path");
7259
+ saveFormdataInLocalStorage(store2.ctx.core.data, path);
7260
+ const config = JSON.parse(localStorage.getItem("pageFormdata"));
7261
+ if (_.isEmpty(store2.ctx.core.errors)) {
7262
+ try {
7263
+ const saveReturn = await submitHandler(store2, service2, config);
7264
+ navigateHandler(store2, true, pageName ? `/${pageName}?id=${id}` : pageName);
7265
+ } catch (err) {
7266
+ navigateHandler(store2, false);
7267
+ }
7268
+ }
7269
+ }
7270
+ const navigateHandler = (store2, isSubmitted, pageName) => {
7271
+ if (isSubmitted) {
7272
+ localStorage.removeItem("pageFormdata");
7273
+ store2.navigate(pageName || -1);
7274
+ store2.setNotify({
7275
+ SuccessMessage: "Submit Successfully",
7276
+ Success: true
7277
+ });
7278
+ } else {
7279
+ store2.setValidation("ValidateAndShow");
7280
+ store2.setNotify({
7281
+ Fail: true,
7282
+ FailMessage: "Errors on Page"
7283
+ });
7284
+ }
7285
+ };
7286
+ function okHandler(store2) {
7287
+ var _a;
7288
+ const path = (_a = store2.searchParams) == null ? void 0 : _a.get("path");
7289
+ console.log(store2.ctx.core.errors);
7290
+ if (_.isEmpty(store2.ctx.core.errors)) {
7291
+ saveFormdataInLocalStorage(store2.ctx.core.data, path);
7292
+ store2.navigate(-1);
7293
+ store2.setNotify({
7294
+ SuccessMessage: "Save Successfully",
7295
+ Success: true
7296
+ });
7297
+ } else {
7298
+ store2.setValidation("ValidateAndShow");
7299
+ store2.setNotify({
7300
+ Fail: true,
7301
+ FailMessage: "Errors on Page"
7302
+ });
7303
+ }
7304
+ }
7252
7305
  const sectionLabels = {
7253
7306
  Select: ["Core", "Properties", "Value", "style", "Event", "Validation"],
7254
7307
  MultipleSelect: ["Core", "Properties", "Value", "style", "Event", "Validation"],
@@ -7311,34 +7364,8 @@ var Component = (store2, dynamicData2, submitHandler, service2) => {
7311
7364
  getSchema: function() {
7312
7365
  return ComponentSchema;
7313
7366
  },
7314
- okHandler: function() {
7315
- var _a;
7316
- const path = (_a = store2.searchParams) == null ? void 0 : _a.get("path");
7317
- console.log(store2.ctx.core.errors);
7318
- if (_.isEmpty(store2.ctx.core.errors)) {
7319
- saveFormdataInLocalStorage(store2.ctx.core.data, path);
7320
- store2.navigate(-1);
7321
- store2.setNotify({
7322
- SuccessMessage: "Save Successfully",
7323
- Success: true
7324
- });
7325
- } else {
7326
- store2.setValidation("ValidateAndShow");
7327
- store2.setNotify({
7328
- Fail: true,
7329
- FailMessage: "Errors on Page"
7330
- });
7331
- }
7332
- },
7333
- savePageHandler: async () => {
7334
- var _a, _b;
7335
- const id = (_a = store2.searchParams) == null ? void 0 : _a.get("id");
7336
- const path = (_b = store2.searchParams) == null ? void 0 : _b.get("path");
7337
- saveFormdataInLocalStorage(store2.ctx.core.data, path);
7338
- const config = JSON.parse(localStorage.getItem("pageFormdata"));
7339
- const isSubmitted = await saveHandler(store2, service2, submitHandler, config);
7340
- navigation(store2, isSubmitted, `/PageMaster?id=${id}`);
7341
- },
7367
+ okHandler: () => okHandler(store2),
7368
+ saveHandler: async () => await saveHandler(store2, service2, submitHandler, "PageMaster"),
7342
7369
  onChange: function() {
7343
7370
  var _a, _b, _c, _d;
7344
7371
  if (((_a = store2 == null ? void 0 : store2.formData) == null ? void 0 : _a.type) !== ((_b = store2 == null ? void 0 : store2.newData) == null ? void 0 : _b.type) && ((_c = store2 == null ? void 0 : store2.newData) == null ? void 0 : _c.type) !== void 0) {
@@ -7415,34 +7442,6 @@ var Component = (store2, dynamicData2, submitHandler, service2) => {
7415
7442
  }
7416
7443
  };
7417
7444
  };
7418
- async function saveHandler(store2, service2, submitHandler, config) {
7419
- let isTrue = false;
7420
- if (_.isEmpty(store2.ctx.core.errors)) {
7421
- try {
7422
- const saveReturn = await submitHandler(store2, service2, config);
7423
- isTrue = true;
7424
- } catch (err) {
7425
- isTrue = false;
7426
- }
7427
- }
7428
- return isTrue;
7429
- }
7430
- const navigation = (store2, isSubmitted, pageName) => {
7431
- if (isSubmitted) {
7432
- localStorage.removeItem("pageFormdata");
7433
- store2.navigate(pageName || -1);
7434
- store2.setNotify({
7435
- SuccessMessage: "Submit Successfully",
7436
- Success: true
7437
- });
7438
- } else {
7439
- store2.setValidation("ValidateAndShow");
7440
- store2.setNotify({
7441
- Fail: true,
7442
- FailMessage: "Errors on Page"
7443
- });
7444
- }
7445
- };
7446
7445
  var pageMaster = (funcParams) => {
7447
7446
  const { store: store2, dynamicData: dynamicData2, config, submitHandler, service: service2 } = funcParams;
7448
7447
  return {
@@ -7485,12 +7484,7 @@ var pageMaster = (funcParams) => {
7485
7484
  `/Component?path=${`elements[${response2 == null ? void 0 : response2.elements.length}]`}&id=${id}`
7486
7485
  );
7487
7486
  },
7488
- savePageHandler: async () => {
7489
- saveFormdataInLocalStorage(store2.ctx.core.data);
7490
- const config2 = JSON.parse(localStorage.getItem("pageFormdata"));
7491
- const isSubmitted = await saveHandler(store2, service2, submitHandler, config2);
7492
- navigation(store2, isSubmitted);
7493
- },
7487
+ saveHandler: async () => await saveHandler(store2, service2, submitHandler, "/PageMasterRecords"),
7494
7488
  Edit_Components: Component(store2, dynamicData2, submitHandler, service2).editComponents,
7495
7489
  Delete_Components: Component(store2, dynamicData2, submitHandler, service2).deleteComponents,
7496
7490
  eventAddHandler: function() {
@@ -7880,7 +7874,7 @@ const EventUiSchema = {
7880
7874
  variant: "contained",
7881
7875
  color: "info",
7882
7876
  type: "text",
7883
- onClick: "savePageHandler",
7877
+ onClick: "saveHandler",
7884
7878
  size: "small"
7885
7879
  },
7886
7880
  style: {
@@ -8124,22 +8118,14 @@ var event = (store2, dynamicData2, submitHandler, service2) => {
8124
8118
  getSchema: () => {
8125
8119
  return EventSchema;
8126
8120
  },
8127
- savePageHandler: async () => {
8128
- var _a, _b;
8129
- const id = (_a = store2.searchParams) == null ? void 0 : _a.get("id");
8130
- const path = (_b = store2.searchParams) == null ? void 0 : _b.get("path");
8131
- saveFormdataInLocalStorage(store2.ctx.core.data, path);
8132
- const config = JSON.parse(localStorage.getItem("pageFormdata"));
8133
- const isSubmitted = await saveHandler(store2, service2, submitHandler, config);
8134
- navigation(store2, isSubmitted, `/PageMaster?id=${id}`);
8135
- },
8121
+ okHandler: () => okHandler(store2),
8122
+ saveHandler: async () => await saveHandler(store2, service2, submitHandler, "PageMaster"),
8136
8123
  onChange: function() {
8137
8124
  var _a, _b, _c;
8138
8125
  if (((_a = store2 == null ? void 0 : store2.formData) == null ? void 0 : _a.Handler) !== ((_b = store2 == null ? void 0 : store2.newData) == null ? void 0 : _b.Handler) && ((_c = store2 == null ? void 0 : store2.newData) == null ? void 0 : _c.Handler) !== void 0) {
8139
8126
  this.refreshPage(store2.newData.Handler || store2.formdata.Handler, store2);
8140
8127
  }
8141
8128
  },
8142
- okHandler: Component(store2, dynamicData2, submitHandler, service2).okHandler,
8143
8129
  addEvent: function() {
8144
8130
  var _a, _b, _c;
8145
8131
  const path = (_a = store2.searchParams) == null ? void 0 : _a.get("path");
@@ -10533,8 +10519,5 @@ const buildUiSchema = (config) => {
10533
10519
  }
10534
10520
  return elements;
10535
10521
  };
10536
- var clearLocalStorage = () => {
10537
- localStorage.removeItem("pageFormdata");
10538
- };
10539
- export { buildConfig, buildSchema, buildUiSchema, clearLocalStorage as clearPreviousCache, pageMaster, Component as pageMasterComponents, event as pageMasterEvents, service as pageService, schema };
10522
+ export { buildConfig, buildSchema, buildUiSchema, clearFromLocalStorage, pageMaster, Component as pageMasterComponents, event as pageMasterEvents, service as pageService, schema };
10540
10523
  //# sourceMappingURL=impaktapps-ui-builder.es.js.map