@zydon/common 2.9.15 → 2.9.17
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/README.md +5 -0
- package/dist/{chunk-CA33LHNH.js → chunk-3753JOQM.js} +2 -2
- package/dist/{chunk-OW5SR67O.js → chunk-3KHPM6SJ.js} +2 -2
- package/dist/{chunk-AALUUWKM.js → chunk-4QA5VA7S.js} +2 -2
- package/dist/{chunk-5FL2EU6H.js → chunk-5I2KKFHV.js} +2 -2
- package/dist/{chunk-3CNKWBWK.js → chunk-5LHW3X5H.js} +3 -3
- package/dist/{chunk-BOPJPHSC.js → chunk-7VHRKBKI.js} +2 -2
- package/dist/chunk-BT6L5NSF.js +18 -0
- package/dist/chunk-BT6L5NSF.js.map +1 -0
- package/dist/{chunk-COBCXMWR.js → chunk-GH2RJOIG.js} +3 -3
- package/dist/{chunk-YSQ5AYHV.js → chunk-JGASCDBR.js} +1 -1
- package/dist/{chunk-NWT5TUJO.js → chunk-JM3SE72J.js} +2 -2
- package/dist/{chunk-65F2BAYR.js → chunk-KCJERCNT.js} +2 -2
- package/dist/{chunk-2QOUWCI5.js → chunk-KWHHEUVE.js} +2 -2
- package/dist/{chunk-SJUOSWUQ.js → chunk-MUEZOZTN.js} +2 -2
- package/dist/{chunk-25BMKLRC.js → chunk-NHRFUAK4.js} +2 -2
- package/dist/{chunk-T3RP2QXG.js → chunk-PVRFBHVB.js} +2 -2
- package/dist/{chunk-JYG5DKR3.js → chunk-T745PFSO.js} +2 -2
- package/dist/{chunk-F4DIC4XM.js → chunk-U344HYZP.js} +2 -2
- package/dist/{chunk-Q64RVUSF.js → chunk-VIOAOJYO.js} +6 -6
- package/dist/{chunk-GWHI4DH5.js → chunk-VTWYBXPN.js} +2 -2
- package/dist/{chunk-Q2D3PURH.js → chunk-XO2DW5UL.js} +2 -2
- package/dist/{chunk-7DG6667M.js → chunk-Y5W727NP.js} +2 -2
- package/dist/{chunk-YIUCRVF5.js → chunk-YDU3ZCS7.js} +2 -2
- package/dist/{chunk-DAEF3QH3.js → chunk-YKOO75F5.js} +4 -4
- package/dist/components/ActionButton/index.js +2 -2
- package/dist/components/Analytics/OverviewAnalytics/index.js +10 -10
- package/dist/components/Analytics/PartnerAnalysis/index.js +8 -8
- package/dist/components/Analytics/index.js +6 -6
- package/dist/components/Autocomplete/index.js +2 -2
- package/dist/components/AvatarButton/index.js +4 -4
- package/dist/components/BuilderLayout/index.js +2 -2
- package/dist/components/BuilderSidebar/index.js +1 -1
- package/dist/components/BulkEditModal/index.d.ts +22 -1
- package/dist/components/BulkEditModal/index.js +12 -12
- package/dist/components/BulkEditModal/index.js.map +1 -1
- package/dist/components/CardBrand/index.js +1 -1
- package/dist/components/Common/index.js +3 -3
- package/dist/components/CopyButton/index.js +2 -2
- package/dist/components/DataCards/index.js +1 -1
- package/dist/components/DataGrid/index.js +2 -2
- package/dist/components/DataView/index.js +5 -5
- package/dist/components/DragButton/index.js +2 -2
- package/dist/components/Drawer/index.js +2 -2
- package/dist/components/DynamicDataView/index.js +10 -10
- package/dist/components/EasyCropModal/index.js +3 -3
- package/dist/components/Error/index.js +1 -1
- package/dist/components/ExpandableGroup/index.js +1 -1
- package/dist/components/FileUpload/index.js +7 -7
- package/dist/components/Filters/index.js +3 -3
- package/dist/components/FrameSkeleton/index.js +1 -1
- package/dist/components/HelpButton/index.js +2 -2
- package/dist/components/Icon/index.js +1 -1
- package/dist/components/IconButton/index.js +2 -2
- package/dist/components/ImageCropModal/index.js +2 -2
- package/dist/components/Incrementer/index.js +2 -2
- package/dist/components/InfoCircle/index.js +2 -2
- package/dist/components/ListBundles/index.js +2 -2
- package/dist/components/MenuItem/index.js +1 -1
- package/dist/components/Modal/index.js +2 -2
- package/dist/components/MoreMenu/index.js +1 -1
- package/dist/components/NotFound/index.js +1 -1
- package/dist/components/PasswordRules/index.js +1 -1
- package/dist/components/PopoverSelect/index.js +1 -1
- package/dist/components/SearchInput/index.js +2 -2
- package/dist/components/SelectList/index.js +4 -4
- package/dist/components/SelectableCards/index.js +3 -3
- package/dist/components/SeoPreview/index.js +1 -1
- package/dist/components/StateDisplay/index.js +2 -2
- package/dist/components/StepUpDialog/index.js +1 -1
- package/dist/components/Steps/index.js +1 -1
- package/dist/components/StyledTab/index.js +1 -1
- package/dist/components/SwapList/index.js +2 -2
- package/dist/components/ToggleTheme/index.js +2 -2
- package/dist/components/WebhookCard/index.js +1 -1
- package/dist/components/carousel/index.js +2 -2
- package/dist/components/form/Address/index.js +3 -3
- package/dist/components/form/Autocomplete/index.js +3 -3
- package/dist/components/form/FileUpload/index.js +7 -7
- package/dist/components/form/Incrementer/index.js +2 -2
- package/dist/components/form/Password/index.js +1 -1
- package/dist/components/form/SelectList/index.js +4 -4
- package/dist/components/form/SelectableCards/index.js +3 -3
- package/dist/components/form/Webhook/index.js +4 -4
- package/dist/components/lightbox/index.js +1 -1
- package/dist/components/table/index.js +2 -2
- package/dist/contexts/PushNotificationsV2/index.d.ts +67 -0
- package/dist/contexts/PushNotificationsV2/index.js +7 -0
- package/dist/contexts/PushNotificationsV2/index.js.map +1 -0
- package/dist/hooks/useReconciliation.d.ts +11 -0
- package/dist/hooks/useReconciliation.js +6 -0
- package/dist/hooks/useReconciliation.js.map +1 -0
- package/dist/hooks/useThemeToggle.js +2 -2
- package/dist/index.js +2 -2
- package/dist/theme/theme-provider.js +2 -2
- package/dist/utils/buildExportPayload.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-SC6LFS3A.js +0 -18
- package/dist/chunk-SC6LFS3A.js.map +0 -1
- /package/dist/{chunk-CA33LHNH.js.map → chunk-3753JOQM.js.map} +0 -0
- /package/dist/{chunk-OW5SR67O.js.map → chunk-3KHPM6SJ.js.map} +0 -0
- /package/dist/{chunk-AALUUWKM.js.map → chunk-4QA5VA7S.js.map} +0 -0
- /package/dist/{chunk-5FL2EU6H.js.map → chunk-5I2KKFHV.js.map} +0 -0
- /package/dist/{chunk-3CNKWBWK.js.map → chunk-5LHW3X5H.js.map} +0 -0
- /package/dist/{chunk-BOPJPHSC.js.map → chunk-7VHRKBKI.js.map} +0 -0
- /package/dist/{chunk-COBCXMWR.js.map → chunk-GH2RJOIG.js.map} +0 -0
- /package/dist/{chunk-YSQ5AYHV.js.map → chunk-JGASCDBR.js.map} +0 -0
- /package/dist/{chunk-NWT5TUJO.js.map → chunk-JM3SE72J.js.map} +0 -0
- /package/dist/{chunk-65F2BAYR.js.map → chunk-KCJERCNT.js.map} +0 -0
- /package/dist/{chunk-2QOUWCI5.js.map → chunk-KWHHEUVE.js.map} +0 -0
- /package/dist/{chunk-SJUOSWUQ.js.map → chunk-MUEZOZTN.js.map} +0 -0
- /package/dist/{chunk-25BMKLRC.js.map → chunk-NHRFUAK4.js.map} +0 -0
- /package/dist/{chunk-T3RP2QXG.js.map → chunk-PVRFBHVB.js.map} +0 -0
- /package/dist/{chunk-JYG5DKR3.js.map → chunk-T745PFSO.js.map} +0 -0
- /package/dist/{chunk-F4DIC4XM.js.map → chunk-U344HYZP.js.map} +0 -0
- /package/dist/{chunk-Q64RVUSF.js.map → chunk-VIOAOJYO.js.map} +0 -0
- /package/dist/{chunk-GWHI4DH5.js.map → chunk-VTWYBXPN.js.map} +0 -0
- /package/dist/{chunk-Q2D3PURH.js.map → chunk-XO2DW5UL.js.map} +0 -0
- /package/dist/{chunk-7DG6667M.js.map → chunk-Y5W727NP.js.map} +0 -0
- /package/dist/{chunk-YIUCRVF5.js.map → chunk-YDU3ZCS7.js.map} +0 -0
- /package/dist/{chunk-DAEF3QH3.js.map → chunk-YKOO75F5.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as a$3 } from '../../chunk-CO2KQFUN.js';
|
|
2
|
-
import { a as a$1 } from '../../chunk-
|
|
2
|
+
import { a as a$1 } from '../../chunk-JGASCDBR.js';
|
|
3
3
|
import '../../chunk-TPOL2YXC.js';
|
|
4
4
|
import { a as a$2 } from '../../chunk-LQRRMVFN.js';
|
|
5
5
|
import S from '@mui/material/MenuItem';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { a as default } from '../../chunk-
|
|
1
|
+
export { a as default } from '../../chunk-5LHW3X5H.js';
|
|
2
2
|
import '../../chunk-RUABKHIV.js';
|
|
3
|
-
import '../../chunk-
|
|
3
|
+
import '../../chunk-3753JOQM.js';
|
|
4
4
|
import '../../chunk-4F2NKGF6.js';
|
|
5
5
|
import '../../chunk-6U5LS7MP.js';
|
|
6
|
-
import '../../chunk-
|
|
7
|
-
import '../../chunk-
|
|
6
|
+
import '../../chunk-VTWYBXPN.js';
|
|
7
|
+
import '../../chunk-JGASCDBR.js';
|
|
8
8
|
import '../../chunk-TPOL2YXC.js';
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { a as default } from '../../chunk-
|
|
1
|
+
export { a as default } from '../../chunk-GH2RJOIG.js';
|
|
2
2
|
import '../../chunk-6ZSTKYGL.js';
|
|
3
|
-
import '../../chunk-
|
|
3
|
+
import '../../chunk-3753JOQM.js';
|
|
4
4
|
import '../../chunk-4F2NKGF6.js';
|
|
5
5
|
import '../../chunk-NIQW2J3M.js';
|
|
6
6
|
import '../../chunk-F65ZXAGV.js';
|
|
7
|
-
import '../../chunk-
|
|
7
|
+
import '../../chunk-JGASCDBR.js';
|
|
8
8
|
import '../../chunk-TPOL2YXC.js';
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as a$3 } from '../../chunk-YXRL4O4H.js';
|
|
2
2
|
import { a as a$4 } from '../../chunk-BT3FTBTT.js';
|
|
3
3
|
import { a as a$2 } from '../../chunk-XAPSXJZO.js';
|
|
4
|
-
import { a as a$1 } from '../../chunk-
|
|
4
|
+
import { a as a$1 } from '../../chunk-JGASCDBR.js';
|
|
5
5
|
import '../../chunk-TPOL2YXC.js';
|
|
6
6
|
import { a } from '../../chunk-SVX7EWV4.js';
|
|
7
7
|
import '../../chunk-FJBC6QA5.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as a$2 } from '../../chunk-6ZSTKYGL.js';
|
|
2
|
-
import { a } from '../../chunk-
|
|
2
|
+
import { a } from '../../chunk-3753JOQM.js';
|
|
3
3
|
import { a as a$1 } from '../../chunk-4F2NKGF6.js';
|
|
4
4
|
import '../../chunk-NIQW2J3M.js';
|
|
5
5
|
import { a as a$3 } from '../../chunk-F65ZXAGV.js';
|
|
6
|
-
import { a as a$4 } from '../../chunk-
|
|
6
|
+
import { a as a$4 } from '../../chunk-JGASCDBR.js';
|
|
7
7
|
import '../../chunk-TPOL2YXC.js';
|
|
8
8
|
import { useState } from 'react';
|
|
9
9
|
import h from '@mui/material/Checkbox';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { a as default } from '../../chunk-UJMWTYPH.js';
|
|
2
2
|
import '../../chunk-U4I7JPER.js';
|
|
3
|
-
import '../../chunk-
|
|
3
|
+
import '../../chunk-JM3SE72J.js';
|
|
4
4
|
import '../../chunk-373WGZZL.js';
|
|
5
|
+
import '../../chunk-WUFEPE2G.js';
|
|
5
6
|
import '../../chunk-BX2DSNRV.js';
|
|
6
7
|
import '../../chunk-X4F3O7PX.js';
|
|
7
8
|
import '../../chunk-Q2AVS24Z.js';
|
|
8
9
|
import '../../chunk-LNESYSHP.js';
|
|
9
10
|
import '../../chunk-YPL4KIKN.js';
|
|
10
11
|
import '../../chunk-HBOBTNB5.js';
|
|
11
|
-
import '../../chunk-WUFEPE2G.js';
|
|
12
12
|
import '../../chunk-GLRLKFPS.js';
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,7 +2,7 @@ import { d } from '../../chunk-JNDZPNQJ.js';
|
|
|
2
2
|
import { a as a$3 } from '../../chunk-7LBBLVDC.js';
|
|
3
3
|
import { a as a$2 } from '../../chunk-UVPQR2Q2.js';
|
|
4
4
|
import { a } from '../../chunk-CO2KQFUN.js';
|
|
5
|
-
import { a as a$4 } from '../../chunk-
|
|
5
|
+
import { a as a$4 } from '../../chunk-JGASCDBR.js';
|
|
6
6
|
import '../../chunk-TPOL2YXC.js';
|
|
7
7
|
import { a as a$1 } from '../../chunk-LQRRMVFN.js';
|
|
8
8
|
import '../../chunk-GLRLKFPS.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { j as ArrowButton, f as Carousel, g as CarouselArrowBasicButtons, i as CarouselArrowFloatButtons, h as CarouselArrowNumberButtons, k as CarouselDotButtons, l as CarouselProgressBar, c as CarouselSlide, n as CarouselThumb, m as CarouselThumbs, e as StyledContainer, d as StyledRoot, a as carouselBreakpoints, b as carouselClasses, o as useCarousel } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
1
|
+
export { j as ArrowButton, f as Carousel, g as CarouselArrowBasicButtons, i as CarouselArrowFloatButtons, h as CarouselArrowNumberButtons, k as CarouselDotButtons, l as CarouselProgressBar, c as CarouselSlide, n as CarouselThumb, m as CarouselThumbs, e as StyledContainer, d as StyledRoot, a as carouselBreakpoints, b as carouselClasses, o as useCarousel } from '../../chunk-YDU3ZCS7.js';
|
|
2
|
+
import '../../chunk-JGASCDBR.js';
|
|
3
3
|
import '../../chunk-TPOL2YXC.js';
|
|
4
4
|
import '../../chunk-GLRLKFPS.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,9 +2,9 @@ import { a as a$3 } from '../../../chunk-MSCOIJQ5.js';
|
|
|
2
2
|
import { a } from '../../../chunk-X64QHBVQ.js';
|
|
3
3
|
import { a as a$1 } from '../../../chunk-YXRL4O4H.js';
|
|
4
4
|
import '../../../chunk-RTC7H5E5.js';
|
|
5
|
-
import { a as a$2 } from '../../../chunk-
|
|
6
|
-
import '../../../chunk-
|
|
7
|
-
import '../../../chunk-
|
|
5
|
+
import { a as a$2 } from '../../../chunk-T745PFSO.js';
|
|
6
|
+
import '../../../chunk-BT6L5NSF.js';
|
|
7
|
+
import '../../../chunk-JGASCDBR.js';
|
|
8
8
|
import '../../../chunk-TPOL2YXC.js';
|
|
9
9
|
import L from '@mui/material/CircularProgress';
|
|
10
10
|
import g from '@mui/material/InputAdornment';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { a as default } from '../../../chunk-
|
|
2
|
-
import '../../../chunk-
|
|
3
|
-
import '../../../chunk-
|
|
1
|
+
export { a as default } from '../../../chunk-T745PFSO.js';
|
|
2
|
+
import '../../../chunk-BT6L5NSF.js';
|
|
3
|
+
import '../../../chunk-JGASCDBR.js';
|
|
4
4
|
import '../../../chunk-TPOL2YXC.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { x, u, v, w } from '../../../chunk-
|
|
2
|
-
import '../../../chunk-
|
|
3
|
-
import '../../../chunk-
|
|
1
|
+
import { x, u, v, w } from '../../../chunk-VIOAOJYO.js';
|
|
2
|
+
import '../../../chunk-7VHRKBKI.js';
|
|
3
|
+
import '../../../chunk-XO2DW5UL.js';
|
|
4
|
+
import '../../../chunk-KWHHEUVE.js';
|
|
4
5
|
import '../../../chunk-KGLU4CR2.js';
|
|
5
|
-
import '../../../chunk-BOPJPHSC.js';
|
|
6
6
|
import '../../../chunk-OF6623HG.js';
|
|
7
|
-
import '../../../chunk-
|
|
8
|
-
import '../../../chunk-6U5LS7MP.js';
|
|
7
|
+
import '../../../chunk-3KHPM6SJ.js';
|
|
9
8
|
import '../../../chunk-5J35UAV6.js';
|
|
9
|
+
import '../../../chunk-6U5LS7MP.js';
|
|
10
10
|
import '../../../chunk-I3B772WD.js';
|
|
11
|
-
import '../../../chunk-
|
|
11
|
+
import '../../../chunk-JGASCDBR.js';
|
|
12
12
|
import '../../../chunk-TPOL2YXC.js';
|
|
13
13
|
import '../../../chunk-2ZJUGM2S.js';
|
|
14
14
|
import '../../../chunk-SVX7EWV4.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a } from '../../../chunk-
|
|
1
|
+
import { a } from '../../../chunk-MUEZOZTN.js';
|
|
2
2
|
import '../../../chunk-I3HQNMR3.js';
|
|
3
3
|
import '../../../chunk-OF6623HG.js';
|
|
4
|
-
import '../../../chunk-
|
|
4
|
+
import '../../../chunk-JGASCDBR.js';
|
|
5
5
|
import '../../../chunk-TPOL2YXC.js';
|
|
6
6
|
import { useFormContext, Controller } from 'react-hook-form';
|
|
7
7
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a } from '../../../chunk-YXRL4O4H.js';
|
|
2
2
|
import { d } from '../../../chunk-A3QLGMSB.js';
|
|
3
|
-
import { a as a$1 } from '../../../chunk-
|
|
3
|
+
import { a as a$1 } from '../../../chunk-JGASCDBR.js';
|
|
4
4
|
import '../../../chunk-TPOL2YXC.js';
|
|
5
5
|
import { useState } from 'react';
|
|
6
6
|
import { useFormContext } from 'react-hook-form';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a } from '../../../chunk-
|
|
1
|
+
import { a } from '../../../chunk-5LHW3X5H.js';
|
|
2
2
|
import '../../../chunk-RUABKHIV.js';
|
|
3
|
-
import '../../../chunk-
|
|
3
|
+
import '../../../chunk-3753JOQM.js';
|
|
4
4
|
import '../../../chunk-4F2NKGF6.js';
|
|
5
5
|
import '../../../chunk-6U5LS7MP.js';
|
|
6
|
-
import '../../../chunk-
|
|
7
|
-
import '../../../chunk-
|
|
6
|
+
import '../../../chunk-VTWYBXPN.js';
|
|
7
|
+
import '../../../chunk-JGASCDBR.js';
|
|
8
8
|
import '../../../chunk-TPOL2YXC.js';
|
|
9
9
|
import { useFormContext, Controller } from 'react-hook-form';
|
|
10
10
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a } from '../../../chunk-
|
|
1
|
+
import { a } from '../../../chunk-GH2RJOIG.js';
|
|
2
2
|
import '../../../chunk-6ZSTKYGL.js';
|
|
3
|
-
import '../../../chunk-
|
|
3
|
+
import '../../../chunk-3753JOQM.js';
|
|
4
4
|
import '../../../chunk-4F2NKGF6.js';
|
|
5
5
|
import '../../../chunk-NIQW2J3M.js';
|
|
6
6
|
import '../../../chunk-F65ZXAGV.js';
|
|
7
|
-
import '../../../chunk-
|
|
7
|
+
import '../../../chunk-JGASCDBR.js';
|
|
8
8
|
import '../../../chunk-TPOL2YXC.js';
|
|
9
9
|
import { useFormContext, Controller } from 'react-hook-form';
|
|
10
10
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as a$1 } from '../../../chunk-YXRL4O4H.js';
|
|
2
|
-
import { a as a$2 } from '../../../chunk-
|
|
3
|
-
import
|
|
4
|
-
import '../../../chunk-
|
|
5
|
-
import { a } from '../../../chunk-
|
|
2
|
+
import { a as a$2 } from '../../../chunk-T745PFSO.js';
|
|
3
|
+
import '../../../chunk-BT6L5NSF.js';
|
|
4
|
+
import { a as a$3 } from '../../../chunk-VTWYBXPN.js';
|
|
5
|
+
import { a } from '../../../chunk-JGASCDBR.js';
|
|
6
6
|
import '../../../chunk-TPOL2YXC.js';
|
|
7
7
|
import { useCallback, useMemo } from 'react';
|
|
8
8
|
import { useFormContext, useFieldArray } from 'react-hook-form';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
1
|
+
import { a } from '../../chunk-4QA5VA7S.js';
|
|
2
|
+
import '../../chunk-JGASCDBR.js';
|
|
3
3
|
import '../../chunk-TPOL2YXC.js';
|
|
4
4
|
import S from '@mui/material/TableCell';
|
|
5
5
|
import F from '@mui/material/TableRow';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
interface PushMessageV2<TPayload = unknown> {
|
|
5
|
+
id: string;
|
|
6
|
+
topic: string;
|
|
7
|
+
payload: TPayload;
|
|
8
|
+
}
|
|
9
|
+
declare enum MessageStatusV2 {
|
|
10
|
+
DELIVERED = "DELIVERED"
|
|
11
|
+
}
|
|
12
|
+
interface MessageStatusPayloadV2 {
|
|
13
|
+
status: MessageStatusV2;
|
|
14
|
+
}
|
|
15
|
+
interface ClientRegistrationPayloadV2 {
|
|
16
|
+
origin_type: string;
|
|
17
|
+
origin_id: string;
|
|
18
|
+
endpoint?: string;
|
|
19
|
+
auth?: string;
|
|
20
|
+
p256dh?: string;
|
|
21
|
+
}
|
|
22
|
+
interface ClientRegistrationResultV2 {
|
|
23
|
+
id: string;
|
|
24
|
+
}
|
|
25
|
+
declare enum PushChannel {
|
|
26
|
+
WEBPUSH = "WEBPUSH",
|
|
27
|
+
STREAM = "STREAM"
|
|
28
|
+
}
|
|
29
|
+
type PushMessageHandler = (message: PushMessageV2) => void;
|
|
30
|
+
interface PushNotificationApiAdaptersV2 {
|
|
31
|
+
registerClient: (payload: ClientRegistrationPayloadV2) => Promise<ClientRegistrationResultV2>;
|
|
32
|
+
removeClient?: (clientId: string) => Promise<void>;
|
|
33
|
+
subscribeTopicsBatch: (clientId: string, topics: string[]) => Promise<void>;
|
|
34
|
+
unsubscribeTopicsBatch: (clientId: string, topics: string[]) => Promise<void>;
|
|
35
|
+
updateMessageStatus: (messageId: string, status: MessageStatusPayloadV2) => Promise<void>;
|
|
36
|
+
subscribeToStream: (clientId: string, onMessage: PushMessageHandler) => () => void;
|
|
37
|
+
}
|
|
38
|
+
interface PushNotificationV2ProviderProps {
|
|
39
|
+
children: ReactNode;
|
|
40
|
+
originId: string;
|
|
41
|
+
originType: string;
|
|
42
|
+
vapidKey: string;
|
|
43
|
+
serviceWorkerPath?: string;
|
|
44
|
+
serviceWorkerFile?: string;
|
|
45
|
+
apiAdapters: PushNotificationApiAdaptersV2;
|
|
46
|
+
onError?: (error: Error) => void;
|
|
47
|
+
contextKey?: string;
|
|
48
|
+
}
|
|
49
|
+
interface PushNotificationV2ContextData {
|
|
50
|
+
clientId: string | null;
|
|
51
|
+
channel: PushChannel | null;
|
|
52
|
+
isLoading: boolean;
|
|
53
|
+
isRegisterError: boolean;
|
|
54
|
+
newMessageCount: number;
|
|
55
|
+
resetMessageCount: () => void;
|
|
56
|
+
registerClient: () => Promise<string | null>;
|
|
57
|
+
subscribeToTopic: (topic: string) => Promise<void>;
|
|
58
|
+
unsubscribeFromTopic: (topic: string) => Promise<void>;
|
|
59
|
+
subscribeTopicsBatch: (topics: string[]) => Promise<void>;
|
|
60
|
+
unsubscribeTopicsBatch: (topics: string[]) => Promise<void>;
|
|
61
|
+
on: (topic: string, handler: PushMessageHandler) => () => void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare const PushNotificationV2Provider: ({ children, originId, originType, vapidKey, serviceWorkerPath, serviceWorkerFile, apiAdapters, onError, contextKey, }: PushNotificationV2ProviderProps) => react_jsx_runtime.JSX.Element;
|
|
65
|
+
declare function usePushNotificationsV2(): PushNotificationV2ContextData;
|
|
66
|
+
|
|
67
|
+
export { ClientRegistrationPayloadV2, ClientRegistrationResultV2, MessageStatusPayloadV2, MessageStatusV2, PushChannel, PushMessageHandler, PushMessageV2, PushNotificationApiAdaptersV2, PushNotificationV2ContextData, PushNotificationV2Provider, PushNotificationV2ProviderProps, usePushNotificationsV2 };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext, useState, useRef, useCallback, useEffect, useMemo, useContext } from 'react';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
function O(o){let l="=".repeat((4-o.length%4)%4),a=(o+l).replace(/-/g,"+").replace(/_/g,"/"),d=window.atob(a),g=new Uint8Array(d.length);for(let P=0;P<d.length;++P)g[P]=d.charCodeAt(P);return g}async function z({vapidKey:o,serviceWorkerPath:l,serviceWorkerFile:a}){if(!("serviceWorker"in navigator)||!("PushManager"in window))return null;try{if(await Notification.requestPermission()!=="granted")return null;let g=await navigator.serviceWorker.register(`${l}${a}`);return await navigator.serviceWorker.ready,await g.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:O(o)})}catch{return null}}var K=(l=>(l.DELIVERED="DELIVERED",l))(K||{}),$=(a=>(a.WEBPUSH="WEBPUSH",a.STREAM="STREAM",a))($||{});var ee=500,J=createContext(void 0),ce=({children:o,originId:l,originType:a,vapidKey:d,serviceWorkerPath:g="/",serviceWorkerFile:P="service-worker.js",apiAdapters:n,onError:c,contextKey:C})=>{let[r,X]=useState(null),[h,j]=useState(null),[S,E]=useState(!1),[x,w]=useState(!1),[N,T]=useState(0),I=useRef(null),W=useRef(new Set),p=useRef(new Map),B=useRef(!1),D=useRef(void 0),b=useCallback(e=>{if(!e?.id||W.current.has(e.id))return;let t=W.current;if(t.size>=ee){let s=t.values().next().value;s!==void 0&&t.delete(s);}t.add(e.id),T(s=>s+1),p.current.get(e.topic)?.forEach(s=>s(e)),n.updateMessageStatus(e.id,{status:"DELIVERED"}).catch(s=>c?.(s));},[n,c]),y=useCallback(async()=>{E(!0);let e=I.current;try{let t=await z({vapidKey:d,serviceWorkerPath:g,serviceWorkerFile:P}),i=t?.toJSON().keys,s={origin_type:a,origin_id:l,...t?{endpoint:t.endpoint,auth:i?.auth,p256dh:i?.p256dh}:{}},{id:R}=await n.registerClient(s);return X(R),I.current=R,w(!1),j(t?"WEBPUSH":"STREAM"),e&&e!==R&&n.removeClient?.(e).catch(Q=>c?.(Q)),R}catch(t){return w(!0),c?.(t),null}finally{E(!1);}},[n,c,l,a,P,g,d]),k=useCallback(()=>y(),[y]),m=useCallback(async e=>{if(!(!r||e.length===0))try{await n.subscribeTopicsBatch(r,e);}catch(t){c?.(t);}},[n,r,c]),V=useCallback(async e=>{if(!(!r||e.length===0))try{await n.unsubscribeTopicsBatch(r,e);}catch(t){c?.(t);}},[n,r,c]),H=useCallback(e=>m([e]),[m]),A=useCallback(e=>V([e]),[V]),U=useCallback((e,t)=>{let i=p.current.get(e)??new Set;return i.add(t),p.current.set(e,i),()=>{let s=p.current.get(e);s&&(s.delete(t),s.size===0&&p.current.delete(e));}},[]),L=useCallback(()=>{T(0);},[]),_=useRef(y);_.current=y,useEffect(()=>{B.current&&D.current===C||(B.current=!0,D.current=C,_.current());},[C]),useEffect(()=>{if(h!=="WEBPUSH"||!("serviceWorker"in navigator))return;let e=t=>{let i=t.data;!i?.id||i.payload===void 0||b({id:i.id,topic:i.topic??"",payload:i.payload});};return navigator.serviceWorker.addEventListener("message",e),()=>{navigator.serviceWorker.removeEventListener("message",e);}},[h,b]),useEffect(()=>{if(h!=="STREAM"||!r)return;let e=n.subscribeToStream(r,b);return ()=>{e();}},[n,h,r,b]);let F=useMemo(()=>!r||S,[r,S]),G=useMemo(()=>({clientId:r,channel:h,isLoading:F,isRegisterError:x,newMessageCount:N,resetMessageCount:L,registerClient:k,subscribeToTopic:H,unsubscribeFromTopic:A,subscribeTopicsBatch:m,unsubscribeTopicsBatch:V,on:U}),[h,r,F,x,N,U,k,L,H,m,A,V]);return jsx(J.Provider,{value:G,children:o})};function ue(){let o=useContext(J);if(!o)throw new Error("usePushNotificationsV2 precisa estar dentro de PushNotificationV2Provider");return o}
|
|
5
|
+
|
|
6
|
+
export { K as MessageStatusV2, $ as PushChannel, ce as PushNotificationV2Provider, ue as usePushNotificationsV2 };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/contexts/PushNotificationsV2/index.tsx","../../../src/contexts/PushNotificationsV2/urlBase64ToUint8Array.ts","../../../src/contexts/PushNotificationsV2/resolveWebPushSubscription.ts","../../../src/contexts/PushNotificationsV2/types.ts"],"names":["createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","urlBase64ToUint8Array","base64String","padding","base64","rawData","outputArray","i","resolveWebPushSubscription","vapidKey","serviceWorkerPath","serviceWorkerFile","registration","MessageStatusV2","PushChannel","jsx","MAX_PROCESSED_IDS","PushNotificationV2Context","PushNotificationV2Provider","children","originId","originType","apiAdapters","onError","contextKey","clientId","setClientId","channel","setChannel","isRegistering","setIsRegistering","isRegisterError","setIsRegisterError","newMessageCount","setNewMessageCount","clientIdRef","processedIdsRef","topicHandlersRef","hasRegisteredRef","registeredKeyRef","deliver","message","processedIds","oldest","prev","handler","error","performRegistration","previousClientId","subscription","keys","payload","id","registerClient","subscribeTopicsBatch","topics","unsubscribeTopicsBatch","subscribeToTopic","topic","unsubscribeFromTopic","on","handlers","currentHandlers","resetMessageCount","performRegistrationRef","event","data","unsubscribe","isLoading","value","usePushNotificationsV2","context"],"mappings":"AAAA,OACE,iBAAAA,EACA,eAAAC,EACA,cAAAC,EACA,aAAAC,EACA,WAAAC,EACA,UAAAC,EACA,YAAAC,MACK,QCRA,SAASC,EAAsBC,EAAkC,CACtE,IAAMC,EAAU,IAAI,QAAQ,EAAKD,EAAa,OAAS,GAAM,CAAC,EACxDE,GAAUF,EAAeC,GAAS,QAAQ,KAAM,GAAG,EAAE,QAAQ,KAAM,GAAG,EAEtEE,EAAU,OAAO,KAAKD,CAAM,EAC5BE,EAAc,IAAI,WAAWD,EAAQ,MAAM,EACjD,QAASE,EAAI,EAAGA,EAAIF,EAAQ,OAAQ,EAAEE,EACpCD,EAAYC,CAAC,EAAIF,EAAQ,WAAWE,CAAC,EAEvC,OAAOD,CACT,CCFA,eAAsBE,EAA2B,CAC/C,SAAAC,EACA,kBAAAC,EACA,kBAAAC,CACF,EAAuE,CACrE,GAAI,EAAE,kBAAmB,YAAc,EAAE,gBAAiB,QACxD,OAAO,KAGT,GAAI,CAGF,GAFmB,MAAM,aAAa,kBAAkB,IAErC,UACjB,OAAO,KAGT,IAAMC,EAAe,MAAM,UAAU,cAAc,SACjD,GAAGF,IAAoBC,GACzB,EACA,aAAM,UAAU,cAAc,MAEvB,MAAMC,EAAa,YAAY,UAAU,CAC9C,gBAAiB,GACjB,qBAAsBX,EAAsBQ,CAAQ,CACtD,CAAC,CACH,MAAE,CACA,OAAO,IACT,CACF,CC5BO,IAAKI,OACVA,EAAA,UAA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iBAAU,cAAc,iBAAiB,UAAWrB,CAAO,EAEpD,IAAM,CACX,UAAU,cAAc,oBAAoB,UAAWA,CAAO,CAChE,CACF,EAAG,CAAClB,EAASa,CAAO,CAAC,EAErB3C,EAAU,IAAM,CACd,GAAI8B,cAAkC,CAACF,EACrC,OAGF,IAAM0C,EAAc7C,EAAY,kBAAkBG,EAAUe,CAAO,EAEnE,MAAO,IAAM,CACX2B,EAAY,CACd,CACF,EAAG,CAAC7C,EAAaK,EAASF,EAAUe,CAAO,CAAC,EAE5C,IAAM4B,EAAYtE,EAChB,IAAM,CAAC2B,GAAYI,EACnB,CAACJ,EAAUI,CAAa,CAC1B,EAEMwC,EAAuCvE,EAC3C,KAAO,CACL,SAAA2B,EACA,QAAAE,EACA,UAAAyC,EACA,gBAAArC,EACA,gBAAAE,EACA,kBAAA8B,EACA,eAAAV,EACA,iBAAAI,EACA,qBAAAE,EACA,qBAAAL,EACA,uBAAAE,EACA,GAAAI,CACF,GACA,CACEjC,EACAF,EACA2C,EACArC,EACAE,EACA2B,EACAP,EACAU,EACAN,EACAH,EACAK,EACAH,CACF,CACF,EAEA,OACEzC,GAACE,EAA0B,SAA1B,CAAmC,MAAOoD,EACxC,SAAAlD,EACH,CAEJ,EAEO,SAASmD,IAAwD,CACtE,IAAMC,EAAU3E,EAAWqB,CAAyB,EAEpD,GAAI,CAACsD,EACH,MAAM,IAAI,MACR,2EACF,EAGF,OAAOA,CACT","sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { resolveWebPushSubscription } from './resolveWebPushSubscription';\nimport {\n ClientRegistrationPayloadV2,\n MessageStatusV2,\n PushChannel,\n PushMessageHandler,\n PushMessageV2,\n PushNotificationV2ContextData,\n PushNotificationV2ProviderProps,\n} from './types';\n\nconst MAX_PROCESSED_IDS = 500;\n\nconst PushNotificationV2Context = createContext<\n PushNotificationV2ContextData | undefined\n>(undefined);\n\nexport const PushNotificationV2Provider = ({\n children,\n originId,\n originType,\n vapidKey,\n serviceWorkerPath = '/',\n serviceWorkerFile = 'service-worker.js',\n apiAdapters,\n onError,\n contextKey,\n}: PushNotificationV2ProviderProps) => {\n const [clientId, setClientId] = useState<string | null>(null);\n const [channel, setChannel] = useState<PushChannel | null>(null);\n const [isRegistering, setIsRegistering] = useState<boolean>(false);\n const [isRegisterError, setIsRegisterError] = useState<boolean>(false);\n const [newMessageCount, setNewMessageCount] = useState<number>(0);\n\n const clientIdRef = useRef<string | null>(null);\n const processedIdsRef = useRef<Set<string>>(new Set());\n const topicHandlersRef = useRef<Map<string, Set<PushMessageHandler>>>(\n new Map(),\n );\n const hasRegisteredRef = useRef<boolean>(false);\n const registeredKeyRef = useRef<string | undefined>(undefined);\n\n const deliver = useCallback(\n (message: PushMessageV2) => {\n if (!message?.id || processedIdsRef.current.has(message.id)) {\n return;\n }\n\n const processedIds = processedIdsRef.current;\n\n if (processedIds.size >= MAX_PROCESSED_IDS) {\n const oldest = processedIds.values().next().value;\n\n if (oldest !== undefined) {\n processedIds.delete(oldest);\n }\n }\n\n processedIds.add(message.id);\n\n setNewMessageCount(prev => prev + 1);\n\n const handlers = topicHandlersRef.current.get(message.topic);\n handlers?.forEach(handler => handler(message));\n\n apiAdapters\n .updateMessageStatus(message.id, { status: MessageStatusV2.DELIVERED })\n .catch(error => onError?.(error as Error));\n },\n [apiAdapters, onError],\n );\n\n const performRegistration = useCallback(async (): Promise<string | null> => {\n setIsRegistering(true);\n\n const previousClientId = clientIdRef.current;\n\n try {\n const subscription = await resolveWebPushSubscription({\n vapidKey,\n serviceWorkerPath,\n serviceWorkerFile,\n });\n const keys = subscription?.toJSON().keys;\n\n const payload: ClientRegistrationPayloadV2 = {\n origin_type: originType,\n origin_id: originId,\n ...(subscription\n ? {\n endpoint: subscription.endpoint,\n auth: keys?.auth,\n p256dh: keys?.p256dh,\n }\n : {}),\n };\n\n const { id } = await apiAdapters.registerClient(payload);\n\n setClientId(id);\n clientIdRef.current = id;\n setIsRegisterError(false);\n setChannel(subscription ? PushChannel.WEBPUSH : PushChannel.STREAM);\n\n if (previousClientId && previousClientId !== id) {\n void apiAdapters\n .removeClient?.(previousClientId)\n .catch(error => onError?.(error as Error));\n }\n\n return id;\n } catch (error) {\n setIsRegisterError(true);\n onError?.(error as Error);\n\n return null;\n } finally {\n setIsRegistering(false);\n }\n }, [\n apiAdapters,\n onError,\n originId,\n originType,\n serviceWorkerFile,\n serviceWorkerPath,\n vapidKey,\n ]);\n\n const registerClient = useCallback(\n () => performRegistration(),\n [performRegistration],\n );\n\n const subscribeTopicsBatch = useCallback(\n async (topics: string[]) => {\n if (!clientId || topics.length === 0) {\n return;\n }\n\n try {\n await apiAdapters.subscribeTopicsBatch(clientId, topics);\n } catch (error) {\n onError?.(error as Error);\n }\n },\n [apiAdapters, clientId, onError],\n );\n\n const unsubscribeTopicsBatch = useCallback(\n async (topics: string[]) => {\n if (!clientId || topics.length === 0) {\n return;\n }\n\n try {\n await apiAdapters.unsubscribeTopicsBatch(clientId, topics);\n } catch (error) {\n onError?.(error as Error);\n }\n },\n [apiAdapters, clientId, onError],\n );\n\n const subscribeToTopic = useCallback(\n (topic: string) => subscribeTopicsBatch([topic]),\n [subscribeTopicsBatch],\n );\n\n const unsubscribeFromTopic = useCallback(\n (topic: string) => unsubscribeTopicsBatch([topic]),\n [unsubscribeTopicsBatch],\n );\n\n const on = useCallback((topic: string, handler: PushMessageHandler) => {\n const handlers =\n topicHandlersRef.current.get(topic) ?? new Set<PushMessageHandler>();\n handlers.add(handler);\n topicHandlersRef.current.set(topic, handlers);\n\n return () => {\n const currentHandlers = topicHandlersRef.current.get(topic);\n\n if (!currentHandlers) {\n return;\n }\n\n currentHandlers.delete(handler);\n\n if (currentHandlers.size === 0) {\n topicHandlersRef.current.delete(topic);\n }\n };\n }, []);\n\n const resetMessageCount = useCallback(() => {\n setNewMessageCount(0);\n }, []);\n\n const performRegistrationRef = useRef(performRegistration);\n performRegistrationRef.current = performRegistration;\n\n useEffect(() => {\n if (hasRegisteredRef.current && registeredKeyRef.current === contextKey) {\n return;\n }\n\n hasRegisteredRef.current = true;\n registeredKeyRef.current = contextKey;\n\n void performRegistrationRef.current();\n }, [contextKey]);\n\n useEffect(() => {\n if (channel !== PushChannel.WEBPUSH || !('serviceWorker' in navigator)) {\n return;\n }\n\n const handler = (event: MessageEvent) => {\n const data = event.data as\n | { id?: string; topic?: string; payload?: unknown }\n | undefined;\n\n if (!data?.id || data.payload === undefined) {\n return;\n }\n\n deliver({ id: data.id, topic: data.topic ?? '', payload: data.payload });\n };\n\n navigator.serviceWorker.addEventListener('message', handler);\n\n return () => {\n navigator.serviceWorker.removeEventListener('message', handler);\n };\n }, [channel, deliver]);\n\n useEffect(() => {\n if (channel !== PushChannel.STREAM || !clientId) {\n return;\n }\n\n const unsubscribe = apiAdapters.subscribeToStream(clientId, deliver);\n\n return () => {\n unsubscribe();\n };\n }, [apiAdapters, channel, clientId, deliver]);\n\n const isLoading = useMemo(\n () => !clientId || isRegistering,\n [clientId, isRegistering],\n );\n\n const value: PushNotificationV2ContextData = useMemo(\n () => ({\n clientId,\n channel,\n isLoading,\n isRegisterError,\n newMessageCount,\n resetMessageCount,\n registerClient,\n subscribeToTopic,\n unsubscribeFromTopic,\n subscribeTopicsBatch,\n unsubscribeTopicsBatch,\n on,\n }),\n [\n channel,\n clientId,\n isLoading,\n isRegisterError,\n newMessageCount,\n on,\n registerClient,\n resetMessageCount,\n subscribeToTopic,\n subscribeTopicsBatch,\n unsubscribeFromTopic,\n unsubscribeTopicsBatch,\n ],\n );\n\n return (\n <PushNotificationV2Context.Provider value={value}>\n {children}\n </PushNotificationV2Context.Provider>\n );\n};\n\nexport function usePushNotificationsV2(): PushNotificationV2ContextData {\n const context = useContext(PushNotificationV2Context);\n\n if (!context) {\n throw new Error(\n 'usePushNotificationsV2 precisa estar dentro de PushNotificationV2Provider',\n );\n }\n\n return context;\n}\n\nexport type {\n ClientRegistrationPayloadV2,\n ClientRegistrationResultV2,\n MessageStatusPayloadV2,\n PushMessageHandler,\n PushMessageV2,\n PushNotificationApiAdaptersV2,\n PushNotificationV2ContextData,\n PushNotificationV2ProviderProps,\n} from './types';\nexport { MessageStatusV2, PushChannel } from './types';\n","export function urlBase64ToUint8Array(base64String: string): Uint8Array {\n const padding = '='.repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/');\n\n const rawData = window.atob(base64);\n const outputArray = new Uint8Array(rawData.length);\n for (let i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n}\n","import { urlBase64ToUint8Array } from './urlBase64ToUint8Array';\n\ninterface ResolveWebPushSubscriptionParams {\n vapidKey: string;\n serviceWorkerPath: string;\n serviceWorkerFile: string;\n}\n\nexport async function resolveWebPushSubscription({\n vapidKey,\n serviceWorkerPath,\n serviceWorkerFile,\n}: ResolveWebPushSubscriptionParams): Promise<PushSubscription | null> {\n if (!('serviceWorker' in navigator) || !('PushManager' in window)) {\n return null;\n }\n\n try {\n const permission = await Notification.requestPermission();\n\n if (permission !== 'granted') {\n return null;\n }\n\n const registration = await navigator.serviceWorker.register(\n `${serviceWorkerPath}${serviceWorkerFile}`,\n );\n await navigator.serviceWorker.ready;\n\n return await registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: urlBase64ToUint8Array(vapidKey) as BufferSource,\n });\n } catch {\n return null;\n }\n}\n","import { ReactNode } from 'react';\n\nexport interface PushMessageV2<TPayload = unknown> {\n id: string;\n topic: string;\n payload: TPayload;\n}\n\nexport enum MessageStatusV2 {\n DELIVERED = 'DELIVERED',\n}\n\nexport interface MessageStatusPayloadV2 {\n status: MessageStatusV2;\n}\n\nexport interface ClientRegistrationPayloadV2 {\n origin_type: string;\n origin_id: string;\n endpoint?: string;\n auth?: string;\n p256dh?: string;\n}\n\nexport interface ClientRegistrationResultV2 {\n id: string;\n}\n\nexport enum PushChannel {\n WEBPUSH = 'WEBPUSH',\n STREAM = 'STREAM',\n}\n\nexport type PushMessageHandler = (message: PushMessageV2) => void;\n\nexport interface PushNotificationApiAdaptersV2 {\n registerClient: (\n payload: ClientRegistrationPayloadV2,\n ) => Promise<ClientRegistrationResultV2>;\n\n removeClient?: (clientId: string) => Promise<void>;\n\n subscribeTopicsBatch: (clientId: string, topics: string[]) => Promise<void>;\n\n unsubscribeTopicsBatch: (clientId: string, topics: string[]) => Promise<void>;\n\n updateMessageStatus: (\n messageId: string,\n status: MessageStatusPayloadV2,\n ) => Promise<void>;\n\n subscribeToStream: (\n clientId: string,\n onMessage: PushMessageHandler,\n ) => () => void;\n}\n\nexport interface PushNotificationV2ProviderProps {\n children: ReactNode;\n originId: string;\n originType: string;\n vapidKey: string;\n serviceWorkerPath?: string;\n serviceWorkerFile?: string;\n apiAdapters: PushNotificationApiAdaptersV2;\n onError?: (error: Error) => void;\n contextKey?: string;\n}\n\nexport interface PushNotificationV2ContextData {\n clientId: string | null;\n channel: PushChannel | null;\n isLoading: boolean;\n isRegisterError: boolean;\n newMessageCount: number;\n resetMessageCount: () => void;\n registerClient: () => Promise<string | null>;\n subscribeToTopic: (topic: string) => Promise<void>;\n unsubscribeFromTopic: (topic: string) => Promise<void>;\n subscribeTopicsBatch: (topics: string[]) => Promise<void>;\n unsubscribeTopicsBatch: (topics: string[]) => Promise<void>;\n on: (topic: string, handler: PushMessageHandler) => () => void;\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface UseReconciliationParams {
|
|
2
|
+
reconcile: () => void | Promise<void>;
|
|
3
|
+
isActive: boolean;
|
|
4
|
+
intervalMs?: number;
|
|
5
|
+
}
|
|
6
|
+
interface UseReconciliationResult {
|
|
7
|
+
notifyActivity: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare function useReconciliation({ reconcile, isActive, intervalMs, }: UseReconciliationParams): UseReconciliationResult;
|
|
10
|
+
|
|
11
|
+
export { useReconciliation };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { useRef, useCallback, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
var s=1e4;function v({reconcile:c,isActive:n,intervalMs:o=s}){let l=useRef(c);l.current=c;let t=useRef(null),e=useCallback(()=>{t.current&&(clearInterval(t.current),t.current=null);},[]),r=useCallback(()=>{e(),t.current=setInterval(()=>{l.current();},o);},[e,o]);return useEffect(()=>{if(!n){e();return}return r(),e},[e,n,r]),{notifyActivity:useCallback(()=>{n&&r();},[n,r])}}
|
|
4
|
+
|
|
5
|
+
export { v as useReconciliation };
|
|
6
|
+
//# sourceMappingURL=useReconciliation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useReconciliation.ts"],"names":["useCallback","useEffect","useRef","DEFAULT_INTERVAL_MS","useReconciliation","reconcile","isActive","intervalMs","reconcileRef","intervalRef","clear","start"],"mappings":"AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,UAAAC,MAAc,QAY/C,IAAMC,EAAsB,IAErB,SAASC,EAAkB,CAChC,UAAAC,EACA,SAAAC,EACA,WAAAC,EAAaJ,CACf,EAAqD,CACnD,IAAMK,EAAeN,EAAOG,CAAS,EACrCG,EAAa,QAAUH,EAEvB,IAAMI,EAAcP,EAA8C,IAAI,EAEhEQ,EAAQV,EAAY,IAAM,CAC1BS,EAAY,UACd,cAAcA,EAAY,OAAO,EACjCA,EAAY,QAAU,KAE1B,EAAG,CAAC,CAAC,EAECE,EAAQX,EAAY,IAAM,CAC9BU,EAAM,EAEND,EAAY,QAAU,YAAY,IAAM,CACjCD,EAAa,QAAQ,CAC5B,EAAGD,CAAU,CACf,EAAG,CAACG,EAAOH,CAAU,CAAC,EAEtB,OAAAN,EAAU,IAAM,CACd,GAAI,CAACK,EAAU,CACbI,EAAM,EAEN,OAGF,OAAAC,EAAM,EAECD,CACT,EAAG,CAACA,EAAOJ,EAAUK,CAAK,CAAC,EAQpB,CAAE,eANcX,EAAY,IAAM,CACnCM,GACFK,EAAM,CAEV,EAAG,CAACL,EAAUK,CAAK,CAAC,CAEI,CAC1B","sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\n\ninterface UseReconciliationParams {\n reconcile: () => void | Promise<void>;\n isActive: boolean;\n intervalMs?: number;\n}\n\ninterface UseReconciliationResult {\n notifyActivity: () => void;\n}\n\nconst DEFAULT_INTERVAL_MS = 10000;\n\nexport function useReconciliation({\n reconcile,\n isActive,\n intervalMs = DEFAULT_INTERVAL_MS,\n}: UseReconciliationParams): UseReconciliationResult {\n const reconcileRef = useRef(reconcile);\n reconcileRef.current = reconcile;\n\n const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const clear = useCallback(() => {\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n intervalRef.current = null;\n }\n }, []);\n\n const start = useCallback(() => {\n clear();\n\n intervalRef.current = setInterval(() => {\n void reconcileRef.current();\n }, intervalMs);\n }, [clear, intervalMs]);\n\n useEffect(() => {\n if (!isActive) {\n clear();\n\n return undefined;\n }\n\n start();\n\n return clear;\n }, [clear, isActive, start]);\n\n const notifyActivity = useCallback(() => {\n if (isActive) {\n start();\n }\n }, [isActive, start]);\n\n return { notifyActivity };\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { a as useThemeToggle } from '../chunk-U4I7JPER.js';
|
|
2
|
-
import '../chunk-
|
|
2
|
+
import '../chunk-JM3SE72J.js';
|
|
3
3
|
import '../chunk-373WGZZL.js';
|
|
4
|
+
import '../chunk-WUFEPE2G.js';
|
|
4
5
|
import '../chunk-BX2DSNRV.js';
|
|
5
6
|
import '../chunk-X4F3O7PX.js';
|
|
6
7
|
import '../chunk-Q2AVS24Z.js';
|
|
7
8
|
import '../chunk-LNESYSHP.js';
|
|
8
9
|
import '../chunk-YPL4KIKN.js';
|
|
9
10
|
import '../chunk-HBOBTNB5.js';
|
|
10
|
-
import '../chunk-WUFEPE2G.js';
|
|
11
11
|
import '../chunk-GLRLKFPS.js';
|
|
12
12
|
//# sourceMappingURL=useThemeToggle.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { a as useThemeToggle } from './chunk-U4I7JPER.js';
|
|
2
|
-
export { b as ThemeProvider, a as createTheme } from './chunk-
|
|
2
|
+
export { b as ThemeProvider, a as createTheme } from './chunk-JM3SE72J.js';
|
|
3
3
|
import './chunk-373WGZZL.js';
|
|
4
|
+
import './chunk-WUFEPE2G.js';
|
|
4
5
|
export { c as SettingsProvider, b as useSettingsContext } from './chunk-BX2DSNRV.js';
|
|
5
6
|
export { b as defaultFont, c as primaryFont, d as secondaryFont, a as shadows, e as typography } from './chunk-X4F3O7PX.js';
|
|
6
7
|
import './chunk-Q2AVS24Z.js';
|
|
7
8
|
import './chunk-LNESYSHP.js';
|
|
8
9
|
export { l as action, k as background, m as basePalette, p as colorSchemes, i as common, a as components, q as createShadowColor, r as customShadows, o as darkPalette, h as error, b as grey, e as info, n as lightPalette, c as primary, d as secondary, f as success, j as text, g as warning } from './chunk-YPL4KIKN.js';
|
|
9
10
|
import './chunk-HBOBTNB5.js';
|
|
10
|
-
import './chunk-WUFEPE2G.js';
|
|
11
11
|
export { a as THEME_CONFIG, q as bgBlur, p as bgGradient, o as borderGradient, j as createPaletteChannel, h as hexToRgbChannel, i as hexToRgbaChannel, l as hideScrollX, m as hideScrollY, r as maxLine, c as mediaQueries, t as menuItem, s as paper, f as pxToRem, e as remToPx, g as responsiveFontSizes, d as setFont, b as stylesMode, n as textGradient, k as varAlpha } from './chunk-GLRLKFPS.js';
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { b as default } from '../chunk-
|
|
1
|
+
export { b as default } from '../chunk-JM3SE72J.js';
|
|
2
2
|
import '../chunk-373WGZZL.js';
|
|
3
|
+
import '../chunk-WUFEPE2G.js';
|
|
3
4
|
export { b as useSettingsContext } from '../chunk-BX2DSNRV.js';
|
|
4
5
|
import '../chunk-X4F3O7PX.js';
|
|
5
6
|
import '../chunk-Q2AVS24Z.js';
|
|
6
7
|
import '../chunk-LNESYSHP.js';
|
|
7
8
|
import '../chunk-YPL4KIKN.js';
|
|
8
9
|
import '../chunk-HBOBTNB5.js';
|
|
9
|
-
import '../chunk-WUFEPE2G.js';
|
|
10
10
|
export { a as THEME_CONFIG } from '../chunk-GLRLKFPS.js';
|
|
11
11
|
//# sourceMappingURL=theme-provider.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import '../chunk-4P2L7UJA.js';
|
|
2
1
|
import '../chunk-P64QBDAO.js';
|
|
2
|
+
import '../chunk-4P2L7UJA.js';
|
|
3
3
|
|
|
4
4
|
var u=(t,e)=>{if(!(!t?.fields||!e))return t.fields.find(r=>r.name===e||r.filter_field_name===e)},i=(t,e)=>{if(!e)return;let r=u(t,e);return t?.fields?r?.filter_field_name||r?.name:e},f=(t,e)=>{if(!(!t?.fields||!e||e.length===0))return e.filter(r=>r!=="ACTIONS")},l=(t,e)=>{let r=e?.trim();if(!r)return;let n=i(t,t?.description_field_name)||i(t,"name");if(n)return {operator:"AND",groups:[{operator:"AND",conditionals:[{fieldName:n,conditional:"LIKE",value:[r]}]}]}},p=(t,e,r)=>{if(!e||!r)return;let n=i(t,e);if(n)return {fieldName:n,sortType:r==="desc"?"DESC":"ASC"}},c=({metadata:t,visibleFieldNames:e,search:r,sort:n,dir:s})=>{let o=f(t,e),d=l(t,r),a=p(t,n,s);return {...o&&{criteria:o},...d&&{filter:d},...a&&{sort:a}}},y=c;
|
|
5
5
|
|
package/package.json
CHANGED
package/dist/chunk-SC6LFS3A.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { a } from './chunk-YSQ5AYHV.js';
|
|
2
|
-
import { memo, createContext, forwardRef, useContext, useMemo, useCallback, useRef, useEffect } from 'react';
|
|
3
|
-
import Ne, { autocompleteClasses } from '@mui/material/Autocomplete';
|
|
4
|
-
import be from '@mui/material/CircularProgress';
|
|
5
|
-
import ye from '@mui/material/TextField';
|
|
6
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
-
import { VariableSizeList } from 'react-window';
|
|
8
|
-
import { useTheme, styled } from '@mui/material/styles';
|
|
9
|
-
import Se from '@mui/material/useMediaQuery';
|
|
10
|
-
import Pe from '@mui/material/ListSubheader';
|
|
11
|
-
import Ie from '@mui/material/Stack';
|
|
12
|
-
import F from '@mui/material/Typography';
|
|
13
|
-
import Me from '@mui/material/Popper';
|
|
14
|
-
|
|
15
|
-
var D=memo(({params:e,name:t,placeholder:s,error:n,helperText:p,label:m,required:L,multiple:l,formattedValue:o,loading:a$1,tabIndex:u,InputLabelProps:y,inputRef:g})=>jsx(ye,{...e,name:t,placeholder:s,fullWidth:!0,error:!!n,helperText:p,label:m,required:L,inputRef:g,InputProps:{...e.InputProps,...!l&&{startAdornment:o&&!Array.isArray(o)&&o.icon?jsx(a,{icon:o.icon}):void 0},endAdornment:jsxs(Fragment,{children:[a$1?jsx(be,{color:"primary",size:20}):null,e.InputProps.endAdornment]})},inputProps:{...e.inputProps,name:t,tabIndex:u},InputLabelProps:y}));D.displayName="AutocompleteInput";var $=D;var w=8,B=memo(e=>{let{data:t,index:s,style:n}=e,p=t[s],m={...n,top:n.top+w,paddingTop:8};if(Object.prototype.hasOwnProperty.call(p,"group")){let y=p;return jsx(Pe,{component:"div",style:m,children:y.group},`list-box-item-group-${y.group}`)}let[L,l]=p,{showValueInLabel:o,key:a$1,...u}=L;return jsx(F,{component:"li",...u,noWrap:!0,style:m,children:jsxs(Ie,{component:"div",direction:"row",flex:1,gap:1,justifyContent:"start",children:[l.icon&&jsx(a,{icon:l.icon}),l.label,o&&jsxs(F,{variant:"inherit",color:"grey.400",children:["(",l.value,")"]})]})},`list-box-item-${a$1}`)});B.displayName="ListboxRow";var U=B;var Re=createContext(void 0),h=Re;var J=createContext({}),K=forwardRef((e,t)=>{let s=useContext(J);return jsx("div",{ref:t,...e,...s})});K.displayName="OuterElementType";var Te=e=>{let t=useRef(null);return useEffect(()=>{t.current!=null&&t.current.resetAfterIndex(0,!0);},[e]),t},ve=forwardRef(function(t,s){let{children:n,...p}=t,m=useMemo(()=>{let r=[];return n.forEach(b=>{r.push(b),Object.prototype.hasOwnProperty.call(b,"children")&&Array.isArray(b.children)&&r.push(...b.children);}),r},[n]),L=useTheme(),l=Se(L.breakpoints.up("sm")),o=m.length,a=l?36:48,u=useCallback(r=>Object.prototype.hasOwnProperty.call(r,"group")?48:a,[a]),y=useMemo(()=>o>8?8*a:m.map(u).reduce((r,b)=>r+b,0),[o,a,m,u]),g=Te(o),P=useContext(h),c=useRef(!1);useEffect(()=>{c.current=!1;},[o]);let x=useCallback(({visibleStopIndex:r})=>{P&&!c.current&&r>=o-3&&(c.current=!0,P());},[P,o]);return jsx("div",{ref:s,children:jsx(J.Provider,{value:p,children:jsx(VariableSizeList,{itemData:m,height:y+2*w,width:"100%",ref:g,outerElementType:K,innerElementType:"ul",itemSize:r=>u(m[r]),overscanCount:5,itemCount:o,onItemsRendered:x,children:U})})})}),Y=ve;var Z=styled(Me)({[`& .${autocompleteClasses.listbox}`]:{boxSizing:"border-box","& ul":{padding:0,margin:0}}});var ze=e=>e&&typeof e=="object"?e.value.toString():e.toString(),De=e=>e,$e=(e,t)=>{let s=t.inputValue.toLocaleUpperCase();return e.filter(n=>`${n.value} ${n.label}`.toLocaleUpperCase().includes(s))},te=memo(forwardRef(({name:e,label:t,value:s,options:n=[],loading:p,noOptionsText:m="Nenhum resultado encontrado.",loadingText:L="Carregando op\xE7\xF5es...",error:l,helperText:o,placeholder:a,onChange:u,groupBy:y,showValueInLabel:g,disabled:P,multiple:c,required:x,renderOption:r,tabIndex:b,onInputChange:C,onSearch:A,onBlur:S,onScrollEnd:oe,InputLabelProps:k,inputRef:G,filterOptions:re,...ne},ie)=>{let N=useRef(null),T=useMemo(()=>c?(Array.isArray(s)?s:[]).reduce((f,v)=>{let z=n.find(de=>de.value.toString()===v.toString());return z?[...f,z]:[...f]},[]):n.find(i=>i.value.toString()===s?.toString())||null,[n,s,c]),se=re??(N.current==="reset"?void 0:$e),pe=useCallback((d,i,f)=>{if(N.current=f,C&&C(d,i,f),f==="input"){A&&A(i);return}f==="reset"&&A&&A(void 0),f==="clear"&&A&&A("");},[C,A]),me=useCallback((d,i)=>{if(!i){u(c?[]:null);return}if(Array.isArray(i)){u(i.map(ze));return}u(typeof i=="string"?i.toString():i.value.toString());},[u,c]),ue=useCallback(d=>{S&&S(d);},[S]),le=useCallback((d,i,f,v)=>r?r(d,i,f,v):[{...d,showValueInLabel:g},i],[r,g]),ae=useMemo(()=>r?void 0:Y,[r]),ce=useCallback(d=>jsx($,{params:d,name:e,placeholder:a,error:l,helperText:o,label:t,required:x,multiple:c,formattedValue:T,loading:p,tabIndex:b,InputLabelProps:k,inputRef:G}),[e,a,l,o,t,x,c,T,p,b,k,G]);return jsx(h.Provider,{value:oe,children:jsx(Ne,{ref:ie,value:T,onInputChange:pe,options:n,loading:p,noOptionsText:m,loadingText:L,disabled:P,disableListWrap:!0,PopperComponent:Z,ListboxComponent:ae,filterOptions:se,onChange:me,onBlur:ue,renderOption:le,renderGroup:De,groupBy:y,multiple:c,renderInput:ce,...ne})})}));te.displayName="Autocomplete";var St=te;
|
|
16
|
-
|
|
17
|
-
export { St as a };
|
|
18
|
-
//# sourceMappingURL=chunk-SC6LFS3A.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Autocomplete/index.tsx","../src/components/Autocomplete/AutocompleteInput.tsx","../src/components/Autocomplete/Listbox.tsx","../src/components/Autocomplete/ListboxRow.tsx","../src/components/Autocomplete/ScrollEndContext.ts","../src/components/Autocomplete/styles.ts"],"names":["forwardRef","memo","useCallback","useMemo","useRef","MuiAutocomplete","CircularProgress","TextField","Fragment","jsx","jsxs","AutocompleteInput","params","name","placeholder","error","helperText","label","required","multiple","formattedValue","loading","tabIndex","InputLabelProps","inputRef","Icon_default","AutocompleteInput_default","createContext","useContext","useEffect","VariableSizeList","useTheme","useMediaQuery","ListSubheader","Stack","Typography","LISTBOX_PADDING","ListboxRow","props","data","index","style","dataSet","inlineStyle","groupItem","itemProps","option","showValueInLabel","key","otherItemProps","ListboxRow_default","ScrollEndContext","ScrollEndContext_default","OuterElementContext","OuterElementType","ref","outerProps","useResetCache","ListboxComponent","children","other","itemData","item","theme","smUp","itemCount","itemSize","getChildSize","child","itemsHeight","a","gridRef","onScrollEnd","firedRef","handleItemsRendered","visibleStopIndex","Listbox_default","autocompleteClasses","Popper","styled","StyledPopper","getOptionValue","optionValue","renderGroup","defaultFilterOptions","optionsFilter","state","searchValue","opt","Autocomplete","value","options","noOptionsText","loadingText","onChange","groupBy","disabled","renderOption","onInputChange","onSearch","onBlur","filterOptionsProp","inputReasonRef","acc","curr","resolvedFilterOptions","handleInputChange","event","eventValue","reason","handleChange","_","handleBlur","memoizedRenderOption","ownerState","renderListbox","memoizedRenderInput","Autocomplete_default"],"mappings":"wCAAA,OACE,cAAAA,GACA,QAAAC,GAEA,eAAAC,EACA,WAAAC,GACA,UAAAC,OACK,QACP,OAAOC,OAKA,6BCbP,OAAS,QAAAJ,OAAY,QACrB,OAAOK,OAAsB,iCAC7B,OAAOC,OAAe,0BAuCR,OAIJ,YAAAC,GAJI,OAAAC,EAIJ,QAAAC,OAJI,oBAjCd,IAAMC,EAAoBV,GACxB,CAAC,CACC,OAAAW,EACA,KAAAC,EACA,YAAAC,EACA,MAAAC,EACA,WAAAC,EACA,MAAAC,EACA,SAAAC,EACA,SAAAC,EACA,eAAAC,EACA,QAAAC,EACA,SAAAC,EACA,gBAAAC,EACA,SAAAC,CACF,IACEf,EAACF,GAAA,CACE,GAAGK,EACJ,KAAMC,EACN,YAAaC,EACb,UAAS,GACT,MAAO,CAAC,CAACC,EACT,WAAYC,EACZ,MAAOC,EACP,SAAUC,EACV,SAAUM,EACV,WAAY,CACV,GAAGZ,EAAO,WACV,GAAI,CAACO,GAAY,CACf,eAC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C,EACP,SAAUC,EACV,SAAUC,EACV,eAAgBC,EAChB,QAASC,EACT,SAAUC,EACV,gBAAiBC,EACjB,SAAUC,EACZ,EAEF,CACEX,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,CACF,CACF,EAEA,OACEf,EAAC2C,EAAiB,SAAjB,CAA0B,MAAOoB,GAChC,SAAA/D,EAACJ,GAAA,CACC,IAAKkD,GACL,MAAOnC,EACP,cAAesF,GACf,QAASf,EACT,QAAStE,EACT,cAAeuE,EACf,YAAaC,EACb,SAAUG,EACV,gBAAe,GACf,gBAAiBhB,EACjB,iBAAkBmC,GAClB,cAAeV,GACf,SAAUK,GACV,OAAQE,GACR,aAAcC,GACd,YAAa9B,GACb,QAASY,EACT,SAAU5E,EACV,YAAaiG,GACZ,GAAGxD,GACN,EACF,CAEJ,CACF,CACF,EAEA6B,GAAa,YAAc,eAE3B,IAAO4B,GAAQ5B","sourcesContent":["import {\n forwardRef,\n memo,\n ReactNode,\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport MuiAutocomplete, {\n AutocompleteOwnerState,\n AutocompleteRenderGroupParams,\n AutocompleteRenderInputParams,\n AutocompleteRenderOptionState,\n} from '@mui/material/Autocomplete';\n\nimport { AutocompleteProps } from 'types/autoCompleteProps';\nimport { Option } from 'types/option';\n\nimport AutocompleteInput from './AutocompleteInput';\nimport ListboxComponent from './Listbox';\nimport ScrollEndContext from './ScrollEndContext';\nimport { StyledPopper } from './styles';\n\nconst getOptionValue = (optionValue: Option | string | number): string =>\n optionValue && typeof optionValue === 'object'\n ? optionValue.value.toString()\n : optionValue.toString();\n\nconst renderGroup = (params: AutocompleteRenderGroupParams) =>\n params as unknown as ReactNode;\n\nconst defaultFilterOptions = (\n optionsFilter: Option[],\n state: { inputValue: string },\n) => {\n const searchValue = state.inputValue.toLocaleUpperCase();\n return optionsFilter.filter(opt => {\n const search = `${opt.value} ${opt.label}`;\n\n return search.toLocaleUpperCase().includes(searchValue);\n });\n};\n\nconst Autocomplete = memo(\n forwardRef<unknown, AutocompleteProps>(\n (\n {\n name,\n label,\n value,\n options = [],\n loading,\n noOptionsText = 'Nenhum resultado encontrado.',\n loadingText = 'Carregando opções...',\n error,\n helperText,\n placeholder,\n onChange,\n groupBy,\n showValueInLabel,\n disabled,\n multiple,\n required,\n renderOption,\n tabIndex,\n onInputChange,\n onSearch,\n onBlur,\n onScrollEnd,\n InputLabelProps,\n inputRef,\n filterOptions: filterOptionsProp,\n ...other\n },\n ref,\n ) => {\n const inputReasonRef = useRef<'input' | 'reset' | 'clear' | null>(null);\n\n const formattedValue = useMemo(() => {\n if (multiple) {\n const values = Array.isArray(value) ? value : [];\n\n return values.reduce<Option[]>((acc, curr) => {\n const item = options.find(\n opt => opt.value.toString() === curr.toString(),\n );\n\n if (item) return [...acc, item];\n\n return [...acc];\n }, []);\n }\n\n const item = options.find(\n opt => opt.value.toString() === value?.toString(),\n );\n\n return item || null;\n }, [options, value, multiple]);\n\n const resolvedFilterOptions =\n filterOptionsProp ??\n (inputReasonRef.current === 'reset' ? undefined : defaultFilterOptions);\n\n const handleInputChange = useCallback(\n (\n event: React.SyntheticEvent,\n eventValue: string,\n reason: 'input' | 'reset' | 'clear',\n ) => {\n inputReasonRef.current = reason;\n if (onInputChange) onInputChange(event, eventValue, reason);\n\n if (reason === 'input') {\n if (onSearch) onSearch(eventValue);\n return;\n }\n\n if (reason === 'reset') {\n if (onSearch) onSearch(undefined);\n }\n\n if (reason === 'clear') {\n if (onSearch) onSearch('');\n }\n },\n [onInputChange, onSearch],\n );\n\n const handleChange = useCallback(\n (\n _: React.SyntheticEvent,\n option: Option | (string | Option)[] | string | null,\n ) => {\n if (!option) {\n onChange(multiple ? [] : null);\n return;\n }\n\n if (Array.isArray(option)) {\n onChange(option.map(getOptionValue));\n return;\n }\n\n onChange(\n typeof option === 'string'\n ? option.toString()\n : option.value.toString(),\n );\n },\n [onChange, multiple],\n );\n\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLDivElement>) => {\n if (onBlur) onBlur(event);\n },\n [onBlur],\n );\n\n const memoizedRenderOption = useCallback(\n (\n props: React.HTMLAttributes<HTMLLIElement> & { key: string },\n option: Option,\n state: AutocompleteRenderOptionState,\n ownerState: AutocompleteOwnerState<Option, boolean, boolean, boolean>,\n ) =>\n renderOption\n ? renderOption(props, option, state, ownerState)\n : ([{ ...props, showValueInLabel }, option] as ReactNode),\n [renderOption, showValueInLabel],\n );\n\n const renderListbox = useMemo(\n () => (renderOption ? undefined : ListboxComponent),\n [renderOption],\n );\n\n const memoizedRenderInput = useCallback(\n (params: AutocompleteRenderInputParams) => (\n <AutocompleteInput\n params={params}\n name={name}\n placeholder={placeholder}\n error={error}\n helperText={helperText}\n label={label}\n required={required}\n multiple={multiple}\n formattedValue={formattedValue}\n loading={loading}\n tabIndex={tabIndex}\n InputLabelProps={InputLabelProps}\n inputRef={inputRef}\n />\n ),\n [\n name,\n placeholder,\n error,\n helperText,\n label,\n required,\n multiple,\n formattedValue,\n loading,\n tabIndex,\n InputLabelProps,\n inputRef,\n ],\n );\n\n return (\n <ScrollEndContext.Provider value={onScrollEnd}>\n <MuiAutocomplete\n ref={ref}\n value={formattedValue}\n onInputChange={handleInputChange}\n options={options}\n loading={loading}\n noOptionsText={noOptionsText}\n loadingText={loadingText}\n disabled={disabled}\n disableListWrap\n PopperComponent={StyledPopper}\n ListboxComponent={renderListbox}\n filterOptions={resolvedFilterOptions}\n onChange={handleChange}\n onBlur={handleBlur}\n renderOption={memoizedRenderOption}\n renderGroup={renderGroup}\n groupBy={groupBy}\n multiple={multiple}\n renderInput={memoizedRenderInput}\n {...other}\n />\n </ScrollEndContext.Provider>\n );\n },\n ),\n);\n\nAutocomplete.displayName = 'Autocomplete';\n\nexport default Autocomplete;\n","import { memo } from 'react';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport TextField from '@mui/material/TextField';\n\nimport Icon from '../Icon';\n\nimport { AutocompleteInputProps } from './props';\n\nconst AutocompleteInput = memo(\n ({\n params,\n name,\n placeholder,\n error,\n helperText,\n label,\n required,\n multiple,\n formattedValue,\n loading,\n tabIndex,\n InputLabelProps,\n inputRef,\n }: AutocompleteInputProps) => (\n <TextField\n {...params}\n name={name}\n placeholder={placeholder}\n fullWidth\n error={!!error}\n helperText={helperText}\n label={label}\n required={required}\n inputRef={inputRef}\n InputProps={{\n ...params.InputProps,\n ...(!multiple && {\n startAdornment:\n formattedValue &&\n !Array.isArray(formattedValue) &&\n formattedValue.icon ? (\n <Icon icon={formattedValue.icon} />\n ) : undefined,\n }),\n endAdornment: (\n <>\n {loading ? <CircularProgress color=\"primary\" size={20} /> : null}\n {params.InputProps.endAdornment}\n </>\n ),\n }}\n inputProps={{\n ...params.inputProps,\n name,\n tabIndex,\n }}\n InputLabelProps={InputLabelProps}\n />\n ),\n);\n\nAutocompleteInput.displayName = 'AutocompleteInput';\n\nexport default AutocompleteInput;\n","import {\n createContext,\n forwardRef,\n HTMLAttributes,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport { ListOnItemsRenderedProps, VariableSizeList } from 'react-window';\nimport { AutocompleteRenderGroupParams } from '@mui/material/Autocomplete';\nimport { useTheme } from '@mui/material/styles';\nimport useMediaQuery from '@mui/material/useMediaQuery';\n\nimport ListboxRow, { LISTBOX_PADDING } from './ListboxRow';\nimport type { ListboxItem } from './props';\nimport ScrollEndContext from './ScrollEndContext';\n\nconst OuterElementContext = createContext({});\n\nconst OuterElementType = forwardRef<HTMLDivElement>((props, ref) => {\n const outerProps = useContext(OuterElementContext);\n return <div ref={ref} {...props} {...outerProps} />;\n});\n\nOuterElementType.displayName = 'OuterElementType';\n\nconst useResetCache = (data: number) => {\n const ref = useRef<VariableSizeList>(null);\n\n useEffect(() => {\n if (ref.current != null) {\n ref.current.resetAfterIndex(0, true);\n }\n }, [data]);\n\n return ref;\n};\n\nconst ListboxComponent = forwardRef<\n HTMLDivElement,\n HTMLAttributes<HTMLElement>\n>(function ListboxComponent(props, ref) {\n const { children, ...other } = props;\n\n const itemData: ListboxItem[] = useMemo(() => {\n const data: ListboxItem[] = [];\n (children as ListboxItem[]).forEach(item => {\n data.push(item);\n if (\n Object.prototype.hasOwnProperty.call(item, 'children') &&\n Array.isArray((item as AutocompleteRenderGroupParams).children)\n ) {\n data.push(\n ...((item as AutocompleteRenderGroupParams)\n .children as ListboxItem[]),\n );\n }\n });\n return data;\n }, [children]);\n\n const theme = useTheme();\n const smUp = useMediaQuery(theme.breakpoints.up('sm'));\n const itemCount = itemData.length;\n const itemSize = smUp ? 36 : 48;\n\n const getChildSize = useCallback(\n (child: ListboxItem) => {\n if (Object.prototype.hasOwnProperty.call(child, 'group')) {\n return 48;\n }\n\n return itemSize;\n },\n [itemSize],\n );\n\n const itemsHeight = useMemo(() => {\n if (itemCount > 8) {\n return 8 * itemSize;\n }\n return itemData.map(getChildSize).reduce((a, b) => a + b, 0);\n }, [itemCount, itemSize, itemData, getChildSize]);\n\n const gridRef = useResetCache(itemCount);\n const onScrollEnd = useContext(ScrollEndContext);\n const firedRef = useRef(false);\n\n useEffect(() => {\n firedRef.current = false;\n }, [itemCount]);\n\n const handleItemsRendered = useCallback(\n ({ visibleStopIndex }: ListOnItemsRenderedProps) => {\n if (\n onScrollEnd &&\n !firedRef.current &&\n visibleStopIndex >= itemCount - 3\n ) {\n firedRef.current = true;\n onScrollEnd();\n }\n },\n [onScrollEnd, itemCount],\n );\n\n return (\n <div ref={ref}>\n <OuterElementContext.Provider value={other}>\n <VariableSizeList\n itemData={itemData}\n height={itemsHeight + 2 * LISTBOX_PADDING}\n width=\"100%\"\n ref={gridRef}\n outerElementType={OuterElementType}\n innerElementType=\"ul\"\n itemSize={index => getChildSize(itemData[index])}\n overscanCount={5}\n itemCount={itemCount}\n onItemsRendered={handleItemsRendered}\n >\n {ListboxRow}\n </VariableSizeList>\n </OuterElementContext.Provider>\n </div>\n );\n});\n\nexport default ListboxComponent;\n","import { HTMLAttributes, memo } from 'react';\nimport { ListChildComponentProps } from 'react-window';\nimport { AutocompleteRenderGroupParams } from '@mui/material/Autocomplete';\nimport ListSubheader from '@mui/material/ListSubheader';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport { Option } from 'types/option';\n\nimport Icon from '../Icon';\n\nimport type { IconName } from './props';\n\nconst LISTBOX_PADDING = 8;\n\nconst ListboxRow = memo((props: ListChildComponentProps) => {\n const { data, index, style } = props;\n const dataSet = data[index] as\n | AutocompleteRenderGroupParams\n | [HTMLAttributes<HTMLLIElement> & { showValueInLabel?: boolean }, Option];\n\n const inlineStyle = {\n ...style,\n top: (style.top as number) + LISTBOX_PADDING,\n paddingTop: 8,\n };\n\n if (Object.prototype.hasOwnProperty.call(dataSet, 'group')) {\n const groupItem = dataSet as AutocompleteRenderGroupParams;\n return (\n <ListSubheader\n key={`list-box-item-group-${groupItem.group}`}\n component=\"div\"\n style={inlineStyle}\n >\n {groupItem.group}\n </ListSubheader>\n );\n }\n\n const [itemProps, option] = dataSet as [\n HTMLAttributes<HTMLLIElement> & {\n showValueInLabel?: boolean;\n key: string;\n },\n Option,\n ];\n const { showValueInLabel, key, ...otherItemProps } = itemProps;\n\n return (\n <Typography\n component=\"li\"\n key={`list-box-item-${key}`}\n {...otherItemProps}\n noWrap\n style={inlineStyle}\n >\n <Stack\n component=\"div\"\n direction=\"row\"\n flex={1}\n gap={1}\n justifyContent=\"start\"\n >\n {option.icon && <Icon icon={option.icon as IconName} />}\n {option.label}\n\n {showValueInLabel && (\n <Typography variant=\"inherit\" color=\"grey.400\">\n ({option.value})\n </Typography>\n )}\n </Stack>\n </Typography>\n );\n});\n\nListboxRow.displayName = 'ListboxRow';\n\nexport { LISTBOX_PADDING };\nexport default ListboxRow;\n","import { createContext } from 'react';\n\nconst ScrollEndContext = createContext<(() => void) | undefined>(undefined);\n\nexport default ScrollEndContext;\n","import { autocompleteClasses } from '@mui/material/Autocomplete';\nimport Popper from '@mui/material/Popper';\nimport { styled } from '@mui/material/styles';\n\nexport const StyledPopper = styled(Popper)({\n [`& .${autocompleteClasses.listbox}`]: {\n boxSizing: 'border-box',\n '& ul': {\n padding: 0,\n margin: 0,\n },\n },\n});\n"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|