plataforma-fundacao-componentes 2.23.20 → 2.23.22
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/hooks/usePublicMenuList/usePublicMenuList.d.ts +23 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +157 -0
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +156 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/models/menus.d.ts +21 -0
- package/dist/utils/ParsingUtils.d.ts +2 -0
- package/package.json +3 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MenuItemProps } from '../../components/menu/components/menuItem/MenuItem';
|
|
2
|
+
import { Item } from '../../models/menus';
|
|
3
|
+
interface Props {
|
|
4
|
+
roles?: string[];
|
|
5
|
+
idFerramenta: string;
|
|
6
|
+
menus: Item[];
|
|
7
|
+
menusLoading?: boolean;
|
|
8
|
+
history: {
|
|
9
|
+
push: (url: string) => void;
|
|
10
|
+
location: any;
|
|
11
|
+
};
|
|
12
|
+
getProgramaLabel: (str: string) => string;
|
|
13
|
+
openModalProfileWarning: (label: string, plural?: boolean, isPerfil?: boolean, labelPrograma?: boolean) => void;
|
|
14
|
+
allProfilesForProgramas: {
|
|
15
|
+
[k: string]: string[];
|
|
16
|
+
};
|
|
17
|
+
isRoute: (str: string, reg: RegExp | string) => boolean;
|
|
18
|
+
closeMenu: () => void;
|
|
19
|
+
incongruencia?: boolean;
|
|
20
|
+
openModalIncongruencia?: () => void;
|
|
21
|
+
}
|
|
22
|
+
export default function usePublicMenuList(props: Props): MenuItemProps[];
|
|
23
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -208,6 +208,7 @@ import useTimeElapsed from './hooks/useTimeElapsed/useTimeElapsed';
|
|
|
208
208
|
import useToastManager from './hooks/useToastManager/useToastManager';
|
|
209
209
|
import useValidatedState from './hooks/useValidatedState/useValidatedState';
|
|
210
210
|
import Chip from './components/chip/Chip';
|
|
211
|
+
import usePublicMenuList from './hooks/usePublicMenuList/usePublicMenuList';
|
|
211
212
|
export * from './components/modal/ModalTypes';
|
|
212
213
|
export * from './libraries/ActionCardThemes';
|
|
213
214
|
export * from './libraries/BlobFileTypes';
|
|
@@ -226,8 +227,12 @@ export * from './libraries/RadioButtonTheme';
|
|
|
226
227
|
export * from './libraries/SicrediLogoThemes';
|
|
227
228
|
export * from './libraries/Toast';
|
|
228
229
|
export * from './libraries/Tooltips';
|
|
230
|
+
export * from './models/menus';
|
|
231
|
+
export { stringToReactElement } from './utils/ParsingUtils';
|
|
229
232
|
export { Accordion, ActionCard, AdvancedSemiHeader, AssembleiaItem, AssembleiaPauta, Aconteceu, AnimatedLink, Banner, BannerAssembleia, BannerPesquisaCpfCnpj, BigBlockButton, BlocoDeNotas, BreadCrumb, Button, ButtonFileUpload, BlocoMinhasAssembleias, BottomNavigation, Card, Carousel, CarouselPersona, CarouselTouchFrendly, Checkbox, Col, Collapse, Container, DatePicker, Doughnut, DoughnutSquare, DropdownItem, DropdownMenu, DropdownSelector, EditableVideoItem, ElementPaginator, Etapas, Etiqueta, FileLoader, FileUpload, FooterSicredi, FullHeightContainer, Header, HeaderSeparator, HeaderSearchField, IconButton, IconButtonWithLabel, Information, Input, InputArea, ItemDropdownDownload, InformativoAssembleiasComImagem, InformativoAssembleiasComVideo, Menu, MenuItem, Modal, ModalManager, Title,
|
|
230
233
|
/**
|
|
231
234
|
* @deprecated
|
|
232
235
|
*/
|
|
233
|
-
Title as ModulosTitle, MoneyByMonth, MoneyMonthLineChart, NotaEdit, Notification, HourEvents, Calendar, CalendarEvent, FloatingPanel, InlineMonthPicker, ScrollArrowOverflow, PageSubTitle, PageTitle, Paginator, PreviaVideo, ProgressBar, RadioButton, QRCode, Row, SearchBlocoDeNotas, Select, Switch, Table, TypedTable, TableFileNameAndAction, TableActions, TableWithOverflow, TextEditor, LeftCheckboxWithLabel, ActionsColumn, Tabs, Toast, ToastManager, Tooltip, TooltipManager, TopLoader, VideoItem, VideoPlayer, VideoModal,
|
|
236
|
+
Title as ModulosTitle, MoneyByMonth, MoneyMonthLineChart, NotaEdit, Notification, HourEvents, Calendar, CalendarEvent, FloatingPanel, InlineMonthPicker, ScrollArrowOverflow, PageSubTitle, PageTitle, Paginator, PreviaVideo, ProgressBar, RadioButton, QRCode, Row, SearchBlocoDeNotas, Select, Switch, Table, TypedTable, TableFileNameAndAction, TableActions, TableWithOverflow, TextEditor, LeftCheckboxWithLabel, ActionsColumn, Tabs, Toast, ToastManager, Tooltip, TooltipManager, TopLoader, VideoItem, VideoPlayer, VideoModal, };
|
|
237
|
+
export { useCallbackedState, useCarouselBehaviour, useControlledTimer, useDraggableContainer, useHTMLShare, useDropOpened, useModalManager, useProgressiveCount, useScreenSize, useStorageState, useTimeElapsed, useToastManager, useValidatedState, usePublicMenuList, };
|
|
238
|
+
export { AconteceuIcon, ChevronArrowRightIcon, FontIcon, PaymentIcon, AddCircleIcon, CircleArrowLeft, CopyIcon, QRCodeIcon, PrintIcon, FormacaoIcon, PercentLoaderIcon, AddIcon, AddAssemblyIcon, CircleArrowRight, FundacaoLogo, PieChartIcon, AlignCenterIcon, ClockIcon, CalendarCheckIcon, DevicePlusIcon, NotebookIcon, AgencyIcon, FundoSocialIcon, PlayIcon, AlignJustifyIcon, CloseIcon, GlobeIcon, QRCodeWhatsapp, AlignLeftIcon, CloudDownloadIcon, GraduationIcon, RedoIcon, AlignRightIcon, CloudUploadIcon, HamburgerIcon, RefreshIcon, ArrowLeftIcon, ComitesIcon, HandUpIcon, SearchIcon, ArrowRightIcon, ComunidadeIcon, HomeIcon, SettingsIcon, AssembleiasIcon, CreditIcon, InformationIcon, SicrediLogo, ATMIcon, CrescerIcon, InvestimentIcon, PhonePlusIcon, SquaresIcon, BackOfficeIcon, CrescerLogo, ItalicIcon, SustentabilidadeIcon, BarChartIcon, Chip, DownloadIcon, LinkIcon, ThreeDotsLoader, BeeIcon, DraggableIcon, LinksUteisIcon, ThumbsUpIcon, BigPlayIcon, EditIcon, ListDotIcon, TimesCircleIcon, BoldIcon, EvidenciasIcon, ListIcon, TransferenciaIcon, CalendarIcon, ExclamationIcon, LoaderIcon, TrashIcon, CardsIcon, ExitIconArrowLeft, LocalIcon, TrianguloInferior, CataventoVerde, ExitIconArrowRight, LockIcon, TwoFileIcon, CheckCircleIcon, EyeIcon, MessageIcon, UnderlineIcon, CheckIcon, FilePlusIcon, MoneyFileIcon, UndoIcon, ChequeIcon, FilesIcon, NavigatorWithMouse, UserIcon, ChevronArrowDownIcon, FilterIcon, OptionsIcon, WebsiteIcon, ChevronArrowLeftIcon, FontColorIcon, ParticipantesIcon, };
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var React = require('react');
|
|
|
4
4
|
var React__default = _interopDefault(React);
|
|
5
5
|
var reactTransitionGroup = require('react-transition-group');
|
|
6
6
|
var moment = _interopDefault(require('moment'));
|
|
7
|
+
var DOMPurify = _interopDefault(require('dompurify'));
|
|
7
8
|
var chart_js = require('chart.js');
|
|
8
9
|
var Sortable = _interopDefault(require('sortablejs'));
|
|
9
10
|
var QR = _interopDefault(require('qrcode'));
|
|
@@ -5067,6 +5068,16 @@ var secondsToHours = function secondsToHours(seconds) {
|
|
|
5067
5068
|
var s = getTwoNumbersIfNotTen(seconds - h * 3600 - m * 60);
|
|
5068
5069
|
return hh.concat(':').concat(mm).concat(':').concat(s);
|
|
5069
5070
|
};
|
|
5071
|
+
var stringToReactElement = function stringToReactElement(str, props) {
|
|
5072
|
+
var __html = DOMPurify.sanitize(str);
|
|
5073
|
+
|
|
5074
|
+
var el = React__default.createElement("div", Object.assign({}, props, {
|
|
5075
|
+
dangerouslySetInnerHTML: {
|
|
5076
|
+
__html: __html
|
|
5077
|
+
}
|
|
5078
|
+
}));
|
|
5079
|
+
return el;
|
|
5080
|
+
};
|
|
5070
5081
|
|
|
5071
5082
|
var rootClassName$1G = 'component-button';
|
|
5072
5083
|
|
|
@@ -40713,6 +40724,150 @@ function Chip(props) {
|
|
|
40713
40724
|
|
|
40714
40725
|
var Chip$1 = React.memo(Chip);
|
|
40715
40726
|
|
|
40727
|
+
var References;
|
|
40728
|
+
|
|
40729
|
+
(function (References) {
|
|
40730
|
+
References[References["FORCE_CLOSE"] = -1] = "FORCE_CLOSE";
|
|
40731
|
+
References[References["OPENED_ACTIVE"] = 0] = "OPENED_ACTIVE";
|
|
40732
|
+
})(References || (References = {}));
|
|
40733
|
+
|
|
40734
|
+
var sortItems = function sortItems(a, b) {
|
|
40735
|
+
return a.ordem - b.ordem;
|
|
40736
|
+
};
|
|
40737
|
+
|
|
40738
|
+
function usePublicMenuList(props) {
|
|
40739
|
+
var hasPermission = React.useCallback(function (need) {
|
|
40740
|
+
var role = !need.roles || !need.roles.length || need.roles.some(function (role) {
|
|
40741
|
+
return props.roles && props.roles.find(function (up) {
|
|
40742
|
+
return up === role;
|
|
40743
|
+
});
|
|
40744
|
+
});
|
|
40745
|
+
var programa = !need.programas || !need.programas.length || need.programas.some(function (prog) {
|
|
40746
|
+
var _props$allProfilesFor;
|
|
40747
|
+
|
|
40748
|
+
return props.allProfilesForProgramas[prog] && ((_props$allProfilesFor = props.allProfilesForProgramas[prog]) === null || _props$allProfilesFor === void 0 ? void 0 : _props$allProfilesFor.some(function (profile) {
|
|
40749
|
+
return props.roles && props.roles.includes(profile);
|
|
40750
|
+
}));
|
|
40751
|
+
});
|
|
40752
|
+
return role && programa;
|
|
40753
|
+
}, [props.allProfilesForProgramas, props.roles]);
|
|
40754
|
+
|
|
40755
|
+
var _useState = React.useState(References.OPENED_ACTIVE),
|
|
40756
|
+
subListReference = _useState[0],
|
|
40757
|
+
setSubListReference = _useState[1];
|
|
40758
|
+
|
|
40759
|
+
var isOpenedByReference = React.useCallback(function (reference) {
|
|
40760
|
+
return reference === subListReference;
|
|
40761
|
+
}, [subListReference]);
|
|
40762
|
+
var setOpenedByReference = React.useCallback(function (reference) {
|
|
40763
|
+
if (isOpenedByReference(reference)) {
|
|
40764
|
+
setSubListReference(References.FORCE_CLOSE);
|
|
40765
|
+
} else {
|
|
40766
|
+
setSubListReference(reference);
|
|
40767
|
+
}
|
|
40768
|
+
}, [isOpenedByReference]);
|
|
40769
|
+
var handleClickLink = React.useCallback(function (url, obj) {
|
|
40770
|
+
var target = obj.novaAba ? '_blank' : '_self';
|
|
40771
|
+
var isPermitted = !obj.permissoes || hasPermission(obj.permissoes);
|
|
40772
|
+
var watchIncongruencia = obj.permissoes && obj.permissoes.incongruencia;
|
|
40773
|
+
|
|
40774
|
+
if (watchIncongruencia && props.incongruencia && typeof props.openModalIncongruencia === 'function') {
|
|
40775
|
+
props.openModalIncongruencia();
|
|
40776
|
+
} else if (isPermitted) {
|
|
40777
|
+
if (obj.internal) {
|
|
40778
|
+
props.history.push(url.replace(window.location.origin, ''));
|
|
40779
|
+
} else {
|
|
40780
|
+
window.open(url, target);
|
|
40781
|
+
}
|
|
40782
|
+
|
|
40783
|
+
setOpenedByReference(References.OPENED_ACTIVE);
|
|
40784
|
+
} else if (obj.permissoes) {
|
|
40785
|
+
var _obj$permissoes$progr, _obj$permissoes$roles;
|
|
40786
|
+
|
|
40787
|
+
var isPrograma = obj.permissoes.programas && !!obj.permissoes.programas.length;
|
|
40788
|
+
var plural = isPrograma ? obj.permissoes.programas && obj.permissoes.programas.length > 1 : obj.permissoes.roles && obj.permissoes.roles.length > 1;
|
|
40789
|
+
var label = isPrograma ? (_obj$permissoes$progr = obj.permissoes.programas) === null || _obj$permissoes$progr === void 0 ? void 0 : _obj$permissoes$progr.map(function (prog) {
|
|
40790
|
+
var _props$getProgramaLab;
|
|
40791
|
+
|
|
40792
|
+
return (_props$getProgramaLab = props.getProgramaLabel(prog)) != null ? _props$getProgramaLab : '';
|
|
40793
|
+
}).join(', ') : (_obj$permissoes$roles = obj.permissoes.roles) === null || _obj$permissoes$roles === void 0 ? void 0 : _obj$permissoes$roles.join(', ');
|
|
40794
|
+
props.openModalProfileWarning(label || '', plural, !isPrograma, obj.labelPrograma);
|
|
40795
|
+
setOpenedByReference(References.FORCE_CLOSE);
|
|
40796
|
+
}
|
|
40797
|
+
|
|
40798
|
+
props.closeMenu();
|
|
40799
|
+
}, [hasPermission, props, setOpenedByReference]);
|
|
40800
|
+
var getSubList = React.useCallback(function (itens) {
|
|
40801
|
+
if (!itens || !itens.length) return undefined;
|
|
40802
|
+
return itens.sort(sortItems).filter(function (sub) {
|
|
40803
|
+
if (sub.permissoes && sub.permissoes.hide) {
|
|
40804
|
+
return hasPermission(sub.permissoes);
|
|
40805
|
+
}
|
|
40806
|
+
|
|
40807
|
+
return true;
|
|
40808
|
+
}).map(function (sub) {
|
|
40809
|
+
return {
|
|
40810
|
+
id: sub.id,
|
|
40811
|
+
icon: React__default.createElement(ListDotIcon, null),
|
|
40812
|
+
label: sub.label,
|
|
40813
|
+
active: sub.regex ? props.isRoute(window.location.pathname, new RegExp(sub.regex)) : false,
|
|
40814
|
+
onClick: function onClick() {
|
|
40815
|
+
if (sub.url) handleClickLink(sub.url, {
|
|
40816
|
+
novaAba: sub.novaAba,
|
|
40817
|
+
permissoes: sub.permissoes,
|
|
40818
|
+
internal: Boolean(sub.idFerramenta && sub.idFerramenta === props.idFerramenta),
|
|
40819
|
+
labelPrograma: sub.labelPrograma
|
|
40820
|
+
});
|
|
40821
|
+
}
|
|
40822
|
+
};
|
|
40823
|
+
});
|
|
40824
|
+
}, [handleClickLink, hasPermission, props]);
|
|
40825
|
+
var menus = React.useMemo(function () {
|
|
40826
|
+
if (!props.menus) return [];
|
|
40827
|
+
return props.menus.sort(sortItems).filter(function (item) {
|
|
40828
|
+
var _item$subItems;
|
|
40829
|
+
|
|
40830
|
+
if (item.permissoes && item.permissoes.hide || (_item$subItems = item.subItems) !== null && _item$subItems !== void 0 && _item$subItems.some(function (s) {
|
|
40831
|
+
return s.permissoes && s.permissoes.hide;
|
|
40832
|
+
})) {
|
|
40833
|
+
var _item$subItems2;
|
|
40834
|
+
|
|
40835
|
+
return !((_item$subItems2 = item.subItems) !== null && _item$subItems2 !== void 0 && _item$subItems2.every(function (s) {
|
|
40836
|
+
return s.permissoes && s.permissoes.hide && !hasPermission(s.permissoes);
|
|
40837
|
+
}));
|
|
40838
|
+
}
|
|
40839
|
+
|
|
40840
|
+
return true;
|
|
40841
|
+
}).map(function (it) {
|
|
40842
|
+
return {
|
|
40843
|
+
icon: stringToReactElement(it.icon, {
|
|
40844
|
+
style: {
|
|
40845
|
+
height: '24px',
|
|
40846
|
+
width: '24px'
|
|
40847
|
+
}
|
|
40848
|
+
}),
|
|
40849
|
+
label: it.label,
|
|
40850
|
+
active: it.regex ? props.isRoute(window.location.pathname, new RegExp(it.regex)) : false,
|
|
40851
|
+
onClick: it.url ? function () {
|
|
40852
|
+
var _it$novaAba;
|
|
40853
|
+
|
|
40854
|
+
return handleClickLink(it.url, {
|
|
40855
|
+
novaAba: (_it$novaAba = it.novaAba) != null ? _it$novaAba : false,
|
|
40856
|
+
permissoes: it.permissoes,
|
|
40857
|
+
internal: Boolean(it.idFerramenta && it.idFerramenta === props.idFerramenta),
|
|
40858
|
+
labelPrograma: it.labelPrograma
|
|
40859
|
+
});
|
|
40860
|
+
} : function () {
|
|
40861
|
+
setOpenedByReference(it.id);
|
|
40862
|
+
},
|
|
40863
|
+
subListOpened: isOpenedByReference(it.id),
|
|
40864
|
+
subList: getSubList(it.subItems)
|
|
40865
|
+
};
|
|
40866
|
+
});
|
|
40867
|
+
}, [isOpenedByReference, props.menus, props.history.location]);
|
|
40868
|
+
return menus;
|
|
40869
|
+
}
|
|
40870
|
+
|
|
40716
40871
|
function AlertModal(props) {
|
|
40717
40872
|
var _useState = React.useState(false),
|
|
40718
40873
|
loading = _useState[0],
|
|
@@ -41071,6 +41226,7 @@ exports.VideoModal = VideoModal;
|
|
|
41071
41226
|
exports.VideoPlayer = VideoPlayer;
|
|
41072
41227
|
exports.WebsiteIcon = WebsiteIcon;
|
|
41073
41228
|
exports.getStatusClassName = getStatusClassName;
|
|
41229
|
+
exports.stringToReactElement = stringToReactElement;
|
|
41074
41230
|
exports.useCallbackedState = useCallbackedState;
|
|
41075
41231
|
exports.useCarouselBehaviour = useCarouselBehaviour;
|
|
41076
41232
|
exports.useControlledTimer = useControlledTimer;
|
|
@@ -41079,6 +41235,7 @@ exports.useDropOpened = useDropOpened;
|
|
|
41079
41235
|
exports.useHTMLShare = useHTMLShare;
|
|
41080
41236
|
exports.useModalManager = useModalManager;
|
|
41081
41237
|
exports.useProgressiveCount = useProgressiveCount;
|
|
41238
|
+
exports.usePublicMenuList = usePublicMenuList;
|
|
41082
41239
|
exports.useScreenSize = useScreenSize;
|
|
41083
41240
|
exports.useStorageState = useStorageState;
|
|
41084
41241
|
exports.useTimeElapsed = useTimeElapsed;
|