impaktapps-ui-builder 1.0.104 → 1.0.106

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.
@@ -8984,8 +8984,7 @@ const EventSchema = {
8984
8984
  oneOf: [
8985
8985
  { title: "RankProvider", const: "RankProvider" },
8986
8986
  { title: "Download File", const: "downloadFile" },
8987
- { title: "downloadFileFromUrl", const: "downloadFileFromUrl" },
8988
- { title: "downloadFileFromBase64", const: "downloadFileFromBase64" }
8987
+ { title: "downloadFileFromUrl", const: "downloadFileFromUrl" }
8989
8988
  ]
8990
8989
  },
8991
8990
  body: {
@@ -9922,22 +9921,7 @@ var event = (store2, dynamicData2, submitHandler, service2, functionsName) => {
9922
9921
  }
9923
9922
  };
9924
9923
  };
9925
- const downloadFile$1 = (obj) => {
9926
- const typeArr = obj.name.split(".");
9927
- const data = obj.data;
9928
- const finalData = window.atob(data);
9929
- let file;
9930
- file = new File([finalData], typeArr[typeArr.length - 1]);
9931
- const url = URL.createObjectURL(file);
9932
- const link = document.createElement("a");
9933
- link.href = typeArr[typeArr.length - 1] === "pdf" ? "data:application/octet-stream;base64," + data : url;
9934
- link.download = `${obj.name}`;
9935
- document.body.appendChild(link);
9936
- link.click();
9937
- URL.revokeObjectURL(url);
9938
- document.body.removeChild(link);
9939
- };
9940
- function downloadFileFromBase64({ data, name }) {
9924
+ function downloadFile$1({ data, name }) {
9941
9925
  var _a;
9942
9926
  const binary = window.atob(data);
9943
9927
  const bytes = new Uint8Array(binary.length);
@@ -10043,7 +10027,8 @@ function executeEventsHandler(params2) {
10043
10027
  params2.config,
10044
10028
  params2.store,
10045
10029
  params2.service,
10046
- params2.formDataHolder
10030
+ params2.formDataHolder,
10031
+ params2.pageLoad
10047
10032
  );
10048
10033
  } else if (params2.config.Handler === "onBackHandler") {
10049
10034
  return (_a = params2.store.functionParameters) == null ? void 0 : _a.handleBack();
@@ -10114,7 +10099,7 @@ function executeCustomHandler(params) {
10114
10099
  return response;
10115
10100
  }
10116
10101
  }
10117
- function mergeFormdata(handlerResponse, componentName, eventConfig, store2, service2, formDataHolder) {
10102
+ function mergeFormdata(handlerResponse, componentName, eventConfig, store2, service2, formDataHolder, pageLoad) {
10118
10103
  var _a, _b, _c;
10119
10104
  if (eventConfig.type === "Select" && (handlerResponse == null ? void 0 : handlerResponse.data)) {
10120
10105
  if (!_.isEmpty(handlerResponse == null ? void 0 : handlerResponse.data)) {
@@ -10157,24 +10142,36 @@ function mergeFormdata(handlerResponse, componentName, eventConfig, store2, serv
10157
10142
  ...store2.newData,
10158
10143
  ...handlerResponse == null ? void 0 : handlerResponse.data
10159
10144
  };
10160
- store2.setFormdata((pre) => {
10161
- return { ...pre, ...handlerResponse == null ? void 0 : handlerResponse.data };
10162
- });
10145
+ formDataHolder = { ...formDataHolder, ...handlerResponse == null ? void 0 : handlerResponse.data };
10146
+ if (!pageLoad) {
10147
+ store2.setFormdata((pre) => {
10148
+ return { ...pre, ...handlerResponse == null ? void 0 : handlerResponse.data };
10149
+ });
10150
+ }
10163
10151
  }
10164
10152
  } else if (eventConfig.type === "Table" && eventConfig.lazyLoading) {
10165
10153
  if (handlerResponse && (handlerResponse == null ? void 0 : handlerResponse.data)) {
10166
10154
  formDataHolder[componentName] = (_a = handlerResponse.data) == null ? void 0 : _a.data;
10167
10155
  formDataHolder[`${componentName}_RowCount`] = (_c = (_b = handlerResponse.data) == null ? void 0 : _b.meta) == null ? void 0 : _c.totalRowCount;
10168
- store2.setFormdata((pre) => {
10169
- return { ...pre, ...formDataHolder };
10170
- });
10156
+ if (!pageLoad) {
10157
+ store2.setFormdata((pre) => {
10158
+ var _a2, _b2, _c2;
10159
+ return {
10160
+ ...pre,
10161
+ [componentName]: (_a2 = handlerResponse.data) == null ? void 0 : _a2.data,
10162
+ [`${componentName}_RowCount`]: (_c2 = (_b2 = handlerResponse.data) == null ? void 0 : _b2.meta) == null ? void 0 : _c2.totalRowCount
10163
+ };
10164
+ });
10165
+ }
10171
10166
  }
10172
10167
  } else {
10173
10168
  if (handlerResponse) {
10174
10169
  formDataHolder[componentName] = handlerResponse.data;
10175
- store2.setFormdata((pre) => {
10176
- return { ...pre, ...formDataHolder };
10177
- });
10170
+ if (!pageLoad) {
10171
+ store2.setFormdata((pre) => {
10172
+ return { ...pre, [componentName]: handlerResponse.data };
10173
+ });
10174
+ }
10178
10175
  }
10179
10176
  }
10180
10177
  }
@@ -10312,7 +10309,7 @@ var service = (funcParams) => {
10312
10309
  dynamicData: funcParams.dynamicData,
10313
10310
  userValue: funcParams.userValue,
10314
10311
  service: funcParams.service,
10315
- serviceHolder: { downloadFile: downloadFile$1, download: downloadFileFromUrl, downloadFileFromBase64, ...funcParams.functionsProvider },
10312
+ serviceHolder: { downloadFile: downloadFile$1, download: downloadFileFromUrl, ...funcParams.functionsProvider },
10316
10313
  eventGroups,
10317
10314
  functionsProvider: funcParams.functionsProvider,
10318
10315
  formDataHolder
@@ -10365,8 +10362,10 @@ var service = (funcParams) => {
10365
10362
  service: funcParams.service,
10366
10363
  serviceHolder: this,
10367
10364
  eventGroups,
10368
- formDataHolder: {}
10365
+ formDataHolder,
10366
+ pageLoad: true
10369
10367
  });
10368
+ funcParams.store.setFormdata((pre) => ({ ...pre, ...formDataHolder }));
10370
10369
  uiSchema.elements.push(notifyUiSchema);
10371
10370
  funcParams.store.setUiSchema(uiSchema);
10372
10371
  },
@@ -10526,7 +10525,6 @@ var service = (funcParams) => {
10526
10525
  },
10527
10526
  downloadFile: downloadFile$1,
10528
10527
  downloadFileFromUrl,
10529
- downloadFileFromBase64,
10530
10528
  ...funcParams.functionsProvider
10531
10529
  };
10532
10530
  };
@@ -12335,94 +12333,64 @@ let schema = {
12335
12333
  properties: {},
12336
12334
  required: []
12337
12335
  };
12338
- function buildOneOf(values) {
12339
- return values.map((e) => ({
12340
- const: e.value,
12341
- title: e.label
12342
- }));
12343
- }
12344
- function applyValidations(schemaNode, validations = [], requiredArr, fieldName) {
12345
- validations.forEach((rule) => {
12346
- if (rule.validationType === "readOnly") {
12347
- schemaNode.disabled = true;
12348
- }
12349
- if (rule.validationType === "required") {
12350
- if (requiredArr && fieldName) {
12351
- requiredArr.push(fieldName);
12352
- }
12353
- } else {
12354
- schemaNode.type = "string";
12355
- schemaNode[rule.validationType] = isNaN(rule.validationValue) ? rule.validationValue : Number(rule.validationValue);
12356
- }
12357
- });
12358
- }
12359
- function buildNode(config2) {
12360
- var _a, _b, _c;
12361
- if (config2.type === "Array") {
12362
- const arraySchema = {
12363
- type: "array",
12364
- items: {
12365
- type: "object",
12366
- properties: {},
12367
- required: []
12368
- }
12369
- };
12370
- (_a = config2.elements) == null ? void 0 : _a.forEach((child) => {
12371
- var _a2;
12372
- const childNode = buildNode(child);
12373
- if (!childNode)
12374
- return;
12375
- arraySchema.items.properties[child.name] = childNode.schema;
12376
- if ((_a2 = childNode.required) == null ? void 0 : _a2.length) {
12377
- arraySchema.items.required.push(child.name);
12378
- }
12379
- });
12380
- return { schema: arraySchema };
12381
- }
12382
- let fieldSchema = {};
12383
- if ((config2.type === "Select" || config2.type === "MultipleSelect") && ((_b = config2.value) == null ? void 0 : _b.length) > 0) {
12384
- if (config2.type === "Select") {
12385
- fieldSchema.oneOf = buildOneOf(config2.value);
12386
- } else {
12387
- fieldSchema.type = "array";
12388
- fieldSchema.items = {
12389
- oneOf: buildOneOf(config2.value)
12336
+ function buildSchemaFromConfig(config2, parentSchema) {
12337
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
12338
+ if (config2.elements) {
12339
+ if (config2.type === "Array") {
12340
+ (_a = parentSchema.properties) != null ? _a : parentSchema.properties = {};
12341
+ (_d = (_b = parentSchema.properties)[_c = config2.name]) != null ? _d : _b[_c] = {
12342
+ type: "array",
12343
+ items: {
12344
+ type: "object",
12345
+ properties: {},
12346
+ required: []
12347
+ }
12390
12348
  };
12349
+ const arrayItemSchema = parentSchema.properties[config2.name].items;
12350
+ (_e = config2.elements) == null ? void 0 : _e.forEach(
12351
+ (child) => buildSchemaFromConfig(child, arrayItemSchema)
12352
+ );
12353
+ return;
12354
+ } else {
12355
+ (_f = config2.elements) == null ? void 0 : _f.forEach(
12356
+ (child) => buildSchemaFromConfig(child, parentSchema)
12357
+ );
12358
+ return;
12391
12359
  }
12392
12360
  }
12393
- if (config2.validation) {
12394
- applyValidations(fieldSchema, config2.validation);
12395
- }
12396
- const required = ((_c = config2.validation) == null ? void 0 : _c.some(
12397
- (v) => v.validationType === "required"
12398
- )) ? [config2.name] : [];
12399
- return {
12400
- schema: fieldSchema,
12401
- required
12402
- };
12403
- }
12404
- function buildSchema(config2) {
12405
- var _a;
12406
- const schema2 = {
12407
- type: "object",
12408
- properties: {},
12409
- required: []
12410
- };
12411
- (_a = config2.elements) == null ? void 0 : _a.forEach((element) => {
12361
+ (_g = parentSchema.properties) != null ? _g : parentSchema.properties = {};
12362
+ (_j = (_h = parentSchema.properties)[_i = config2.name]) != null ? _j : _h[_i] = {};
12363
+ const fieldSchema = parentSchema.properties[config2.name];
12364
+ (_k = config2.validation) == null ? void 0 : _k.forEach((v) => {
12412
12365
  var _a2;
12413
- const node = buildNode(element);
12414
- if (!node)
12415
- return;
12416
- schema2.properties[element.name] = node.schema;
12417
- if ((_a2 = node.required) == null ? void 0 : _a2.length) {
12418
- schema2.required.push(element.name);
12366
+ if (v.validationType === "required") {
12367
+ (_a2 = parentSchema.required) != null ? _a2 : parentSchema.required = [];
12368
+ parentSchema.required.push(config2.name);
12369
+ } else {
12370
+ fieldSchema.type = "string";
12371
+ fieldSchema[v.validationType] = isNaN(v.validationValue) ? v.validationValue : Number(v.validationValue);
12419
12372
  }
12420
12373
  });
12421
- if (schema2.required.length === 0) {
12422
- delete schema2.required;
12374
+ if (config2.type === "Select" && ((_l = config2.value) == null ? void 0 : _l.length)) {
12375
+ fieldSchema.oneOf = config2.value.map((v) => ({
12376
+ const: v.value,
12377
+ title: v.label
12378
+ }));
12379
+ }
12380
+ if (config2.type === "MultipleSelect" && ((_m = config2.value) == null ? void 0 : _m.length)) {
12381
+ fieldSchema.type = "array";
12382
+ fieldSchema.items = {
12383
+ oneOf: config2.value.map((v) => ({
12384
+ const: v.value,
12385
+ title: v.label
12386
+ }))
12387
+ };
12423
12388
  }
12424
- return schema2;
12425
12389
  }
12390
+ const buildSchema = (config2) => {
12391
+ buildSchemaFromConfig(config2, schema);
12392
+ return schema;
12393
+ };
12426
12394
  const buildUiSchema = (config2, store2) => {
12427
12395
  let elements = {};
12428
12396
  const componentScope2 = `#/properties/${config2.name}`;
@@ -12662,5 +12630,5 @@ const buildUiSchema = (config2, store2) => {
12662
12630
  }
12663
12631
  return elements;
12664
12632
  };
12665
- export { buildConfig, buildSchema, buildUiSchema, clearFromSessionStorage, downloadFileFromBase64, downloadFileFromUrl, pageMaster, Component as pageMasterComponents, event as pageMasterEvents, service as pageService, schema };
12633
+ export { buildConfig, buildSchema, buildUiSchema, clearFromSessionStorage, downloadFile$1 as downloadFile, downloadFileFromUrl, pageMaster, Component as pageMasterComponents, event as pageMasterEvents, service as pageService, schema };
12666
12634
  //# sourceMappingURL=impaktapps-ui-builder.es.js.map