@bluemarble/bm-components 2.4.0 → 3.0.0-beta.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/index.cjs +1600 -1365
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +251 -154
- package/dist/index.d.ts +251 -154
- package/dist/index.js +1918 -1683
- package/dist/index.js.map +1 -1
- package/package.json +26 -29
package/dist/index.cjs
CHANGED
|
@@ -206,7 +206,7 @@ var require_react_is_development = __commonJS({
|
|
|
206
206
|
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
207
207
|
var Element = REACT_ELEMENT_TYPE;
|
|
208
208
|
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
209
|
-
var
|
|
209
|
+
var Fragment10 = REACT_FRAGMENT_TYPE;
|
|
210
210
|
var Lazy = REACT_LAZY_TYPE;
|
|
211
211
|
var Memo = REACT_MEMO_TYPE;
|
|
212
212
|
var Portal2 = REACT_PORTAL_TYPE;
|
|
@@ -265,7 +265,7 @@ var require_react_is_development = __commonJS({
|
|
|
265
265
|
exports.ContextProvider = ContextProvider;
|
|
266
266
|
exports.Element = Element;
|
|
267
267
|
exports.ForwardRef = ForwardRef;
|
|
268
|
-
exports.Fragment =
|
|
268
|
+
exports.Fragment = Fragment10;
|
|
269
269
|
exports.Lazy = Lazy;
|
|
270
270
|
exports.Memo = Memo;
|
|
271
271
|
exports.Portal = Portal2;
|
|
@@ -1179,13 +1179,283 @@ var require_react_is2 = __commonJS({
|
|
|
1179
1179
|
}
|
|
1180
1180
|
});
|
|
1181
1181
|
|
|
1182
|
+
// packages/http-client/types.ts
|
|
1183
|
+
var HttpClientError = class _HttpClientError extends Error {
|
|
1184
|
+
constructor(status, statusText, data) {
|
|
1185
|
+
super(`Request failed with status ${status}: ${statusText}`);
|
|
1186
|
+
this.name = "HttpClientError";
|
|
1187
|
+
this.status = status;
|
|
1188
|
+
this.statusText = statusText;
|
|
1189
|
+
this.data = data;
|
|
1190
|
+
}
|
|
1191
|
+
static isHttpClientError(e) {
|
|
1192
|
+
return e instanceof _HttpClientError;
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
// packages/http-client/util.ts
|
|
1197
|
+
function buildURL(base, path, params) {
|
|
1198
|
+
const url = base ? `${base.replace(/\/$/, "")}/${path.replace(/^\//, "")}` : path;
|
|
1199
|
+
if (!params || Object.keys(params).length === 0) return url;
|
|
1200
|
+
const query = new URLSearchParams(
|
|
1201
|
+
Object.entries(params).map(([k, v]) => [k, String(v)])
|
|
1202
|
+
).toString();
|
|
1203
|
+
return `${url}?${query}`;
|
|
1204
|
+
}
|
|
1205
|
+
function buildHeaders(defaults, overrides, token) {
|
|
1206
|
+
const headers = {
|
|
1207
|
+
"Content-Type": "application/json",
|
|
1208
|
+
...defaults,
|
|
1209
|
+
...overrides
|
|
1210
|
+
};
|
|
1211
|
+
if (token) {
|
|
1212
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
1213
|
+
}
|
|
1214
|
+
return headers;
|
|
1215
|
+
}
|
|
1216
|
+
function toRecord(headers) {
|
|
1217
|
+
const record = {};
|
|
1218
|
+
headers.forEach((value, key) => {
|
|
1219
|
+
record[key] = value;
|
|
1220
|
+
});
|
|
1221
|
+
return record;
|
|
1222
|
+
}
|
|
1223
|
+
function withTimeout(ms, external) {
|
|
1224
|
+
if (!ms && !external) {
|
|
1225
|
+
const controller2 = new AbortController();
|
|
1226
|
+
return { signal: controller2.signal, clear: () => {
|
|
1227
|
+
} };
|
|
1228
|
+
}
|
|
1229
|
+
if (!ms && external) {
|
|
1230
|
+
return { signal: external, clear: () => {
|
|
1231
|
+
} };
|
|
1232
|
+
}
|
|
1233
|
+
const controller = new AbortController();
|
|
1234
|
+
const timer = setTimeout(() => controller.abort(new DOMException("Request timed out", "TimeoutError")), ms);
|
|
1235
|
+
if (external) {
|
|
1236
|
+
external.addEventListener("abort", () => controller.abort(external.reason), { once: true });
|
|
1237
|
+
}
|
|
1238
|
+
return {
|
|
1239
|
+
signal: controller.signal,
|
|
1240
|
+
clear: () => clearTimeout(timer)
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
// packages/http-client/index.ts
|
|
1245
|
+
async function executeRequest(reqConfig, clientConfig, defaultHeaders, token, instanceSignal) {
|
|
1246
|
+
const url = buildURL(clientConfig.baseURL, reqConfig.url, reqConfig.params);
|
|
1247
|
+
const headers = buildHeaders(defaultHeaders, reqConfig.headers, token);
|
|
1248
|
+
const timeout = _nullishCoalesce(reqConfig.timeout, () => ( clientConfig.timeout));
|
|
1249
|
+
const externalSignal = reqConfig.signal ? AbortSignal.any([reqConfig.signal, instanceSignal]) : instanceSignal;
|
|
1250
|
+
const { signal, clear } = withTimeout(timeout, externalSignal);
|
|
1251
|
+
try {
|
|
1252
|
+
const response = await fetch(url, {
|
|
1253
|
+
method: _nullishCoalesce(reqConfig.method, () => ( "GET")),
|
|
1254
|
+
headers,
|
|
1255
|
+
body: reqConfig.data != null ? JSON.stringify(reqConfig.data) : void 0,
|
|
1256
|
+
signal
|
|
1257
|
+
});
|
|
1258
|
+
if (!response.ok) {
|
|
1259
|
+
const contentType = _nullishCoalesce(response.headers.get("content-type"), () => ( ""));
|
|
1260
|
+
const errData = contentType.includes("application/json") ? await response.json() : await response.text();
|
|
1261
|
+
throw new HttpClientError(response.status, response.statusText, errData);
|
|
1262
|
+
}
|
|
1263
|
+
let data;
|
|
1264
|
+
const responseType = reqConfig.responseType;
|
|
1265
|
+
if (responseType === "arraybuffer") {
|
|
1266
|
+
data = await response.arrayBuffer();
|
|
1267
|
+
} else if (responseType === "blob") {
|
|
1268
|
+
data = await response.blob();
|
|
1269
|
+
} else if (responseType === "text") {
|
|
1270
|
+
data = await response.text();
|
|
1271
|
+
} else if (responseType === "json") {
|
|
1272
|
+
data = await response.json();
|
|
1273
|
+
} else {
|
|
1274
|
+
const contentType = _nullishCoalesce(response.headers.get("content-type"), () => ( ""));
|
|
1275
|
+
data = contentType.includes("application/json") ? await response.json() : await response.text();
|
|
1276
|
+
}
|
|
1277
|
+
return {
|
|
1278
|
+
data,
|
|
1279
|
+
status: response.status,
|
|
1280
|
+
statusText: response.statusText,
|
|
1281
|
+
headers: toRecord(response.headers)
|
|
1282
|
+
};
|
|
1283
|
+
} finally {
|
|
1284
|
+
clear();
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
function createHttpClient(clientConfig = {}) {
|
|
1288
|
+
const { auth } = clientConfig;
|
|
1289
|
+
const maxRetries = _nullishCoalesce(_optionalChain([auth, 'optionalAccess', _2 => _2.maxRetries]), () => ( 1));
|
|
1290
|
+
const defaultHeaders = { ...clientConfig.headers };
|
|
1291
|
+
let abortController = new AbortController();
|
|
1292
|
+
async function request(reqConfig) {
|
|
1293
|
+
const token = auth ? await auth.getToken() : null;
|
|
1294
|
+
let attemptsLeft = maxRetries;
|
|
1295
|
+
try {
|
|
1296
|
+
return await executeRequest(reqConfig, clientConfig, defaultHeaders, token, abortController.signal);
|
|
1297
|
+
} catch (err) {
|
|
1298
|
+
if (!HttpClientError.isHttpClientError(err) || err.status !== 401) throw err;
|
|
1299
|
+
if (!_optionalChain([auth, 'optionalAccess', _3 => _3.refreshToken])) throw err;
|
|
1300
|
+
while (attemptsLeft > 0) {
|
|
1301
|
+
attemptsLeft--;
|
|
1302
|
+
const newToken = await auth.refreshToken();
|
|
1303
|
+
try {
|
|
1304
|
+
return await executeRequest(reqConfig, clientConfig, defaultHeaders, newToken, abortController.signal);
|
|
1305
|
+
} catch (retryErr) {
|
|
1306
|
+
if (!HttpClientError.isHttpClientError(retryErr) || retryErr.status !== 401) throw retryErr;
|
|
1307
|
+
if (attemptsLeft === 0) throw retryErr;
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
throw err;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
return {
|
|
1314
|
+
request,
|
|
1315
|
+
get(url, config) {
|
|
1316
|
+
return request({ ...config, url, method: "GET" });
|
|
1317
|
+
},
|
|
1318
|
+
post(url, data, config) {
|
|
1319
|
+
return request({ ...config, url, method: "POST", data });
|
|
1320
|
+
},
|
|
1321
|
+
put(url, data, config) {
|
|
1322
|
+
return request({ ...config, url, method: "PUT", data });
|
|
1323
|
+
},
|
|
1324
|
+
patch(url, data, config) {
|
|
1325
|
+
return request({ ...config, url, method: "PATCH", data });
|
|
1326
|
+
},
|
|
1327
|
+
delete(url, config) {
|
|
1328
|
+
return request({ ...config, url, method: "DELETE" });
|
|
1329
|
+
},
|
|
1330
|
+
setHeader(key, value) {
|
|
1331
|
+
if (value === null) {
|
|
1332
|
+
delete defaultHeaders[key];
|
|
1333
|
+
} else {
|
|
1334
|
+
defaultHeaders[key] = value;
|
|
1335
|
+
}
|
|
1336
|
+
},
|
|
1337
|
+
abort() {
|
|
1338
|
+
abortController.abort();
|
|
1339
|
+
abortController = new AbortController();
|
|
1340
|
+
}
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
// packages/nookies/index.ts
|
|
1345
|
+
var _cookie = require('cookie'); var cookie = _interopRequireWildcard(_cookie);
|
|
1346
|
+
var _setcookieparser = require('set-cookie-parser'); var setCookieParser = _interopRequireWildcard(_setcookieparser);
|
|
1347
|
+
|
|
1348
|
+
// packages/nookies/util.ts
|
|
1349
|
+
function isBrowser() {
|
|
1350
|
+
return typeof window !== "undefined";
|
|
1351
|
+
}
|
|
1352
|
+
function createCookie(name, value, options) {
|
|
1353
|
+
let sameSite = options.sameSite;
|
|
1354
|
+
if (sameSite === true) {
|
|
1355
|
+
sameSite = "strict";
|
|
1356
|
+
}
|
|
1357
|
+
if (sameSite === void 0 || sameSite === false) {
|
|
1358
|
+
sameSite = "lax";
|
|
1359
|
+
}
|
|
1360
|
+
const cookieToSet = { ...options, sameSite };
|
|
1361
|
+
delete cookieToSet.encode;
|
|
1362
|
+
return {
|
|
1363
|
+
name,
|
|
1364
|
+
value,
|
|
1365
|
+
...cookieToSet
|
|
1366
|
+
};
|
|
1367
|
+
}
|
|
1368
|
+
function hasSameProperties(a, b) {
|
|
1369
|
+
const aProps = Object.getOwnPropertyNames(a);
|
|
1370
|
+
const bProps = Object.getOwnPropertyNames(b);
|
|
1371
|
+
if (aProps.length !== bProps.length) {
|
|
1372
|
+
return false;
|
|
1373
|
+
}
|
|
1374
|
+
for (let i = 0; i < aProps.length; i++) {
|
|
1375
|
+
const propName = aProps[i];
|
|
1376
|
+
if (a[propName] !== b[propName]) {
|
|
1377
|
+
return false;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
return true;
|
|
1381
|
+
}
|
|
1382
|
+
function areCookiesEqual(a, b) {
|
|
1383
|
+
let sameSiteSame = a.sameSite === b.sameSite;
|
|
1384
|
+
if (typeof a.sameSite === "string" && typeof b.sameSite === "string") {
|
|
1385
|
+
sameSiteSame = a.sameSite.toLowerCase() === b.sameSite.toLowerCase();
|
|
1386
|
+
}
|
|
1387
|
+
return hasSameProperties(
|
|
1388
|
+
{ ...a, sameSite: void 0 },
|
|
1389
|
+
{ ...b, sameSite: void 0 }
|
|
1390
|
+
) && sameSiteSame;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
// packages/nookies/index.ts
|
|
1394
|
+
function parseCookies(ctx, options) {
|
|
1395
|
+
if (_optionalChain([ctx, 'optionalAccess', _4 => _4.req, 'optionalAccess', _5 => _5.headers, 'optionalAccess', _6 => _6.cookie])) {
|
|
1396
|
+
return cookie.parse(ctx.req.headers.cookie, options);
|
|
1397
|
+
}
|
|
1398
|
+
if (isBrowser()) {
|
|
1399
|
+
return cookie.parse(document.cookie, options);
|
|
1400
|
+
}
|
|
1401
|
+
return {};
|
|
1402
|
+
}
|
|
1403
|
+
function setCookie(ctx, name, value, options = {}) {
|
|
1404
|
+
if (_optionalChain([ctx, 'optionalAccess', _7 => _7.res, 'optionalAccess', _8 => _8.getHeader]) && ctx.res.setHeader) {
|
|
1405
|
+
if (_optionalChain([ctx, 'optionalAccess', _9 => _9.res, 'optionalAccess', _10 => _10.finished])) {
|
|
1406
|
+
console.warn(`Not setting "${name}" cookie. Response has finished.`);
|
|
1407
|
+
console.warn(`You should set cookie before res.send()`);
|
|
1408
|
+
return {};
|
|
1409
|
+
}
|
|
1410
|
+
let cookies = ctx.res.getHeader("Set-Cookie") || [];
|
|
1411
|
+
if (typeof cookies === "string") cookies = [cookies];
|
|
1412
|
+
if (typeof cookies === "number") cookies = [];
|
|
1413
|
+
const parsedCookies = setCookieParser.parse(cookies, {
|
|
1414
|
+
decodeValues: false
|
|
1415
|
+
});
|
|
1416
|
+
const newCookie = createCookie(name, value, options);
|
|
1417
|
+
let cookiesToSet = [];
|
|
1418
|
+
parsedCookies.forEach((parsedCookie) => {
|
|
1419
|
+
if (!areCookiesEqual(parsedCookie, newCookie)) {
|
|
1420
|
+
const serializedCookie = cookie.serialize(
|
|
1421
|
+
parsedCookie.name,
|
|
1422
|
+
parsedCookie.value,
|
|
1423
|
+
{
|
|
1424
|
+
// we prevent reencoding by default, but you might override it
|
|
1425
|
+
encode: (val) => val,
|
|
1426
|
+
...parsedCookie
|
|
1427
|
+
}
|
|
1428
|
+
);
|
|
1429
|
+
cookiesToSet.push(serializedCookie);
|
|
1430
|
+
}
|
|
1431
|
+
});
|
|
1432
|
+
cookiesToSet.push(cookie.serialize(name, value, options));
|
|
1433
|
+
ctx.res.setHeader("Set-Cookie", cookiesToSet);
|
|
1434
|
+
}
|
|
1435
|
+
if (isBrowser()) {
|
|
1436
|
+
if (options && options.httpOnly) {
|
|
1437
|
+
throw new Error("Can not set a httpOnly cookie in the browser.");
|
|
1438
|
+
}
|
|
1439
|
+
document.cookie = cookie.serialize(name, value, options);
|
|
1440
|
+
}
|
|
1441
|
+
return {};
|
|
1442
|
+
}
|
|
1443
|
+
function destroyCookie(ctx, name, options) {
|
|
1444
|
+
return setCookie(ctx, name, "", { ...options || {}, maxAge: -1 });
|
|
1445
|
+
}
|
|
1446
|
+
var nookies = {
|
|
1447
|
+
set: setCookie,
|
|
1448
|
+
get: parseCookies,
|
|
1449
|
+
destroy: destroyCookie
|
|
1450
|
+
};
|
|
1451
|
+
|
|
1182
1452
|
// src/components/Grid/Grid.tsx
|
|
1183
1453
|
|
|
1184
1454
|
|
|
1185
1455
|
|
|
1186
1456
|
|
|
1187
1457
|
|
|
1188
|
-
var _react = require('react'); var
|
|
1458
|
+
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react); var React3 = _interopRequireWildcard(_react);
|
|
1189
1459
|
|
|
1190
1460
|
|
|
1191
1461
|
|
|
@@ -1204,7 +1474,7 @@ var _material = require('@mui/material');
|
|
|
1204
1474
|
|
|
1205
1475
|
// src/components/Grid/Header.tsx
|
|
1206
1476
|
|
|
1207
|
-
|
|
1477
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
1208
1478
|
var GridHeader = ({
|
|
1209
1479
|
setOrder,
|
|
1210
1480
|
setOrderBy,
|
|
@@ -1232,34 +1502,31 @@ var GridHeader = ({
|
|
|
1232
1502
|
break;
|
|
1233
1503
|
}
|
|
1234
1504
|
}
|
|
1235
|
-
return /* @__PURE__ */
|
|
1236
|
-
return /* @__PURE__ */
|
|
1505
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.TableHead, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.TableRow, { sx: { backgroundColor: "background.default" }, children: titles.map((title) => {
|
|
1506
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1237
1507
|
_material.TableCell,
|
|
1238
1508
|
{
|
|
1239
|
-
key: title.name,
|
|
1240
1509
|
sortDirection: orderBy === title.name ? order : false,
|
|
1241
|
-
sx: { fontWeight: "bold", ...title.sx }
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1510
|
+
sx: { fontWeight: "bold", ...title.sx },
|
|
1511
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1512
|
+
_material.TableSortLabel,
|
|
1513
|
+
{
|
|
1514
|
+
onClick: () => onRequestSort(title.name),
|
|
1515
|
+
active: orderBy === title.name,
|
|
1516
|
+
direction: orderBy === title.name ? order : "asc",
|
|
1517
|
+
sx: {
|
|
1518
|
+
position: "relative",
|
|
1519
|
+
svg: { position: "absolute", right: "27px" }
|
|
1520
|
+
},
|
|
1521
|
+
children: title.label
|
|
1252
1522
|
}
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1523
|
+
)
|
|
1524
|
+
},
|
|
1525
|
+
title.name
|
|
1256
1526
|
);
|
|
1257
|
-
})));
|
|
1527
|
+
}) }) });
|
|
1258
1528
|
};
|
|
1259
1529
|
|
|
1260
|
-
// src/components/Grid/Filters.tsx
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
1530
|
// node_modules/@mui/utils/esm/formatMuiErrorMessage/formatMuiErrorMessage.js
|
|
1264
1531
|
function formatMuiErrorMessage(code, ...args) {
|
|
1265
1532
|
const url = new URL(`https://mui.com/production-error/?code=${code}`);
|
|
@@ -1297,7 +1564,7 @@ function isPlainObject(item) {
|
|
|
1297
1564
|
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in item) && !(Symbol.iterator in item);
|
|
1298
1565
|
}
|
|
1299
1566
|
function deepClone(source) {
|
|
1300
|
-
if (/* @__PURE__ */
|
|
1567
|
+
if (/* @__PURE__ */ React.isValidElement(source) || (0, import_react_is.isValidElementType)(source) || !isPlainObject(source)) {
|
|
1301
1568
|
return source;
|
|
1302
1569
|
}
|
|
1303
1570
|
const output = {};
|
|
@@ -1314,7 +1581,7 @@ function deepmerge(target, source, options = {
|
|
|
1314
1581
|
} : target;
|
|
1315
1582
|
if (isPlainObject(target) && isPlainObject(source)) {
|
|
1316
1583
|
Object.keys(source).forEach((key) => {
|
|
1317
|
-
if (/* @__PURE__ */
|
|
1584
|
+
if (/* @__PURE__ */ React.isValidElement(source[key]) || (0, import_react_is.isValidElementType)(source[key])) {
|
|
1318
1585
|
output[key] = source[key];
|
|
1319
1586
|
} else if (isPlainObject(source[key]) && // Avoid prototype pollution
|
|
1320
1587
|
Object.prototype.hasOwnProperty.call(target, key) && isPlainObject(target[key])) {
|
|
@@ -1413,7 +1680,7 @@ function sortContainerQueries(theme, css2) {
|
|
|
1413
1680
|
}
|
|
1414
1681
|
const sorted = Object.keys(css2).filter((key) => key.startsWith("@container")).sort((a, b) => {
|
|
1415
1682
|
const regex = /min-width:\s*([0-9.]+)/;
|
|
1416
|
-
return +(_optionalChain([a, 'access',
|
|
1683
|
+
return +(_optionalChain([a, 'access', _11 => _11.match, 'call', _12 => _12(regex), 'optionalAccess', _13 => _13[1]]) || 0) - +(_optionalChain([b, 'access', _14 => _14.match, 'call', _15 => _15(regex), 'optionalAccess', _16 => _16[1]]) || 0);
|
|
1417
1684
|
});
|
|
1418
1685
|
if (!sorted.length) {
|
|
1419
1686
|
return css2;
|
|
@@ -1557,7 +1824,7 @@ function handleBreakpoints(props, propValue, styleFromPropValue) {
|
|
|
1557
1824
|
return output;
|
|
1558
1825
|
}
|
|
1559
1826
|
function createEmptyBreakpointObject(breakpointsInput = {}) {
|
|
1560
|
-
const breakpointsInOrder = _optionalChain([breakpointsInput, 'access',
|
|
1827
|
+
const breakpointsInOrder = _optionalChain([breakpointsInput, 'access', _17 => _17.keys, 'optionalAccess', _18 => _18.reduce, 'call', _19 => _19((acc, key) => {
|
|
1561
1828
|
const breakpointStyleKey = breakpointsInput.up(key);
|
|
1562
1829
|
acc[breakpointStyleKey] = {};
|
|
1563
1830
|
return acc;
|
|
@@ -2003,13 +2270,13 @@ var width = style_default({
|
|
|
2003
2270
|
var maxWidth = (props) => {
|
|
2004
2271
|
if (props.maxWidth !== void 0 && props.maxWidth !== null) {
|
|
2005
2272
|
const styleFromPropValue = (propValue) => {
|
|
2006
|
-
const breakpoint = _optionalChain([props, 'access',
|
|
2273
|
+
const breakpoint = _optionalChain([props, 'access', _20 => _20.theme, 'optionalAccess', _21 => _21.breakpoints, 'optionalAccess', _22 => _22.values, 'optionalAccess', _23 => _23[propValue]]) || values[propValue];
|
|
2007
2274
|
if (!breakpoint) {
|
|
2008
2275
|
return {
|
|
2009
2276
|
maxWidth: sizingTransform(propValue)
|
|
2010
2277
|
};
|
|
2011
2278
|
}
|
|
2012
|
-
if (_optionalChain([props, 'access',
|
|
2279
|
+
if (_optionalChain([props, 'access', _24 => _24.theme, 'optionalAccess', _25 => _25.breakpoints, 'optionalAccess', _26 => _26.unit]) !== "px") {
|
|
2013
2280
|
return {
|
|
2014
2281
|
maxWidth: `${breakpoint}${props.theme.breakpoints.unit}`
|
|
2015
2282
|
};
|
|
@@ -2467,7 +2734,7 @@ var styleFunctionSx_default = styleFunctionSx;
|
|
|
2467
2734
|
function applyStyles(key, styles2) {
|
|
2468
2735
|
const theme = this;
|
|
2469
2736
|
if (theme.vars) {
|
|
2470
|
-
if (!_optionalChain([theme, 'access',
|
|
2737
|
+
if (!_optionalChain([theme, 'access', _27 => _27.colorSchemes, 'optionalAccess', _28 => _28[key]]) || typeof theme.getColorSchemeSelector !== "function") {
|
|
2471
2738
|
return {};
|
|
2472
2739
|
}
|
|
2473
2740
|
let selector = theme.getColorSchemeSelector(key);
|
|
@@ -2518,7 +2785,7 @@ function createTheme(options = {}, ...args) {
|
|
|
2518
2785
|
muiTheme = args.reduce((acc, argument) => deepmerge(acc, argument), muiTheme);
|
|
2519
2786
|
muiTheme.unstable_sxConfig = {
|
|
2520
2787
|
...defaultSxConfig_default,
|
|
2521
|
-
..._optionalChain([other, 'optionalAccess',
|
|
2788
|
+
..._optionalChain([other, 'optionalAccess', _29 => _29.unstable_sxConfig])
|
|
2522
2789
|
};
|
|
2523
2790
|
muiTheme.unstable_sx = function sx(props) {
|
|
2524
2791
|
return styleFunctionSx_default({
|
|
@@ -2536,7 +2803,7 @@ function isObjectEmpty(obj) {
|
|
|
2536
2803
|
return Object.keys(obj).length === 0;
|
|
2537
2804
|
}
|
|
2538
2805
|
function useTheme(defaultTheme = null) {
|
|
2539
|
-
const contextTheme =
|
|
2806
|
+
const contextTheme = React2.useContext(_react2.ThemeContext);
|
|
2540
2807
|
return !contextTheme || isObjectEmpty(contextTheme) ? defaultTheme : contextTheme;
|
|
2541
2808
|
}
|
|
2542
2809
|
var useThemeWithoutDefault_default = useTheme;
|
|
@@ -2554,7 +2821,7 @@ var splitProps = (props) => {
|
|
|
2554
2821
|
systemProps: {},
|
|
2555
2822
|
otherProps: {}
|
|
2556
2823
|
};
|
|
2557
|
-
const config = _nullishCoalesce(_optionalChain([props, 'optionalAccess',
|
|
2824
|
+
const config = _nullishCoalesce(_optionalChain([props, 'optionalAccess', _30 => _30.theme, 'optionalAccess', _31 => _31.unstable_sxConfig]), () => ( defaultSxConfig_default));
|
|
2558
2825
|
Object.keys(props).forEach((prop) => {
|
|
2559
2826
|
if (config[prop]) {
|
|
2560
2827
|
result.systemProps[prop] = props[prop];
|
|
@@ -2641,7 +2908,7 @@ function clsx() {
|
|
|
2641
2908
|
var clsx_default = clsx;
|
|
2642
2909
|
|
|
2643
2910
|
// node_modules/@mui/system/esm/createBox/createBox.js
|
|
2644
|
-
|
|
2911
|
+
|
|
2645
2912
|
function createBox(options = {}) {
|
|
2646
2913
|
const {
|
|
2647
2914
|
themeId,
|
|
@@ -2652,7 +2919,7 @@ function createBox(options = {}) {
|
|
|
2652
2919
|
const BoxRoot = styled("div", {
|
|
2653
2920
|
shouldForwardProp: (prop) => prop !== "theme" && prop !== "sx" && prop !== "as"
|
|
2654
2921
|
})(styleFunctionSx_default);
|
|
2655
|
-
const Box9 = /* @__PURE__ */
|
|
2922
|
+
const Box9 = /* @__PURE__ */ React3.forwardRef(function Box10(inProps, ref) {
|
|
2656
2923
|
const theme = useTheme_default(defaultTheme);
|
|
2657
2924
|
const {
|
|
2658
2925
|
className,
|
|
@@ -2732,6 +2999,7 @@ var Box_default = Box;
|
|
|
2732
2999
|
// src/components/Grid/Filters.tsx
|
|
2733
3000
|
var _md = require('react-icons/md');
|
|
2734
3001
|
|
|
3002
|
+
|
|
2735
3003
|
var FiltersBar = ({
|
|
2736
3004
|
customButtons,
|
|
2737
3005
|
selectedFilters,
|
|
@@ -2742,7 +3010,7 @@ var FiltersBar = ({
|
|
|
2742
3010
|
setAnchorEl,
|
|
2743
3011
|
noFilters
|
|
2744
3012
|
}) => {
|
|
2745
|
-
return /* @__PURE__ */
|
|
3013
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2746
3014
|
Box_default,
|
|
2747
3015
|
{
|
|
2748
3016
|
sx: {
|
|
@@ -2750,26 +3018,34 @@ var FiltersBar = ({
|
|
|
2750
3018
|
justifyContent: "space-between",
|
|
2751
3019
|
alignItems: "center",
|
|
2752
3020
|
width: "100%"
|
|
2753
|
-
}
|
|
2754
|
-
},
|
|
2755
|
-
!noFilters && /* @__PURE__ */ React2.default.createElement(Box_default, { sx: { pl: 1 } }, selectedFilters.map((item, index) => {
|
|
2756
|
-
return /* @__PURE__ */ React2.default.createElement(
|
|
2757
|
-
_material.Chip,
|
|
2758
|
-
{
|
|
2759
|
-
key: index,
|
|
2760
|
-
label: item.value,
|
|
2761
|
-
onDelete: () => handleCloseFilter(item)
|
|
2762
|
-
}
|
|
2763
|
-
);
|
|
2764
|
-
})),
|
|
2765
|
-
/* @__PURE__ */ React2.default.createElement(Box_default, { ref: searchAnchorEl, sx: { minHeight: 30, width: "100%" } }, customButtons, !noFilterButtons && /* @__PURE__ */ React2.default.createElement(React2.default.Fragment, null, /* @__PURE__ */ React2.default.createElement(_material.Tooltip, { title: "Buscar" }, /* @__PURE__ */ React2.default.createElement(_material.IconButton, { onClick: () => setOpenSearch(true) }, /* @__PURE__ */ React2.default.createElement(_md.MdSearch, { size: 8 * 3 }))), /* @__PURE__ */ React2.default.createElement(_material.Tooltip, { title: "Filtrar" }, /* @__PURE__ */ React2.default.createElement(
|
|
2766
|
-
_material.IconButton,
|
|
2767
|
-
{
|
|
2768
|
-
sx: { position: "relative" },
|
|
2769
|
-
onClick: ({ currentTarget }) => setAnchorEl(currentTarget)
|
|
2770
3021
|
},
|
|
2771
|
-
|
|
2772
|
-
|
|
3022
|
+
children: [
|
|
3023
|
+
!noFilters && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Box_default, { sx: { pl: 1 }, children: selectedFilters.map((item, index) => {
|
|
3024
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3025
|
+
_material.Chip,
|
|
3026
|
+
{
|
|
3027
|
+
label: item.value,
|
|
3028
|
+
onDelete: () => handleCloseFilter(item)
|
|
3029
|
+
},
|
|
3030
|
+
index
|
|
3031
|
+
);
|
|
3032
|
+
}) }),
|
|
3033
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Box_default, { ref: searchAnchorEl, sx: { minHeight: 30, width: "100%" }, children: [
|
|
3034
|
+
customButtons,
|
|
3035
|
+
!noFilterButtons && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3036
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Buscar", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.IconButton, { onClick: () => setOpenSearch(true), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _md.MdSearch, { size: 8 * 3 }) }) }),
|
|
3037
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Filtrar", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3038
|
+
_material.IconButton,
|
|
3039
|
+
{
|
|
3040
|
+
sx: { position: "relative" },
|
|
3041
|
+
onClick: ({ currentTarget }) => setAnchorEl(currentTarget),
|
|
3042
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _md.MdFilterList, { size: 8 * 3 })
|
|
3043
|
+
}
|
|
3044
|
+
) })
|
|
3045
|
+
] })
|
|
3046
|
+
] })
|
|
3047
|
+
]
|
|
3048
|
+
}
|
|
2773
3049
|
);
|
|
2774
3050
|
};
|
|
2775
3051
|
|
|
@@ -2795,9 +3071,6 @@ function getPropertyValue(obj, property) {
|
|
|
2795
3071
|
return String(property.split(".").reduce((o, k) => o && o[k], obj));
|
|
2796
3072
|
}
|
|
2797
3073
|
|
|
2798
|
-
// src/components/Grid/AutoCreatedRows.tsx
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
3074
|
// src/components/Grid/Td.tsx
|
|
2802
3075
|
|
|
2803
3076
|
var Td = _material.TableCell;
|
|
@@ -2807,18 +3080,20 @@ var Td = _material.TableCell;
|
|
|
2807
3080
|
var Tr = _material.TableRow;
|
|
2808
3081
|
|
|
2809
3082
|
// src/components/Grid/AutoCreatedRows.tsx
|
|
3083
|
+
|
|
2810
3084
|
var AutoCreatedRows = ({
|
|
2811
3085
|
tableData,
|
|
2812
3086
|
columns,
|
|
2813
3087
|
primaryKey
|
|
2814
3088
|
}) => {
|
|
2815
|
-
return /* @__PURE__ */
|
|
3089
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: tableData.map((row) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Tr, { children: columns.map((column) => {
|
|
2816
3090
|
const cellValue = column.transformer ? column.transformer(row[column.name]) : row[column.name];
|
|
2817
|
-
return /* @__PURE__ */
|
|
2818
|
-
}))));
|
|
3091
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Td, { children: cellValue }, column.name);
|
|
3092
|
+
}) }, row[primaryKey])) });
|
|
2819
3093
|
};
|
|
2820
3094
|
|
|
2821
3095
|
// src/components/Grid/Grid.tsx
|
|
3096
|
+
|
|
2822
3097
|
var Grid = (props) => {
|
|
2823
3098
|
const {
|
|
2824
3099
|
columnTitles,
|
|
@@ -2992,159 +3267,180 @@ var Grid = (props) => {
|
|
|
2992
3267
|
_react.useEffect.call(void 0, () => {
|
|
2993
3268
|
updateFilters(selectedFilters);
|
|
2994
3269
|
}, [selectedFilters]);
|
|
2995
|
-
return /* @__PURE__ */
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
setOpenSearch,
|
|
3000
|
-
searchAnchorEl,
|
|
3001
|
-
noFilters,
|
|
3002
|
-
noFilterButtons,
|
|
3003
|
-
selectedFilters,
|
|
3004
|
-
customButtons,
|
|
3005
|
-
handleCloseFilter
|
|
3006
|
-
}
|
|
3007
|
-
), /* @__PURE__ */ React2.default.createElement(_material.TableContainer, null, /* @__PURE__ */ React2.default.createElement(_material.Table, { size: "small" }, /* @__PURE__ */ React2.default.createElement(
|
|
3008
|
-
GridHeader,
|
|
3009
|
-
{
|
|
3010
|
-
titles: columnTitles,
|
|
3011
|
-
order,
|
|
3012
|
-
orderBy,
|
|
3013
|
-
setOrder,
|
|
3014
|
-
setOrderBy
|
|
3015
|
-
}
|
|
3016
|
-
), /* @__PURE__ */ React2.default.createElement(_material.TableBody, null, props.children ? props.children : primaryKey ? /* @__PURE__ */ React2.default.createElement(
|
|
3017
|
-
AutoCreatedRows,
|
|
3018
|
-
{
|
|
3019
|
-
tableData,
|
|
3020
|
-
columns: columnTitles,
|
|
3021
|
-
primaryKey
|
|
3022
|
-
}
|
|
3023
|
-
) : null, footer))), !noPagination && /* @__PURE__ */ React2.default.createElement(
|
|
3024
|
-
_material.TablePagination,
|
|
3025
|
-
{
|
|
3026
|
-
page,
|
|
3027
|
-
component: "div",
|
|
3028
|
-
rowsPerPage,
|
|
3029
|
-
labelRowsPerPage: "Linhas por p\xE1gina",
|
|
3030
|
-
rowsPerPageOptions: rowOptions,
|
|
3031
|
-
count: countRows,
|
|
3032
|
-
labelDisplayedRows: ({ page: page2 }) => `${page2 + 1} de ${Math.floor(countRows / rowsPerPage) + 1}`,
|
|
3033
|
-
onPageChange: (_, newPage) => {
|
|
3034
|
-
setPage(newPage);
|
|
3035
|
-
},
|
|
3036
|
-
onRowsPerPageChange: handleChangeRowsPerPage
|
|
3037
|
-
}
|
|
3038
|
-
), /* @__PURE__ */ React2.default.createElement(
|
|
3039
|
-
_material.Popover,
|
|
3040
|
-
{
|
|
3041
|
-
anchorEl,
|
|
3042
|
-
open: !!anchorEl,
|
|
3043
|
-
onClose: () => setAnchorEl(null),
|
|
3044
|
-
anchorOrigin: {
|
|
3045
|
-
vertical: "top",
|
|
3046
|
-
horizontal: "right"
|
|
3047
|
-
},
|
|
3048
|
-
transformOrigin: {
|
|
3049
|
-
vertical: "top",
|
|
3050
|
-
horizontal: "right"
|
|
3051
|
-
}
|
|
3052
|
-
},
|
|
3053
|
-
/* @__PURE__ */ React2.default.createElement(_material.Box, { sx: { minWidth: 300, padding: 2 } }, /* @__PURE__ */ React2.default.createElement(_material.Typography, { fontWeight: "bold", variant: "body2" }, "Filtrar por:"), /* @__PURE__ */ React2.default.createElement(
|
|
3054
|
-
_material.Autocomplete,
|
|
3270
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Paper, { children: [
|
|
3271
|
+
isLoading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.LinearProgress, {}),
|
|
3272
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3273
|
+
FiltersBar,
|
|
3055
3274
|
{
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3275
|
+
setAnchorEl,
|
|
3276
|
+
setOpenSearch,
|
|
3277
|
+
searchAnchorEl,
|
|
3278
|
+
noFilters,
|
|
3279
|
+
noFilterButtons,
|
|
3280
|
+
selectedFilters,
|
|
3281
|
+
customButtons,
|
|
3282
|
+
handleCloseFilter
|
|
3283
|
+
}
|
|
3284
|
+
),
|
|
3285
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.TableContainer, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Table, { size: "small", children: [
|
|
3286
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3287
|
+
GridHeader,
|
|
3288
|
+
{
|
|
3289
|
+
titles: columnTitles,
|
|
3290
|
+
order,
|
|
3291
|
+
orderBy,
|
|
3292
|
+
setOrder,
|
|
3293
|
+
setOrderBy
|
|
3294
|
+
}
|
|
3295
|
+
),
|
|
3296
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.TableBody, { children: [
|
|
3297
|
+
props.children ? props.children : primaryKey ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3298
|
+
AutoCreatedRows,
|
|
3063
3299
|
{
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
label: "Coluna"
|
|
3300
|
+
tableData,
|
|
3301
|
+
columns: columnTitles,
|
|
3302
|
+
primaryKey
|
|
3068
3303
|
}
|
|
3069
|
-
)
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3304
|
+
) : null,
|
|
3305
|
+
footer
|
|
3306
|
+
] })
|
|
3307
|
+
] }) }),
|
|
3308
|
+
!noPagination && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3309
|
+
_material.TablePagination,
|
|
3073
3310
|
{
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3311
|
+
page,
|
|
3312
|
+
component: "div",
|
|
3313
|
+
rowsPerPage,
|
|
3314
|
+
labelRowsPerPage: "Linhas por p\xE1gina",
|
|
3315
|
+
rowsPerPageOptions: rowOptions,
|
|
3316
|
+
count: countRows,
|
|
3317
|
+
labelDisplayedRows: ({ page: page2 }) => `${page2 + 1} de ${Math.floor(countRows / rowsPerPage) + 1}`,
|
|
3318
|
+
onPageChange: (_, newPage) => {
|
|
3319
|
+
setPage(newPage);
|
|
3077
3320
|
},
|
|
3078
|
-
|
|
3079
|
-
options: valuesToFilter.map((title) => title),
|
|
3080
|
-
renderInput: (params) => /* @__PURE__ */ React2.default.createElement(
|
|
3081
|
-
_material.TextField,
|
|
3082
|
-
{
|
|
3083
|
-
variant: "standard",
|
|
3084
|
-
margin: "dense",
|
|
3085
|
-
...params,
|
|
3086
|
-
label: "Valor"
|
|
3087
|
-
}
|
|
3088
|
-
)
|
|
3321
|
+
onRowsPerPageChange: handleChangeRowsPerPage
|
|
3089
3322
|
}
|
|
3090
|
-
),
|
|
3091
|
-
|
|
3323
|
+
),
|
|
3324
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3325
|
+
_material.Popover,
|
|
3092
3326
|
{
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3327
|
+
anchorEl,
|
|
3328
|
+
open: !!anchorEl,
|
|
3329
|
+
onClose: () => setAnchorEl(null),
|
|
3330
|
+
anchorOrigin: {
|
|
3331
|
+
vertical: "top",
|
|
3332
|
+
horizontal: "right"
|
|
3333
|
+
},
|
|
3334
|
+
transformOrigin: {
|
|
3335
|
+
vertical: "top",
|
|
3336
|
+
horizontal: "right"
|
|
3337
|
+
},
|
|
3338
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { minWidth: 300, padding: 2 }, children: [
|
|
3339
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { fontWeight: "bold", variant: "body2", children: "Filtrar por:" }),
|
|
3340
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3341
|
+
_material.Autocomplete,
|
|
3342
|
+
{
|
|
3343
|
+
value: selectedTitle || "",
|
|
3344
|
+
onChange: ({ target }) => {
|
|
3345
|
+
!target.innerHTML.includes("path") ? setSelectedTitle(target.innerHTML) : setSelectedTitle(void 0);
|
|
3346
|
+
},
|
|
3347
|
+
options: columnTitles.map((title) => title.label),
|
|
3348
|
+
renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3349
|
+
_material.TextField,
|
|
3350
|
+
{
|
|
3351
|
+
variant: "standard",
|
|
3352
|
+
margin: "dense",
|
|
3353
|
+
...params,
|
|
3354
|
+
label: "Coluna"
|
|
3355
|
+
}
|
|
3356
|
+
)
|
|
3357
|
+
}
|
|
3358
|
+
),
|
|
3359
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3360
|
+
_material.Autocomplete,
|
|
3361
|
+
{
|
|
3362
|
+
value: selectedFilterValue || "",
|
|
3363
|
+
onChange: ({ target }) => {
|
|
3364
|
+
!target.innerHTML.includes("path") ? setSelectedFilterValue(target.innerHTML) : setSelectedFilterValue(void 0);
|
|
3365
|
+
},
|
|
3366
|
+
disabled: valuesToFilter.length < 1,
|
|
3367
|
+
options: valuesToFilter.map((title) => title),
|
|
3368
|
+
renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3369
|
+
_material.TextField,
|
|
3370
|
+
{
|
|
3371
|
+
variant: "standard",
|
|
3372
|
+
margin: "dense",
|
|
3373
|
+
...params,
|
|
3374
|
+
label: "Valor"
|
|
3375
|
+
}
|
|
3376
|
+
)
|
|
3377
|
+
}
|
|
3378
|
+
),
|
|
3379
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: { py: 1 } }),
|
|
3380
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3381
|
+
_material.Button,
|
|
3382
|
+
{
|
|
3383
|
+
disabled: !selectedFilterValue,
|
|
3384
|
+
onClick: handleAddFilter,
|
|
3385
|
+
fullWidth: true,
|
|
3386
|
+
children: "Adicionar filtro"
|
|
3387
|
+
}
|
|
3388
|
+
)
|
|
3389
|
+
] })
|
|
3112
3390
|
}
|
|
3113
|
-
|
|
3114
|
-
/* @__PURE__ */
|
|
3115
|
-
_material.
|
|
3391
|
+
),
|
|
3392
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3393
|
+
_material.Popover,
|
|
3116
3394
|
{
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
alignItems: "flex-end"
|
|
3124
|
-
}
|
|
3125
|
-
},
|
|
3126
|
-
/* @__PURE__ */ React2.default.createElement(
|
|
3127
|
-
_material.TextField,
|
|
3128
|
-
{
|
|
3129
|
-
variant: "standard",
|
|
3130
|
-
margin: "dense",
|
|
3131
|
-
label: "Buscar",
|
|
3132
|
-
value: searchText,
|
|
3133
|
-
onChange: ({ currentTarget }) => setSearchText(currentTarget.value)
|
|
3134
|
-
}
|
|
3135
|
-
),
|
|
3136
|
-
/* @__PURE__ */ React2.default.createElement(_material.Box, null, /* @__PURE__ */ React2.default.createElement(
|
|
3137
|
-
_material.IconButton,
|
|
3138
|
-
{
|
|
3139
|
-
onClick: () => {
|
|
3140
|
-
setSearchText("");
|
|
3141
|
-
setOpenSearch(false);
|
|
3142
|
-
}
|
|
3395
|
+
anchorEl: searchAnchorEl.current,
|
|
3396
|
+
open: openSearch,
|
|
3397
|
+
onClose: () => setOpenSearch(false),
|
|
3398
|
+
anchorOrigin: {
|
|
3399
|
+
vertical: "top",
|
|
3400
|
+
horizontal: "left"
|
|
3143
3401
|
},
|
|
3144
|
-
|
|
3145
|
-
|
|
3402
|
+
transformOrigin: {
|
|
3403
|
+
vertical: "top",
|
|
3404
|
+
horizontal: "left"
|
|
3405
|
+
},
|
|
3406
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3407
|
+
_material.Box,
|
|
3408
|
+
{
|
|
3409
|
+
sx: {
|
|
3410
|
+
minWidth: 300,
|
|
3411
|
+
px: 2,
|
|
3412
|
+
pb: 1,
|
|
3413
|
+
display: "grid",
|
|
3414
|
+
gridTemplateColumns: "1fr 30px",
|
|
3415
|
+
alignItems: "flex-end"
|
|
3416
|
+
},
|
|
3417
|
+
children: [
|
|
3418
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3419
|
+
_material.TextField,
|
|
3420
|
+
{
|
|
3421
|
+
variant: "standard",
|
|
3422
|
+
margin: "dense",
|
|
3423
|
+
label: "Buscar",
|
|
3424
|
+
value: searchText,
|
|
3425
|
+
onChange: ({ currentTarget }) => setSearchText(currentTarget.value)
|
|
3426
|
+
}
|
|
3427
|
+
),
|
|
3428
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3429
|
+
_material.IconButton,
|
|
3430
|
+
{
|
|
3431
|
+
onClick: () => {
|
|
3432
|
+
setSearchText("");
|
|
3433
|
+
setOpenSearch(false);
|
|
3434
|
+
},
|
|
3435
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _md.MdClose, { size: 8 * 3 })
|
|
3436
|
+
}
|
|
3437
|
+
) })
|
|
3438
|
+
]
|
|
3439
|
+
}
|
|
3440
|
+
)
|
|
3441
|
+
}
|
|
3146
3442
|
)
|
|
3147
|
-
)
|
|
3443
|
+
] });
|
|
3148
3444
|
};
|
|
3149
3445
|
var Grid_default = Grid;
|
|
3150
3446
|
|
|
@@ -3154,8 +3450,8 @@ var Grid_default = Grid;
|
|
|
3154
3450
|
|
|
3155
3451
|
// src/components/Grid/EditableTableCell/DefaultInput.tsx
|
|
3156
3452
|
|
|
3453
|
+
var _dayjs = require('dayjs'); var _dayjs2 = _interopRequireDefault(_dayjs);
|
|
3157
3454
|
|
|
3158
|
-
var _moment = require('moment'); var _moment2 = _interopRequireDefault(_moment);
|
|
3159
3455
|
var DefaultInput = (allProps) => {
|
|
3160
3456
|
const {
|
|
3161
3457
|
TextFieldProps: TextFieldProps3,
|
|
@@ -3174,21 +3470,21 @@ var DefaultInput = (allProps) => {
|
|
|
3174
3470
|
if (formatInputDefautvalue) return formatInputDefautvalue(value);
|
|
3175
3471
|
switch (type) {
|
|
3176
3472
|
case "date":
|
|
3177
|
-
return
|
|
3473
|
+
return _dayjs2.default.call(void 0, value).format("YYYY-MM-DD");
|
|
3178
3474
|
case "datetime-local":
|
|
3179
|
-
return
|
|
3475
|
+
return _dayjs2.default.call(void 0, value).format("YYYY-MM-DDTHH:mm:ss");
|
|
3180
3476
|
default:
|
|
3181
3477
|
return String(value);
|
|
3182
3478
|
}
|
|
3183
3479
|
};
|
|
3184
3480
|
const handleSave = (event) => {
|
|
3185
|
-
onUpdateValue(String(_optionalChain([event, 'access',
|
|
3481
|
+
onUpdateValue(String(_optionalChain([event, 'access', _32 => _32.target, 'optionalAccess', _33 => _33.value])));
|
|
3186
3482
|
setIsEditing(false);
|
|
3187
3483
|
const response = {
|
|
3188
3484
|
name,
|
|
3189
3485
|
event,
|
|
3190
|
-
value: _optionalChain([event, 'access',
|
|
3191
|
-
data: { ...rowData, [name]: _optionalChain([event, 'access',
|
|
3486
|
+
value: _optionalChain([event, 'access', _34 => _34.target, 'optionalAccess', _35 => _35.value]),
|
|
3487
|
+
data: { ...rowData, [name]: _optionalChain([event, 'access', _36 => _36.target, 'optionalAccess', _37 => _37.value]) }
|
|
3192
3488
|
};
|
|
3193
3489
|
onSave(response);
|
|
3194
3490
|
};
|
|
@@ -3196,7 +3492,7 @@ var DefaultInput = (allProps) => {
|
|
|
3196
3492
|
if (ev.code === "Enter") handleSave(ev);
|
|
3197
3493
|
if (ev.code === "Escape") handleCancelEditing();
|
|
3198
3494
|
};
|
|
3199
|
-
return /* @__PURE__ */
|
|
3495
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3200
3496
|
_material.TextField,
|
|
3201
3497
|
{
|
|
3202
3498
|
name,
|
|
@@ -3205,10 +3501,10 @@ var DefaultInput = (allProps) => {
|
|
|
3205
3501
|
autoFocus: true,
|
|
3206
3502
|
type,
|
|
3207
3503
|
size: "small",
|
|
3208
|
-
defaultValue: formatDefaultValue(_optionalChain([rowData, 'optionalAccess',
|
|
3504
|
+
defaultValue: formatDefaultValue(_optionalChain([rowData, 'optionalAccess', _38 => _38[name]])),
|
|
3209
3505
|
sx: {
|
|
3210
3506
|
width: fullWidth ? "100%" : "intial",
|
|
3211
|
-
..._optionalChain([TextFieldProps3, 'optionalAccess',
|
|
3507
|
+
..._optionalChain([TextFieldProps3, 'optionalAccess', _39 => _39.sx])
|
|
3212
3508
|
},
|
|
3213
3509
|
inputProps: {
|
|
3214
3510
|
style: {
|
|
@@ -3218,11 +3514,11 @@ var DefaultInput = (allProps) => {
|
|
|
3218
3514
|
onKeyDown
|
|
3219
3515
|
},
|
|
3220
3516
|
InputProps: {
|
|
3221
|
-
..._optionalChain([TextFieldProps3, 'optionalAccess',
|
|
3517
|
+
..._optionalChain([TextFieldProps3, 'optionalAccess', _40 => _40.InputProps]),
|
|
3222
3518
|
sx: {
|
|
3223
3519
|
fontSize: 14,
|
|
3224
3520
|
pl: 0.2,
|
|
3225
|
-
..._optionalChain([TextFieldProps3, 'optionalAccess',
|
|
3521
|
+
..._optionalChain([TextFieldProps3, 'optionalAccess', _41 => _41.InputProps, 'optionalAccess', _42 => _42.sx])
|
|
3226
3522
|
}
|
|
3227
3523
|
},
|
|
3228
3524
|
...TextFieldProps3
|
|
@@ -3234,6 +3530,7 @@ var DefaultInput = (allProps) => {
|
|
|
3234
3530
|
var _reactimask = require('react-imask');
|
|
3235
3531
|
|
|
3236
3532
|
|
|
3533
|
+
|
|
3237
3534
|
var InputMask = (allProps) => {
|
|
3238
3535
|
const {
|
|
3239
3536
|
TextFieldProps: TextFieldProps3,
|
|
@@ -3246,18 +3543,16 @@ var InputMask = (allProps) => {
|
|
|
3246
3543
|
handleCancelEditing,
|
|
3247
3544
|
setIsEditing
|
|
3248
3545
|
} = allProps;
|
|
3249
|
-
const { ref, unmaskedValue, setValue } = _reactimask.useIMask.call(void 0,
|
|
3250
|
-
mask
|
|
3251
|
-
);
|
|
3546
|
+
const { ref, unmaskedValue, setValue } = _reactimask.useIMask.call(void 0, mask);
|
|
3252
3547
|
const handleSave = (event) => {
|
|
3253
3548
|
setIsEditing(false);
|
|
3254
|
-
setValue(String(_optionalChain([event, 'access',
|
|
3549
|
+
setValue(String(_optionalChain([event, 'access', _43 => _43.target, 'optionalAccess', _44 => _44.value])));
|
|
3255
3550
|
const response = {
|
|
3256
3551
|
name,
|
|
3257
3552
|
event,
|
|
3258
|
-
value: _optionalChain([event, 'access',
|
|
3553
|
+
value: _optionalChain([event, 'access', _45 => _45.target, 'optionalAccess', _46 => _46.value]),
|
|
3259
3554
|
unmaskedValue,
|
|
3260
|
-
data: { ...rowData, [name]: _optionalChain([event, 'access',
|
|
3555
|
+
data: { ...rowData, [name]: _optionalChain([event, 'access', _47 => _47.target, 'optionalAccess', _48 => _48.value]) }
|
|
3261
3556
|
};
|
|
3262
3557
|
onSave(response);
|
|
3263
3558
|
};
|
|
@@ -3266,9 +3561,9 @@ var InputMask = (allProps) => {
|
|
|
3266
3561
|
if (ev.code === "Escape") handleCancelEditing();
|
|
3267
3562
|
};
|
|
3268
3563
|
_react.useEffect.call(void 0, () => {
|
|
3269
|
-
if (_optionalChain([rowData, 'optionalAccess',
|
|
3270
|
-
}, [_optionalChain([rowData, 'optionalAccess',
|
|
3271
|
-
return /* @__PURE__ */
|
|
3564
|
+
if (_optionalChain([rowData, 'optionalAccess', _49 => _49[name]])) setValue(String(_optionalChain([rowData, 'optionalAccess', _50 => _50[name]])));
|
|
3565
|
+
}, [_optionalChain([rowData, 'optionalAccess', _51 => _51[name]])]);
|
|
3566
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3272
3567
|
_material.TextField,
|
|
3273
3568
|
{
|
|
3274
3569
|
inputRef: ref,
|
|
@@ -3279,7 +3574,7 @@ var InputMask = (allProps) => {
|
|
|
3279
3574
|
size: "small",
|
|
3280
3575
|
sx: {
|
|
3281
3576
|
width: fullWidth ? "100%" : "intial",
|
|
3282
|
-
..._optionalChain([TextFieldProps3, 'optionalAccess',
|
|
3577
|
+
..._optionalChain([TextFieldProps3, 'optionalAccess', _52 => _52.sx])
|
|
3283
3578
|
},
|
|
3284
3579
|
inputProps: {
|
|
3285
3580
|
style: {
|
|
@@ -3289,11 +3584,11 @@ var InputMask = (allProps) => {
|
|
|
3289
3584
|
onKeyDown
|
|
3290
3585
|
},
|
|
3291
3586
|
InputProps: {
|
|
3292
|
-
..._optionalChain([TextFieldProps3, 'optionalAccess',
|
|
3587
|
+
..._optionalChain([TextFieldProps3, 'optionalAccess', _53 => _53.InputProps]),
|
|
3293
3588
|
sx: {
|
|
3294
3589
|
fontSize: 14,
|
|
3295
3590
|
pl: 0.2,
|
|
3296
|
-
..._optionalChain([TextFieldProps3, 'optionalAccess',
|
|
3591
|
+
..._optionalChain([TextFieldProps3, 'optionalAccess', _54 => _54.InputProps, 'optionalAccess', _55 => _55.sx])
|
|
3297
3592
|
}
|
|
3298
3593
|
},
|
|
3299
3594
|
...TextFieldProps3
|
|
@@ -3302,6 +3597,7 @@ var InputMask = (allProps) => {
|
|
|
3302
3597
|
};
|
|
3303
3598
|
|
|
3304
3599
|
// src/components/Grid/EditableTableCell/index.tsx
|
|
3600
|
+
|
|
3305
3601
|
var EditableTableCell = (allProps) => {
|
|
3306
3602
|
const {
|
|
3307
3603
|
TextFieldProps: TextFieldProps3,
|
|
@@ -3320,12 +3616,12 @@ var EditableTableCell = (allProps) => {
|
|
|
3320
3616
|
...props
|
|
3321
3617
|
} = allProps;
|
|
3322
3618
|
const [isEditing, setIsEditing] = _react.useState.call(void 0, false);
|
|
3323
|
-
const [value, setValue] = _react.useState.call(void 0, _optionalChain([rowData, 'optionalAccess',
|
|
3619
|
+
const [value, setValue] = _react.useState.call(void 0, _optionalChain([rowData, 'optionalAccess', _56 => _56[name]]));
|
|
3324
3620
|
const handleCancelEditing = () => {
|
|
3325
3621
|
setIsEditing(false);
|
|
3326
3622
|
if (onCancel) onCancel();
|
|
3327
3623
|
};
|
|
3328
|
-
return /* @__PURE__ */
|
|
3624
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3329
3625
|
_material.TableCell,
|
|
3330
3626
|
{
|
|
3331
3627
|
...props,
|
|
@@ -3335,55 +3631,55 @@ var EditableTableCell = (allProps) => {
|
|
|
3335
3631
|
border: bordered ? "1px solid" : "initial",
|
|
3336
3632
|
borderColor: "divider"
|
|
3337
3633
|
},
|
|
3338
|
-
onDoubleClick: () => setIsEditing(true)
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
}
|
|
3370
|
-
|
|
3634
|
+
onDoubleClick: () => setIsEditing(true),
|
|
3635
|
+
children: isEditing ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: mask ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3636
|
+
InputMask,
|
|
3637
|
+
{
|
|
3638
|
+
mask,
|
|
3639
|
+
isEditing,
|
|
3640
|
+
setIsEditing,
|
|
3641
|
+
name,
|
|
3642
|
+
rowData,
|
|
3643
|
+
onSave: ({ value: value2, ...rest }) => {
|
|
3644
|
+
setValue(value2);
|
|
3645
|
+
onSave({ value: value2, ...rest });
|
|
3646
|
+
},
|
|
3647
|
+
handleCancelEditing,
|
|
3648
|
+
formatInputDefautvalue
|
|
3649
|
+
}
|
|
3650
|
+
) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3651
|
+
DefaultInput,
|
|
3652
|
+
{
|
|
3653
|
+
onUpdateValue: (newValue) => {
|
|
3654
|
+
setValue(newValue);
|
|
3655
|
+
},
|
|
3656
|
+
isEditing,
|
|
3657
|
+
name,
|
|
3658
|
+
rowData,
|
|
3659
|
+
onSave,
|
|
3660
|
+
handleCancelEditing,
|
|
3661
|
+
setIsEditing,
|
|
3662
|
+
formatInputDefautvalue,
|
|
3663
|
+
type
|
|
3664
|
+
}
|
|
3665
|
+
) }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: formatCellValue(value) })
|
|
3666
|
+
}
|
|
3371
3667
|
);
|
|
3372
3668
|
};
|
|
3373
3669
|
|
|
3374
3670
|
// src/components/Input/index.tsx
|
|
3375
3671
|
|
|
3376
|
-
|
|
3377
3672
|
var _formik = require('formik');
|
|
3673
|
+
|
|
3378
3674
|
var Input = ({ withFormik = true, ...rest }) => {
|
|
3379
|
-
if (withFormik) return /* @__PURE__ */
|
|
3380
|
-
else return /* @__PURE__ */
|
|
3675
|
+
if (withFormik) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FormikInput, { ...rest });
|
|
3676
|
+
else return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BaseInput, { ...rest });
|
|
3381
3677
|
};
|
|
3382
3678
|
var BaseInput = (props) => {
|
|
3383
|
-
return /* @__PURE__ */
|
|
3679
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.TextField, { fullWidth: true, ...props });
|
|
3384
3680
|
};
|
|
3385
3681
|
var FormikInput = ({ name, shrink, ...rest }) => {
|
|
3386
|
-
return /* @__PURE__ */
|
|
3682
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _formik.Field, { name, children: ({ field: { value, ...field }, meta: { error } }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3387
3683
|
BaseInput,
|
|
3388
3684
|
{
|
|
3389
3685
|
defaultValue: value,
|
|
@@ -3393,16 +3689,17 @@ var FormikInput = ({ name, shrink, ...rest }) => {
|
|
|
3393
3689
|
...rest,
|
|
3394
3690
|
InputLabelProps: { shrink, ...rest.InputLabelProps }
|
|
3395
3691
|
}
|
|
3396
|
-
));
|
|
3692
|
+
) });
|
|
3397
3693
|
};
|
|
3398
3694
|
|
|
3399
3695
|
// src/components/InputMask/index.tsx
|
|
3400
3696
|
|
|
3401
3697
|
|
|
3402
3698
|
|
|
3699
|
+
|
|
3403
3700
|
function InputMask2({ withFormik = true, ...rest }) {
|
|
3404
|
-
if (withFormik) return /* @__PURE__ */
|
|
3405
|
-
else return /* @__PURE__ */
|
|
3701
|
+
if (withFormik) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FormikInputMask, { ...rest });
|
|
3702
|
+
else return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BaseInputMask, { ...rest });
|
|
3406
3703
|
}
|
|
3407
3704
|
var BaseInputMask = ({
|
|
3408
3705
|
mask,
|
|
@@ -3427,7 +3724,7 @@ var BaseInputMask = ({
|
|
|
3427
3724
|
setValue(controlledValue);
|
|
3428
3725
|
maskRef.current.value = controlledValue;
|
|
3429
3726
|
}, [controlledValue]);
|
|
3430
|
-
return /* @__PURE__ */
|
|
3727
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BaseInput, { inputRef: ref, ...rest });
|
|
3431
3728
|
};
|
|
3432
3729
|
function FormikInputMask({
|
|
3433
3730
|
mask,
|
|
@@ -3454,14 +3751,14 @@ function FormikInputMask({
|
|
|
3454
3751
|
if (formikSaveFunction.current)
|
|
3455
3752
|
formikSaveFunction.current(name, unmaskedValue);
|
|
3456
3753
|
}, [value]);
|
|
3457
|
-
return /* @__PURE__ */
|
|
3754
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _formik.Field, { name, children: ({
|
|
3458
3755
|
field: { value: value2, ...field },
|
|
3459
3756
|
meta: { error },
|
|
3460
3757
|
form: { setFieldValue }
|
|
3461
3758
|
}) => {
|
|
3462
3759
|
initialValue.current = value2;
|
|
3463
3760
|
formikSaveFunction.current = setFieldValue;
|
|
3464
|
-
return /* @__PURE__ */
|
|
3761
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3465
3762
|
BaseInput,
|
|
3466
3763
|
{
|
|
3467
3764
|
...rest,
|
|
@@ -3471,7 +3768,7 @@ function FormikInputMask({
|
|
|
3471
3768
|
helperText: error
|
|
3472
3769
|
}
|
|
3473
3770
|
);
|
|
3474
|
-
});
|
|
3771
|
+
} });
|
|
3475
3772
|
}
|
|
3476
3773
|
|
|
3477
3774
|
// src/components/Select/index.tsx
|
|
@@ -3484,9 +3781,9 @@ function FormikInputMask({
|
|
|
3484
3781
|
|
|
3485
3782
|
|
|
3486
3783
|
var CustomInputLabel = _material.InputLabel;
|
|
3487
|
-
function Select({ withFormik = true, ...rest }) {
|
|
3488
|
-
if (withFormik) return /* @__PURE__ */
|
|
3489
|
-
else return /* @__PURE__ */
|
|
3784
|
+
function Select({ withFormik = true, helperText, ...rest }) {
|
|
3785
|
+
if (withFormik) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FormikSelect, { helperText, ...rest });
|
|
3786
|
+
else return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BaseSelect, { ...rest });
|
|
3490
3787
|
}
|
|
3491
3788
|
function BaseSelect({
|
|
3492
3789
|
name,
|
|
@@ -3496,18 +3793,21 @@ function BaseSelect({
|
|
|
3496
3793
|
InputLabelProps: InputLabelProps2,
|
|
3497
3794
|
...rest
|
|
3498
3795
|
}) {
|
|
3499
|
-
return /* @__PURE__ */
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
name
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3796
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.FormControl, { fullWidth: true, ...FormControlProps2, children: [
|
|
3797
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomInputLabel, { ...InputLabelProps2, children: label }),
|
|
3798
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3799
|
+
_material.Select,
|
|
3800
|
+
{
|
|
3801
|
+
name,
|
|
3802
|
+
inputProps: {
|
|
3803
|
+
name
|
|
3804
|
+
},
|
|
3805
|
+
label,
|
|
3806
|
+
...rest,
|
|
3807
|
+
children
|
|
3808
|
+
}
|
|
3809
|
+
)
|
|
3810
|
+
] });
|
|
3511
3811
|
}
|
|
3512
3812
|
function FormikSelect({
|
|
3513
3813
|
name,
|
|
@@ -3522,20 +3822,24 @@ function FormikSelect({
|
|
|
3522
3822
|
const onChange = (_, { props: { value: value2 } }) => {
|
|
3523
3823
|
setValue(value2);
|
|
3524
3824
|
};
|
|
3525
|
-
return /* @__PURE__ */
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3825
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.FormControl, { fullWidth: true, ...FormControlProps2, error: Boolean(_optionalChain([meta, 'optionalAccess', _57 => _57.error])), children: [
|
|
3826
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomInputLabel, { ...InputLabelProps2, children: label }),
|
|
3827
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3828
|
+
_material.Select,
|
|
3829
|
+
{
|
|
3830
|
+
inputProps: {
|
|
3831
|
+
name
|
|
3832
|
+
},
|
|
3833
|
+
label,
|
|
3834
|
+
...rest,
|
|
3835
|
+
...field,
|
|
3836
|
+
defaultValue: value,
|
|
3837
|
+
onChange,
|
|
3838
|
+
children
|
|
3839
|
+
}
|
|
3840
|
+
),
|
|
3841
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormHelperText, { children: helperText || _optionalChain([meta, 'optionalAccess', _58 => _58.error]) })
|
|
3842
|
+
] });
|
|
3539
3843
|
}
|
|
3540
3844
|
|
|
3541
3845
|
// src/components/Autocomplete/index.tsx
|
|
@@ -3551,6 +3855,7 @@ function FormikSelect({
|
|
|
3551
3855
|
|
|
3552
3856
|
|
|
3553
3857
|
var _styles = require('@mui/material/styles');
|
|
3858
|
+
|
|
3554
3859
|
function Autocomplete2({
|
|
3555
3860
|
withFormik = true,
|
|
3556
3861
|
name,
|
|
@@ -3560,11 +3865,11 @@ function Autocomplete2({
|
|
|
3560
3865
|
if (withFormik) {
|
|
3561
3866
|
const theme = _styles.useTheme.call(void 0, );
|
|
3562
3867
|
const isLegacyBehaviorDisabledTheme = _react.useMemo.call(void 0, () => {
|
|
3563
|
-
return _optionalChain([theme, 'access',
|
|
3868
|
+
return _optionalChain([theme, 'access', _59 => _59.components, 'optionalAccess', _60 => _60.MuiAutocomplete, 'optionalAccess', _61 => _61.defaultProps, 'optionalAccess', _62 => _62["data-legacy-behavior"]]) === "disabled";
|
|
3564
3869
|
}, [theme]);
|
|
3565
|
-
const isLegacyBehaviorDisabled = typeof _optionalChain([rest, 'optionalAccess',
|
|
3870
|
+
const isLegacyBehaviorDisabled = typeof _optionalChain([rest, 'optionalAccess', _63 => _63["data-legacy-behavior"]]) !== "undefined" ? rest["data-legacy-behavior"] === "disabled" : isLegacyBehaviorDisabledTheme;
|
|
3566
3871
|
if (isLegacyBehaviorDisabled)
|
|
3567
|
-
return /* @__PURE__ */
|
|
3872
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3568
3873
|
FormikAutocomplete,
|
|
3569
3874
|
{
|
|
3570
3875
|
name,
|
|
@@ -3572,7 +3877,7 @@ function Autocomplete2({
|
|
|
3572
3877
|
...rest
|
|
3573
3878
|
}
|
|
3574
3879
|
);
|
|
3575
|
-
return /* @__PURE__ */
|
|
3880
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3576
3881
|
FormikAutocompleteLegacy,
|
|
3577
3882
|
{
|
|
3578
3883
|
name,
|
|
@@ -3581,14 +3886,14 @@ function Autocomplete2({
|
|
|
3581
3886
|
}
|
|
3582
3887
|
);
|
|
3583
3888
|
}
|
|
3584
|
-
return /* @__PURE__ */
|
|
3889
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BaseInput2, { ...rest });
|
|
3585
3890
|
}
|
|
3586
3891
|
function BaseInput2(props) {
|
|
3587
|
-
return /* @__PURE__ */
|
|
3892
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3588
3893
|
_material.Autocomplete,
|
|
3589
3894
|
{
|
|
3590
3895
|
fullWidth: true,
|
|
3591
|
-
renderInput: (params) => /* @__PURE__ */
|
|
3896
|
+
renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.TextField, { label: props.label, ...params }),
|
|
3592
3897
|
...props
|
|
3593
3898
|
}
|
|
3594
3899
|
);
|
|
@@ -3602,14 +3907,14 @@ function FormikAutocompleteLegacy({
|
|
|
3602
3907
|
name: props.name
|
|
3603
3908
|
});
|
|
3604
3909
|
const [defaultOption] = _react.useState.call(void 0, () => {
|
|
3605
|
-
const key = _optionalChain([option, 'optionalAccess',
|
|
3910
|
+
const key = _optionalChain([option, 'optionalAccess', _64 => _64.key]);
|
|
3606
3911
|
if (key) return props.options.find((option2) => option2[key] === value);
|
|
3607
3912
|
return props.options.find(
|
|
3608
3913
|
(option2) => Object.values(option2)[0] === value
|
|
3609
3914
|
);
|
|
3610
3915
|
});
|
|
3611
3916
|
const onChange = (_, newValue) => {
|
|
3612
|
-
const value2 = _optionalChain([option, 'optionalAccess',
|
|
3917
|
+
const value2 = _optionalChain([option, 'optionalAccess', _65 => _65.value]);
|
|
3613
3918
|
if (getOptionValue) {
|
|
3614
3919
|
setValue(getOptionValue(newValue));
|
|
3615
3920
|
} else if (value2) {
|
|
@@ -3617,30 +3922,33 @@ function FormikAutocompleteLegacy({
|
|
|
3617
3922
|
} else setValue(newValue);
|
|
3618
3923
|
};
|
|
3619
3924
|
const getOptionLabel = (item) => {
|
|
3620
|
-
if (_optionalChain([props, 'optionalAccess',
|
|
3621
|
-
if (_optionalChain([option, 'optionalAccess',
|
|
3925
|
+
if (_optionalChain([props, 'optionalAccess', _66 => _66.getOptionLabel])) return props.getOptionLabel(item);
|
|
3926
|
+
if (_optionalChain([option, 'optionalAccess', _67 => _67.label])) return String(item[option.label]);
|
|
3622
3927
|
return "[getOptionLabel] error";
|
|
3623
3928
|
};
|
|
3624
3929
|
const isOptionEqualToValue = (a, b) => {
|
|
3625
|
-
const key = _optionalChain([option, 'optionalAccess',
|
|
3626
|
-
if (_optionalChain([props, 'optionalAccess',
|
|
3930
|
+
const key = _optionalChain([option, 'optionalAccess', _68 => _68.key]);
|
|
3931
|
+
if (_optionalChain([props, 'optionalAccess', _69 => _69.isOptionEqualToValue])) return props.isOptionEqualToValue(a, b);
|
|
3627
3932
|
if (key) return a[key] === b[key];
|
|
3628
3933
|
return Object.values(a)[0] === Object.values(b)[0];
|
|
3629
3934
|
};
|
|
3630
|
-
return /* @__PURE__ */
|
|
3935
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3631
3936
|
_material.Autocomplete,
|
|
3632
3937
|
{
|
|
3633
3938
|
getOptionLabel,
|
|
3634
|
-
renderInput: (params) => /* @__PURE__ */
|
|
3939
|
+
renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3635
3940
|
_material.TextField,
|
|
3636
3941
|
{
|
|
3637
|
-
error: Boolean(_optionalChain([meta, 'optionalAccess',
|
|
3638
|
-
helperText: _optionalChain([meta, 'optionalAccess',
|
|
3942
|
+
error: Boolean(_optionalChain([meta, 'optionalAccess', _70 => _70.error])),
|
|
3943
|
+
helperText: _optionalChain([meta, 'optionalAccess', _71 => _71.error]),
|
|
3639
3944
|
...params,
|
|
3640
3945
|
...field,
|
|
3641
3946
|
InputProps: {
|
|
3642
3947
|
...params.InputProps,
|
|
3643
|
-
endAdornment: /* @__PURE__ */
|
|
3948
|
+
endAdornment: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.Fragment, { children: [
|
|
3949
|
+
props.loading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.CircularProgress, { color: "inherit", size: 20 }) : null,
|
|
3950
|
+
params.InputProps.endAdornment
|
|
3951
|
+
] })
|
|
3644
3952
|
},
|
|
3645
3953
|
label: props.label,
|
|
3646
3954
|
required: props.required,
|
|
@@ -3665,26 +3973,29 @@ function FormikAutocomplete({
|
|
|
3665
3973
|
});
|
|
3666
3974
|
const [defaultValue] = _react.useState.call(void 0, value);
|
|
3667
3975
|
const onChange = (_, newValue) => {
|
|
3668
|
-
const value2 = _optionalChain([option, 'optionalAccess',
|
|
3976
|
+
const value2 = _optionalChain([option, 'optionalAccess', _72 => _72.value]);
|
|
3669
3977
|
if (getOptionValue) {
|
|
3670
3978
|
setValue(getOptionValue(newValue));
|
|
3671
3979
|
} else if (value2) {
|
|
3672
3980
|
setValue(newValue[value2]);
|
|
3673
3981
|
} else setValue(newValue);
|
|
3674
3982
|
};
|
|
3675
|
-
return /* @__PURE__ */
|
|
3983
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3676
3984
|
_material.Autocomplete,
|
|
3677
3985
|
{
|
|
3678
|
-
renderInput: (params) => /* @__PURE__ */
|
|
3986
|
+
renderInput: (params) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3679
3987
|
_material.TextField,
|
|
3680
3988
|
{
|
|
3681
|
-
error: Boolean(_optionalChain([meta, 'optionalAccess',
|
|
3682
|
-
helperText: _optionalChain([meta, 'optionalAccess',
|
|
3989
|
+
error: Boolean(_optionalChain([meta, 'optionalAccess', _73 => _73.error])),
|
|
3990
|
+
helperText: _optionalChain([meta, 'optionalAccess', _74 => _74.error]),
|
|
3683
3991
|
...params,
|
|
3684
3992
|
...field,
|
|
3685
3993
|
InputProps: {
|
|
3686
3994
|
...params.InputProps,
|
|
3687
|
-
endAdornment: /* @__PURE__ */
|
|
3995
|
+
endAdornment: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.Fragment, { children: [
|
|
3996
|
+
props.loading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.CircularProgress, { color: "inherit", size: 20 }) : null,
|
|
3997
|
+
params.InputProps.endAdornment
|
|
3998
|
+
] })
|
|
3688
3999
|
},
|
|
3689
4000
|
label: props.label,
|
|
3690
4001
|
required: props.required,
|
|
@@ -3706,50 +4017,58 @@ function FormikAutocomplete({
|
|
|
3706
4017
|
|
|
3707
4018
|
|
|
3708
4019
|
|
|
4020
|
+
|
|
4021
|
+
|
|
3709
4022
|
var Checkbox = ({
|
|
3710
4023
|
withFormik = true,
|
|
3711
4024
|
name,
|
|
3712
4025
|
...props
|
|
3713
4026
|
}) => {
|
|
3714
|
-
if (withFormik && name) return /* @__PURE__ */
|
|
3715
|
-
else return /* @__PURE__ */
|
|
4027
|
+
if (withFormik && name) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FormikCheckbox, { name, ...props });
|
|
4028
|
+
else return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BaseCheckbox, { ...props });
|
|
3716
4029
|
};
|
|
3717
4030
|
var BaseCheckbox = ({
|
|
3718
4031
|
label,
|
|
4032
|
+
helperText,
|
|
3719
4033
|
FormControlLabelProps: FormControlLabelProps3,
|
|
3720
4034
|
...props
|
|
3721
4035
|
}) => {
|
|
3722
|
-
return /* @__PURE__ */
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
4036
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.FormControl, { children: [
|
|
4037
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4038
|
+
_material.FormControlLabel,
|
|
4039
|
+
{
|
|
4040
|
+
label,
|
|
4041
|
+
control: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Checkbox, { ...props }),
|
|
4042
|
+
...FormControlLabelProps3
|
|
4043
|
+
}
|
|
4044
|
+
),
|
|
4045
|
+
helperText && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormHelperText, { children: helperText })
|
|
4046
|
+
] });
|
|
3730
4047
|
};
|
|
3731
4048
|
var FormikCheckbox = ({
|
|
3732
4049
|
label,
|
|
3733
4050
|
name,
|
|
4051
|
+
helperText,
|
|
3734
4052
|
FormControlLabelProps: FormControlLabelProps3,
|
|
3735
4053
|
...props
|
|
3736
4054
|
}) => {
|
|
3737
|
-
const [{ value, ...field }, , { setValue }] = _formik.useField.call(void 0, {
|
|
3738
|
-
name
|
|
3739
|
-
});
|
|
4055
|
+
const [{ value, ...field }, { error }, { setValue }] = _formik.useField.call(void 0, { name });
|
|
3740
4056
|
const onChange = (_, value2) => {
|
|
3741
4057
|
setValue(value2);
|
|
3742
4058
|
};
|
|
3743
|
-
return /* @__PURE__ */
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
4059
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.FormControl, { error: Boolean(error), children: [
|
|
4060
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4061
|
+
_material.FormControlLabel,
|
|
4062
|
+
{
|
|
4063
|
+
label,
|
|
4064
|
+
control: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Checkbox, { ...props, checked: Boolean(value) }),
|
|
4065
|
+
...field,
|
|
4066
|
+
onChange,
|
|
4067
|
+
...FormControlLabelProps3
|
|
4068
|
+
}
|
|
4069
|
+
),
|
|
4070
|
+
(error || helperText) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormHelperText, { children: _nullishCoalesce(error, () => ( helperText)) })
|
|
4071
|
+
] });
|
|
3753
4072
|
};
|
|
3754
4073
|
|
|
3755
4074
|
// src/components/Switch/index.tsx
|
|
@@ -3759,46 +4078,54 @@ var FormikCheckbox = ({
|
|
|
3759
4078
|
|
|
3760
4079
|
|
|
3761
4080
|
|
|
4081
|
+
|
|
4082
|
+
|
|
3762
4083
|
var Switch = ({ withFormik = true, name, ...props }) => {
|
|
3763
|
-
if (withFormik && name) return /* @__PURE__ */
|
|
3764
|
-
else return /* @__PURE__ */
|
|
4084
|
+
if (withFormik && name) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FormikSwitch, { name, ...props });
|
|
4085
|
+
else return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BaseSwitch, { ...props });
|
|
3765
4086
|
};
|
|
3766
4087
|
var BaseSwitch = ({
|
|
3767
4088
|
label,
|
|
4089
|
+
helperText,
|
|
3768
4090
|
FormControlLabelProps: FormControlLabelProps3,
|
|
3769
4091
|
...props
|
|
3770
4092
|
}) => {
|
|
3771
|
-
return /* @__PURE__ */
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
4093
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.FormControl, { children: [
|
|
4094
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4095
|
+
_material.FormControlLabel,
|
|
4096
|
+
{
|
|
4097
|
+
label,
|
|
4098
|
+
control: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Switch, { ...props }),
|
|
4099
|
+
...FormControlLabelProps3
|
|
4100
|
+
}
|
|
4101
|
+
),
|
|
4102
|
+
helperText && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormHelperText, { children: helperText })
|
|
4103
|
+
] });
|
|
3779
4104
|
};
|
|
3780
4105
|
var FormikSwitch = ({
|
|
3781
4106
|
label,
|
|
3782
4107
|
name,
|
|
4108
|
+
helperText,
|
|
3783
4109
|
FormControlLabelProps: FormControlLabelProps3,
|
|
3784
4110
|
...props
|
|
3785
4111
|
}) => {
|
|
3786
|
-
const [{ value, onChange: unused, ...field }, , { setValue }] = _formik.useField.call(void 0, {
|
|
3787
|
-
name
|
|
3788
|
-
});
|
|
4112
|
+
const [{ value, onChange: unused, ...field }, { error }, { setValue }] = _formik.useField.call(void 0, { name });
|
|
3789
4113
|
const onChange = (_, value2) => {
|
|
3790
4114
|
setValue(value2);
|
|
3791
4115
|
};
|
|
3792
|
-
return /* @__PURE__ */
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
4116
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.FormControl, { error: Boolean(error), children: [
|
|
4117
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4118
|
+
_material.FormControlLabel,
|
|
4119
|
+
{
|
|
4120
|
+
label,
|
|
4121
|
+
onChange,
|
|
4122
|
+
control: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Switch, { checked: value, ...props }),
|
|
4123
|
+
...field,
|
|
4124
|
+
...FormControlLabelProps3
|
|
4125
|
+
}
|
|
4126
|
+
),
|
|
4127
|
+
(error || helperText) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormHelperText, { children: _nullishCoalesce(error, () => ( helperText)) })
|
|
4128
|
+
] });
|
|
3802
4129
|
};
|
|
3803
4130
|
|
|
3804
4131
|
// src/components/Radio/index.tsx
|
|
@@ -3811,55 +4138,64 @@ var FormikSwitch = ({
|
|
|
3811
4138
|
|
|
3812
4139
|
|
|
3813
4140
|
|
|
4141
|
+
|
|
3814
4142
|
var Radio = ({
|
|
3815
4143
|
name,
|
|
3816
4144
|
withFormik = true,
|
|
3817
4145
|
...rest
|
|
3818
4146
|
}) => {
|
|
3819
|
-
if (withFormik && name) return /* @__PURE__ */
|
|
3820
|
-
else return /* @__PURE__ */
|
|
4147
|
+
if (withFormik && name) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FormikRadio, { name, ...rest });
|
|
4148
|
+
else return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BaseRadio, { ...rest });
|
|
3821
4149
|
};
|
|
3822
4150
|
var BaseRadio = ({
|
|
3823
4151
|
label,
|
|
3824
4152
|
options,
|
|
4153
|
+
helperText,
|
|
3825
4154
|
...rest
|
|
3826
4155
|
}) => {
|
|
3827
|
-
return /* @__PURE__ */
|
|
3828
|
-
_material.
|
|
3829
|
-
{
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
4156
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.FormControl, { children: [
|
|
4157
|
+
label && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormLabel, { children: label }),
|
|
4158
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.RadioGroup, { ...rest, children: options.map((option) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4159
|
+
_material.FormControlLabel,
|
|
4160
|
+
{
|
|
4161
|
+
value: option.value,
|
|
4162
|
+
label: option.label,
|
|
4163
|
+
control: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Radio, {})
|
|
4164
|
+
},
|
|
4165
|
+
String(option.value)
|
|
4166
|
+
)) }),
|
|
4167
|
+
helperText && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormHelperText, { children: helperText })
|
|
4168
|
+
] });
|
|
3836
4169
|
};
|
|
3837
4170
|
var FormikRadio = ({
|
|
3838
4171
|
label,
|
|
3839
4172
|
name,
|
|
3840
4173
|
options,
|
|
4174
|
+
helperText,
|
|
3841
4175
|
...rest
|
|
3842
4176
|
}) => {
|
|
3843
|
-
const
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
{
|
|
3849
|
-
defaultValue: value,
|
|
3850
|
-
onChange: (_, value2) => onChange(setFieldValue, value2),
|
|
3851
|
-
...rest
|
|
3852
|
-
},
|
|
3853
|
-
options.map((option) => /* @__PURE__ */ React2.default.createElement(
|
|
3854
|
-
_material.FormControlLabel,
|
|
4177
|
+
const [{ value }, meta, { setValue }] = _formik.useField.call(void 0, name);
|
|
4178
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.FormControl, { error: Boolean(meta.error), children: [
|
|
4179
|
+
label && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormLabel, { children: label }),
|
|
4180
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4181
|
+
_material.RadioGroup,
|
|
3855
4182
|
{
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
4183
|
+
value: _nullishCoalesce(value, () => ( "")),
|
|
4184
|
+
onChange: (_, val) => setValue(val),
|
|
4185
|
+
...rest,
|
|
4186
|
+
children: options.map((option) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4187
|
+
_material.FormControlLabel,
|
|
4188
|
+
{
|
|
4189
|
+
value: option.value,
|
|
4190
|
+
label: option.label,
|
|
4191
|
+
control: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Radio, {})
|
|
4192
|
+
},
|
|
4193
|
+
String(option.value)
|
|
4194
|
+
))
|
|
3860
4195
|
}
|
|
3861
|
-
)
|
|
3862
|
-
|
|
4196
|
+
),
|
|
4197
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.FormHelperText, { children: helperText || meta.error })
|
|
4198
|
+
] });
|
|
3863
4199
|
};
|
|
3864
4200
|
|
|
3865
4201
|
// src/components/LargeButton/index.tsx
|
|
@@ -3875,23 +4211,23 @@ var LargeButton = ({
|
|
|
3875
4211
|
sx,
|
|
3876
4212
|
...rest
|
|
3877
4213
|
}) => {
|
|
3878
|
-
return /* @__PURE__ */
|
|
4214
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3879
4215
|
_material.Button,
|
|
3880
4216
|
{
|
|
3881
4217
|
variant: "contained",
|
|
3882
4218
|
fullWidth: true,
|
|
3883
4219
|
sx: { fontWeight: "bold", ...sx },
|
|
3884
4220
|
disabled: rest.disabled || loading,
|
|
3885
|
-
...rest
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
4221
|
+
...rest,
|
|
4222
|
+
children: loading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4223
|
+
_material.CircularProgress,
|
|
4224
|
+
{
|
|
4225
|
+
size: 25,
|
|
4226
|
+
color: "inherit",
|
|
4227
|
+
...CircularProgressProps2
|
|
4228
|
+
}
|
|
4229
|
+
) : children
|
|
4230
|
+
}
|
|
3895
4231
|
);
|
|
3896
4232
|
};
|
|
3897
4233
|
|
|
@@ -3905,16 +4241,16 @@ function getTabProps(index) {
|
|
|
3905
4241
|
}
|
|
3906
4242
|
var TabPanel = (props) => {
|
|
3907
4243
|
const { children, value, index, ...other } = props;
|
|
3908
|
-
return /* @__PURE__ */
|
|
4244
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3909
4245
|
"div",
|
|
3910
4246
|
{
|
|
3911
4247
|
role: "tabpanel",
|
|
3912
4248
|
hidden: value !== index,
|
|
3913
4249
|
id: `tabpanel-${index}`,
|
|
3914
4250
|
"aria-labelledby": `tab-${index}`,
|
|
3915
|
-
...other
|
|
3916
|
-
|
|
3917
|
-
|
|
4251
|
+
...other,
|
|
4252
|
+
children: value === index && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children })
|
|
4253
|
+
}
|
|
3918
4254
|
);
|
|
3919
4255
|
};
|
|
3920
4256
|
|
|
@@ -3931,7 +4267,6 @@ var TabPanel = (props) => {
|
|
|
3931
4267
|
|
|
3932
4268
|
|
|
3933
4269
|
|
|
3934
|
-
|
|
3935
4270
|
// src/components/BaseGrid/Pagination/index.tsx
|
|
3936
4271
|
|
|
3937
4272
|
|
|
@@ -3952,44 +4287,55 @@ var GridPagination = ({
|
|
|
3952
4287
|
rowsPerPage,
|
|
3953
4288
|
dense
|
|
3954
4289
|
}) => {
|
|
3955
|
-
return /* @__PURE__ */
|
|
4290
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3956
4291
|
_material.Stack,
|
|
3957
4292
|
{
|
|
3958
4293
|
direction: "row",
|
|
3959
4294
|
justifyContent: "space-between",
|
|
3960
4295
|
alignItems: "center",
|
|
3961
4296
|
width: "100%",
|
|
3962
|
-
py: dense ? 0.5 : 1
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
4297
|
+
py: dense ? 0.5 : 1,
|
|
4298
|
+
children: [
|
|
4299
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, {}),
|
|
4300
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Stack, { direction: "row", alignItems: "center", children: [
|
|
4301
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4302
|
+
_material.Select,
|
|
4303
|
+
{
|
|
4304
|
+
variant: "standard",
|
|
4305
|
+
size: "small",
|
|
4306
|
+
margin: "dense",
|
|
4307
|
+
sx: { width: 60, mr: 2, textAlign: "center", fontSize: 13 },
|
|
4308
|
+
value: rowsPerPage,
|
|
4309
|
+
onChange: ({ target }) => setRowsPerPage(parseInt(target.value)),
|
|
4310
|
+
children: rowsPerPageOptions.map((option) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.MenuItem, { value: option, children: option }, option))
|
|
4311
|
+
}
|
|
4312
|
+
),
|
|
4313
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Typography, { variant: "body2", children: [
|
|
4314
|
+
currentPage + 1,
|
|
4315
|
+
" de ",
|
|
4316
|
+
totalNumberOfPages + 1
|
|
4317
|
+
] }),
|
|
4318
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4319
|
+
_material.IconButton,
|
|
4320
|
+
{
|
|
4321
|
+
size: "small",
|
|
4322
|
+
disabled: currentPage === 0,
|
|
4323
|
+
onClick: () => onPageChange(currentPage - 1),
|
|
4324
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _md.MdArrowBackIosNew, { size: 8 * 2 })
|
|
4325
|
+
}
|
|
4326
|
+
),
|
|
4327
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4328
|
+
_material.IconButton,
|
|
4329
|
+
{
|
|
4330
|
+
size: "small",
|
|
4331
|
+
disabled: currentPage === totalNumberOfPages,
|
|
4332
|
+
onClick: () => onPageChange(currentPage + 1),
|
|
4333
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _md.MdArrowForwardIos, { size: 8 * 2 })
|
|
4334
|
+
}
|
|
4335
|
+
)
|
|
4336
|
+
] })
|
|
4337
|
+
]
|
|
4338
|
+
}
|
|
3993
4339
|
);
|
|
3994
4340
|
};
|
|
3995
4341
|
|
|
@@ -4031,6 +4377,7 @@ var styles = {
|
|
|
4031
4377
|
};
|
|
4032
4378
|
|
|
4033
4379
|
// src/components/BaseGrid/index.tsx
|
|
4380
|
+
|
|
4034
4381
|
function BaseGrid({
|
|
4035
4382
|
columns,
|
|
4036
4383
|
children,
|
|
@@ -4057,7 +4404,7 @@ function BaseGrid({
|
|
|
4057
4404
|
loadingColSpan,
|
|
4058
4405
|
isLoading
|
|
4059
4406
|
}) {
|
|
4060
|
-
return /* @__PURE__ */
|
|
4407
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
4061
4408
|
_material.Paper,
|
|
4062
4409
|
{
|
|
4063
4410
|
...paperProps,
|
|
@@ -4066,71 +4413,82 @@ function BaseGrid({
|
|
|
4066
4413
|
...styles.bordered(bordered),
|
|
4067
4414
|
...styles.striped(striped),
|
|
4068
4415
|
...styles.lastRowBorder(hideFooter),
|
|
4069
|
-
..._optionalChain([paperProps, 'optionalAccess',
|
|
4070
|
-
}
|
|
4071
|
-
},
|
|
4072
|
-
/* @__PURE__ */ React2.default.createElement(
|
|
4073
|
-
_material.Box,
|
|
4074
|
-
{
|
|
4075
|
-
...boxContainerProps,
|
|
4076
|
-
sx: { overflowX: "auto", ..._optionalChain([boxContainerProps, 'optionalAccess', _67 => _67.sx]) }
|
|
4416
|
+
..._optionalChain([paperProps, 'optionalAccess', _75 => _75.sx])
|
|
4077
4417
|
},
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
size: "small",
|
|
4082
|
-
stickyHeader: true,
|
|
4083
|
-
...tableProps,
|
|
4084
|
-
sx: {
|
|
4085
|
-
..._optionalChain([tableProps, 'optionalAccess', _68 => _68.sx])
|
|
4086
|
-
}
|
|
4087
|
-
},
|
|
4088
|
-
/* @__PURE__ */ React2.default.createElement(_material.TableHead, { ...tableHeadProps }, /* @__PURE__ */ React2.default.createElement(_material.TableRow, null, prependColumn, columns.map((column) => /* @__PURE__ */ React2.default.createElement(
|
|
4089
|
-
_material.TableCell,
|
|
4418
|
+
children: [
|
|
4419
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4420
|
+
_material.Box,
|
|
4090
4421
|
{
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4422
|
+
...boxContainerProps,
|
|
4423
|
+
sx: { overflowX: "auto", ..._optionalChain([boxContainerProps, 'optionalAccess', _76 => _76.sx]) },
|
|
4424
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
4425
|
+
_material.Table,
|
|
4426
|
+
{
|
|
4427
|
+
size: "small",
|
|
4428
|
+
stickyHeader: true,
|
|
4429
|
+
...tableProps,
|
|
4430
|
+
sx: {
|
|
4431
|
+
..._optionalChain([tableProps, 'optionalAccess', _77 => _77.sx])
|
|
4432
|
+
},
|
|
4433
|
+
children: [
|
|
4434
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.TableHead, { ...tableHeadProps, children: [
|
|
4435
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.TableRow, { children: [
|
|
4436
|
+
prependColumn,
|
|
4437
|
+
columns.map((column) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4438
|
+
_material.TableCell,
|
|
4439
|
+
{
|
|
4440
|
+
padding: dense ? "none" : "normal",
|
|
4441
|
+
...column.props,
|
|
4442
|
+
sx: {
|
|
4443
|
+
pl: 2,
|
|
4444
|
+
..._optionalChain([column, 'optionalAccess', _78 => _78.sx])
|
|
4445
|
+
},
|
|
4446
|
+
children: column.children ? column.children : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4447
|
+
_material.TableSortLabel,
|
|
4448
|
+
{
|
|
4449
|
+
active: sortedBy.some((p) => p.prop === column.name),
|
|
4450
|
+
direction: _optionalChain([sortedBy, 'access', _79 => _79.find, 'call', _80 => _80((p) => p.prop === column.name), 'optionalAccess', _81 => _81.direction]) || "desc",
|
|
4451
|
+
onClick: () => onSortBy(column.name),
|
|
4452
|
+
disabled: column.canSort === false,
|
|
4453
|
+
...tableSortLabelProps,
|
|
4454
|
+
sx: { ..._optionalChain([tableSortLabelProps, 'optionalAccess', _82 => _82.sx]) },
|
|
4455
|
+
children: column.label
|
|
4456
|
+
}
|
|
4457
|
+
)
|
|
4458
|
+
},
|
|
4459
|
+
column.name
|
|
4460
|
+
)),
|
|
4461
|
+
appendColumn
|
|
4462
|
+
] }),
|
|
4463
|
+
isLoading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.TableRow, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4464
|
+
_material.TableCell,
|
|
4465
|
+
{
|
|
4466
|
+
colSpan: loadingColSpan || columns.length,
|
|
4467
|
+
sx: { p: 0, border: "none" },
|
|
4468
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.LinearProgress, {})
|
|
4469
|
+
}
|
|
4470
|
+
) })
|
|
4471
|
+
] }),
|
|
4472
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.TableBody, { ...tableBodyProps, children })
|
|
4473
|
+
]
|
|
4474
|
+
}
|
|
4475
|
+
)
|
|
4476
|
+
}
|
|
4477
|
+
),
|
|
4478
|
+
!hideFooter && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4479
|
+
GridPagination,
|
|
4113
4480
|
{
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
rowsPerPageOptions,
|
|
4126
|
-
currentPage,
|
|
4127
|
-
totalNumberOfPages,
|
|
4128
|
-
onPageChange,
|
|
4129
|
-
setRowsPerPage,
|
|
4130
|
-
rowsPerPage,
|
|
4131
|
-
dense
|
|
4132
|
-
}
|
|
4133
|
-
)
|
|
4481
|
+
rowsPerPageOptions,
|
|
4482
|
+
currentPage,
|
|
4483
|
+
totalNumberOfPages,
|
|
4484
|
+
onPageChange,
|
|
4485
|
+
setRowsPerPage,
|
|
4486
|
+
rowsPerPage,
|
|
4487
|
+
dense
|
|
4488
|
+
}
|
|
4489
|
+
)
|
|
4490
|
+
]
|
|
4491
|
+
}
|
|
4134
4492
|
);
|
|
4135
4493
|
}
|
|
4136
4494
|
|
|
@@ -4143,7 +4501,7 @@ function BaseGridAutoRows({
|
|
|
4143
4501
|
columns,
|
|
4144
4502
|
rowKey
|
|
4145
4503
|
}) {
|
|
4146
|
-
return /* @__PURE__ */
|
|
4504
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: data.map((row) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.TableRow, { children: columns.map((column) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.TableCell, { children: row[column.name] }, column.name)) }, row[rowKey])) });
|
|
4147
4505
|
}
|
|
4148
4506
|
|
|
4149
4507
|
// src/components/Modal/index.tsx
|
|
@@ -4153,7 +4511,12 @@ function BaseGridAutoRows({
|
|
|
4153
4511
|
|
|
4154
4512
|
|
|
4155
4513
|
var Modal = ({ open, onClose, BoxProps: BoxProps3, ...rest }) => {
|
|
4156
|
-
|
|
4514
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4515
|
+
console.warn(
|
|
4516
|
+
"[Modal] is deprecated. Use `BaseDialog` instead. `Modal` will be removed in a future release."
|
|
4517
|
+
);
|
|
4518
|
+
}
|
|
4519
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Modal, { open, onClose, ...rest, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4157
4520
|
_material.Box,
|
|
4158
4521
|
{
|
|
4159
4522
|
...BoxProps3,
|
|
@@ -4165,11 +4528,11 @@ var Modal = ({ open, onClose, BoxProps: BoxProps3, ...rest }) => {
|
|
|
4165
4528
|
left: "50%",
|
|
4166
4529
|
transform: "translate(-50%, -50%)",
|
|
4167
4530
|
borderRadius: 1,
|
|
4168
|
-
..._optionalChain([BoxProps3, 'optionalAccess',
|
|
4169
|
-
}
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
));
|
|
4531
|
+
..._optionalChain([BoxProps3, 'optionalAccess', _83 => _83.sx])
|
|
4532
|
+
},
|
|
4533
|
+
children: rest.children
|
|
4534
|
+
}
|
|
4535
|
+
) });
|
|
4173
4536
|
};
|
|
4174
4537
|
|
|
4175
4538
|
// src/components/utils/GetInputLabel.ts
|
|
@@ -4199,28 +4562,31 @@ var Dialog = ({
|
|
|
4199
4562
|
options,
|
|
4200
4563
|
...rest
|
|
4201
4564
|
}) => {
|
|
4202
|
-
return /* @__PURE__ */
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4565
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Dialog, { open, ...rest, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 2 }, children: [
|
|
4566
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.DialogTitle, { sx: { fontWeight: "bold" }, children: title }),
|
|
4567
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.DialogContentText, { sx: { px: "10px", textAlign: "center", mb: 2 }, children: body }),
|
|
4568
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.DialogActions, { children: options.map((option, index) => {
|
|
4569
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4570
|
+
_material.Button,
|
|
4571
|
+
{
|
|
4572
|
+
onClick: () => option.cb(option.label),
|
|
4573
|
+
variant: option.focus ? "contained" : "text",
|
|
4574
|
+
sx: {
|
|
4575
|
+
fontWeight: option.focus ? "bold" : "normal",
|
|
4576
|
+
color: option.focus ? "#fff" : "primary.main"
|
|
4577
|
+
},
|
|
4578
|
+
disableElevation: true,
|
|
4579
|
+
disabled: loading,
|
|
4580
|
+
children: loading && option.focus ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.CircularProgress, { size: 25, color: "inherit" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: option.label })
|
|
4212
4581
|
},
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
);
|
|
4218
|
-
}))));
|
|
4582
|
+
index
|
|
4583
|
+
);
|
|
4584
|
+
}) })
|
|
4585
|
+
] }) });
|
|
4219
4586
|
};
|
|
4220
4587
|
|
|
4221
4588
|
// src/components/DialogConfirm/DialogConfirm.view.tsx
|
|
4222
4589
|
|
|
4223
|
-
|
|
4224
4590
|
var _colors = require('@mui/material/colors');
|
|
4225
4591
|
|
|
4226
4592
|
|
|
@@ -4240,8 +4606,8 @@ function UseDialogConfirm() {
|
|
|
4240
4606
|
};
|
|
4241
4607
|
};
|
|
4242
4608
|
const onProceed = async (event) => {
|
|
4243
|
-
_optionalChain([event, 'optionalAccess',
|
|
4244
|
-
_optionalChain([event, 'optionalAccess',
|
|
4609
|
+
_optionalChain([event, 'optionalAccess', _84 => _84.preventDefault, 'call', _85 => _85()]);
|
|
4610
|
+
_optionalChain([event, 'optionalAccess', _86 => _86.stopPropagation, 'call', _87 => _87()]);
|
|
4245
4611
|
setLoading(true);
|
|
4246
4612
|
try {
|
|
4247
4613
|
if (!onConfirmFn.current) return;
|
|
@@ -4252,8 +4618,8 @@ function UseDialogConfirm() {
|
|
|
4252
4618
|
}
|
|
4253
4619
|
};
|
|
4254
4620
|
const onCancel = (event) => {
|
|
4255
|
-
_optionalChain([event, 'optionalAccess',
|
|
4256
|
-
_optionalChain([event, 'optionalAccess',
|
|
4621
|
+
_optionalChain([event, 'optionalAccess', _88 => _88.preventDefault, 'call', _89 => _89()]);
|
|
4622
|
+
_optionalChain([event, 'optionalAccess', _90 => _90.stopPropagation, 'call', _91 => _91()]);
|
|
4257
4623
|
setOpened(false);
|
|
4258
4624
|
};
|
|
4259
4625
|
const onCloseModal = () => {
|
|
@@ -4271,50 +4637,59 @@ function UseDialogConfirm() {
|
|
|
4271
4637
|
}
|
|
4272
4638
|
|
|
4273
4639
|
// src/components/DialogConfirm/DialogConfirm.view.tsx
|
|
4640
|
+
|
|
4274
4641
|
var DEFAULT_ICON = _md.MdOutlineWarningAmber;
|
|
4275
4642
|
var DialogConfirm = (props) => {
|
|
4276
4643
|
const model = UseDialogConfirm();
|
|
4277
4644
|
const Icon = props.icon || DEFAULT_ICON;
|
|
4278
|
-
return /* @__PURE__ */
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
{
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4645
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4646
|
+
props.children({
|
|
4647
|
+
onConfirm: model.onConfirm,
|
|
4648
|
+
onCancel: model.onCancel
|
|
4649
|
+
}),
|
|
4650
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Portal, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Modal, { open: model.opened, onClose: model.onCloseModal, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 2, maxWidth: 400, textAlign: "center" }, children: [
|
|
4651
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4652
|
+
_material.Stack,
|
|
4653
|
+
{
|
|
4654
|
+
mx: "auto",
|
|
4655
|
+
color: _colors.orange[800],
|
|
4656
|
+
bgcolor: _colors.orange[50],
|
|
4657
|
+
borderRadius: "50%",
|
|
4658
|
+
height: 8 * 5,
|
|
4659
|
+
width: 8 * 5,
|
|
4660
|
+
direction: "row",
|
|
4661
|
+
justifyContent: "center",
|
|
4662
|
+
alignItems: "center",
|
|
4663
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { size: 8 * 3 })
|
|
4664
|
+
}
|
|
4665
|
+
),
|
|
4666
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { fontWeight: "bold", variant: "h6", mt: 1, children: props.title || "Aten\xE7\xE3o" }),
|
|
4667
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { my: 1, children: props.body || "Tem certeza que deseja realizar essa a\xE7\xE3o?" }),
|
|
4668
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Stack, { gap: 1, mt: 3, color: _colors.grey[600], children: [
|
|
4669
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4670
|
+
LargeButton,
|
|
4671
|
+
{
|
|
4672
|
+
color: "warning",
|
|
4673
|
+
loading: model.isLoading,
|
|
4674
|
+
onClick: model.onProceed,
|
|
4675
|
+
children: props.confirmButtonText || "Confirmar"
|
|
4676
|
+
}
|
|
4677
|
+
),
|
|
4678
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4679
|
+
LargeButton,
|
|
4680
|
+
{
|
|
4681
|
+
variant: "outlined",
|
|
4682
|
+
disabled: model.isLoading,
|
|
4683
|
+
onClick: model.onCancel,
|
|
4684
|
+
color: "inherit",
|
|
4685
|
+
children: props.cancelButtonText || "Cancelar"
|
|
4686
|
+
}
|
|
4687
|
+
)
|
|
4688
|
+
] })
|
|
4689
|
+
] }) }) })
|
|
4690
|
+
] });
|
|
4313
4691
|
};
|
|
4314
4692
|
|
|
4315
|
-
// src/components/BaseDialog/BaseDialog.tsx
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
4693
|
// src/components/BaseDialog/BaseDialogHook.ts
|
|
4319
4694
|
|
|
4320
4695
|
|
|
@@ -4348,7 +4723,7 @@ var BaseDialogProvider = (props) => {
|
|
|
4348
4723
|
const closeAllDialogs = _react.useCallback.call(void 0, () => {
|
|
4349
4724
|
return setOpenedDialogs([]);
|
|
4350
4725
|
}, [openedDialogs]);
|
|
4351
|
-
return /* @__PURE__ */
|
|
4726
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4352
4727
|
BaseDialogContext.Provider,
|
|
4353
4728
|
{
|
|
4354
4729
|
value: {
|
|
@@ -4358,9 +4733,9 @@ var BaseDialogProvider = (props) => {
|
|
|
4358
4733
|
open: openDialog,
|
|
4359
4734
|
closeAll: closeAllDialogs,
|
|
4360
4735
|
close: closeDialog
|
|
4361
|
-
}
|
|
4362
|
-
|
|
4363
|
-
|
|
4736
|
+
},
|
|
4737
|
+
children: props.children
|
|
4738
|
+
}
|
|
4364
4739
|
);
|
|
4365
4740
|
};
|
|
4366
4741
|
|
|
@@ -4372,7 +4747,7 @@ var BaseDialogInstanceContext = _react.createContext.call(void 0,
|
|
|
4372
4747
|
);
|
|
4373
4748
|
var BaseDialogInstanceProvider = (props) => {
|
|
4374
4749
|
const actions = useBaseDialog();
|
|
4375
|
-
return /* @__PURE__ */
|
|
4750
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BaseDialogInstanceContext.Provider, { value: { name: props.name, actions }, children: props.children });
|
|
4376
4751
|
};
|
|
4377
4752
|
|
|
4378
4753
|
// src/components/BaseDialog/BaseDialogHook.ts
|
|
@@ -4407,7 +4782,7 @@ var BaseDialogHeader = ({
|
|
|
4407
4782
|
if (onClose) return onClose();
|
|
4408
4783
|
closeDialog(name);
|
|
4409
4784
|
}
|
|
4410
|
-
return /* @__PURE__ */
|
|
4785
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
4411
4786
|
_material.Stack,
|
|
4412
4787
|
{
|
|
4413
4788
|
direction: "row",
|
|
@@ -4415,24 +4790,27 @@ var BaseDialogHeader = ({
|
|
|
4415
4790
|
justifyContent: "space-between",
|
|
4416
4791
|
px: 2,
|
|
4417
4792
|
my: 1,
|
|
4418
|
-
...props
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4793
|
+
...props,
|
|
4794
|
+
children: [
|
|
4795
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h6", fontWeight: "bold", ...TypographyProps2, children: title }),
|
|
4796
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.IconButton, { ...IconButtonProps, onClick: handleClose, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _md.MdClose, {}) })
|
|
4797
|
+
]
|
|
4798
|
+
}
|
|
4422
4799
|
);
|
|
4423
4800
|
};
|
|
4424
4801
|
|
|
4425
4802
|
// src/components/BaseDialog/BaseDialog.tsx
|
|
4803
|
+
|
|
4426
4804
|
var BaseDialogContainer = ({
|
|
4427
4805
|
children,
|
|
4428
4806
|
...rest
|
|
4429
4807
|
}) => {
|
|
4430
4808
|
const { name } = useBaseDialogInstance();
|
|
4431
4809
|
const { isOpened, close: closeDialog } = useBaseDialog();
|
|
4432
|
-
return /* @__PURE__ */
|
|
4810
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Modal, { open: isOpened(name), onClose: () => closeDialog(name), ...rest, children: children instanceof Function ? children({ close: () => closeDialog(name) }) : children });
|
|
4433
4811
|
};
|
|
4434
4812
|
var BaseDialogBody = (props) => {
|
|
4435
|
-
return /* @__PURE__ */
|
|
4813
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { px: 2, pb: 2, width: "100vw", maxWidth: 650, ...props, children: props.children });
|
|
4436
4814
|
};
|
|
4437
4815
|
var BaseDialogTrigger = ({
|
|
4438
4816
|
name,
|
|
@@ -4440,23 +4818,23 @@ var BaseDialogTrigger = ({
|
|
|
4440
4818
|
...props
|
|
4441
4819
|
}) => {
|
|
4442
4820
|
const { open } = useBaseDialog();
|
|
4443
|
-
return /* @__PURE__ */
|
|
4821
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4444
4822
|
_material.Button,
|
|
4445
4823
|
{
|
|
4446
4824
|
...props,
|
|
4447
4825
|
onClick: (...params) => {
|
|
4448
4826
|
if (onClick) onClick(...params);
|
|
4449
4827
|
open(name);
|
|
4450
|
-
}
|
|
4451
|
-
|
|
4452
|
-
|
|
4828
|
+
},
|
|
4829
|
+
children: props.children
|
|
4830
|
+
}
|
|
4453
4831
|
);
|
|
4454
4832
|
};
|
|
4455
4833
|
var BaseDialogCreate = (name = /* @__PURE__ */ Symbol()) => {
|
|
4456
4834
|
return {
|
|
4457
4835
|
name,
|
|
4458
|
-
Trigger: (props) => /* @__PURE__ */
|
|
4459
|
-
Root: (props) => /* @__PURE__ */
|
|
4836
|
+
Trigger: (props) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BaseDialogTrigger, { name, ...props }),
|
|
4837
|
+
Root: (props) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BaseDialogInstanceProvider, { name, ...props }),
|
|
4460
4838
|
Container: BaseDialogContainer,
|
|
4461
4839
|
Header: BaseDialogHeader,
|
|
4462
4840
|
Body: BaseDialogBody
|
|
@@ -4472,162 +4850,55 @@ var BaseDialog = {
|
|
|
4472
4850
|
Body: BaseDialogBody
|
|
4473
4851
|
};
|
|
4474
4852
|
|
|
4475
|
-
// src/
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
this.status = status;
|
|
4482
|
-
}
|
|
4853
|
+
// src/contexts/FormHelperProvider.tsx
|
|
4854
|
+
|
|
4855
|
+
|
|
4856
|
+
var FormHelperContext = _react.createContext.call(void 0, {});
|
|
4857
|
+
var FormHelperProvider = ({ formatErrorMessage, api, children }) => {
|
|
4858
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FormHelperContext.Provider, { value: { formatErrorMessage, api }, children });
|
|
4483
4859
|
};
|
|
4484
4860
|
|
|
4485
|
-
// src/
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4861
|
+
// src/contexts/AlertContext.tsx
|
|
4862
|
+
|
|
4863
|
+
|
|
4864
|
+
|
|
4865
|
+
// src/components/Toast/index.tsx
|
|
4866
|
+
|
|
4867
|
+
|
|
4868
|
+
|
|
4869
|
+
var Toast = ({ open, onClose, severity, message }) => {
|
|
4870
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4871
|
+
_material.Snackbar,
|
|
4872
|
+
{
|
|
4873
|
+
open,
|
|
4874
|
+
autoHideDuration: 6e3,
|
|
4875
|
+
onClose,
|
|
4876
|
+
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
4877
|
+
sx: { zIndex: 99999999 },
|
|
4878
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4879
|
+
_material.Alert,
|
|
4880
|
+
{
|
|
4881
|
+
severity,
|
|
4882
|
+
elevation: 2,
|
|
4883
|
+
action: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4884
|
+
_material.IconButton,
|
|
4885
|
+
{
|
|
4886
|
+
"aria-label": "close",
|
|
4887
|
+
color: "inherit",
|
|
4888
|
+
size: "small",
|
|
4889
|
+
onClick: onClose,
|
|
4890
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _md.MdClose, { fontSize: "inherit" })
|
|
4891
|
+
}
|
|
4892
|
+
),
|
|
4893
|
+
children: message
|
|
4894
|
+
}
|
|
4895
|
+
)
|
|
4896
|
+
}
|
|
4897
|
+
) });
|
|
4492
4898
|
};
|
|
4493
4899
|
|
|
4494
|
-
// src/helpers/apiHelper/index.ts
|
|
4495
|
-
var VALID_METHODS = [
|
|
4496
|
-
"GET",
|
|
4497
|
-
"HEAD",
|
|
4498
|
-
"POST",
|
|
4499
|
-
"PUT",
|
|
4500
|
-
"DELETE",
|
|
4501
|
-
"CONNECT",
|
|
4502
|
-
"OPTIONS",
|
|
4503
|
-
"TRACE",
|
|
4504
|
-
"PATCH"
|
|
4505
|
-
];
|
|
4506
|
-
var _ApiHelper = class _ApiHelper {
|
|
4507
|
-
async onFinally(_req, _res) {
|
|
4508
|
-
}
|
|
4509
|
-
async onError(_req, _res, _error) {
|
|
4510
|
-
}
|
|
4511
|
-
constructor(props) {
|
|
4512
|
-
this.public = _nullishCoalesce(_optionalChain([props, 'optionalAccess', _83 => _83.public]), () => ( false));
|
|
4513
|
-
this.middlewares = (_optionalChain([props, 'optionalAccess', _84 => _84.middlewares]) || []).reverse();
|
|
4514
|
-
this.onFinally = _optionalChain([props, 'optionalAccess', _85 => _85.onFinally]) || (async () => {
|
|
4515
|
-
});
|
|
4516
|
-
this.onError = _optionalChain([props, 'optionalAccess', _86 => _86.onError]) || (async () => {
|
|
4517
|
-
});
|
|
4518
|
-
}
|
|
4519
|
-
createMethods(methods) {
|
|
4520
|
-
return async (req, res) => {
|
|
4521
|
-
const currentMethod = methods[req.method] || methods.ALL;
|
|
4522
|
-
const options = { public: this.public };
|
|
4523
|
-
if (req.method === "OPTIONS") return res.status(200).end();
|
|
4524
|
-
try {
|
|
4525
|
-
if (!VALID_METHODS.includes(req.method))
|
|
4526
|
-
throw new HttpError(405, "M\xE9todo inv\xE1lido");
|
|
4527
|
-
if (!currentMethod) throw new HttpError(500, "M\xE9todo n\xE3o encontrado");
|
|
4528
|
-
const methodWithMiddlewares = this.middlewares.reduce(
|
|
4529
|
-
(acc, fn) => fn(acc, options),
|
|
4530
|
-
currentMethod
|
|
4531
|
-
);
|
|
4532
|
-
return await methodWithMiddlewares(req, res, options);
|
|
4533
|
-
} catch (error) {
|
|
4534
|
-
if (error instanceof DomainError) return res.status(400).json(error.message);
|
|
4535
|
-
if (error instanceof HttpError) return res.status(error.status).json(error.message);
|
|
4536
|
-
this.onError(req, res, error);
|
|
4537
|
-
throw error;
|
|
4538
|
-
} finally {
|
|
4539
|
-
await this.onFinally(req, res);
|
|
4540
|
-
}
|
|
4541
|
-
};
|
|
4542
|
-
}
|
|
4543
|
-
buildFactory(factory) {
|
|
4544
|
-
const options = {
|
|
4545
|
-
public: this.public
|
|
4546
|
-
};
|
|
4547
|
-
return async (req, res) => {
|
|
4548
|
-
const methods = factory(req, res);
|
|
4549
|
-
const handler = methods[req.method];
|
|
4550
|
-
const methodWithMiddlewares = this.middlewares.reduce((acc, fn) => {
|
|
4551
|
-
return fn(acc, options);
|
|
4552
|
-
}, handler);
|
|
4553
|
-
return await methodWithMiddlewares(req, res, options);
|
|
4554
|
-
};
|
|
4555
|
-
}
|
|
4556
|
-
static build(factory, options) {
|
|
4557
|
-
const helper = new _ApiHelper({
|
|
4558
|
-
...options
|
|
4559
|
-
}).buildFactory(factory);
|
|
4560
|
-
return helper;
|
|
4561
|
-
}
|
|
4562
|
-
static parse(body, parser) {
|
|
4563
|
-
try {
|
|
4564
|
-
const object = parser.parse(body);
|
|
4565
|
-
return object;
|
|
4566
|
-
} catch (error) {
|
|
4567
|
-
throw new HttpError(400, {
|
|
4568
|
-
code: "invalid.body",
|
|
4569
|
-
error: "Dados inv\xE1lidos",
|
|
4570
|
-
details: error
|
|
4571
|
-
});
|
|
4572
|
-
}
|
|
4573
|
-
}
|
|
4574
|
-
/** @deprecated Use {@Link ApiHelper.build} instead. */
|
|
4575
|
-
static create({ onFinally }) {
|
|
4576
|
-
return new _ApiHelper({
|
|
4577
|
-
onFinally
|
|
4578
|
-
});
|
|
4579
|
-
}
|
|
4580
|
-
};
|
|
4581
|
-
/** @deprecated Use {@link ApiHelper.parser} instead. */
|
|
4582
|
-
_ApiHelper.parserErrorWrapper = _ApiHelper.parse;
|
|
4583
|
-
var ApiHelper = _ApiHelper;
|
|
4584
|
-
|
|
4585
|
-
// src/hooks/useFormHelper.ts
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
// src/hooks/useAlert.ts
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
4900
|
// src/contexts/AlertContext.tsx
|
|
4592
4901
|
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
// src/components/Toast/index.tsx
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
var Toast = ({ open, onClose, severity, message }) => {
|
|
4600
|
-
return /* @__PURE__ */ React2.default.createElement(React2.default.Fragment, null, /* @__PURE__ */ React2.default.createElement(
|
|
4601
|
-
_material.Snackbar,
|
|
4602
|
-
{
|
|
4603
|
-
open,
|
|
4604
|
-
autoHideDuration: 6e3,
|
|
4605
|
-
onClose,
|
|
4606
|
-
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
4607
|
-
sx: { zIndex: 99999999 }
|
|
4608
|
-
},
|
|
4609
|
-
/* @__PURE__ */ React2.default.createElement(
|
|
4610
|
-
_material.Alert,
|
|
4611
|
-
{
|
|
4612
|
-
severity,
|
|
4613
|
-
elevation: 2,
|
|
4614
|
-
action: /* @__PURE__ */ React2.default.createElement(
|
|
4615
|
-
_material.IconButton,
|
|
4616
|
-
{
|
|
4617
|
-
"aria-label": "close",
|
|
4618
|
-
color: "inherit",
|
|
4619
|
-
size: "small",
|
|
4620
|
-
onClick: onClose
|
|
4621
|
-
},
|
|
4622
|
-
/* @__PURE__ */ React2.default.createElement(_md.MdClose, { fontSize: "inherit" })
|
|
4623
|
-
)
|
|
4624
|
-
},
|
|
4625
|
-
message
|
|
4626
|
-
)
|
|
4627
|
-
));
|
|
4628
|
-
};
|
|
4629
|
-
|
|
4630
|
-
// src/contexts/AlertContext.tsx
|
|
4631
4902
|
var AlertContext = _react.createContext.call(void 0, {});
|
|
4632
4903
|
var AlertProvider = ({ children }) => {
|
|
4633
4904
|
const [severity, setSeverity] = _react.useState.call(void 0, "info");
|
|
@@ -4644,611 +4915,138 @@ var AlertProvider = ({ children }) => {
|
|
|
4644
4915
|
const onCloseToast = _react.useCallback.call(void 0, () => {
|
|
4645
4916
|
setIsVisible(false);
|
|
4646
4917
|
}, []);
|
|
4647
|
-
return /* @__PURE__ */
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4918
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, AlertContext.Provider, { value: { createAlert }, children: [
|
|
4919
|
+
children,
|
|
4920
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4921
|
+
Toast,
|
|
4922
|
+
{
|
|
4923
|
+
open: isVisible,
|
|
4924
|
+
onClose: onCloseToast,
|
|
4925
|
+
severity,
|
|
4926
|
+
message
|
|
4927
|
+
}
|
|
4928
|
+
)
|
|
4929
|
+
] });
|
|
4656
4930
|
};
|
|
4657
4931
|
|
|
4658
|
-
// src/
|
|
4659
|
-
var useAlert = () => {
|
|
4660
|
-
return _react.useContext.call(void 0, AlertContext);
|
|
4661
|
-
};
|
|
4932
|
+
// src/contexts/AuthContext.tsx
|
|
4662
4933
|
|
|
4663
|
-
// src/hooks/useLoading.ts
|
|
4664
4934
|
|
|
4665
|
-
function useLoading() {
|
|
4666
|
-
const [state, setState] = _react.useState.call(void 0, []);
|
|
4667
|
-
const isLoading = _react.useCallback.call(void 0, (prop) => state.includes(prop), [state]);
|
|
4668
|
-
const setLoading = _react.useCallback.call(void 0, (prop, remove) => {
|
|
4669
|
-
if (remove)
|
|
4670
|
-
setState((prevState) => prevState.filter((state2) => state2 !== prop));
|
|
4671
|
-
else setState((prevState) => [...prevState, prop]);
|
|
4672
|
-
}, []);
|
|
4673
|
-
return { isLoading, setLoading };
|
|
4674
|
-
}
|
|
4675
4935
|
|
|
4676
|
-
// src/contexts/FormHelperProvider.tsx
|
|
4677
4936
|
|
|
4678
4937
|
|
|
4679
|
-
var FormHelperContext = _react.createContext.call(void 0, {});
|
|
4680
|
-
var FormHelperProvider = ({ formatErrorMessage, api, children }) => {
|
|
4681
|
-
return /* @__PURE__ */ React2.default.createElement(FormHelperContext.Provider, { value: { formatErrorMessage, api } }, children);
|
|
4682
|
-
};
|
|
4683
4938
|
|
|
4684
|
-
// src/hooks/useFormHelper.ts
|
|
4685
|
-
function useFormHelper() {
|
|
4686
|
-
const alertProps = useAlert();
|
|
4687
|
-
const loadingProps = useLoading();
|
|
4688
|
-
const { api, formatErrorMessage } = _react.useContext.call(void 0, FormHelperContext);
|
|
4689
|
-
const { createAlert } = alertProps;
|
|
4690
|
-
const { setLoading } = loadingProps;
|
|
4691
|
-
const sourceRef = _react.useRef.call(void 0, new AbortController());
|
|
4692
|
-
const onSubmitWrapper = _react.useCallback.call(void 0,
|
|
4693
|
-
(fn, { name }) => {
|
|
4694
|
-
return async (fields, methods) => {
|
|
4695
|
-
const LOADING_NAME = name;
|
|
4696
|
-
setLoading(LOADING_NAME);
|
|
4697
|
-
try {
|
|
4698
|
-
await fn(fields, methods);
|
|
4699
|
-
} catch (error) {
|
|
4700
|
-
errorHandler(error, methods.setErrors);
|
|
4701
|
-
} finally {
|
|
4702
|
-
setLoading(LOADING_NAME, true);
|
|
4703
|
-
}
|
|
4704
|
-
};
|
|
4705
|
-
},
|
|
4706
|
-
[setLoading]
|
|
4707
|
-
);
|
|
4708
|
-
const onRequestWrapper = _react.useCallback.call(void 0,
|
|
4709
|
-
(fn, { name }) => {
|
|
4710
|
-
return async (...params) => {
|
|
4711
|
-
const LOADING_NAME = name;
|
|
4712
|
-
setLoading(LOADING_NAME);
|
|
4713
|
-
api.interceptors.request.use(
|
|
4714
|
-
(config) => {
|
|
4715
|
-
if (!config.signal && sourceRef.current && config.method === "get") {
|
|
4716
|
-
config.signal = sourceRef.current.signal;
|
|
4717
|
-
}
|
|
4718
|
-
return config;
|
|
4719
|
-
},
|
|
4720
|
-
(error) => {
|
|
4721
|
-
return Promise.reject(error);
|
|
4722
|
-
}
|
|
4723
|
-
);
|
|
4724
|
-
try {
|
|
4725
|
-
const response = await fn(...params);
|
|
4726
|
-
return response;
|
|
4727
|
-
} catch (error) {
|
|
4728
|
-
errorHandler(error);
|
|
4729
|
-
} finally {
|
|
4730
|
-
setLoading(LOADING_NAME, true);
|
|
4731
|
-
}
|
|
4732
|
-
};
|
|
4733
|
-
},
|
|
4734
|
-
[setLoading, api]
|
|
4735
|
-
);
|
|
4736
|
-
const errorHandler = _react.useCallback.call(void 0,
|
|
4737
|
-
(error, callback) => {
|
|
4738
|
-
if (_optionalChain([error, 'optionalAccess', _87 => _87.message]) === "cancel.navigation") return;
|
|
4739
|
-
if (callback) {
|
|
4740
|
-
if (error.response.data.code === "invalid.body") {
|
|
4741
|
-
const errors = error.response.data.details.issues;
|
|
4742
|
-
const currentErrors = errors.reduce((acc, item) => {
|
|
4743
|
-
acc[item.path.join(".")] = item.message;
|
|
4744
|
-
return acc;
|
|
4745
|
-
}, {});
|
|
4746
|
-
callback(currentErrors);
|
|
4747
|
-
}
|
|
4748
|
-
}
|
|
4749
|
-
createAlert(formatErrorMessage(error), "error");
|
|
4750
|
-
},
|
|
4751
|
-
[formatErrorMessage, createAlert]
|
|
4752
|
-
);
|
|
4753
|
-
_react.useEffect.call(void 0, () => {
|
|
4754
|
-
return () => {
|
|
4755
|
-
sourceRef.current.abort();
|
|
4756
|
-
sourceRef.current = new AbortController();
|
|
4757
|
-
};
|
|
4758
|
-
}, []);
|
|
4759
|
-
return {
|
|
4760
|
-
...alertProps,
|
|
4761
|
-
...loadingProps,
|
|
4762
|
-
onSubmitWrapper,
|
|
4763
|
-
onRequestWrapper
|
|
4764
|
-
};
|
|
4765
|
-
}
|
|
4766
4939
|
|
|
4767
|
-
// src/
|
|
4768
|
-
var _cookie = require('cookie'); var cookie = _interopRequireWildcard(_cookie);
|
|
4769
|
-
var _uuid = require('uuid');
|
|
4770
|
-
var _jsonwebtoken = require('jsonwebtoken'); var _jsonwebtoken2 = _interopRequireDefault(_jsonwebtoken);
|
|
4940
|
+
// src/hooks/useGrid.ts
|
|
4771
4941
|
|
|
4772
|
-
// packages/nookies/index.ts
|
|
4773
4942
|
|
|
4774
|
-
|
|
4943
|
+
// src/hooks/useFilter.ts
|
|
4775
4944
|
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
}
|
|
4785
|
-
if (sameSite === void 0 || sameSite === false) {
|
|
4786
|
-
sameSite = "lax";
|
|
4787
|
-
}
|
|
4788
|
-
const cookieToSet = { ...options, sameSite };
|
|
4789
|
-
delete cookieToSet.encode;
|
|
4790
|
-
return {
|
|
4791
|
-
name,
|
|
4792
|
-
value,
|
|
4793
|
-
...cookieToSet
|
|
4794
|
-
};
|
|
4795
|
-
}
|
|
4796
|
-
function hasSameProperties(a, b) {
|
|
4797
|
-
const aProps = Object.getOwnPropertyNames(a);
|
|
4798
|
-
const bProps = Object.getOwnPropertyNames(b);
|
|
4799
|
-
if (aProps.length !== bProps.length) {
|
|
4800
|
-
return false;
|
|
4801
|
-
}
|
|
4802
|
-
for (let i = 0; i < aProps.length; i++) {
|
|
4803
|
-
const propName = aProps[i];
|
|
4804
|
-
if (a[propName] !== b[propName]) {
|
|
4805
|
-
return false;
|
|
4945
|
+
|
|
4946
|
+
// src/components/utils/getObjectValue.ts
|
|
4947
|
+
function getObjectValue(obj) {
|
|
4948
|
+
return (prop) => {
|
|
4949
|
+
try {
|
|
4950
|
+
return prop.split(".").reduce((o, k) => o[k], obj);
|
|
4951
|
+
} catch (_) {
|
|
4952
|
+
return void 0;
|
|
4806
4953
|
}
|
|
4807
|
-
}
|
|
4808
|
-
return true;
|
|
4809
|
-
}
|
|
4810
|
-
function areCookiesEqual(a, b) {
|
|
4811
|
-
let sameSiteSame = a.sameSite === b.sameSite;
|
|
4812
|
-
if (typeof a.sameSite === "string" && typeof b.sameSite === "string") {
|
|
4813
|
-
sameSiteSame = a.sameSite.toLowerCase() === b.sameSite.toLowerCase();
|
|
4814
|
-
}
|
|
4815
|
-
return hasSameProperties(
|
|
4816
|
-
{ ...a, sameSite: void 0 },
|
|
4817
|
-
{ ...b, sameSite: void 0 }
|
|
4818
|
-
) && sameSiteSame;
|
|
4954
|
+
};
|
|
4819
4955
|
}
|
|
4820
4956
|
|
|
4821
|
-
//
|
|
4822
|
-
function
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
function setCookie(ctx, name, value, options = {}) {
|
|
4832
|
-
if (_optionalChain([ctx, 'optionalAccess', _91 => _91.res, 'optionalAccess', _92 => _92.getHeader]) && ctx.res.setHeader) {
|
|
4833
|
-
if (_optionalChain([ctx, 'optionalAccess', _93 => _93.res, 'optionalAccess', _94 => _94.finished])) {
|
|
4834
|
-
console.warn(`Not setting "${name}" cookie. Response has finished.`);
|
|
4835
|
-
console.warn(`You should set cookie before res.send()`);
|
|
4836
|
-
return {};
|
|
4837
|
-
}
|
|
4838
|
-
let cookies = ctx.res.getHeader("Set-Cookie") || [];
|
|
4839
|
-
if (typeof cookies === "string") cookies = [cookies];
|
|
4840
|
-
if (typeof cookies === "number") cookies = [];
|
|
4841
|
-
const parsedCookies = setCookieParser.parse(cookies, {
|
|
4842
|
-
decodeValues: false
|
|
4843
|
-
});
|
|
4844
|
-
const newCookie = createCookie(name, value, options);
|
|
4845
|
-
let cookiesToSet = [];
|
|
4846
|
-
parsedCookies.forEach((parsedCookie) => {
|
|
4847
|
-
if (!areCookiesEqual(parsedCookie, newCookie)) {
|
|
4848
|
-
const serializedCookie = cookie.serialize(
|
|
4849
|
-
parsedCookie.name,
|
|
4850
|
-
parsedCookie.value,
|
|
4851
|
-
{
|
|
4852
|
-
// we prevent reencoding by default, but you might override it
|
|
4853
|
-
encode: (val) => val,
|
|
4854
|
-
...parsedCookie
|
|
4855
|
-
}
|
|
4856
|
-
);
|
|
4857
|
-
cookiesToSet.push(serializedCookie);
|
|
4858
|
-
}
|
|
4859
|
-
});
|
|
4860
|
-
cookiesToSet.push(cookie.serialize(name, value, options));
|
|
4861
|
-
ctx.res.setHeader("Set-Cookie", cookiesToSet);
|
|
4862
|
-
}
|
|
4863
|
-
if (isBrowser()) {
|
|
4864
|
-
if (options && options.httpOnly) {
|
|
4865
|
-
throw new Error("Can not set a httpOnly cookie in the browser.");
|
|
4957
|
+
// src/hooks/useFilter.ts
|
|
4958
|
+
function useFilter(props = { defaultFilters: [] }) {
|
|
4959
|
+
const [selectedFilters, setSelectedFilters] = _react.useState.call(void 0, () => {
|
|
4960
|
+
const { defaultFilters } = props;
|
|
4961
|
+
return defaultFilters || [];
|
|
4962
|
+
});
|
|
4963
|
+
const filterBy = _react.useCallback.call(void 0, (newFilter) => {
|
|
4964
|
+
const propToCompare = _optionalChain([newFilter, 'optionalAccess', _92 => _92.id]) ? "id" : "prop";
|
|
4965
|
+
function removeRepeatedFilters(filter) {
|
|
4966
|
+
return filter[propToCompare] !== newFilter[propToCompare];
|
|
4866
4967
|
}
|
|
4867
|
-
|
|
4968
|
+
setSelectedFilters((filters) => [
|
|
4969
|
+
...filters.filter(removeRepeatedFilters),
|
|
4970
|
+
newFilter
|
|
4971
|
+
]);
|
|
4972
|
+
}, []);
|
|
4973
|
+
const removeFilter = _react.useCallback.call(void 0,
|
|
4974
|
+
(prop, isId) => {
|
|
4975
|
+
const propToCompare = isId ? "id" : "prop";
|
|
4976
|
+
setSelectedFilters(
|
|
4977
|
+
selectedFilters.filter((filter) => filter[propToCompare] !== prop)
|
|
4978
|
+
);
|
|
4979
|
+
},
|
|
4980
|
+
[selectedFilters]
|
|
4981
|
+
);
|
|
4982
|
+
function clearAllFilters() {
|
|
4983
|
+
setSelectedFilters([]);
|
|
4868
4984
|
}
|
|
4869
|
-
return {
|
|
4985
|
+
return {
|
|
4986
|
+
filters: selectedFilters,
|
|
4987
|
+
filterBy,
|
|
4988
|
+
removeFilter,
|
|
4989
|
+
createFilter,
|
|
4990
|
+
clearAllFilters
|
|
4991
|
+
};
|
|
4870
4992
|
}
|
|
4871
|
-
function
|
|
4872
|
-
|
|
4993
|
+
function isDate(date) {
|
|
4994
|
+
if (date instanceof Date) return true;
|
|
4995
|
+
else if (String(date).endsWith("Z")) return true;
|
|
4996
|
+
return false;
|
|
4873
4997
|
}
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
return
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
};
|
|
4898
|
-
try {
|
|
4899
|
-
const decoded = jwtDecode(token);
|
|
4900
|
-
req.user = decoded.sub;
|
|
4901
|
-
} catch (_) {
|
|
4902
|
-
res.status(401).json({ error: "Token inv\xE1lido", code: "token.expired" });
|
|
4903
|
-
return true;
|
|
4998
|
+
function compareFilter(item, filter) {
|
|
4999
|
+
const itemValue = getObjectValue(item)(filter.prop);
|
|
5000
|
+
switch (filter.compareType) {
|
|
5001
|
+
case "equal":
|
|
5002
|
+
return itemValue === filter.value;
|
|
5003
|
+
case "notEqual":
|
|
5004
|
+
return itemValue !== filter.value;
|
|
5005
|
+
case "in":
|
|
5006
|
+
return filter.value.includes(itemValue);
|
|
5007
|
+
case "notIn":
|
|
5008
|
+
return !filter.value.includes(itemValue);
|
|
5009
|
+
case "valueIn":
|
|
5010
|
+
return itemValue.includes(filter.value);
|
|
5011
|
+
case "valueNotIn":
|
|
5012
|
+
return !itemValue.includes(filter.value);
|
|
5013
|
+
case "gte":
|
|
5014
|
+
return isDate(itemValue) ? new Date(String(itemValue)) >= filter.value : itemValue >= filter.value;
|
|
5015
|
+
case "gt":
|
|
5016
|
+
return isDate(itemValue) ? new Date(String(itemValue)) > filter.value : itemValue > filter.value;
|
|
5017
|
+
case "lte":
|
|
5018
|
+
return isDate(itemValue) ? new Date(String(itemValue)) <= filter.value : itemValue <= filter.value;
|
|
5019
|
+
case "lt":
|
|
5020
|
+
return isDate(itemValue) ? new Date(String(itemValue)) < filter.value : itemValue < filter.value;
|
|
4904
5021
|
}
|
|
4905
5022
|
}
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
onInvalidateRefreshToken,
|
|
4914
|
-
onCreateRefreshToken,
|
|
4915
|
-
onGetUserData
|
|
4916
|
-
}) {
|
|
4917
|
-
this.generateJwtAndRefreshToken = async (userId, payload = {}) => {
|
|
4918
|
-
const token = _jsonwebtoken2.default.sign(payload, process.env.JWT_SECRET, {
|
|
4919
|
-
subject: String(userId),
|
|
4920
|
-
expiresIn: this.tokenExpTimeInSeconds || 60 * 15
|
|
4921
|
-
// 15 minutos
|
|
4922
|
-
});
|
|
4923
|
-
const uniqueToken = _uuid.v4.call(void 0, );
|
|
4924
|
-
await this.onCreateRefreshToken(userId, uniqueToken);
|
|
4925
|
-
return {
|
|
4926
|
-
token,
|
|
4927
|
-
refreshToken: uniqueToken
|
|
4928
|
-
};
|
|
4929
|
-
};
|
|
4930
|
-
this.invalidateCookies = (res) => {
|
|
4931
|
-
return res.setHeader("Set-Cookie", [
|
|
4932
|
-
_cookie.serialize.call(void 0, this.cookies.sessionToken, "", {
|
|
4933
|
-
maxAge: -1,
|
|
4934
|
-
path: "/"
|
|
4935
|
-
}),
|
|
4936
|
-
_cookie.serialize.call(void 0, this.cookies.refreshToken, "", {
|
|
4937
|
-
maxAge: -1,
|
|
4938
|
-
path: "/"
|
|
4939
|
-
})
|
|
4940
|
-
]);
|
|
4941
|
-
};
|
|
4942
|
-
this.cookies = cookies;
|
|
4943
|
-
this.oauth = oauth;
|
|
4944
|
-
this.tokenExpTimeInSeconds = tokenExpTimeInSeconds;
|
|
4945
|
-
this.onLogin = onLogin;
|
|
4946
|
-
this.onValidateRefreshToken = onValidateRefreshToken;
|
|
4947
|
-
this.onInvalidateRefreshToken = onInvalidateRefreshToken;
|
|
4948
|
-
this.onCreateRefreshToken = onCreateRefreshToken;
|
|
4949
|
-
this.onGetUserData = onGetUserData;
|
|
5023
|
+
function createFilter(filters) {
|
|
5024
|
+
function apply(item) {
|
|
5025
|
+
const satisfiedFilters = filters.reduce((acc, filter) => {
|
|
5026
|
+
if (compareFilter(item, filter)) acc += 1;
|
|
5027
|
+
return acc;
|
|
5028
|
+
}, 0);
|
|
5029
|
+
return satisfiedFilters === filters.length;
|
|
4950
5030
|
}
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
sameSite: true
|
|
4966
|
-
});
|
|
4967
|
-
setCookie({ res }, this.cookies.refreshToken, refreshToken, {
|
|
4968
|
-
secure: true,
|
|
4969
|
-
maxAge: 60 * 60 * 24 * 30,
|
|
4970
|
-
// 30 days
|
|
4971
|
-
path: "/",
|
|
4972
|
-
sameSite: true,
|
|
4973
|
-
httpOnly: true
|
|
4974
|
-
});
|
|
4975
|
-
return res.json({ token, refreshToken });
|
|
5031
|
+
return {
|
|
5032
|
+
apply
|
|
5033
|
+
};
|
|
5034
|
+
}
|
|
5035
|
+
|
|
5036
|
+
// src/helpers/sortHelper.ts
|
|
5037
|
+
function SortHelper(...fields) {
|
|
5038
|
+
return (a, b) => {
|
|
5039
|
+
for (const field of fields) {
|
|
5040
|
+
let direction = 1;
|
|
5041
|
+
let key = field;
|
|
5042
|
+
if (field.startsWith("-")) {
|
|
5043
|
+
direction = -1;
|
|
5044
|
+
key = field.slice(1);
|
|
4976
5045
|
}
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
}
|
|
4982
|
-
if (req.url.endsWith("/refresh")) {
|
|
4983
|
-
const error = decodeSessionToken({
|
|
4984
|
-
req,
|
|
4985
|
-
res,
|
|
4986
|
-
sessionTokenName: this.cookies.sessionToken,
|
|
4987
|
-
validate: false
|
|
4988
|
-
});
|
|
4989
|
-
if (error) return;
|
|
4990
|
-
const userId = String(req.user);
|
|
4991
|
-
const refreshToken = parseCookies({ req })[this.cookies.refreshToken];
|
|
4992
|
-
if (!refreshToken) {
|
|
4993
|
-
this.invalidateCookies(res);
|
|
4994
|
-
return res.status(400).json({
|
|
4995
|
-
error: "Refresh Token inv\xE1lido"
|
|
4996
|
-
});
|
|
4997
|
-
}
|
|
4998
|
-
const isValidRefreshToken = await this.onValidateRefreshToken(
|
|
4999
|
-
userId,
|
|
5000
|
-
refreshToken
|
|
5001
|
-
);
|
|
5002
|
-
if (!isValidRefreshToken) {
|
|
5003
|
-
this.invalidateCookies(res);
|
|
5004
|
-
return res.status(400).json({
|
|
5005
|
-
error: "Refresh Token inv\xE1lido"
|
|
5006
|
-
});
|
|
5007
|
-
}
|
|
5008
|
-
await this.onInvalidateRefreshToken(userId, refreshToken);
|
|
5009
|
-
const { token, refreshToken: newRefreshToken } = await this.generateJwtAndRefreshToken(userId, {});
|
|
5010
|
-
setCookie({ res }, this.cookies.sessionToken, token, {
|
|
5011
|
-
secure: true,
|
|
5012
|
-
maxAge: 60 * 60 * 24 * 30,
|
|
5013
|
-
// 30 days
|
|
5014
|
-
path: "/",
|
|
5015
|
-
sameSite: true
|
|
5016
|
-
});
|
|
5017
|
-
setCookie({ res }, this.cookies.refreshToken, newRefreshToken, {
|
|
5018
|
-
secure: true,
|
|
5019
|
-
maxAge: 60 * 60 * 24 * 30,
|
|
5020
|
-
// 30 days
|
|
5021
|
-
path: "/",
|
|
5022
|
-
sameSite: true,
|
|
5023
|
-
httpOnly: true
|
|
5024
|
-
});
|
|
5025
|
-
return res.json({
|
|
5026
|
-
token,
|
|
5027
|
-
refreshToken: newRefreshToken
|
|
5028
|
-
});
|
|
5029
|
-
}
|
|
5030
|
-
if (req.url.endsWith("/me")) {
|
|
5031
|
-
const error = decodeSessionToken({
|
|
5032
|
-
req,
|
|
5033
|
-
res,
|
|
5034
|
-
sessionTokenName: this.cookies.sessionToken,
|
|
5035
|
-
validate: true
|
|
5036
|
-
});
|
|
5037
|
-
if (error) return;
|
|
5038
|
-
if (!req.user)
|
|
5039
|
-
return res.status(400).json({ error: "Usu\xE1rio n\xE3o encontrado" });
|
|
5040
|
-
const userData = await this.onGetUserData(req.user);
|
|
5041
|
-
if (!userData)
|
|
5042
|
-
return res.status(400).json({ error: "Usu\xE1rio n\xE3o encontrado" });
|
|
5043
|
-
return res.json(userData);
|
|
5044
|
-
}
|
|
5045
|
-
if (req.url.endsWith("/oauth-url") && this.oauth) {
|
|
5046
|
-
const params = {
|
|
5047
|
-
client_id: this.oauth.client_id,
|
|
5048
|
-
redirect_uri: this.oauth.redirect_uri,
|
|
5049
|
-
scope: this.oauth.scope,
|
|
5050
|
-
response_type: "code",
|
|
5051
|
-
response_mode: "query"
|
|
5052
|
-
};
|
|
5053
|
-
const url = `https://login.microsoftonline.com/${this.oauth.tenant_id}/oauth2/v2.0/authorize?${new URLSearchParams(params)}`;
|
|
5054
|
-
return res.json({
|
|
5055
|
-
url
|
|
5056
|
-
});
|
|
5057
|
-
}
|
|
5058
|
-
return res.status(404).json({ error: "Route not found" });
|
|
5059
|
-
}
|
|
5060
|
-
async oauthSignInCallback(code) {
|
|
5061
|
-
if (!this.oauth) throw new Error("OAUTH variables is not defined");
|
|
5062
|
-
const body = {
|
|
5063
|
-
client_id: this.oauth.client_id,
|
|
5064
|
-
scope: this.oauth.scope,
|
|
5065
|
-
code,
|
|
5066
|
-
session_state: this.oauth.client_id,
|
|
5067
|
-
redirect_uri: this.oauth.redirect_uri,
|
|
5068
|
-
grant_type: "authorization_code",
|
|
5069
|
-
client_secret: this.oauth.client_secret
|
|
5070
|
-
};
|
|
5071
|
-
const response = await fetch(
|
|
5072
|
-
`https://login.microsoftonline.com/${this.oauth.tenant_id}/oauth2/v2.0/token`,
|
|
5073
|
-
{
|
|
5074
|
-
method: "POST",
|
|
5075
|
-
body: new URLSearchParams(body),
|
|
5076
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
5077
|
-
}
|
|
5078
|
-
);
|
|
5079
|
-
const data = await response.json();
|
|
5080
|
-
const decodedToken = _jsonwebtoken2.default.decode(data.access_token);
|
|
5081
|
-
const email = decodedToken.upn;
|
|
5082
|
-
const fullName = `${_optionalChain([decodedToken, 'optionalAccess', _100 => _100.given_name])} ${_optionalChain([decodedToken, 'optionalAccess', _101 => _101.family_name])}`;
|
|
5083
|
-
return { decodedToken, email, fullName };
|
|
5084
|
-
}
|
|
5085
|
-
createOauthCallbackGetServerSideProps({
|
|
5086
|
-
onSuccessDestination,
|
|
5087
|
-
onFailedDestination
|
|
5088
|
-
}) {
|
|
5089
|
-
return async (ctx) => {
|
|
5090
|
-
if (!this.oauth) throw new Error("Oauth env variables are not defined");
|
|
5091
|
-
const code = ctx.query.code;
|
|
5092
|
-
if (!code)
|
|
5093
|
-
return {
|
|
5094
|
-
redirect: {
|
|
5095
|
-
permanent: false,
|
|
5096
|
-
destination: onFailedDestination || "/"
|
|
5097
|
-
}
|
|
5098
|
-
};
|
|
5099
|
-
try {
|
|
5100
|
-
const { fullName, email } = await this.oauthSignInCallback(code);
|
|
5101
|
-
const userExists = await this.onGetUserData(email);
|
|
5102
|
-
if (!userExists && !this.oauth.onCreateUser)
|
|
5103
|
-
throw new Error("User does not exists");
|
|
5104
|
-
if (!userExists && this.oauth.onCreateUser) {
|
|
5105
|
-
await this.oauth.onCreateUser({ fullname: fullName, email });
|
|
5106
|
-
}
|
|
5107
|
-
const { token, refreshToken } = await this.generateJwtAndRefreshToken(
|
|
5108
|
-
email,
|
|
5109
|
-
{}
|
|
5110
|
-
);
|
|
5111
|
-
setCookie(ctx, this.cookies.sessionToken, token, {
|
|
5112
|
-
secure: true,
|
|
5113
|
-
maxAge: 60 * 60 * 24 * 30,
|
|
5114
|
-
// 30 days
|
|
5115
|
-
path: "/"
|
|
5116
|
-
});
|
|
5117
|
-
setCookie(ctx, this.cookies.refreshToken, refreshToken, {
|
|
5118
|
-
secure: true,
|
|
5119
|
-
maxAge: 60 * 60 * 24 * 30,
|
|
5120
|
-
// 30 days
|
|
5121
|
-
path: "/",
|
|
5122
|
-
httpOnly: true
|
|
5123
|
-
});
|
|
5124
|
-
return {
|
|
5125
|
-
redirect: {
|
|
5126
|
-
destination: onSuccessDestination,
|
|
5127
|
-
permanent: false
|
|
5128
|
-
}
|
|
5129
|
-
};
|
|
5130
|
-
} catch (error) {
|
|
5131
|
-
return {
|
|
5132
|
-
props: {
|
|
5133
|
-
error: JSON.stringify(error)
|
|
5134
|
-
}
|
|
5135
|
-
};
|
|
5136
|
-
}
|
|
5137
|
-
};
|
|
5138
|
-
}
|
|
5139
|
-
};
|
|
5140
|
-
|
|
5141
|
-
// src/hooks/useGrid.ts
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
// src/hooks/useFilter.ts
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
// src/components/utils/getObjectValue.ts
|
|
5149
|
-
function getObjectValue(obj) {
|
|
5150
|
-
return (prop) => {
|
|
5151
|
-
try {
|
|
5152
|
-
return prop.split(".").reduce((o, k) => o[k], obj);
|
|
5153
|
-
} catch (_) {
|
|
5154
|
-
return void 0;
|
|
5155
|
-
}
|
|
5156
|
-
};
|
|
5157
|
-
}
|
|
5158
|
-
|
|
5159
|
-
// src/hooks/useFilter.ts
|
|
5160
|
-
function useFilter(props = { defaultFilters: [] }) {
|
|
5161
|
-
const [selectedFilters, setSelectedFilters] = _react.useState.call(void 0, () => {
|
|
5162
|
-
const { defaultFilters } = props;
|
|
5163
|
-
return defaultFilters || [];
|
|
5164
|
-
});
|
|
5165
|
-
const filterBy = _react.useCallback.call(void 0, (newFilter) => {
|
|
5166
|
-
const propToCompare = _optionalChain([newFilter, 'optionalAccess', _102 => _102.id]) ? "id" : "prop";
|
|
5167
|
-
function removeRepeatedFilters(filter) {
|
|
5168
|
-
return filter[propToCompare] !== newFilter[propToCompare];
|
|
5169
|
-
}
|
|
5170
|
-
setSelectedFilters((filters) => [
|
|
5171
|
-
...filters.filter(removeRepeatedFilters),
|
|
5172
|
-
newFilter
|
|
5173
|
-
]);
|
|
5174
|
-
}, []);
|
|
5175
|
-
const removeFilter = _react.useCallback.call(void 0,
|
|
5176
|
-
(prop, isId) => {
|
|
5177
|
-
const propToCompare = isId ? "id" : "prop";
|
|
5178
|
-
setSelectedFilters(
|
|
5179
|
-
selectedFilters.filter((filter) => filter[propToCompare] !== prop)
|
|
5180
|
-
);
|
|
5181
|
-
},
|
|
5182
|
-
[selectedFilters]
|
|
5183
|
-
);
|
|
5184
|
-
function clearAllFilters() {
|
|
5185
|
-
setSelectedFilters([]);
|
|
5186
|
-
}
|
|
5187
|
-
return {
|
|
5188
|
-
filters: selectedFilters,
|
|
5189
|
-
filterBy,
|
|
5190
|
-
removeFilter,
|
|
5191
|
-
createFilter,
|
|
5192
|
-
clearAllFilters
|
|
5193
|
-
};
|
|
5194
|
-
}
|
|
5195
|
-
function isDate(date) {
|
|
5196
|
-
if (date instanceof Date) return true;
|
|
5197
|
-
else if (String(date).endsWith("Z")) return true;
|
|
5198
|
-
return false;
|
|
5199
|
-
}
|
|
5200
|
-
function compareFilter(item, filter) {
|
|
5201
|
-
const itemValue = getObjectValue(item)(filter.prop);
|
|
5202
|
-
switch (filter.compareType) {
|
|
5203
|
-
case "equal":
|
|
5204
|
-
return itemValue === filter.value;
|
|
5205
|
-
case "notEqual":
|
|
5206
|
-
return itemValue !== filter.value;
|
|
5207
|
-
case "in":
|
|
5208
|
-
return filter.value.includes(itemValue);
|
|
5209
|
-
case "notIn":
|
|
5210
|
-
return !filter.value.includes(itemValue);
|
|
5211
|
-
case "valueIn":
|
|
5212
|
-
return itemValue.includes(filter.value);
|
|
5213
|
-
case "valueNotIn":
|
|
5214
|
-
return !itemValue.includes(filter.value);
|
|
5215
|
-
case "gte":
|
|
5216
|
-
return isDate(itemValue) ? _moment2.default.call(void 0, String(itemValue)).isSameOrAfter(filter.value) : itemValue >= filter.value;
|
|
5217
|
-
case "gt":
|
|
5218
|
-
return isDate(itemValue) ? _moment2.default.call(void 0, String(itemValue)).isAfter(filter.value) : itemValue > filter.value;
|
|
5219
|
-
case "lte":
|
|
5220
|
-
return isDate(itemValue) ? _moment2.default.call(void 0, String(itemValue)).isSameOrBefore(filter.value) : itemValue <= filter.value;
|
|
5221
|
-
case "lt":
|
|
5222
|
-
return isDate(itemValue) ? _moment2.default.call(void 0, String(itemValue)).isBefore(filter.value) : itemValue < filter.value;
|
|
5223
|
-
}
|
|
5224
|
-
}
|
|
5225
|
-
function createFilter(filters) {
|
|
5226
|
-
function apply(item) {
|
|
5227
|
-
const satisfiedFilters = filters.reduce((acc, filter) => {
|
|
5228
|
-
if (compareFilter(item, filter)) acc += 1;
|
|
5229
|
-
return acc;
|
|
5230
|
-
}, 0);
|
|
5231
|
-
return satisfiedFilters === filters.length;
|
|
5232
|
-
}
|
|
5233
|
-
return {
|
|
5234
|
-
apply
|
|
5235
|
-
};
|
|
5236
|
-
}
|
|
5237
|
-
|
|
5238
|
-
// src/helpers/sortHelper.ts
|
|
5239
|
-
function SortHelper(...fields) {
|
|
5240
|
-
return (a, b) => {
|
|
5241
|
-
for (const field of fields) {
|
|
5242
|
-
let direction = 1;
|
|
5243
|
-
let key = field;
|
|
5244
|
-
if (field.startsWith("-")) {
|
|
5245
|
-
direction = -1;
|
|
5246
|
-
key = field.slice(1);
|
|
5247
|
-
}
|
|
5248
|
-
const aVal = a[key];
|
|
5249
|
-
const bVal = b[key];
|
|
5250
|
-
if (aVal > bVal) return direction;
|
|
5251
|
-
if (aVal < bVal) return -direction;
|
|
5046
|
+
const aVal = a[key];
|
|
5047
|
+
const bVal = b[key];
|
|
5048
|
+
if (aVal > bVal) return direction;
|
|
5049
|
+
if (aVal < bVal) return -direction;
|
|
5252
5050
|
}
|
|
5253
5051
|
return 0;
|
|
5254
5052
|
};
|
|
@@ -5447,28 +5245,23 @@ function useAsyncGrid({
|
|
|
5447
5245
|
search,
|
|
5448
5246
|
rowsPerPageOptions = [30, 60, 100],
|
|
5449
5247
|
onRequest,
|
|
5450
|
-
|
|
5248
|
+
httpClient,
|
|
5451
5249
|
url,
|
|
5452
5250
|
defaultData: externalDefaultData,
|
|
5453
5251
|
defaultCurrentPage,
|
|
5454
5252
|
defaultSortedBy
|
|
5455
5253
|
}) {
|
|
5456
5254
|
const [defaultData, setDefaultData] = _react.useState.call(void 0, externalDefaultData || []);
|
|
5457
|
-
const [sortedBy, setSortedBy] = _react.useState.call(void 0,
|
|
5458
|
-
defaultSortedBy || []
|
|
5459
|
-
);
|
|
5255
|
+
const [sortedBy, setSortedBy] = _react.useState.call(void 0, defaultSortedBy || []);
|
|
5460
5256
|
const [totalNumberOfItems, setTotalNumberOfItems] = _react.useState.call(void 0, 0);
|
|
5461
5257
|
const [isLoading, setIsLoading] = _react.useState.call(void 0, false);
|
|
5462
5258
|
const [currentPage, setCurrentPage] = _react.useState.call(void 0, defaultCurrentPage || 0);
|
|
5463
5259
|
const [rowsPerPage, setRowsPerPage] = _react.useState.call(void 0, rowsPerPageOptions[0]);
|
|
5464
5260
|
const totalNumberOfPages = Math.ceil(totalNumberOfItems / rowsPerPage) - 1;
|
|
5465
|
-
const toggleSortedDirection = _react.useCallback.call(void 0,
|
|
5466
|
-
(direction)
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
},
|
|
5470
|
-
[]
|
|
5471
|
-
);
|
|
5261
|
+
const toggleSortedDirection = _react.useCallback.call(void 0, (direction) => {
|
|
5262
|
+
if (direction === "asc") return "desc";
|
|
5263
|
+
return "asc";
|
|
5264
|
+
}, []);
|
|
5472
5265
|
const setSort = _react.useCallback.call(void 0, (prop, direction) => {
|
|
5473
5266
|
setSortedBy((prev) => [...prev, { prop, direction }]);
|
|
5474
5267
|
}, []);
|
|
@@ -5504,33 +5297,27 @@ function useAsyncGrid({
|
|
|
5504
5297
|
setDefaultData(data);
|
|
5505
5298
|
}, []);
|
|
5506
5299
|
const baseRequest = _react.useCallback.call(void 0,
|
|
5507
|
-
async ({
|
|
5508
|
-
|
|
5509
|
-
search: search2,
|
|
5510
|
-
filters: filters2,
|
|
5511
|
-
sortedBy: sortedBy2,
|
|
5512
|
-
rowsPerPage: rowsPerPage2
|
|
5513
|
-
}) => {
|
|
5514
|
-
if (!axiosInstance) throw new Error("Axios instance not provided");
|
|
5300
|
+
async ({ page, search: search2, filters: filters2, sortedBy: sortedBy2, rowsPerPage: rowsPerPage2 }) => {
|
|
5301
|
+
if (!httpClient) throw new Error("HttpClient instance not provided");
|
|
5515
5302
|
try {
|
|
5516
5303
|
const params = new URLSearchParams({
|
|
5517
5304
|
page: String(page),
|
|
5518
5305
|
rowsPerPage: String(rowsPerPage2),
|
|
5519
|
-
searchText: _optionalChain([search2, 'optionalAccess',
|
|
5306
|
+
searchText: _optionalChain([search2, 'optionalAccess', _93 => _93.value]) || "",
|
|
5520
5307
|
sort: sortedBy2.map(({ prop, direction }) => `${prop}:${direction}`).join(","),
|
|
5521
|
-
filters: filters2.map(
|
|
5522
|
-
(filter) => `${filter.prop}:${filter.compareType}:${filter.value}`
|
|
5523
|
-
).join(",")
|
|
5308
|
+
filters: filters2.map((filter) => `${filter.prop}:${filter.compareType}:${filter.value}`).join(",")
|
|
5524
5309
|
});
|
|
5525
5310
|
const pathWithParams = `${url}?${params.toString()}`;
|
|
5526
|
-
const { data } = await
|
|
5311
|
+
const { data } = await httpClient.get(
|
|
5312
|
+
pathWithParams
|
|
5313
|
+
);
|
|
5527
5314
|
setTotalNumberOfItems(data.totalNumberOfItems);
|
|
5528
5315
|
return data.rows;
|
|
5529
5316
|
} catch (_) {
|
|
5530
5317
|
return [];
|
|
5531
5318
|
}
|
|
5532
5319
|
},
|
|
5533
|
-
[
|
|
5320
|
+
[httpClient, url]
|
|
5534
5321
|
);
|
|
5535
5322
|
const updateGridContent = _react.useCallback.call(void 0,
|
|
5536
5323
|
async ({
|
|
@@ -5618,12 +5405,97 @@ function useEvent(event, handler, passive = false) {
|
|
|
5618
5405
|
});
|
|
5619
5406
|
}
|
|
5620
5407
|
|
|
5621
|
-
// src/
|
|
5622
|
-
|
|
5623
|
-
|
|
5408
|
+
// src/hooks/useLoading.ts
|
|
5624
5409
|
|
|
5410
|
+
function useLoading() {
|
|
5411
|
+
const [state, setState] = _react.useState.call(void 0, []);
|
|
5412
|
+
const isLoading = _react.useCallback.call(void 0, (prop) => state.includes(prop), [state]);
|
|
5413
|
+
const setLoading = _react.useCallback.call(void 0, (prop, remove) => {
|
|
5414
|
+
if (remove)
|
|
5415
|
+
setState((prevState) => prevState.filter((state2) => state2 !== prop));
|
|
5416
|
+
else setState((prevState) => [...prevState, prop]);
|
|
5417
|
+
}, []);
|
|
5418
|
+
return { isLoading, setLoading };
|
|
5419
|
+
}
|
|
5625
5420
|
|
|
5421
|
+
// src/hooks/useAlert.ts
|
|
5626
5422
|
|
|
5423
|
+
var useAlert = () => {
|
|
5424
|
+
return _react.useContext.call(void 0, AlertContext);
|
|
5425
|
+
};
|
|
5426
|
+
|
|
5427
|
+
// src/hooks/useFormHelper.ts
|
|
5428
|
+
|
|
5429
|
+
function useFormHelper() {
|
|
5430
|
+
const alertProps = useAlert();
|
|
5431
|
+
const loadingProps = useLoading();
|
|
5432
|
+
const { api, formatErrorMessage } = _react.useContext.call(void 0, FormHelperContext);
|
|
5433
|
+
const { createAlert } = alertProps;
|
|
5434
|
+
const { setLoading } = loadingProps;
|
|
5435
|
+
const onSubmitWrapper = _react.useCallback.call(void 0,
|
|
5436
|
+
(fn, { name }) => {
|
|
5437
|
+
return async (fields, methods) => {
|
|
5438
|
+
const LOADING_NAME = name;
|
|
5439
|
+
setLoading(LOADING_NAME);
|
|
5440
|
+
try {
|
|
5441
|
+
await fn(fields, methods);
|
|
5442
|
+
} catch (error) {
|
|
5443
|
+
errorHandler(error, methods.setErrors);
|
|
5444
|
+
} finally {
|
|
5445
|
+
setLoading(LOADING_NAME, true);
|
|
5446
|
+
}
|
|
5447
|
+
};
|
|
5448
|
+
},
|
|
5449
|
+
[setLoading]
|
|
5450
|
+
);
|
|
5451
|
+
const onRequestWrapper = _react.useCallback.call(void 0,
|
|
5452
|
+
(fn, { name }) => {
|
|
5453
|
+
return async (...params) => {
|
|
5454
|
+
const LOADING_NAME = name;
|
|
5455
|
+
setLoading(LOADING_NAME);
|
|
5456
|
+
try {
|
|
5457
|
+
const response = await fn(...params);
|
|
5458
|
+
return response;
|
|
5459
|
+
} catch (error) {
|
|
5460
|
+
errorHandler(error);
|
|
5461
|
+
} finally {
|
|
5462
|
+
setLoading(LOADING_NAME, true);
|
|
5463
|
+
}
|
|
5464
|
+
};
|
|
5465
|
+
},
|
|
5466
|
+
[setLoading]
|
|
5467
|
+
);
|
|
5468
|
+
const errorHandler = _react.useCallback.call(void 0,
|
|
5469
|
+
(error, callback) => {
|
|
5470
|
+
if (_optionalChain([error, 'optionalAccess', _94 => _94.message]) === "cancel.navigation") return;
|
|
5471
|
+
if (callback) {
|
|
5472
|
+
if (error.response.data.code === "invalid.body") {
|
|
5473
|
+
const errors = error.response.data.details.issues;
|
|
5474
|
+
const currentErrors = errors.reduce((acc, item) => {
|
|
5475
|
+
acc[item.path.join(".")] = item.message;
|
|
5476
|
+
return acc;
|
|
5477
|
+
}, {});
|
|
5478
|
+
callback(currentErrors);
|
|
5479
|
+
}
|
|
5480
|
+
}
|
|
5481
|
+
createAlert(formatErrorMessage(error), "error");
|
|
5482
|
+
},
|
|
5483
|
+
[formatErrorMessage, createAlert]
|
|
5484
|
+
);
|
|
5485
|
+
_react.useEffect.call(void 0, () => {
|
|
5486
|
+
return () => {
|
|
5487
|
+
api.abort();
|
|
5488
|
+
};
|
|
5489
|
+
}, [api]);
|
|
5490
|
+
return {
|
|
5491
|
+
...alertProps,
|
|
5492
|
+
...loadingProps,
|
|
5493
|
+
onSubmitWrapper,
|
|
5494
|
+
onRequestWrapper
|
|
5495
|
+
};
|
|
5496
|
+
}
|
|
5497
|
+
|
|
5498
|
+
// src/contexts/AuthContext.tsx
|
|
5627
5499
|
|
|
5628
5500
|
function createAuthContext() {
|
|
5629
5501
|
return _react.createContext.call(void 0, {});
|
|
@@ -5646,13 +5518,13 @@ function CreateAuthProvider({
|
|
|
5646
5518
|
password
|
|
5647
5519
|
});
|
|
5648
5520
|
const { token } = response.data;
|
|
5649
|
-
api.
|
|
5521
|
+
api.setHeader("Authorization", `Bearer ${token}`);
|
|
5650
5522
|
const { data } = await api.get("/auth/me");
|
|
5651
5523
|
setUser(data);
|
|
5652
5524
|
setStatus("autenticated");
|
|
5653
5525
|
return true;
|
|
5654
5526
|
} catch (error) {
|
|
5655
|
-
createAlert(_optionalChain([error, 'optionalAccess',
|
|
5527
|
+
createAlert(_optionalChain([error, 'optionalAccess', _95 => _95.response, 'optionalAccess', _96 => _96.data, 'optionalAccess', _97 => _97.error]), "error");
|
|
5656
5528
|
setStatus("unauthenticated");
|
|
5657
5529
|
throw error;
|
|
5658
5530
|
}
|
|
@@ -5675,7 +5547,7 @@ function CreateAuthProvider({
|
|
|
5675
5547
|
});
|
|
5676
5548
|
}
|
|
5677
5549
|
}, [api, sessionTokenName]);
|
|
5678
|
-
return /* @__PURE__ */
|
|
5550
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5679
5551
|
Provider,
|
|
5680
5552
|
{
|
|
5681
5553
|
value: {
|
|
@@ -5683,12 +5555,375 @@ function CreateAuthProvider({
|
|
|
5683
5555
|
signOut: ClientSignOut,
|
|
5684
5556
|
signIn,
|
|
5685
5557
|
status
|
|
5686
|
-
}
|
|
5687
|
-
|
|
5688
|
-
|
|
5558
|
+
},
|
|
5559
|
+
children
|
|
5560
|
+
}
|
|
5689
5561
|
);
|
|
5690
5562
|
}
|
|
5691
5563
|
|
|
5564
|
+
// src/errors/HttpError.ts
|
|
5565
|
+
var HttpError = class extends Error {
|
|
5566
|
+
constructor(status, message) {
|
|
5567
|
+
super(message);
|
|
5568
|
+
this.message = message;
|
|
5569
|
+
this.stack = `HttpError: ${message}`;
|
|
5570
|
+
this.status = status;
|
|
5571
|
+
}
|
|
5572
|
+
};
|
|
5573
|
+
|
|
5574
|
+
// src/errors/DomainError.ts
|
|
5575
|
+
var DomainError = class extends Error {
|
|
5576
|
+
constructor(message) {
|
|
5577
|
+
super(message);
|
|
5578
|
+
this.message = message;
|
|
5579
|
+
this.stack = `DomainError: ${message}`;
|
|
5580
|
+
}
|
|
5581
|
+
};
|
|
5582
|
+
|
|
5583
|
+
// src/helpers/apiHelper/index.ts
|
|
5584
|
+
var VALID_METHODS = [
|
|
5585
|
+
"GET",
|
|
5586
|
+
"HEAD",
|
|
5587
|
+
"POST",
|
|
5588
|
+
"PUT",
|
|
5589
|
+
"DELETE",
|
|
5590
|
+
"CONNECT",
|
|
5591
|
+
"OPTIONS",
|
|
5592
|
+
"TRACE",
|
|
5593
|
+
"PATCH"
|
|
5594
|
+
];
|
|
5595
|
+
var _ApiHelper = class _ApiHelper {
|
|
5596
|
+
async onFinally(_req, _res) {
|
|
5597
|
+
}
|
|
5598
|
+
async onError(_req, _res, _error) {
|
|
5599
|
+
}
|
|
5600
|
+
constructor(props) {
|
|
5601
|
+
this.public = _nullishCoalesce(_optionalChain([props, 'optionalAccess', _98 => _98.public]), () => ( false));
|
|
5602
|
+
this.middlewares = (_optionalChain([props, 'optionalAccess', _99 => _99.middlewares]) || []).reverse();
|
|
5603
|
+
this.onFinally = _optionalChain([props, 'optionalAccess', _100 => _100.onFinally]) || (async () => {
|
|
5604
|
+
});
|
|
5605
|
+
this.onError = _optionalChain([props, 'optionalAccess', _101 => _101.onError]) || (async () => {
|
|
5606
|
+
});
|
|
5607
|
+
}
|
|
5608
|
+
createMethods(methods) {
|
|
5609
|
+
return async (req, res) => {
|
|
5610
|
+
const currentMethod = methods[req.method] || methods.ALL;
|
|
5611
|
+
const options = { public: this.public };
|
|
5612
|
+
if (req.method === "OPTIONS") return res.status(200).end();
|
|
5613
|
+
try {
|
|
5614
|
+
if (!VALID_METHODS.includes(req.method))
|
|
5615
|
+
throw new HttpError(405, "M\xE9todo inv\xE1lido");
|
|
5616
|
+
if (!currentMethod) throw new HttpError(500, "M\xE9todo n\xE3o encontrado");
|
|
5617
|
+
const methodWithMiddlewares = this.middlewares.reduce(
|
|
5618
|
+
(acc, fn) => fn(acc, options),
|
|
5619
|
+
currentMethod
|
|
5620
|
+
);
|
|
5621
|
+
return await methodWithMiddlewares(req, res, options);
|
|
5622
|
+
} catch (error) {
|
|
5623
|
+
if (error instanceof DomainError) return res.status(400).json(error.message);
|
|
5624
|
+
if (error instanceof HttpError) return res.status(error.status).json(error.message);
|
|
5625
|
+
this.onError(req, res, error);
|
|
5626
|
+
throw error;
|
|
5627
|
+
} finally {
|
|
5628
|
+
await this.onFinally(req, res);
|
|
5629
|
+
}
|
|
5630
|
+
};
|
|
5631
|
+
}
|
|
5632
|
+
buildFactory(factory) {
|
|
5633
|
+
const options = { public: this.public };
|
|
5634
|
+
return async (req, res) => {
|
|
5635
|
+
const methods = factory(req, res);
|
|
5636
|
+
const handler = methods[req.method];
|
|
5637
|
+
const methodWithMiddlewares = this.middlewares.reduce((acc, fn) => fn(acc, options), handler);
|
|
5638
|
+
return await methodWithMiddlewares(req, res, options);
|
|
5639
|
+
};
|
|
5640
|
+
}
|
|
5641
|
+
static build(factory, options) {
|
|
5642
|
+
return new _ApiHelper({ ...options }).buildFactory(factory);
|
|
5643
|
+
}
|
|
5644
|
+
static parse(body, parser) {
|
|
5645
|
+
try {
|
|
5646
|
+
const object = parser.parse(body);
|
|
5647
|
+
return object;
|
|
5648
|
+
} catch (error) {
|
|
5649
|
+
throw new HttpError(400, {
|
|
5650
|
+
code: "invalid.body",
|
|
5651
|
+
error: "Dados inv\xE1lidos",
|
|
5652
|
+
details: error
|
|
5653
|
+
});
|
|
5654
|
+
}
|
|
5655
|
+
}
|
|
5656
|
+
/** @deprecated Use {@Link ApiHelper.build} instead. */
|
|
5657
|
+
static create({ onFinally }) {
|
|
5658
|
+
return new _ApiHelper({
|
|
5659
|
+
onFinally
|
|
5660
|
+
});
|
|
5661
|
+
}
|
|
5662
|
+
};
|
|
5663
|
+
/** @deprecated Use {@link ApiHelper.parser} instead. */
|
|
5664
|
+
_ApiHelper.parserErrorWrapper = _ApiHelper.parse;
|
|
5665
|
+
var ApiHelper = _ApiHelper;
|
|
5666
|
+
|
|
5667
|
+
// src/helpers/authHelper.ts
|
|
5668
|
+
var _crypto = require('crypto');
|
|
5669
|
+
|
|
5670
|
+
var _jsonwebtoken = require('jsonwebtoken'); var _jsonwebtoken2 = _interopRequireDefault(_jsonwebtoken);
|
|
5671
|
+
function decodeSessionToken({
|
|
5672
|
+
req,
|
|
5673
|
+
res,
|
|
5674
|
+
sessionTokenName,
|
|
5675
|
+
validate
|
|
5676
|
+
}) {
|
|
5677
|
+
const token = _optionalChain([req, 'access', _102 => _102.headers, 'access', _103 => _103.authorization, 'optionalAccess', _104 => _104.split, 'call', _105 => _105(" "), 'access', _106 => _106[1]]) || req.cookies[sessionTokenName];
|
|
5678
|
+
if (!token) {
|
|
5679
|
+
res.status(401).json({ error: "Token inv\xE1lido", code: "token.invalid" });
|
|
5680
|
+
return true;
|
|
5681
|
+
}
|
|
5682
|
+
const jwtDecode = (token2) => {
|
|
5683
|
+
if (validate) {
|
|
5684
|
+
return _jsonwebtoken2.default.verify(token2, process.env.JWT_SECRET);
|
|
5685
|
+
}
|
|
5686
|
+
return _jsonwebtoken2.default.decode(token2);
|
|
5687
|
+
};
|
|
5688
|
+
try {
|
|
5689
|
+
const decoded = jwtDecode(token);
|
|
5690
|
+
req.user = decoded.sub;
|
|
5691
|
+
} catch (_) {
|
|
5692
|
+
res.status(401).json({ error: "Token inv\xE1lido", code: "token.expired" });
|
|
5693
|
+
return true;
|
|
5694
|
+
}
|
|
5695
|
+
}
|
|
5696
|
+
var AuthHelper = class {
|
|
5697
|
+
constructor({
|
|
5698
|
+
cookies,
|
|
5699
|
+
oauth,
|
|
5700
|
+
tokenExpTimeInSeconds,
|
|
5701
|
+
onLogin,
|
|
5702
|
+
onValidateRefreshToken,
|
|
5703
|
+
onInvalidateRefreshToken,
|
|
5704
|
+
onCreateRefreshToken,
|
|
5705
|
+
onGetUserData
|
|
5706
|
+
}) {
|
|
5707
|
+
this.generateJwtAndRefreshToken = async (userId, payload = {}) => {
|
|
5708
|
+
const token = _jsonwebtoken2.default.sign(payload, process.env.JWT_SECRET, {
|
|
5709
|
+
subject: String(userId),
|
|
5710
|
+
expiresIn: this.tokenExpTimeInSeconds || 60 * 15
|
|
5711
|
+
// 15 minutos
|
|
5712
|
+
});
|
|
5713
|
+
const uniqueToken = _crypto.randomUUID.call(void 0, );
|
|
5714
|
+
await this.onCreateRefreshToken(userId, uniqueToken);
|
|
5715
|
+
return {
|
|
5716
|
+
token,
|
|
5717
|
+
refreshToken: uniqueToken
|
|
5718
|
+
};
|
|
5719
|
+
};
|
|
5720
|
+
this.invalidateCookies = (res) => {
|
|
5721
|
+
return res.setHeader("Set-Cookie", [
|
|
5722
|
+
_cookie.serialize.call(void 0, this.cookies.sessionToken, "", {
|
|
5723
|
+
maxAge: -1,
|
|
5724
|
+
path: "/"
|
|
5725
|
+
}),
|
|
5726
|
+
_cookie.serialize.call(void 0, this.cookies.refreshToken, "", {
|
|
5727
|
+
maxAge: -1,
|
|
5728
|
+
path: "/"
|
|
5729
|
+
})
|
|
5730
|
+
]);
|
|
5731
|
+
};
|
|
5732
|
+
this.cookies = cookies;
|
|
5733
|
+
this.oauth = oauth;
|
|
5734
|
+
this.tokenExpTimeInSeconds = tokenExpTimeInSeconds;
|
|
5735
|
+
this.onLogin = onLogin;
|
|
5736
|
+
this.onValidateRefreshToken = onValidateRefreshToken;
|
|
5737
|
+
this.onInvalidateRefreshToken = onInvalidateRefreshToken;
|
|
5738
|
+
this.onCreateRefreshToken = onCreateRefreshToken;
|
|
5739
|
+
this.onGetUserData = onGetUserData;
|
|
5740
|
+
}
|
|
5741
|
+
async handler(req, res) {
|
|
5742
|
+
if (!req.url) return res.status(400).json({ error: "url not sent" });
|
|
5743
|
+
if (req.url.endsWith("/login")) {
|
|
5744
|
+
const loginResult = await this.onLogin(req.body);
|
|
5745
|
+
if (loginResult.status === "success") {
|
|
5746
|
+
const { refreshToken, token } = await this.generateJwtAndRefreshToken(
|
|
5747
|
+
loginResult.userId,
|
|
5748
|
+
{}
|
|
5749
|
+
);
|
|
5750
|
+
setCookie({ res }, this.cookies.sessionToken, token, {
|
|
5751
|
+
secure: true,
|
|
5752
|
+
maxAge: 60 * 60 * 24 * 30,
|
|
5753
|
+
// 30 days
|
|
5754
|
+
path: "/",
|
|
5755
|
+
sameSite: true
|
|
5756
|
+
});
|
|
5757
|
+
setCookie({ res }, this.cookies.refreshToken, refreshToken, {
|
|
5758
|
+
secure: true,
|
|
5759
|
+
maxAge: 60 * 60 * 24 * 30,
|
|
5760
|
+
// 30 days
|
|
5761
|
+
path: "/",
|
|
5762
|
+
sameSite: true,
|
|
5763
|
+
httpOnly: true
|
|
5764
|
+
});
|
|
5765
|
+
return res.json({ token, refreshToken });
|
|
5766
|
+
}
|
|
5767
|
+
throw new HttpError(400, loginResult.response);
|
|
5768
|
+
}
|
|
5769
|
+
if (req.url.endsWith("/logout")) {
|
|
5770
|
+
this.invalidateCookies(res).end();
|
|
5771
|
+
}
|
|
5772
|
+
if (req.url.endsWith("/refresh")) {
|
|
5773
|
+
const error = decodeSessionToken({
|
|
5774
|
+
req,
|
|
5775
|
+
res,
|
|
5776
|
+
sessionTokenName: this.cookies.sessionToken,
|
|
5777
|
+
validate: false
|
|
5778
|
+
});
|
|
5779
|
+
if (error) return;
|
|
5780
|
+
const userId = String(req.user);
|
|
5781
|
+
const refreshToken = parseCookies({ req })[this.cookies.refreshToken];
|
|
5782
|
+
if (!refreshToken) {
|
|
5783
|
+
this.invalidateCookies(res);
|
|
5784
|
+
return res.status(400).json({
|
|
5785
|
+
error: "Refresh Token inv\xE1lido"
|
|
5786
|
+
});
|
|
5787
|
+
}
|
|
5788
|
+
const isValidRefreshToken = await this.onValidateRefreshToken(userId, refreshToken);
|
|
5789
|
+
if (!isValidRefreshToken) {
|
|
5790
|
+
this.invalidateCookies(res);
|
|
5791
|
+
return res.status(400).json({
|
|
5792
|
+
error: "Refresh Token inv\xE1lido"
|
|
5793
|
+
});
|
|
5794
|
+
}
|
|
5795
|
+
await this.onInvalidateRefreshToken(userId, refreshToken);
|
|
5796
|
+
const { token, refreshToken: newRefreshToken } = await this.generateJwtAndRefreshToken(
|
|
5797
|
+
userId,
|
|
5798
|
+
{}
|
|
5799
|
+
);
|
|
5800
|
+
setCookie({ res }, this.cookies.sessionToken, token, {
|
|
5801
|
+
secure: true,
|
|
5802
|
+
maxAge: 60 * 60 * 24 * 30,
|
|
5803
|
+
// 30 days
|
|
5804
|
+
path: "/",
|
|
5805
|
+
sameSite: true
|
|
5806
|
+
});
|
|
5807
|
+
setCookie({ res }, this.cookies.refreshToken, newRefreshToken, {
|
|
5808
|
+
secure: true,
|
|
5809
|
+
maxAge: 60 * 60 * 24 * 30,
|
|
5810
|
+
// 30 days
|
|
5811
|
+
path: "/",
|
|
5812
|
+
sameSite: true,
|
|
5813
|
+
httpOnly: true
|
|
5814
|
+
});
|
|
5815
|
+
return res.json({
|
|
5816
|
+
token,
|
|
5817
|
+
refreshToken: newRefreshToken
|
|
5818
|
+
});
|
|
5819
|
+
}
|
|
5820
|
+
if (req.url.endsWith("/me")) {
|
|
5821
|
+
const error = decodeSessionToken({
|
|
5822
|
+
req,
|
|
5823
|
+
res,
|
|
5824
|
+
sessionTokenName: this.cookies.sessionToken,
|
|
5825
|
+
validate: true
|
|
5826
|
+
});
|
|
5827
|
+
if (error) return;
|
|
5828
|
+
if (!req.user) return res.status(400).json({ error: "Usu\xE1rio n\xE3o encontrado" });
|
|
5829
|
+
const userData = await this.onGetUserData(req.user);
|
|
5830
|
+
if (!userData) return res.status(400).json({ error: "Usu\xE1rio n\xE3o encontrado" });
|
|
5831
|
+
return res.json(userData);
|
|
5832
|
+
}
|
|
5833
|
+
if (req.url.endsWith("/oauth-url") && this.oauth) {
|
|
5834
|
+
const params = {
|
|
5835
|
+
client_id: this.oauth.client_id,
|
|
5836
|
+
redirect_uri: this.oauth.redirect_uri,
|
|
5837
|
+
scope: this.oauth.scope,
|
|
5838
|
+
response_type: "code",
|
|
5839
|
+
response_mode: "query"
|
|
5840
|
+
};
|
|
5841
|
+
const url = `https://login.microsoftonline.com/${this.oauth.tenant_id}/oauth2/v2.0/authorize?${new URLSearchParams(params)}`;
|
|
5842
|
+
return res.json({
|
|
5843
|
+
url
|
|
5844
|
+
});
|
|
5845
|
+
}
|
|
5846
|
+
return res.status(404).json({ error: "Route not found" });
|
|
5847
|
+
}
|
|
5848
|
+
async oauthSignInCallback(code) {
|
|
5849
|
+
if (!this.oauth) throw new Error("OAUTH variables is not defined");
|
|
5850
|
+
const body = {
|
|
5851
|
+
client_id: this.oauth.client_id,
|
|
5852
|
+
scope: this.oauth.scope,
|
|
5853
|
+
code,
|
|
5854
|
+
session_state: this.oauth.client_id,
|
|
5855
|
+
redirect_uri: this.oauth.redirect_uri,
|
|
5856
|
+
grant_type: "authorization_code",
|
|
5857
|
+
client_secret: this.oauth.client_secret
|
|
5858
|
+
};
|
|
5859
|
+
const response = await fetch(
|
|
5860
|
+
`https://login.microsoftonline.com/${this.oauth.tenant_id}/oauth2/v2.0/token`,
|
|
5861
|
+
{
|
|
5862
|
+
method: "POST",
|
|
5863
|
+
body: new URLSearchParams(body),
|
|
5864
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
5865
|
+
}
|
|
5866
|
+
);
|
|
5867
|
+
const data = await response.json();
|
|
5868
|
+
const decodedToken = _jsonwebtoken2.default.decode(data.access_token);
|
|
5869
|
+
const email = decodedToken.upn;
|
|
5870
|
+
const fullName = `${_optionalChain([decodedToken, 'optionalAccess', _107 => _107.given_name])} ${_optionalChain([decodedToken, 'optionalAccess', _108 => _108.family_name])}`;
|
|
5871
|
+
return { decodedToken, email, fullName };
|
|
5872
|
+
}
|
|
5873
|
+
createOauthCallbackGetServerSideProps({
|
|
5874
|
+
onSuccessDestination,
|
|
5875
|
+
onFailedDestination
|
|
5876
|
+
}) {
|
|
5877
|
+
return async (ctx) => {
|
|
5878
|
+
if (!this.oauth) throw new Error("Oauth env variables are not defined");
|
|
5879
|
+
const code = ctx.query.code;
|
|
5880
|
+
if (!code)
|
|
5881
|
+
return {
|
|
5882
|
+
redirect: {
|
|
5883
|
+
permanent: false,
|
|
5884
|
+
destination: onFailedDestination || "/"
|
|
5885
|
+
}
|
|
5886
|
+
};
|
|
5887
|
+
try {
|
|
5888
|
+
const { fullName, email } = await this.oauthSignInCallback(code);
|
|
5889
|
+
const userExists = await this.onGetUserData(email);
|
|
5890
|
+
if (!userExists && !this.oauth.onCreateUser) throw new Error("User does not exists");
|
|
5891
|
+
if (!userExists && this.oauth.onCreateUser) {
|
|
5892
|
+
await this.oauth.onCreateUser({ fullname: fullName, email });
|
|
5893
|
+
}
|
|
5894
|
+
const { token, refreshToken } = await this.generateJwtAndRefreshToken(email, {});
|
|
5895
|
+
setCookie(ctx, this.cookies.sessionToken, token, {
|
|
5896
|
+
secure: true,
|
|
5897
|
+
maxAge: 60 * 60 * 24 * 30,
|
|
5898
|
+
// 30 days
|
|
5899
|
+
path: "/"
|
|
5900
|
+
});
|
|
5901
|
+
setCookie(ctx, this.cookies.refreshToken, refreshToken, {
|
|
5902
|
+
secure: true,
|
|
5903
|
+
maxAge: 60 * 60 * 24 * 30,
|
|
5904
|
+
// 30 days
|
|
5905
|
+
path: "/",
|
|
5906
|
+
httpOnly: true
|
|
5907
|
+
});
|
|
5908
|
+
return {
|
|
5909
|
+
redirect: {
|
|
5910
|
+
destination: onSuccessDestination,
|
|
5911
|
+
permanent: false
|
|
5912
|
+
}
|
|
5913
|
+
};
|
|
5914
|
+
} catch (error) {
|
|
5915
|
+
return {
|
|
5916
|
+
props: {
|
|
5917
|
+
error: JSON.stringify(error)
|
|
5918
|
+
}
|
|
5919
|
+
};
|
|
5920
|
+
}
|
|
5921
|
+
};
|
|
5922
|
+
}
|
|
5923
|
+
};
|
|
5924
|
+
|
|
5925
|
+
|
|
5926
|
+
|
|
5692
5927
|
|
|
5693
5928
|
|
|
5694
5929
|
|
|
@@ -5740,7 +5975,7 @@ function CreateAuthProvider({
|
|
|
5740
5975
|
|
|
5741
5976
|
|
|
5742
5977
|
|
|
5743
|
-
exports.AlertContext = AlertContext; exports.AlertProvider = AlertProvider; exports.ApiHelper = ApiHelper; exports.AuthHelper = AuthHelper; exports.Autocomplete = Autocomplete2; exports.BaseDialog = BaseDialog; exports.BaseDialogBody = BaseDialogBody; exports.BaseDialogContainer = BaseDialogContainer; exports.BaseDialogCreate = BaseDialogCreate; exports.BaseDialogTrigger = BaseDialogTrigger; exports.BaseGrid = BaseGrid; exports.BaseGridAutoRows = BaseGridAutoRows; exports.Checkbox = Checkbox; exports.CreateAuthProvider = CreateAuthProvider; exports.Dialog = Dialog; exports.DialogConfirm = DialogConfirm; exports.DomainError = DomainError; exports.EditableTableCell = EditableTableCell; exports.FormHelperContext = FormHelperContext; exports.FormHelperProvider = FormHelperProvider; exports.GetInputLabel = GetInputLabel; exports.Grid = Grid_default; exports.HttpError = HttpError; exports.Input = Input; exports.InputMask = InputMask2; exports.LargeButton = LargeButton; exports.Modal = Modal; exports.Radio = Radio; exports.Select = Select; exports.Switch = Switch; exports.TabPanel = TabPanel; exports.Td = Td; exports.Tr = Tr; exports.UseDialogConfirm = UseDialogConfirm; exports.createAuthContext = createAuthContext; exports.createFilter = createFilter; exports.destroyCookie = destroyCookie; exports.filterData = filterData; exports.getTabProps = getTabProps; exports.nookies = nookies; exports.parseCookies = parseCookies; exports.setCookie = setCookie; exports.useAlert = useAlert; exports.useAsyncGrid = useAsyncGrid; exports.useBaseDialog = useBaseDialog; exports.useBaseDialogInstance = useBaseDialogInstance; exports.useEvent = useEvent; exports.useFilter = useFilter; exports.useFormHelper = useFormHelper; exports.useGrid = useGrid; exports.useLoading = useLoading;
|
|
5978
|
+
exports.AlertContext = AlertContext; exports.AlertProvider = AlertProvider; exports.ApiHelper = ApiHelper; exports.AuthHelper = AuthHelper; exports.Autocomplete = Autocomplete2; exports.BaseDialog = BaseDialog; exports.BaseDialogBody = BaseDialogBody; exports.BaseDialogContainer = BaseDialogContainer; exports.BaseDialogCreate = BaseDialogCreate; exports.BaseDialogTrigger = BaseDialogTrigger; exports.BaseGrid = BaseGrid; exports.BaseGridAutoRows = BaseGridAutoRows; exports.Checkbox = Checkbox; exports.CreateAuthProvider = CreateAuthProvider; exports.Dialog = Dialog; exports.DialogConfirm = DialogConfirm; exports.DomainError = DomainError; exports.EditableTableCell = EditableTableCell; exports.FormHelperContext = FormHelperContext; exports.FormHelperProvider = FormHelperProvider; exports.GetInputLabel = GetInputLabel; exports.Grid = Grid_default; exports.HttpClientError = HttpClientError; exports.HttpError = HttpError; exports.Input = Input; exports.InputMask = InputMask2; exports.LargeButton = LargeButton; exports.Modal = Modal; exports.Radio = Radio; exports.Select = Select; exports.Switch = Switch; exports.TabPanel = TabPanel; exports.Td = Td; exports.Tr = Tr; exports.UseDialogConfirm = UseDialogConfirm; exports.createAuthContext = createAuthContext; exports.createFilter = createFilter; exports.createHttpClient = createHttpClient; exports.destroyCookie = destroyCookie; exports.filterData = filterData; exports.getTabProps = getTabProps; exports.nookies = nookies; exports.parseCookies = parseCookies; exports.setCookie = setCookie; exports.useAlert = useAlert; exports.useAsyncGrid = useAsyncGrid; exports.useBaseDialog = useBaseDialog; exports.useBaseDialogInstance = useBaseDialogInstance; exports.useEvent = useEvent; exports.useFilter = useFilter; exports.useFormHelper = useFormHelper; exports.useGrid = useGrid; exports.useLoading = useLoading;
|
|
5744
5979
|
/*! Bundled license information:
|
|
5745
5980
|
|
|
5746
5981
|
react-is/cjs/react-is.production.min.js:
|