@apexcura/core 0.0.17-Beta33 → 0.0.17-Beta331

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.mjs DELETED
@@ -1,422 +0,0 @@
1
- // src/libraries/element-executor.tsx
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
- Image,
21
- PasswordElement,
22
- SingleCheckbox,
23
- DropDownGroup,
24
- FileUpload,
25
- TabsElement,
26
- Upload,
27
- OtpElement,
28
- CircleDonut,
29
- SemiCircleDonut,
30
- HorizontalBarChart,
31
- DoubleBarChart,
32
- LineChart,
33
- BarChart,
34
- DivContainer,
35
- ColorPickerElement,
36
- NotificationAlert
37
- } from "@apexcura/ui-components";
38
- import moment from "moment";
39
-
40
- // src/services/http-service.tsx
41
- import axios from "axios";
42
-
43
- // src/constants/network-list.tsx
44
- var networkList = {
45
- base_url: "https://dummyjson.com"
46
- };
47
- var network_list_default = networkList;
48
-
49
- // src/services/http-service.tsx
50
- var HttpClient = axios.create({
51
- baseURL: network_list_default.base_url,
52
- headers: {
53
- "Content-Type": "application/json",
54
- "accept": "application/json"
55
- }
56
- });
57
- function postService(url, method, data) {
58
- const token = JSON.parse(localStorage.getItem("token") || "null");
59
- const setHref = (str) => {
60
- window.location.href = str;
61
- };
62
- const currenthref = window.location.pathname;
63
- return HttpClient({
64
- method,
65
- url,
66
- data,
67
- headers: {
68
- "authorization": token
69
- }
70
- }).then((response) => {
71
- const responseData = response.data;
72
- const status = response.status;
73
- if (status === 200) {
74
- if (responseData.status) {
75
- return responseData;
76
- } else {
77
- if (responseData.token === "invalid" && currenthref !== "/") {
78
- localStorage.clearAll();
79
- setHref("/");
80
- return;
81
- } else if (responseData.IS_MAINTENANCE_MODE && url !== "checkAuthToken" && url !== "login") {
82
- localStorage.clearAll();
83
- setHref("/");
84
- return;
85
- } else {
86
- return responseData;
87
- }
88
- }
89
- } else {
90
- return false;
91
- }
92
- }).catch((error) => {
93
- return false;
94
- });
95
- }
96
-
97
- // src/libraries/element-executor.tsx
98
- var ElementExecutor = (props) => {
99
- const [data, setData] = useState([]);
100
- const [schema, setSchema] = useState(props.data.schema);
101
- const onHandleChange = (name, value) => {
102
- const updateSchema = (schema2) => {
103
- return schema2.map((field) => {
104
- if (field.name === name) {
105
- field["value"] = value;
106
- props.selectedRecord && props.selectedRecord(field);
107
- }
108
- if (field.fields && field.fields.length) {
109
- field.fields = updateSchema(field.fields);
110
- }
111
- return field;
112
- });
113
- };
114
- const updatedSchema = updateSchema(schema);
115
- setSchema(updatedSchema);
116
- props.setData && props.setData({ ...props.data, schema: updatedSchema });
117
- };
118
- const handleSelectData = async () => {
119
- try {
120
- const response = await postService("/products/", "POST", []);
121
- if (response !== false && typeof response === "object") {
122
- setData(response.products);
123
- }
124
- } catch (error) {
125
- console.log(error);
126
- }
127
- };
128
- const renderElement = (elementProps) => {
129
- switch (elementProps.element) {
130
- case "input-text":
131
- return /* @__PURE__ */ React.createElement(
132
- TextElement,
133
- {
134
- ...elementProps,
135
- onChange: (value) => onHandleChange(elementProps.name || "", value)
136
- }
137
- );
138
- case "input-number":
139
- return /* @__PURE__ */ React.createElement(
140
- NumberElement,
141
- {
142
- ...elementProps,
143
- onChange: (value) => onHandleChange(elementProps.name || "", value)
144
- }
145
- );
146
- case "input-textarea":
147
- return /* @__PURE__ */ React.createElement(
148
- TextareaElement,
149
- {
150
- ...elementProps,
151
- onChange: (value) => onHandleChange(elementProps.name || "", value)
152
- }
153
- );
154
- case "single-select":
155
- return /* @__PURE__ */ React.createElement(
156
- SelectElement,
157
- {
158
- ...elementProps,
159
- onChange: (value) => onHandleChange(elementProps.name || "", value)
160
- }
161
- );
162
- case "input-mobile":
163
- return /* @__PURE__ */ React.createElement(
164
- NumberElement,
165
- {
166
- ...elementProps,
167
- onChange: (value) => onHandleChange(elementProps.name || "", value)
168
- }
169
- );
170
- case "input-checkbox":
171
- return /* @__PURE__ */ React.createElement(
172
- CheckboxElement,
173
- {
174
- ...elementProps,
175
- onChange: (value) => onHandleChange(elementProps.name || "", value)
176
- }
177
- );
178
- case "input-radio":
179
- return /* @__PURE__ */ React.createElement(
180
- RadioElement,
181
- {
182
- ...elementProps,
183
- onChange: (value) => onHandleChange(elementProps.name || "", value)
184
- }
185
- );
186
- case "input-description":
187
- return /* @__PURE__ */ React.createElement(
188
- CkEditor,
189
- {
190
- ...elementProps,
191
- onChange: (value) => onHandleChange(elementProps.name || "", value)
192
- }
193
- );
194
- case "input-single-select":
195
- return /* @__PURE__ */ React.createElement(
196
- SingleSelectElement,
197
- {
198
- ...elementProps,
199
- dropDownOptions: data.length > 0 ? data : [],
200
- onChange: (value) => onHandleChange(elementProps.name || "", value),
201
- onClick: handleSelectData
202
- }
203
- );
204
- case "input-multiple-select":
205
- return /* @__PURE__ */ React.createElement(
206
- MultipleSelectElement,
207
- {
208
- ...elementProps,
209
- dropDownOptions: data.length > 0 ? data : [],
210
- onChange: (value) => onHandleChange(elementProps.name || "", value),
211
- onClick: handleSelectData
212
- }
213
- );
214
- case "add-more":
215
- return /* @__PURE__ */ React.createElement(AddMoreTable, { ...elementProps });
216
- case "div":
217
- return /* @__PURE__ */ React.createElement(
218
- DivContainer,
219
- {
220
- ...elementProps,
221
- onClick: () => props.selectedRecord && props.selectedRecord(elementProps)
222
- }
223
- );
224
- case "button":
225
- return /* @__PURE__ */ React.createElement(
226
- ButtonElement,
227
- {
228
- ...elementProps,
229
- onClick: () => props.selectedRecord && props.selectedRecord(elementProps)
230
- }
231
- );
232
- case "sidebar":
233
- return /* @__PURE__ */ React.createElement(
234
- Sidebar,
235
- {
236
- ...elementProps,
237
- onChange: (value) => onHandleChange(elementProps.name || "", value)
238
- }
239
- );
240
- case "navbar":
241
- return /* @__PURE__ */ React.createElement(Navbar, { ...elementProps });
242
- case "table":
243
- return /* @__PURE__ */ React.createElement(
244
- TableElement,
245
- {
246
- ...elementProps,
247
- onChange: (value) => onHandleChange(elementProps.name || "", value)
248
- }
249
- );
250
- case "daterangepicker":
251
- return /* @__PURE__ */ React.createElement(
252
- DateRangePickerElement,
253
- {
254
- ...elementProps,
255
- onChange: (value) => onHandleChange(elementProps.name || "", value)
256
- }
257
- );
258
- case "datepicker":
259
- return /* @__PURE__ */ React.createElement(
260
- DatePickerElement,
261
- {
262
- ...elementProps,
263
- onChange: (value) => onHandleChange(elementProps.name || "", value)
264
- }
265
- );
266
- case "upload":
267
- return /* @__PURE__ */ React.createElement(
268
- FileUpload,
269
- {
270
- ...elementProps,
271
- onChange: (value) => onHandleChange(elementProps.name || "", value)
272
- }
273
- );
274
- case "upload-manually":
275
- return /* @__PURE__ */ React.createElement(
276
- Upload,
277
- {
278
- ...elementProps,
279
- onChange: (value) => onHandleChange(elementProps.name || "", value)
280
- }
281
- );
282
- case "image":
283
- return /* @__PURE__ */ React.createElement(Image, { ...elementProps });
284
- case "input-password":
285
- return /* @__PURE__ */ React.createElement(
286
- PasswordElement,
287
- {
288
- ...elementProps,
289
- onChange: (value) => onHandleChange(elementProps.name || "", value)
290
- }
291
- );
292
- case "single-checkbox":
293
- return /* @__PURE__ */ React.createElement(
294
- SingleCheckbox,
295
- {
296
- ...elementProps,
297
- onChange: (value) => onHandleChange(elementProps.name || "", value)
298
- }
299
- );
300
- case "dropdown-group":
301
- return /* @__PURE__ */ React.createElement(
302
- DropDownGroup,
303
- {
304
- ...elementProps,
305
- onChange: (value) => onHandleChange(elementProps.name || "", value)
306
- }
307
- );
308
- case "tabs":
309
- return /* @__PURE__ */ React.createElement(
310
- TabsElement,
311
- {
312
- ...elementProps,
313
- onChange: (value) => onHandleChange(elementProps.name || "", value)
314
- }
315
- );
316
- case "otp":
317
- return /* @__PURE__ */ React.createElement(
318
- OtpElement,
319
- {
320
- ...elementProps,
321
- onChange: (value) => onHandleChange(elementProps.name || "", value)
322
- }
323
- );
324
- case "circle-donut":
325
- return /* @__PURE__ */ React.createElement(
326
- CircleDonut,
327
- {
328
- ...elementProps,
329
- onChange: (value) => onHandleChange(elementProps.name || "", value)
330
- }
331
- );
332
- case "semicircle-donut":
333
- return /* @__PURE__ */ React.createElement(
334
- SemiCircleDonut,
335
- {
336
- ...elementProps,
337
- onChange: (value) => onHandleChange(elementProps.name || "", value)
338
- }
339
- );
340
- case "horizontal-barchart":
341
- return /* @__PURE__ */ React.createElement(
342
- HorizontalBarChart,
343
- {
344
- ...elementProps,
345
- onChange: (value) => onHandleChange(elementProps.name || "", value)
346
- }
347
- );
348
- case "linechart":
349
- return /* @__PURE__ */ React.createElement(
350
- LineChart,
351
- {
352
- ...elementProps,
353
- onChange: (value) => onHandleChange(elementProps.name || "", value)
354
- }
355
- );
356
- case "double-barchart":
357
- return /* @__PURE__ */ React.createElement(
358
- DoubleBarChart,
359
- {
360
- ...elementProps,
361
- onChange: (value) => onHandleChange(elementProps.name || "", value)
362
- }
363
- );
364
- case "barchart":
365
- return /* @__PURE__ */ React.createElement(
366
- BarChart,
367
- {
368
- ...elementProps,
369
- onChange: (value) => onHandleChange(elementProps.name || "", value)
370
- }
371
- );
372
- case "color-picker":
373
- return /* @__PURE__ */ React.createElement(
374
- ColorPickerElement,
375
- {
376
- ...elementProps,
377
- onChange: (value) => onHandleChange(elementProps.name || "", value)
378
- }
379
- );
380
- case "alert":
381
- return /* @__PURE__ */ React.createElement(
382
- NotificationAlert,
383
- {
384
- ...elementProps,
385
- onChange: (value) => onHandleChange(elementProps.name || "", value)
386
- }
387
- );
388
- default:
389
- return null;
390
- }
391
- };
392
- const renderFields = (schema2) => {
393
- return schema2 && schema2.map((eachSection) => {
394
- if (eachSection.visible !== false) {
395
- return /* @__PURE__ */ React.createElement(React.Fragment, { key: eachSection.name }, eachSection.fields && eachSection.fields.length > 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, renderElement(eachSection), /* @__PURE__ */ React.createElement("div", { className: eachSection.className, key: eachSection.name }, renderFields(eachSection.fields)), eachSection.dateTime ? /* @__PURE__ */ React.createElement(
396
- "p",
397
- {
398
- style: {
399
- fontSize: "10px",
400
- textAlign: eachSection.source === "bot" ? "left" : "right"
401
- }
402
- },
403
- moment(eachSection.dateTime).format("LT")
404
- ) : "") : /* @__PURE__ */ React.createElement(React.Fragment, null, renderElement(eachSection), eachSection.dateTime ? /* @__PURE__ */ React.createElement(
405
- "p",
406
- {
407
- style: {
408
- fontSize: "10px",
409
- textAlign: eachSection.source === "bot" ? "left" : "right"
410
- }
411
- },
412
- moment(eachSection.dateTime).format("LT")
413
- ) : ""));
414
- }
415
- return null;
416
- });
417
- };
418
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: props.data.className }, renderFields(schema)));
419
- };
420
- export {
421
- ElementExecutor
422
- };
package/jest.config.js DELETED
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- preset: 'ts-jest',
3
- testEnvironment: 'jsdom',
4
- moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
5
- moduleNameMapper: {
6
- '\\.(css|less)$': 'identity-obj-proxy',
7
- },
8
- testMatch: ['**/__tests__/**/*.ts?(x)', '**/?(*.)+(spec|test).ts?(x)'],
9
- };