@apexcura/core 0.0.14 → 0.0.15-Beta1

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.
package/dist/index.d.mts CHANGED
@@ -4,38 +4,151 @@ type styling = {
4
4
  horizontalGutter?: number;
5
5
  verticalGutter?: number;
6
6
  };
7
- type ElementExecutorProps = {
7
+ type FormExecutorProps = {
8
8
  data: {
9
- visible?: boolean;
10
- className?: string;
11
- sectionName?: string;
12
- sectionLabel?: string;
13
- sectionOrder?: number;
14
- colCount: number;
15
- fields: {
9
+ className: string;
10
+ schema?: {
16
11
  name?: string;
17
12
  label?: string;
18
- placeholder?: string;
19
- element?: string;
20
- type?: string;
21
- value?: string | number | boolean | any[] | object[];
22
- fieldNames?: any[];
23
- dropDownOptions?: any[];
13
+ source?: string;
24
14
  visible?: boolean;
15
+ element?: string;
16
+ className?: string;
17
+ action?: string;
18
+ order?: number;
19
+ sie?: string;
20
+ colCount?: number;
25
21
  disabled?: boolean;
26
- required: boolean;
27
- prefix?: React.ReactNode;
28
- suffix?: React.ReactNode;
29
- addonBefore?: React.ReactNode;
30
- defaultValue?: string;
31
- status?: "error" | "warning";
32
- styles?: React.CSSProperties;
33
- fieldClassName?: string;
34
- elementClassName?: string;
35
- variant?: "outlined" | "borderless" | "filled";
22
+ activeClassName?: string;
23
+ listClassName?: string;
24
+ listItemClassName?: string;
25
+ buttonClassName?: string;
26
+ icon?: string;
27
+ placement?: string;
28
+ profileImageClassName?: string;
29
+ value?: string | number | boolean | any[] | object[] | null;
30
+ img?: string;
31
+ primaryText?: string;
32
+ secondaryText?: string;
33
+ count?: number;
34
+ profileImage?: string;
35
+ profileSubClassName?: string;
36
+ subContainerClassName?: string;
37
+ secondTextClassName?: string;
38
+ iconsClassName?: string;
39
+ labelClassName?: string;
40
+ modalContent?: {
41
+ className?: string;
42
+ fields?: {
43
+ _id?: string;
44
+ name?: string;
45
+ label?: string;
46
+ source?: string;
47
+ initial_message?: boolean;
48
+ element: string;
49
+ className?: string;
50
+ position?: string;
51
+ }[];
52
+ };
53
+ items?: {
54
+ icon?: React.JSX.Element;
55
+ label?: string;
56
+ active?: boolean;
57
+ text?: string;
58
+ time?: string;
59
+ }[];
60
+ fields?: {
61
+ name?: string;
62
+ label?: string;
63
+ placeholder?: string;
64
+ element?: string;
65
+ type?: string;
66
+ value?: string | number | boolean | any[] | object[] | null;
67
+ fieldNames?: any[];
68
+ optionType?: string;
69
+ options?: {
70
+ label: string;
71
+ value: string;
72
+ className?: string;
73
+ selectedClassName?: string;
74
+ }[];
75
+ dropDownOptions?: any[];
76
+ visible?: boolean;
77
+ disabled?: boolean;
78
+ required?: boolean;
79
+ prefix?: React.ReactNode;
80
+ suffix?: React.ReactNode;
81
+ addonBefore?: React.ReactNode;
82
+ defaultValue?: string;
83
+ status?: "error" | "warning";
84
+ styles?: React.CSSProperties;
85
+ fieldClassName?: string;
86
+ elementClassName?: string;
87
+ variant?: "outlined" | "borderless" | "filled";
88
+ thead?: {
89
+ id: number;
90
+ name?: string;
91
+ label?: string;
92
+ visible?: boolean;
93
+ required?: boolean;
94
+ key?: string;
95
+ }[];
96
+ tbody?: {
97
+ id?: number;
98
+ name?: string;
99
+ label?: string;
100
+ element?: string;
101
+ type?: string;
102
+ variable_data?: {
103
+ id: {
104
+ id?: number;
105
+ };
106
+ Route?: {
107
+ label: string;
108
+ element: string;
109
+ type: string;
110
+ };
111
+ Dose?: {
112
+ label: string;
113
+ element: string;
114
+ type: string;
115
+ };
116
+ Frequency?: {
117
+ label: string;
118
+ element: string;
119
+ type: string;
120
+ };
121
+ When?: {
122
+ label: string;
123
+ element: string;
124
+ type: string;
125
+ };
126
+ Duration?: {
127
+ label: string;
128
+ element: string;
129
+ type: string;
130
+ };
131
+ Instructions?: {
132
+ label: string;
133
+ element: string;
134
+ type: string;
135
+ };
136
+ SubRows?: {
137
+ label: string;
138
+ };
139
+ }[];
140
+ }[];
141
+ payload_keys?: string[];
142
+ api_endpoint?: string;
143
+ next_id?: string;
144
+ action?: string;
145
+ }[];
36
146
  }[];
37
- }[];
147
+ };
148
+ setData: Function;
149
+ selectedRecord: Function;
38
150
  };
39
- declare const ElementExecutor: (props: ElementExecutorProps & styling) => React.JSX.Element;
151
+ type ElementExecutorProps = FormExecutorProps & styling;
152
+ declare const ElementExecutor: (props: ElementExecutorProps) => React.JSX.Element;
40
153
 
41
154
  export { ElementExecutor };
package/dist/index.d.ts CHANGED
@@ -4,38 +4,151 @@ type styling = {
4
4
  horizontalGutter?: number;
5
5
  verticalGutter?: number;
6
6
  };
7
- type ElementExecutorProps = {
7
+ type FormExecutorProps = {
8
8
  data: {
9
- visible?: boolean;
10
- className?: string;
11
- sectionName?: string;
12
- sectionLabel?: string;
13
- sectionOrder?: number;
14
- colCount: number;
15
- fields: {
9
+ className: string;
10
+ schema?: {
16
11
  name?: string;
17
12
  label?: string;
18
- placeholder?: string;
19
- element?: string;
20
- type?: string;
21
- value?: string | number | boolean | any[] | object[];
22
- fieldNames?: any[];
23
- dropDownOptions?: any[];
13
+ source?: string;
24
14
  visible?: boolean;
15
+ element?: string;
16
+ className?: string;
17
+ action?: string;
18
+ order?: number;
19
+ sie?: string;
20
+ colCount?: number;
25
21
  disabled?: boolean;
26
- required: boolean;
27
- prefix?: React.ReactNode;
28
- suffix?: React.ReactNode;
29
- addonBefore?: React.ReactNode;
30
- defaultValue?: string;
31
- status?: "error" | "warning";
32
- styles?: React.CSSProperties;
33
- fieldClassName?: string;
34
- elementClassName?: string;
35
- variant?: "outlined" | "borderless" | "filled";
22
+ activeClassName?: string;
23
+ listClassName?: string;
24
+ listItemClassName?: string;
25
+ buttonClassName?: string;
26
+ icon?: string;
27
+ placement?: string;
28
+ profileImageClassName?: string;
29
+ value?: string | number | boolean | any[] | object[] | null;
30
+ img?: string;
31
+ primaryText?: string;
32
+ secondaryText?: string;
33
+ count?: number;
34
+ profileImage?: string;
35
+ profileSubClassName?: string;
36
+ subContainerClassName?: string;
37
+ secondTextClassName?: string;
38
+ iconsClassName?: string;
39
+ labelClassName?: string;
40
+ modalContent?: {
41
+ className?: string;
42
+ fields?: {
43
+ _id?: string;
44
+ name?: string;
45
+ label?: string;
46
+ source?: string;
47
+ initial_message?: boolean;
48
+ element: string;
49
+ className?: string;
50
+ position?: string;
51
+ }[];
52
+ };
53
+ items?: {
54
+ icon?: React.JSX.Element;
55
+ label?: string;
56
+ active?: boolean;
57
+ text?: string;
58
+ time?: string;
59
+ }[];
60
+ fields?: {
61
+ name?: string;
62
+ label?: string;
63
+ placeholder?: string;
64
+ element?: string;
65
+ type?: string;
66
+ value?: string | number | boolean | any[] | object[] | null;
67
+ fieldNames?: any[];
68
+ optionType?: string;
69
+ options?: {
70
+ label: string;
71
+ value: string;
72
+ className?: string;
73
+ selectedClassName?: string;
74
+ }[];
75
+ dropDownOptions?: any[];
76
+ visible?: boolean;
77
+ disabled?: boolean;
78
+ required?: boolean;
79
+ prefix?: React.ReactNode;
80
+ suffix?: React.ReactNode;
81
+ addonBefore?: React.ReactNode;
82
+ defaultValue?: string;
83
+ status?: "error" | "warning";
84
+ styles?: React.CSSProperties;
85
+ fieldClassName?: string;
86
+ elementClassName?: string;
87
+ variant?: "outlined" | "borderless" | "filled";
88
+ thead?: {
89
+ id: number;
90
+ name?: string;
91
+ label?: string;
92
+ visible?: boolean;
93
+ required?: boolean;
94
+ key?: string;
95
+ }[];
96
+ tbody?: {
97
+ id?: number;
98
+ name?: string;
99
+ label?: string;
100
+ element?: string;
101
+ type?: string;
102
+ variable_data?: {
103
+ id: {
104
+ id?: number;
105
+ };
106
+ Route?: {
107
+ label: string;
108
+ element: string;
109
+ type: string;
110
+ };
111
+ Dose?: {
112
+ label: string;
113
+ element: string;
114
+ type: string;
115
+ };
116
+ Frequency?: {
117
+ label: string;
118
+ element: string;
119
+ type: string;
120
+ };
121
+ When?: {
122
+ label: string;
123
+ element: string;
124
+ type: string;
125
+ };
126
+ Duration?: {
127
+ label: string;
128
+ element: string;
129
+ type: string;
130
+ };
131
+ Instructions?: {
132
+ label: string;
133
+ element: string;
134
+ type: string;
135
+ };
136
+ SubRows?: {
137
+ label: string;
138
+ };
139
+ }[];
140
+ }[];
141
+ payload_keys?: string[];
142
+ api_endpoint?: string;
143
+ next_id?: string;
144
+ action?: string;
145
+ }[];
36
146
  }[];
37
- }[];
147
+ };
148
+ setData: Function;
149
+ selectedRecord: Function;
38
150
  };
39
- declare const ElementExecutor: (props: ElementExecutorProps & styling) => React.JSX.Element;
151
+ type ElementExecutorProps = FormExecutorProps & styling;
152
+ declare const ElementExecutor: (props: ElementExecutorProps) => React.JSX.Element;
40
153
 
41
154
  export { ElementExecutor };
package/dist/index.js CHANGED
@@ -96,76 +96,161 @@ function postService(url, method, data) {
96
96
  }
97
97
 
98
98
  // src/libraries/element-executor.tsx
99
- var import_antd = require("antd");
100
99
  var ElementExecutor = (props) => {
101
- const [formData, setFormData] = (0, import_react.useState)({});
102
100
  const [data, setData] = (0, import_react.useState)([]);
101
+ const [schema, setSchema] = (0, import_react.useState)(props.data.schema);
103
102
  const onHandleChange = (name, value) => {
104
- setFormData((prev) => ({ ...prev, [name]: value }));
103
+ let prev = schema;
104
+ prev?.map((fie) => {
105
+ if (fie.name === name) {
106
+ fie["value"] = value;
107
+ }
108
+ if (fie.element === "radio=input") {
109
+ fie.options.map((eachOption) => {
110
+ if (eachOption.name === name) {
111
+ props.selectedRecord(value);
112
+ }
113
+ });
114
+ }
115
+ if (fie.fields && fie.fields.length) {
116
+ fie.fields.map((sub) => {
117
+ if (sub.name === name) {
118
+ sub["value"] = value;
119
+ props.selectedRecord(fie);
120
+ }
121
+ return sub;
122
+ });
123
+ }
124
+ return fie;
125
+ });
126
+ setSchema([...prev]);
127
+ props.setData({ ...props.data, schema: prev });
105
128
  };
106
- (0, import_react.useEffect)(() => {
107
- const fetchData = async () => {
108
- try {
109
- const response = await postService("/products/", "POST", []);
110
- if (response !== false && typeof response === "object") {
111
- setData(response.products);
112
- }
113
- } catch (error) {
114
- console.log(error);
129
+ const handleSelectData = async () => {
130
+ try {
131
+ const response = await postService("/products/", "POST", []);
132
+ if (response !== false && typeof response === "object") {
133
+ setData(response.products);
115
134
  }
116
- };
117
- fetchData();
118
- }, []);
119
- const onHandleSubmit = async () => {
120
- console.log(formData);
135
+ } catch (error) {
136
+ console.log(error);
137
+ }
121
138
  };
122
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, props.data.map((eachSection) => {
123
- if (eachSection.visible) {
124
- return /* @__PURE__ */ import_react.default.createElement(import_antd.Row, { gutter: [props.horizontalGutter, props.verticalGutter] }, /* @__PURE__ */ import_react.default.createElement("h3", null, eachSection.sectionLabel), /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { span: 24 / eachSection.colCount, className: `${eachSection.className}` }, eachSection.fields.map(
125
- (eachField) => {
126
- if (eachField.visible && eachField.element === "input-text") {
127
- return /* @__PURE__ */ import_react.default.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ import_react.default.createElement(import_ui_components.TextElement, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
128
- } else if (eachField.visible && eachField.element === "input-number") {
129
- return /* @__PURE__ */ import_react.default.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ import_react.default.createElement(import_ui_components.NumberElement, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
130
- } else if (eachField.visible && eachField.element === "input-gender") {
131
- return /* @__PURE__ */ import_react.default.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ import_react.default.createElement(import_ui_components.SelectElement, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
132
- } else if (eachField.visible && eachField.element === "input-mobile") {
133
- return /* @__PURE__ */ import_react.default.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ import_react.default.createElement(import_ui_components.NumberElement, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
134
- } else if (eachField.visible && eachField.element === "input-textarea") {
135
- return /* @__PURE__ */ import_react.default.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ import_react.default.createElement(import_ui_components.TextareaElement, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
136
- } else if (eachField.visible && eachField.element === "input-checkbox") {
137
- return /* @__PURE__ */ import_react.default.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ import_react.default.createElement(import_ui_components.CheckboxElement, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
138
- } else if (eachField.visible && eachField.element === "input-radio") {
139
- return /* @__PURE__ */ import_react.default.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ import_react.default.createElement(import_ui_components.RadioElement, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
140
- } else if (eachField.visible && eachField.element === "input-description") {
141
- return /* @__PURE__ */ import_react.default.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ import_react.default.createElement(import_ui_components.CkEditor, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
142
- } else if (eachField.visible && eachField.element === "input-single-select") {
143
- return /* @__PURE__ */ import_react.default.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ import_react.default.createElement(
144
- import_ui_components.SingleSelectElement,
145
- {
146
- ...eachField,
147
- dropDownOptions: data.length > 0 ? data : [],
148
- onChange: (value) => onHandleChange(eachField.name || "", value)
149
- }
150
- ));
151
- } else if (eachField.visible && eachField.element === "input-multiple-select") {
152
- return /* @__PURE__ */ import_react.default.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ import_react.default.createElement(
153
- import_ui_components.MultipleSelectElement,
154
- {
155
- ...eachField,
156
- onChange: (value) => onHandleChange(eachField.name || "", value),
157
- dropDownOptions: data.length > 0 ? data : []
158
- }
159
- ));
160
- } else {
161
- return null;
139
+ const renderElement = (elementProps) => {
140
+ switch (elementProps.element) {
141
+ case "input-text":
142
+ return /* @__PURE__ */ import_react.default.createElement(
143
+ import_ui_components.TextElement,
144
+ {
145
+ ...elementProps,
146
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
162
147
  }
163
- return null;
164
- }
165
- )));
148
+ );
149
+ case "input-number":
150
+ return /* @__PURE__ */ import_react.default.createElement(
151
+ import_ui_components.NumberElement,
152
+ {
153
+ ...elementProps,
154
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
155
+ }
156
+ );
157
+ case "input-textarea":
158
+ return /* @__PURE__ */ import_react.default.createElement(
159
+ import_ui_components.TextareaElement,
160
+ {
161
+ ...elementProps,
162
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
163
+ }
164
+ );
165
+ case "input-gender":
166
+ return /* @__PURE__ */ import_react.default.createElement(
167
+ import_ui_components.SelectElement,
168
+ {
169
+ ...elementProps,
170
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
171
+ }
172
+ );
173
+ case "input-mobile":
174
+ return /* @__PURE__ */ import_react.default.createElement(
175
+ import_ui_components.NumberElement,
176
+ {
177
+ ...elementProps,
178
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
179
+ }
180
+ );
181
+ case "input-checkbox":
182
+ return /* @__PURE__ */ import_react.default.createElement(
183
+ import_ui_components.CheckboxElement,
184
+ {
185
+ ...elementProps,
186
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
187
+ }
188
+ );
189
+ case "input-radio":
190
+ return /* @__PURE__ */ import_react.default.createElement(
191
+ import_ui_components.RadioElement,
192
+ {
193
+ ...elementProps,
194
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
195
+ }
196
+ );
197
+ case "input-description":
198
+ return /* @__PURE__ */ import_react.default.createElement(
199
+ import_ui_components.CkEditor,
200
+ {
201
+ ...elementProps,
202
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
203
+ }
204
+ );
205
+ case "input-single-select":
206
+ return /* @__PURE__ */ import_react.default.createElement(
207
+ import_ui_components.SingleSelectElement,
208
+ {
209
+ ...elementProps,
210
+ dropDownOptions: data.length > 0 ? data : [],
211
+ onChange: (value) => onHandleChange(elementProps.name || "", value),
212
+ onClick: handleSelectData
213
+ }
214
+ );
215
+ case "input-multiple-select":
216
+ return /* @__PURE__ */ import_react.default.createElement(
217
+ import_ui_components.MultipleSelectElement,
218
+ {
219
+ ...elementProps,
220
+ dropDownOptions: data.length > 0 ? data : [],
221
+ onChange: (value) => onHandleChange(elementProps.name || "", value),
222
+ onClick: handleSelectData
223
+ }
224
+ );
225
+ case "add-more":
226
+ return /* @__PURE__ */ import_react.default.createElement(import_ui_components.AddMoreTable, { ...elementProps });
227
+ case "div":
228
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: elementProps.className }, elementProps.label);
229
+ case "button":
230
+ return /* @__PURE__ */ import_react.default.createElement(import_ui_components.ButtonElement, { ...elementProps });
231
+ case "sidebar":
232
+ return /* @__PURE__ */ import_react.default.createElement(import_ui_components.Sidebar, { ...elementProps, onChange: (value) => onHandleChange(elementProps.name || "", value) });
233
+ case "navbar":
234
+ return /* @__PURE__ */ import_react.default.createElement(import_ui_components.Navbar, { ...elementProps });
235
+ case "table":
236
+ return /* @__PURE__ */ import_react.default.createElement(import_ui_components.TableElement, { ...elementProps, onChange: (value) => onHandleChange(elementProps.name || "", value) });
237
+ case "daterangepicker":
238
+ return /* @__PURE__ */ import_react.default.createElement(import_ui_components.DateRangePickerElement, { ...elementProps, onChange: (value) => onHandleChange(elementProps.name || "", value) });
239
+ case "datepicker":
240
+ return /* @__PURE__ */ import_react.default.createElement(import_ui_components.DatePickerElement, { ...elementProps, onChange: (value) => onHandleChange(elementProps.name || "", value) });
241
+ default:
242
+ return null;
166
243
  }
167
- return null;
168
- }), /* @__PURE__ */ import_react.default.createElement("div", { onClick: onHandleSubmit }, /* @__PURE__ */ import_react.default.createElement(import_ui_components.ButtonElement, null)));
244
+ };
245
+ const renderFields = (schema2) => {
246
+ return schema2 && schema2.map((eachSection) => {
247
+ if (eachSection.visible !== false) {
248
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, eachSection.fields && eachSection.fields.length > 0 ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, renderElement(eachSection), /* @__PURE__ */ import_react.default.createElement("div", { className: eachSection.className, key: eachSection.name }, eachSection.label && /* @__PURE__ */ import_react.default.createElement("p", { className: eachSection.labelClassName }, eachSection.label), renderFields(eachSection.fields))) : renderElement(eachSection));
249
+ }
250
+ return null;
251
+ });
252
+ };
253
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: props.data.className }, renderFields(schema)));
169
254
  };
170
255
  // Annotate the CommonJS export names for ESM import in node:
171
256
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -1,6 +1,23 @@
1
1
  // src/libraries/element-executor.tsx
2
- import React, { useEffect, useState } from "react";
3
- import { TextElement, NumberElement, TextareaElement, SelectElement, ButtonElement, RadioElement, CheckboxElement, CkEditor, SingleSelectElement, MultipleSelectElement } from "@apexcura/ui-components";
2
+ import React, { useState } from "react";
3
+ import {
4
+ TextElement,
5
+ NumberElement,
6
+ TextareaElement,
7
+ SelectElement,
8
+ ButtonElement,
9
+ RadioElement,
10
+ CheckboxElement,
11
+ CkEditor,
12
+ SingleSelectElement,
13
+ MultipleSelectElement,
14
+ AddMoreTable,
15
+ Sidebar,
16
+ Navbar,
17
+ TableElement,
18
+ DateRangePickerElement,
19
+ DatePickerElement
20
+ } from "@apexcura/ui-components";
4
21
 
5
22
  // src/services/http-service.tsx
6
23
  import axios from "axios";
@@ -60,76 +77,161 @@ function postService(url, method, data) {
60
77
  }
61
78
 
62
79
  // src/libraries/element-executor.tsx
63
- import { Col, Row } from "antd";
64
80
  var ElementExecutor = (props) => {
65
- const [formData, setFormData] = useState({});
66
81
  const [data, setData] = useState([]);
82
+ const [schema, setSchema] = useState(props.data.schema);
67
83
  const onHandleChange = (name, value) => {
68
- setFormData((prev) => ({ ...prev, [name]: value }));
84
+ let prev = schema;
85
+ prev?.map((fie) => {
86
+ if (fie.name === name) {
87
+ fie["value"] = value;
88
+ }
89
+ if (fie.element === "radio=input") {
90
+ fie.options.map((eachOption) => {
91
+ if (eachOption.name === name) {
92
+ props.selectedRecord(value);
93
+ }
94
+ });
95
+ }
96
+ if (fie.fields && fie.fields.length) {
97
+ fie.fields.map((sub) => {
98
+ if (sub.name === name) {
99
+ sub["value"] = value;
100
+ props.selectedRecord(fie);
101
+ }
102
+ return sub;
103
+ });
104
+ }
105
+ return fie;
106
+ });
107
+ setSchema([...prev]);
108
+ props.setData({ ...props.data, schema: prev });
69
109
  };
70
- useEffect(() => {
71
- const fetchData = async () => {
72
- try {
73
- const response = await postService("/products/", "POST", []);
74
- if (response !== false && typeof response === "object") {
75
- setData(response.products);
76
- }
77
- } catch (error) {
78
- console.log(error);
110
+ const handleSelectData = async () => {
111
+ try {
112
+ const response = await postService("/products/", "POST", []);
113
+ if (response !== false && typeof response === "object") {
114
+ setData(response.products);
79
115
  }
80
- };
81
- fetchData();
82
- }, []);
83
- const onHandleSubmit = async () => {
84
- console.log(formData);
116
+ } catch (error) {
117
+ console.log(error);
118
+ }
85
119
  };
86
- return /* @__PURE__ */ React.createElement(React.Fragment, null, props.data.map((eachSection) => {
87
- if (eachSection.visible) {
88
- return /* @__PURE__ */ React.createElement(Row, { gutter: [props.horizontalGutter, props.verticalGutter] }, /* @__PURE__ */ React.createElement("h3", null, eachSection.sectionLabel), /* @__PURE__ */ React.createElement(Col, { span: 24 / eachSection.colCount, className: `${eachSection.className}` }, eachSection.fields.map(
89
- (eachField) => {
90
- if (eachField.visible && eachField.element === "input-text") {
91
- return /* @__PURE__ */ React.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ React.createElement(TextElement, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
92
- } else if (eachField.visible && eachField.element === "input-number") {
93
- return /* @__PURE__ */ React.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ React.createElement(NumberElement, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
94
- } else if (eachField.visible && eachField.element === "input-gender") {
95
- return /* @__PURE__ */ React.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ React.createElement(SelectElement, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
96
- } else if (eachField.visible && eachField.element === "input-mobile") {
97
- return /* @__PURE__ */ React.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ React.createElement(NumberElement, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
98
- } else if (eachField.visible && eachField.element === "input-textarea") {
99
- return /* @__PURE__ */ React.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ React.createElement(TextareaElement, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
100
- } else if (eachField.visible && eachField.element === "input-checkbox") {
101
- return /* @__PURE__ */ React.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ React.createElement(CheckboxElement, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
102
- } else if (eachField.visible && eachField.element === "input-radio") {
103
- return /* @__PURE__ */ React.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ React.createElement(RadioElement, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
104
- } else if (eachField.visible && eachField.element === "input-description") {
105
- return /* @__PURE__ */ React.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ React.createElement(CkEditor, { ...eachField, onChange: (value) => onHandleChange(eachField.name || "", value) }));
106
- } else if (eachField.visible && eachField.element === "input-single-select") {
107
- return /* @__PURE__ */ React.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ React.createElement(
108
- SingleSelectElement,
109
- {
110
- ...eachField,
111
- dropDownOptions: data.length > 0 ? data : [],
112
- onChange: (value) => onHandleChange(eachField.name || "", value)
113
- }
114
- ));
115
- } else if (eachField.visible && eachField.element === "input-multiple-select") {
116
- return /* @__PURE__ */ React.createElement("div", { className: `${eachField.fieldClassName}` }, /* @__PURE__ */ React.createElement(
117
- MultipleSelectElement,
118
- {
119
- ...eachField,
120
- onChange: (value) => onHandleChange(eachField.name || "", value),
121
- dropDownOptions: data.length > 0 ? data : []
122
- }
123
- ));
124
- } else {
125
- return null;
120
+ const renderElement = (elementProps) => {
121
+ switch (elementProps.element) {
122
+ case "input-text":
123
+ return /* @__PURE__ */ React.createElement(
124
+ TextElement,
125
+ {
126
+ ...elementProps,
127
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
126
128
  }
127
- return null;
128
- }
129
- )));
129
+ );
130
+ case "input-number":
131
+ return /* @__PURE__ */ React.createElement(
132
+ NumberElement,
133
+ {
134
+ ...elementProps,
135
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
136
+ }
137
+ );
138
+ case "input-textarea":
139
+ return /* @__PURE__ */ React.createElement(
140
+ TextareaElement,
141
+ {
142
+ ...elementProps,
143
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
144
+ }
145
+ );
146
+ case "input-gender":
147
+ return /* @__PURE__ */ React.createElement(
148
+ SelectElement,
149
+ {
150
+ ...elementProps,
151
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
152
+ }
153
+ );
154
+ case "input-mobile":
155
+ return /* @__PURE__ */ React.createElement(
156
+ NumberElement,
157
+ {
158
+ ...elementProps,
159
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
160
+ }
161
+ );
162
+ case "input-checkbox":
163
+ return /* @__PURE__ */ React.createElement(
164
+ CheckboxElement,
165
+ {
166
+ ...elementProps,
167
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
168
+ }
169
+ );
170
+ case "input-radio":
171
+ return /* @__PURE__ */ React.createElement(
172
+ RadioElement,
173
+ {
174
+ ...elementProps,
175
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
176
+ }
177
+ );
178
+ case "input-description":
179
+ return /* @__PURE__ */ React.createElement(
180
+ CkEditor,
181
+ {
182
+ ...elementProps,
183
+ onChange: (value) => onHandleChange(elementProps.name || "", value)
184
+ }
185
+ );
186
+ case "input-single-select":
187
+ return /* @__PURE__ */ React.createElement(
188
+ SingleSelectElement,
189
+ {
190
+ ...elementProps,
191
+ dropDownOptions: data.length > 0 ? data : [],
192
+ onChange: (value) => onHandleChange(elementProps.name || "", value),
193
+ onClick: handleSelectData
194
+ }
195
+ );
196
+ case "input-multiple-select":
197
+ return /* @__PURE__ */ React.createElement(
198
+ MultipleSelectElement,
199
+ {
200
+ ...elementProps,
201
+ dropDownOptions: data.length > 0 ? data : [],
202
+ onChange: (value) => onHandleChange(elementProps.name || "", value),
203
+ onClick: handleSelectData
204
+ }
205
+ );
206
+ case "add-more":
207
+ return /* @__PURE__ */ React.createElement(AddMoreTable, { ...elementProps });
208
+ case "div":
209
+ return /* @__PURE__ */ React.createElement("div", { className: elementProps.className }, elementProps.label);
210
+ case "button":
211
+ return /* @__PURE__ */ React.createElement(ButtonElement, { ...elementProps });
212
+ case "sidebar":
213
+ return /* @__PURE__ */ React.createElement(Sidebar, { ...elementProps, onChange: (value) => onHandleChange(elementProps.name || "", value) });
214
+ case "navbar":
215
+ return /* @__PURE__ */ React.createElement(Navbar, { ...elementProps });
216
+ case "table":
217
+ return /* @__PURE__ */ React.createElement(TableElement, { ...elementProps, onChange: (value) => onHandleChange(elementProps.name || "", value) });
218
+ case "daterangepicker":
219
+ return /* @__PURE__ */ React.createElement(DateRangePickerElement, { ...elementProps, onChange: (value) => onHandleChange(elementProps.name || "", value) });
220
+ case "datepicker":
221
+ return /* @__PURE__ */ React.createElement(DatePickerElement, { ...elementProps, onChange: (value) => onHandleChange(elementProps.name || "", value) });
222
+ default:
223
+ return null;
130
224
  }
131
- return null;
132
- }), /* @__PURE__ */ React.createElement("div", { onClick: onHandleSubmit }, /* @__PURE__ */ React.createElement(ButtonElement, null)));
225
+ };
226
+ const renderFields = (schema2) => {
227
+ return schema2 && schema2.map((eachSection) => {
228
+ if (eachSection.visible !== false) {
229
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, eachSection.fields && eachSection.fields.length > 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, renderElement(eachSection), /* @__PURE__ */ React.createElement("div", { className: eachSection.className, key: eachSection.name }, eachSection.label && /* @__PURE__ */ React.createElement("p", { className: eachSection.labelClassName }, eachSection.label), renderFields(eachSection.fields))) : renderElement(eachSection));
230
+ }
231
+ return null;
232
+ });
233
+ };
234
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: props.data.className }, renderFields(schema)));
133
235
  };
134
236
  export {
135
237
  ElementExecutor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/core",
3
- "version": "0.0.14",
3
+ "version": "0.0.15-Beta1",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",
@@ -28,7 +28,7 @@
28
28
  "build": "tsup"
29
29
  },
30
30
  "dependencies": {
31
- "@apexcura/ui-components": "^0.0.9-Beta7",
31
+ "@apexcura/ui-components": "^0.0.13-Beta0",
32
32
  "@testing-library/jest-dom": "^6.4.2",
33
33
  "@testing-library/react": "^15.0.6",
34
34
  "@types/react-global-configuration": "^1.3.3",