@bluemarble/bm-components 1.17.0 → 1.18.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 +67 -2
- package/dist/index.d.ts +67 -2
- package/dist/index.js +180 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +252 -75
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -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 Box9 = /* @__PURE__ */ React3.forwardRef(function Box10(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 Box9;
|
|
2421
2421
|
}
|
|
2422
2422
|
|
|
2423
2423
|
// node_modules/@mui/utils/generateUtilityClass/generateUtilityClass.js
|
|
@@ -4157,6 +4157,176 @@ var DialogConfirm = (props) => {
|
|
|
4157
4157
|
))))));
|
|
4158
4158
|
};
|
|
4159
4159
|
|
|
4160
|
+
// src/components/BaseDialog/BaseDialog.tsx
|
|
4161
|
+
import React28 from "react";
|
|
4162
|
+
|
|
4163
|
+
// src/components/BaseDialog/BaseDialogHook.ts
|
|
4164
|
+
import { useContext as useContext2 } from "react";
|
|
4165
|
+
|
|
4166
|
+
// src/components/BaseDialog/BaseDialogContext.tsx
|
|
4167
|
+
import React25 from "react";
|
|
4168
|
+
import { createContext, useCallback, useState as useState5 } from "react";
|
|
4169
|
+
var BaseDialogContext = createContext({});
|
|
4170
|
+
var BaseDialogProvider = (props) => {
|
|
4171
|
+
const [openedDialogs, setOpenedDialogs] = useState5([]);
|
|
4172
|
+
const isOpened = useCallback(
|
|
4173
|
+
(dialog) => {
|
|
4174
|
+
return openedDialogs.includes(dialog);
|
|
4175
|
+
},
|
|
4176
|
+
[openedDialogs]
|
|
4177
|
+
);
|
|
4178
|
+
const toggleDialog = useCallback(
|
|
4179
|
+
(dialog) => {
|
|
4180
|
+
return openedDialogs.includes(dialog);
|
|
4181
|
+
},
|
|
4182
|
+
[openedDialogs]
|
|
4183
|
+
);
|
|
4184
|
+
const openDialog = useCallback((dialog) => {
|
|
4185
|
+
return setOpenedDialogs((prev) => {
|
|
4186
|
+
const filteredArr = prev.filter((item) => item !== dialog);
|
|
4187
|
+
return [...filteredArr, dialog];
|
|
4188
|
+
});
|
|
4189
|
+
}, []);
|
|
4190
|
+
const closeDialog = useCallback((dialog) => {
|
|
4191
|
+
return setOpenedDialogs((prev) => prev.filter((item) => item !== dialog));
|
|
4192
|
+
}, []);
|
|
4193
|
+
const closeAllDialogs = useCallback(() => {
|
|
4194
|
+
return setOpenedDialogs([]);
|
|
4195
|
+
}, [openedDialogs]);
|
|
4196
|
+
return /* @__PURE__ */ React25.createElement(
|
|
4197
|
+
BaseDialogContext.Provider,
|
|
4198
|
+
{
|
|
4199
|
+
value: {
|
|
4200
|
+
opened: openedDialogs,
|
|
4201
|
+
isOpened,
|
|
4202
|
+
toggle: toggleDialog,
|
|
4203
|
+
open: openDialog,
|
|
4204
|
+
closeAll: closeAllDialogs,
|
|
4205
|
+
close: closeDialog
|
|
4206
|
+
}
|
|
4207
|
+
},
|
|
4208
|
+
props.children
|
|
4209
|
+
);
|
|
4210
|
+
};
|
|
4211
|
+
|
|
4212
|
+
// src/components/BaseDialog/BaseDialogInstanceContext.tsx
|
|
4213
|
+
import React26 from "react";
|
|
4214
|
+
import { createContext as createContext2 } from "react";
|
|
4215
|
+
var BaseDialogInstanceContext = createContext2(
|
|
4216
|
+
{}
|
|
4217
|
+
);
|
|
4218
|
+
var BaseDialogInstanceProvider = (props) => {
|
|
4219
|
+
const actions = useBaseDialog();
|
|
4220
|
+
return /* @__PURE__ */ React26.createElement(BaseDialogInstanceContext.Provider, { value: { name: props.name, actions } }, props.children);
|
|
4221
|
+
};
|
|
4222
|
+
|
|
4223
|
+
// src/components/BaseDialog/BaseDialogHook.ts
|
|
4224
|
+
function useBaseDialog() {
|
|
4225
|
+
return useContext2(BaseDialogContext);
|
|
4226
|
+
}
|
|
4227
|
+
function useBaseDialogInstance() {
|
|
4228
|
+
return useContext2(BaseDialogInstanceContext);
|
|
4229
|
+
}
|
|
4230
|
+
|
|
4231
|
+
// src/components/BaseDialog/BaseDialog.tsx
|
|
4232
|
+
import { Box as Box8, Button as Button4 } from "@mui/material";
|
|
4233
|
+
|
|
4234
|
+
// src/components/BaseDialog/BaseDialogHeader.tsx
|
|
4235
|
+
import React27 from "react";
|
|
4236
|
+
import {
|
|
4237
|
+
IconButton as IconButton4,
|
|
4238
|
+
Stack as Stack3,
|
|
4239
|
+
Typography as Typography4
|
|
4240
|
+
} from "@mui/material";
|
|
4241
|
+
import { MdClose as MdClose2 } from "react-icons/md";
|
|
4242
|
+
var BaseDialogHeader = (_a) => {
|
|
4243
|
+
var _b = _a, {
|
|
4244
|
+
title,
|
|
4245
|
+
onClose,
|
|
4246
|
+
IconButtonProps,
|
|
4247
|
+
TypographyProps: TypographyProps2
|
|
4248
|
+
} = _b, props = __objRest(_b, [
|
|
4249
|
+
"title",
|
|
4250
|
+
"onClose",
|
|
4251
|
+
"IconButtonProps",
|
|
4252
|
+
"TypographyProps"
|
|
4253
|
+
]);
|
|
4254
|
+
const { name } = useBaseDialogInstance();
|
|
4255
|
+
const { close: closeDialog } = useBaseDialog();
|
|
4256
|
+
function handleClose() {
|
|
4257
|
+
if (onClose)
|
|
4258
|
+
return onClose();
|
|
4259
|
+
closeDialog(name);
|
|
4260
|
+
}
|
|
4261
|
+
return /* @__PURE__ */ React27.createElement(
|
|
4262
|
+
Stack3,
|
|
4263
|
+
__spreadValues({
|
|
4264
|
+
direction: "row",
|
|
4265
|
+
alignItems: "center",
|
|
4266
|
+
justifyContent: "space-between",
|
|
4267
|
+
px: 2,
|
|
4268
|
+
my: 1
|
|
4269
|
+
}, props),
|
|
4270
|
+
/* @__PURE__ */ React27.createElement(Typography4, __spreadValues({ variant: "h6", fontWeight: "bold" }, TypographyProps2), title),
|
|
4271
|
+
/* @__PURE__ */ React27.createElement(IconButton4, __spreadProps(__spreadValues({}, IconButtonProps), { onClick: handleClose }), /* @__PURE__ */ React27.createElement(MdClose2, null))
|
|
4272
|
+
);
|
|
4273
|
+
};
|
|
4274
|
+
|
|
4275
|
+
// src/components/BaseDialog/BaseDialog.tsx
|
|
4276
|
+
var BaseDialogContainer = (_a) => {
|
|
4277
|
+
var _b = _a, {
|
|
4278
|
+
children
|
|
4279
|
+
} = _b, rest = __objRest(_b, [
|
|
4280
|
+
"children"
|
|
4281
|
+
]);
|
|
4282
|
+
const { name } = useBaseDialogInstance();
|
|
4283
|
+
const { isOpened, close: closeDialog } = useBaseDialog();
|
|
4284
|
+
return /* @__PURE__ */ React28.createElement(Modal, __spreadValues({ open: isOpened(name), onClose: () => closeDialog(name) }, rest), children instanceof Function ? children({ close: () => closeDialog(name) }) : children);
|
|
4285
|
+
};
|
|
4286
|
+
var BaseDialogBody = (props) => {
|
|
4287
|
+
return /* @__PURE__ */ React28.createElement(Box8, __spreadValues({ px: 2, pb: 2, width: "100vw", maxWidth: 650 }, props), props.children);
|
|
4288
|
+
};
|
|
4289
|
+
var BaseDialogTrigger = (_a) => {
|
|
4290
|
+
var _b = _a, {
|
|
4291
|
+
name,
|
|
4292
|
+
onClick
|
|
4293
|
+
} = _b, props = __objRest(_b, [
|
|
4294
|
+
"name",
|
|
4295
|
+
"onClick"
|
|
4296
|
+
]);
|
|
4297
|
+
const { open } = useBaseDialog();
|
|
4298
|
+
return /* @__PURE__ */ React28.createElement(
|
|
4299
|
+
Button4,
|
|
4300
|
+
__spreadProps(__spreadValues({}, props), {
|
|
4301
|
+
onClick: (...params) => {
|
|
4302
|
+
if (onClick)
|
|
4303
|
+
onClick(...params);
|
|
4304
|
+
open(name);
|
|
4305
|
+
}
|
|
4306
|
+
}),
|
|
4307
|
+
props.children
|
|
4308
|
+
);
|
|
4309
|
+
};
|
|
4310
|
+
var BaseDialogCreate = (name = Symbol()) => {
|
|
4311
|
+
return {
|
|
4312
|
+
name,
|
|
4313
|
+
Trigger: (props) => /* @__PURE__ */ React28.createElement(BaseDialogTrigger, __spreadValues({ name }, props)),
|
|
4314
|
+
Root: (props) => /* @__PURE__ */ React28.createElement(BaseDialogInstanceProvider, __spreadValues({ name }, props)),
|
|
4315
|
+
Container: BaseDialogContainer,
|
|
4316
|
+
Header: BaseDialogHeader,
|
|
4317
|
+
Body: BaseDialogBody
|
|
4318
|
+
};
|
|
4319
|
+
};
|
|
4320
|
+
var BaseDialog = {
|
|
4321
|
+
Create: BaseDialogCreate,
|
|
4322
|
+
Trigger: BaseDialogTrigger,
|
|
4323
|
+
Provider: BaseDialogProvider,
|
|
4324
|
+
Root: BaseDialogInstanceProvider,
|
|
4325
|
+
Container: BaseDialogContainer,
|
|
4326
|
+
Header: BaseDialogHeader,
|
|
4327
|
+
Body: BaseDialogBody
|
|
4328
|
+
};
|
|
4329
|
+
|
|
4160
4330
|
// src/errors/HttpError.ts
|
|
4161
4331
|
var HttpError = class extends Error {
|
|
4162
4332
|
constructor(status, message) {
|
|
@@ -4270,21 +4440,21 @@ var ApiHelper = class _ApiHelper {
|
|
|
4270
4440
|
};
|
|
4271
4441
|
|
|
4272
4442
|
// src/hooks/useFormHelper.ts
|
|
4273
|
-
import { useCallback as
|
|
4443
|
+
import { useCallback as useCallback4, useContext as useContext4, useEffect as useEffect4, useRef as useRef4 } from "react";
|
|
4274
4444
|
|
|
4275
4445
|
// src/hooks/useAlert.ts
|
|
4276
|
-
import { useContext as
|
|
4446
|
+
import { useContext as useContext3 } from "react";
|
|
4277
4447
|
|
|
4278
4448
|
// src/contexts/AlertContext.tsx
|
|
4279
|
-
import
|
|
4280
|
-
import { createContext, useState as
|
|
4449
|
+
import React30, { useCallback as useCallback2 } from "react";
|
|
4450
|
+
import { createContext as createContext3, useState as useState6 } from "react";
|
|
4281
4451
|
|
|
4282
4452
|
// src/components/Toast/index.tsx
|
|
4283
|
-
import
|
|
4284
|
-
import { Alert, IconButton as
|
|
4285
|
-
import { MdClose as
|
|
4453
|
+
import React29 from "react";
|
|
4454
|
+
import { Alert, IconButton as IconButton5, Snackbar } from "@mui/material";
|
|
4455
|
+
import { MdClose as MdClose3 } from "react-icons/md";
|
|
4286
4456
|
var Toast = ({ open, onClose, severity, message }) => {
|
|
4287
|
-
return /* @__PURE__ */
|
|
4457
|
+
return /* @__PURE__ */ React29.createElement(React29.Fragment, null, /* @__PURE__ */ React29.createElement(
|
|
4288
4458
|
Snackbar,
|
|
4289
4459
|
{
|
|
4290
4460
|
open,
|
|
@@ -4293,20 +4463,20 @@ var Toast = ({ open, onClose, severity, message }) => {
|
|
|
4293
4463
|
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
4294
4464
|
sx: { zIndex: 99999999 }
|
|
4295
4465
|
},
|
|
4296
|
-
/* @__PURE__ */
|
|
4466
|
+
/* @__PURE__ */ React29.createElement(
|
|
4297
4467
|
Alert,
|
|
4298
4468
|
{
|
|
4299
4469
|
severity,
|
|
4300
4470
|
elevation: 2,
|
|
4301
|
-
action: /* @__PURE__ */
|
|
4302
|
-
|
|
4471
|
+
action: /* @__PURE__ */ React29.createElement(
|
|
4472
|
+
IconButton5,
|
|
4303
4473
|
{
|
|
4304
4474
|
"aria-label": "close",
|
|
4305
4475
|
color: "inherit",
|
|
4306
4476
|
size: "small",
|
|
4307
4477
|
onClick: onClose
|
|
4308
4478
|
},
|
|
4309
|
-
/* @__PURE__ */
|
|
4479
|
+
/* @__PURE__ */ React29.createElement(MdClose3, { fontSize: "inherit" })
|
|
4310
4480
|
)
|
|
4311
4481
|
},
|
|
4312
4482
|
message
|
|
@@ -4315,12 +4485,12 @@ var Toast = ({ open, onClose, severity, message }) => {
|
|
|
4315
4485
|
};
|
|
4316
4486
|
|
|
4317
4487
|
// src/contexts/AlertContext.tsx
|
|
4318
|
-
var AlertContext =
|
|
4488
|
+
var AlertContext = createContext3({});
|
|
4319
4489
|
var AlertProvider = ({ children }) => {
|
|
4320
|
-
const [severity, setSeverity] =
|
|
4321
|
-
const [message, setMessage] =
|
|
4322
|
-
const [isVisible, setIsVisible] =
|
|
4323
|
-
const createAlert =
|
|
4490
|
+
const [severity, setSeverity] = useState6("info");
|
|
4491
|
+
const [message, setMessage] = useState6("");
|
|
4492
|
+
const [isVisible, setIsVisible] = useState6(false);
|
|
4493
|
+
const createAlert = useCallback2(
|
|
4324
4494
|
(newMessage, severity2) => {
|
|
4325
4495
|
setMessage(newMessage);
|
|
4326
4496
|
setSeverity(severity2);
|
|
@@ -4328,10 +4498,10 @@ var AlertProvider = ({ children }) => {
|
|
|
4328
4498
|
},
|
|
4329
4499
|
[]
|
|
4330
4500
|
);
|
|
4331
|
-
const onCloseToast =
|
|
4501
|
+
const onCloseToast = useCallback2(() => {
|
|
4332
4502
|
setIsVisible(false);
|
|
4333
4503
|
}, []);
|
|
4334
|
-
return /* @__PURE__ */
|
|
4504
|
+
return /* @__PURE__ */ React30.createElement(AlertContext.Provider, { value: { createAlert } }, children, /* @__PURE__ */ React30.createElement(
|
|
4335
4505
|
Toast,
|
|
4336
4506
|
{
|
|
4337
4507
|
open: isVisible,
|
|
@@ -4344,15 +4514,15 @@ var AlertProvider = ({ children }) => {
|
|
|
4344
4514
|
|
|
4345
4515
|
// src/hooks/useAlert.ts
|
|
4346
4516
|
var useAlert = () => {
|
|
4347
|
-
return
|
|
4517
|
+
return useContext3(AlertContext);
|
|
4348
4518
|
};
|
|
4349
4519
|
|
|
4350
4520
|
// src/hooks/useLoading.ts
|
|
4351
|
-
import { useCallback as
|
|
4521
|
+
import { useCallback as useCallback3, useState as useState7 } from "react";
|
|
4352
4522
|
function useLoading() {
|
|
4353
|
-
const [state, setState] =
|
|
4354
|
-
const isLoading =
|
|
4355
|
-
const setLoading =
|
|
4523
|
+
const [state, setState] = useState7([]);
|
|
4524
|
+
const isLoading = useCallback3((prop) => state.includes(prop), [state]);
|
|
4525
|
+
const setLoading = useCallback3((prop, remove) => {
|
|
4356
4526
|
if (remove)
|
|
4357
4527
|
setState((prevState) => prevState.filter((state2) => state2 !== prop));
|
|
4358
4528
|
else
|
|
@@ -4362,22 +4532,22 @@ function useLoading() {
|
|
|
4362
4532
|
}
|
|
4363
4533
|
|
|
4364
4534
|
// src/contexts/FormHelperProvider.tsx
|
|
4365
|
-
import
|
|
4366
|
-
import { createContext as
|
|
4367
|
-
var FormHelperContext =
|
|
4535
|
+
import React31 from "react";
|
|
4536
|
+
import { createContext as createContext4 } from "react";
|
|
4537
|
+
var FormHelperContext = createContext4({});
|
|
4368
4538
|
var FormHelperProvider = ({ formatErrorMessage, api, children }) => {
|
|
4369
|
-
return /* @__PURE__ */
|
|
4539
|
+
return /* @__PURE__ */ React31.createElement(FormHelperContext.Provider, { value: { formatErrorMessage, api } }, children);
|
|
4370
4540
|
};
|
|
4371
4541
|
|
|
4372
4542
|
// src/hooks/useFormHelper.ts
|
|
4373
4543
|
function useFormHelper() {
|
|
4374
4544
|
const alertProps = useAlert();
|
|
4375
4545
|
const loadingProps = useLoading();
|
|
4376
|
-
const { api, formatErrorMessage } =
|
|
4546
|
+
const { api, formatErrorMessage } = useContext4(FormHelperContext);
|
|
4377
4547
|
const { createAlert } = alertProps;
|
|
4378
4548
|
const { setLoading } = loadingProps;
|
|
4379
4549
|
const sourceRef = useRef4(new AbortController());
|
|
4380
|
-
const onSubmitWrapper =
|
|
4550
|
+
const onSubmitWrapper = useCallback4(
|
|
4381
4551
|
(fn, { name }) => {
|
|
4382
4552
|
return (fields, methods) => __async(this, null, function* () {
|
|
4383
4553
|
const LOADING_NAME = name;
|
|
@@ -4393,7 +4563,7 @@ function useFormHelper() {
|
|
|
4393
4563
|
},
|
|
4394
4564
|
[setLoading]
|
|
4395
4565
|
);
|
|
4396
|
-
const onRequestWrapper =
|
|
4566
|
+
const onRequestWrapper = useCallback4(
|
|
4397
4567
|
(fn, { name }) => {
|
|
4398
4568
|
return (...params) => __async(this, null, function* () {
|
|
4399
4569
|
const LOADING_NAME = name;
|
|
@@ -4421,7 +4591,7 @@ function useFormHelper() {
|
|
|
4421
4591
|
},
|
|
4422
4592
|
[setLoading, api]
|
|
4423
4593
|
);
|
|
4424
|
-
const errorHandler =
|
|
4594
|
+
const errorHandler = useCallback4(
|
|
4425
4595
|
(error, callback) => {
|
|
4426
4596
|
if ((error == null ? void 0 : error.message) === "cancel.navigation")
|
|
4427
4597
|
return;
|
|
@@ -4727,11 +4897,11 @@ var AuthHelper = class {
|
|
|
4727
4897
|
};
|
|
4728
4898
|
|
|
4729
4899
|
// src/hooks/useGrid.ts
|
|
4730
|
-
import { useCallback as
|
|
4900
|
+
import { useCallback as useCallback6, useEffect as useEffect5, useMemo as useMemo3, useState as useState9 } from "react";
|
|
4731
4901
|
|
|
4732
4902
|
// src/hooks/useFilter.ts
|
|
4733
4903
|
import moment2 from "moment";
|
|
4734
|
-
import { useCallback as
|
|
4904
|
+
import { useCallback as useCallback5, useState as useState8 } from "react";
|
|
4735
4905
|
|
|
4736
4906
|
// src/components/utils/getObjectValue.ts
|
|
4737
4907
|
function getObjectValue(obj) {
|
|
@@ -4746,11 +4916,11 @@ function getObjectValue(obj) {
|
|
|
4746
4916
|
|
|
4747
4917
|
// src/hooks/useFilter.ts
|
|
4748
4918
|
function useFilter(props = { defaultFilters: [] }) {
|
|
4749
|
-
const [selectedFilters, setSelectedFilters] =
|
|
4919
|
+
const [selectedFilters, setSelectedFilters] = useState8(() => {
|
|
4750
4920
|
const { defaultFilters } = props;
|
|
4751
4921
|
return defaultFilters || [];
|
|
4752
4922
|
});
|
|
4753
|
-
const filterBy =
|
|
4923
|
+
const filterBy = useCallback5((newFilter) => {
|
|
4754
4924
|
const propToCompare = (newFilter == null ? void 0 : newFilter.id) ? "id" : "prop";
|
|
4755
4925
|
function removeRepeatedFilters(filter) {
|
|
4756
4926
|
return filter[propToCompare] !== newFilter[propToCompare];
|
|
@@ -4760,7 +4930,7 @@ function useFilter(props = { defaultFilters: [] }) {
|
|
|
4760
4930
|
newFilter
|
|
4761
4931
|
]);
|
|
4762
4932
|
}, []);
|
|
4763
|
-
const removeFilter =
|
|
4933
|
+
const removeFilter = useCallback5(
|
|
4764
4934
|
(prop, isId) => {
|
|
4765
4935
|
const propToCompare = isId ? "id" : "prop";
|
|
4766
4936
|
setSelectedFilters(
|
|
@@ -4837,13 +5007,13 @@ function useGrid({
|
|
|
4837
5007
|
defaultCurrentPage,
|
|
4838
5008
|
defaultSortedBy
|
|
4839
5009
|
}) {
|
|
4840
|
-
const [defaultData, setDefaultData] =
|
|
4841
|
-
const [sortedBy, setSortedBy] =
|
|
5010
|
+
const [defaultData, setDefaultData] = useState9(externalDefaultData || []);
|
|
5011
|
+
const [sortedBy, setSortedBy] = useState9(
|
|
4842
5012
|
defaultSortedBy || []
|
|
4843
5013
|
);
|
|
4844
|
-
const [currentPage, setCurrentPage] =
|
|
4845
|
-
const [rowsPerPage, setRowsPerPage] =
|
|
4846
|
-
const toggleSortedDirection =
|
|
5014
|
+
const [currentPage, setCurrentPage] = useState9(defaultCurrentPage || 0);
|
|
5015
|
+
const [rowsPerPage, setRowsPerPage] = useState9(rowsPerPageOptions[0]);
|
|
5016
|
+
const toggleSortedDirection = useCallback6(
|
|
4847
5017
|
(direction) => {
|
|
4848
5018
|
if (direction === "asc")
|
|
4849
5019
|
return "desc";
|
|
@@ -4851,16 +5021,16 @@ function useGrid({
|
|
|
4851
5021
|
},
|
|
4852
5022
|
[]
|
|
4853
5023
|
);
|
|
4854
|
-
const clearSort =
|
|
5024
|
+
const clearSort = useCallback6(() => {
|
|
4855
5025
|
setSortedBy([]);
|
|
4856
5026
|
}, []);
|
|
4857
|
-
const appendSort =
|
|
5027
|
+
const appendSort = useCallback6((prop, direction) => {
|
|
4858
5028
|
setSortedBy((prev) => [...prev, { prop, direction }]);
|
|
4859
5029
|
}, []);
|
|
4860
|
-
const setSort =
|
|
5030
|
+
const setSort = useCallback6((prop, direction) => {
|
|
4861
5031
|
setSortedBy([{ prop, direction }]);
|
|
4862
5032
|
}, []);
|
|
4863
|
-
const onSortBy =
|
|
5033
|
+
const onSortBy = useCallback6(
|
|
4864
5034
|
(prop) => {
|
|
4865
5035
|
if (!prop)
|
|
4866
5036
|
return;
|
|
@@ -4887,10 +5057,10 @@ function useGrid({
|
|
|
4887
5057
|
},
|
|
4888
5058
|
[toggleSortedDirection, sortedBy]
|
|
4889
5059
|
);
|
|
4890
|
-
const set =
|
|
5060
|
+
const set = useCallback6((data) => {
|
|
4891
5061
|
setDefaultData(data);
|
|
4892
5062
|
}, []);
|
|
4893
|
-
const sortData =
|
|
5063
|
+
const sortData = useCallback6(
|
|
4894
5064
|
(data) => {
|
|
4895
5065
|
if (sortedBy.length > 0) {
|
|
4896
5066
|
const symbolDir = {
|
|
@@ -4913,7 +5083,7 @@ function useGrid({
|
|
|
4913
5083
|
return;
|
|
4914
5084
|
setCurrentPage(pageNumber);
|
|
4915
5085
|
};
|
|
4916
|
-
const onChangeRowsPerPage =
|
|
5086
|
+
const onChangeRowsPerPage = useCallback6(
|
|
4917
5087
|
(rows) => {
|
|
4918
5088
|
let totalNumberOfPages2 = Math.round(filteredData.length / rows) - 1;
|
|
4919
5089
|
totalNumberOfPages2 = totalNumberOfPages2 <= 0 ? 0 : 1;
|
|
@@ -5009,7 +5179,7 @@ function createSearch(options) {
|
|
|
5009
5179
|
}
|
|
5010
5180
|
|
|
5011
5181
|
// src/hooks/useAsyncGrid.ts
|
|
5012
|
-
import { useCallback as
|
|
5182
|
+
import { useCallback as useCallback7, useEffect as useEffect6, useState as useState10 } from "react";
|
|
5013
5183
|
function useAsyncGrid({
|
|
5014
5184
|
columns,
|
|
5015
5185
|
filters = [],
|
|
@@ -5022,16 +5192,16 @@ function useAsyncGrid({
|
|
|
5022
5192
|
defaultCurrentPage,
|
|
5023
5193
|
defaultSortedBy
|
|
5024
5194
|
}) {
|
|
5025
|
-
const [defaultData, setDefaultData] =
|
|
5026
|
-
const [sortedBy, setSortedBy] =
|
|
5195
|
+
const [defaultData, setDefaultData] = useState10(externalDefaultData || []);
|
|
5196
|
+
const [sortedBy, setSortedBy] = useState10(
|
|
5027
5197
|
defaultSortedBy || []
|
|
5028
5198
|
);
|
|
5029
|
-
const [totalNumberOfItems, setTotalNumberOfItems] =
|
|
5030
|
-
const [isLoading, setIsLoading] =
|
|
5031
|
-
const [currentPage, setCurrentPage] =
|
|
5032
|
-
const [rowsPerPage, setRowsPerPage] =
|
|
5199
|
+
const [totalNumberOfItems, setTotalNumberOfItems] = useState10(0);
|
|
5200
|
+
const [isLoading, setIsLoading] = useState10(false);
|
|
5201
|
+
const [currentPage, setCurrentPage] = useState10(defaultCurrentPage || 0);
|
|
5202
|
+
const [rowsPerPage, setRowsPerPage] = useState10(rowsPerPageOptions[0]);
|
|
5033
5203
|
const totalNumberOfPages = Math.ceil(totalNumberOfItems / rowsPerPage) - 1;
|
|
5034
|
-
const toggleSortedDirection =
|
|
5204
|
+
const toggleSortedDirection = useCallback7(
|
|
5035
5205
|
(direction) => {
|
|
5036
5206
|
if (direction === "asc")
|
|
5037
5207
|
return "desc";
|
|
@@ -5039,10 +5209,10 @@ function useAsyncGrid({
|
|
|
5039
5209
|
},
|
|
5040
5210
|
[]
|
|
5041
5211
|
);
|
|
5042
|
-
const setSort =
|
|
5212
|
+
const setSort = useCallback7((prop, direction) => {
|
|
5043
5213
|
setSortedBy((prev) => [...prev, { prop, direction }]);
|
|
5044
5214
|
}, []);
|
|
5045
|
-
const onSortBy =
|
|
5215
|
+
const onSortBy = useCallback7(
|
|
5046
5216
|
(prop) => __async(this, null, function* () {
|
|
5047
5217
|
if (!prop)
|
|
5048
5218
|
return;
|
|
@@ -5072,10 +5242,10 @@ function useAsyncGrid({
|
|
|
5072
5242
|
}),
|
|
5073
5243
|
[sortedBy, toggleSortedDirection, rowsPerPage, currentPage]
|
|
5074
5244
|
);
|
|
5075
|
-
const set =
|
|
5245
|
+
const set = useCallback7((data) => {
|
|
5076
5246
|
setDefaultData(data);
|
|
5077
5247
|
}, []);
|
|
5078
|
-
const baseRequest =
|
|
5248
|
+
const baseRequest = useCallback7(
|
|
5079
5249
|
(_0) => __async(this, [_0], function* ({
|
|
5080
5250
|
page,
|
|
5081
5251
|
search: search2,
|
|
@@ -5105,7 +5275,7 @@ function useAsyncGrid({
|
|
|
5105
5275
|
}),
|
|
5106
5276
|
[axiosInstance, url]
|
|
5107
5277
|
);
|
|
5108
|
-
const updateGridContent =
|
|
5278
|
+
const updateGridContent = useCallback7(
|
|
5109
5279
|
(_0) => __async(this, [_0], function* ({
|
|
5110
5280
|
page,
|
|
5111
5281
|
sortedBy: sortedBy2,
|
|
@@ -5131,7 +5301,7 @@ function useAsyncGrid({
|
|
|
5131
5301
|
}),
|
|
5132
5302
|
[set, search, filters, onRequest, baseRequest]
|
|
5133
5303
|
);
|
|
5134
|
-
const onPageChange =
|
|
5304
|
+
const onPageChange = useCallback7(
|
|
5135
5305
|
(pageNumber) => {
|
|
5136
5306
|
if (pageNumber < 0)
|
|
5137
5307
|
return;
|
|
@@ -5141,7 +5311,7 @@ function useAsyncGrid({
|
|
|
5141
5311
|
},
|
|
5142
5312
|
[updateGridContent, totalNumberOfPages, sortedBy, rowsPerPage]
|
|
5143
5313
|
);
|
|
5144
|
-
const onChangeRowsPerPage =
|
|
5314
|
+
const onChangeRowsPerPage = useCallback7(
|
|
5145
5315
|
(rows) => {
|
|
5146
5316
|
let totalNumberOfPages2 = Math.round(totalNumberOfItems / rows) - 1;
|
|
5147
5317
|
totalNumberOfPages2 = totalNumberOfPages2 <= 0 ? 0 : 1;
|
|
@@ -5194,15 +5364,15 @@ function useEvent(event, handler, passive = false) {
|
|
|
5194
5364
|
}
|
|
5195
5365
|
|
|
5196
5366
|
// src/contexts/AuthContext.tsx
|
|
5197
|
-
import
|
|
5367
|
+
import React32, { useCallback as useCallback8 } from "react";
|
|
5198
5368
|
import {
|
|
5199
|
-
createContext as
|
|
5369
|
+
createContext as createContext5,
|
|
5200
5370
|
useEffect as useEffect8,
|
|
5201
|
-
useState as
|
|
5371
|
+
useState as useState11
|
|
5202
5372
|
} from "react";
|
|
5203
5373
|
import { parseCookies as parseCookies2 } from "nookies";
|
|
5204
5374
|
function createAuthContext() {
|
|
5205
|
-
return
|
|
5375
|
+
return createContext5({});
|
|
5206
5376
|
}
|
|
5207
5377
|
function CreateAuthProvider({
|
|
5208
5378
|
api,
|
|
@@ -5210,10 +5380,10 @@ function CreateAuthProvider({
|
|
|
5210
5380
|
sessionTokenName,
|
|
5211
5381
|
Provider
|
|
5212
5382
|
}) {
|
|
5213
|
-
const [user, setUser] =
|
|
5214
|
-
const [status, setStatus] =
|
|
5383
|
+
const [user, setUser] = useState11();
|
|
5384
|
+
const [status, setStatus] = useState11("unauthenticated");
|
|
5215
5385
|
const { createAlert } = useAlert();
|
|
5216
|
-
const signIn =
|
|
5386
|
+
const signIn = useCallback8(
|
|
5217
5387
|
(_0) => __async(this, [_0], function* ({ email, password }) {
|
|
5218
5388
|
var _a, _b;
|
|
5219
5389
|
setStatus("loading");
|
|
@@ -5236,7 +5406,7 @@ function CreateAuthProvider({
|
|
|
5236
5406
|
}),
|
|
5237
5407
|
[createAlert, api]
|
|
5238
5408
|
);
|
|
5239
|
-
const ClientSignOut =
|
|
5409
|
+
const ClientSignOut = useCallback8(() => __async(this, null, function* () {
|
|
5240
5410
|
yield api.get("/auth/logout");
|
|
5241
5411
|
setUser(void 0);
|
|
5242
5412
|
}), [api]);
|
|
@@ -5252,7 +5422,7 @@ function CreateAuthProvider({
|
|
|
5252
5422
|
});
|
|
5253
5423
|
}
|
|
5254
5424
|
}, [api, sessionTokenName]);
|
|
5255
|
-
return /* @__PURE__ */
|
|
5425
|
+
return /* @__PURE__ */ React32.createElement(
|
|
5256
5426
|
Provider,
|
|
5257
5427
|
{
|
|
5258
5428
|
value: {
|
|
@@ -5271,6 +5441,11 @@ export {
|
|
|
5271
5441
|
ApiHelper,
|
|
5272
5442
|
AuthHelper,
|
|
5273
5443
|
Autocomplete2 as Autocomplete,
|
|
5444
|
+
BaseDialog,
|
|
5445
|
+
BaseDialogBody,
|
|
5446
|
+
BaseDialogContainer,
|
|
5447
|
+
BaseDialogCreate,
|
|
5448
|
+
BaseDialogTrigger,
|
|
5274
5449
|
BaseGrid,
|
|
5275
5450
|
BaseGridAutoRows,
|
|
5276
5451
|
Checkbox,
|
|
@@ -5301,6 +5476,8 @@ export {
|
|
|
5301
5476
|
getTabProps,
|
|
5302
5477
|
useAlert,
|
|
5303
5478
|
useAsyncGrid,
|
|
5479
|
+
useBaseDialog,
|
|
5480
|
+
useBaseDialogInstance,
|
|
5304
5481
|
useEvent,
|
|
5305
5482
|
useFilter,
|
|
5306
5483
|
useFormHelper,
|