impaktapps-ui-builder 0.0.279 → 0.0.281

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,5 +3,10 @@ export declare let schema: {
3
3
  properties: {};
4
4
  required: any[];
5
5
  };
6
+ export declare const buildSchema: (config: any, tableName?: string) => {
7
+ type: string;
8
+ properties: {};
9
+ required: any[];
10
+ };
6
11
  declare const buildUiSchema: (config: any) => any;
7
12
  export default buildUiSchema;
@@ -24,8 +24,8 @@ export declare const ValidationSection: {
24
24
  main: {
25
25
  label: string;
26
26
  options: {
27
- title: string;
28
27
  const: string;
28
+ title: string;
29
29
  }[];
30
30
  };
31
31
  };
@@ -5,5 +5,5 @@ export { default as pageService } from "../runtime/services/service";
5
5
  export { schema } from "../builder/build/buildUiSchema";
6
6
  export { default as buildConfig } from "../builder/build/buildConfig";
7
7
  export { default as buildUiSchema } from "../builder/build/buildUiSchema";
8
- export { default as buildSchema } from "../builder/build/buildSchema";
8
+ export { buildSchema } from "../builder/build/buildUiSchema";
9
9
  export { default as clearPreviousCache } from "../builder/services/clearLocalStorage";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impaktapps-ui-builder",
3
- "version": "0.0.279",
3
+ "version": "0.0.281",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "tsc && vite build",
@@ -34,29 +34,78 @@ import { buildCheckbox } from "./buildCheckbox";
34
34
  import { buildLineGraph } from "./buildLineGraph";
35
35
  import { buildRadio } from "./buildRadio";
36
36
  import { buildEmptyBox } from "./buildEmptyBox";
37
- export let schema = {
37
+ export let schema = {
38
38
  type: "object",
39
39
  properties: {},
40
40
  required: []
41
41
  };
42
- function buildRule(configObj: any) {
42
+
43
+ function buildRule(configObj: any, tableName?: string) {
43
44
  if (configObj.validation) {
44
45
  configObj.validation.forEach((rule: any) => {
45
- if (!schema.properties[configObj.name]) {
46
- schema.properties[configObj.name] = {};
47
- }
48
- if (rule.validationType === "required") {
49
- schema.required.push(configObj.name)
46
+ if (tableName) {
47
+ if (schema.properties?.[tableName]?.items?.properties) {
48
+ if (!schema.properties?.[tableName]?.items?.properties?.[configObj.name]) {
49
+ schema.properties[tableName].items.properties[configObj.name] = {};
50
+ }
51
+ if (rule.validationType === "required") {
52
+ schema.properties?.[tableName]?.items?.required.push(configObj.name)
53
+ } else {
54
+ schema.properties[tableName].items.properties[configObj.name]["type"] = "string"
55
+ schema.properties[tableName].items.properties[configObj.name][rule.validationType] =
56
+ isNaN(rule.validationValue) ?
57
+ rule.validationValue : Number(rule.validationValue)
58
+ }
59
+
60
+ }
50
61
  } else {
51
- schema.properties[configObj.name]["type"] = "string"
52
- schema.properties[configObj.name][rule.validationType] =
53
- isNaN(rule.validationValue) ?
54
- rule.validationValue : Number(rule.validationValue)
62
+
63
+ if (!schema.properties[configObj.name]) {
64
+ schema.properties[configObj.name] = {};
65
+ }
66
+ if (rule.validationType === "required") {
67
+ schema.required.push(configObj.name)
68
+ } else {
69
+ schema.properties[configObj.name]["type"] = "string"
70
+ schema.properties[configObj.name][rule.validationType] =
71
+ isNaN(rule.validationValue) ?
72
+ rule.validationValue : Number(rule.validationValue)
73
+ }
74
+
75
+
76
+
55
77
  }
56
78
  });
57
79
  }
58
80
 
59
81
  }
82
+ export const buildSchema = (config: any, tableName?: string) => {
83
+ buildRule(config, tableName);
84
+ if (config?.elements) {
85
+
86
+ if (config.type == "Table") {
87
+ if (!schema.properties[config.name]) {
88
+ schema.properties[config.name] = {
89
+ type: "array",
90
+ items: {
91
+ type: "object",
92
+ properties: {},
93
+ required: []
94
+ }
95
+ }
96
+ }
97
+ config.elements.map((e, elemInd) => {
98
+ buildSchema(e, config.name)
99
+ })
100
+ }
101
+ else {
102
+ config.elements.map((e, elemInd) => {
103
+ buildSchema(e)
104
+ })
105
+ }
106
+ }
107
+ return schema;
108
+ }
60
109
 
61
110
 
62
111
  const buildUiSchema = (config: any) => {
@@ -75,48 +124,37 @@ const buildUiSchema = (config: any) => {
75
124
  break;
76
125
  case "Text":
77
126
  elements = buildTextField(config, componentScope);
78
- buildRule(config);
79
127
  break;
80
128
  case "TextArea":
81
129
  elements = buildTextArea(config, componentScope)
82
- buildRule(config);
83
130
  break;
84
131
  case "Date":
85
132
  elements = buildDate(config, componentScope);
86
- buildRule(config);
87
133
  break;
88
134
  case "Select":
89
135
  elements = buildSelect(config, componentScope);
90
- buildRule(config);
91
136
  break;
92
137
  case "Radio":
93
138
  elements = buildRadio(config, componentScope);
94
- buildRule(config);
95
139
  break;
96
140
  case "Button":
97
141
 
98
142
  elements = buildButton(config, componentScope);
99
- buildRule(config);
100
143
  break;
101
144
  case "Table":
102
145
  elements = buildTable(config, componentScope);
103
- buildRule(config);
104
146
  break;
105
147
  case "Box":
106
148
  elements = buildLabel(config, componentScope);
107
- buildRule(config);
108
149
  break;
109
150
  case "CheckBox":
110
151
  elements = buildCheckbox(config, componentScope);
111
- buildRule(config);
112
152
  break;
113
153
  case "UploadFile":
114
154
  elements = buildUploadFile(config, componentScope);
115
- buildRule(config);
116
155
  break;
117
156
  case "DownloadFile":
118
157
  elements = buildDownloadFile(config, componentScope);
119
- buildRule(config);
120
158
  break;
121
159
  case "EmptyBox":
122
160
  elements = buildEmptyBox(config, componentScope);
@@ -165,7 +203,6 @@ const buildUiSchema = (config: any) => {
165
203
 
166
204
  case "MultipleSelect":
167
205
  elements = buildMultiSelect(config, componentScope);
168
- buildRule(config);
169
206
  break;
170
207
  case "LeaderBoard":
171
208
  elements = buildLeaderBoard(config);
@@ -204,7 +241,6 @@ const buildUiSchema = (config: any) => {
204
241
  });
205
242
  }
206
243
  }
207
- localStorage.setItem("libSchema", JSON.stringify(schema || {}))
208
244
  return elements;
209
245
  }
210
246
 
@@ -1,7 +1,7 @@
1
1
  export const ValidationSection = {
2
2
  type: "HorizontalLayout",
3
3
  elements: [
4
- {
4
+ {
5
5
  type: "Control",
6
6
  scope: "#/properties/validation",
7
7
  layout: 11.5,
@@ -27,10 +27,10 @@ export const ValidationSection = {
27
27
  main: {
28
28
  label: "Validation Type",
29
29
  options: [
30
- { title: "required", const: "Required" },
31
- { title: "minLength", const: "Minimum Length" },
32
- { title: "maxLength", const: "Maximum Length" },
33
- { title: "pattern", const: "Pattern" },
30
+ { const: "required", title: "Required" },
31
+ { const: "minLength", title: "Minimum Length" },
32
+ { const: "maxLength", title: "Maximum Length" },
33
+ { const: "pattern", title: "Pattern" },
34
34
  ]
35
35
  },
36
36
  },
@@ -6,5 +6,5 @@ export {default as pageService} from "../runtime/services/service"
6
6
  export { schema} from "../builder/build/buildUiSchema"
7
7
  export {default as buildConfig} from "../builder/build/buildConfig"
8
8
  export {default as buildUiSchema} from "../builder/build/buildUiSchema"
9
- export {default as buildSchema} from "../builder/build/buildSchema"
9
+ export {buildSchema} from "../builder/build/buildUiSchema"
10
10
  export {default as clearPreviousCache} from "../builder/services/clearLocalStorage"
@@ -1,6 +0,0 @@
1
- export declare const buildSchema: (config: any) => {
2
- type: string;
3
- properties: {};
4
- required: any[];
5
- };
6
- export default buildSchema;