@bluemarble/bm-components 1.16.1 → 1.17.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.d.mts +31 -5
- package/dist/index.d.ts +31 -5
- package/dist/index.js +121 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +156 -104
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -12
package/dist/index.mjs
CHANGED
|
@@ -258,7 +258,7 @@ var require_react_is_development = __commonJS({
|
|
|
258
258
|
var Fragment3 = REACT_FRAGMENT_TYPE;
|
|
259
259
|
var Lazy = REACT_LAZY_TYPE;
|
|
260
260
|
var Memo = REACT_MEMO_TYPE;
|
|
261
|
-
var
|
|
261
|
+
var Portal2 = REACT_PORTAL_TYPE;
|
|
262
262
|
var Profiler = REACT_PROFILER_TYPE;
|
|
263
263
|
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
264
264
|
var Suspense = REACT_SUSPENSE_TYPE;
|
|
@@ -317,7 +317,7 @@ var require_react_is_development = __commonJS({
|
|
|
317
317
|
exports.Fragment = Fragment3;
|
|
318
318
|
exports.Lazy = Lazy;
|
|
319
319
|
exports.Memo = Memo;
|
|
320
|
-
exports.Portal =
|
|
320
|
+
exports.Portal = Portal2;
|
|
321
321
|
exports.Profiler = Profiler;
|
|
322
322
|
exports.StrictMode = StrictMode;
|
|
323
323
|
exports.Suspense = Suspense;
|
|
@@ -2404,7 +2404,7 @@ function createBox(options = {}) {
|
|
|
2404
2404
|
const BoxRoot = styled("div", {
|
|
2405
2405
|
shouldForwardProp: (prop) => prop !== "theme" && prop !== "sx" && prop !== "as"
|
|
2406
2406
|
})(styleFunctionSx_default);
|
|
2407
|
-
const
|
|
2407
|
+
const Box8 = /* @__PURE__ */ React3.forwardRef(function Box9(inProps, ref) {
|
|
2408
2408
|
const theme = useTheme_default(defaultTheme);
|
|
2409
2409
|
const _extendSxProp = extendSxProp(inProps), {
|
|
2410
2410
|
className,
|
|
@@ -2417,7 +2417,7 @@ function createBox(options = {}) {
|
|
|
2417
2417
|
theme: themeId ? theme[themeId] || theme : theme
|
|
2418
2418
|
}, other));
|
|
2419
2419
|
});
|
|
2420
|
-
return
|
|
2420
|
+
return Box8;
|
|
2421
2421
|
}
|
|
2422
2422
|
|
|
2423
2423
|
// node_modules/@mui/utils/generateUtilityClass/generateUtilityClass.js
|
|
@@ -3992,11 +3992,11 @@ import {
|
|
|
3992
3992
|
Modal as MuiModal
|
|
3993
3993
|
} from "@mui/material";
|
|
3994
3994
|
var Modal = (_a) => {
|
|
3995
|
-
var _b = _a, { open, onClose } = _b, rest = __objRest(_b, ["open", "onClose"]);
|
|
3995
|
+
var _b = _a, { open, onClose, BoxProps: BoxProps3 } = _b, rest = __objRest(_b, ["open", "onClose", "BoxProps"]);
|
|
3996
3996
|
return /* @__PURE__ */ React22.createElement(MuiModal, __spreadValues({ open, onClose }, rest), /* @__PURE__ */ React22.createElement(
|
|
3997
3997
|
Box5,
|
|
3998
|
-
{
|
|
3999
|
-
sx: {
|
|
3998
|
+
__spreadProps(__spreadValues({}, BoxProps3), {
|
|
3999
|
+
sx: __spreadValues({
|
|
4000
4000
|
outline: "none",
|
|
4001
4001
|
backgroundColor: "background.paper",
|
|
4002
4002
|
position: "absolute",
|
|
@@ -4004,9 +4004,9 @@ var Modal = (_a) => {
|
|
|
4004
4004
|
left: "50%",
|
|
4005
4005
|
transform: "translate(-50%, -50%)",
|
|
4006
4006
|
borderRadius: 1
|
|
4007
|
-
}
|
|
4008
|
-
},
|
|
4009
|
-
|
|
4007
|
+
}, BoxProps3 == null ? void 0 : BoxProps3.sx)
|
|
4008
|
+
}),
|
|
4009
|
+
rest.children
|
|
4010
4010
|
));
|
|
4011
4011
|
};
|
|
4012
4012
|
|
|
@@ -4062,6 +4062,101 @@ var Dialog = (_a) => {
|
|
|
4062
4062
|
}))));
|
|
4063
4063
|
};
|
|
4064
4064
|
|
|
4065
|
+
// src/components/DialogConfirm/DialogConfirm.view.tsx
|
|
4066
|
+
import React24 from "react";
|
|
4067
|
+
import { Box as Box7, Portal, Stack as Stack2, Typography as Typography3 } from "@mui/material";
|
|
4068
|
+
import { grey, orange } from "@mui/material/colors";
|
|
4069
|
+
import { MdOutlineWarningAmber } from "react-icons/md";
|
|
4070
|
+
|
|
4071
|
+
// src/components/DialogConfirm/DialogConfirm.model.ts
|
|
4072
|
+
import { useRef as useRef3, useState as useState4 } from "react";
|
|
4073
|
+
function UseDialogConfirm() {
|
|
4074
|
+
const [opened, setOpened] = useState4(false);
|
|
4075
|
+
const [isLoading, setLoading] = useState4(false);
|
|
4076
|
+
const onConfirmFn = useRef3();
|
|
4077
|
+
const paramsFn = useRef3([]);
|
|
4078
|
+
const onConfirm = (fn) => {
|
|
4079
|
+
onConfirmFn.current = fn;
|
|
4080
|
+
return (...params) => __async(this, null, function* () {
|
|
4081
|
+
paramsFn.current = params;
|
|
4082
|
+
setOpened(true);
|
|
4083
|
+
});
|
|
4084
|
+
};
|
|
4085
|
+
const onProceed = (event) => __async(this, null, function* () {
|
|
4086
|
+
event == null ? void 0 : event.preventDefault();
|
|
4087
|
+
event == null ? void 0 : event.stopPropagation();
|
|
4088
|
+
setLoading(true);
|
|
4089
|
+
try {
|
|
4090
|
+
if (!onConfirmFn.current)
|
|
4091
|
+
return;
|
|
4092
|
+
yield onConfirmFn.current(...paramsFn.current);
|
|
4093
|
+
} finally {
|
|
4094
|
+
setOpened(false);
|
|
4095
|
+
setLoading(false);
|
|
4096
|
+
}
|
|
4097
|
+
});
|
|
4098
|
+
const onCancel = (event) => {
|
|
4099
|
+
event == null ? void 0 : event.preventDefault();
|
|
4100
|
+
event == null ? void 0 : event.stopPropagation();
|
|
4101
|
+
setOpened(false);
|
|
4102
|
+
};
|
|
4103
|
+
const onCloseModal = () => {
|
|
4104
|
+
if (isLoading)
|
|
4105
|
+
return;
|
|
4106
|
+
setOpened(false);
|
|
4107
|
+
};
|
|
4108
|
+
return {
|
|
4109
|
+
isLoading,
|
|
4110
|
+
opened,
|
|
4111
|
+
onConfirm,
|
|
4112
|
+
onCloseModal,
|
|
4113
|
+
onCancel,
|
|
4114
|
+
onProceed
|
|
4115
|
+
};
|
|
4116
|
+
}
|
|
4117
|
+
|
|
4118
|
+
// src/components/DialogConfirm/DialogConfirm.view.tsx
|
|
4119
|
+
var DEFAULT_ICON = MdOutlineWarningAmber;
|
|
4120
|
+
var DialogConfirm = (props) => {
|
|
4121
|
+
const model = UseDialogConfirm();
|
|
4122
|
+
const Icon = props.icon || DEFAULT_ICON;
|
|
4123
|
+
return /* @__PURE__ */ React24.createElement(React24.Fragment, null, props.children({
|
|
4124
|
+
onConfirm: model.onConfirm,
|
|
4125
|
+
onCancel: model.onCancel
|
|
4126
|
+
}), /* @__PURE__ */ React24.createElement(Portal, null, /* @__PURE__ */ React24.createElement(Modal, { open: model.opened, onClose: model.onCloseModal }, /* @__PURE__ */ React24.createElement(Box7, { sx: { p: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React24.createElement(
|
|
4127
|
+
Stack2,
|
|
4128
|
+
{
|
|
4129
|
+
mx: "auto",
|
|
4130
|
+
color: orange[800],
|
|
4131
|
+
bgcolor: orange[50],
|
|
4132
|
+
borderRadius: "50%",
|
|
4133
|
+
height: 8 * 5,
|
|
4134
|
+
width: 8 * 5,
|
|
4135
|
+
direction: "row",
|
|
4136
|
+
justifyContent: "center",
|
|
4137
|
+
alignItems: "center"
|
|
4138
|
+
},
|
|
4139
|
+
/* @__PURE__ */ React24.createElement(Icon, { size: 8 * 3 })
|
|
4140
|
+
), /* @__PURE__ */ React24.createElement(Typography3, { fontWeight: "bold", variant: "h6", mt: 1 }, props.title || "Aten\xE7\xE3o"), /* @__PURE__ */ React24.createElement(Typography3, { my: 1 }, props.body || "Tem certeza que deseja realizar essa a\xE7\xE3o?"), /* @__PURE__ */ React24.createElement(Stack2, { gap: 1, mt: 3, color: grey[600] }, /* @__PURE__ */ React24.createElement(
|
|
4141
|
+
LargeButton,
|
|
4142
|
+
{
|
|
4143
|
+
color: "warning",
|
|
4144
|
+
loading: model.isLoading,
|
|
4145
|
+
onClick: model.onProceed
|
|
4146
|
+
},
|
|
4147
|
+
props.confirmButtonText || "Confirmar"
|
|
4148
|
+
), /* @__PURE__ */ React24.createElement(
|
|
4149
|
+
LargeButton,
|
|
4150
|
+
{
|
|
4151
|
+
variant: "outlined",
|
|
4152
|
+
disabled: model.isLoading,
|
|
4153
|
+
onClick: model.onCancel,
|
|
4154
|
+
color: "inherit"
|
|
4155
|
+
},
|
|
4156
|
+
props.cancelButtonText || "Confirmar"
|
|
4157
|
+
))))));
|
|
4158
|
+
};
|
|
4159
|
+
|
|
4065
4160
|
// src/errors/HttpError.ts
|
|
4066
4161
|
var HttpError = class extends Error {
|
|
4067
4162
|
constructor(status, message) {
|
|
@@ -4175,21 +4270,21 @@ var ApiHelper = class _ApiHelper {
|
|
|
4175
4270
|
};
|
|
4176
4271
|
|
|
4177
4272
|
// src/hooks/useFormHelper.ts
|
|
4178
|
-
import { useCallback as useCallback3, useContext as useContext3, useEffect as useEffect4, useRef as
|
|
4273
|
+
import { useCallback as useCallback3, useContext as useContext3, useEffect as useEffect4, useRef as useRef4 } from "react";
|
|
4179
4274
|
|
|
4180
4275
|
// src/hooks/useAlert.ts
|
|
4181
4276
|
import { useContext as useContext2 } from "react";
|
|
4182
4277
|
|
|
4183
4278
|
// src/contexts/AlertContext.tsx
|
|
4184
|
-
import
|
|
4185
|
-
import { createContext, useState as
|
|
4279
|
+
import React26, { useCallback } from "react";
|
|
4280
|
+
import { createContext, useState as useState5 } from "react";
|
|
4186
4281
|
|
|
4187
4282
|
// src/components/Toast/index.tsx
|
|
4188
|
-
import
|
|
4283
|
+
import React25 from "react";
|
|
4189
4284
|
import { Alert, IconButton as IconButton4, Snackbar } from "@mui/material";
|
|
4190
4285
|
import { MdClose as MdClose2 } from "react-icons/md";
|
|
4191
4286
|
var Toast = ({ open, onClose, severity, message }) => {
|
|
4192
|
-
return /* @__PURE__ */
|
|
4287
|
+
return /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(
|
|
4193
4288
|
Snackbar,
|
|
4194
4289
|
{
|
|
4195
4290
|
open,
|
|
@@ -4198,12 +4293,12 @@ var Toast = ({ open, onClose, severity, message }) => {
|
|
|
4198
4293
|
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
4199
4294
|
sx: { zIndex: 99999999 }
|
|
4200
4295
|
},
|
|
4201
|
-
/* @__PURE__ */
|
|
4296
|
+
/* @__PURE__ */ React25.createElement(
|
|
4202
4297
|
Alert,
|
|
4203
4298
|
{
|
|
4204
4299
|
severity,
|
|
4205
4300
|
elevation: 2,
|
|
4206
|
-
action: /* @__PURE__ */
|
|
4301
|
+
action: /* @__PURE__ */ React25.createElement(
|
|
4207
4302
|
IconButton4,
|
|
4208
4303
|
{
|
|
4209
4304
|
"aria-label": "close",
|
|
@@ -4211,7 +4306,7 @@ var Toast = ({ open, onClose, severity, message }) => {
|
|
|
4211
4306
|
size: "small",
|
|
4212
4307
|
onClick: onClose
|
|
4213
4308
|
},
|
|
4214
|
-
/* @__PURE__ */
|
|
4309
|
+
/* @__PURE__ */ React25.createElement(MdClose2, { fontSize: "inherit" })
|
|
4215
4310
|
)
|
|
4216
4311
|
},
|
|
4217
4312
|
message
|
|
@@ -4222,9 +4317,9 @@ var Toast = ({ open, onClose, severity, message }) => {
|
|
|
4222
4317
|
// src/contexts/AlertContext.tsx
|
|
4223
4318
|
var AlertContext = createContext({});
|
|
4224
4319
|
var AlertProvider = ({ children }) => {
|
|
4225
|
-
const [severity, setSeverity] =
|
|
4226
|
-
const [message, setMessage] =
|
|
4227
|
-
const [isVisible, setIsVisible] =
|
|
4320
|
+
const [severity, setSeverity] = useState5("info");
|
|
4321
|
+
const [message, setMessage] = useState5("");
|
|
4322
|
+
const [isVisible, setIsVisible] = useState5(false);
|
|
4228
4323
|
const createAlert = useCallback(
|
|
4229
4324
|
(newMessage, severity2) => {
|
|
4230
4325
|
setMessage(newMessage);
|
|
@@ -4236,7 +4331,7 @@ var AlertProvider = ({ children }) => {
|
|
|
4236
4331
|
const onCloseToast = useCallback(() => {
|
|
4237
4332
|
setIsVisible(false);
|
|
4238
4333
|
}, []);
|
|
4239
|
-
return /* @__PURE__ */
|
|
4334
|
+
return /* @__PURE__ */ React26.createElement(AlertContext.Provider, { value: { createAlert } }, children, /* @__PURE__ */ React26.createElement(
|
|
4240
4335
|
Toast,
|
|
4241
4336
|
{
|
|
4242
4337
|
open: isVisible,
|
|
@@ -4253,9 +4348,9 @@ var useAlert = () => {
|
|
|
4253
4348
|
};
|
|
4254
4349
|
|
|
4255
4350
|
// src/hooks/useLoading.ts
|
|
4256
|
-
import { useCallback as useCallback2, useState as
|
|
4351
|
+
import { useCallback as useCallback2, useState as useState6 } from "react";
|
|
4257
4352
|
function useLoading() {
|
|
4258
|
-
const [state, setState] =
|
|
4353
|
+
const [state, setState] = useState6([]);
|
|
4259
4354
|
const isLoading = useCallback2((prop) => state.includes(prop), [state]);
|
|
4260
4355
|
const setLoading = useCallback2((prop, remove) => {
|
|
4261
4356
|
if (remove)
|
|
@@ -4267,11 +4362,11 @@ function useLoading() {
|
|
|
4267
4362
|
}
|
|
4268
4363
|
|
|
4269
4364
|
// src/contexts/FormHelperProvider.tsx
|
|
4270
|
-
import
|
|
4365
|
+
import React27 from "react";
|
|
4271
4366
|
import { createContext as createContext2 } from "react";
|
|
4272
4367
|
var FormHelperContext = createContext2({});
|
|
4273
4368
|
var FormHelperProvider = ({ formatErrorMessage, api, children }) => {
|
|
4274
|
-
return /* @__PURE__ */
|
|
4369
|
+
return /* @__PURE__ */ React27.createElement(FormHelperContext.Provider, { value: { formatErrorMessage, api } }, children);
|
|
4275
4370
|
};
|
|
4276
4371
|
|
|
4277
4372
|
// src/hooks/useFormHelper.ts
|
|
@@ -4281,7 +4376,7 @@ function useFormHelper() {
|
|
|
4281
4376
|
const { api, formatErrorMessage } = useContext3(FormHelperContext);
|
|
4282
4377
|
const { createAlert } = alertProps;
|
|
4283
4378
|
const { setLoading } = loadingProps;
|
|
4284
|
-
const sourceRef =
|
|
4379
|
+
const sourceRef = useRef4(new AbortController());
|
|
4285
4380
|
const onSubmitWrapper = useCallback3(
|
|
4286
4381
|
(fn, { name }) => {
|
|
4287
4382
|
return (fields, methods) => __async(this, null, function* () {
|
|
@@ -4359,55 +4454,7 @@ function useFormHelper() {
|
|
|
4359
4454
|
// src/helpers/authHelper.ts
|
|
4360
4455
|
import { serialize } from "cookie";
|
|
4361
4456
|
import { parseCookies, setCookie } from "nookies";
|
|
4362
|
-
|
|
4363
|
-
// node_modules/uuid/dist/esm-node/rng.js
|
|
4364
|
-
import crypto from "crypto";
|
|
4365
|
-
var rnds8Pool = new Uint8Array(256);
|
|
4366
|
-
var poolPtr = rnds8Pool.length;
|
|
4367
|
-
function rng() {
|
|
4368
|
-
if (poolPtr > rnds8Pool.length - 16) {
|
|
4369
|
-
crypto.randomFillSync(rnds8Pool);
|
|
4370
|
-
poolPtr = 0;
|
|
4371
|
-
}
|
|
4372
|
-
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
4373
|
-
}
|
|
4374
|
-
|
|
4375
|
-
// node_modules/uuid/dist/esm-node/stringify.js
|
|
4376
|
-
var byteToHex = [];
|
|
4377
|
-
for (let i = 0; i < 256; ++i) {
|
|
4378
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
4379
|
-
}
|
|
4380
|
-
function unsafeStringify(arr, offset = 0) {
|
|
4381
|
-
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
4382
|
-
}
|
|
4383
|
-
|
|
4384
|
-
// node_modules/uuid/dist/esm-node/native.js
|
|
4385
|
-
import crypto2 from "crypto";
|
|
4386
|
-
var native_default = {
|
|
4387
|
-
randomUUID: crypto2.randomUUID
|
|
4388
|
-
};
|
|
4389
|
-
|
|
4390
|
-
// node_modules/uuid/dist/esm-node/v4.js
|
|
4391
|
-
function v4(options, buf, offset) {
|
|
4392
|
-
if (native_default.randomUUID && !buf && !options) {
|
|
4393
|
-
return native_default.randomUUID();
|
|
4394
|
-
}
|
|
4395
|
-
options = options || {};
|
|
4396
|
-
const rnds = options.random || (options.rng || rng)();
|
|
4397
|
-
rnds[6] = rnds[6] & 15 | 64;
|
|
4398
|
-
rnds[8] = rnds[8] & 63 | 128;
|
|
4399
|
-
if (buf) {
|
|
4400
|
-
offset = offset || 0;
|
|
4401
|
-
for (let i = 0; i < 16; ++i) {
|
|
4402
|
-
buf[offset + i] = rnds[i];
|
|
4403
|
-
}
|
|
4404
|
-
return buf;
|
|
4405
|
-
}
|
|
4406
|
-
return unsafeStringify(rnds);
|
|
4407
|
-
}
|
|
4408
|
-
var v4_default = v4;
|
|
4409
|
-
|
|
4410
|
-
// src/helpers/authHelper.ts
|
|
4457
|
+
import { v4 as uuid } from "uuid";
|
|
4411
4458
|
import jwt from "jsonwebtoken";
|
|
4412
4459
|
function decodeSessionToken({
|
|
4413
4460
|
req,
|
|
@@ -4452,7 +4499,7 @@ var AuthHelper = class {
|
|
|
4452
4499
|
expiresIn: this.tokenExpTimeInSeconds || 60 * 15
|
|
4453
4500
|
// 15 minutos
|
|
4454
4501
|
});
|
|
4455
|
-
const uniqueToken =
|
|
4502
|
+
const uniqueToken = uuid();
|
|
4456
4503
|
yield this.onCreateRefreshToken(userId, uniqueToken);
|
|
4457
4504
|
return {
|
|
4458
4505
|
token,
|
|
@@ -4680,11 +4727,11 @@ var AuthHelper = class {
|
|
|
4680
4727
|
};
|
|
4681
4728
|
|
|
4682
4729
|
// src/hooks/useGrid.ts
|
|
4683
|
-
import { useCallback as useCallback5, useEffect as useEffect5, useMemo as useMemo3, useState as
|
|
4730
|
+
import { useCallback as useCallback5, useEffect as useEffect5, useMemo as useMemo3, useState as useState8 } from "react";
|
|
4684
4731
|
|
|
4685
4732
|
// src/hooks/useFilter.ts
|
|
4686
4733
|
import moment2 from "moment";
|
|
4687
|
-
import { useCallback as useCallback4, useState as
|
|
4734
|
+
import { useCallback as useCallback4, useState as useState7 } from "react";
|
|
4688
4735
|
|
|
4689
4736
|
// src/components/utils/getObjectValue.ts
|
|
4690
4737
|
function getObjectValue(obj) {
|
|
@@ -4699,7 +4746,7 @@ function getObjectValue(obj) {
|
|
|
4699
4746
|
|
|
4700
4747
|
// src/hooks/useFilter.ts
|
|
4701
4748
|
function useFilter(props = { defaultFilters: [] }) {
|
|
4702
|
-
const [selectedFilters, setSelectedFilters] =
|
|
4749
|
+
const [selectedFilters, setSelectedFilters] = useState7(() => {
|
|
4703
4750
|
const { defaultFilters } = props;
|
|
4704
4751
|
return defaultFilters || [];
|
|
4705
4752
|
});
|
|
@@ -4790,12 +4837,12 @@ function useGrid({
|
|
|
4790
4837
|
defaultCurrentPage,
|
|
4791
4838
|
defaultSortedBy
|
|
4792
4839
|
}) {
|
|
4793
|
-
const [defaultData, setDefaultData] =
|
|
4794
|
-
const [sortedBy, setSortedBy] =
|
|
4840
|
+
const [defaultData, setDefaultData] = useState8(externalDefaultData || []);
|
|
4841
|
+
const [sortedBy, setSortedBy] = useState8(
|
|
4795
4842
|
defaultSortedBy || []
|
|
4796
4843
|
);
|
|
4797
|
-
const [currentPage, setCurrentPage] =
|
|
4798
|
-
const [rowsPerPage, setRowsPerPage] =
|
|
4844
|
+
const [currentPage, setCurrentPage] = useState8(defaultCurrentPage || 0);
|
|
4845
|
+
const [rowsPerPage, setRowsPerPage] = useState8(rowsPerPageOptions[0]);
|
|
4799
4846
|
const toggleSortedDirection = useCallback5(
|
|
4800
4847
|
(direction) => {
|
|
4801
4848
|
if (direction === "asc")
|
|
@@ -4876,8 +4923,15 @@ function useGrid({
|
|
|
4876
4923
|
},
|
|
4877
4924
|
[currentPage]
|
|
4878
4925
|
);
|
|
4926
|
+
const orderedData = useMemo3(() => {
|
|
4927
|
+
if (sortedBy.length === 0)
|
|
4928
|
+
return defaultData;
|
|
4929
|
+
const newData = defaultData.slice(0);
|
|
4930
|
+
const sortedData = sortData(newData);
|
|
4931
|
+
return sortedData;
|
|
4932
|
+
}, [defaultData, sortData, sortedBy]);
|
|
4879
4933
|
const filteredData = useMemo3(() => {
|
|
4880
|
-
let newData =
|
|
4934
|
+
let newData = orderedData.slice(0);
|
|
4881
4935
|
if (search && search.value !== "") {
|
|
4882
4936
|
const searchBy = createSearch(search);
|
|
4883
4937
|
newData = newData.filter(searchBy);
|
|
@@ -4886,16 +4940,12 @@ function useGrid({
|
|
|
4886
4940
|
return newData;
|
|
4887
4941
|
const newFilter = createFilter(filters);
|
|
4888
4942
|
return newData.filter(newFilter.apply);
|
|
4889
|
-
}, [
|
|
4890
|
-
const orderedData = useMemo3(() => {
|
|
4891
|
-
const sortedData = sortData(filteredData);
|
|
4892
|
-
return sortedData;
|
|
4893
|
-
}, [filteredData, sortData]);
|
|
4943
|
+
}, [orderedData, search, filters]);
|
|
4894
4944
|
const paginatedData = useMemo3(() => {
|
|
4895
4945
|
const startPage = currentPage * rowsPerPage;
|
|
4896
4946
|
const endPage = startPage + rowsPerPage;
|
|
4897
|
-
return
|
|
4898
|
-
}, [currentPage, rowsPerPage,
|
|
4947
|
+
return filteredData.slice(startPage, endPage);
|
|
4948
|
+
}, [currentPage, rowsPerPage, filteredData]);
|
|
4899
4949
|
const totalNumberOfPages = Math.ceil(filteredData.length / rowsPerPage) - 1;
|
|
4900
4950
|
useEffect5(() => {
|
|
4901
4951
|
if (externalDefaultData)
|
|
@@ -4959,7 +5009,7 @@ function createSearch(options) {
|
|
|
4959
5009
|
}
|
|
4960
5010
|
|
|
4961
5011
|
// src/hooks/useAsyncGrid.ts
|
|
4962
|
-
import { useCallback as useCallback6, useEffect as useEffect6, useState as
|
|
5012
|
+
import { useCallback as useCallback6, useEffect as useEffect6, useState as useState9 } from "react";
|
|
4963
5013
|
function useAsyncGrid({
|
|
4964
5014
|
columns,
|
|
4965
5015
|
filters = [],
|
|
@@ -4972,14 +5022,14 @@ function useAsyncGrid({
|
|
|
4972
5022
|
defaultCurrentPage,
|
|
4973
5023
|
defaultSortedBy
|
|
4974
5024
|
}) {
|
|
4975
|
-
const [defaultData, setDefaultData] =
|
|
4976
|
-
const [sortedBy, setSortedBy] =
|
|
5025
|
+
const [defaultData, setDefaultData] = useState9(externalDefaultData || []);
|
|
5026
|
+
const [sortedBy, setSortedBy] = useState9(
|
|
4977
5027
|
defaultSortedBy || []
|
|
4978
5028
|
);
|
|
4979
|
-
const [totalNumberOfItems, setTotalNumberOfItems] =
|
|
4980
|
-
const [isLoading, setIsLoading] =
|
|
4981
|
-
const [currentPage, setCurrentPage] =
|
|
4982
|
-
const [rowsPerPage, setRowsPerPage] =
|
|
5029
|
+
const [totalNumberOfItems, setTotalNumberOfItems] = useState9(0);
|
|
5030
|
+
const [isLoading, setIsLoading] = useState9(false);
|
|
5031
|
+
const [currentPage, setCurrentPage] = useState9(defaultCurrentPage || 0);
|
|
5032
|
+
const [rowsPerPage, setRowsPerPage] = useState9(rowsPerPageOptions[0]);
|
|
4983
5033
|
const totalNumberOfPages = Math.ceil(totalNumberOfItems / rowsPerPage) - 1;
|
|
4984
5034
|
const toggleSortedDirection = useCallback6(
|
|
4985
5035
|
(direction) => {
|
|
@@ -5144,11 +5194,11 @@ function useEvent(event, handler, passive = false) {
|
|
|
5144
5194
|
}
|
|
5145
5195
|
|
|
5146
5196
|
// src/contexts/AuthContext.tsx
|
|
5147
|
-
import
|
|
5197
|
+
import React28, { useCallback as useCallback7 } from "react";
|
|
5148
5198
|
import {
|
|
5149
5199
|
createContext as createContext3,
|
|
5150
5200
|
useEffect as useEffect8,
|
|
5151
|
-
useState as
|
|
5201
|
+
useState as useState10
|
|
5152
5202
|
} from "react";
|
|
5153
5203
|
import { parseCookies as parseCookies2 } from "nookies";
|
|
5154
5204
|
function createAuthContext() {
|
|
@@ -5160,8 +5210,8 @@ function CreateAuthProvider({
|
|
|
5160
5210
|
sessionTokenName,
|
|
5161
5211
|
Provider
|
|
5162
5212
|
}) {
|
|
5163
|
-
const [user, setUser] =
|
|
5164
|
-
const [status, setStatus] =
|
|
5213
|
+
const [user, setUser] = useState10();
|
|
5214
|
+
const [status, setStatus] = useState10("unauthenticated");
|
|
5165
5215
|
const { createAlert } = useAlert();
|
|
5166
5216
|
const signIn = useCallback7(
|
|
5167
5217
|
(_0) => __async(this, [_0], function* ({ email, password }) {
|
|
@@ -5202,7 +5252,7 @@ function CreateAuthProvider({
|
|
|
5202
5252
|
});
|
|
5203
5253
|
}
|
|
5204
5254
|
}, [api, sessionTokenName]);
|
|
5205
|
-
return /* @__PURE__ */
|
|
5255
|
+
return /* @__PURE__ */ React28.createElement(
|
|
5206
5256
|
Provider,
|
|
5207
5257
|
{
|
|
5208
5258
|
value: {
|
|
@@ -5226,6 +5276,7 @@ export {
|
|
|
5226
5276
|
Checkbox,
|
|
5227
5277
|
CreateAuthProvider,
|
|
5228
5278
|
Dialog,
|
|
5279
|
+
DialogConfirm,
|
|
5229
5280
|
DomainError,
|
|
5230
5281
|
EditableTableCell,
|
|
5231
5282
|
FormHelperContext,
|
|
@@ -5243,6 +5294,7 @@ export {
|
|
|
5243
5294
|
TabPanel,
|
|
5244
5295
|
Td,
|
|
5245
5296
|
Tr,
|
|
5297
|
+
UseDialogConfirm,
|
|
5246
5298
|
createAuthContext,
|
|
5247
5299
|
createFilter,
|
|
5248
5300
|
filterData,
|