@apia/api 1.0.4 → 2.0.0
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/ApiaApiContext.js +15 -0
- package/dist/ApiaApiContext.js.map +1 -0
- package/dist/ApiaApiHandler.d.ts +62 -0
- package/dist/ApiaApiHandler.d.ts.map +1 -0
- package/dist/ApiaApiHandler.js +374 -0
- package/dist/ApiaApiHandler.js.map +1 -0
- package/dist/apiaApi.d.ts +156 -0
- package/dist/apiaApi.d.ts.map +1 -0
- package/dist/apiaApi.js +458 -0
- package/dist/apiaApi.js.map +1 -0
- package/dist/buttons/ApiaApiButtonsContainer.js +129 -0
- package/dist/buttons/ApiaApiButtonsContainer.js.map +1 -0
- package/dist/fields/ApiaApiCheckbox.js +39 -0
- package/dist/fields/ApiaApiCheckbox.js.map +1 -0
- package/dist/fields/ApiaApiFieldsContainer.js +213 -0
- package/dist/fields/ApiaApiFieldsContainer.js.map +1 -0
- package/dist/fields/ApiaApiFileInput.js +34 -0
- package/dist/fields/ApiaApiFileInput.js.map +1 -0
- package/dist/fields/ApiaApiInput.d.ts +20 -0
- package/dist/fields/ApiaApiInput.d.ts.map +1 -0
- package/dist/fields/ApiaApiInput.js +110 -0
- package/dist/fields/ApiaApiInput.js.map +1 -0
- package/dist/fields/ApiaApiRadio.js +43 -0
- package/dist/fields/ApiaApiRadio.js.map +1 -0
- package/dist/fields/ApiaApiSelect.js +64 -0
- package/dist/fields/ApiaApiSelect.js.map +1 -0
- package/dist/fields/ApiaApiTextArea.js +50 -0
- package/dist/fields/ApiaApiTextArea.js.map +1 -0
- package/dist/index.d.ts +5 -255
- package/dist/index.js +4 -1771
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +39 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +23 -36
- package/LICENSE.md +0 -21
- package/README.md +0 -26
- package/cleanDist.json +0 -3
package/dist/index.js
CHANGED
|
@@ -1,1771 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { debugDispatcher, EventEmitter, parseXmlAsync, arrayOrArray, useMount, encrypt, WithEventsValue, focus, focusSelector, useStateRef, useUnmount } from '@apia/util';
|
|
6
|
-
import { notify, getNotificationMessageObj, dispatchNotifications } from '@apia/notifications';
|
|
7
|
-
import { classToValidate, Checkbox, FileInput, classToValidationFunction, Input, Radio, Select, Textarea, useFormContext, validationsStore, hasSucceedFormValidation, Form } from '@apia/validations';
|
|
8
|
-
import { SimpleButton, useModal, Modal, ProgressBar } from '@apia/components';
|
|
9
|
-
import axios from 'axios';
|
|
10
|
-
import { merge, uniqueId } from 'lodash';
|
|
11
|
-
import QueryString from 'qs';
|
|
12
|
-
import { session } from '@apia/session';
|
|
13
|
-
|
|
14
|
-
const ApiaApiId = createContext("apiaApi");
|
|
15
|
-
const ApiaApiContext = ({
|
|
16
|
-
children,
|
|
17
|
-
id
|
|
18
|
-
}) => {
|
|
19
|
-
return /* @__PURE__ */ jsx(ApiaApiId.Provider, { value: id, children });
|
|
20
|
-
};
|
|
21
|
-
var ApiaApiContext$1 = React.memo(ApiaApiContext);
|
|
22
|
-
|
|
23
|
-
var __defProp$9 = Object.defineProperty;
|
|
24
|
-
var __defProps$4 = Object.defineProperties;
|
|
25
|
-
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
26
|
-
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
27
|
-
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
28
|
-
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
29
|
-
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
30
|
-
var __spreadValues$9 = (a, b) => {
|
|
31
|
-
for (var prop in b || (b = {}))
|
|
32
|
-
if (__hasOwnProp$9.call(b, prop))
|
|
33
|
-
__defNormalProp$9(a, prop, b[prop]);
|
|
34
|
-
if (__getOwnPropSymbols$9)
|
|
35
|
-
for (var prop of __getOwnPropSymbols$9(b)) {
|
|
36
|
-
if (__propIsEnum$9.call(b, prop))
|
|
37
|
-
__defNormalProp$9(a, prop, b[prop]);
|
|
38
|
-
}
|
|
39
|
-
return a;
|
|
40
|
-
};
|
|
41
|
-
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
42
|
-
var __objRest$1 = (source, exclude) => {
|
|
43
|
-
var target = {};
|
|
44
|
-
for (var prop in source)
|
|
45
|
-
if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
46
|
-
target[prop] = source[prop];
|
|
47
|
-
if (source != null && __getOwnPropSymbols$9)
|
|
48
|
-
for (var prop of __getOwnPropSymbols$9(source)) {
|
|
49
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
|
|
50
|
-
target[prop] = source[prop];
|
|
51
|
-
}
|
|
52
|
-
return target;
|
|
53
|
-
};
|
|
54
|
-
var __async$2 = (__this, __arguments, generator) => {
|
|
55
|
-
return new Promise((resolve, reject) => {
|
|
56
|
-
var fulfilled = (value) => {
|
|
57
|
-
try {
|
|
58
|
-
step(generator.next(value));
|
|
59
|
-
} catch (e) {
|
|
60
|
-
reject(e);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
var rejected = (value) => {
|
|
64
|
-
try {
|
|
65
|
-
step(generator.throw(value));
|
|
66
|
-
} catch (e) {
|
|
67
|
-
reject(e);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
71
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
debugDispatcher.on(
|
|
75
|
-
"parseXml",
|
|
76
|
-
(_0) => __async$2(void 0, [_0], function* ([text]) {
|
|
77
|
-
const result = yield parseXmlAsync(text);
|
|
78
|
-
console.info(result);
|
|
79
|
-
}),
|
|
80
|
-
"Acepta un par\xE1metro de tipo string y realiza un parseo como si fuera xml, convirti\xE9ndolo a objeto javascript."
|
|
81
|
-
);
|
|
82
|
-
const defaultConfig = {
|
|
83
|
-
debug: true,
|
|
84
|
-
colors: {
|
|
85
|
-
exception: "red",
|
|
86
|
-
alert: "yellow",
|
|
87
|
-
message: "lightgreen"
|
|
88
|
-
},
|
|
89
|
-
handleLoad: false
|
|
90
|
-
};
|
|
91
|
-
const STORED_CONFIG = "ApiaApiConfig";
|
|
92
|
-
let forcedConfig = {};
|
|
93
|
-
const storedConfig = localStorage.getItem(STORED_CONFIG);
|
|
94
|
-
if (storedConfig)
|
|
95
|
-
forcedConfig = JSON.parse(storedConfig);
|
|
96
|
-
function getConfig(outerBehaveConfig) {
|
|
97
|
-
return merge({}, defaultConfig, outerBehaveConfig, forcedConfig);
|
|
98
|
-
}
|
|
99
|
-
function makeUrl(url, queryData, stringifyOptions) {
|
|
100
|
-
let finalUrl = url;
|
|
101
|
-
const questionMarkIndex = finalUrl.indexOf("?");
|
|
102
|
-
if (questionMarkIndex === -1)
|
|
103
|
-
finalUrl += "?";
|
|
104
|
-
else if (questionMarkIndex !== finalUrl.length - 1 && !finalUrl.endsWith("&"))
|
|
105
|
-
finalUrl += "&";
|
|
106
|
-
let parsedUrl = `${finalUrl}${queryData ? QueryString.stringify(queryData, stringifyOptions) : ""}`;
|
|
107
|
-
if (parsedUrl.endsWith("&") || parsedUrl.endsWith("?")) {
|
|
108
|
-
parsedUrl = parsedUrl.slice(0, parsedUrl.length - 1);
|
|
109
|
-
}
|
|
110
|
-
return parsedUrl;
|
|
111
|
-
}
|
|
112
|
-
const getURLActionName = (url) => {
|
|
113
|
-
var _a;
|
|
114
|
-
const actionIdx = (_a = url.match(/action=(\w+)/)) == null ? void 0 : _a[1];
|
|
115
|
-
return actionIdx != null ? actionIdx : "noAction";
|
|
116
|
-
};
|
|
117
|
-
const ApiaActions = new class ApiaActions2 extends EventEmitter {
|
|
118
|
-
}();
|
|
119
|
-
function getColor(color, colors = ((_a) => (_a = defaultConfig.colors) != null ? _a : {
|
|
120
|
-
exception: "red",
|
|
121
|
-
alert: "yellow",
|
|
122
|
-
message: "green"
|
|
123
|
-
})()) {
|
|
124
|
-
return colors[color];
|
|
125
|
-
}
|
|
126
|
-
const handleWrongResponse = (error) => {
|
|
127
|
-
let errorMessage;
|
|
128
|
-
if (typeof error !== "string") {
|
|
129
|
-
if (error.message)
|
|
130
|
-
errorMessage = error.message;
|
|
131
|
-
else
|
|
132
|
-
errorMessage = error.toString();
|
|
133
|
-
} else
|
|
134
|
-
errorMessage = error;
|
|
135
|
-
notify({
|
|
136
|
-
type: "danger",
|
|
137
|
-
message: error.message.replaceAll("AxiosError", "Error")
|
|
138
|
-
});
|
|
139
|
-
console.log("%c ", "font-size:10vh");
|
|
140
|
-
console.log("%cError in ApiaApi", "color:red;font-size:2em;font-weight:bold");
|
|
141
|
-
console.log(`red/${errorMessage}`, { error });
|
|
142
|
-
console.log("%c ", "font-size:10vh");
|
|
143
|
-
};
|
|
144
|
-
function isJsonResponse(response) {
|
|
145
|
-
return response.headers["content-type"].match("application/json");
|
|
146
|
-
}
|
|
147
|
-
function isXmlResponse(response) {
|
|
148
|
-
return response.headers["content-type"].match(
|
|
149
|
-
/(?:application|text)?\/xml/
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
function isHtmlResponse(response) {
|
|
153
|
-
return response.headers["content-type"].match(
|
|
154
|
-
/(?:application|text)?\/html/
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
function handleActions(actions) {
|
|
158
|
-
var _a, _b;
|
|
159
|
-
if (actions) {
|
|
160
|
-
if (getConfig().debug)
|
|
161
|
-
console.log(
|
|
162
|
-
"%cHandled actions: ",
|
|
163
|
-
`color: ${(_b = (_a = getConfig().colors) == null ? void 0 : _a.message) != null ? _b : "green"}`,
|
|
164
|
-
{ actions }
|
|
165
|
-
);
|
|
166
|
-
const actionsArray = arrayOrArray(actions.action);
|
|
167
|
-
actionsArray.forEach((action) => {
|
|
168
|
-
ApiaActions.emit("action", __spreadProps$4(__spreadValues$9({}, action), {
|
|
169
|
-
param: arrayOrArray(action.param)
|
|
170
|
-
}));
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
function handleOnClose({
|
|
175
|
-
exceptions,
|
|
176
|
-
onClose,
|
|
177
|
-
sysExceptions,
|
|
178
|
-
sysMessages
|
|
179
|
-
}) {
|
|
180
|
-
try {
|
|
181
|
-
import(
|
|
182
|
-
/* webpackChunkName: "api-[request]" */
|
|
183
|
-
`/api/onClose/${onClose}.ts`
|
|
184
|
-
).then(
|
|
185
|
-
(func) => {
|
|
186
|
-
if (exceptions || sysExceptions || sysMessages) {
|
|
187
|
-
const notificationsObject = getNotificationMessageObj({
|
|
188
|
-
exceptions,
|
|
189
|
-
onClose,
|
|
190
|
-
sysExceptions,
|
|
191
|
-
sysMessages
|
|
192
|
-
});
|
|
193
|
-
if (notificationsObject)
|
|
194
|
-
notificationsObject.forEach((notification) => {
|
|
195
|
-
notify(__spreadProps$4(__spreadValues$9({}, notification), {
|
|
196
|
-
onClose: func.default
|
|
197
|
-
}));
|
|
198
|
-
});
|
|
199
|
-
else
|
|
200
|
-
func.default();
|
|
201
|
-
} else
|
|
202
|
-
func.default();
|
|
203
|
-
},
|
|
204
|
-
(e) => {
|
|
205
|
-
notify({
|
|
206
|
-
message: `onClose action not found: ${String(e)}`,
|
|
207
|
-
type: "danger"
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
);
|
|
211
|
-
} catch (e) {
|
|
212
|
-
parseMessages({ exceptions, sysExceptions, sysMessages });
|
|
213
|
-
console.error("Error while handling onClose");
|
|
214
|
-
console.error(e);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
function parseMessages(response) {
|
|
218
|
-
if (!response)
|
|
219
|
-
return;
|
|
220
|
-
const { exceptions, sysMessages, sysExceptions } = response;
|
|
221
|
-
if (exceptions || sysExceptions || sysMessages) {
|
|
222
|
-
try {
|
|
223
|
-
dispatchNotifications({
|
|
224
|
-
exceptions,
|
|
225
|
-
sysExceptions,
|
|
226
|
-
sysMessages
|
|
227
|
-
});
|
|
228
|
-
} catch (e) {
|
|
229
|
-
handleWrongResponse(new Error(e));
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
const parseSuccessfulResponse = (_0, _1, ..._2) => __async$2(void 0, [_0, _1, ..._2], function* (response, currentUrl, outerBehaveConfig = defaultConfig) {
|
|
234
|
-
var _a;
|
|
235
|
-
const behaveConfig = getConfig(outerBehaveConfig);
|
|
236
|
-
let parsedObj = void 0;
|
|
237
|
-
if (isJsonResponse(response)) {
|
|
238
|
-
if (typeof response.data === "string")
|
|
239
|
-
parsedObj = JSON.parse(
|
|
240
|
-
response.data.trim()
|
|
241
|
-
);
|
|
242
|
-
else if (typeof response.data === "object" && response.data)
|
|
243
|
-
parsedObj = response.data;
|
|
244
|
-
} else if (isXmlResponse(response)) {
|
|
245
|
-
parsedObj = yield parseXmlAsync(response.data).catch(
|
|
246
|
-
(e) => {
|
|
247
|
-
handleWrongResponse(new Error(e));
|
|
248
|
-
}
|
|
249
|
-
);
|
|
250
|
-
} else if (isHtmlResponse(response)) {
|
|
251
|
-
console.error(
|
|
252
|
-
"El contenido devuelto es Html, no se esperaba esa respuesta"
|
|
253
|
-
);
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
if (behaveConfig.validateResponse) {
|
|
257
|
-
const validateResult = yield behaveConfig.validateResponse(__spreadProps$4(__spreadValues$9({}, response), {
|
|
258
|
-
data: (_a = parsedObj == null ? void 0 : parsedObj.load) != null ? _a : parsedObj
|
|
259
|
-
}));
|
|
260
|
-
if (typeof validateResult === "string")
|
|
261
|
-
throw new Error(`Validation error: ${validateResult}`);
|
|
262
|
-
else if (!validateResult) {
|
|
263
|
-
throw new Error("Error");
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
if (parsedObj) {
|
|
267
|
-
const _b = parsedObj, {
|
|
268
|
-
actions,
|
|
269
|
-
onClose,
|
|
270
|
-
exceptions,
|
|
271
|
-
sysExceptions,
|
|
272
|
-
sysMessages,
|
|
273
|
-
load
|
|
274
|
-
} = _b, rest = __objRest$1(_b, [
|
|
275
|
-
"actions",
|
|
276
|
-
"onClose",
|
|
277
|
-
"exceptions",
|
|
278
|
-
"sysExceptions",
|
|
279
|
-
"sysMessages",
|
|
280
|
-
"load"
|
|
281
|
-
]);
|
|
282
|
-
if (rest.code === "-1" && exceptions) {
|
|
283
|
-
session.invalidate();
|
|
284
|
-
return null;
|
|
285
|
-
}
|
|
286
|
-
if (exceptions && behaveConfig.debug) {
|
|
287
|
-
console.log(
|
|
288
|
-
`%cparseSuccessfulResponse`,
|
|
289
|
-
`color: ${getColor("exception", behaveConfig.colors)}`,
|
|
290
|
-
{
|
|
291
|
-
exceptions
|
|
292
|
-
}
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
if (sysExceptions && behaveConfig.debug) {
|
|
296
|
-
console.log(
|
|
297
|
-
`%cparseSuccessfulResponse`,
|
|
298
|
-
`color: ${getColor("exception", behaveConfig.colors)}`,
|
|
299
|
-
{
|
|
300
|
-
sysExceptions
|
|
301
|
-
}
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
if (sysMessages && behaveConfig.debug) {
|
|
305
|
-
console.log(
|
|
306
|
-
`%cparseSuccessfulResponse`,
|
|
307
|
-
`color: ${getColor("alert", behaveConfig.colors)}`,
|
|
308
|
-
{
|
|
309
|
-
sysMessages
|
|
310
|
-
}
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
handleActions(actions);
|
|
314
|
-
if (behaveConfig.handleLoad && onClose)
|
|
315
|
-
handleOnClose({
|
|
316
|
-
exceptions,
|
|
317
|
-
onClose,
|
|
318
|
-
sysExceptions,
|
|
319
|
-
sysMessages
|
|
320
|
-
});
|
|
321
|
-
else
|
|
322
|
-
parseMessages({ exceptions, sysExceptions, sysMessages });
|
|
323
|
-
if (load) {
|
|
324
|
-
if (behaveConfig.handleLoad) {
|
|
325
|
-
console.log(
|
|
326
|
-
`%chandleLoad`,
|
|
327
|
-
`color: ${getColor("message", behaveConfig.colors)}`,
|
|
328
|
-
{
|
|
329
|
-
load
|
|
330
|
-
}
|
|
331
|
-
);
|
|
332
|
-
if (!handle(load, currentUrl, {
|
|
333
|
-
methodsPath: outerBehaveConfig.methodsPath,
|
|
334
|
-
modalConfiguration: __spreadProps$4(__spreadValues$9({}, behaveConfig.modalConfiguration), {
|
|
335
|
-
onClose: () => {
|
|
336
|
-
var _a2, _b2;
|
|
337
|
-
if (onClose)
|
|
338
|
-
handleOnClose({
|
|
339
|
-
exceptions,
|
|
340
|
-
onClose,
|
|
341
|
-
sysExceptions,
|
|
342
|
-
sysMessages
|
|
343
|
-
});
|
|
344
|
-
if ((_a2 = behaveConfig.modalConfiguration) == null ? void 0 : _a2.onClose)
|
|
345
|
-
(_b2 = behaveConfig.modalConfiguration) == null ? void 0 : _b2.onClose();
|
|
346
|
-
}
|
|
347
|
-
})
|
|
348
|
-
})) {
|
|
349
|
-
console.log(
|
|
350
|
-
`%cunhandledLoad -> There is no handler defined`,
|
|
351
|
-
`color: ${getColor("exception", behaveConfig.colors)}`,
|
|
352
|
-
{
|
|
353
|
-
load
|
|
354
|
-
}
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
return __spreadProps$4(__spreadValues$9({}, load), { sysMessages, exceptions, sysExceptions });
|
|
359
|
-
}
|
|
360
|
-
return __spreadProps$4(__spreadValues$9({}, rest), { sysMessages, exceptions, sysExceptions });
|
|
361
|
-
}
|
|
362
|
-
return null;
|
|
363
|
-
});
|
|
364
|
-
function handleResponse(_0, _1) {
|
|
365
|
-
return __async$2(this, arguments, function* (result, currentUrl, outerBehaveConfig = defaultConfig) {
|
|
366
|
-
var _a;
|
|
367
|
-
const behaveConfig = getConfig(outerBehaveConfig);
|
|
368
|
-
try {
|
|
369
|
-
if (!result || result.data === void 0) {
|
|
370
|
-
if (behaveConfig.debug)
|
|
371
|
-
console.log(
|
|
372
|
-
`%cApiaApi wrong response`,
|
|
373
|
-
`color: ${getColor("alert", behaveConfig.colors)}`
|
|
374
|
-
);
|
|
375
|
-
} else {
|
|
376
|
-
const parsedResponse = yield parseSuccessfulResponse(
|
|
377
|
-
result,
|
|
378
|
-
currentUrl,
|
|
379
|
-
behaveConfig
|
|
380
|
-
);
|
|
381
|
-
const action = getURLActionName(currentUrl);
|
|
382
|
-
if (behaveConfig.debug)
|
|
383
|
-
console.log(
|
|
384
|
-
`%c <- ApiaApi.${(_a = result.config.method) != null ? _a : ""} ${action} `,
|
|
385
|
-
`color: ${getColor("message", behaveConfig.colors)}`,
|
|
386
|
-
{
|
|
387
|
-
data: parsedResponse
|
|
388
|
-
}
|
|
389
|
-
);
|
|
390
|
-
return __spreadProps$4(__spreadValues$9({}, result), {
|
|
391
|
-
data: parsedResponse,
|
|
392
|
-
hasError: !!(parsedResponse == null ? void 0 : parsedResponse.exceptions) || !!(parsedResponse == null ? void 0 : parsedResponse.sysExceptions),
|
|
393
|
-
hasMessages: !!(parsedResponse == null ? void 0 : parsedResponse.sysMessages)
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
} catch (e) {
|
|
397
|
-
handleWrongResponse(new Error(e));
|
|
398
|
-
return null;
|
|
399
|
-
}
|
|
400
|
-
return null;
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
function post(par1, par2) {
|
|
404
|
-
return __async$2(this, null, function* () {
|
|
405
|
-
const actualUrl = typeof par1 !== "string" ? makeApiaUrl() : par1;
|
|
406
|
-
const configParameter = typeof par1 === "string" ? par2 != null ? par2 : defaultConfig : par1;
|
|
407
|
-
const behaveConfig = __spreadProps$4(__spreadValues$9({}, getConfig(configParameter)), {
|
|
408
|
-
postData: configParameter.postDataTreatement === "stringify" ? QueryString.stringify(
|
|
409
|
-
configParameter.postData,
|
|
410
|
-
configParameter.stringifyOptions
|
|
411
|
-
) : configParameter.postData
|
|
412
|
-
});
|
|
413
|
-
const parsedUrl = makeUrl(
|
|
414
|
-
actualUrl,
|
|
415
|
-
behaveConfig.queryData,
|
|
416
|
-
behaveConfig.stringifyOptions
|
|
417
|
-
);
|
|
418
|
-
if (behaveConfig.debug) {
|
|
419
|
-
const queryString = actualUrl.split("&");
|
|
420
|
-
const action = getURLActionName(actualUrl);
|
|
421
|
-
console.log(
|
|
422
|
-
`%cApiaApi.post ${action}`,
|
|
423
|
-
`color: ${getColor("message", behaveConfig.colors)}`,
|
|
424
|
-
{
|
|
425
|
-
url: parsedUrl,
|
|
426
|
-
queryDataInURL: [...queryString],
|
|
427
|
-
queryData: behaveConfig.queryData,
|
|
428
|
-
formData: behaveConfig.postData,
|
|
429
|
-
stringifyOptiopns: behaveConfig.stringifyOptions
|
|
430
|
-
}
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
|
-
const response = yield axios.post(
|
|
434
|
-
parsedUrl,
|
|
435
|
-
behaveConfig.postData,
|
|
436
|
-
behaveConfig.axiosConfig
|
|
437
|
-
).catch((e) => {
|
|
438
|
-
handleWrongResponse(new Error(e));
|
|
439
|
-
});
|
|
440
|
-
if (response) {
|
|
441
|
-
const result = handleResponse(response, actualUrl, behaveConfig);
|
|
442
|
-
return result;
|
|
443
|
-
}
|
|
444
|
-
return null;
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
function get(par1, par2) {
|
|
448
|
-
return __async$2(this, null, function* () {
|
|
449
|
-
const actualUrl = typeof par1 !== "string" ? makeApiaUrl() : par1;
|
|
450
|
-
const behaveConfig = getConfig(
|
|
451
|
-
typeof par1 === "string" ? par2 != null ? par2 : defaultConfig : par1
|
|
452
|
-
);
|
|
453
|
-
const parsedUrl = makeUrl(
|
|
454
|
-
actualUrl,
|
|
455
|
-
behaveConfig.queryData,
|
|
456
|
-
behaveConfig.stringifyOptions
|
|
457
|
-
);
|
|
458
|
-
if (behaveConfig.debug)
|
|
459
|
-
console.log(
|
|
460
|
-
`%cApiaApi.get`,
|
|
461
|
-
`color: ${getColor("message", behaveConfig.colors)}`,
|
|
462
|
-
{
|
|
463
|
-
url: parsedUrl
|
|
464
|
-
}
|
|
465
|
-
);
|
|
466
|
-
const response = yield axios.get(parsedUrl, behaveConfig.axiosConfig).catch((e) => {
|
|
467
|
-
handleWrongResponse(new Error(e));
|
|
468
|
-
});
|
|
469
|
-
if (response) {
|
|
470
|
-
const result = yield handleResponse(
|
|
471
|
-
response,
|
|
472
|
-
actualUrl,
|
|
473
|
-
behaveConfig
|
|
474
|
-
);
|
|
475
|
-
return result;
|
|
476
|
-
}
|
|
477
|
-
return null;
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
const ApiaApi = {
|
|
481
|
-
get,
|
|
482
|
-
getConfig,
|
|
483
|
-
post
|
|
484
|
-
};
|
|
485
|
-
function makeApiaUrl(props) {
|
|
486
|
-
var _b, _c, _d;
|
|
487
|
-
let actualQueryData = {};
|
|
488
|
-
if (props) {
|
|
489
|
-
const _a = props, rest = __objRest$1(_a, [
|
|
490
|
-
"ajaxUrl",
|
|
491
|
-
"queryString",
|
|
492
|
-
"stringifyOptions",
|
|
493
|
-
"shouldAvoidTabId",
|
|
494
|
-
"preventAsXmlParameter",
|
|
495
|
-
"avoidTabId",
|
|
496
|
-
"tabId"
|
|
497
|
-
]);
|
|
498
|
-
actualQueryData = __spreadValues$9({}, rest);
|
|
499
|
-
}
|
|
500
|
-
const queryString = QueryString.stringify(
|
|
501
|
-
actualQueryData,
|
|
502
|
-
(_b = props == null ? void 0 : props.stringifyOptions) != null ? _b : {
|
|
503
|
-
arrayFormat: "repeat",
|
|
504
|
-
encodeValuesOnly: false
|
|
505
|
-
}
|
|
506
|
-
);
|
|
507
|
-
let actualAjaxUrl = (_c = props == null ? void 0 : props.ajaxUrl) != null ? _c : window.URL_REQUEST_AJAX;
|
|
508
|
-
if (actualAjaxUrl.indexOf("?") === actualAjaxUrl.length - 1) {
|
|
509
|
-
actualAjaxUrl = actualAjaxUrl.slice(0, actualAjaxUrl.length - 1);
|
|
510
|
-
}
|
|
511
|
-
if (!actualAjaxUrl.startsWith("/")) {
|
|
512
|
-
actualAjaxUrl = `/${actualAjaxUrl}`;
|
|
513
|
-
}
|
|
514
|
-
const match = window.TAB_ID_REQUEST.match(/tokenId=(\w+)/);
|
|
515
|
-
const currentTokenId = (match != null ? match : [])[1];
|
|
516
|
-
let tabId = ((props == null ? void 0 : props.tabId) ? `&tabId=${props.tabId}&tokenId=${currentTokenId}` : window.TAB_ID_REQUEST).slice(1);
|
|
517
|
-
if (props == null ? void 0 : props.avoidTabId) {
|
|
518
|
-
tabId = "";
|
|
519
|
-
}
|
|
520
|
-
let { CONTEXT } = window;
|
|
521
|
-
if (CONTEXT == null ? void 0 : CONTEXT.endsWith("/")) {
|
|
522
|
-
CONTEXT += CONTEXT.slice(0, CONTEXT.length - 1);
|
|
523
|
-
}
|
|
524
|
-
let timestamp = `timestamp=${Date.now()}&`;
|
|
525
|
-
if ((props == null ? void 0 : props.queryString) && props.queryString.includes("timestamp=") || (queryString == null ? void 0 : queryString.includes("timestamp="))) {
|
|
526
|
-
timestamp = "";
|
|
527
|
-
}
|
|
528
|
-
const contextWord = CONTEXT.replaceAll("/", "");
|
|
529
|
-
actualAjaxUrl = (_d = actualAjaxUrl.match(
|
|
530
|
-
new RegExp(`^(?:(?:/?${contextWord})?/)?(.+)$`)
|
|
531
|
-
)) == null ? void 0 : _d[1];
|
|
532
|
-
return `${contextWord ? "/" : ""}${contextWord}/${actualAjaxUrl}?${timestamp}${!(props == null ? void 0 : props.preventAsXmlParameter) ? "asXml=true&" : ""}${(props == null ? void 0 : props.queryString) ? `${props.queryString}&` : ""}${queryString ? `${queryString}&` : ""}${tabId}`;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
var __defProp$8 = Object.defineProperty;
|
|
536
|
-
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
537
|
-
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
538
|
-
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
539
|
-
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
540
|
-
var __spreadValues$8 = (a, b) => {
|
|
541
|
-
for (var prop in b || (b = {}))
|
|
542
|
-
if (__hasOwnProp$8.call(b, prop))
|
|
543
|
-
__defNormalProp$8(a, prop, b[prop]);
|
|
544
|
-
if (__getOwnPropSymbols$8)
|
|
545
|
-
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
546
|
-
if (__propIsEnum$8.call(b, prop))
|
|
547
|
-
__defNormalProp$8(a, prop, b[prop]);
|
|
548
|
-
}
|
|
549
|
-
return a;
|
|
550
|
-
};
|
|
551
|
-
const ApiaApiCheckbox = (props) => {
|
|
552
|
-
const element = React__default.useMemo(() => props.element, [props.element]);
|
|
553
|
-
const className = React__default.useMemo(
|
|
554
|
-
() => element.class ? `handler__checkbox ${element.class}` : "handler__checkbox",
|
|
555
|
-
[element.class]
|
|
556
|
-
);
|
|
557
|
-
const validationRules = React__default.useMemo(
|
|
558
|
-
() => __spreadValues$8({
|
|
559
|
-
required: element.mandatory
|
|
560
|
-
}, classToValidate(element.class)),
|
|
561
|
-
[element.class, element.mandatory]
|
|
562
|
-
);
|
|
563
|
-
const submitValueParser = React__default.useCallback(
|
|
564
|
-
(value) => value === "on" || value === true,
|
|
565
|
-
[]
|
|
566
|
-
);
|
|
567
|
-
return /* @__PURE__ */ jsx(
|
|
568
|
-
Checkbox,
|
|
569
|
-
{
|
|
570
|
-
className,
|
|
571
|
-
name: element.id || element.name,
|
|
572
|
-
label: element.text,
|
|
573
|
-
title: element.title || element.text,
|
|
574
|
-
initialValue: String(element.selected) === "true",
|
|
575
|
-
disabled: element.readonly || element.disabled,
|
|
576
|
-
validationRules,
|
|
577
|
-
onChange: element.onChange,
|
|
578
|
-
submitValueParser
|
|
579
|
-
}
|
|
580
|
-
);
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
var __defProp$7 = Object.defineProperty;
|
|
584
|
-
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
585
|
-
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
586
|
-
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
587
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
588
|
-
var __spreadValues$7 = (a, b) => {
|
|
589
|
-
for (var prop in b || (b = {}))
|
|
590
|
-
if (__hasOwnProp$7.call(b, prop))
|
|
591
|
-
__defNormalProp$7(a, prop, b[prop]);
|
|
592
|
-
if (__getOwnPropSymbols$7)
|
|
593
|
-
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
594
|
-
if (__propIsEnum$7.call(b, prop))
|
|
595
|
-
__defNormalProp$7(a, prop, b[prop]);
|
|
596
|
-
}
|
|
597
|
-
return a;
|
|
598
|
-
};
|
|
599
|
-
const ApiaApiFileInput = (props) => {
|
|
600
|
-
const element = React__default.useMemo(() => props.element, [props.element]);
|
|
601
|
-
const className = React__default.useMemo(
|
|
602
|
-
() => element.class ? `handler__file ${element.class}` : "handler__file",
|
|
603
|
-
[element.class]
|
|
604
|
-
);
|
|
605
|
-
const validationRules = React__default.useMemo(
|
|
606
|
-
() => __spreadValues$7({
|
|
607
|
-
required: element.mandatory
|
|
608
|
-
}, classToValidate(element.class)),
|
|
609
|
-
[element.class, element.mandatory]
|
|
610
|
-
);
|
|
611
|
-
return /* @__PURE__ */ jsx(
|
|
612
|
-
FileInput,
|
|
613
|
-
{
|
|
614
|
-
className,
|
|
615
|
-
name: element.id || element.name,
|
|
616
|
-
label: element.text,
|
|
617
|
-
title: element.title || element.text,
|
|
618
|
-
readOnly: element.readonly,
|
|
619
|
-
disabled: element.disabled,
|
|
620
|
-
validationRules
|
|
621
|
-
}
|
|
622
|
-
);
|
|
623
|
-
};
|
|
624
|
-
ApiaApiFileInput.displayName = "ApiaApiFileInput";
|
|
625
|
-
|
|
626
|
-
var __defProp$6 = Object.defineProperty;
|
|
627
|
-
var __defProps$3 = Object.defineProperties;
|
|
628
|
-
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
629
|
-
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
630
|
-
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
631
|
-
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
632
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
633
|
-
var __spreadValues$6 = (a, b) => {
|
|
634
|
-
for (var prop in b || (b = {}))
|
|
635
|
-
if (__hasOwnProp$6.call(b, prop))
|
|
636
|
-
__defNormalProp$6(a, prop, b[prop]);
|
|
637
|
-
if (__getOwnPropSymbols$6)
|
|
638
|
-
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
639
|
-
if (__propIsEnum$6.call(b, prop))
|
|
640
|
-
__defNormalProp$6(a, prop, b[prop]);
|
|
641
|
-
}
|
|
642
|
-
return a;
|
|
643
|
-
};
|
|
644
|
-
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
645
|
-
const getModal = (path) => {
|
|
646
|
-
return React__default.lazy(() => {
|
|
647
|
-
return new Promise((resolve) => {
|
|
648
|
-
import(
|
|
649
|
-
/* webpackChunkName: "handlerModal" */
|
|
650
|
-
/* webpackInclude: /\.tsx?$/ */
|
|
651
|
-
`/api/modals/${path}`
|
|
652
|
-
).then((result) => {
|
|
653
|
-
resolve(
|
|
654
|
-
result
|
|
655
|
-
);
|
|
656
|
-
}).catch((error) => {
|
|
657
|
-
resolve({
|
|
658
|
-
default: () => {
|
|
659
|
-
console.error(error);
|
|
660
|
-
throw new Error(
|
|
661
|
-
`The above error ocurred at component ApiaApiHandler/${path}, does it exist?`
|
|
662
|
-
);
|
|
663
|
-
}
|
|
664
|
-
});
|
|
665
|
-
});
|
|
666
|
-
});
|
|
667
|
-
});
|
|
668
|
-
};
|
|
669
|
-
const ApiaApiInput = (props) => {
|
|
670
|
-
const element = React__default.useMemo(() => props.element, [props.element]);
|
|
671
|
-
const [Submodal, setSubmodal] = React__default.useState(null);
|
|
672
|
-
useMount(() => {
|
|
673
|
-
if (element.modalFunction) {
|
|
674
|
-
const found = element.modalFunction.match(/(?:fnc)?(\w+)\(?\)?$/);
|
|
675
|
-
if (found) {
|
|
676
|
-
const modalName = found[found.length - 1];
|
|
677
|
-
setSubmodal(getModal(modalName));
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
});
|
|
681
|
-
const className = React__default.useMemo(
|
|
682
|
-
() => element.class ? `handler__${element.type} ${element.class}` : `handler__${element.type}`,
|
|
683
|
-
[element.class, element.type]
|
|
684
|
-
);
|
|
685
|
-
const validationRules = React__default.useMemo(
|
|
686
|
-
() => __spreadValues$6({
|
|
687
|
-
required: element.mandatory,
|
|
688
|
-
maxLength: element.maxlength ? Number(element.maxlength) : void 0,
|
|
689
|
-
pattern: element.regExp,
|
|
690
|
-
patternMessage: element.regExpMessage
|
|
691
|
-
}, classToValidate(element.class)),
|
|
692
|
-
[
|
|
693
|
-
element.class,
|
|
694
|
-
element.mandatory,
|
|
695
|
-
element.maxlength,
|
|
696
|
-
element.regExp,
|
|
697
|
-
element.regExpMessage
|
|
698
|
-
]
|
|
699
|
-
);
|
|
700
|
-
const validationFunction = React__default.useMemo(
|
|
701
|
-
() => classToValidationFunction(element.class),
|
|
702
|
-
[element.class]
|
|
703
|
-
);
|
|
704
|
-
const submitValueParser = React__default.useCallback(
|
|
705
|
-
(value) => {
|
|
706
|
-
if (element.type === "password") {
|
|
707
|
-
return encrypt(
|
|
708
|
-
window.SALT,
|
|
709
|
-
window.IV,
|
|
710
|
-
window.PASSPHRASE,
|
|
711
|
-
value,
|
|
712
|
-
Number(window.KEY_SIZE),
|
|
713
|
-
Number(window.ITERATION_COUNT)
|
|
714
|
-
);
|
|
715
|
-
}
|
|
716
|
-
return value;
|
|
717
|
-
},
|
|
718
|
-
[element.type]
|
|
719
|
-
);
|
|
720
|
-
if (element.modalFunction) {
|
|
721
|
-
if (Submodal) {
|
|
722
|
-
return /* @__PURE__ */ jsx(React__default.Suspense, { children: /* @__PURE__ */ jsx(Submodal, __spreadProps$3(__spreadValues$6({}, props), { element })) });
|
|
723
|
-
}
|
|
724
|
-
return null;
|
|
725
|
-
}
|
|
726
|
-
return /* @__PURE__ */ jsx(
|
|
727
|
-
Input,
|
|
728
|
-
{
|
|
729
|
-
type: element.isADate ? "date" : element.type,
|
|
730
|
-
className,
|
|
731
|
-
name: element.id || element.name,
|
|
732
|
-
label: element.text,
|
|
733
|
-
title: element.title || element.text,
|
|
734
|
-
value: element.value,
|
|
735
|
-
readOnly: element.readonly,
|
|
736
|
-
disabled: element.disabled,
|
|
737
|
-
validationFunction,
|
|
738
|
-
validationRules,
|
|
739
|
-
submitValueParser,
|
|
740
|
-
onChange: element.onChange,
|
|
741
|
-
autoComplete: element.type === "password" ? "new-password" : void 0
|
|
742
|
-
}
|
|
743
|
-
);
|
|
744
|
-
};
|
|
745
|
-
ApiaApiInput.displayName = "ApiaApiInput";
|
|
746
|
-
|
|
747
|
-
var __defProp$5 = Object.defineProperty;
|
|
748
|
-
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
749
|
-
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
750
|
-
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
751
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
752
|
-
var __spreadValues$5 = (a, b) => {
|
|
753
|
-
for (var prop in b || (b = {}))
|
|
754
|
-
if (__hasOwnProp$5.call(b, prop))
|
|
755
|
-
__defNormalProp$5(a, prop, b[prop]);
|
|
756
|
-
if (__getOwnPropSymbols$5)
|
|
757
|
-
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
758
|
-
if (__propIsEnum$5.call(b, prop))
|
|
759
|
-
__defNormalProp$5(a, prop, b[prop]);
|
|
760
|
-
}
|
|
761
|
-
return a;
|
|
762
|
-
};
|
|
763
|
-
const ApiaApiRadio = (props) => {
|
|
764
|
-
var _a;
|
|
765
|
-
const element = React__default.useMemo(() => props.element, [props.element]);
|
|
766
|
-
const className = React__default.useMemo(
|
|
767
|
-
() => element.class ? `handler__radio ${element.class}` : "handler__radio",
|
|
768
|
-
[element.class]
|
|
769
|
-
);
|
|
770
|
-
const options = React__default.useMemo(
|
|
771
|
-
() => {
|
|
772
|
-
var _a2;
|
|
773
|
-
return arrayOrArray((_a2 = element.options) == null ? void 0 : _a2.option).map((currOption) => {
|
|
774
|
-
return { value: currOption.value, label: currOption.content };
|
|
775
|
-
});
|
|
776
|
-
},
|
|
777
|
-
[(_a = element.options) == null ? void 0 : _a.option]
|
|
778
|
-
);
|
|
779
|
-
const validationRules = React__default.useMemo(
|
|
780
|
-
() => __spreadValues$5({
|
|
781
|
-
required: element.mandatory
|
|
782
|
-
}, classToValidate(element.class)),
|
|
783
|
-
[element.class, element.mandatory]
|
|
784
|
-
);
|
|
785
|
-
return /* @__PURE__ */ jsx(
|
|
786
|
-
Radio,
|
|
787
|
-
{
|
|
788
|
-
className,
|
|
789
|
-
name: element.id || element.name,
|
|
790
|
-
label: element.text,
|
|
791
|
-
title: element.title || element.text,
|
|
792
|
-
initialValue: element.value,
|
|
793
|
-
disabled: element.readonly || element.disabled,
|
|
794
|
-
validationRules,
|
|
795
|
-
options,
|
|
796
|
-
onChange: element.onChange
|
|
797
|
-
}
|
|
798
|
-
);
|
|
799
|
-
};
|
|
800
|
-
ApiaApiRadio.displayName = "ApiaApiRadio";
|
|
801
|
-
|
|
802
|
-
var __defProp$4 = Object.defineProperty;
|
|
803
|
-
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
804
|
-
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
805
|
-
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
806
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
807
|
-
var __spreadValues$4 = (a, b) => {
|
|
808
|
-
for (var prop in b || (b = {}))
|
|
809
|
-
if (__hasOwnProp$4.call(b, prop))
|
|
810
|
-
__defNormalProp$4(a, prop, b[prop]);
|
|
811
|
-
if (__getOwnPropSymbols$4)
|
|
812
|
-
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
813
|
-
if (__propIsEnum$4.call(b, prop))
|
|
814
|
-
__defNormalProp$4(a, prop, b[prop]);
|
|
815
|
-
}
|
|
816
|
-
return a;
|
|
817
|
-
};
|
|
818
|
-
const apiaApiSelectOptions = new class ApiaApiSelectOptions extends EventEmitter {
|
|
819
|
-
}();
|
|
820
|
-
const ApiaApiSelect = (props) => {
|
|
821
|
-
var _a;
|
|
822
|
-
const element = React__default.useMemo(() => props.element, [props.element]);
|
|
823
|
-
const className = React__default.useMemo(
|
|
824
|
-
() => element.class ? `handler__select ${element.class}` : "handler__select",
|
|
825
|
-
[element.class]
|
|
826
|
-
);
|
|
827
|
-
const [options, setOptions] = React__default.useState(
|
|
828
|
-
arrayOrArray((_a = element.options) == null ? void 0 : _a.option).map((currOption) => {
|
|
829
|
-
return { value: currOption.value, label: currOption.content };
|
|
830
|
-
})
|
|
831
|
-
);
|
|
832
|
-
const validationRules = React__default.useMemo(
|
|
833
|
-
() => __spreadValues$4({
|
|
834
|
-
required: element.mandatory
|
|
835
|
-
}, classToValidate(element.class)),
|
|
836
|
-
[element.class, element.mandatory]
|
|
837
|
-
);
|
|
838
|
-
React__default.useEffect(() => {
|
|
839
|
-
const unsuscribe = apiaApiSelectOptions.on("setOptions", (ev) => {
|
|
840
|
-
if (ev.fieldName === element.name) {
|
|
841
|
-
setOptions(
|
|
842
|
-
ev.options.map((currOption) => ({
|
|
843
|
-
value: currOption.value,
|
|
844
|
-
label: currOption.content
|
|
845
|
-
}))
|
|
846
|
-
);
|
|
847
|
-
}
|
|
848
|
-
});
|
|
849
|
-
return () => {
|
|
850
|
-
unsuscribe();
|
|
851
|
-
};
|
|
852
|
-
}, [element.name]);
|
|
853
|
-
const initialValue = React__default.useMemo(
|
|
854
|
-
() => {
|
|
855
|
-
var _a2, _b, _c, _d;
|
|
856
|
-
return (_d = (_c = (_a2 = options.find((current) => current.value === props.element.value)) == null ? void 0 : _a2.value) != null ? _c : (_b = options[0]) == null ? void 0 : _b.value) != null ? _d : "";
|
|
857
|
-
},
|
|
858
|
-
[options, props.element.value]
|
|
859
|
-
);
|
|
860
|
-
return /* @__PURE__ */ jsx(
|
|
861
|
-
Select,
|
|
862
|
-
{
|
|
863
|
-
className,
|
|
864
|
-
name: element.id || element.name,
|
|
865
|
-
label: element.text,
|
|
866
|
-
title: element.title || element.text,
|
|
867
|
-
initialValue,
|
|
868
|
-
disabled: element.readonly || element.disabled,
|
|
869
|
-
validationRules,
|
|
870
|
-
options,
|
|
871
|
-
onChange: element.onChange
|
|
872
|
-
}
|
|
873
|
-
);
|
|
874
|
-
};
|
|
875
|
-
ApiaApiSelect.displayName = "ApiaApiSelect";
|
|
876
|
-
|
|
877
|
-
var __defProp$3 = Object.defineProperty;
|
|
878
|
-
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
879
|
-
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
880
|
-
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
881
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
882
|
-
var __spreadValues$3 = (a, b) => {
|
|
883
|
-
for (var prop in b || (b = {}))
|
|
884
|
-
if (__hasOwnProp$3.call(b, prop))
|
|
885
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
886
|
-
if (__getOwnPropSymbols$3)
|
|
887
|
-
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
888
|
-
if (__propIsEnum$3.call(b, prop))
|
|
889
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
890
|
-
}
|
|
891
|
-
return a;
|
|
892
|
-
};
|
|
893
|
-
const ApiaApiTextArea = (props) => {
|
|
894
|
-
const element = React__default.useMemo(() => props.element, [props.element]);
|
|
895
|
-
const className = React__default.useMemo(
|
|
896
|
-
() => element.class ? `handler__textarea ${element.class}` : "handler__textarea",
|
|
897
|
-
[element.class]
|
|
898
|
-
);
|
|
899
|
-
const validationRules = React__default.useMemo(
|
|
900
|
-
() => __spreadValues$3({
|
|
901
|
-
required: element.mandatory,
|
|
902
|
-
maxLength: element.maxlength ? Number(element.maxlength) : void 0,
|
|
903
|
-
pattern: element.regExp,
|
|
904
|
-
patternMessage: element.regExpMessage
|
|
905
|
-
}, classToValidate(element.class)),
|
|
906
|
-
[
|
|
907
|
-
element.class,
|
|
908
|
-
element.mandatory,
|
|
909
|
-
element.maxlength,
|
|
910
|
-
element.regExp,
|
|
911
|
-
element.regExpMessage
|
|
912
|
-
]
|
|
913
|
-
);
|
|
914
|
-
const validationFunction = React__default.useMemo(
|
|
915
|
-
() => classToValidationFunction(element.class),
|
|
916
|
-
[element.class]
|
|
917
|
-
);
|
|
918
|
-
return /* @__PURE__ */ jsx(
|
|
919
|
-
Textarea,
|
|
920
|
-
{
|
|
921
|
-
className,
|
|
922
|
-
name: element.id || element.name,
|
|
923
|
-
label: element.text,
|
|
924
|
-
title: element.title || element.text,
|
|
925
|
-
value: element.value,
|
|
926
|
-
readOnly: element.readonly,
|
|
927
|
-
disabled: element.disabled,
|
|
928
|
-
validationFunction,
|
|
929
|
-
validationRules,
|
|
930
|
-
onChange: element.onChange
|
|
931
|
-
}
|
|
932
|
-
);
|
|
933
|
-
};
|
|
934
|
-
ApiaApiTextArea.displayName = "ApiaApiTextArea";
|
|
935
|
-
|
|
936
|
-
var __defProp$2 = Object.defineProperty;
|
|
937
|
-
var __defProps$2 = Object.defineProperties;
|
|
938
|
-
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
939
|
-
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
940
|
-
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
941
|
-
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
942
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
943
|
-
var __spreadValues$2 = (a, b) => {
|
|
944
|
-
for (var prop in b || (b = {}))
|
|
945
|
-
if (__hasOwnProp$2.call(b, prop))
|
|
946
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
947
|
-
if (__getOwnPropSymbols$2)
|
|
948
|
-
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
949
|
-
if (__propIsEnum$2.call(b, prop))
|
|
950
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
951
|
-
}
|
|
952
|
-
return a;
|
|
953
|
-
};
|
|
954
|
-
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
955
|
-
const parseApiaApiSections = (elements) => {
|
|
956
|
-
var _a;
|
|
957
|
-
const removeEndingSpacers = (sectionElements) => {
|
|
958
|
-
if (sectionElements.length > 1) {
|
|
959
|
-
for (let i = sectionElements.length - 1; i >= 0; i--) {
|
|
960
|
-
if (sectionElements[i].type === "empty") {
|
|
961
|
-
sectionElements.pop();
|
|
962
|
-
} else {
|
|
963
|
-
return sectionElements;
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
return sectionElements;
|
|
968
|
-
};
|
|
969
|
-
const sectionIndexes = [];
|
|
970
|
-
if (((_a = elements[0]) == null ? void 0 : _a.type) !== "2columnTitle") {
|
|
971
|
-
sectionIndexes.push(-1);
|
|
972
|
-
}
|
|
973
|
-
elements.forEach((element, index) => {
|
|
974
|
-
if (element.type === "2columnTitle") {
|
|
975
|
-
sectionIndexes.push(index);
|
|
976
|
-
}
|
|
977
|
-
});
|
|
978
|
-
const sections = [];
|
|
979
|
-
sectionIndexes.forEach((sectionIndex, arrayIndex) => {
|
|
980
|
-
const start = sectionIndex + 1 < elements.length ? sectionIndex + 1 : elements.length - 1;
|
|
981
|
-
const end = arrayIndex + 1 < sectionIndexes.length ? sectionIndexes[arrayIndex + 1] : void 0;
|
|
982
|
-
sections.push({
|
|
983
|
-
sectionId: `ApiaApiSection_${arrayIndex}`,
|
|
984
|
-
sectionHeader: sectionIndex !== -1 ? __spreadProps$2(__spreadValues$2({}, elements[sectionIndex]), {
|
|
985
|
-
sectionElementId: `sectionHeader_${arrayIndex}`
|
|
986
|
-
}) : void 0,
|
|
987
|
-
sectionElements: removeEndingSpacers(elements.slice(start, end)).map(
|
|
988
|
-
(currentElement) => __spreadProps$2(__spreadValues$2({}, currentElement), {
|
|
989
|
-
sectionElementId: `sectionElement_${currentElement.id || currentElement.name || uniqueId()}`
|
|
990
|
-
})
|
|
991
|
-
)
|
|
992
|
-
});
|
|
993
|
-
});
|
|
994
|
-
return sections;
|
|
995
|
-
};
|
|
996
|
-
const NonMemoizedApiaApiFieldsContainer = (props) => {
|
|
997
|
-
var _a, _b;
|
|
998
|
-
const elements = React__default.useMemo(
|
|
999
|
-
() => {
|
|
1000
|
-
var _a2, _b2, _c;
|
|
1001
|
-
return arrayOrArray((_c = (_b2 = (_a2 = props == null ? void 0 : props.definition) == null ? void 0 : _a2.form.elements) == null ? void 0 : _b2.element) != null ? _c : []);
|
|
1002
|
-
},
|
|
1003
|
-
[(_b = (_a = props == null ? void 0 : props.definition) == null ? void 0 : _a.form.elements) == null ? void 0 : _b.element]
|
|
1004
|
-
);
|
|
1005
|
-
const sections = React__default.useMemo(
|
|
1006
|
-
() => parseApiaApiSections(elements),
|
|
1007
|
-
[elements]
|
|
1008
|
-
);
|
|
1009
|
-
const renderSectionContent = React__default.useCallback(
|
|
1010
|
-
(sectionId, sectionElements) => {
|
|
1011
|
-
const isVisible = sectionElements.findIndex((element) => element.type !== "hidden") !== -1;
|
|
1012
|
-
return /* @__PURE__ */ jsx(
|
|
1013
|
-
Box,
|
|
1014
|
-
{
|
|
1015
|
-
className: isVisible ? "handler__form__elements__section__content" : `handler__form__elements__section__content handler__hidden`,
|
|
1016
|
-
children: sectionElements.map((current) => {
|
|
1017
|
-
const element = __spreadProps$2(__spreadValues$2({}, current), {
|
|
1018
|
-
onChange() {
|
|
1019
|
-
getFunction(current.onChange, props).then((onChangeMethod) => {
|
|
1020
|
-
if (onChangeMethod) {
|
|
1021
|
-
onChangeMethod();
|
|
1022
|
-
}
|
|
1023
|
-
}).catch(console.error);
|
|
1024
|
-
}
|
|
1025
|
-
});
|
|
1026
|
-
switch (element.type) {
|
|
1027
|
-
case "table": {
|
|
1028
|
-
const data = JSON.parse(element.text);
|
|
1029
|
-
return /* @__PURE__ */ jsx(
|
|
1030
|
-
Box,
|
|
1031
|
-
__spreadProps$2(__spreadValues$2({}, getVariant("layout.common.tables.information")), {
|
|
1032
|
-
children: /* @__PURE__ */ jsxs("table", { sx: { width: "100%" }, children: [
|
|
1033
|
-
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: data.columns.map((column) => {
|
|
1034
|
-
return /* @__PURE__ */ jsx("th", { children: column }, column);
|
|
1035
|
-
}) }) }),
|
|
1036
|
-
/* @__PURE__ */ jsx("tbody", { children: data.rows.map((row) => {
|
|
1037
|
-
return /* @__PURE__ */ jsx("tr", { children: row.cells.map((cell, i) => {
|
|
1038
|
-
return /* @__PURE__ */ jsx("td", { children: cell }, `${cell}_${data.columns[i]}`);
|
|
1039
|
-
}) }, row.cells.join("-"));
|
|
1040
|
-
}) })
|
|
1041
|
-
] })
|
|
1042
|
-
}),
|
|
1043
|
-
element.sectionElementId
|
|
1044
|
-
);
|
|
1045
|
-
}
|
|
1046
|
-
case "2columnSubTitle":
|
|
1047
|
-
return /* @__PURE__ */ jsx(
|
|
1048
|
-
Box,
|
|
1049
|
-
{
|
|
1050
|
-
className: element.class,
|
|
1051
|
-
as: "h6",
|
|
1052
|
-
children: element.value || element.text
|
|
1053
|
-
},
|
|
1054
|
-
element.sectionElementId
|
|
1055
|
-
);
|
|
1056
|
-
case "2column":
|
|
1057
|
-
return /* @__PURE__ */ jsx(
|
|
1058
|
-
Box,
|
|
1059
|
-
{
|
|
1060
|
-
dangerouslySetInnerHTML: {
|
|
1061
|
-
__html: element.value || element.text
|
|
1062
|
-
},
|
|
1063
|
-
className: element.class
|
|
1064
|
-
},
|
|
1065
|
-
element.sectionElementId
|
|
1066
|
-
);
|
|
1067
|
-
case "checkbox":
|
|
1068
|
-
return /* @__PURE__ */ jsx(
|
|
1069
|
-
ApiaApiCheckbox,
|
|
1070
|
-
__spreadProps$2(__spreadValues$2({}, props), {
|
|
1071
|
-
element
|
|
1072
|
-
}),
|
|
1073
|
-
element.sectionElementId
|
|
1074
|
-
);
|
|
1075
|
-
case "file":
|
|
1076
|
-
return /* @__PURE__ */ jsx(
|
|
1077
|
-
ApiaApiFileInput,
|
|
1078
|
-
__spreadProps$2(__spreadValues$2({}, props), {
|
|
1079
|
-
element
|
|
1080
|
-
}),
|
|
1081
|
-
element.sectionElementId
|
|
1082
|
-
);
|
|
1083
|
-
case "hidden":
|
|
1084
|
-
case "password":
|
|
1085
|
-
case "text":
|
|
1086
|
-
return /* @__PURE__ */ jsx(
|
|
1087
|
-
ApiaApiInput,
|
|
1088
|
-
__spreadProps$2(__spreadValues$2({}, props), {
|
|
1089
|
-
element
|
|
1090
|
-
}),
|
|
1091
|
-
element.sectionElementId
|
|
1092
|
-
);
|
|
1093
|
-
case "select":
|
|
1094
|
-
return /* @__PURE__ */ jsx(
|
|
1095
|
-
ApiaApiSelect,
|
|
1096
|
-
__spreadProps$2(__spreadValues$2({}, props), {
|
|
1097
|
-
element
|
|
1098
|
-
}),
|
|
1099
|
-
element.sectionElementId
|
|
1100
|
-
);
|
|
1101
|
-
case "radio":
|
|
1102
|
-
return /* @__PURE__ */ jsx(
|
|
1103
|
-
ApiaApiRadio,
|
|
1104
|
-
__spreadProps$2(__spreadValues$2({}, props), {
|
|
1105
|
-
element
|
|
1106
|
-
}),
|
|
1107
|
-
element.sectionElementId
|
|
1108
|
-
);
|
|
1109
|
-
case "textarea":
|
|
1110
|
-
return /* @__PURE__ */ jsx(
|
|
1111
|
-
ApiaApiTextArea,
|
|
1112
|
-
__spreadProps$2(__spreadValues$2({}, props), {
|
|
1113
|
-
element
|
|
1114
|
-
}),
|
|
1115
|
-
element.sectionElementId
|
|
1116
|
-
);
|
|
1117
|
-
case "empty":
|
|
1118
|
-
return /* @__PURE__ */ jsx(Box, { className: "spacer" }, element.sectionElementId);
|
|
1119
|
-
default:
|
|
1120
|
-
console.warn(
|
|
1121
|
-
`Unhandled element type: ${element.type}`,
|
|
1122
|
-
element
|
|
1123
|
-
);
|
|
1124
|
-
return null;
|
|
1125
|
-
}
|
|
1126
|
-
})
|
|
1127
|
-
},
|
|
1128
|
-
sectionId
|
|
1129
|
-
);
|
|
1130
|
-
},
|
|
1131
|
-
[props]
|
|
1132
|
-
);
|
|
1133
|
-
return /* @__PURE__ */ jsx(Box, { className: "handler__form__elements", children: sections.map((section) => {
|
|
1134
|
-
if (section.sectionHeader) {
|
|
1135
|
-
return renderSectionContent(
|
|
1136
|
-
section.sectionId,
|
|
1137
|
-
section.sectionElements
|
|
1138
|
-
);
|
|
1139
|
-
}
|
|
1140
|
-
return renderSectionContent(section.sectionId, section.sectionElements);
|
|
1141
|
-
}) });
|
|
1142
|
-
};
|
|
1143
|
-
const ApiaApiFieldsContainer = React__default.memo(
|
|
1144
|
-
NonMemoizedApiaApiFieldsContainer
|
|
1145
|
-
);
|
|
1146
|
-
ApiaApiFieldsContainer.displayName = "ApiaApiFieldsContainer";
|
|
1147
|
-
|
|
1148
|
-
var __defProp$1 = Object.defineProperty;
|
|
1149
|
-
var __defProps$1 = Object.defineProperties;
|
|
1150
|
-
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
1151
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
1152
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
1153
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
1154
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1155
|
-
var __spreadValues$1 = (a, b) => {
|
|
1156
|
-
for (var prop in b || (b = {}))
|
|
1157
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
1158
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
1159
|
-
if (__getOwnPropSymbols$1)
|
|
1160
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
1161
|
-
if (__propIsEnum$1.call(b, prop))
|
|
1162
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
1163
|
-
}
|
|
1164
|
-
return a;
|
|
1165
|
-
};
|
|
1166
|
-
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
1167
|
-
var __async$1 = (__this, __arguments, generator) => {
|
|
1168
|
-
return new Promise((resolve, reject) => {
|
|
1169
|
-
var fulfilled = (value) => {
|
|
1170
|
-
try {
|
|
1171
|
-
step(generator.next(value));
|
|
1172
|
-
} catch (e) {
|
|
1173
|
-
reject(e);
|
|
1174
|
-
}
|
|
1175
|
-
};
|
|
1176
|
-
var rejected = (value) => {
|
|
1177
|
-
try {
|
|
1178
|
-
step(generator.throw(value));
|
|
1179
|
-
} catch (e) {
|
|
1180
|
-
reject(e);
|
|
1181
|
-
}
|
|
1182
|
-
};
|
|
1183
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
1184
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
1185
|
-
});
|
|
1186
|
-
};
|
|
1187
|
-
var __forAwait = (obj, it, method) => {
|
|
1188
|
-
it = obj[Symbol.asyncIterator];
|
|
1189
|
-
method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((resolve, reject, done) => {
|
|
1190
|
-
arg = fn.call(obj, arg);
|
|
1191
|
-
done = arg.done;
|
|
1192
|
-
return Promise.resolve(arg.value).then((value) => resolve({ value, done }), reject);
|
|
1193
|
-
}));
|
|
1194
|
-
return it ? it.call(obj) : (obj = obj[Symbol.iterator](), it = {}, method("next"), method("return"), it);
|
|
1195
|
-
};
|
|
1196
|
-
const parseButtons = (buttons) => {
|
|
1197
|
-
return buttons.map((currentButton) => __spreadProps$1(__spreadValues$1({}, currentButton), {
|
|
1198
|
-
buttonKey: uniqueId(),
|
|
1199
|
-
type: ["submitAjax", "submit"].includes(currentButton.type) ? "submit" : "button"
|
|
1200
|
-
}));
|
|
1201
|
-
};
|
|
1202
|
-
const NonMemoizedApiaApiButtonsContainer = (props) => {
|
|
1203
|
-
var _a, _b, _c, _d;
|
|
1204
|
-
const buttonElements = React__default.useMemo(
|
|
1205
|
-
() => {
|
|
1206
|
-
var _a2, _b2, _c2;
|
|
1207
|
-
return arrayOrArray((_c2 = (_b2 = (_a2 = props.definition) == null ? void 0 : _a2.form.buttons) == null ? void 0 : _b2.button) != null ? _c2 : []);
|
|
1208
|
-
},
|
|
1209
|
-
[(_b = (_a = props.definition) == null ? void 0 : _a.form.buttons) == null ? void 0 : _b.button]
|
|
1210
|
-
);
|
|
1211
|
-
const buttons = React__default.useMemo(
|
|
1212
|
-
() => parseButtons(buttonElements),
|
|
1213
|
-
[buttonElements]
|
|
1214
|
-
);
|
|
1215
|
-
const modalConfiguration = React__default.useMemo(
|
|
1216
|
-
() => {
|
|
1217
|
-
var _a2;
|
|
1218
|
-
return (_a2 = props.configuration) == null ? void 0 : _a2.modalConfiguration;
|
|
1219
|
-
},
|
|
1220
|
-
[(_c = props.configuration) == null ? void 0 : _c.modalConfiguration]
|
|
1221
|
-
);
|
|
1222
|
-
const methodsPath = React__default.useMemo(
|
|
1223
|
-
() => {
|
|
1224
|
-
var _a2;
|
|
1225
|
-
return (_a2 = props.configuration) == null ? void 0 : _a2.methodsPath;
|
|
1226
|
-
},
|
|
1227
|
-
[(_d = props.configuration) == null ? void 0 : _d.methodsPath]
|
|
1228
|
-
);
|
|
1229
|
-
const { name: apiaApiForm } = useFormContext();
|
|
1230
|
-
const renderButton = React__default.useCallback(
|
|
1231
|
-
(currentButton) => {
|
|
1232
|
-
var _a2;
|
|
1233
|
-
const key = currentButton.buttonKey;
|
|
1234
|
-
const className = `handler__${(_a2 = currentButton.type) != null ? _a2 : ""}`;
|
|
1235
|
-
const onClick = () => {
|
|
1236
|
-
void function submitForm() {
|
|
1237
|
-
return __async$1(this, null, function* () {
|
|
1238
|
-
const validationResult = yield validationsStore.validateForm(
|
|
1239
|
-
apiaApiForm
|
|
1240
|
-
);
|
|
1241
|
-
if (!hasSucceedFormValidation(validationResult)) {
|
|
1242
|
-
return;
|
|
1243
|
-
}
|
|
1244
|
-
const { submitValues } = validationResult;
|
|
1245
|
-
function runButtonMethod() {
|
|
1246
|
-
void (() => __async$1(this, null, function* () {
|
|
1247
|
-
var _a3, _b2, _c2, _d2;
|
|
1248
|
-
if (currentButton.onclick) {
|
|
1249
|
-
const actions = currentButton.onclick.split(";");
|
|
1250
|
-
try {
|
|
1251
|
-
for (var iter = __forAwait(actions), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
|
|
1252
|
-
const action = temp.value;
|
|
1253
|
-
const method = yield getFunction(action, __spreadValues$1({}, props));
|
|
1254
|
-
if (method) {
|
|
1255
|
-
method({
|
|
1256
|
-
currentUrl: (_b2 = (_a3 = props.definition) == null ? void 0 : _a3.form.action) != null ? _b2 : "noUrl"
|
|
1257
|
-
});
|
|
1258
|
-
} else {
|
|
1259
|
-
throw new Error(
|
|
1260
|
-
`The requested action is not defined: "${(_d2 = (_c2 = props.definition) == null ? void 0 : _c2.form.action) != null ? _d2 : ""}"`
|
|
1261
|
-
);
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
} catch (temp) {
|
|
1265
|
-
error = [temp];
|
|
1266
|
-
} finally {
|
|
1267
|
-
try {
|
|
1268
|
-
more && (temp = iter.return) && (yield temp.call(iter));
|
|
1269
|
-
} finally {
|
|
1270
|
-
if (error)
|
|
1271
|
-
throw error[0];
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
}))();
|
|
1276
|
-
}
|
|
1277
|
-
if ((props == null ? void 0 : props.definition) && currentButton.type === "submit") {
|
|
1278
|
-
const formData = new FormData();
|
|
1279
|
-
Object.entries(submitValues).forEach(([name, value]) => {
|
|
1280
|
-
formData.append(name, value != null ? value : "");
|
|
1281
|
-
});
|
|
1282
|
-
const hasContext = props == null ? void 0 : props.definition.form.action.match(
|
|
1283
|
-
new RegExp(`^${window.CONTEXT}/`)
|
|
1284
|
-
);
|
|
1285
|
-
const url = `${hasContext ? "" : window.CONTEXT}${!(props == null ? void 0 : props.definition.form.action.startsWith("/")) ? "/" : ""}${props == null ? void 0 : props.definition.form.action}`;
|
|
1286
|
-
props.setState((current) => __spreadProps$1(__spreadValues$1({}, current), {
|
|
1287
|
-
isLoading: true
|
|
1288
|
-
}));
|
|
1289
|
-
void ApiaApi.post(url, {
|
|
1290
|
-
postData: props.state.isMultipart ? formData : QueryString.stringify(
|
|
1291
|
-
[...formData.entries(), ["isAjax", true]].reduce((accumulated, [name, value]) => {
|
|
1292
|
-
const retValue = __spreadValues$1({}, accumulated);
|
|
1293
|
-
retValue[name.toString()] = value.toString();
|
|
1294
|
-
return retValue;
|
|
1295
|
-
}, {})
|
|
1296
|
-
),
|
|
1297
|
-
handleLoad: true,
|
|
1298
|
-
notificationsCategory: "apiaApiHandler",
|
|
1299
|
-
modalConfiguration,
|
|
1300
|
-
methodsPath
|
|
1301
|
-
}).finally(() => {
|
|
1302
|
-
var _a3;
|
|
1303
|
-
runButtonMethod();
|
|
1304
|
-
if ((_a3 = props == null ? void 0 : props.definition) == null ? void 0 : _a3.form.closeOnSubmit) {
|
|
1305
|
-
props.close();
|
|
1306
|
-
}
|
|
1307
|
-
});
|
|
1308
|
-
} else {
|
|
1309
|
-
runButtonMethod();
|
|
1310
|
-
}
|
|
1311
|
-
});
|
|
1312
|
-
}();
|
|
1313
|
-
};
|
|
1314
|
-
return /* @__PURE__ */ jsx(
|
|
1315
|
-
SimpleButton,
|
|
1316
|
-
{
|
|
1317
|
-
className,
|
|
1318
|
-
disabled: props.state.disabled,
|
|
1319
|
-
id: currentButton.id || currentButton.text,
|
|
1320
|
-
isLoading: props.state.isLoading,
|
|
1321
|
-
title: currentButton.text,
|
|
1322
|
-
type: currentButton.type,
|
|
1323
|
-
onClick,
|
|
1324
|
-
children: currentButton.text
|
|
1325
|
-
},
|
|
1326
|
-
key
|
|
1327
|
-
);
|
|
1328
|
-
},
|
|
1329
|
-
[apiaApiForm, methodsPath, modalConfiguration, props]
|
|
1330
|
-
);
|
|
1331
|
-
return /* @__PURE__ */ jsx(Box, { className: "handler__form__buttons", children: buttons.map((currentButton) => renderButton(currentButton)) });
|
|
1332
|
-
};
|
|
1333
|
-
const ApiaApiButtonsContainer = React__default.memo(
|
|
1334
|
-
NonMemoizedApiaApiButtonsContainer
|
|
1335
|
-
);
|
|
1336
|
-
|
|
1337
|
-
var __defProp = Object.defineProperty;
|
|
1338
|
-
var __defProps = Object.defineProperties;
|
|
1339
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
1340
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1341
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1342
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
1343
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1344
|
-
var __spreadValues = (a, b) => {
|
|
1345
|
-
for (var prop in b || (b = {}))
|
|
1346
|
-
if (__hasOwnProp.call(b, prop))
|
|
1347
|
-
__defNormalProp(a, prop, b[prop]);
|
|
1348
|
-
if (__getOwnPropSymbols)
|
|
1349
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
1350
|
-
if (__propIsEnum.call(b, prop))
|
|
1351
|
-
__defNormalProp(a, prop, b[prop]);
|
|
1352
|
-
}
|
|
1353
|
-
return a;
|
|
1354
|
-
};
|
|
1355
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1356
|
-
var __objRest = (source, exclude) => {
|
|
1357
|
-
var target = {};
|
|
1358
|
-
for (var prop in source)
|
|
1359
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1360
|
-
target[prop] = source[prop];
|
|
1361
|
-
if (source != null && __getOwnPropSymbols)
|
|
1362
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
1363
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
1364
|
-
target[prop] = source[prop];
|
|
1365
|
-
}
|
|
1366
|
-
return target;
|
|
1367
|
-
};
|
|
1368
|
-
var __async = (__this, __arguments, generator) => {
|
|
1369
|
-
return new Promise((resolve, reject) => {
|
|
1370
|
-
var fulfilled = (value) => {
|
|
1371
|
-
try {
|
|
1372
|
-
step(generator.next(value));
|
|
1373
|
-
} catch (e) {
|
|
1374
|
-
reject(e);
|
|
1375
|
-
}
|
|
1376
|
-
};
|
|
1377
|
-
var rejected = (value) => {
|
|
1378
|
-
try {
|
|
1379
|
-
step(generator.throw(value));
|
|
1380
|
-
} catch (e) {
|
|
1381
|
-
reject(e);
|
|
1382
|
-
}
|
|
1383
|
-
};
|
|
1384
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
1385
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
1386
|
-
});
|
|
1387
|
-
};
|
|
1388
|
-
const ApiaApiMessenger = new class extends EventEmitter {
|
|
1389
|
-
}();
|
|
1390
|
-
const FunctionsDispatcher = new class extends EventEmitter {
|
|
1391
|
-
}();
|
|
1392
|
-
const apiaApiForm = "ApiaApiForm";
|
|
1393
|
-
const methods = {};
|
|
1394
|
-
function getFunction(name, handler) {
|
|
1395
|
-
return __async(this, null, function* () {
|
|
1396
|
-
return new Promise((resolve) => {
|
|
1397
|
-
var _a, _b, _c;
|
|
1398
|
-
try {
|
|
1399
|
-
const separateNameFromParametersRegex = /^\/?([\w\d_-]+)\/?(?:\(([^)]*)\))?$/;
|
|
1400
|
-
const match = name.match(separateNameFromParametersRegex);
|
|
1401
|
-
if (match) {
|
|
1402
|
-
const functionName = match[1];
|
|
1403
|
-
const parameters = match[2];
|
|
1404
|
-
const path = [
|
|
1405
|
-
...(_c = (_b = (_a = handler.configuration) == null ? void 0 : _a.methodsPath) == null ? void 0 : _b.split("/").filter((current) => !!current)) != null ? _c : [],
|
|
1406
|
-
functionName
|
|
1407
|
-
].join("/");
|
|
1408
|
-
const storeMethodAndResolve = (result) => {
|
|
1409
|
-
if (typeof result.default !== "function")
|
|
1410
|
-
notFound();
|
|
1411
|
-
const method = result.default;
|
|
1412
|
-
methods[functionName] = (props) => {
|
|
1413
|
-
var _a2;
|
|
1414
|
-
return method(handler, __spreadProps(__spreadValues({}, props), {
|
|
1415
|
-
inlineArguments: (_a2 = parameters == null ? void 0 : parameters.split(",").map((argument) => {
|
|
1416
|
-
if (argument.startsWith("'") || argument.startsWith('"'))
|
|
1417
|
-
return argument.slice(1, argument.length - 1);
|
|
1418
|
-
return argument;
|
|
1419
|
-
})) != null ? _a2 : []
|
|
1420
|
-
}));
|
|
1421
|
-
};
|
|
1422
|
-
resolve(methods[functionName]);
|
|
1423
|
-
};
|
|
1424
|
-
const notFound = () => {
|
|
1425
|
-
throw new Error(
|
|
1426
|
-
`${functionName}.ts not found at ${path}.ts nor ./${functionName}.ts`
|
|
1427
|
-
);
|
|
1428
|
-
};
|
|
1429
|
-
import(
|
|
1430
|
-
/* webpackChunkName: "api-methods-[request]" */
|
|
1431
|
-
`/api/methods/${path}.ts`
|
|
1432
|
-
).then(storeMethodAndResolve).catch(() => {
|
|
1433
|
-
var _a2;
|
|
1434
|
-
if (((_a2 = handler.configuration) == null ? void 0 : _a2.methodsPath) !== void 0)
|
|
1435
|
-
import(
|
|
1436
|
-
/* webpackChunkName: "api-methods-[request]" */
|
|
1437
|
-
`/api/methods/${functionName}.ts`
|
|
1438
|
-
).then(storeMethodAndResolve).catch(notFound);
|
|
1439
|
-
else {
|
|
1440
|
-
notFound();
|
|
1441
|
-
}
|
|
1442
|
-
});
|
|
1443
|
-
}
|
|
1444
|
-
} catch (e) {
|
|
1445
|
-
console.error(e);
|
|
1446
|
-
handler.reset();
|
|
1447
|
-
handler.setError({
|
|
1448
|
-
type: "danger",
|
|
1449
|
-
message: "Error while loading current method."
|
|
1450
|
-
});
|
|
1451
|
-
}
|
|
1452
|
-
});
|
|
1453
|
-
});
|
|
1454
|
-
}
|
|
1455
|
-
function isForm(responseObject) {
|
|
1456
|
-
return responseObject.form !== void 0 && typeof responseObject.form === "object" && !!responseObject.form;
|
|
1457
|
-
}
|
|
1458
|
-
function isFunction(responseObject) {
|
|
1459
|
-
return typeof responseObject.canClose === "boolean" && typeof responseObject.type === "string" && !!responseObject.function;
|
|
1460
|
-
}
|
|
1461
|
-
function isMessage(responseObject) {
|
|
1462
|
-
if (typeof responseObject.canClose === "boolean" && typeof responseObject.type === "string" && typeof responseObject.text === "object" && responseObject.text && typeof responseObject.text.label === "string") {
|
|
1463
|
-
return true;
|
|
1464
|
-
}
|
|
1465
|
-
return false;
|
|
1466
|
-
}
|
|
1467
|
-
const modalConfigurationHandler = new WithEventsValue();
|
|
1468
|
-
function useModalConfiguration() {
|
|
1469
|
-
const [, setValue, value] = useStateRef(
|
|
1470
|
-
void 0
|
|
1471
|
-
);
|
|
1472
|
-
const handleChange = React.useCallback(
|
|
1473
|
-
(newEventsHandler) => {
|
|
1474
|
-
setValue(newEventsHandler);
|
|
1475
|
-
},
|
|
1476
|
-
[setValue]
|
|
1477
|
-
);
|
|
1478
|
-
useMount(() => {
|
|
1479
|
-
modalConfigurationHandler.on("update", handleChange);
|
|
1480
|
-
});
|
|
1481
|
-
useUnmount(() => {
|
|
1482
|
-
return modalConfigurationHandler.off("update", handleChange);
|
|
1483
|
-
});
|
|
1484
|
-
return value;
|
|
1485
|
-
}
|
|
1486
|
-
const currentFormDispatcher = new class currentFormDispatcher2 extends EventEmitter {
|
|
1487
|
-
emit(eventName, params) {
|
|
1488
|
-
super.emit(eventName, params);
|
|
1489
|
-
}
|
|
1490
|
-
}();
|
|
1491
|
-
function handle(responseObject, currentUrl, configuration) {
|
|
1492
|
-
modalConfigurationHandler.value = configuration;
|
|
1493
|
-
if (isForm(responseObject)) {
|
|
1494
|
-
currentFormDispatcher.emit("form", responseObject);
|
|
1495
|
-
return true;
|
|
1496
|
-
}
|
|
1497
|
-
if (isFunction(responseObject)) {
|
|
1498
|
-
FunctionsDispatcher.emit("method", {
|
|
1499
|
-
name: responseObject.function.name,
|
|
1500
|
-
props: {
|
|
1501
|
-
messages: responseObject.function.messages,
|
|
1502
|
-
attributes: responseObject.function,
|
|
1503
|
-
currentUrl
|
|
1504
|
-
}
|
|
1505
|
-
});
|
|
1506
|
-
return true;
|
|
1507
|
-
}
|
|
1508
|
-
if (isMessage(responseObject)) {
|
|
1509
|
-
ApiaApiMessenger.emit("message", {
|
|
1510
|
-
predicate: responseObject.text.content,
|
|
1511
|
-
title: responseObject.text.title
|
|
1512
|
-
});
|
|
1513
|
-
return true;
|
|
1514
|
-
}
|
|
1515
|
-
return false;
|
|
1516
|
-
}
|
|
1517
|
-
const initialState = {
|
|
1518
|
-
disabled: false,
|
|
1519
|
-
isLoading: false,
|
|
1520
|
-
isMultipart: false,
|
|
1521
|
-
progress: 0,
|
|
1522
|
-
errors: {}
|
|
1523
|
-
};
|
|
1524
|
-
const ApiaApiHandlerNonMemoized = () => {
|
|
1525
|
-
const configuration = useModalConfiguration();
|
|
1526
|
-
const [state, setState] = React.useState(__spreadProps(__spreadValues({}, initialState), {
|
|
1527
|
-
windowIndex: -1
|
|
1528
|
-
}));
|
|
1529
|
-
const [currentForm2, setCurrentForm] = React.useState(
|
|
1530
|
-
void 0
|
|
1531
|
-
);
|
|
1532
|
-
React.useEffect(() => {
|
|
1533
|
-
return currentFormDispatcher.on("form", setCurrentForm);
|
|
1534
|
-
}, []);
|
|
1535
|
-
const setValue = React.useCallback((name, value) => {
|
|
1536
|
-
return validationsStore.setFieldValue(apiaApiForm, name, value);
|
|
1537
|
-
}, []);
|
|
1538
|
-
React.useEffect(() => {
|
|
1539
|
-
var _a2, _b, _c;
|
|
1540
|
-
if (!currentForm2)
|
|
1541
|
-
return;
|
|
1542
|
-
const elements = arrayOrArray((_c = (_b = (_a2 = currentForm2 == null ? void 0 : currentForm2.form) == null ? void 0 : _a2.elements) == null ? void 0 : _b.element) != null ? _c : []);
|
|
1543
|
-
let isMultipart = false;
|
|
1544
|
-
const elementsValues = Object.values(elements);
|
|
1545
|
-
let i = 0;
|
|
1546
|
-
while (i < elementsValues.length && !isMultipart) {
|
|
1547
|
-
if (elementsValues[i++].type === "file") {
|
|
1548
|
-
isMultipart = true;
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
setState((currentState) => {
|
|
1552
|
-
return __spreadProps(__spreadValues(__spreadValues({}, currentState), initialState), {
|
|
1553
|
-
isMultipart
|
|
1554
|
-
});
|
|
1555
|
-
});
|
|
1556
|
-
}, [currentForm2]);
|
|
1557
|
-
const _a = useModal(), { show, onClose } = _a, modalHookProps = __objRest(_a, ["show", "onClose"]);
|
|
1558
|
-
const close = React.useCallback(() => {
|
|
1559
|
-
var _a2, _b, _c;
|
|
1560
|
-
onClose();
|
|
1561
|
-
currentFormDispatcher.emit("form", void 0);
|
|
1562
|
-
setState((currentState) => {
|
|
1563
|
-
return __spreadValues(__spreadValues({}, currentState), initialState);
|
|
1564
|
-
});
|
|
1565
|
-
(_c = (_b = (_a2 = configuration.current) == null ? void 0 : _a2.modalConfiguration) == null ? void 0 : _b.onClose) == null ? void 0 : _c.call(_b);
|
|
1566
|
-
validationsStore.unregisterForm(apiaApiForm);
|
|
1567
|
-
}, [onClose, configuration]);
|
|
1568
|
-
const modalRef = React.useRef(null);
|
|
1569
|
-
React.useEffect(() => {
|
|
1570
|
-
var _a2;
|
|
1571
|
-
const elements = (_a2 = modalRef.current) == null ? void 0 : _a2.querySelectorAll(
|
|
1572
|
-
"a,input,textarea,button"
|
|
1573
|
-
);
|
|
1574
|
-
if ((elements == null ? void 0 : elements.length) === 1)
|
|
1575
|
-
void focus.on([...elements][0]);
|
|
1576
|
-
});
|
|
1577
|
-
const setError = React.useCallback(
|
|
1578
|
-
(notification) => {
|
|
1579
|
-
notify(__spreadValues({}, notification));
|
|
1580
|
-
},
|
|
1581
|
-
[]
|
|
1582
|
-
);
|
|
1583
|
-
const initialFocusGetter = React.useCallback((ref) => {
|
|
1584
|
-
return ref == null ? void 0 : ref.querySelector(focusSelector);
|
|
1585
|
-
}, []);
|
|
1586
|
-
const defaultModalProps = React.useMemo(
|
|
1587
|
-
() => {
|
|
1588
|
-
var _a2, _b, _c;
|
|
1589
|
-
return {
|
|
1590
|
-
onClose: close,
|
|
1591
|
-
id: apiaApiForm,
|
|
1592
|
-
title: (_c = (_b = (_a2 = configuration.current) == null ? void 0 : _a2.modalConfiguration) == null ? void 0 : _b.modalTitle) != null ? _c : currentForm2 == null ? void 0 : currentForm2.form.title,
|
|
1593
|
-
size: "md-fixed",
|
|
1594
|
-
shouldCloseOnEsc: !state.disabled,
|
|
1595
|
-
shouldCloseOnOverlayClick: !state.disabled,
|
|
1596
|
-
initialFocusGetter
|
|
1597
|
-
};
|
|
1598
|
-
},
|
|
1599
|
-
[
|
|
1600
|
-
close,
|
|
1601
|
-
configuration,
|
|
1602
|
-
currentForm2 == null ? void 0 : currentForm2.form.title,
|
|
1603
|
-
initialFocusGetter,
|
|
1604
|
-
state.disabled
|
|
1605
|
-
]
|
|
1606
|
-
);
|
|
1607
|
-
const getModalProps = React.useCallback(
|
|
1608
|
-
(innerHandler) => {
|
|
1609
|
-
var _a2, _b, _c;
|
|
1610
|
-
if (innerHandler.setModalProps) {
|
|
1611
|
-
const overrideProps = (_c = innerHandler.setModalProps) == null ? void 0 : _c.call(
|
|
1612
|
-
innerHandler,
|
|
1613
|
-
{
|
|
1614
|
-
methodsPath: (_a2 = innerHandler.configuration) == null ? void 0 : _a2.methodsPath,
|
|
1615
|
-
modalConfiguration: (_b = innerHandler.configuration) == null ? void 0 : _b.modalConfiguration
|
|
1616
|
-
},
|
|
1617
|
-
innerHandler.formDefinition
|
|
1618
|
-
);
|
|
1619
|
-
if (overrideProps) {
|
|
1620
|
-
const currentOnClose = () => {
|
|
1621
|
-
var _a3, _b2;
|
|
1622
|
-
(_a3 = overrideProps == null ? void 0 : overrideProps.onClose) == null ? void 0 : _a3.call(overrideProps);
|
|
1623
|
-
(_b2 = defaultModalProps.onClose) == null ? void 0 : _b2.call(defaultModalProps);
|
|
1624
|
-
};
|
|
1625
|
-
const currentOnExited = () => {
|
|
1626
|
-
var _a3, _b2;
|
|
1627
|
-
(_a3 = overrideProps == null ? void 0 : overrideProps.onExited) == null ? void 0 : _a3.call(overrideProps);
|
|
1628
|
-
(_b2 = modalHookProps == null ? void 0 : modalHookProps.onExited) == null ? void 0 : _b2.call(modalHookProps);
|
|
1629
|
-
};
|
|
1630
|
-
return __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, defaultModalProps), overrideProps), modalHookProps), {
|
|
1631
|
-
onClose: currentOnClose,
|
|
1632
|
-
onExited: currentOnExited
|
|
1633
|
-
});
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
return __spreadValues(__spreadValues({}, defaultModalProps), modalHookProps);
|
|
1637
|
-
},
|
|
1638
|
-
[defaultModalProps, modalHookProps]
|
|
1639
|
-
);
|
|
1640
|
-
const getHandler = React.useCallback(() => {
|
|
1641
|
-
const newHandler = {
|
|
1642
|
-
alert,
|
|
1643
|
-
close,
|
|
1644
|
-
configuration: configuration.current,
|
|
1645
|
-
formDefinition: currentForm2,
|
|
1646
|
-
reset: () => {
|
|
1647
|
-
return setState((currentState) => {
|
|
1648
|
-
return __spreadValues(__spreadValues({}, currentState), initialState);
|
|
1649
|
-
});
|
|
1650
|
-
},
|
|
1651
|
-
setError,
|
|
1652
|
-
setMessage: (message) => {
|
|
1653
|
-
var _a2, _b;
|
|
1654
|
-
if ((_b = (_a2 = configuration.current) == null ? void 0 : _a2.modalConfiguration) == null ? void 0 : _b.onMessage)
|
|
1655
|
-
configuration.current.modalConfiguration.onMessage(message);
|
|
1656
|
-
},
|
|
1657
|
-
setState,
|
|
1658
|
-
state,
|
|
1659
|
-
setValue
|
|
1660
|
-
};
|
|
1661
|
-
return newHandler;
|
|
1662
|
-
}, [close, configuration, currentForm2, setError, state, setValue]);
|
|
1663
|
-
const handler = getHandler();
|
|
1664
|
-
const modalProps = getModalProps(handler);
|
|
1665
|
-
const handleAction = React.useCallback(
|
|
1666
|
-
(action) => __async(void 0, null, function* () {
|
|
1667
|
-
const innerHandler = getHandler();
|
|
1668
|
-
if (action.toDo === "ajaxHiddeAll") {
|
|
1669
|
-
close();
|
|
1670
|
-
}
|
|
1671
|
-
if (action.toDo === "functionTimedCall") {
|
|
1672
|
-
const method = yield getFunction(
|
|
1673
|
-
arrayOrArray(action.param)[1],
|
|
1674
|
-
innerHandler
|
|
1675
|
-
);
|
|
1676
|
-
if (method) {
|
|
1677
|
-
setTimeout(
|
|
1678
|
-
() => {
|
|
1679
|
-
var _a2, _b;
|
|
1680
|
-
return method({
|
|
1681
|
-
currentUrl: (_b = (_a2 = innerHandler.formDefinition) == null ? void 0 : _a2.form.action) != null ? _b : "noUrl"
|
|
1682
|
-
});
|
|
1683
|
-
},
|
|
1684
|
-
Number(action.param[0])
|
|
1685
|
-
);
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
}),
|
|
1689
|
-
[close, getHandler]
|
|
1690
|
-
);
|
|
1691
|
-
const handleFunction = React.useCallback(
|
|
1692
|
-
(_0) => __async(void 0, [_0], function* ({ name, props: { messages, attributes, currentUrl } }) {
|
|
1693
|
-
const innerHandler = getHandler();
|
|
1694
|
-
const method = yield getFunction(`${name}`, innerHandler);
|
|
1695
|
-
if (method) {
|
|
1696
|
-
method({ messages, attributes, currentUrl });
|
|
1697
|
-
}
|
|
1698
|
-
}),
|
|
1699
|
-
[getHandler]
|
|
1700
|
-
);
|
|
1701
|
-
const handleMessage = React.useCallback(
|
|
1702
|
-
(ev) => {
|
|
1703
|
-
var _a2, _b, _c, _d;
|
|
1704
|
-
const innerHandler = getHandler();
|
|
1705
|
-
notify({
|
|
1706
|
-
message: ev.predicate,
|
|
1707
|
-
type: "warning",
|
|
1708
|
-
onClose: (_b = (_a2 = innerHandler.configuration) == null ? void 0 : _a2.modalConfiguration) == null ? void 0 : _b.onMessageClose
|
|
1709
|
-
});
|
|
1710
|
-
const onMessage = (_d = (_c = innerHandler.configuration) == null ? void 0 : _c.modalConfiguration) == null ? void 0 : _d.onMessage;
|
|
1711
|
-
if (onMessage) {
|
|
1712
|
-
onMessage(ev);
|
|
1713
|
-
}
|
|
1714
|
-
},
|
|
1715
|
-
[getHandler]
|
|
1716
|
-
);
|
|
1717
|
-
React.useEffect(() => {
|
|
1718
|
-
ApiaApiMessenger.on("message", handleMessage);
|
|
1719
|
-
FunctionsDispatcher.on("method", handleFunction);
|
|
1720
|
-
ApiaActions.on("action", handleAction);
|
|
1721
|
-
return () => {
|
|
1722
|
-
ApiaApiMessenger.off("message", handleMessage);
|
|
1723
|
-
FunctionsDispatcher.off("method", handleFunction);
|
|
1724
|
-
ApiaActions.off("action", handleAction);
|
|
1725
|
-
};
|
|
1726
|
-
}, [handleAction, handleFunction, handleMessage, state.windowIndex]);
|
|
1727
|
-
React.useEffect(() => {
|
|
1728
|
-
if (currentForm2) {
|
|
1729
|
-
show();
|
|
1730
|
-
}
|
|
1731
|
-
}, [currentForm2]);
|
|
1732
|
-
const formRef = React.useCallback(
|
|
1733
|
-
(el) => __async(void 0, null, function* () {
|
|
1734
|
-
if (el && (currentForm2 == null ? void 0 : currentForm2.form.onLoad)) {
|
|
1735
|
-
const method = yield getFunction(
|
|
1736
|
-
`${currentForm2 == null ? void 0 : currentForm2.form.onLoad}`,
|
|
1737
|
-
getHandler()
|
|
1738
|
-
);
|
|
1739
|
-
if (method) {
|
|
1740
|
-
method();
|
|
1741
|
-
}
|
|
1742
|
-
}
|
|
1743
|
-
}),
|
|
1744
|
-
[currentForm2 == null ? void 0 : currentForm2.form.onLoad, getHandler]
|
|
1745
|
-
);
|
|
1746
|
-
return /* @__PURE__ */ jsx(ApiaApiContext$1, { id: apiaApiForm, children: /* @__PURE__ */ jsx(Modal, __spreadProps(__spreadValues({}, modalProps), { ref: modalRef, children: currentForm2 && /* @__PURE__ */ jsx(Box, __spreadProps(__spreadValues({}, getVariant("layout.common.modals.apiaApi")), { children: /* @__PURE__ */ jsxs(
|
|
1747
|
-
Form,
|
|
1748
|
-
{
|
|
1749
|
-
name: apiaApiForm,
|
|
1750
|
-
unregisterOnUnmount: true,
|
|
1751
|
-
avoidFieldsOverride: true,
|
|
1752
|
-
className: "handler__form",
|
|
1753
|
-
children: [
|
|
1754
|
-
/* @__PURE__ */ jsx(ApiaApiFieldsContainer, __spreadValues({ definition: currentForm2 }, handler)),
|
|
1755
|
-
state.isMultipart && state.progress > 0 && /* @__PURE__ */ jsx(Box, { className: "progressBox", children: /* @__PURE__ */ jsx(
|
|
1756
|
-
ProgressBar,
|
|
1757
|
-
{
|
|
1758
|
-
id: "ApiaApiHandler progress",
|
|
1759
|
-
progress: state.progress,
|
|
1760
|
-
loading: true
|
|
1761
|
-
}
|
|
1762
|
-
) }),
|
|
1763
|
-
/* @__PURE__ */ jsx(ApiaApiButtonsContainer, __spreadValues({ definition: currentForm2 }, handler)),
|
|
1764
|
-
/* @__PURE__ */ jsx(Box, { ref: formRef, sx: { display: "none" } })
|
|
1765
|
-
]
|
|
1766
|
-
}
|
|
1767
|
-
) })) })) });
|
|
1768
|
-
};
|
|
1769
|
-
const ApiaApiHandler = React.memo(ApiaApiHandlerNonMemoized);
|
|
1770
|
-
|
|
1771
|
-
export { ApiaApi, ApiaApiHandler, getFunction, getModal, makeApiaUrl };
|
|
1
|
+
export { ApiaApiHandler, getFunction } from './ApiaApiHandler.js';
|
|
2
|
+
export { default as ApiaApi, makeApiaUrl } from './apiaApi.js';
|
|
3
|
+
export { getModal } from './fields/ApiaApiInput.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|