datastake-daf 0.6.272 → 0.6.274

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.
@@ -1,411 +1,371 @@
1
1
  /* eslint-disable no-unused-vars */
2
- import { Tabs, Alert } from "antd";
3
- import React, { useEffect, useState } from "react";
4
- import Group from "./components/group";
5
- import Input from "./components/input";
6
- import { getInputLabel } from "./config";
7
- import { getToken } from "../../../../helpers/Token";
8
- import RepeatableGroup from "./components/repeatableGroup";
9
- import RepeatableModals from "./components/repeatableModals";
10
- import { repeatObjects, isGroupInput, groupSubsections, getLastRow, showHideInput } from "./helper";
11
- import GetIcon from "../Icon/index.jsx";
2
+ import { Tabs, Alert } from 'antd';
3
+ import React, { useEffect, useState } from 'react';
4
+ import Group from './components/group';
5
+ import Input from './components/input';
6
+ import { getInputLabel } from './config';
7
+ import { getToken } from '../../../../helpers/Token';
8
+ import RepeatableGroup from './components/repeatableGroup';
9
+ import RepeatableModals from './components/repeatableModals';
10
+ import { repeatObjects, isGroupInput, groupSubsections, getLastRow, showHideInput } from './helper';
11
+ import GetIcon from '../Icon/index.jsx';
12
12
 
13
13
  const Content = ({
14
- style = {},
15
- form = {},
16
- data = {},
17
- groupConfig = {},
18
- versionsDatapoints,
19
- linkingData = {},
20
- linkingForms = {},
21
- ajaxOptions = [],
22
- // ADDED
23
- t,
24
- app,
25
- ajaxForms,
26
- language,
27
- changeAjaxForms,
28
- getApiBaseUrl,
29
- getAppHeader,
30
- user,
31
- evaluationConfig = [],
32
- fullWidth = false,
14
+ style = {},
15
+ form = {},
16
+ data = {},
17
+ groupConfig = {},
18
+ versionsDatapoints,
19
+ linkingData = {},
20
+ linkingForms = {},
21
+ ajaxOptions = [],
22
+ // ADDED
23
+ t,
24
+ app,
25
+ ajaxForms,
26
+ language,
27
+ changeAjaxForms,
28
+ getApiBaseUrl,
29
+ getAppHeader,
30
+ user,
31
+ evaluationConfig = [],
33
32
  }) => {
34
- const groupSingle = (grps) => {
35
- const form = Object.keys(grps).reduce((f, gKey) => {
36
- if (
37
- grps[gKey].type !== "modal" &&
38
- !isGroupInput(grps[gKey], false, data) &&
39
- !isGroupInput(grps[gKey], true, data) &&
40
- grps[gKey].display !== "group" &&
41
- !grps[gKey].viewGroup &&
42
- !grps[gKey].component
43
- ) {
44
- if (grps[gKey].group && !f[grps[gKey].group]) {
45
- f[grps[gKey].group] = {};
46
- Object.assign(f[grps[gKey].group], { [gKey]: grps[gKey] });
47
- } else if (grps[gKey].group && f[grps[gKey].group]) {
48
- Object.assign(f[grps[gKey].group], { [gKey]: grps[gKey] });
49
- }
33
+ const groupSingle = (grps) => {
34
+ const form = Object.keys(grps).reduce((f, gKey) => {
35
+ if (
36
+ grps[gKey].type !== 'modal' &&
37
+ !isGroupInput(grps[gKey], false, data) &&
38
+ !isGroupInput(grps[gKey], true, data) &&
39
+ grps[gKey].display !== 'group' &&
40
+ !grps[gKey].viewGroup &&
41
+ !grps[gKey].component) {
42
+ if (grps[gKey].group && !f[grps[gKey].group]) {
43
+ f[grps[gKey].group] = {};
44
+ Object.assign(f[grps[gKey].group], { [gKey]: grps[gKey] });
45
+ } else if (grps[gKey].group && f[grps[gKey].group]) {
46
+ Object.assign(f[grps[gKey].group], { [gKey]: grps[gKey] });
47
+ }
50
48
 
51
- if (grps[gKey]?.meta?.group && !f[grps[gKey]?.meta?.group]) {
52
- f[grps[gKey]?.meta?.group] = {};
53
- Object.assign(f[grps[gKey].meta.group], { [gKey]: grps[gKey] });
54
- } else if (grps[gKey]?.meta?.group && f[grps[gKey]?.meta?.group]) {
55
- Object.assign(f[grps[gKey].meta.group], { [gKey]: grps[gKey] });
56
- }
49
+ if (grps[gKey]?.meta?.group && !f[grps[gKey]?.meta?.group]) {
50
+ f[grps[gKey]?.meta?.group] = {};
51
+ Object.assign(f[grps[gKey].meta.group], { [gKey]: grps[gKey] });
52
+ } else if (grps[gKey]?.meta?.group && f[grps[gKey]?.meta?.group]) {
53
+ Object.assign(f[grps[gKey].meta.group], { [gKey]: grps[gKey] });
54
+ }
57
55
 
58
- if (grps[gKey].section && !f[grps[gKey].section]) {
59
- f[grps[gKey].section] = {};
60
- Object.assign(f[grps[gKey].section], { [gKey]: grps[gKey] });
61
- } else if (grps[gKey].section && f[grps[gKey].section]) {
62
- Object.assign(f[grps[gKey].section], { [gKey]: grps[gKey] });
63
- }
64
- }
65
- return f;
66
- }, {});
67
- return form;
68
- };
56
+ if (grps[gKey].section && !f[grps[gKey].section]) {
57
+ f[grps[gKey].section] = {};
58
+ Object.assign(f[grps[gKey].section], { [gKey]: grps[gKey] });
59
+ } else if (grps[gKey].section && f[grps[gKey].section]) {
60
+ Object.assign(f[grps[gKey].section], { [gKey]: grps[gKey] });
61
+ }
62
+ }
63
+ return f;
64
+ }, {});
65
+ return form;
66
+ }
69
67
 
70
- const getDisplayGroupConfig = (groups, key) => {
71
- return Object.keys(groups).reduce((items, gKey) => {
72
- if (groups[gKey].viewGroup === key) {
73
- // eslint-disable-next-line no-unused-vars
74
- const { viewGroup, ...gCfg } = groups[gKey];
75
- items[gKey] = gCfg;
76
- }
77
- return items;
78
- }, {});
79
- };
68
+ const getDisplayGroupConfig = (groups, key) => {
69
+ return Object.keys(groups).reduce((items, gKey) => {
70
+ if (groups[gKey].viewGroup === key) {
71
+ // eslint-disable-next-line no-unused-vars
72
+ const { viewGroup, ...gCfg } = groups[gKey];
73
+ items[gKey] = gCfg;
74
+ }
75
+ return items;
76
+ }, {});
77
+ }
80
78
 
81
- const getComponent = (component, key, config) => {
82
- switch (component) {
83
- case "repeatableModals":
84
- return (
85
- <RepeatableModals
86
- app={app}
87
- key={key}
88
- t={t}
89
- ajaxForms={ajaxForms}
90
- changeAjaxForms={changeAjaxForms}
91
- getApiBaseUrl={getApiBaseUrl}
92
- getAppHeader={getAppHeader}
93
- user={user}
94
- getToken={getToken}
95
- name={key}
96
- data={data}
97
- config={config}
98
- linkingData={linkingData}
99
- linkingForms={linkingForms}
100
- ajaxOptions={ajaxOptions}
101
- />
102
- );
103
- default:
104
- return <p>Component</p>;
105
- }
106
- };
79
+ const getComponent = (component, key, config) => {
80
+ switch (component) {
81
+ case 'repeatableModals':
82
+ return <RepeatableModals
83
+ app={app}
84
+ key={key}
85
+ t={t}
86
+ ajaxForms={ajaxForms}
87
+ changeAjaxForms={changeAjaxForms}
88
+ getApiBaseUrl={getApiBaseUrl}
89
+ getAppHeader={getAppHeader}
90
+ user={user}
91
+ getToken={getToken}
92
+ name={key}
93
+ data={data}
94
+ config={config}
95
+ linkingData={linkingData}
96
+ linkingForms={linkingForms}
97
+ ajaxOptions={ajaxOptions}
98
+ />;
99
+ default:
100
+ return <p>Component</p>;
101
+ }
102
+ }
107
103
 
108
- const isDisplayGroup = (input) => input.display && input.display === "group";
109
- const isSingleModal = (input) => input.type && input.type === "modal";
110
- const hasComponent = (input) => input.component && typeof input.component === "string";
104
+ const isDisplayGroup = (input) => input.display && input.display === 'group';
105
+ const isSingleModal = (input) => input.type && input.type === 'modal';
106
+ const hasComponent = (input) => input.component && typeof input.component === 'string';
111
107
 
112
- const typeRender = (groups, singleGroupsKeys, addedContent) => {
113
- const _length = Object.keys(groups || {}).length;
114
- const isEven = _length % 2 === 0;
108
+ const typeRender = (groups, singleGroupsKeys, addedContent) => {
109
+ const _length = Object.keys(groups || {}).length;
110
+ const isEven = _length % 2 === 0;
115
111
 
116
- const groupped = Object.keys(groups).reduce((all, key) => {
117
- const _val = groups[key];
118
- const group = _val.group || _val?.meta?.group || _val.section;
112
+ const groupped = Object.keys(groups).reduce((all, key) => {
113
+ const _val = groups[key];
114
+ const group = _val.group || _val?.meta?.group || _val.section;
119
115
 
120
- if (all[group]) {
121
- all[group][key] = _val;
122
- } else {
123
- all[group] = { [key]: _val };
124
- }
116
+ if (all[group]) {
117
+ all[group][key] = _val;
118
+ } else {
119
+ all[group] = { [key]: _val };
120
+ }
125
121
 
126
- return all;
127
- }, {});
122
+ return all;
123
+ }, {});
128
124
 
129
- return Object.keys(groupped).map((key) => {
130
- const groups = groupped[key];
131
125
 
132
- return (
133
- <React.Fragment key={key}>
134
- {repeatObjects(groups, (key, ind) => {
135
- // normal group
136
- return hasComponent(groups[key]) ? (
137
- getComponent(groups[key].component, key, groups[key])
138
- ) : isGroupInput(groups[key], false, data) ? (
139
- <Group
140
- t={t}
141
- key={key}
142
- name={key}
143
- linkingData={linkingData}
144
- config={groups[key]}
145
- data={data}
146
- allData={data}
147
- linkingForms={linkingForms}
148
- cols={2}
149
- ajaxForms={ajaxForms}
150
- changeAjaxForms={changeAjaxForms}
151
- getApiBaseUrl={getApiBaseUrl}
152
- getAppHeader={getAppHeader}
153
- user={user}
154
- getToken={getToken}
155
- evaluationConfig={evaluationConfig}
156
- ajaxOptions={ajaxOptions}
157
- ></Group>
158
- ) : // repeatable group
159
- isGroupInput(groups[key], true, data) ? (
160
- <RepeatableGroup
161
- app={app}
162
- key={key}
163
- t={t}
164
- ajaxForms={ajaxForms}
165
- changeAjaxForms={changeAjaxForms}
166
- getApiBaseUrl={getApiBaseUrl}
167
- getAppHeader={getAppHeader}
168
- user={user}
169
- getToken={getToken}
170
- name={key}
171
- config={groups[key]}
172
- data={data}
173
- allData={data}
174
- linkingData={linkingData}
175
- linkingForms={linkingForms}
176
- ajaxOptions={ajaxOptions}
177
- ></RepeatableGroup>
178
- ) : // single inputs grouped
179
- singleGroupsKeys.includes(key) ? (
180
- (() => {
181
- if (!addedContent.includes(key)) {
182
- const currentGroup = Object.keys(groupSingle(groups)).find(
183
- (k) => Object.keys(groupSingle(groups)[k]).includes(key),
184
- );
185
- addedContent.push(
186
- ...Object.keys(groupSingle(groups)[currentGroup]),
187
- );
188
- const config = groupSingle(groups)[currentGroup];
189
- if (
190
- groups[key].viewShowIf ||
191
- groups[key]?.meta?.excludeFromView
192
- ) {
193
- if (!showHideInput(groups[key], data)) {
194
- return null;
195
- }
196
- }
126
+ return Object.keys(groupped).map((key) => {
127
+ const groups = groupped[key];
197
128
 
198
- return (
199
- <div
200
- className="group"
201
- id={currentGroup}
202
- key={`${currentGroup}-${Date.now()}`}
203
- >
204
- {groupConfig[currentGroup] ? (
205
- <div className="title">
206
- <h1>{groupConfig[currentGroup][language]}</h1>
207
- </div>
208
- ) : null}
209
- <Input
210
- app={app}
211
- t={t}
212
- ajaxForms={ajaxForms}
213
- changeAjaxForms={changeAjaxForms}
214
- getApiBaseUrl={getApiBaseUrl}
215
- getAppHeader={getAppHeader}
216
- user={user}
217
- getToken={getToken}
218
- versionsDatapoints={versionsDatapoints}
219
- key={key}
220
- name={config.dataId || key}
221
- config={config}
222
- data={data}
223
- allData={data}
224
- linkingData={linkingData}
225
- className={
226
- isEven
227
- ? ind === _length - 1 || ind === _length - 2
228
- ? "last"
229
- : undefined
230
- : ind === _length - 1
231
- ? "last"
232
- : undefined
233
- }
234
- linkingForms={linkingForms}
235
- ajaxOptions={ajaxOptions}
236
- evaluationConfig={evaluationConfig}
237
- cols={2}
238
- ></Input>
239
- </div>
240
- );
241
- }
242
- })()
243
- ) : // display group
244
- isDisplayGroup(groups[key]) ? (
245
- <div className="group display" key={key}>
246
- <div className="title">
247
- <h1>{groups[key].label}</h1>
248
- </div>
249
- {typeRender(
250
- getDisplayGroupConfig(groups, key),
251
- singleGroupsKeys,
252
- addedContent,
253
- )}
254
- </div>
255
- ) : // single modal
256
- isSingleModal(groups[key]) ? (
257
- <div className="group" key={key}>
258
- <div className="title">
259
- <h1>
260
- {groups[key].outputLabel ||
261
- getInputLabel(groups[key], data)}
262
- </h1>
263
- </div>
264
- <Input
265
- app={app}
266
- t={t}
267
- key={key}
268
- ajaxForms={ajaxForms}
269
- changeAjaxForms={changeAjaxForms}
270
- getApiBaseUrl={getApiBaseUrl}
271
- getAppHeader={getAppHeader}
272
- user={user}
273
- getToken={getToken}
274
- versionsDatapoints={versionsDatapoints}
275
- parent={key}
276
- name={groups[key].dataId || key}
277
- config={groups[key]}
278
- className="last"
279
- data={data}
280
- allData={data}
281
- linkingData={linkingData}
282
- linkingForms={linkingForms}
283
- ajaxOptions={ajaxOptions}
284
- evaluationConfig={evaluationConfig}
285
- cols={2}
286
- ></Input>
287
- </div>
288
- ) : null;
289
- })}
290
- </React.Fragment>
291
- );
292
- });
293
- };
129
+ return (
130
+ <React.Fragment key={key}>
131
+ {repeatObjects(groups, (key, ind) => {
132
+ // normal group
133
+ return hasComponent(groups[key]) ? getComponent(groups[key].component, key, groups[key]) : isGroupInput(groups[key], false, data)
134
+ ? (
135
+ <Group
136
+ t={t}
137
+ key={key}
138
+ name={key}
139
+ linkingData={linkingData}
140
+ config={groups[key]}
141
+ data={data}
142
+ allData={data}
143
+ linkingForms={linkingForms}
144
+ cols={2}
145
+ ajaxForms={ajaxForms}
146
+ changeAjaxForms={changeAjaxForms}
147
+ getApiBaseUrl={getApiBaseUrl}
148
+ getAppHeader={getAppHeader}
149
+ user={user}
150
+ getToken={getToken}
151
+ evaluationConfig={evaluationConfig}
152
+ ajaxOptions={ajaxOptions}
153
+ >
154
+ </Group>
155
+ )
156
+ // repeatable group
157
+ : isGroupInput(groups[key], true, data)
158
+ ? <RepeatableGroup
159
+ app={app}
160
+ key={key}
161
+ t={t}
162
+ ajaxForms={ajaxForms}
163
+ changeAjaxForms={changeAjaxForms}
164
+ getApiBaseUrl={getApiBaseUrl}
165
+ getAppHeader={getAppHeader}
166
+ user={user}
167
+ getToken={getToken}
168
+ name={key}
169
+ config={groups[key]}
170
+ data={data}
171
+ allData={data}
172
+ linkingData={linkingData}
173
+ linkingForms={linkingForms}
174
+ ajaxOptions={ajaxOptions}
175
+ >
176
+ </RepeatableGroup>
177
+ // single inputs grouped
178
+ : singleGroupsKeys.includes(key) ? (() => {
179
+ if (!addedContent.includes(key)) {
180
+ const currentGroup = Object.keys(groupSingle(groups))
181
+ .find(k => Object.keys(groupSingle(groups)[k]).includes(key));
182
+ addedContent.push(...Object.keys(groupSingle(groups)[currentGroup]));
183
+ const config = groupSingle(groups)[currentGroup];
184
+ if (groups[key].viewShowIf || groups[key]?.meta?.excludeFromView) {
185
+ if (!showHideInput(groups[key], data)) {
186
+ return null;
187
+ }
188
+ }
294
189
 
295
- useEffect(() => {
296
- setTimeout(() => {
297
- const groups = Array.from(document.getElementsByClassName("group"));
298
- const rows = Array.from(document.querySelectorAll(".repetable-row-extra"));
299
- rows.forEach((row) => {
300
- const inputs = Array.from(row.querySelectorAll(".input"));
301
- const lasts = getLastRow(
302
- inputs.map((i, ind) => ind),
303
- 4,
304
- );
305
- if (lasts) {
306
- lasts.forEach((index) => inputs[index].classList.add("last"));
307
- }
308
- });
309
- groups.forEach((group) => {
310
- // const isRepeatable = Array.from(group.classList).includes('repeatable');
311
- const inputs = Array.from(group.querySelectorAll(".input"));
312
- // if (inputs.length && !isRepeatable) {
313
- // if (inputs.length % 2 === 0) {
314
- // inputs[inputs.length - 1].classList.add('last');
315
- // inputs[inputs.length - 2].classList.add('last');
316
- // } else {
317
- // inputs[inputs.length - 1].classList.add('last');
318
- // }
319
- // }
320
- // remove groups without inputs
321
- if (!inputs.length) {
322
- group.remove();
323
- }
324
- });
325
- }, 200);
326
- }, [form, data]);
190
+ return <div className="group" id={currentGroup} key={`${currentGroup}-${Date.now()}`}>
191
+ {groupConfig[currentGroup] ? <div className="title">
192
+ <h1>{groupConfig[currentGroup][language]}</h1>
193
+ </div> : null}
194
+ <Input
195
+ app={app}
196
+ t={t}
197
+ ajaxForms={ajaxForms}
198
+ changeAjaxForms={changeAjaxForms}
199
+ getApiBaseUrl={getApiBaseUrl}
200
+ getAppHeader={getAppHeader}
201
+ user={user}
202
+ getToken={getToken}
203
+ versionsDatapoints={versionsDatapoints}
204
+ key={key}
205
+ name={config.dataId || key}
206
+ config={config}
207
+ data={data}
208
+ allData={data}
209
+ linkingData={linkingData}
210
+ className={
211
+ isEven ? (
212
+ (ind === _length - 1 || ind === _length - 2) ? 'last' : undefined
213
+ ) : ind === _length - 1 ? 'last' : undefined}
214
+ linkingForms={linkingForms}
215
+ ajaxOptions={ajaxOptions}
216
+ evaluationConfig={evaluationConfig}
217
+ cols={2}
218
+ >
219
+ </Input>
220
+ </div>
221
+ }
222
+ })()
223
+ // display group
224
+ : isDisplayGroup(groups[key])
225
+ ? (
226
+ <div className="group display" key={key}>
227
+ <div className="title">
228
+ <h1>{groups[key].label}</h1>
229
+ </div>
230
+ {typeRender(getDisplayGroupConfig(groups, key), singleGroupsKeys, addedContent)}
231
+ </div>
232
+ )
233
+ // single modal
234
+ : isSingleModal(groups[key])
235
+ ? (
236
+ <div className="group" key={key}>
237
+ <div className="title">
238
+ <h1>{groups[key].outputLabel || getInputLabel(groups[key], data)}</h1>
239
+ </div>
240
+ <Input
241
+ app={app}
242
+ t={t}
243
+ key={key}
244
+ ajaxForms={ajaxForms}
245
+ changeAjaxForms={changeAjaxForms}
246
+ getApiBaseUrl={getApiBaseUrl}
247
+ getAppHeader={getAppHeader}
248
+ user={user}
249
+ getToken={getToken}
250
+ versionsDatapoints={versionsDatapoints}
251
+ parent={key}
252
+ name={groups[key].dataId || key}
253
+ config={groups[key]}
254
+ className="last"
255
+ data={data}
256
+ allData={data}
257
+ linkingData={linkingData}
258
+ linkingForms={linkingForms}
259
+ ajaxOptions={ajaxOptions}
260
+ evaluationConfig={evaluationConfig}
261
+ cols={2}
262
+ >
263
+ </Input>
264
+ </div>
265
+ )
266
+ : null;
267
+ })}
268
+ </React.Fragment>
269
+ )
270
+ })
271
+ }
327
272
 
328
- const [extraRequestSent, setExtraRequestSent] = useState({});
329
- const [extraRequestLoading, setExtraRequestLoading] = useState({});
330
- const [extraRequestData, setExtraRequestData] = useState({});
331
- const hasSubSections = false;
273
+ useEffect(() => {
274
+ setTimeout(() => {
275
+ const groups = Array.from(document.getElementsByClassName('group'));
276
+ const rows = Array.from(document.querySelectorAll('.repetable-row-extra'));
277
+ rows.forEach(row => {
278
+ const inputs = Array.from(row.querySelectorAll('.input'));
279
+ const lasts = getLastRow(inputs.map((i, ind) => ind), 4);
280
+ if (lasts) {
281
+ lasts.forEach(index => inputs[index].classList.add('last'));
282
+ }
283
+ });
284
+ groups.forEach(group => {
285
+ // const isRepeatable = Array.from(group.classList).includes('repeatable');
286
+ const inputs = Array.from(group.querySelectorAll('.input'));
287
+ // if (inputs.length && !isRepeatable) {
288
+ // if (inputs.length % 2 === 0) {
289
+ // inputs[inputs.length - 1].classList.add('last');
290
+ // inputs[inputs.length - 2].classList.add('last');
291
+ // } else {
292
+ // inputs[inputs.length - 1].classList.add('last');
293
+ // }
294
+ // }
295
+ // remove groups without inputs
296
+ if (!inputs.length) {
297
+ group.remove();
298
+ }
299
+ });
300
+ }, 200)
301
+ }, [form, data])
332
302
 
333
- const renderContent = (f, showTitle = true) => {
334
- if (f) {
335
- const alertType = ["error", "warning", "info", "success"];
336
- if (f.alertConf && f.alertConf.type === "warning") {
337
- return <Alert message={f.alertConf.text} type={f.alertConf.type} showIcon />;
338
- }
339
- let { label, icon, position, ...groups } = f;
340
- groups = Object.keys(groups).reduce((items, key) => {
341
- if (!groups[key]?.meta?.excludeFromView) {
342
- items[key] = groups[key];
343
- }
344
- return items;
345
- }, {});
346
- const addedContent = [];
347
- const singleGroupsKeys = [].concat(
348
- ...Object.keys(groupSingle(groups)).map((key) =>
349
- Object.keys(groupSingle(groups)[key]),
350
- ),
351
- );
303
+ const [extraRequestSent, setExtraRequestSent] = useState({});
304
+ const [extraRequestLoading, setExtraRequestLoading] = useState({});
305
+ const [extraRequestData, setExtraRequestData] = useState({});
306
+ const hasSubSections = false;
352
307
 
353
- return (
354
- <>
355
- <div className="wrapper" key={Date.now()} style={{ width: fullWidth ? "100%" : 700 }}>
356
- {f.alertConf ? (
357
- <Alert
358
- className="w-100"
359
- style={{ marginBottom: "20px" }}
360
- message={f.alertConf.text}
361
- type={
362
- alertType.includes(f.alertConf.type) ? f.alertConf.type : "info"
363
- }
364
- showIcon
365
- />
366
- ) : null}
367
- {typeRender(groups, singleGroupsKeys, addedContent)}
368
- </div>
369
- </>
370
- );
371
- }
372
- };
308
+ const renderContent = (f, showTitle = true) => {
309
+ if (f) {
310
+ const alertType = ['error', 'warning', 'info', 'success'];
311
+ if (f.alertConf && f.alertConf.type === 'warning') {
312
+ return <Alert message={f.alertConf.text} type={f.alertConf.type} showIcon />
313
+ }
314
+ let { label, icon, position, ...groups } = f;
315
+ groups = Object.keys(groups).reduce((items, key) => {
316
+ if (!groups[key]?.meta?.excludeFromView) {
317
+ items[key] = groups[key];
318
+ }
319
+ return items;
320
+ }, {});
321
+ const addedContent = [];
322
+ const singleGroupsKeys = [].concat(...Object.keys(groupSingle(groups))
323
+ .map(key => Object.keys(groupSingle(groups)[key])));
373
324
 
374
- let groupSections = [];
375
- if (hasSubSections) {
376
- groupSections = groupSubsections(form);
377
- }
325
+ return <>
326
+ <div className="wrapper" key={Date.now()} style={{ width: 700 }}>
327
+ {f.alertConf ? <Alert className="w-100" style={{ marginBottom: '20px' }} message={f.alertConf.text} type={
328
+ alertType.includes(f.alertConf.type) ? f.alertConf.type : 'info'
329
+ } showIcon /> : null}
330
+ {typeRender(groups, singleGroupsKeys, addedContent)}
331
+ </div>
332
+ </>
333
+ }
334
+ }
378
335
 
379
- return (
380
- <div className="content" style={style}>
381
- {!hasSubSections ? (
382
- renderContent(form)
383
- ) : (
384
- <React.Fragment>
385
- <h1 className="title">{form ? getInputLabel(form, data) : ""}</h1>
386
- <Tabs
387
- className="section-tabs"
388
- items={repeatObjects(groupSections, (key) => {
389
- const section = groupSections[key];
336
+ let groupSections = [];
337
+ if (hasSubSections) {
338
+ groupSections = groupSubsections(form);
339
+ }
390
340
 
391
- return {
392
- style: { maxHeight: "calc(100vh - 100px)", overflowY: "auto" },
393
- label: (
394
- <span>
395
- {section.icon ? <GetIcon icon={section.icon} /> : null}{" "}
396
- {getInputLabel(section, data)}
397
- </span>
398
- ),
399
- key: key,
400
- tabKey: key,
401
- children: renderContent(groupSections[key], false),
402
- };
403
- })}
404
- />
405
- </React.Fragment>
406
- )}
407
- </div>
408
- );
409
- };
341
+ return (
342
+ <div className="content" style={style}>
343
+ {!hasSubSections ? renderContent(form) : (
344
+ <React.Fragment>
345
+ <h1 className="title">{form ? getInputLabel(form, data) : ''}</h1>
346
+ <Tabs
347
+ className="section-tabs"
348
+ items={repeatObjects(groupSections, (key) => {
349
+ const section = groupSections[key];
350
+
351
+ return {
352
+ style: { maxHeight: 'calc(100vh - 100px)', overflowY: 'auto' },
353
+ label: (
354
+ <span>
355
+ {section.icon ?
356
+ <GetIcon icon={section.icon} /> : null} {getInputLabel(section, data)}
357
+ </span>
358
+ ),
359
+ key: key,
360
+ tabKey: key,
361
+ children: renderContent(groupSections[key], false),
362
+ };
363
+ })}
364
+ />
365
+ </React.Fragment>
366
+ )}
367
+ </div>
368
+ );
369
+ }
410
370
 
411
371
  export default Content;