impaktapps-ui-builder 1.0.119 → 1.0.120

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.
@@ -3,8 +3,7 @@ export declare let schema: {
3
3
  properties: {};
4
4
  required: any[];
5
5
  };
6
- export declare function buildSchemaFromConfig(config: any, parentSchema: any): void;
7
- export declare const buildSchema: (config: any) => {
6
+ export declare const buildSchema: (config: any, tableName?: string, isArrayType?: boolean) => {
8
7
  type: string;
9
8
  properties: {};
10
9
  required: any[];
@@ -7,4 +7,3 @@ export { default as buildConfig } from "../builder/build/buildConfig";
7
7
  export { default as buildUiSchema } from "../builder/build/buildUiSchema";
8
8
  export { buildSchema } from "../builder/build/buildUiSchema";
9
9
  export { default as clearFromSessionStorage } from "../builder/services/utils";
10
- export { downloadFile, downloadFileFromUrl } from "../runtime/services/downloadFile";
@@ -1,5 +1,2 @@
1
- export declare function downloadFile({ data, name }: {
2
- data: string;
3
- name: string;
4
- }): void;
5
- export declare const downloadFileFromUrl: (response: any, service: any) => void;
1
+ export declare const downloadFile: (obj: any) => void;
2
+ export declare const doDownload: (response: any, service: any) => void;
@@ -1,4 +1,3 @@
1
- import { downloadFile } from "./downloadFile";
2
1
  interface funcParamsProps {
3
2
  store: any;
4
3
  dynamicData: any;
@@ -27,8 +26,8 @@ declare const _default: (funcParams: funcParamsProps) => {
27
26
  onBack: (functionParameters: any) => Promise<void>;
28
27
  onNext: (functionParameters: any) => Promise<void>;
29
28
  onReset: (functionParameters: any) => Promise<void>;
30
- callHandler: (eventType: string, functionParameters?: any) => void;
31
- downloadFile: typeof downloadFile;
32
- downloadFileFromUrl: (response: any, service: any) => void;
29
+ callHandler: (eventType: string, functionParameters?: any) => Promise<void>;
30
+ downloadFile: (obj: any) => void;
31
+ download: (response: any, service: any) => void;
33
32
  };
34
33
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impaktapps-ui-builder",
3
- "version": "1.0.119",
3
+ "version": "1.0.120",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "tsc && vite build",
@@ -7,9 +7,9 @@ export const buildCard = (config,componentScope,store) =>{
7
7
  if (config.style) {
8
8
  card.config.wrapperStyle = JSON.parse(config.style)
9
9
  }
10
- card.elements[0].elements[0].elements[0].elements[1].scope = `#/properties/${config.name}/properties/value`;
11
- card.elements[1].scope = `#/properties/${config.name}/properties/url`;
12
- card.elements[0].elements[0].elements[1].scope = `#/properties/${config.name}/properties/description`;
10
+ card.elements[0].elements[0].elements[0].elements[1].scope = `#/properties/${config.name}/properties/value`
11
+ card.elements[1].scope = `#/properties/${config.name}/properties/url`
12
+ card.elements[0].elements[0].elements[1].scope = `#/properties/${config.name}/properties/description`
13
13
  if(config.layout){
14
14
  card.config.layout = createLayoutFormat(config.layout)
15
15
  }
@@ -10,9 +10,6 @@ export const buildTable = (config: any, componentScope: string) => {
10
10
  if (config.lazyLoading) {
11
11
  table.config.main.lazyLoading = config.lazyLoading === "YES" ? true : false;
12
12
  }
13
- if (config.defaultColumnSize) {
14
- table.config.main.defaultColumnSize = config.defaultColumnSize
15
- }
16
13
  if (config.enableRowMovement) {
17
14
  table.config.main.enableRowMovement = config.enableRowMovement === "YES" ? true : false;
18
15
  }
@@ -44,28 +41,28 @@ export const buildTable = (config: any, componentScope: string) => {
44
41
  if (config.downloadAllData) {
45
42
  table.config.main.downloadAllData = config.downloadAllData === "YES" ? true : false
46
43
  }
47
- if (config.disableGlobalSearch) {
44
+ if(config.disableGlobalSearch){
48
45
  table.config.main.disableGlobalSearch = config.disableGlobalSearch === "YES" ? true : false
49
46
  }
50
- if (config.disableColumnFilter) {
47
+ if(config.disableColumnFilter){
51
48
  table.config.main.disableColumnFilter = config.disableColumnFilter === "YES" ? true : false
52
49
  }
53
- if (config.disableSorting) {
50
+ if(config.disableSorting){
54
51
  table.config.main.disableSorting = config.disableSorting === "YES" ? true : false
55
52
  }
56
- if (config.disableEditColumn) {
53
+ if(config.disableEditColumn){
57
54
  table.config.main.disableEditColumn = config.disableEditColumn === "YES" ? true : false
58
55
  }
59
- if (config.disableFullScreenToggle) {
56
+ if(config.disableFullScreenToggle){
60
57
  table.config.main.disableFullScreenToggle = config.disableFullScreenToggle === "YES" ? true : false
61
58
  }
62
- if (config.disableDensityToggle) {
59
+ if(config.disableDensityToggle){
63
60
  table.config.main.disableDensityToggle = config.disableDensityToggle === "YES" ? true : false
64
61
  }
65
- if (config.disableDownloadFile) {
62
+ if(config.disableDownloadFile){
66
63
  table.config.main.disableDownloadFile = config.disableDownloadFile === "YES" ? true : false
67
64
  }
68
- if (config.disablePagination) {
65
+ if(config.disablePagination){
69
66
  table.config.main.disablePagination = config.disablePagination === "YES" ? true : false
70
67
  }
71
68
  if (config.Table_Download_Keys_Name) {
@@ -74,8 +71,11 @@ export const buildTable = (config: any, componentScope: string) => {
74
71
  if (config.selectKey) {
75
72
  table.config.main.selectKey = config.selectKey
76
73
  }
77
- if (config.maxPageSize) {
74
+ if(config.maxPageSize){
78
75
  table.config.main.maxPageSize = config.maxPageSize
79
76
  }
77
+ if(config.initialDensity){
78
+ table.config.main.initialDensity = config.initialDensity
79
+ }
80
80
  return table;
81
81
  };
@@ -1,4 +1,6 @@
1
1
  import _ from "lodash";
2
+ import emptyBox from "./uischema/emptyBox";
3
+ import cardSlider from "./uischema/cardSlider";
2
4
  import { buildLeaderBoard } from "./buildLeaderboard";
3
5
  import { buildProgressBarCard } from "./buildProgressBarCard";
4
6
  import { buildProgressBar } from "./buildProgressBar";
@@ -45,77 +47,127 @@ export let schema = {
45
47
  properties: {},
46
48
  required: []
47
49
  };
48
- function buildOneOf(values: any[]) {
49
- return values.map((e) => ({
50
- const: e.value,
51
- title: e.label
52
- }));
53
- }
54
- export function buildSchemaFromConfig(config: any, parentSchema: any) {
55
- if (config.elements) {
56
- if (config.type === "Array") {
57
- parentSchema.properties ??= {};
58
- parentSchema.properties[config.name] ??= {
59
- type: "array",
50
+ //MultipleSelect
51
+ function buildRule(configObj: any, tableName?: string, arrayHolderName?: boolean) {
52
+ if (arrayHolderName) {
53
+ if (schema.properties?.[tableName]?.items?.properties) {
54
+ if (!schema.properties?.[tableName]?.items?.properties?.[configObj.name]) {
55
+ schema.properties[tableName].items.properties[configObj.name] = {};
56
+ if (configObj.type === "Select" && configObj.value?.length > 0) {
57
+ schema.properties[tableName].items.properties[configObj.name] = {
58
+ oneOf: configObj.value.map((e) => {
59
+ return { const: e.value, title: e.label }
60
+ })
61
+ }
62
+ }
63
+ else if (configObj.type === "MultipleSelect" && configObj.value?.length > 0) {
64
+ schema.properties[tableName].items.properties[configObj.name] = {
65
+ items: {
66
+ oneOf: configObj.value.map((e) => {
67
+ return { const: e.value, title: e.label }
68
+ })
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+ } else if ((configObj.type === "Select" || configObj.type === "MultipleSelect") && configObj.value?.length > 0) {
75
+ if (configObj.type === "Select") {
76
+ schema.properties[configObj.name] = {
77
+ oneOf: configObj.value.map((e) => {
78
+ return { const: e.value, title: e.label }
79
+ })
80
+ }
81
+ }
82
+ else if (configObj.type === "MultipleSelect") {
83
+ schema.properties[configObj.name] = {
60
84
  items: {
61
- type: "object",
62
- properties: {},
63
- required: [],
64
- },
65
- };
85
+ oneOf: configObj.value.map((e) => {
86
+ return { const: e.value, title: e.label }
87
+ })
88
+ }
89
+ }
90
+ }
91
+ }
92
+ if (configObj.validation) {
93
+ configObj.validation.forEach((rule: any) => {
94
+ if (tableName) {
95
+ if (schema.properties?.[tableName]?.items?.properties) {
96
+ if (!schema.properties?.[tableName]?.items?.properties?.[configObj.name]) {
97
+ schema.properties[tableName].items.properties[configObj.name] = {};
98
+ if (configObj.type === "Select" || configObj.value?.length > 0) {
99
+ schema.properties[tableName].items.properties[configObj.name] = {
100
+ oneOf: configObj.value.map((e) => {
101
+ return { const: e.value, title: e.label }
102
+ })
103
+ }
104
+ }
105
+ else if (configObj.type === "MultipleSelect" || configObj.value?.length > 0) {
106
+ schema.properties[tableName].items.properties[configObj.name] = {
107
+ items: {
108
+ oneOf: configObj.value.map((e) => {
109
+ return { const: e.value, title: e.label }
110
+ })
111
+ }
112
+ }
113
+ }
114
+ }
115
+ if (rule.validationType === "required") {
116
+ schema.properties?.[tableName]?.items?.required.push(configObj.name)
117
+ } else {
118
+ schema.properties[tableName].items.properties[configObj.name]["type"] = "string"
119
+ schema.properties[tableName].items.properties[configObj.name][rule.validationType] =
120
+ isNaN(rule.validationValue) ?
121
+ rule.validationValue : Number(rule.validationValue)
122
+ }
123
+
124
+ }
125
+ } else {
126
+ if (!schema.properties[configObj.name]) {
127
+ schema.properties[configObj.name] = {};
128
+ }
129
+ if (rule.validationType === "required") {
130
+ schema.required.push(configObj.name)
131
+ } else {
132
+ schema.properties[configObj.name]["type"] = "string"
133
+ schema.properties[configObj.name][rule.validationType] =
134
+ isNaN(rule.validationValue) ?
135
+ rule.validationValue : Number(rule.validationValue)
136
+ }
137
+ }
138
+ });
139
+ }
66
140
 
67
- const arrayItemSchema = parentSchema.properties[config.name].items;
68
141
 
69
- config.elements?.forEach((child: any) =>
70
- buildSchemaFromConfig(child, arrayItemSchema)
71
- );
72
- return;
73
- } else {
74
- config.elements?.forEach((child: any) =>
75
- buildSchemaFromConfig(child, parentSchema)
76
- );
77
- return;
142
+ }
143
+ export const buildSchema = (config: any, tableName?: string, isArrayType?: boolean) => {
144
+ buildRule(config, tableName, isArrayType);
145
+ if (config?.elements) {
146
+ if ( config.type == "Array") {
147
+ if (!schema.properties[config.name]) {
148
+ schema.properties[config.name] = {
149
+ type: "array",
150
+ items: {
151
+ type: "object",
152
+ properties: {},
153
+ required: []
154
+ }
155
+ }
156
+ }
157
+ config.elements.map((e, elemInd) => {
158
+ buildSchema(e, config.name, config.type === "Array" ? true : false)
159
+ })
78
160
  }
79
- }
80
- parentSchema.properties ??= {};
81
- parentSchema.properties[config.name] ??= {};
82
- const fieldSchema = parentSchema.properties[config.name];
83
- config.validation?.forEach((v: any) => {
84
- if (v.validationType === "required") {
85
- parentSchema.required ??= [];
86
- parentSchema.required.push(config.name);
87
- } else if (v.validationType === "readOnly") {
88
- fieldSchema.type = "string";
89
- fieldSchema.disabled = true;
90
- } else {
91
- fieldSchema.type = "string";
92
- fieldSchema[v.validationType] = isNaN(v.validationValue)
93
- ? v.validationValue
94
- : Number(v.validationValue);
161
+ else {
162
+ config.elements.map((e, elemInd) => {
163
+ buildSchema(e)
164
+ })
95
165
  }
96
- });
97
- if (config.type === "Select" && config.value?.length) {
98
- fieldSchema.oneOf = config.value.map((v: any) => ({
99
- const: v.value,
100
- title: v.label,
101
- }));
102
166
  }
103
- if (config.type === "MultipleSelect" && config.value?.length) {
104
- fieldSchema.type = "array";
105
- fieldSchema.items = {
106
- oneOf: config.value.map((v: any) => ({
107
- const: v.value,
108
- title: v.label,
109
- })),
110
- };
111
- }
112
- }
113
-
114
- export const buildSchema = (config) => {
115
- buildSchemaFromConfig(config, schema)
116
167
  return schema;
117
168
  }
118
169
 
170
+
119
171
  const buildUiSchema = (config: any, store?: any) => {
120
172
  let elements: any = {};
121
173
  const componentScope = `#/properties/${config.name}`;
@@ -335,7 +387,7 @@ const buildUiSchema = (config: any, store?: any) => {
335
387
  }
336
388
  if (cellElem.elementType == "tableHeader") {
337
389
  const headerElem = buildUiSchema(cellElem, store);
338
- tableHeaderElements.push({ widget: headerElem });
390
+ tableHeaderElements.push({widget:headerElem});
339
391
  return false;
340
392
  }
341
393
  const tableElem = {
@@ -327,7 +327,7 @@ export const buildPropertiesSection = function (type: String) {
327
327
  emptyBox("PopUpEmpty", { xs: 6, sm: 6, md: 0, lg: 0 })
328
328
  ]
329
329
  break;
330
- case "Text":
330
+ case "Text":
331
331
  uiSchema.elements = [
332
332
  getInputField("placeholder", "Placeholder"),
333
333
  getRadioInputField("multiline", "Multiline", ["YES", "NO"]),
@@ -477,7 +477,7 @@ export const buildPropertiesSection = function (type: String) {
477
477
  getRadioInputField("disableDensityToggle", "Disable Density Toggle", ["YES", "NO"]),
478
478
  getRadioInputField("disableDownloadFile", "Disable Download File", ["YES", "NO"]),
479
479
  getRadioInputField("disablePagination", "Disable Pagination", ["YES", "NO"]),
480
- getInputField("selectKey", "Selection Key"),//defaultColumnSize
480
+ getInputField("selectKey", "Selection Key"),
481
481
  getMultiSelectField("filteringOptions", "Filtering Options"),
482
482
  getSelectField("maxPageSize", "Max Page Size", [
483
483
  { label: "10", value: 10 },
@@ -487,6 +487,11 @@ export const buildPropertiesSection = function (type: String) {
487
487
  { label: "100", value: 100 },
488
488
  { label: "500", value: 500 }
489
489
  ]),
490
+ getSelectField("initialDensity", "Initial Toggle Density", [
491
+ { label: "Compact", value: "compact" },
492
+ { label: "Comfortable", value: "comfortable" },
493
+ { label: "Spacious", value: "spacious" }
494
+ ]),
490
495
  buildWrapper("Tree Table Properties", [
491
496
  getRadioInputField("enableRowMovement", "Row Rearrangement", ["YES", "NO"]),
492
497
  getRadioInputField("enableExpanding", "Row Expanding", ["YES", "NO"]),
@@ -494,7 +499,7 @@ export const buildPropertiesSection = function (type: String) {
494
499
  getRadioInputField("paginateExpandedRows", "Multi Page Expansion", ["YES", "NO"]),
495
500
  getRadioInputField("treeStructure", "Flat Tree Structure", ["YES", "NO"]),
496
501
  getRadioInputField("filterFromLeafRows", "Filter from tree rows", ["YES", "NO"]),
497
- getInputField("defaultColumnSize", "Default Column Size"), , emptyBox("LazyLoadingTableEmpty3")
502
+ emptyBox("LazyLoadingTableEmpty2"), emptyBox("LazyLoadingTableEmpty3")
498
503
  ]),
499
504
  getArrayControl("Table_Download_Keys_Name", "KeyName", "Table Key Name"),
500
505
  sizeHolder,
@@ -532,7 +537,7 @@ export const buildPropertiesSection = function (type: String) {
532
537
  emptyBox("MultipleSelectEmpty2")
533
538
  ]
534
539
  break;
535
- case "Date":
540
+ case "Date":
536
541
  uiSchema.elements = [
537
542
  getSelectField("variant", "Variant", [
538
543
  { label: "Outlined", value: "outlined" },
@@ -542,7 +547,7 @@ export const buildPropertiesSection = function (type: String) {
542
547
  emptyBox("DateEmpty1", { xs: 6, sm: 6, md: 8, lg: 9 }),
543
548
  ]
544
549
  break;
545
- case "DateTime":
550
+ case "DateTime":
546
551
  uiSchema.elements = [
547
552
  getSelectField("variant", "Variant", [
548
553
  { label: "Outlined", value: "outlined" },
@@ -569,7 +574,7 @@ export const buildPropertiesSection = function (type: String) {
569
574
  getRadioInputField("variant", "Variant", ["Outlined", "Standard"]),
570
575
  getRadioInputField("disableUpload", "Disable Upload", ["YES", "NO"]),
571
576
  getRadioInputField("disableDelete", "Disable Delete", ["YES", "NO"]),
572
- getRadioInputField("disableDownload", "Disable Download", ["YES", "NO"])
577
+ getRadioInputField("disableDownload", "Disable Download", ["YES", "NO"])
573
578
  ]
574
579
  break;
575
580
  }
@@ -58,15 +58,15 @@ export const ComponentSchema: any = {
58
58
  { title: "Date Column", const: "date" },
59
59
  { title: "DateTime Column", const: "dateTime" },
60
60
  { title: "Amount Column", const: "amount" },
61
- { title: "Center Column", const: "action" }
61
+ { title: "Center Column", const: "action"}
62
62
  ]
63
63
  },
64
64
  variant: {
65
65
  oneOf: [
66
- { title: "Outlined", const: "outlined" },
67
- { title: "Filled", const: "filled" },
68
- { title: "Standard", const: "standard" },
69
- ]
66
+ { title: "Outlined", const: "outlined" },
67
+ { title: "Filled", const: "filled" },
68
+ { title: "Standard", const: "standard" },
69
+ ]
70
70
  },
71
71
  orientation: {
72
72
  oneOf: [
@@ -83,7 +83,7 @@ export const ComponentSchema: any = {
83
83
  { title: "Put", const: "put" },
84
84
  ]
85
85
  },
86
- maxPageSize: {
86
+ maxPageSize:{
87
87
  type: "number",
88
88
  oneOf: [
89
89
  { title: "10", const: 10 },
@@ -94,6 +94,14 @@ export const ComponentSchema: any = {
94
94
  { title: "500", const: 500 }
95
95
  ]
96
96
  },
97
+ initialDensity:{
98
+ type: "string",
99
+ oneOf: [
100
+ { title: "Compact", const: "compact" },
101
+ { title: "Comfortable", const: "comfortable" },
102
+ { title: "Spacious", const: "spacious" }
103
+ ]
104
+ },
97
105
  layout: {
98
106
  type: "array",
99
107
  items: {
@@ -297,7 +305,6 @@ export const ComponentSchema: any = {
297
305
  { const: "minLength", title: "Minimum Length" },
298
306
  { const: "maxLength", title: "Maximum Length" },
299
307
  { const: "pattern", title: "Pattern" },
300
- { const: "readOnly", title: "Read Only" },
301
308
  ]
302
309
  },
303
310
  validationValue: {
@@ -1,5 +1,3 @@
1
- import { title } from "process";
2
-
3
1
  export const EventSchema = {
4
2
  type: "object",
5
3
  properties: {
@@ -74,7 +72,7 @@ export const EventSchema = {
74
72
  oneOf: [
75
73
  { title: "RankProvider", const: "RankProvider" },
76
74
  { title: "Download File", const: "downloadFile" },
77
- { title: "downloadFileFromUrl", const: "downloadFileFromUrl" },
75
+ { title: "Download", const: "download" },
78
76
  ]
79
77
  },
80
78
  body: {
@@ -30,7 +30,7 @@ const sectionLabels = {
30
30
  Timer: ["Core", "Events", "Style", "Validation"],
31
31
  Rank: ["Core", "Events", "Style", "Validation"],
32
32
  Button: ["Core", "Properties", "Events", "Style", "Validation"],
33
- Array: ["Core", "Components", "Properties","Events","Validation"],
33
+ Array: ["Core", "Components", "Properties","Validation"],
34
34
  Radio: ["Core", "Properties", "Events", "Style", "Validation"],
35
35
  Text: ["Core", "Properties", "Events", "Style", "Validation"],
36
36
  TextArea: ["Core", "Properties", "Events", "Style", "Validation"],
@@ -31,18 +31,18 @@ export default (funcParams: funcParamsProps) => {
31
31
  return formData;
32
32
  }
33
33
  saveFormdataInSessionStorage(config)
34
- return { ...config, type: "page" }
34
+ return config
35
35
  },
36
36
  getUiSchema: function () {
37
37
  const UiSchema = _.cloneDeep(PageMasterUiSchema(store.theme.myTheme));
38
- if (sessionStorage.getItem("copiedConfig")) {
38
+ if (sessionStorage.getItem("copiedConfig") ) {
39
39
  Component(store, dynamicData, submitHandler, service).ElementPathSetter(UiSchema)
40
40
  }
41
41
  return UiSchema;
42
42
  },
43
43
  getSchema: () => {
44
44
  const schema = _.cloneDeep(PageMasterSchema);
45
- if (sessionStorage.getItem("copiedConfig")) {
45
+ if (sessionStorage.getItem("copiedConfig") ) {
46
46
  schema.properties.RemoveItemButton.disabled = false;
47
47
  }
48
48
  return schema;
@@ -70,8 +70,8 @@ export default (funcParams: funcParamsProps) => {
70
70
  },
71
71
  saveHandler: async () => await saveHandler(store, service, submitHandler),
72
72
  Edit_Components: Component(store, dynamicData, submitHandler, service).editComponents,
73
-
74
- Delete_Components: async function () {
73
+
74
+ Delete_Components: async function() {
75
75
  await Component(store, dynamicData, submitHandler, service).deleteComponents(false);
76
76
  store.updateDialog("popUpPageMasterComponent");
77
77
  },
@@ -99,25 +99,25 @@ export default (funcParams: funcParamsProps) => {
99
99
  store.updateDialog("popUpPageMasterEvent");
100
100
  sessionStorage.removeItem('rowId');
101
101
  },
102
- deletePopUpComponent: function () {
102
+ deletePopUpComponent: function(){
103
103
  const rowId = dynamicData.path.split(".")[1];
104
- sessionStorage.setItem('rowId', rowId);
104
+ sessionStorage.setItem('rowId',rowId);
105
105
  store.updateDialog("popUpPageMasterComponent");
106
106
  },
107
- deletePopUpEvent: function () {
107
+ deletePopUpEvent: function(){
108
108
  const rowId = dynamicData.path.split(".")[1];
109
- sessionStorage.setItem('rowId', rowId);
109
+ sessionStorage.setItem('rowId',rowId);
110
110
  store.updateDialog("popUpPageMasterEvent");
111
111
  },
112
112
 
113
113
 
114
- copyPasteElement: function () {
115
- Component(store, dynamicData, submitHandler, service).copyPasteElement(store, this.setPage.bind(this));
114
+ copyPasteElement: function(){
115
+ Component(store, dynamicData, submitHandler, service).copyPasteElement(store,this.setPage.bind(this));
116
116
  },
117
-
118
- RemoveItemButton: function () {
117
+
118
+ RemoveItemButton: function(){
119
119
  Component(store, dynamicData, submitHandler, service).RemoveItemButton(store)
120
120
  },
121
-
121
+
122
122
  }
123
123
  };
@@ -1,11 +1,10 @@
1
1
 
2
- export { default as pageMaster } from "../builder/services/pageMaster"
3
- export { default as pageMasterEvents } from "../builder/services/event"
4
- export { default as pageMasterComponents } from "../builder/services/component"
5
- export { default as pageService } from "../runtime/services/service"
6
- export { schema } from "../builder/build/buildUiSchema"
7
- export { default as buildConfig } from "../builder/build/buildConfig"
8
- export { default as buildUiSchema } from "../builder/build/buildUiSchema"
9
- export { buildSchema } from "../builder/build/buildUiSchema"
10
- export { default as clearFromSessionStorage } from "../builder/services/utils"
11
- export { downloadFile, downloadFileFromUrl } from "../runtime/services/downloadFile"
2
+ export {default as pageMaster} from "../builder/services/pageMaster"
3
+ export {default as pageMasterEvents} from "../builder/services/event"
4
+ export {default as pageMasterComponents} from "../builder/services/component"
5
+ export {default as pageService} from "../runtime/services/service"
6
+ export { schema} from "../builder/build/buildUiSchema"
7
+ export {default as buildConfig} from "../builder/build/buildConfig"
8
+ export {default as buildUiSchema} from "../builder/build/buildUiSchema"
9
+ export {buildSchema} from "../builder/build/buildUiSchema"
10
+ export {default as clearFromSessionStorage} from "../builder/services/utils"
@@ -1,47 +1,32 @@
1
- export function downloadFile({ data, name }: { data: string; name: string }) {
2
- const binary = window.atob(data);
3
- const bytes = new Uint8Array(binary.length);
4
-
5
- for (let i = 0; i < binary.length; i++) {
6
- bytes[i] = binary.charCodeAt(i);
7
- }
8
-
9
- const extension = name.split(".").pop()?.toLowerCase();
10
- const mimeMap: Record<string, string> = {
11
- pdf: "application/pdf",
12
- png: "image/png",
13
- jpg: "image/jpeg",
14
- jpeg: "image/jpeg",
15
- xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
16
- csv: "text/csv",
17
- };
18
-
19
- const blob = new Blob([bytes], {
20
- type: mimeMap[extension!] || "application/octet-stream",
21
- });
22
-
23
- const url = URL.createObjectURL(blob);
24
- const a = document.createElement("a");
25
- a.href = url;
26
- a.download = name;
27
- a.click();
1
+ export const downloadFile = (obj: any) => {
2
+ const typeArr = obj.name.split(".");
3
+ const data = obj.data;
4
+ const finalData = window.atob(data);
5
+ let file;
6
+ file = new File([finalData], typeArr[typeArr.length - 1]);
7
+
8
+ const url = URL.createObjectURL(file);
9
+ const link = document.createElement("a");
10
+ link.href = typeArr[typeArr.length - 1] === 'pdf' ? 'data:application/octet-stream;base64,' + data : url;
11
+ link.download = `${obj.name}`;
12
+ document.body.appendChild(link);
13
+ link.click();
28
14
 
29
15
  URL.revokeObjectURL(url);
30
- }
16
+ document.body.removeChild(link);
17
+ };
31
18
 
32
- export const downloadFileFromUrl = (response: any, service) => {
19
+ export const doDownload = (response: any, service) => {
33
20
  let url = `${service.defaults.baseURL}/${response.path}`;
34
21
  if (response?.params) {
35
22
  const keysArray = Object.keys(response?.params);
36
23
  keysArray.map((e, i) => {
37
- url = url + `${i === 0 ? "?" : "&"}${e}=${response?.params[e]}`
24
+ url = url + `${i === 0?"?":"&"}${e}=${response?.params[e]}`
38
25
  })
39
- };
26
+ }
40
27
  const link = document.createElement('a');
41
28
  link.href = url;
42
29
  document.body.appendChild(link);
43
30
  link.click();
44
31
  link.parentNode.removeChild(link);
45
32
  };
46
-
47
-