impaktapps-ui-builder 1.0.113 → 1.0.114

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,7 +3,8 @@ export declare let schema: {
3
3
  properties: {};
4
4
  required: any[];
5
5
  };
6
- export declare const buildSchema: (config: any, tableName?: string, isArrayType?: boolean) => {
6
+ export declare function buildSchemaFromConfig(config: any, parentSchema: any): void;
7
+ export declare const buildSchema: (config: any) => {
7
8
  type: string;
8
9
  properties: {};
9
10
  required: any[];
@@ -7,3 +7,4 @@ 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,2 +1,5 @@
1
- export declare const downloadFile: (obj: any) => void;
2
- export declare const doDownload: (response: any, service: any) => void;
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,3 +1,4 @@
1
+ import { downloadFile } from "./downloadFile";
1
2
  interface funcParamsProps {
2
3
  store: any;
3
4
  dynamicData: any;
@@ -26,8 +27,8 @@ declare const _default: (funcParams: funcParamsProps) => {
26
27
  onBack: (functionParameters: any) => Promise<void>;
27
28
  onNext: (functionParameters: any) => Promise<void>;
28
29
  onReset: (functionParameters: any) => Promise<void>;
29
- callHandler: (eventType: string, functionParameters?: any) => Promise<void>;
30
- downloadFile: (obj: any) => void;
31
- download: (response: any, service: any) => void;
30
+ callHandler: (eventType: string, functionParameters?: any) => void;
31
+ downloadFile: typeof downloadFile;
32
+ downloadFileFromUrl: (response: any, service: any) => void;
32
33
  };
33
34
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impaktapps-ui-builder",
3
- "version": "1.0.113",
3
+ "version": "1.0.114",
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,6 +10,9 @@ 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
+ }
13
16
  if (config.enableRowMovement) {
14
17
  table.config.main.enableRowMovement = config.enableRowMovement === "YES" ? true : false;
15
18
  }
@@ -41,28 +44,28 @@ export const buildTable = (config: any, componentScope: string) => {
41
44
  if (config.downloadAllData) {
42
45
  table.config.main.downloadAllData = config.downloadAllData === "YES" ? true : false
43
46
  }
44
- if(config.disableGlobalSearch){
47
+ if (config.disableGlobalSearch) {
45
48
  table.config.main.disableGlobalSearch = config.disableGlobalSearch === "YES" ? true : false
46
49
  }
47
- if(config.disableColumnFilter){
50
+ if (config.disableColumnFilter) {
48
51
  table.config.main.disableColumnFilter = config.disableColumnFilter === "YES" ? true : false
49
52
  }
50
- if(config.disableSorting){
53
+ if (config.disableSorting) {
51
54
  table.config.main.disableSorting = config.disableSorting === "YES" ? true : false
52
55
  }
53
- if(config.disableEditColumn){
56
+ if (config.disableEditColumn) {
54
57
  table.config.main.disableEditColumn = config.disableEditColumn === "YES" ? true : false
55
58
  }
56
- if(config.disableFullScreenToggle){
59
+ if (config.disableFullScreenToggle) {
57
60
  table.config.main.disableFullScreenToggle = config.disableFullScreenToggle === "YES" ? true : false
58
61
  }
59
- if(config.disableDensityToggle){
62
+ if (config.disableDensityToggle) {
60
63
  table.config.main.disableDensityToggle = config.disableDensityToggle === "YES" ? true : false
61
64
  }
62
- if(config.disableDownloadFile){
65
+ if (config.disableDownloadFile) {
63
66
  table.config.main.disableDownloadFile = config.disableDownloadFile === "YES" ? true : false
64
67
  }
65
- if(config.disablePagination){
68
+ if (config.disablePagination) {
66
69
  table.config.main.disablePagination = config.disablePagination === "YES" ? true : false
67
70
  }
68
71
  if (config.Table_Download_Keys_Name) {
@@ -71,11 +74,8 @@ export const buildTable = (config: any, componentScope: string) => {
71
74
  if (config.selectKey) {
72
75
  table.config.main.selectKey = config.selectKey
73
76
  }
74
- if(config.maxPageSize){
77
+ if (config.maxPageSize) {
75
78
  table.config.main.maxPageSize = config.maxPageSize
76
79
  }
77
- if(config.initialDensity){
78
- table.config.main.initialDensity = config.initialDensity
79
- }
80
80
  return table;
81
81
  };
@@ -1,6 +1,4 @@
1
1
  import _ from "lodash";
2
- import emptyBox from "./uischema/emptyBox";
3
- import cardSlider from "./uischema/cardSlider";
4
2
  import { buildLeaderBoard } from "./buildLeaderboard";
5
3
  import { buildProgressBarCard } from "./buildProgressBarCard";
6
4
  import { buildProgressBar } from "./buildProgressBar";
@@ -47,126 +45,76 @@ export let schema = {
47
45
  properties: {},
48
46
  required: []
49
47
  };
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] = {
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",
84
60
  items: {
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
- }
61
+ type: "object",
62
+ properties: {},
63
+ required: [],
64
+ },
65
+ };
140
66
 
67
+ const arrayItemSchema = parentSchema.properties[config.name].items;
141
68
 
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
- })
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;
160
78
  }
161
- else {
162
- config.elements.map((e, elemInd) => {
163
- buildSchema(e)
164
- })
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);
165
95
  }
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
+ }
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
+ };
166
111
  }
167
- return schema;
168
112
  }
169
113
 
114
+ export const buildSchema = (config) => {
115
+ buildSchemaFromConfig(config, schema)
116
+ return schema;
117
+ }
170
118
 
171
119
  const buildUiSchema = (config: any, store?: any) => {
172
120
  let elements: any = {};
@@ -387,7 +335,7 @@ const buildUiSchema = (config: any, store?: any) => {
387
335
  }
388
336
  if (cellElem.elementType == "tableHeader") {
389
337
  const headerElem = buildUiSchema(cellElem, store);
390
- tableHeaderElements.push({widget:headerElem});
338
+ tableHeaderElements.push({ widget: headerElem });
391
339
  return false;
392
340
  }
393
341
  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"),
480
+ getInputField("selectKey", "Selection Key"),//defaultColumnSize
481
481
  getMultiSelectField("filteringOptions", "Filtering Options"),
482
482
  getSelectField("maxPageSize", "Max Page Size", [
483
483
  { label: "10", value: 10 },
@@ -487,11 +487,6 @@ 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
- ]),
495
490
  buildWrapper("Tree Table Properties", [
496
491
  getRadioInputField("enableRowMovement", "Row Rearrangement", ["YES", "NO"]),
497
492
  getRadioInputField("enableExpanding", "Row Expanding", ["YES", "NO"]),
@@ -499,7 +494,7 @@ export const buildPropertiesSection = function (type: String) {
499
494
  getRadioInputField("paginateExpandedRows", "Multi Page Expansion", ["YES", "NO"]),
500
495
  getRadioInputField("treeStructure", "Flat Tree Structure", ["YES", "NO"]),
501
496
  getRadioInputField("filterFromLeafRows", "Filter from tree rows", ["YES", "NO"]),
502
- emptyBox("LazyLoadingTableEmpty2"), emptyBox("LazyLoadingTableEmpty3")
497
+ getInputField("defaultColumnSize", "Default Column Size"), , emptyBox("LazyLoadingTableEmpty3")
503
498
  ]),
504
499
  getArrayControl("Table_Download_Keys_Name", "KeyName", "Table Key Name"),
505
500
  sizeHolder,
@@ -537,7 +532,7 @@ export const buildPropertiesSection = function (type: String) {
537
532
  emptyBox("MultipleSelectEmpty2")
538
533
  ]
539
534
  break;
540
- case "Date":
535
+ case "Date":
541
536
  uiSchema.elements = [
542
537
  getSelectField("variant", "Variant", [
543
538
  { label: "Outlined", value: "outlined" },
@@ -547,7 +542,7 @@ export const buildPropertiesSection = function (type: String) {
547
542
  emptyBox("DateEmpty1", { xs: 6, sm: 6, md: 8, lg: 9 }),
548
543
  ]
549
544
  break;
550
- case "DateTime":
545
+ case "DateTime":
551
546
  uiSchema.elements = [
552
547
  getSelectField("variant", "Variant", [
553
548
  { label: "Outlined", value: "outlined" },
@@ -574,7 +569,7 @@ export const buildPropertiesSection = function (type: String) {
574
569
  getRadioInputField("variant", "Variant", ["Outlined", "Standard"]),
575
570
  getRadioInputField("disableUpload", "Disable Upload", ["YES", "NO"]),
576
571
  getRadioInputField("disableDelete", "Disable Delete", ["YES", "NO"]),
577
- getRadioInputField("disableDownload", "Disable Download", ["YES", "NO"])
572
+ getRadioInputField("disableDownload", "Disable Download", ["YES", "NO"])
578
573
  ]
579
574
  break;
580
575
  }
@@ -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,14 +94,6 @@ 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
- },
105
97
  layout: {
106
98
  type: "array",
107
99
  items: {
@@ -305,6 +297,7 @@ export const ComponentSchema: any = {
305
297
  { const: "minLength", title: "Minimum Length" },
306
298
  { const: "maxLength", title: "Maximum Length" },
307
299
  { const: "pattern", title: "Pattern" },
300
+ { const: "readOnly", title: "Read Only" },
308
301
  ]
309
302
  },
310
303
  validationValue: {
@@ -1,3 +1,5 @@
1
+ import { title } from "process";
2
+
1
3
  export const EventSchema = {
2
4
  type: "object",
3
5
  properties: {
@@ -72,7 +74,7 @@ export const EventSchema = {
72
74
  oneOf: [
73
75
  { title: "RankProvider", const: "RankProvider" },
74
76
  { title: "Download File", const: "downloadFile" },
75
- { title: "Download", const: "download" },
77
+ { title: "downloadFileFromUrl", const: "downloadFileFromUrl" },
76
78
  ]
77
79
  },
78
80
  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","Validation"],
33
+ Array: ["Core", "Components", "Properties","Events","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
34
+ return { ...config, type: "page" }
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,10 +1,11 @@
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"
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"
@@ -1,32 +1,47 @@
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();
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();
14
28
 
15
29
  URL.revokeObjectURL(url);
16
- document.body.removeChild(link);
17
- };
30
+ }
18
31
 
19
- export const doDownload = (response: any, service) => {
32
+ export const downloadFileFromUrl = (response: any, service) => {
20
33
  let url = `${service.defaults.baseURL}/${response.path}`;
21
34
  if (response?.params) {
22
35
  const keysArray = Object.keys(response?.params);
23
36
  keysArray.map((e, i) => {
24
- url = url + `${i === 0?"?":"&"}${e}=${response?.params[e]}`
37
+ url = url + `${i === 0 ? "?" : "&"}${e}=${response?.params[e]}`
25
38
  })
26
- }
39
+ };
27
40
  const link = document.createElement('a');
28
41
  link.href = url;
29
42
  document.body.appendChild(link);
30
43
  link.click();
31
44
  link.parentNode.removeChild(link);
32
45
  };
46
+
47
+