@govbr-ds/webcomponents 2.1.0 → 2.1.2
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 +0 -11
- package/cem/custom-elements.json +272 -71
- package/dist/cjs/app-globals-DcqHuMBv.js +9 -0
- package/dist/cjs/br-avatar.cjs.entry.js +248 -0
- package/dist/cjs/br-breadcrumb-item.cjs.entry.js +45 -0
- package/dist/cjs/br-breadcrumb.cjs.entry.js +443 -0
- package/dist/cjs/br-button_2.cjs.entry.js +280 -0
- package/dist/cjs/br-card.cjs.entry.js +111 -0
- package/dist/cjs/br-carousel-page.cjs.entry.js +80 -0
- package/dist/cjs/br-carousel.cjs.entry.js +565 -0
- package/dist/cjs/br-checkbox-group.cjs.entry.js +118 -0
- package/dist/cjs/br-checkbox.cjs.entry.js +288 -0
- package/dist/cjs/br-checkgroup.cjs.entry.js +20 -0
- package/dist/cjs/br-collapse_2.cjs.entry.js +683 -0
- package/dist/cjs/br-cookiebar-cookie.cjs.entry.js +83 -0
- package/dist/cjs/br-cookiebar-group.cjs.entry.js +309 -0
- package/dist/cjs/br-cookiebar-header.cjs.entry.js +39 -0
- package/dist/cjs/br-cookiebar-link.cjs.entry.js +55 -0
- package/dist/cjs/br-cookiebar-note-group.cjs.entry.js +70 -0
- package/dist/cjs/br-cookiebar-note.cjs.entry.js +25 -0
- package/dist/cjs/br-cookiebar.cjs.entry.js +758 -0
- package/dist/cjs/br-crumb.cjs.entry.js +51 -0
- package/dist/cjs/br-date-picker_3.cjs.entry.js +2447 -0
- package/dist/cjs/br-datetime-picker.cjs.entry.js +1886 -0
- package/dist/cjs/br-divider.cjs.entry.js +225 -0
- package/dist/cjs/br-dropdown_2.cjs.entry.js +2000 -0
- package/dist/cjs/br-footer-category.cjs.entry.js +102 -0
- package/dist/cjs/br-footer-item.cjs.entry.js +52 -0
- package/dist/cjs/br-footer-legal.cjs.entry.js +41 -0
- package/dist/cjs/br-footer-logo.cjs.entry.js +104 -0
- package/dist/cjs/br-footer-social.cjs.entry.js +71 -0
- package/dist/cjs/br-footer.cjs.entry.js +92 -0
- package/dist/cjs/br-header-function.cjs.entry.js +142 -0
- package/dist/cjs/br-header-link.cjs.entry.js +60 -0
- package/dist/cjs/br-header-list.cjs.entry.js +279 -0
- package/dist/cjs/br-header-logo.cjs.entry.js +178 -0
- package/dist/cjs/br-header.cjs.entry.js +642 -0
- package/dist/cjs/br-icon.cjs.entry.js +485 -0
- package/dist/cjs/br-input.cjs.entry.js +599 -0
- package/dist/cjs/br-item.cjs.entry.js +367 -0
- package/dist/cjs/br-link.cjs.entry.js +133 -0
- package/dist/cjs/br-loading.cjs.entry.js +505 -0
- package/dist/cjs/br-magic-button.cjs.entry.js +93 -0
- package/dist/cjs/br-menu-group.cjs.entry.js +23 -0
- package/dist/cjs/br-menu-header.cjs.entry.js +47 -0
- package/dist/cjs/br-menu-info.cjs.entry.js +38 -0
- package/dist/cjs/br-menu-item.cjs.entry.js +79 -0
- package/dist/cjs/br-menu-link.cjs.entry.js +56 -0
- package/dist/cjs/br-menu-list.cjs.entry.js +149 -0
- package/dist/cjs/br-menu-logo.cjs.entry.js +75 -0
- package/dist/cjs/br-menu-social.cjs.entry.js +65 -0
- package/dist/cjs/br-menu.cjs.entry.js +993 -0
- package/dist/cjs/br-modal.cjs.entry.js +496 -0
- package/dist/cjs/br-notification-body.cjs.entry.js +71 -0
- package/dist/cjs/br-notification-header.cjs.entry.js +48 -0
- package/dist/cjs/br-notification-item.cjs.entry.js +110 -0
- package/dist/cjs/br-notification.cjs.entry.js +334 -0
- package/dist/cjs/br-pagination.cjs.entry.js +884 -0
- package/dist/cjs/br-radio-group.cjs.entry.js +428 -0
- package/dist/cjs/br-radio.cjs.entry.js +357 -0
- package/dist/cjs/br-scrim.cjs.entry.js +1336 -0
- package/dist/cjs/br-select-input_3.cjs.entry.js +988 -0
- package/dist/cjs/br-sign-in.cjs.entry.js +126 -0
- package/dist/cjs/br-skip-link-item.cjs.entry.js +20 -0
- package/dist/cjs/br-skip-link.cjs.entry.js +362 -0
- package/dist/cjs/br-skiplink-item.cjs.entry.js +192 -0
- package/dist/cjs/br-slider.cjs.entry.js +687 -0
- package/dist/cjs/br-step_2.cjs.entry.js +628 -0
- package/dist/cjs/br-switch.cjs.entry.js +245 -0
- package/dist/cjs/br-tab-item.cjs.entry.js +185 -0
- package/dist/cjs/br-tab.cjs.entry.js +397 -0
- package/dist/cjs/br-table-body.cjs.entry.js +37 -0
- package/dist/cjs/br-table-cell.cjs.entry.js +184 -0
- package/dist/cjs/br-table-header-cell.cjs.entry.js +173 -0
- package/dist/cjs/br-table-header.cjs.entry.js +37 -0
- package/dist/cjs/br-table-row.cjs.entry.js +81 -0
- package/dist/cjs/br-table.cjs.entry.js +680 -0
- package/dist/cjs/br-tag.cjs.entry.js +493 -0
- package/dist/cjs/br-textarea.cjs.entry.js +306 -0
- package/dist/cjs/br-tooltip.cjs.entry.js +627 -0
- package/dist/cjs/br-upload.cjs.entry.js +581 -0
- package/dist/cjs/br-wizard-panel.cjs.entry.js +54 -0
- package/dist/cjs/br-wizard.cjs.entry.js +708 -0
- package/dist/cjs/breakpoint-observer-P8veqXg7.js +144 -0
- package/dist/cjs/clamp-Co_hWptd.js +25 -0
- package/dist/cjs/cookiebar.utils-CB1gQwZ4.js +18 -0
- package/dist/cjs/datetime-picker-constants-B5pWeOn1.js +3827 -0
- package/dist/cjs/event-CmVdNHxl.js +56 -0
- package/dist/cjs/floating-surface-dismiss-ccdiD0KF.js +63 -0
- package/dist/cjs/floating-ui-MBI1osio.js +136 -0
- package/dist/cjs/floating-ui.dom-BUSTaaxR.js +1715 -0
- package/dist/cjs/focus-DuywwJPR.js +30 -0
- package/dist/cjs/getNextElement-R9l3JtM9.js +31 -0
- package/dist/cjs/iconify-icon-DfODV9bf.js +2307 -0
- package/dist/cjs/id-CjRFMzf6.js +20 -0
- package/dist/cjs/index-C92n55ch.js +678 -0
- package/dist/cjs/index-CRdcutym.js +3287 -0
- package/dist/cjs/index.cjs.js +12 -0
- package/dist/cjs/isNil-DO5zWc3l.js +19 -0
- package/dist/cjs/isValid-Fu3kaWNn.js +3694 -0
- package/dist/cjs/loader.cjs.js +17 -0
- package/dist/cjs/native-dialog--Ewqm4w0.js +49 -0
- package/dist/cjs/navigation-AbzwcRCU.js +25 -0
- package/dist/cjs/parts-D5K3ae2C.js +19 -0
- package/dist/cjs/props-CScmBvKd.js +24 -0
- package/dist/cjs/raf-batcher-yc87a4dS.js +55 -0
- package/dist/cjs/slot-DAllytTj.js +48 -0
- package/dist/cjs/swipe-BU8_XE9f.js +345 -0
- package/dist/cjs/table-constants-BOPSay0B.js +183 -0
- package/dist/cjs/validator-CTCajtT9.js +123 -0
- package/dist/cjs/webcomponents.cjs.js +50 -0
- package/dist/collection/assets/icon-search.svg +6 -0
- package/dist/collection/assets/logo-negative.svg +1 -0
- package/dist/collection/assets/logo-positive.svg +1 -0
- package/dist/collection/assets/wc.svg +1 -0
- package/dist/collection/collection-manifest.json +113 -0
- package/dist/collection/components/avatar/avatar.css +1 -0
- package/dist/collection/components/avatar/avatar.js +589 -0
- package/dist/collection/components/avatar/avatar.types.js +1 -0
- package/dist/collection/components/breadcrumb/breadcrumb-item/breadcrumb-item.js +166 -0
- package/dist/collection/components/breadcrumb/breadcrumb.css +1 -0
- package/dist/collection/components/breadcrumb/breadcrumb.js +619 -0
- package/dist/collection/components/breadcrumb/breadcrumb.types.js +1 -0
- package/dist/collection/components/breadcrumb/crumb/crumb.js +175 -0
- package/dist/collection/components/button/button.css +1 -0
- package/dist/collection/components/button/button.js +546 -0
- package/dist/collection/components/button/button.types.js +1 -0
- package/dist/collection/components/card/card.css +1 -0
- package/dist/collection/components/card/card.js +225 -0
- package/dist/collection/components/carousel/carousel-page/carousel-page.css +1 -0
- package/dist/collection/components/carousel/carousel-page/carousel-page.js +195 -0
- package/dist/collection/components/carousel/carousel.css +1 -0
- package/dist/collection/components/carousel/carousel.js +1217 -0
- package/dist/collection/components/carousel/carousel.types.js +1 -0
- package/dist/collection/components/checkbox/checkbox.css +1 -0
- package/dist/collection/components/checkbox/checkbox.js +823 -0
- package/dist/collection/components/checkbox/checkbox.types.js +1 -0
- package/dist/collection/components/checkbox-group/checkbox-group.css +1 -0
- package/dist/collection/components/checkbox-group/checkbox-group.js +268 -0
- package/dist/collection/components/checkgroup/checkgroup.js +166 -0
- package/dist/collection/components/collapse/collapse.css +1 -0
- package/dist/collection/components/collapse/collapse.js +642 -0
- package/dist/collection/components/collapse/collapse.types.js +1 -0
- package/dist/collection/components/cookiebar/cookiebar-cookie/cookiebar-cookie.css +1 -0
- package/dist/collection/components/cookiebar/cookiebar-cookie/cookiebar-cookie.js +529 -0
- package/dist/collection/components/cookiebar/cookiebar-group/cookiebar-group.css +1 -0
- package/dist/collection/components/cookiebar/cookiebar-group/cookiebar-group.js +628 -0
- package/dist/collection/components/cookiebar/cookiebar-header/cookiebar-header.css +1 -0
- package/dist/collection/components/cookiebar/cookiebar-header/cookiebar-header.js +165 -0
- package/dist/collection/components/cookiebar/cookiebar-link/cookiebar-link.css +1 -0
- package/dist/collection/components/cookiebar/cookiebar-link/cookiebar-link.js +201 -0
- package/dist/collection/components/cookiebar/cookiebar-note/cookiebar-note.css +1 -0
- package/dist/collection/components/cookiebar/cookiebar-note/cookiebar-note.js +100 -0
- package/dist/collection/components/cookiebar/cookiebar-note-group/cookiebar-note-group.css +1 -0
- package/dist/collection/components/cookiebar/cookiebar-note-group/cookiebar-note-group.js +172 -0
- package/dist/collection/components/cookiebar/cookiebar.css +1 -0
- package/dist/collection/components/cookiebar/cookiebar.js +1419 -0
- package/dist/collection/components/cookiebar/cookiebar.types.js +1 -0
- package/dist/collection/components/cookiebar/cookiebar.utils.js +14 -0
- package/dist/collection/components/datetime-picker/date-picker/date-picker-locale.js +94 -0
- package/dist/collection/components/datetime-picker/date-picker/date-picker-props-validation.js +57 -0
- package/dist/collection/components/datetime-picker/date-picker/date-picker.css +1 -0
- package/dist/collection/components/datetime-picker/date-picker/date-picker.js +913 -0
- package/dist/collection/components/datetime-picker/datetime-input/datetime-input-props-validation.js +65 -0
- package/dist/collection/components/datetime-picker/datetime-input/datetime-input.css +1 -0
- package/dist/collection/components/datetime-picker/datetime-input/datetime-input.js +826 -0
- package/dist/collection/components/datetime-picker/datetime-picker-constants.js +36 -0
- package/dist/collection/components/datetime-picker/datetime-picker-form-associated.js +112 -0
- package/dist/collection/components/datetime-picker/datetime-picker-props-validation.js +202 -0
- package/dist/collection/components/datetime-picker/datetime-picker.css +1 -0
- package/dist/collection/components/datetime-picker/datetime-picker.js +1924 -0
- package/dist/collection/components/datetime-picker/datetime-picker.types.js +1 -0
- package/dist/collection/components/datetime-picker/datetime-picker.utils.js +250 -0
- package/dist/collection/components/datetime-picker/time-picker/time-picker-constants.js +13 -0
- package/dist/collection/components/datetime-picker/time-picker/time-picker.css +1 -0
- package/dist/collection/components/datetime-picker/time-picker/time-picker.js +456 -0
- package/dist/collection/components/divider/divider.css +1 -0
- package/dist/collection/components/divider/divider.js +537 -0
- package/dist/collection/components/divider/divider.types.js +1 -0
- package/dist/collection/components/dropdown/dropdown.css +1 -0
- package/dist/collection/components/dropdown/dropdown.js +939 -0
- package/dist/collection/components/dropdown/dropdown.types.js +1 -0
- package/dist/collection/components/footer/footer-category/footer-category.css +1 -0
- package/dist/collection/components/footer/footer-category/footer-category.js +160 -0
- package/dist/collection/components/footer/footer-item/footer-item.css +1 -0
- package/dist/collection/components/footer/footer-item/footer-item.js +154 -0
- package/dist/collection/components/footer/footer-legal/footer-legal.css +1 -0
- package/dist/collection/components/footer/footer-legal/footer-legal.js +75 -0
- package/dist/collection/components/footer/footer-logo/footer-logo.css +1 -0
- package/dist/collection/components/footer/footer-logo/footer-logo.js +342 -0
- package/dist/collection/components/footer/footer-logo/footer-logo.types.js +1 -0
- package/dist/collection/components/footer/footer-social/footer-social.css +1 -0
- package/dist/collection/components/footer/footer-social/footer-social.js +239 -0
- package/dist/collection/components/footer/footer.css +1 -0
- package/dist/collection/components/footer/footer.js +245 -0
- package/dist/collection/components/footer/footer.types.js +1 -0
- package/dist/collection/components/global.types.js +1 -0
- package/dist/collection/components/header/header-function/header-function.css +1 -0
- package/dist/collection/components/header/header-function/header-function.js +311 -0
- package/dist/collection/components/header/header-link/header-link.css +1 -0
- package/dist/collection/components/header/header-link/header-link.js +189 -0
- package/dist/collection/components/header/header-list/header-list.css +1 -0
- package/dist/collection/components/header/header-list/header-list.js +452 -0
- package/dist/collection/components/header/header-logo/header-logo.css +1 -0
- package/dist/collection/components/header/header-logo/header-logo.js +421 -0
- package/dist/collection/components/header/header.css +1 -0
- package/dist/collection/components/header/header.js +1131 -0
- package/dist/collection/components/header/header.types.js +1 -0
- package/dist/collection/components/icon/default-icons-cache.js +233 -0
- package/dist/collection/components/icon/icon.css +1 -0
- package/dist/collection/components/icon/icon.js +598 -0
- package/dist/collection/components/icon/icon.types.js +1 -0
- package/dist/collection/components/icon/icon.utils.js +33 -0
- package/dist/collection/components/input/input.css +1 -0
- package/dist/collection/components/input/input.js +1642 -0
- package/dist/collection/components/input/input.types.js +1 -0
- package/dist/collection/components/item/item.css +1 -0
- package/dist/collection/components/item/item.js +917 -0
- package/dist/collection/components/item/item.types.js +1 -0
- package/dist/collection/components/link/link.css +1 -0
- package/dist/collection/components/link/link.js +699 -0
- package/dist/collection/components/list/list.css +1 -0
- package/dist/collection/components/list/list.js +728 -0
- package/dist/collection/components/loading/loading.css +1 -0
- package/dist/collection/components/loading/loading.js +1169 -0
- package/dist/collection/components/loading/loading.types.js +1 -0
- package/dist/collection/components/magic-button/magic-button.css +1 -0
- package/dist/collection/components/magic-button/magic-button.js +238 -0
- package/dist/collection/components/menu/menu-group/menu-group.css +1 -0
- package/dist/collection/components/menu/menu-group/menu-group.js +77 -0
- package/dist/collection/components/menu/menu-header/menu-header.css +1 -0
- package/dist/collection/components/menu/menu-header/menu-header.js +161 -0
- package/dist/collection/components/menu/menu-info/menu-info.css +1 -0
- package/dist/collection/components/menu/menu-info/menu-info.js +94 -0
- package/dist/collection/components/menu/menu-item/menu-item.css +1 -0
- package/dist/collection/components/menu/menu-item/menu-item.js +306 -0
- package/dist/collection/components/menu/menu-item/menu-item.types.js +1 -0
- package/dist/collection/components/menu/menu-link/menu-link.css +1 -0
- package/dist/collection/components/menu/menu-link/menu-link.js +260 -0
- package/dist/collection/components/menu/menu-list/menu-list.css +1 -0
- package/dist/collection/components/menu/menu-list/menu-list.js +311 -0
- package/dist/collection/components/menu/menu-logo/menu-logo.css +1 -0
- package/dist/collection/components/menu/menu-logo/menu-logo.js +230 -0
- package/dist/collection/components/menu/menu-social/menu-social.css +1 -0
- package/dist/collection/components/menu/menu-social/menu-social.js +263 -0
- package/dist/collection/components/menu/menu.css +1 -0
- package/dist/collection/components/menu/menu.js +1372 -0
- package/dist/collection/components/menu/menu.types.js +1 -0
- package/dist/collection/components/menu/menu.utils.js +279 -0
- package/dist/collection/components/message/message.css +1 -0
- package/dist/collection/components/message/message.js +508 -0
- package/dist/collection/components/modal/modal.css +1 -0
- package/dist/collection/components/modal/modal.js +842 -0
- package/dist/collection/components/modal/modal.types.js +1 -0
- package/dist/collection/components/notification/notification-body/notification-body.css +1 -0
- package/dist/collection/components/notification/notification-body/notification-body.js +153 -0
- package/dist/collection/components/notification/notification-header/notification-header.css +1 -0
- package/dist/collection/components/notification/notification-header/notification-header.js +181 -0
- package/dist/collection/components/notification/notification-item/notification-item.css +1 -0
- package/dist/collection/components/notification/notification-item/notification-item.js +351 -0
- package/dist/collection/components/notification/notification-item/notification-item.types.js +1 -0
- package/dist/collection/components/notification/notification.css +1 -0
- package/dist/collection/components/notification/notification.js +838 -0
- package/dist/collection/components/notification/notification.types.js +1 -0
- package/dist/collection/components/pagination/pagination.css +1 -0
- package/dist/collection/components/pagination/pagination.js +1470 -0
- package/dist/collection/components/pagination/pagination.types.js +1 -0
- package/dist/collection/components/radio/radio.css +1 -0
- package/dist/collection/components/radio/radio.js +847 -0
- package/dist/collection/components/radio/radio.types.js +1 -0
- package/dist/collection/components/radio-group/radio-group.css +1 -0
- package/dist/collection/components/radio-group/radio-group.js +862 -0
- package/dist/collection/components/radio-group/radio-group.types.js +1 -0
- package/dist/collection/components/scrim/scrim.css +1 -0
- package/dist/collection/components/scrim/scrim.js +1825 -0
- package/dist/collection/components/scrim/scrim.types.js +1 -0
- package/dist/collection/components/scrim/scrim.utils.js +132 -0
- package/dist/collection/components/select/select-input/select-input.css +1 -0
- package/dist/collection/components/select/select-input/select-input.js +586 -0
- package/dist/collection/components/select/select-list/select-list.css +1 -0
- package/dist/collection/components/select/select-list/select-list.js +1159 -0
- package/dist/collection/components/select/select-option/select-option.css +1 -0
- package/dist/collection/components/select/select-option/select-option.js +564 -0
- package/dist/collection/components/select/select.constants.js +6 -0
- package/dist/collection/components/select/select.css +1 -0
- package/dist/collection/components/select/select.js +2692 -0
- package/dist/collection/components/select/select.types.js +1 -0
- package/dist/collection/components/select/select.utils.js +34 -0
- package/dist/collection/components/sign-in/sign-in.css +1 -0
- package/dist/collection/components/sign-in/sign-in.js +401 -0
- package/dist/collection/components/sign-in/sign-in.types.js +1 -0
- package/dist/collection/components/skip-link/skip-link-item/skip-link-item-alias.js +103 -0
- package/dist/collection/components/skip-link/skip-link-item/skip-link-item.css +1 -0
- package/dist/collection/components/skip-link/skip-link-item/skip-link-item.js +450 -0
- package/dist/collection/components/skip-link/skip-link.css +1 -0
- package/dist/collection/components/skip-link/skip-link.js +699 -0
- package/dist/collection/components/skip-link/skip-link.types.js +1 -0
- package/dist/collection/components/slider/slider.css +1 -0
- package/dist/collection/components/slider/slider.js +1324 -0
- package/dist/collection/components/slider/slider.types.js +1 -0
- package/dist/collection/components/step/step-item/step-item.css +1 -0
- package/dist/collection/components/step/step-item/step-item.js +604 -0
- package/dist/collection/components/step/step-item/step-item.types.js +1 -0
- package/dist/collection/components/step/step.css +1 -0
- package/dist/collection/components/step/step.js +896 -0
- package/dist/collection/components/step/step.types.js +1 -0
- package/dist/collection/components/switch/switch.css +1 -0
- package/dist/collection/components/switch/switch.js +715 -0
- package/dist/collection/components/switch/switch.types.js +1 -0
- package/dist/collection/components/tab/tab-item/tab-item.css +1 -0
- package/dist/collection/components/tab/tab-item/tab-item.js +425 -0
- package/dist/collection/components/tab/tab.css +1 -0
- package/dist/collection/components/tab/tab.js +724 -0
- package/dist/collection/components/tab/tab.types.js +1 -0
- package/dist/collection/components/table/table-body/table-body.css +1 -0
- package/dist/collection/components/table/table-body/table-body.js +51 -0
- package/dist/collection/components/table/table-cell/table-cell.css +1 -0
- package/dist/collection/components/table/table-cell/table-cell.js +373 -0
- package/dist/collection/components/table/table-constants.js +171 -0
- package/dist/collection/components/table/table-header/table-header.css +1 -0
- package/dist/collection/components/table/table-header/table-header.js +51 -0
- package/dist/collection/components/table/table-header-cell/table-header-cell.css +1 -0
- package/dist/collection/components/table/table-header-cell/table-header-cell.js +402 -0
- package/dist/collection/components/table/table-row/table-row.css +1 -0
- package/dist/collection/components/table/table-row/table-row.js +261 -0
- package/dist/collection/components/table/table-tokens.js +50 -0
- package/dist/collection/components/table/table-types.js +1 -0
- package/dist/collection/components/table/table-utils.js +44 -0
- package/dist/collection/components/table/table.css +1 -0
- package/dist/collection/components/table/table.js +1030 -0
- package/dist/collection/components/tag/tag.css +1 -0
- package/dist/collection/components/tag/tag.js +1152 -0
- package/dist/collection/components/tag/tag.types.js +1 -0
- package/dist/collection/components/textarea/textarea.css +1 -0
- package/dist/collection/components/textarea/textarea.js +985 -0
- package/dist/collection/components/textarea/textarea.types.js +1 -0
- package/dist/collection/components/tooltip/tooltip.css +1 -0
- package/dist/collection/components/tooltip/tooltip.js +1024 -0
- package/dist/collection/components/tooltip/tooltip.types.js +1 -0
- package/dist/collection/components/upload/upload.css +1 -0
- package/dist/collection/components/upload/upload.js +1314 -0
- package/dist/collection/components/upload/upload.types.js +1 -0
- package/dist/collection/components/wizard/wizard-panel/wizard-panel.css +1 -0
- package/dist/collection/components/wizard/wizard-panel/wizard-panel.js +167 -0
- package/dist/collection/components/wizard/wizard.css +1 -0
- package/dist/collection/components/wizard/wizard.js +1228 -0
- package/dist/collection/index.js +14 -0
- package/dist/collection/pages/components/cookiebar/index.js +26 -0
- package/dist/collection/pages/components/link/index.js +29 -0
- package/dist/collection/pages/components/pagination/index.js +12 -0
- package/dist/collection/pages/components/slider/index.js +18 -0
- package/dist/collection/pages/scripts/code-editor.js +101 -0
- package/dist/collection/pages/scripts/component-controls.js +600 -0
- package/dist/collection/pages/scripts/dev-event-console.js +47 -0
- package/dist/collection/pages/scripts/menu.js +192 -0
- package/dist/collection/pages/scripts/pageLoader.js +1422 -0
- package/dist/collection/shared/utils/assetsPath.js +75 -0
- package/dist/collection/shared/utils/breakpoint-observer.js +139 -0
- package/dist/collection/shared/utils/clamp.js +21 -0
- package/dist/collection/shared/utils/css-variables.js +12 -0
- package/dist/collection/shared/utils/cssVariables.js +37 -0
- package/dist/collection/shared/utils/date.js +405 -0
- package/dist/collection/shared/utils/debounce.js +39 -0
- package/dist/collection/shared/utils/event.js +55 -0
- package/dist/collection/shared/utils/floating-surface-dismiss.js +59 -0
- package/dist/collection/shared/utils/floating-ui.js +131 -0
- package/dist/collection/shared/utils/focus.js +24 -0
- package/dist/collection/shared/utils/form.js +82 -0
- package/dist/collection/shared/utils/format-bytes.js +20 -0
- package/dist/collection/shared/utils/getNextElement.js +30 -0
- package/dist/collection/shared/utils/getRandom.js +27 -0
- package/dist/collection/shared/utils/helpers.js +31 -0
- package/dist/collection/shared/utils/id.js +16 -0
- package/dist/collection/shared/utils/index.js +60 -0
- package/dist/collection/shared/utils/interfaces.js +1 -0
- package/dist/collection/shared/utils/isClient.js +14 -0
- package/dist/collection/shared/utils/isDefined.js +19 -0
- package/dist/collection/shared/utils/isEmpty.js +30 -0
- package/dist/collection/shared/utils/isHTMLElement.js +16 -0
- package/dist/collection/shared/utils/isNil.js +15 -0
- package/dist/collection/shared/utils/isString.js +20 -0
- package/dist/collection/shared/utils/native-dialog.js +44 -0
- package/dist/collection/shared/utils/navigation.js +21 -0
- package/dist/collection/shared/utils/parts.js +15 -0
- package/dist/collection/shared/utils/prop-warning.js +7 -0
- package/dist/collection/shared/utils/props.js +37 -0
- package/dist/collection/shared/utils/raf-batcher.js +51 -0
- package/dist/collection/shared/utils/scrollLock.js +141 -0
- package/dist/collection/shared/utils/setRafTimeout.js +38 -0
- package/dist/collection/shared/utils/slot.js +113 -0
- package/dist/collection/shared/utils/ssr-date.js +33 -0
- package/dist/collection/shared/utils/stringToArray.js +29 -0
- package/dist/collection/shared/utils/swipe.js +342 -0
- package/dist/collection/shared/utils/transition.js +127 -0
- package/dist/collection/shared/utils/types.js +1 -0
- package/dist/collection/shared/utils/validator.js +51 -0
- package/dist/collection/value-accessors/angular-value-accessor-config.js +41 -0
- package/dist/collection/value-accessors/index.js +6 -0
- package/dist/collection/value-accessors/vue-model-config.js +43 -0
- package/dist/components/br-avatar.d.ts +11 -0
- package/dist/components/br-avatar.js +5 -0
- package/dist/components/br-breadcrumb-item.d.ts +11 -0
- package/dist/components/br-breadcrumb-item.js +5 -0
- package/dist/components/br-breadcrumb.d.ts +11 -0
- package/dist/components/br-breadcrumb.js +5 -0
- package/dist/components/br-button.d.ts +11 -0
- package/dist/components/br-button.js +5 -0
- package/dist/components/br-card.d.ts +11 -0
- package/dist/components/br-card.js +5 -0
- package/dist/components/br-carousel-page.d.ts +11 -0
- package/dist/components/br-carousel-page.js +5 -0
- package/dist/components/br-carousel.d.ts +11 -0
- package/dist/components/br-carousel.js +5 -0
- package/dist/components/br-checkbox-group.d.ts +11 -0
- package/dist/components/br-checkbox-group.js +5 -0
- package/dist/components/br-checkbox.d.ts +11 -0
- package/dist/components/br-checkbox.js +5 -0
- package/dist/components/br-checkgroup.d.ts +11 -0
- package/dist/components/br-checkgroup.js +5 -0
- package/dist/components/br-collapse.d.ts +11 -0
- package/dist/components/br-collapse.js +5 -0
- package/dist/components/br-cookiebar-cookie.d.ts +11 -0
- package/dist/components/br-cookiebar-cookie.js +5 -0
- package/dist/components/br-cookiebar-group.d.ts +11 -0
- package/dist/components/br-cookiebar-group.js +5 -0
- package/dist/components/br-cookiebar-header.d.ts +11 -0
- package/dist/components/br-cookiebar-header.js +5 -0
- package/dist/components/br-cookiebar-link.d.ts +11 -0
- package/dist/components/br-cookiebar-link.js +5 -0
- package/dist/components/br-cookiebar-note-group.d.ts +11 -0
- package/dist/components/br-cookiebar-note-group.js +5 -0
- package/dist/components/br-cookiebar-note.d.ts +11 -0
- package/dist/components/br-cookiebar-note.js +5 -0
- package/dist/components/br-cookiebar.d.ts +11 -0
- package/dist/components/br-cookiebar.js +5 -0
- package/dist/components/br-crumb.d.ts +11 -0
- package/dist/components/br-crumb.js +5 -0
- package/dist/components/br-date-picker.d.ts +11 -0
- package/dist/components/br-date-picker.js +5 -0
- package/dist/components/br-datetime-input.d.ts +11 -0
- package/dist/components/br-datetime-input.js +5 -0
- package/dist/components/br-datetime-picker.d.ts +11 -0
- package/dist/components/br-datetime-picker.js +5 -0
- package/dist/components/br-divider.d.ts +11 -0
- package/dist/components/br-divider.js +5 -0
- package/dist/components/br-dropdown.d.ts +11 -0
- package/dist/components/br-dropdown.js +5 -0
- package/dist/components/br-footer-category.d.ts +11 -0
- package/dist/components/br-footer-category.js +5 -0
- package/dist/components/br-footer-item.d.ts +11 -0
- package/dist/components/br-footer-item.js +5 -0
- package/dist/components/br-footer-legal.d.ts +11 -0
- package/dist/components/br-footer-legal.js +5 -0
- package/dist/components/br-footer-logo.d.ts +11 -0
- package/dist/components/br-footer-logo.js +5 -0
- package/dist/components/br-footer-social.d.ts +11 -0
- package/dist/components/br-footer-social.js +5 -0
- package/dist/components/br-footer.d.ts +11 -0
- package/dist/components/br-footer.js +5 -0
- package/dist/components/br-header-function.d.ts +11 -0
- package/dist/components/br-header-function.js +5 -0
- package/dist/components/br-header-link.d.ts +11 -0
- package/dist/components/br-header-link.js +5 -0
- package/dist/components/br-header-list.d.ts +11 -0
- package/dist/components/br-header-list.js +5 -0
- package/dist/components/br-header-logo.d.ts +11 -0
- package/dist/components/br-header-logo.js +5 -0
- package/dist/components/br-header.d.ts +11 -0
- package/dist/components/br-header.js +5 -0
- package/dist/components/br-icon.d.ts +11 -0
- package/dist/components/br-icon.js +5 -0
- package/dist/components/br-input.d.ts +11 -0
- package/dist/components/br-input.js +5 -0
- package/dist/components/br-item.d.ts +11 -0
- package/dist/components/br-item.js +5 -0
- package/dist/components/br-link.d.ts +11 -0
- package/dist/components/br-link.js +5 -0
- package/dist/components/br-list.d.ts +11 -0
- package/dist/components/br-list.js +5 -0
- package/dist/components/br-loading.d.ts +11 -0
- package/dist/components/br-loading.js +5 -0
- package/dist/components/br-magic-button.d.ts +11 -0
- package/dist/components/br-magic-button.js +5 -0
- package/dist/components/br-menu-group.d.ts +11 -0
- package/dist/components/br-menu-group.js +5 -0
- package/dist/components/br-menu-header.d.ts +11 -0
- package/dist/components/br-menu-header.js +5 -0
- package/dist/components/br-menu-info.d.ts +11 -0
- package/dist/components/br-menu-info.js +5 -0
- package/dist/components/br-menu-item.d.ts +11 -0
- package/dist/components/br-menu-item.js +5 -0
- package/dist/components/br-menu-link.d.ts +11 -0
- package/dist/components/br-menu-link.js +5 -0
- package/dist/components/br-menu-list.d.ts +11 -0
- package/dist/components/br-menu-list.js +5 -0
- package/dist/components/br-menu-logo.d.ts +11 -0
- package/dist/components/br-menu-logo.js +5 -0
- package/dist/components/br-menu-social.d.ts +11 -0
- package/dist/components/br-menu-social.js +5 -0
- package/dist/components/br-menu.d.ts +11 -0
- package/dist/components/br-menu.js +5 -0
- package/dist/components/br-message.d.ts +11 -0
- package/dist/components/br-message.js +5 -0
- package/dist/components/br-modal.d.ts +11 -0
- package/dist/components/br-modal.js +5 -0
- package/dist/components/br-notification-body.d.ts +11 -0
- package/dist/components/br-notification-body.js +5 -0
- package/dist/components/br-notification-header.d.ts +11 -0
- package/dist/components/br-notification-header.js +5 -0
- package/dist/components/br-notification-item.d.ts +11 -0
- package/dist/components/br-notification-item.js +5 -0
- package/dist/components/br-notification.d.ts +11 -0
- package/dist/components/br-notification.js +5 -0
- package/dist/components/br-pagination.d.ts +11 -0
- package/dist/components/br-pagination.js +5 -0
- package/dist/components/br-radio-group.d.ts +11 -0
- package/dist/components/br-radio-group.js +5 -0
- package/dist/components/br-radio.d.ts +11 -0
- package/dist/components/br-radio.js +5 -0
- package/dist/components/br-scrim.d.ts +11 -0
- package/dist/components/br-scrim.js +5 -0
- package/dist/components/br-select-input.d.ts +11 -0
- package/dist/components/br-select-input.js +5 -0
- package/dist/components/br-select-list.d.ts +11 -0
- package/dist/components/br-select-list.js +5 -0
- package/dist/components/br-select-option.d.ts +11 -0
- package/dist/components/br-select-option.js +5 -0
- package/dist/components/br-select.d.ts +11 -0
- package/dist/components/br-select.js +5 -0
- package/dist/components/br-sign-in.d.ts +11 -0
- package/dist/components/br-sign-in.js +5 -0
- package/dist/components/br-skip-link-item.d.ts +11 -0
- package/dist/components/br-skip-link-item.js +5 -0
- package/dist/components/br-skip-link.d.ts +11 -0
- package/dist/components/br-skip-link.js +5 -0
- package/dist/components/br-skiplink-item.d.ts +11 -0
- package/dist/components/br-skiplink-item.js +5 -0
- package/dist/components/br-slider.d.ts +11 -0
- package/dist/components/br-slider.js +5 -0
- package/dist/components/br-step-item.d.ts +11 -0
- package/dist/components/br-step-item.js +5 -0
- package/dist/components/br-step.d.ts +11 -0
- package/dist/components/br-step.js +5 -0
- package/dist/components/br-switch.d.ts +11 -0
- package/dist/components/br-switch.js +5 -0
- package/dist/components/br-tab-item.d.ts +11 -0
- package/dist/components/br-tab-item.js +5 -0
- package/dist/components/br-tab.d.ts +11 -0
- package/dist/components/br-tab.js +5 -0
- package/dist/components/br-table-body.d.ts +11 -0
- package/dist/components/br-table-body.js +5 -0
- package/dist/components/br-table-cell.d.ts +11 -0
- package/dist/components/br-table-cell.js +5 -0
- package/dist/components/br-table-header-cell.d.ts +11 -0
- package/dist/components/br-table-header-cell.js +5 -0
- package/dist/components/br-table-header.d.ts +11 -0
- package/dist/components/br-table-header.js +5 -0
- package/dist/components/br-table-row.d.ts +11 -0
- package/dist/components/br-table-row.js +5 -0
- package/dist/components/br-table.d.ts +11 -0
- package/dist/components/br-table.js +5 -0
- package/dist/components/br-tag.d.ts +11 -0
- package/dist/components/br-tag.js +5 -0
- package/dist/components/br-textarea.d.ts +11 -0
- package/dist/components/br-textarea.js +5 -0
- package/dist/components/br-time-picker.d.ts +11 -0
- package/dist/components/br-time-picker.js +5 -0
- package/dist/components/br-tooltip.d.ts +11 -0
- package/dist/components/br-tooltip.js +5 -0
- package/dist/components/br-upload.d.ts +11 -0
- package/dist/components/br-upload.js +5 -0
- package/dist/components/br-wizard-panel.d.ts +11 -0
- package/dist/components/br-wizard-panel.js +5 -0
- package/dist/components/br-wizard.d.ts +11 -0
- package/dist/components/br-wizard.js +5 -0
- package/dist/components/index.d.ts +213 -0
- package/dist/components/index.js +5 -0
- package/dist/components/p-34Jfn-U-.js +5 -0
- package/dist/components/p-5z6jgH1D.js +5 -0
- package/dist/components/p-6OdfnwnK.js +5 -0
- package/dist/components/p-9S9bgUT0.js +5 -0
- package/dist/components/p-B-qLmYZC.js +5 -0
- package/dist/components/p-B55qsau4.js +5 -0
- package/dist/components/p-B7Amgxkp.js +5 -0
- package/dist/components/p-BC7f6MK8.js +5 -0
- package/dist/components/p-BKuMQJrQ.js +5 -0
- package/dist/components/p-BPJpHGOW.js +5 -0
- package/dist/components/p-BWXfdbQH.js +5 -0
- package/dist/components/p-Bb-nLtTG.js +5 -0
- package/dist/components/p-BeE7R9nu.js +5 -0
- package/dist/components/p-BkS6ujyf.js +5 -0
- package/dist/components/p-Bo0QYHJO.js +5 -0
- package/dist/components/p-C1yRmdso.js +5 -0
- package/dist/components/p-C2i2c_io.js +5 -0
- package/dist/components/p-C7v0lVlX.js +5 -0
- package/dist/components/p-CMBsvswx.js +5 -0
- package/dist/components/p-CRrimdz6.js +5 -0
- package/dist/components/p-CWORw84-.js +5 -0
- package/dist/components/p-CXMwM9m4.js +5 -0
- package/dist/components/p-CdDwqbBv.js +5 -0
- package/dist/components/p-CvUMXJCl.js +5 -0
- package/dist/components/p-D3usVJE2.js +16 -0
- package/dist/components/p-D6zroLx5.js +5 -0
- package/dist/components/p-DA5GS53D.js +5 -0
- package/dist/components/p-DBP6K_aq.js +5 -0
- package/dist/components/p-DBmwzG9E.js +5 -0
- package/dist/components/p-DCrVo-8T.js +5 -0
- package/dist/components/p-DFUKDNck.js +5 -0
- package/dist/components/p-DHicj0By.js +5 -0
- package/dist/components/p-DIK54tTj.js +5 -0
- package/dist/components/p-DQRSHR-D.js +5 -0
- package/dist/components/p-DRVMm1Py.js +5 -0
- package/dist/components/p-DWPmUV72.js +5 -0
- package/dist/components/p-DXjQyH6s.js +5 -0
- package/dist/components/p-DYA74R1r.js +5 -0
- package/dist/components/p-DmCxdB9P.js +5 -0
- package/dist/components/p-Dmfk7eEe.js +5 -0
- package/dist/components/p-Dp0xy_3n.js +5 -0
- package/dist/components/p-DxZJrIyL.js +5 -0
- package/dist/components/p-JAkkThgf.js +5 -0
- package/dist/components/p-Ud-WB0hx.js +5 -0
- package/dist/components/p-bhULC15U.js +5 -0
- package/dist/components/p-cF3ia5e9.js +5 -0
- package/dist/components/p-fpMNttbg.js +5 -0
- package/dist/components/p-gvnfuTjd.js +5 -0
- package/dist/components/p-qYONSNcf.js +5 -0
- package/dist/components/p-qhhHGJY1.js +5 -0
- package/dist/components/p-ttI0nvv_.js +5 -0
- package/dist/components/p-ukNmfGNP.js +5 -0
- package/dist/components/p-xa8e1kSW.js +5 -0
- package/dist/esm/app-globals-DVjNHTTs.js +7 -0
- package/dist/esm/br-avatar.entry.js +246 -0
- package/dist/esm/br-breadcrumb-item.entry.js +43 -0
- package/dist/esm/br-breadcrumb.entry.js +441 -0
- package/dist/esm/br-button_2.entry.js +277 -0
- package/dist/esm/br-card.entry.js +109 -0
- package/dist/esm/br-carousel-page.entry.js +78 -0
- package/dist/esm/br-carousel.entry.js +563 -0
- package/dist/esm/br-checkbox-group.entry.js +116 -0
- package/dist/esm/br-checkbox.entry.js +286 -0
- package/dist/esm/br-checkgroup.entry.js +18 -0
- package/dist/esm/br-collapse_2.entry.js +680 -0
- package/dist/esm/br-cookiebar-cookie.entry.js +81 -0
- package/dist/esm/br-cookiebar-group.entry.js +307 -0
- package/dist/esm/br-cookiebar-header.entry.js +37 -0
- package/dist/esm/br-cookiebar-link.entry.js +53 -0
- package/dist/esm/br-cookiebar-note-group.entry.js +68 -0
- package/dist/esm/br-cookiebar-note.entry.js +23 -0
- package/dist/esm/br-cookiebar.entry.js +756 -0
- package/dist/esm/br-crumb.entry.js +49 -0
- package/dist/esm/br-date-picker_3.entry.js +2443 -0
- package/dist/esm/br-datetime-picker.entry.js +1884 -0
- package/dist/esm/br-divider.entry.js +223 -0
- package/dist/esm/br-dropdown_2.entry.js +1997 -0
- package/dist/esm/br-footer-category.entry.js +100 -0
- package/dist/esm/br-footer-item.entry.js +50 -0
- package/dist/esm/br-footer-legal.entry.js +39 -0
- package/dist/esm/br-footer-logo.entry.js +102 -0
- package/dist/esm/br-footer-social.entry.js +69 -0
- package/dist/esm/br-footer.entry.js +90 -0
- package/dist/esm/br-header-function.entry.js +140 -0
- package/dist/esm/br-header-link.entry.js +58 -0
- package/dist/esm/br-header-list.entry.js +277 -0
- package/dist/esm/br-header-logo.entry.js +176 -0
- package/dist/esm/br-header.entry.js +640 -0
- package/dist/esm/br-icon.entry.js +483 -0
- package/dist/esm/br-input.entry.js +597 -0
- package/dist/esm/br-item.entry.js +365 -0
- package/dist/esm/br-link.entry.js +131 -0
- package/dist/esm/br-loading.entry.js +503 -0
- package/dist/esm/br-magic-button.entry.js +91 -0
- package/dist/esm/br-menu-group.entry.js +21 -0
- package/dist/esm/br-menu-header.entry.js +45 -0
- package/dist/esm/br-menu-info.entry.js +36 -0
- package/dist/esm/br-menu-item.entry.js +77 -0
- package/dist/esm/br-menu-link.entry.js +54 -0
- package/dist/esm/br-menu-list.entry.js +147 -0
- package/dist/esm/br-menu-logo.entry.js +73 -0
- package/dist/esm/br-menu-social.entry.js +63 -0
- package/dist/esm/br-menu.entry.js +991 -0
- package/dist/esm/br-modal.entry.js +494 -0
- package/dist/esm/br-notification-body.entry.js +69 -0
- package/dist/esm/br-notification-header.entry.js +46 -0
- package/dist/esm/br-notification-item.entry.js +108 -0
- package/dist/esm/br-notification.entry.js +332 -0
- package/dist/esm/br-pagination.entry.js +882 -0
- package/dist/esm/br-radio-group.entry.js +426 -0
- package/dist/esm/br-radio.entry.js +355 -0
- package/dist/esm/br-scrim.entry.js +1334 -0
- package/dist/esm/br-select-input_3.entry.js +984 -0
- package/dist/esm/br-sign-in.entry.js +124 -0
- package/dist/esm/br-skip-link-item.entry.js +18 -0
- package/dist/esm/br-skip-link.entry.js +360 -0
- package/dist/esm/br-skiplink-item.entry.js +190 -0
- package/dist/esm/br-slider.entry.js +685 -0
- package/dist/esm/br-step_2.entry.js +625 -0
- package/dist/esm/br-switch.entry.js +243 -0
- package/dist/esm/br-tab-item.entry.js +183 -0
- package/dist/esm/br-tab.entry.js +395 -0
- package/dist/esm/br-table-body.entry.js +35 -0
- package/dist/esm/br-table-cell.entry.js +182 -0
- package/dist/esm/br-table-header-cell.entry.js +171 -0
- package/dist/esm/br-table-header.entry.js +35 -0
- package/dist/esm/br-table-row.entry.js +79 -0
- package/dist/esm/br-table.entry.js +678 -0
- package/dist/esm/br-tag.entry.js +491 -0
- package/dist/esm/br-textarea.entry.js +304 -0
- package/dist/esm/br-tooltip.entry.js +625 -0
- package/dist/esm/br-upload.entry.js +579 -0
- package/dist/esm/br-wizard-panel.entry.js +52 -0
- package/dist/esm/br-wizard.entry.js +706 -0
- package/dist/esm/breakpoint-observer-DBmwzG9E.js +141 -0
- package/dist/esm/clamp-gvnfuTjd.js +23 -0
- package/dist/esm/cookiebar.utils-DYA74R1r.js +16 -0
- package/dist/esm/datetime-picker-constants-Bfm58jO6.js +3798 -0
- package/dist/esm/event-DFN_so7I.js +48 -0
- package/dist/esm/floating-surface-dismiss-BWXfdbQH.js +61 -0
- package/dist/esm/floating-ui-BavFwMnx.js +134 -0
- package/dist/esm/floating-ui.dom-DIK54tTj.js +1707 -0
- package/dist/esm/focus-DxZJrIyL.js +26 -0
- package/dist/esm/getNextElement-9S9bgUT0.js +28 -0
- package/dist/esm/iconify-icon-D3usVJE2.js +2303 -0
- package/dist/esm/id-BkS6ujyf.js +18 -0
- package/dist/esm/index-Bo-2igoO.js +671 -0
- package/dist/esm/index-C2RBydfd.js +3258 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/isNil-B-qLmYZC.js +17 -0
- package/dist/esm/isValid-DIUZX1qS.js +3684 -0
- package/dist/esm/loader.js +15 -0
- package/dist/esm/native-dialog-B55qsau4.js +46 -0
- package/dist/esm/navigation-bhULC15U.js +23 -0
- package/dist/esm/parts-Bb5vVlCC.js +17 -0
- package/dist/esm/props-DRVMm1Py.js +22 -0
- package/dist/esm/raf-batcher-cF3ia5e9.js +53 -0
- package/dist/esm/slot-BIG-yees.js +44 -0
- package/dist/esm/swipe-Dmfk7eEe.js +343 -0
- package/dist/esm/table-constants-CXMwM9m4.js +170 -0
- package/dist/esm/validator-D3tVP32U.js +113 -0
- package/dist/esm/webcomponents.js +46 -0
- package/dist/hydrate/index.d.ts +287 -0
- package/dist/hydrate/index.js +67516 -0
- package/dist/hydrate/index.mjs +67506 -0
- package/dist/hydrate/package.json +12 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/loader/cdn.js +5 -0
- package/dist/loader/index.cjs.js +5 -0
- package/dist/loader/index.d.ts +24 -0
- package/dist/loader/index.es2017.js +5 -0
- package/dist/loader/index.js +6 -0
- package/dist/types/components/item/item.d.ts +1 -0
- package/dist/types/components/select/select-list/select-list.d.ts +1 -0
- package/dist/types/components/select/select-option/select-option.d.ts +1 -0
- package/dist/types/components/select/select.d.ts +14 -0
- package/dist/types/components/select/select.types.d.ts +2 -0
- package/dist/types/components/select/select.utils.d.ts +13 -0
- package/dist/webcomponents/index.esm.js +5 -0
- package/dist/webcomponents/p-0196804a.entry.js +5 -0
- package/dist/webcomponents/p-0410186a.entry.js +5 -0
- package/dist/webcomponents/p-0415ef22.entry.js +5 -0
- package/dist/webcomponents/p-0777c7b1.entry.js +5 -0
- package/dist/webcomponents/p-0caa4d12.entry.js +5 -0
- package/dist/webcomponents/p-0d4f718d.entry.js +5 -0
- package/dist/webcomponents/p-0e84c9e8.entry.js +5 -0
- package/dist/webcomponents/p-12286e73.entry.js +5 -0
- package/dist/webcomponents/p-147ac8d3.entry.js +5 -0
- package/dist/webcomponents/p-1580beee.entry.js +5 -0
- package/dist/webcomponents/p-18ee6175.entry.js +5 -0
- package/dist/webcomponents/p-1bca4499.entry.js +5 -0
- package/dist/webcomponents/p-1c303a4e.entry.js +5 -0
- package/dist/webcomponents/p-1d6b0b6f.entry.js +5 -0
- package/dist/webcomponents/p-1d8cb8fd.entry.js +5 -0
- package/dist/webcomponents/p-224daaac.entry.js +5 -0
- package/dist/webcomponents/p-28426d2a.entry.js +5 -0
- package/dist/webcomponents/p-2abd2da0.entry.js +5 -0
- package/dist/webcomponents/p-2fdc51ae.entry.js +5 -0
- package/dist/webcomponents/p-30c428b6.entry.js +5 -0
- package/dist/webcomponents/p-36bbea4e.entry.js +5 -0
- package/dist/webcomponents/p-3907ebfa.entry.js +5 -0
- package/dist/webcomponents/p-39a16f9d.entry.js +5 -0
- package/dist/webcomponents/p-3ebbd2f5.entry.js +5 -0
- package/dist/webcomponents/p-3ef7eac8.entry.js +5 -0
- package/dist/webcomponents/p-45356e9a.entry.js +5 -0
- package/dist/webcomponents/p-46513db4.entry.js +5 -0
- package/dist/webcomponents/p-4c13221a.entry.js +5 -0
- package/dist/webcomponents/p-51ce2c31.entry.js +5 -0
- package/dist/webcomponents/p-52df61cb.entry.js +5 -0
- package/dist/webcomponents/p-569134cf.entry.js +5 -0
- package/dist/webcomponents/p-5ce7db4a.entry.js +5 -0
- package/dist/webcomponents/p-5f373708.entry.js +5 -0
- package/dist/webcomponents/p-5f6afb79.entry.js +5 -0
- package/dist/webcomponents/p-5fc7ba4c.entry.js +5 -0
- package/dist/webcomponents/p-66006312.entry.js +5 -0
- package/dist/webcomponents/p-66b13fd9.entry.js +5 -0
- package/dist/webcomponents/p-6OdfnwnK.js +5 -0
- package/dist/webcomponents/p-750799b7.entry.js +5 -0
- package/dist/webcomponents/p-756ff2ad.entry.js +5 -0
- package/dist/webcomponents/p-765bfe27.entry.js +5 -0
- package/dist/webcomponents/p-7ab96c11.entry.js +5 -0
- package/dist/webcomponents/p-7c2ff8b4.entry.js +5 -0
- package/dist/webcomponents/p-7f7506f0.entry.js +5 -0
- package/dist/webcomponents/p-7fb03a49.entry.js +5 -0
- package/dist/webcomponents/p-82200563.entry.js +5 -0
- package/dist/webcomponents/p-83ff4579.entry.js +5 -0
- package/dist/webcomponents/p-85f8063b.entry.js +5 -0
- package/dist/webcomponents/p-8b558233.entry.js +5 -0
- package/dist/webcomponents/p-8e6c2767.entry.js +5 -0
- package/dist/webcomponents/p-8e819355.entry.js +5 -0
- package/dist/webcomponents/p-92a9b9c4.entry.js +5 -0
- package/dist/webcomponents/p-966ad32f.entry.js +5 -0
- package/dist/webcomponents/p-9679d230.entry.js +5 -0
- package/dist/webcomponents/p-96dd663b.entry.js +5 -0
- package/dist/webcomponents/p-98843fa3.entry.js +5 -0
- package/dist/webcomponents/p-9S9bgUT0.js +5 -0
- package/dist/webcomponents/p-9a375eff.entry.js +5 -0
- package/dist/webcomponents/p-9b358cff.entry.js +5 -0
- package/dist/webcomponents/p-9f7558c7.entry.js +5 -0
- package/dist/webcomponents/p-B-qLmYZC.js +5 -0
- package/dist/webcomponents/p-B55qsau4.js +5 -0
- package/dist/webcomponents/p-BIG-yees.js +5 -0
- package/dist/webcomponents/p-BWXfdbQH.js +5 -0
- package/dist/webcomponents/p-Bb5vVlCC.js +5 -0
- package/dist/webcomponents/p-Bfm58jO6.js +5 -0
- package/dist/webcomponents/p-BhMVJQ4-.js +5 -0
- package/dist/webcomponents/p-BkS6ujyf.js +5 -0
- package/dist/webcomponents/p-C2RBydfd.js +6 -0
- package/dist/webcomponents/p-CO5cOQQU.js +5 -0
- package/dist/webcomponents/p-CXMwM9m4.js +5 -0
- package/dist/webcomponents/p-D3tVP32U.js +5 -0
- package/dist/webcomponents/p-D3usVJE2.js +16 -0
- package/dist/webcomponents/p-DBmwzG9E.js +5 -0
- package/dist/webcomponents/p-DFN_so7I.js +5 -0
- package/dist/webcomponents/p-DIK54tTj.js +5 -0
- package/dist/webcomponents/p-DRVMm1Py.js +5 -0
- package/dist/webcomponents/p-DVjNHTTs.js +5 -0
- package/dist/webcomponents/p-DYA74R1r.js +5 -0
- package/dist/webcomponents/p-Dmfk7eEe.js +5 -0
- package/dist/webcomponents/p-DxZJrIyL.js +5 -0
- package/dist/webcomponents/p-a382e115.entry.js +5 -0
- package/dist/webcomponents/p-a4ae72e3.entry.js +5 -0
- package/dist/webcomponents/p-a994c190.entry.js +5 -0
- package/dist/webcomponents/p-a9ff7c25.entry.js +5 -0
- package/dist/webcomponents/p-bhULC15U.js +5 -0
- package/dist/webcomponents/p-c0b0f531.entry.js +5 -0
- package/dist/webcomponents/p-c211af17.entry.js +5 -0
- package/dist/webcomponents/p-c492d926.entry.js +5 -0
- package/dist/webcomponents/p-c4cfe599.entry.js +5 -0
- package/dist/webcomponents/p-c846e784.entry.js +5 -0
- package/dist/webcomponents/p-c949d993.entry.js +5 -0
- package/dist/webcomponents/p-cF3ia5e9.js +5 -0
- package/dist/webcomponents/p-d1e899cd.entry.js +5 -0
- package/dist/webcomponents/p-d38d82cc.entry.js +5 -0
- package/dist/webcomponents/p-e0ce536a.entry.js +5 -0
- package/dist/webcomponents/p-e1331288.entry.js +5 -0
- package/dist/webcomponents/p-e360a463.entry.js +5 -0
- package/dist/webcomponents/p-f078f972.entry.js +5 -0
- package/dist/webcomponents/p-f26038e2.entry.js +5 -0
- package/dist/webcomponents/p-f303f6b3.entry.js +5 -0
- package/dist/webcomponents/p-f6318e94.entry.js +5 -0
- package/dist/webcomponents/p-f85ee01c.entry.js +5 -0
- package/dist/webcomponents/p-fcd4ae48.entry.js +5 -0
- package/dist/webcomponents/p-ffe0241e.entry.js +5 -0
- package/dist/webcomponents/p-gvnfuTjd.js +5 -0
- package/dist/webcomponents/webcomponents.esm.js +5 -0
- package/package.json +3 -7
- package/cem/.gitkeep +0 -0
|
@@ -0,0 +1,2307 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Construído por SERPRO
|
|
3
|
+
* © https://serpro.gov.br/ - MIT License.
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* (c) Iconify
|
|
9
|
+
*
|
|
10
|
+
* For the full copyright and license information, please view the license.txt
|
|
11
|
+
* files at https://github.com/iconify/iconify
|
|
12
|
+
*
|
|
13
|
+
* Licensed under MIT.
|
|
14
|
+
*
|
|
15
|
+
* @license MIT
|
|
16
|
+
* @version 3.0.2
|
|
17
|
+
*/
|
|
18
|
+
/** Default values for dimensions */
|
|
19
|
+
const defaultIconDimensions = Object.freeze({
|
|
20
|
+
left: 0,
|
|
21
|
+
top: 0,
|
|
22
|
+
width: 16,
|
|
23
|
+
height: 16
|
|
24
|
+
});
|
|
25
|
+
/** Default values for transformations */
|
|
26
|
+
const defaultIconTransformations = Object.freeze({
|
|
27
|
+
rotate: 0,
|
|
28
|
+
vFlip: false,
|
|
29
|
+
hFlip: false
|
|
30
|
+
});
|
|
31
|
+
/** Default values for all optional IconifyIcon properties */
|
|
32
|
+
const defaultIconProps = Object.freeze({
|
|
33
|
+
...defaultIconDimensions,
|
|
34
|
+
...defaultIconTransformations
|
|
35
|
+
});
|
|
36
|
+
/** Default values for all properties used in ExtendedIconifyIcon */
|
|
37
|
+
const defaultExtendedIconProps = Object.freeze({
|
|
38
|
+
...defaultIconProps,
|
|
39
|
+
body: "",
|
|
40
|
+
hidden: false
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Default icon customisations values
|
|
45
|
+
*/
|
|
46
|
+
const defaultIconSizeCustomisations = Object.freeze({
|
|
47
|
+
width: null,
|
|
48
|
+
height: null
|
|
49
|
+
});
|
|
50
|
+
const defaultIconCustomisations = Object.freeze({
|
|
51
|
+
...defaultIconSizeCustomisations,
|
|
52
|
+
...defaultIconTransformations
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get rotation value
|
|
57
|
+
*/
|
|
58
|
+
function rotateFromString(value, defaultValue = 0) {
|
|
59
|
+
const units = value.replace(/^-?[0-9.]*/, "");
|
|
60
|
+
function cleanup(value$1) {
|
|
61
|
+
while (value$1 < 0) value$1 += 4;
|
|
62
|
+
return value$1 % 4;
|
|
63
|
+
}
|
|
64
|
+
if (units === "") {
|
|
65
|
+
const num = parseInt(value);
|
|
66
|
+
return isNaN(num) ? 0 : cleanup(num);
|
|
67
|
+
} else if (units !== value) {
|
|
68
|
+
let split = 0;
|
|
69
|
+
switch (units) {
|
|
70
|
+
case "%":
|
|
71
|
+
split = 25;
|
|
72
|
+
break;
|
|
73
|
+
case "deg": split = 90;
|
|
74
|
+
}
|
|
75
|
+
if (split) {
|
|
76
|
+
let num = parseFloat(value.slice(0, value.length - units.length));
|
|
77
|
+
if (isNaN(num)) return 0;
|
|
78
|
+
num = num / split;
|
|
79
|
+
return num % 1 === 0 ? cleanup(num) : 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return defaultValue;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const separator = /[\s,]+/;
|
|
86
|
+
/**
|
|
87
|
+
* Apply "flip" string to icon customisations
|
|
88
|
+
*/
|
|
89
|
+
function flipFromString(custom, flip) {
|
|
90
|
+
flip.split(separator).forEach((str) => {
|
|
91
|
+
switch (str.trim()) {
|
|
92
|
+
case "horizontal":
|
|
93
|
+
custom.hFlip = true;
|
|
94
|
+
break;
|
|
95
|
+
case "vertical":
|
|
96
|
+
custom.vFlip = true;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const defaultCustomisations = {
|
|
103
|
+
...defaultIconCustomisations,
|
|
104
|
+
preserveAspectRatio: '',
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Get customisations
|
|
108
|
+
*/
|
|
109
|
+
function getCustomisations(node) {
|
|
110
|
+
const customisations = {
|
|
111
|
+
...defaultCustomisations,
|
|
112
|
+
};
|
|
113
|
+
const attr = (key, def) => node.getAttribute(key) || def;
|
|
114
|
+
// Dimensions
|
|
115
|
+
customisations.width = attr('width', null);
|
|
116
|
+
customisations.height = attr('height', null);
|
|
117
|
+
// Rotation
|
|
118
|
+
customisations.rotate = rotateFromString(attr('rotate', ''));
|
|
119
|
+
// Flip
|
|
120
|
+
flipFromString(customisations, attr('flip', ''));
|
|
121
|
+
// SVG attributes
|
|
122
|
+
customisations.preserveAspectRatio = attr('preserveAspectRatio', attr('preserveaspectratio', ''));
|
|
123
|
+
return customisations;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Check if customisations have been updated
|
|
127
|
+
*/
|
|
128
|
+
function haveCustomisationsChanged(value1, value2) {
|
|
129
|
+
for (const key in defaultCustomisations) {
|
|
130
|
+
if (value1[key] !== value2[key]) {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Expression to test part of icon name.
|
|
139
|
+
*
|
|
140
|
+
* Used when loading icons from Iconify API due to project naming convension.
|
|
141
|
+
* Ignored when using custom icon sets - convension does not apply.
|
|
142
|
+
*/
|
|
143
|
+
const matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
144
|
+
/**
|
|
145
|
+
* Convert string icon name to IconifyIconName object.
|
|
146
|
+
*/
|
|
147
|
+
const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
|
|
148
|
+
const colonSeparated = value.split(":");
|
|
149
|
+
if (value.slice(0, 1) === "@") {
|
|
150
|
+
if (colonSeparated.length < 2 || colonSeparated.length > 3) return null;
|
|
151
|
+
provider = colonSeparated.shift().slice(1);
|
|
152
|
+
}
|
|
153
|
+
if (colonSeparated.length > 3 || !colonSeparated.length) return null;
|
|
154
|
+
if (colonSeparated.length > 1) {
|
|
155
|
+
const name$1 = colonSeparated.pop();
|
|
156
|
+
const prefix = colonSeparated.pop();
|
|
157
|
+
const result = {
|
|
158
|
+
provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
|
|
159
|
+
prefix,
|
|
160
|
+
name: name$1
|
|
161
|
+
};
|
|
162
|
+
return validate && !validateIconName(result) ? null : result;
|
|
163
|
+
}
|
|
164
|
+
const name = colonSeparated[0];
|
|
165
|
+
const dashSeparated = name.split("-");
|
|
166
|
+
if (dashSeparated.length > 1) {
|
|
167
|
+
const result = {
|
|
168
|
+
provider,
|
|
169
|
+
prefix: dashSeparated.shift(),
|
|
170
|
+
name: dashSeparated.join("-")
|
|
171
|
+
};
|
|
172
|
+
return validate && !validateIconName(result) ? null : result;
|
|
173
|
+
}
|
|
174
|
+
if (allowSimpleName && provider === "") {
|
|
175
|
+
const result = {
|
|
176
|
+
provider,
|
|
177
|
+
prefix: "",
|
|
178
|
+
name
|
|
179
|
+
};
|
|
180
|
+
return validate && !validateIconName(result, allowSimpleName) ? null : result;
|
|
181
|
+
}
|
|
182
|
+
return null;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Check if icon is valid.
|
|
186
|
+
*
|
|
187
|
+
* This function is not part of stringToIcon because validation is not needed for most code.
|
|
188
|
+
*/
|
|
189
|
+
const validateIconName = (icon, allowSimpleName) => {
|
|
190
|
+
if (!icon) return false;
|
|
191
|
+
return !!((allowSimpleName && icon.prefix === "" || !!icon.prefix) && !!icon.name);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Resolve icon set icons
|
|
196
|
+
*
|
|
197
|
+
* Returns parent icon for each icon
|
|
198
|
+
*/
|
|
199
|
+
function getIconsTree(data, names) {
|
|
200
|
+
const icons = data.icons;
|
|
201
|
+
const aliases = data.aliases || Object.create(null);
|
|
202
|
+
const resolved = Object.create(null);
|
|
203
|
+
function resolve(name) {
|
|
204
|
+
if (icons[name]) return resolved[name] = [];
|
|
205
|
+
if (!(name in resolved)) {
|
|
206
|
+
resolved[name] = null;
|
|
207
|
+
const parent = aliases[name] && aliases[name].parent;
|
|
208
|
+
const value = parent && resolve(parent);
|
|
209
|
+
if (value) resolved[name] = [parent].concat(value);
|
|
210
|
+
}
|
|
211
|
+
return resolved[name];
|
|
212
|
+
}
|
|
213
|
+
(Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);
|
|
214
|
+
return resolved;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Merge transformations
|
|
219
|
+
*/
|
|
220
|
+
function mergeIconTransformations(obj1, obj2) {
|
|
221
|
+
const result = {};
|
|
222
|
+
if (!obj1.hFlip !== !obj2.hFlip) result.hFlip = true;
|
|
223
|
+
if (!obj1.vFlip !== !obj2.vFlip) result.vFlip = true;
|
|
224
|
+
const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
|
|
225
|
+
if (rotate) result.rotate = rotate;
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Merge icon and alias
|
|
231
|
+
*
|
|
232
|
+
* Can also be used to merge default values and icon
|
|
233
|
+
*/
|
|
234
|
+
function mergeIconData(parent, child) {
|
|
235
|
+
const result = mergeIconTransformations(parent, child);
|
|
236
|
+
for (const key in defaultExtendedIconProps) if (key in defaultIconTransformations) {
|
|
237
|
+
if (key in parent && !(key in result)) result[key] = defaultIconTransformations[key];
|
|
238
|
+
} else if (key in child) result[key] = child[key];
|
|
239
|
+
else if (key in parent) result[key] = parent[key];
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Get icon data, using prepared aliases tree
|
|
245
|
+
*/
|
|
246
|
+
function internalGetIconData(data, name, tree) {
|
|
247
|
+
const icons = data.icons;
|
|
248
|
+
const aliases = data.aliases || Object.create(null);
|
|
249
|
+
let currentProps = {};
|
|
250
|
+
function parse(name$1) {
|
|
251
|
+
currentProps = mergeIconData(icons[name$1] || aliases[name$1], currentProps);
|
|
252
|
+
}
|
|
253
|
+
parse(name);
|
|
254
|
+
tree.forEach(parse);
|
|
255
|
+
return mergeIconData(data, currentProps);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Extract icons from an icon set
|
|
260
|
+
*
|
|
261
|
+
* Returns list of icons that were found in icon set
|
|
262
|
+
*/
|
|
263
|
+
function parseIconSet(data, callback) {
|
|
264
|
+
const names = [];
|
|
265
|
+
if (typeof data !== "object" || typeof data.icons !== "object") return names;
|
|
266
|
+
if (data.not_found instanceof Array) data.not_found.forEach((name) => {
|
|
267
|
+
callback(name, null);
|
|
268
|
+
names.push(name);
|
|
269
|
+
});
|
|
270
|
+
const tree = getIconsTree(data);
|
|
271
|
+
for (const name in tree) {
|
|
272
|
+
const item = tree[name];
|
|
273
|
+
if (item) {
|
|
274
|
+
callback(name, internalGetIconData(data, name, item));
|
|
275
|
+
names.push(name);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return names;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Optional properties
|
|
283
|
+
*/
|
|
284
|
+
const optionalPropertyDefaults = {
|
|
285
|
+
provider: "",
|
|
286
|
+
aliases: {},
|
|
287
|
+
not_found: {},
|
|
288
|
+
...defaultIconDimensions
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* Check props
|
|
292
|
+
*/
|
|
293
|
+
function checkOptionalProps(item, defaults) {
|
|
294
|
+
for (const prop in defaults) if (prop in item && typeof item[prop] !== typeof defaults[prop]) return false;
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Validate icon set, return it as IconifyJSON on success, null on failure
|
|
299
|
+
*
|
|
300
|
+
* Unlike validateIconSet(), this function is very basic.
|
|
301
|
+
* It does not throw exceptions, it does not check metadata, it does not fix stuff.
|
|
302
|
+
*/
|
|
303
|
+
function quicklyValidateIconSet(obj) {
|
|
304
|
+
if (typeof obj !== "object" || obj === null) return null;
|
|
305
|
+
const data = obj;
|
|
306
|
+
if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") return null;
|
|
307
|
+
if (!checkOptionalProps(obj, optionalPropertyDefaults)) return null;
|
|
308
|
+
const icons = data.icons;
|
|
309
|
+
for (const name in icons) {
|
|
310
|
+
const icon = icons[name];
|
|
311
|
+
if (!name || typeof icon.body !== "string" || !checkOptionalProps(icon, defaultExtendedIconProps)) return null;
|
|
312
|
+
}
|
|
313
|
+
const aliases = data.aliases || Object.create(null);
|
|
314
|
+
for (const name in aliases) {
|
|
315
|
+
const icon = aliases[name];
|
|
316
|
+
const parent = icon.parent;
|
|
317
|
+
if (!name || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(icon, defaultExtendedIconProps)) return null;
|
|
318
|
+
}
|
|
319
|
+
return data;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Storage by provider and prefix
|
|
324
|
+
*/
|
|
325
|
+
const dataStorage = Object.create(null);
|
|
326
|
+
/**
|
|
327
|
+
* Create new storage
|
|
328
|
+
*/
|
|
329
|
+
function newStorage(provider, prefix) {
|
|
330
|
+
return {
|
|
331
|
+
provider,
|
|
332
|
+
prefix,
|
|
333
|
+
icons: Object.create(null),
|
|
334
|
+
missing: /* @__PURE__ */ new Set()
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Get storage for provider and prefix
|
|
339
|
+
*/
|
|
340
|
+
function getStorage(provider, prefix) {
|
|
341
|
+
const providerStorage = dataStorage[provider] || (dataStorage[provider] = Object.create(null));
|
|
342
|
+
return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Add icon set to storage
|
|
346
|
+
*
|
|
347
|
+
* Returns array of added icons
|
|
348
|
+
*/
|
|
349
|
+
function addIconSet(storage, data) {
|
|
350
|
+
if (!quicklyValidateIconSet(data)) return [];
|
|
351
|
+
return parseIconSet(data, (name, icon) => {
|
|
352
|
+
if (icon) storage.icons[name] = icon;
|
|
353
|
+
else storage.missing.add(name);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Add icon to storage
|
|
358
|
+
*/
|
|
359
|
+
function addIconToStorage(storage, name, icon) {
|
|
360
|
+
try {
|
|
361
|
+
if (typeof icon.body === "string") {
|
|
362
|
+
storage.icons[name] = { ...icon };
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
} catch (err) {}
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* List available icons
|
|
370
|
+
*/
|
|
371
|
+
function listIcons$1(provider, prefix) {
|
|
372
|
+
let allIcons = [];
|
|
373
|
+
(typeof provider === "string" ? [provider] : Object.keys(dataStorage)).forEach((provider$1) => {
|
|
374
|
+
(typeof provider$1 === "string" && typeof prefix === "string" ? [prefix] : Object.keys(dataStorage[provider$1] || {})).forEach((prefix$1) => {
|
|
375
|
+
const storage = getStorage(provider$1, prefix$1);
|
|
376
|
+
allIcons = allIcons.concat(Object.keys(storage.icons).map((name) => (provider$1 !== "" ? "@" + provider$1 + ":" : "") + prefix$1 + ":" + name));
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
return allIcons;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Allow storing icons without provider or prefix, making it possible to store icons like "home"
|
|
384
|
+
*/
|
|
385
|
+
let simpleNames = false;
|
|
386
|
+
function allowSimpleNames(allow) {
|
|
387
|
+
if (typeof allow === "boolean") simpleNames = allow;
|
|
388
|
+
return simpleNames;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Get icon data
|
|
392
|
+
*
|
|
393
|
+
* Returns:
|
|
394
|
+
* - IconifyIcon on success, object directly from storage so don't modify it
|
|
395
|
+
* - null if icon is marked as missing (returned in `not_found` property from API, so don't bother sending API requests)
|
|
396
|
+
* - undefined if icon is missing in storage
|
|
397
|
+
*/
|
|
398
|
+
function getIconData(name) {
|
|
399
|
+
const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
|
|
400
|
+
if (icon) {
|
|
401
|
+
const storage = getStorage(icon.provider, icon.prefix);
|
|
402
|
+
const iconName = icon.name;
|
|
403
|
+
return storage.icons[iconName] || (storage.missing.has(iconName) ? null : void 0);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Add one icon
|
|
408
|
+
*/
|
|
409
|
+
function addIcon$1(name, data) {
|
|
410
|
+
const icon = stringToIcon(name, true, simpleNames);
|
|
411
|
+
if (!icon) return false;
|
|
412
|
+
const storage = getStorage(icon.provider, icon.prefix);
|
|
413
|
+
if (data) return addIconToStorage(storage, icon.name, data);
|
|
414
|
+
else {
|
|
415
|
+
storage.missing.add(icon.name);
|
|
416
|
+
return true;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Add icon set
|
|
421
|
+
*/
|
|
422
|
+
function addCollection$1(data, provider) {
|
|
423
|
+
if (typeof data !== "object") return false;
|
|
424
|
+
if (typeof provider !== "string") provider = data.provider || "";
|
|
425
|
+
if (simpleNames && !provider && !data.prefix) {
|
|
426
|
+
let added = false;
|
|
427
|
+
if (quicklyValidateIconSet(data)) {
|
|
428
|
+
data.prefix = "";
|
|
429
|
+
parseIconSet(data, (name, icon) => {
|
|
430
|
+
if (addIcon$1(name, icon)) added = true;
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
return added;
|
|
434
|
+
}
|
|
435
|
+
const prefix = data.prefix;
|
|
436
|
+
if (!validateIconName({
|
|
437
|
+
prefix,
|
|
438
|
+
name: "a"
|
|
439
|
+
})) return false;
|
|
440
|
+
return !!addIconSet(getStorage(provider, prefix), data);
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Check if icon data is available
|
|
444
|
+
*/
|
|
445
|
+
function iconLoaded$1(name) {
|
|
446
|
+
return !!getIconData(name);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Get full icon
|
|
450
|
+
*/
|
|
451
|
+
function getIcon$1(name) {
|
|
452
|
+
const result = getIconData(name);
|
|
453
|
+
return result ? {
|
|
454
|
+
...defaultIconProps,
|
|
455
|
+
...result
|
|
456
|
+
} : result;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Remove callback
|
|
461
|
+
*/
|
|
462
|
+
function removeCallback(storages, id) {
|
|
463
|
+
storages.forEach((storage) => {
|
|
464
|
+
const items = storage.loaderCallbacks;
|
|
465
|
+
if (items) storage.loaderCallbacks = items.filter((row) => row.id !== id);
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Update all callbacks for provider and prefix
|
|
470
|
+
*/
|
|
471
|
+
function updateCallbacks(storage) {
|
|
472
|
+
if (!storage.pendingCallbacksFlag) {
|
|
473
|
+
storage.pendingCallbacksFlag = true;
|
|
474
|
+
setTimeout(() => {
|
|
475
|
+
storage.pendingCallbacksFlag = false;
|
|
476
|
+
const items = storage.loaderCallbacks ? storage.loaderCallbacks.slice(0) : [];
|
|
477
|
+
if (!items.length) return;
|
|
478
|
+
let hasPending = false;
|
|
479
|
+
const provider = storage.provider;
|
|
480
|
+
const prefix = storage.prefix;
|
|
481
|
+
items.forEach((item) => {
|
|
482
|
+
const icons = item.icons;
|
|
483
|
+
const oldLength = icons.pending.length;
|
|
484
|
+
icons.pending = icons.pending.filter((icon) => {
|
|
485
|
+
if (icon.prefix !== prefix) return true;
|
|
486
|
+
const name = icon.name;
|
|
487
|
+
if (storage.icons[name]) icons.loaded.push({
|
|
488
|
+
provider,
|
|
489
|
+
prefix,
|
|
490
|
+
name
|
|
491
|
+
});
|
|
492
|
+
else if (storage.missing.has(name)) icons.missing.push({
|
|
493
|
+
provider,
|
|
494
|
+
prefix,
|
|
495
|
+
name
|
|
496
|
+
});
|
|
497
|
+
else {
|
|
498
|
+
hasPending = true;
|
|
499
|
+
return true;
|
|
500
|
+
}
|
|
501
|
+
return false;
|
|
502
|
+
});
|
|
503
|
+
if (icons.pending.length !== oldLength) {
|
|
504
|
+
if (!hasPending) removeCallback([storage], item.id);
|
|
505
|
+
item.callback(icons.loaded.slice(0), icons.missing.slice(0), icons.pending.slice(0), item.abort);
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Unique id counter for callbacks
|
|
513
|
+
*/
|
|
514
|
+
let idCounter = 0;
|
|
515
|
+
/**
|
|
516
|
+
* Add callback
|
|
517
|
+
*/
|
|
518
|
+
function storeCallback(callback, icons, pendingSources) {
|
|
519
|
+
const id = idCounter++;
|
|
520
|
+
const abort = removeCallback.bind(null, pendingSources, id);
|
|
521
|
+
if (!icons.pending.length) return abort;
|
|
522
|
+
const item = {
|
|
523
|
+
id,
|
|
524
|
+
icons,
|
|
525
|
+
callback,
|
|
526
|
+
abort
|
|
527
|
+
};
|
|
528
|
+
pendingSources.forEach((storage) => {
|
|
529
|
+
(storage.loaderCallbacks || (storage.loaderCallbacks = [])).push(item);
|
|
530
|
+
});
|
|
531
|
+
return abort;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Check if icons have been loaded
|
|
536
|
+
*/
|
|
537
|
+
function sortIcons(icons) {
|
|
538
|
+
const result = {
|
|
539
|
+
loaded: [],
|
|
540
|
+
missing: [],
|
|
541
|
+
pending: []
|
|
542
|
+
};
|
|
543
|
+
const storage = Object.create(null);
|
|
544
|
+
icons.sort((a, b) => {
|
|
545
|
+
if (a.provider !== b.provider) return a.provider.localeCompare(b.provider);
|
|
546
|
+
if (a.prefix !== b.prefix) return a.prefix.localeCompare(b.prefix);
|
|
547
|
+
return a.name.localeCompare(b.name);
|
|
548
|
+
});
|
|
549
|
+
let lastIcon = {
|
|
550
|
+
provider: "",
|
|
551
|
+
prefix: "",
|
|
552
|
+
name: ""
|
|
553
|
+
};
|
|
554
|
+
icons.forEach((icon) => {
|
|
555
|
+
if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) return;
|
|
556
|
+
lastIcon = icon;
|
|
557
|
+
const provider = icon.provider;
|
|
558
|
+
const prefix = icon.prefix;
|
|
559
|
+
const name = icon.name;
|
|
560
|
+
const providerStorage = storage[provider] || (storage[provider] = Object.create(null));
|
|
561
|
+
const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
|
|
562
|
+
let list;
|
|
563
|
+
if (name in localStorage.icons) list = result.loaded;
|
|
564
|
+
else if (prefix === "" || localStorage.missing.has(name)) list = result.missing;
|
|
565
|
+
else list = result.pending;
|
|
566
|
+
const item = {
|
|
567
|
+
provider,
|
|
568
|
+
prefix,
|
|
569
|
+
name
|
|
570
|
+
};
|
|
571
|
+
list.push(item);
|
|
572
|
+
});
|
|
573
|
+
return result;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Local storate types and entries
|
|
578
|
+
*/
|
|
579
|
+
const storage = Object.create(null);
|
|
580
|
+
/**
|
|
581
|
+
* Set API module
|
|
582
|
+
*/
|
|
583
|
+
function setAPIModule(provider, item) {
|
|
584
|
+
storage[provider] = item;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Get API module
|
|
588
|
+
*/
|
|
589
|
+
function getAPIModule(provider) {
|
|
590
|
+
return storage[provider] || storage[""];
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Convert icons list from string/icon mix to icons and validate them
|
|
595
|
+
*/
|
|
596
|
+
function listToIcons(list, validate = true, simpleNames = false) {
|
|
597
|
+
const result = [];
|
|
598
|
+
list.forEach((item) => {
|
|
599
|
+
const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames) : item;
|
|
600
|
+
if (icon) result.push(icon);
|
|
601
|
+
});
|
|
602
|
+
return result;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Create full API configuration from partial data
|
|
607
|
+
*/
|
|
608
|
+
function createAPIConfig(source) {
|
|
609
|
+
let resources;
|
|
610
|
+
if (typeof source.resources === "string") resources = [source.resources];
|
|
611
|
+
else {
|
|
612
|
+
resources = source.resources;
|
|
613
|
+
if (!(resources instanceof Array) || !resources.length) return null;
|
|
614
|
+
}
|
|
615
|
+
return {
|
|
616
|
+
resources,
|
|
617
|
+
path: source.path || "/",
|
|
618
|
+
maxURL: source.maxURL || 500,
|
|
619
|
+
rotate: source.rotate || 750,
|
|
620
|
+
timeout: source.timeout || 5e3,
|
|
621
|
+
random: source.random === true,
|
|
622
|
+
index: source.index || 0,
|
|
623
|
+
dataAfterTimeout: source.dataAfterTimeout !== false
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Local storage
|
|
628
|
+
*/
|
|
629
|
+
const configStorage = Object.create(null);
|
|
630
|
+
/**
|
|
631
|
+
* Redundancy for API servers.
|
|
632
|
+
*
|
|
633
|
+
* API should have very high uptime because of implemented redundancy at server level, but
|
|
634
|
+
* sometimes bad things happen. On internet 100% uptime is not possible.
|
|
635
|
+
*
|
|
636
|
+
* There could be routing problems. Server might go down for whatever reason, but it takes
|
|
637
|
+
* few minutes to detect that downtime, so during those few minutes API might not be accessible.
|
|
638
|
+
*
|
|
639
|
+
* This script has some redundancy to mitigate possible network issues.
|
|
640
|
+
*
|
|
641
|
+
* If one host cannot be reached in 'rotate' (750 by default) ms, script will try to retrieve
|
|
642
|
+
* data from different host. Hosts have different configurations, pointing to different
|
|
643
|
+
* API servers hosted at different providers.
|
|
644
|
+
*/
|
|
645
|
+
const fallBackAPISources = ["https://api.simplesvg.com", "https://api.unisvg.com"];
|
|
646
|
+
const fallBackAPI = [];
|
|
647
|
+
while (fallBackAPISources.length > 0) if (fallBackAPISources.length === 1) fallBackAPI.push(fallBackAPISources.shift());
|
|
648
|
+
else if (Math.random() > .5) fallBackAPI.push(fallBackAPISources.shift());
|
|
649
|
+
else fallBackAPI.push(fallBackAPISources.pop());
|
|
650
|
+
configStorage[""] = createAPIConfig({ resources: ["https://api.iconify.design"].concat(fallBackAPI) });
|
|
651
|
+
/**
|
|
652
|
+
* Add custom config for provider
|
|
653
|
+
*/
|
|
654
|
+
function addAPIProvider$1(provider, customConfig) {
|
|
655
|
+
const config = createAPIConfig(customConfig);
|
|
656
|
+
if (config === null) return false;
|
|
657
|
+
configStorage[provider] = config;
|
|
658
|
+
return true;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Get API configuration
|
|
662
|
+
*/
|
|
663
|
+
function getAPIConfig(provider) {
|
|
664
|
+
return configStorage[provider];
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* List API providers
|
|
668
|
+
*/
|
|
669
|
+
function listAPIProviders() {
|
|
670
|
+
return Object.keys(configStorage);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Default RedundancyConfig for API calls
|
|
675
|
+
*/
|
|
676
|
+
const defaultConfig = {
|
|
677
|
+
resources: [],
|
|
678
|
+
index: 0,
|
|
679
|
+
timeout: 2e3,
|
|
680
|
+
rotate: 750,
|
|
681
|
+
random: false,
|
|
682
|
+
dataAfterTimeout: false
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Send query
|
|
687
|
+
*/
|
|
688
|
+
function sendQuery(config, payload, query, done) {
|
|
689
|
+
const resourcesCount = config.resources.length;
|
|
690
|
+
const startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;
|
|
691
|
+
let resources;
|
|
692
|
+
if (config.random) {
|
|
693
|
+
let list = config.resources.slice(0);
|
|
694
|
+
resources = [];
|
|
695
|
+
while (list.length > 1) {
|
|
696
|
+
const nextIndex = Math.floor(Math.random() * list.length);
|
|
697
|
+
resources.push(list[nextIndex]);
|
|
698
|
+
list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
|
|
699
|
+
}
|
|
700
|
+
resources = resources.concat(list);
|
|
701
|
+
} else resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
|
|
702
|
+
const startTime = Date.now();
|
|
703
|
+
let status = "pending";
|
|
704
|
+
let queriesSent = 0;
|
|
705
|
+
let lastError;
|
|
706
|
+
let timer = null;
|
|
707
|
+
let queue = [];
|
|
708
|
+
let doneCallbacks = [];
|
|
709
|
+
if (typeof done === "function") doneCallbacks.push(done);
|
|
710
|
+
/**
|
|
711
|
+
* Reset timer
|
|
712
|
+
*/
|
|
713
|
+
function resetTimer() {
|
|
714
|
+
if (timer) {
|
|
715
|
+
clearTimeout(timer);
|
|
716
|
+
timer = null;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* Abort everything
|
|
721
|
+
*/
|
|
722
|
+
function abort() {
|
|
723
|
+
if (status === "pending") status = "aborted";
|
|
724
|
+
resetTimer();
|
|
725
|
+
queue.forEach((item) => {
|
|
726
|
+
if (item.status === "pending") item.status = "aborted";
|
|
727
|
+
});
|
|
728
|
+
queue = [];
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Add / replace callback to call when execution is complete.
|
|
732
|
+
* This can be used to abort pending query implementations when query is complete or aborted.
|
|
733
|
+
*/
|
|
734
|
+
function subscribe(callback, overwrite) {
|
|
735
|
+
if (overwrite) doneCallbacks = [];
|
|
736
|
+
if (typeof callback === "function") doneCallbacks.push(callback);
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Get query status
|
|
740
|
+
*/
|
|
741
|
+
function getQueryStatus() {
|
|
742
|
+
return {
|
|
743
|
+
startTime,
|
|
744
|
+
payload,
|
|
745
|
+
status,
|
|
746
|
+
queriesSent,
|
|
747
|
+
queriesPending: queue.length,
|
|
748
|
+
subscribe,
|
|
749
|
+
abort
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Fail query
|
|
754
|
+
*/
|
|
755
|
+
function failQuery() {
|
|
756
|
+
status = "failed";
|
|
757
|
+
doneCallbacks.forEach((callback) => {
|
|
758
|
+
callback(void 0, lastError);
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* Clear queue
|
|
763
|
+
*/
|
|
764
|
+
function clearQueue() {
|
|
765
|
+
queue.forEach((item) => {
|
|
766
|
+
if (item.status === "pending") item.status = "aborted";
|
|
767
|
+
});
|
|
768
|
+
queue = [];
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Got response from module
|
|
772
|
+
*/
|
|
773
|
+
function moduleResponse(item, response, data) {
|
|
774
|
+
const isError = response !== "success";
|
|
775
|
+
queue = queue.filter((queued) => queued !== item);
|
|
776
|
+
switch (status) {
|
|
777
|
+
case "pending": break;
|
|
778
|
+
case "failed":
|
|
779
|
+
if (isError || !config.dataAfterTimeout) return;
|
|
780
|
+
break;
|
|
781
|
+
default: return;
|
|
782
|
+
}
|
|
783
|
+
if (response === "abort") {
|
|
784
|
+
lastError = data;
|
|
785
|
+
failQuery();
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
if (isError) {
|
|
789
|
+
lastError = data;
|
|
790
|
+
if (!queue.length) if (!resources.length) failQuery();
|
|
791
|
+
else execNext();
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
resetTimer();
|
|
795
|
+
clearQueue();
|
|
796
|
+
if (!config.random) {
|
|
797
|
+
const index = config.resources.indexOf(item.resource);
|
|
798
|
+
if (index !== -1 && index !== config.index) config.index = index;
|
|
799
|
+
}
|
|
800
|
+
status = "completed";
|
|
801
|
+
doneCallbacks.forEach((callback) => {
|
|
802
|
+
callback(data);
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Execute next query
|
|
807
|
+
*/
|
|
808
|
+
function execNext() {
|
|
809
|
+
if (status !== "pending") return;
|
|
810
|
+
resetTimer();
|
|
811
|
+
const resource = resources.shift();
|
|
812
|
+
if (resource === void 0) {
|
|
813
|
+
if (queue.length) {
|
|
814
|
+
timer = setTimeout(() => {
|
|
815
|
+
resetTimer();
|
|
816
|
+
if (status === "pending") {
|
|
817
|
+
clearQueue();
|
|
818
|
+
failQuery();
|
|
819
|
+
}
|
|
820
|
+
}, config.timeout);
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
failQuery();
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
const item = {
|
|
827
|
+
status: "pending",
|
|
828
|
+
resource,
|
|
829
|
+
callback: (status$1, data) => {
|
|
830
|
+
moduleResponse(item, status$1, data);
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
queue.push(item);
|
|
834
|
+
queriesSent++;
|
|
835
|
+
timer = setTimeout(execNext, config.rotate);
|
|
836
|
+
query(resource, payload, item.callback);
|
|
837
|
+
}
|
|
838
|
+
setTimeout(execNext);
|
|
839
|
+
return getQueryStatus;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* Redundancy instance
|
|
844
|
+
*/
|
|
845
|
+
function initRedundancy(cfg) {
|
|
846
|
+
const config = {
|
|
847
|
+
...defaultConfig,
|
|
848
|
+
...cfg
|
|
849
|
+
};
|
|
850
|
+
let queries = [];
|
|
851
|
+
/**
|
|
852
|
+
* Remove aborted and completed queries
|
|
853
|
+
*/
|
|
854
|
+
function cleanup() {
|
|
855
|
+
queries = queries.filter((item) => item().status === "pending");
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Send query
|
|
859
|
+
*/
|
|
860
|
+
function query(payload, queryCallback, doneCallback) {
|
|
861
|
+
const query$1 = sendQuery(config, payload, queryCallback, (data, error) => {
|
|
862
|
+
cleanup();
|
|
863
|
+
if (doneCallback) doneCallback(data, error);
|
|
864
|
+
});
|
|
865
|
+
queries.push(query$1);
|
|
866
|
+
return query$1;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Find instance
|
|
870
|
+
*/
|
|
871
|
+
function find(callback) {
|
|
872
|
+
return queries.find((value) => {
|
|
873
|
+
return callback(value);
|
|
874
|
+
}) || null;
|
|
875
|
+
}
|
|
876
|
+
return {
|
|
877
|
+
query,
|
|
878
|
+
find,
|
|
879
|
+
setIndex: (index) => {
|
|
880
|
+
config.index = index;
|
|
881
|
+
},
|
|
882
|
+
getIndex: () => config.index,
|
|
883
|
+
cleanup
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
function emptyCallback$1() {}
|
|
888
|
+
const redundancyCache = Object.create(null);
|
|
889
|
+
/**
|
|
890
|
+
* Get Redundancy instance for provider
|
|
891
|
+
*/
|
|
892
|
+
function getRedundancyCache(provider) {
|
|
893
|
+
if (!redundancyCache[provider]) {
|
|
894
|
+
const config = getAPIConfig(provider);
|
|
895
|
+
if (!config) return;
|
|
896
|
+
redundancyCache[provider] = {
|
|
897
|
+
config,
|
|
898
|
+
redundancy: initRedundancy(config)
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
return redundancyCache[provider];
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Send API query
|
|
905
|
+
*/
|
|
906
|
+
function sendAPIQuery(target, query, callback) {
|
|
907
|
+
let redundancy;
|
|
908
|
+
let send;
|
|
909
|
+
if (typeof target === "string") {
|
|
910
|
+
const api = getAPIModule(target);
|
|
911
|
+
if (!api) {
|
|
912
|
+
callback(void 0, 424);
|
|
913
|
+
return emptyCallback$1;
|
|
914
|
+
}
|
|
915
|
+
send = api.send;
|
|
916
|
+
const cached = getRedundancyCache(target);
|
|
917
|
+
if (cached) redundancy = cached.redundancy;
|
|
918
|
+
} else {
|
|
919
|
+
const config = createAPIConfig(target);
|
|
920
|
+
if (config) {
|
|
921
|
+
redundancy = initRedundancy(config);
|
|
922
|
+
const api = getAPIModule(target.resources ? target.resources[0] : "");
|
|
923
|
+
if (api) send = api.send;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
if (!redundancy || !send) {
|
|
927
|
+
callback(void 0, 424);
|
|
928
|
+
return emptyCallback$1;
|
|
929
|
+
}
|
|
930
|
+
return redundancy.query(query, send, callback)().abort;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
function emptyCallback() {}
|
|
934
|
+
/**
|
|
935
|
+
* Function called when new icons have been loaded
|
|
936
|
+
*/
|
|
937
|
+
function loadedNewIcons(storage) {
|
|
938
|
+
if (!storage.iconsLoaderFlag) {
|
|
939
|
+
storage.iconsLoaderFlag = true;
|
|
940
|
+
setTimeout(() => {
|
|
941
|
+
storage.iconsLoaderFlag = false;
|
|
942
|
+
updateCallbacks(storage);
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Check icon names for API
|
|
948
|
+
*/
|
|
949
|
+
function checkIconNamesForAPI(icons) {
|
|
950
|
+
const valid = [];
|
|
951
|
+
const invalid = [];
|
|
952
|
+
icons.forEach((name) => {
|
|
953
|
+
(name.match(matchIconName) ? valid : invalid).push(name);
|
|
954
|
+
});
|
|
955
|
+
return {
|
|
956
|
+
valid,
|
|
957
|
+
invalid
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Parse loader response
|
|
962
|
+
*/
|
|
963
|
+
function parseLoaderResponse(storage, icons, data) {
|
|
964
|
+
function checkMissing() {
|
|
965
|
+
const pending = storage.pendingIcons;
|
|
966
|
+
icons.forEach((name) => {
|
|
967
|
+
if (pending) pending.delete(name);
|
|
968
|
+
if (!storage.icons[name]) storage.missing.add(name);
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
if (data && typeof data === "object") try {
|
|
972
|
+
if (!addIconSet(storage, data).length) {
|
|
973
|
+
checkMissing();
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
} catch (err) {
|
|
977
|
+
console.error(err);
|
|
978
|
+
}
|
|
979
|
+
checkMissing();
|
|
980
|
+
loadedNewIcons(storage);
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Handle response that can be async
|
|
984
|
+
*/
|
|
985
|
+
function parsePossiblyAsyncResponse(response, callback) {
|
|
986
|
+
if (response instanceof Promise) response.then((data) => {
|
|
987
|
+
callback(data);
|
|
988
|
+
}).catch(() => {
|
|
989
|
+
callback(null);
|
|
990
|
+
});
|
|
991
|
+
else callback(response);
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Load icons
|
|
995
|
+
*/
|
|
996
|
+
function loadNewIcons(storage, icons) {
|
|
997
|
+
if (!storage.iconsToLoad) storage.iconsToLoad = icons;
|
|
998
|
+
else storage.iconsToLoad = storage.iconsToLoad.concat(icons).sort();
|
|
999
|
+
if (!storage.iconsQueueFlag) {
|
|
1000
|
+
storage.iconsQueueFlag = true;
|
|
1001
|
+
setTimeout(() => {
|
|
1002
|
+
storage.iconsQueueFlag = false;
|
|
1003
|
+
const { provider, prefix } = storage;
|
|
1004
|
+
const icons$1 = storage.iconsToLoad;
|
|
1005
|
+
delete storage.iconsToLoad;
|
|
1006
|
+
if (!icons$1 || !icons$1.length) return;
|
|
1007
|
+
const customIconLoader = storage.loadIcon;
|
|
1008
|
+
if (storage.loadIcons && (icons$1.length > 1 || !customIconLoader)) {
|
|
1009
|
+
parsePossiblyAsyncResponse(storage.loadIcons(icons$1, prefix, provider), (data) => {
|
|
1010
|
+
parseLoaderResponse(storage, icons$1, data);
|
|
1011
|
+
});
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
if (customIconLoader) {
|
|
1015
|
+
icons$1.forEach((name) => {
|
|
1016
|
+
parsePossiblyAsyncResponse(customIconLoader(name, prefix, provider), (data) => {
|
|
1017
|
+
parseLoaderResponse(storage, [name], data ? {
|
|
1018
|
+
prefix,
|
|
1019
|
+
icons: { [name]: data }
|
|
1020
|
+
} : null);
|
|
1021
|
+
});
|
|
1022
|
+
});
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
const { valid, invalid } = checkIconNamesForAPI(icons$1);
|
|
1026
|
+
if (invalid.length) parseLoaderResponse(storage, invalid, null);
|
|
1027
|
+
if (!valid.length) return;
|
|
1028
|
+
const api = prefix.match(matchIconName) ? getAPIModule(provider) : null;
|
|
1029
|
+
if (!api) {
|
|
1030
|
+
parseLoaderResponse(storage, valid, null);
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
api.prepare(provider, prefix, valid).forEach((item) => {
|
|
1034
|
+
sendAPIQuery(provider, item, (data) => {
|
|
1035
|
+
parseLoaderResponse(storage, item.icons, data);
|
|
1036
|
+
});
|
|
1037
|
+
});
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Load icons
|
|
1043
|
+
*/
|
|
1044
|
+
const loadIcons$1 = (icons, callback) => {
|
|
1045
|
+
const sortedIcons = sortIcons(listToIcons(icons, true, allowSimpleNames()));
|
|
1046
|
+
if (!sortedIcons.pending.length) {
|
|
1047
|
+
let callCallback = true;
|
|
1048
|
+
if (callback) setTimeout(() => {
|
|
1049
|
+
if (callCallback) callback(sortedIcons.loaded, sortedIcons.missing, sortedIcons.pending, emptyCallback);
|
|
1050
|
+
});
|
|
1051
|
+
return () => {
|
|
1052
|
+
callCallback = false;
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
const newIcons = Object.create(null);
|
|
1056
|
+
const sources = [];
|
|
1057
|
+
let lastProvider, lastPrefix;
|
|
1058
|
+
sortedIcons.pending.forEach((icon) => {
|
|
1059
|
+
const { provider, prefix } = icon;
|
|
1060
|
+
if (prefix === lastPrefix && provider === lastProvider) return;
|
|
1061
|
+
lastProvider = provider;
|
|
1062
|
+
lastPrefix = prefix;
|
|
1063
|
+
sources.push(getStorage(provider, prefix));
|
|
1064
|
+
const providerNewIcons = newIcons[provider] || (newIcons[provider] = Object.create(null));
|
|
1065
|
+
if (!providerNewIcons[prefix]) providerNewIcons[prefix] = [];
|
|
1066
|
+
});
|
|
1067
|
+
sortedIcons.pending.forEach((icon) => {
|
|
1068
|
+
const { provider, prefix, name } = icon;
|
|
1069
|
+
const storage = getStorage(provider, prefix);
|
|
1070
|
+
const pendingQueue = storage.pendingIcons || (storage.pendingIcons = /* @__PURE__ */ new Set());
|
|
1071
|
+
if (!pendingQueue.has(name)) {
|
|
1072
|
+
pendingQueue.add(name);
|
|
1073
|
+
newIcons[provider][prefix].push(name);
|
|
1074
|
+
}
|
|
1075
|
+
});
|
|
1076
|
+
sources.forEach((storage) => {
|
|
1077
|
+
const list = newIcons[storage.provider][storage.prefix];
|
|
1078
|
+
if (list.length) loadNewIcons(storage, list);
|
|
1079
|
+
});
|
|
1080
|
+
return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
|
|
1081
|
+
};
|
|
1082
|
+
/**
|
|
1083
|
+
* Load one icon using Promise
|
|
1084
|
+
*/
|
|
1085
|
+
const loadIcon$1 = (icon) => {
|
|
1086
|
+
return new Promise((fulfill, reject) => {
|
|
1087
|
+
const iconObj = typeof icon === "string" ? stringToIcon(icon, true) : icon;
|
|
1088
|
+
if (!iconObj) {
|
|
1089
|
+
reject(icon);
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
loadIcons$1([iconObj || icon], (loaded) => {
|
|
1093
|
+
if (loaded.length && iconObj) {
|
|
1094
|
+
const data = getIconData(iconObj);
|
|
1095
|
+
if (data) {
|
|
1096
|
+
fulfill({
|
|
1097
|
+
...defaultIconProps,
|
|
1098
|
+
...data
|
|
1099
|
+
});
|
|
1100
|
+
return;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
reject(icon);
|
|
1104
|
+
});
|
|
1105
|
+
});
|
|
1106
|
+
};
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* Test icon string
|
|
1110
|
+
*/
|
|
1111
|
+
function testIconObject(value) {
|
|
1112
|
+
try {
|
|
1113
|
+
const obj = typeof value === 'string' ? JSON.parse(value) : value;
|
|
1114
|
+
if (typeof obj.body === 'string') {
|
|
1115
|
+
return {
|
|
1116
|
+
...obj,
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1120
|
+
}
|
|
1121
|
+
catch (err) {
|
|
1122
|
+
//
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* Parse icon value, load if needed
|
|
1128
|
+
*/
|
|
1129
|
+
function parseIconValue(value, onload) {
|
|
1130
|
+
if (typeof value === 'object') {
|
|
1131
|
+
const data = testIconObject(value);
|
|
1132
|
+
return {
|
|
1133
|
+
data,
|
|
1134
|
+
value,
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
if (typeof value !== 'string') {
|
|
1138
|
+
// Invalid value
|
|
1139
|
+
return {
|
|
1140
|
+
value,
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
// Check for JSON
|
|
1144
|
+
if (value.includes('{')) {
|
|
1145
|
+
const data = testIconObject(value);
|
|
1146
|
+
if (data) {
|
|
1147
|
+
return {
|
|
1148
|
+
data,
|
|
1149
|
+
value,
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
// Parse icon name
|
|
1154
|
+
const name = stringToIcon(value, true, true);
|
|
1155
|
+
if (!name) {
|
|
1156
|
+
return {
|
|
1157
|
+
value,
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
// Valid icon name: check if data is available
|
|
1161
|
+
const data = getIconData(name);
|
|
1162
|
+
// Icon data exists or icon has no prefix. Do not load icon from API if icon has no prefix
|
|
1163
|
+
if (data !== undefined || !name.prefix) {
|
|
1164
|
+
return {
|
|
1165
|
+
value,
|
|
1166
|
+
name,
|
|
1167
|
+
data, // could be 'null' -> icon is missing
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
// Load icon
|
|
1171
|
+
const loading = loadIcons$1([name], () => onload(value, name, getIconData(name)));
|
|
1172
|
+
return {
|
|
1173
|
+
value,
|
|
1174
|
+
name,
|
|
1175
|
+
loading,
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
// Check for Safari
|
|
1180
|
+
let isBuggedSafari = false;
|
|
1181
|
+
try {
|
|
1182
|
+
isBuggedSafari = navigator.vendor.indexOf('Apple') === 0;
|
|
1183
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1184
|
+
}
|
|
1185
|
+
catch (err) {
|
|
1186
|
+
//
|
|
1187
|
+
}
|
|
1188
|
+
/**
|
|
1189
|
+
* Get render mode
|
|
1190
|
+
*/
|
|
1191
|
+
function getRenderMode(body, mode) {
|
|
1192
|
+
switch (mode) {
|
|
1193
|
+
// Force mode
|
|
1194
|
+
case 'svg':
|
|
1195
|
+
case 'bg':
|
|
1196
|
+
case 'mask':
|
|
1197
|
+
return mode;
|
|
1198
|
+
}
|
|
1199
|
+
// Check for animation, use 'style' for animated icons, unless browser is Safari
|
|
1200
|
+
// (only <a>, which should be ignored or animations start with '<a')
|
|
1201
|
+
if (mode !== 'style' &&
|
|
1202
|
+
(isBuggedSafari || body.indexOf('<a') === -1)) {
|
|
1203
|
+
// Render <svg>
|
|
1204
|
+
return 'svg';
|
|
1205
|
+
}
|
|
1206
|
+
// Use background or mask
|
|
1207
|
+
return body.indexOf('currentColor') === -1 ? 'bg' : 'mask';
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* Regular expressions for calculating dimensions
|
|
1212
|
+
*/
|
|
1213
|
+
const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
|
|
1214
|
+
const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
|
|
1215
|
+
function calculateSize$1(size, ratio, precision) {
|
|
1216
|
+
if (ratio === 1) return size;
|
|
1217
|
+
precision = precision || 100;
|
|
1218
|
+
if (typeof size === "number") return Math.ceil(size * ratio * precision) / precision;
|
|
1219
|
+
if (typeof size !== "string") return size;
|
|
1220
|
+
const oldParts = size.split(unitsSplit);
|
|
1221
|
+
if (oldParts === null || !oldParts.length) return size;
|
|
1222
|
+
const newParts = [];
|
|
1223
|
+
let code = oldParts.shift();
|
|
1224
|
+
let isNumber = unitsTest.test(code);
|
|
1225
|
+
while (true) {
|
|
1226
|
+
if (isNumber) {
|
|
1227
|
+
const num = parseFloat(code);
|
|
1228
|
+
if (isNaN(num)) newParts.push(code);
|
|
1229
|
+
else newParts.push(Math.ceil(num * ratio * precision) / precision);
|
|
1230
|
+
} else newParts.push(code);
|
|
1231
|
+
code = oldParts.shift();
|
|
1232
|
+
if (code === void 0) return newParts.join("");
|
|
1233
|
+
isNumber = !isNumber;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
function splitSVGDefs(content, tag = "defs") {
|
|
1238
|
+
let defs = "";
|
|
1239
|
+
const index = content.indexOf("<" + tag);
|
|
1240
|
+
while (index >= 0) {
|
|
1241
|
+
const start = content.indexOf(">", index);
|
|
1242
|
+
const end = content.indexOf("</" + tag);
|
|
1243
|
+
if (start === -1 || end === -1) break;
|
|
1244
|
+
const endEnd = content.indexOf(">", end);
|
|
1245
|
+
if (endEnd === -1) break;
|
|
1246
|
+
defs += content.slice(start + 1, end).trim();
|
|
1247
|
+
content = content.slice(0, index).trim() + content.slice(endEnd + 1);
|
|
1248
|
+
}
|
|
1249
|
+
return {
|
|
1250
|
+
defs,
|
|
1251
|
+
content
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Merge defs and content
|
|
1256
|
+
*/
|
|
1257
|
+
function mergeDefsAndContent(defs, content) {
|
|
1258
|
+
return defs ? "<defs>" + defs + "</defs>" + content : content;
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Wrap SVG content, without wrapping definitions
|
|
1262
|
+
*/
|
|
1263
|
+
function wrapSVGContent(body, start, end) {
|
|
1264
|
+
const split = splitSVGDefs(body);
|
|
1265
|
+
return mergeDefsAndContent(split.defs, start + split.content + end);
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* Check if value should be unset. Allows multiple keywords
|
|
1270
|
+
*/
|
|
1271
|
+
const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
|
|
1272
|
+
/**
|
|
1273
|
+
* Get SVG attributes and content from icon + customisations
|
|
1274
|
+
*
|
|
1275
|
+
* Does not generate style to make it compatible with frameworks that use objects for style, such as React.
|
|
1276
|
+
* Instead, it generates 'inline' value. If true, rendering engine should add verticalAlign: -0.125em to icon.
|
|
1277
|
+
*
|
|
1278
|
+
* Customisations should be normalised by platform specific parser.
|
|
1279
|
+
* Result should be converted to <svg> by platform specific parser.
|
|
1280
|
+
* Use replaceIDs to generate unique IDs for body.
|
|
1281
|
+
*/
|
|
1282
|
+
function iconToSVG(icon, customisations) {
|
|
1283
|
+
const fullIcon = {
|
|
1284
|
+
...defaultIconProps,
|
|
1285
|
+
...icon
|
|
1286
|
+
};
|
|
1287
|
+
const fullCustomisations = {
|
|
1288
|
+
...defaultIconCustomisations,
|
|
1289
|
+
...customisations
|
|
1290
|
+
};
|
|
1291
|
+
const box = {
|
|
1292
|
+
left: fullIcon.left,
|
|
1293
|
+
top: fullIcon.top,
|
|
1294
|
+
width: fullIcon.width,
|
|
1295
|
+
height: fullIcon.height
|
|
1296
|
+
};
|
|
1297
|
+
let body = fullIcon.body;
|
|
1298
|
+
[fullIcon, fullCustomisations].forEach((props) => {
|
|
1299
|
+
const transformations = [];
|
|
1300
|
+
const hFlip = props.hFlip;
|
|
1301
|
+
const vFlip = props.vFlip;
|
|
1302
|
+
let rotation = props.rotate;
|
|
1303
|
+
if (hFlip) if (vFlip) rotation += 2;
|
|
1304
|
+
else {
|
|
1305
|
+
transformations.push("translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")");
|
|
1306
|
+
transformations.push("scale(-1 1)");
|
|
1307
|
+
box.top = box.left = 0;
|
|
1308
|
+
}
|
|
1309
|
+
else if (vFlip) {
|
|
1310
|
+
transformations.push("translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")");
|
|
1311
|
+
transformations.push("scale(1 -1)");
|
|
1312
|
+
box.top = box.left = 0;
|
|
1313
|
+
}
|
|
1314
|
+
let tempValue;
|
|
1315
|
+
if (rotation < 0) rotation -= Math.floor(rotation / 4) * 4;
|
|
1316
|
+
rotation = rotation % 4;
|
|
1317
|
+
switch (rotation) {
|
|
1318
|
+
case 1:
|
|
1319
|
+
tempValue = box.height / 2 + box.top;
|
|
1320
|
+
transformations.unshift("rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")");
|
|
1321
|
+
break;
|
|
1322
|
+
case 2:
|
|
1323
|
+
transformations.unshift("rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")");
|
|
1324
|
+
break;
|
|
1325
|
+
case 3:
|
|
1326
|
+
tempValue = box.width / 2 + box.left;
|
|
1327
|
+
transformations.unshift("rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")");
|
|
1328
|
+
break;
|
|
1329
|
+
}
|
|
1330
|
+
if (rotation % 2 === 1) {
|
|
1331
|
+
if (box.left !== box.top) {
|
|
1332
|
+
tempValue = box.left;
|
|
1333
|
+
box.left = box.top;
|
|
1334
|
+
box.top = tempValue;
|
|
1335
|
+
}
|
|
1336
|
+
if (box.width !== box.height) {
|
|
1337
|
+
tempValue = box.width;
|
|
1338
|
+
box.width = box.height;
|
|
1339
|
+
box.height = tempValue;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
if (transformations.length) body = wrapSVGContent(body, "<g transform=\"" + transformations.join(" ") + "\">", "</g>");
|
|
1343
|
+
});
|
|
1344
|
+
const customisationsWidth = fullCustomisations.width;
|
|
1345
|
+
const customisationsHeight = fullCustomisations.height;
|
|
1346
|
+
const boxWidth = box.width;
|
|
1347
|
+
const boxHeight = box.height;
|
|
1348
|
+
let width;
|
|
1349
|
+
let height;
|
|
1350
|
+
if (customisationsWidth === null) {
|
|
1351
|
+
height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
|
|
1352
|
+
width = calculateSize$1(height, boxWidth / boxHeight);
|
|
1353
|
+
} else {
|
|
1354
|
+
width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
|
|
1355
|
+
height = customisationsHeight === null ? calculateSize$1(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
|
|
1356
|
+
}
|
|
1357
|
+
const attributes = {};
|
|
1358
|
+
const setAttr = (prop, value) => {
|
|
1359
|
+
if (!isUnsetKeyword(value)) attributes[prop] = value.toString();
|
|
1360
|
+
};
|
|
1361
|
+
setAttr("width", width);
|
|
1362
|
+
setAttr("height", height);
|
|
1363
|
+
const viewBox = [
|
|
1364
|
+
box.left,
|
|
1365
|
+
box.top,
|
|
1366
|
+
boxWidth,
|
|
1367
|
+
boxHeight
|
|
1368
|
+
];
|
|
1369
|
+
attributes.viewBox = viewBox.join(" ");
|
|
1370
|
+
return {
|
|
1371
|
+
attributes,
|
|
1372
|
+
viewBox,
|
|
1373
|
+
body
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
/**
|
|
1378
|
+
* Generate <svg>
|
|
1379
|
+
*/
|
|
1380
|
+
function iconToHTML$1(body, attributes) {
|
|
1381
|
+
let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : " xmlns:xlink=\"http://www.w3.org/1999/xlink\"";
|
|
1382
|
+
for (const attr in attributes) renderAttribsHTML += " " + attr + "=\"" + attributes[attr] + "\"";
|
|
1383
|
+
return "<svg xmlns=\"http://www.w3.org/2000/svg\"" + renderAttribsHTML + ">" + body + "</svg>";
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
/**
|
|
1387
|
+
* Encode SVG for use in url()
|
|
1388
|
+
*
|
|
1389
|
+
* Short alternative to encodeURIComponent() that encodes only stuff used in SVG, generating
|
|
1390
|
+
* smaller code.
|
|
1391
|
+
*/
|
|
1392
|
+
function encodeSVGforURL(svg) {
|
|
1393
|
+
return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
|
|
1394
|
+
}
|
|
1395
|
+
/**
|
|
1396
|
+
* Generate data: URL from SVG
|
|
1397
|
+
*/
|
|
1398
|
+
function svgToData(svg) {
|
|
1399
|
+
return "data:image/svg+xml," + encodeSVGforURL(svg);
|
|
1400
|
+
}
|
|
1401
|
+
/**
|
|
1402
|
+
* Generate url() from SVG
|
|
1403
|
+
*/
|
|
1404
|
+
function svgToURL$1(svg) {
|
|
1405
|
+
return "url(\"" + svgToData(svg) + "\")";
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
const detectFetch = () => {
|
|
1409
|
+
let callback;
|
|
1410
|
+
try {
|
|
1411
|
+
callback = fetch;
|
|
1412
|
+
if (typeof callback === "function") return callback;
|
|
1413
|
+
} catch (err) {}
|
|
1414
|
+
};
|
|
1415
|
+
/**
|
|
1416
|
+
* Fetch function
|
|
1417
|
+
*/
|
|
1418
|
+
let fetchModule = detectFetch();
|
|
1419
|
+
/**
|
|
1420
|
+
* Set custom fetch() function
|
|
1421
|
+
*/
|
|
1422
|
+
function setFetch(fetch$1) {
|
|
1423
|
+
fetchModule = fetch$1;
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* Get fetch() function. Used by Icon Finder Core
|
|
1427
|
+
*/
|
|
1428
|
+
function getFetch() {
|
|
1429
|
+
return fetchModule;
|
|
1430
|
+
}
|
|
1431
|
+
/**
|
|
1432
|
+
* Calculate maximum icons list length for prefix
|
|
1433
|
+
*/
|
|
1434
|
+
function calculateMaxLength(provider, prefix) {
|
|
1435
|
+
const config = getAPIConfig(provider);
|
|
1436
|
+
if (!config) return 0;
|
|
1437
|
+
let result;
|
|
1438
|
+
if (!config.maxURL) result = 0;
|
|
1439
|
+
else {
|
|
1440
|
+
let maxHostLength = 0;
|
|
1441
|
+
config.resources.forEach((item) => {
|
|
1442
|
+
const host = item;
|
|
1443
|
+
maxHostLength = Math.max(maxHostLength, host.length);
|
|
1444
|
+
});
|
|
1445
|
+
const url = prefix + ".json?icons=";
|
|
1446
|
+
result = config.maxURL - maxHostLength - config.path.length - url.length;
|
|
1447
|
+
}
|
|
1448
|
+
return result;
|
|
1449
|
+
}
|
|
1450
|
+
/**
|
|
1451
|
+
* Should query be aborted, based on last HTTP status
|
|
1452
|
+
*/
|
|
1453
|
+
function shouldAbort(status) {
|
|
1454
|
+
return status === 404;
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* Prepare params
|
|
1458
|
+
*/
|
|
1459
|
+
const prepare = (provider, prefix, icons) => {
|
|
1460
|
+
const results = [];
|
|
1461
|
+
const maxLength = calculateMaxLength(provider, prefix);
|
|
1462
|
+
const type = "icons";
|
|
1463
|
+
let item = {
|
|
1464
|
+
type,
|
|
1465
|
+
provider,
|
|
1466
|
+
prefix,
|
|
1467
|
+
icons: []
|
|
1468
|
+
};
|
|
1469
|
+
let length = 0;
|
|
1470
|
+
icons.forEach((name, index) => {
|
|
1471
|
+
length += name.length + 1;
|
|
1472
|
+
if (length >= maxLength && index > 0) {
|
|
1473
|
+
results.push(item);
|
|
1474
|
+
item = {
|
|
1475
|
+
type,
|
|
1476
|
+
provider,
|
|
1477
|
+
prefix,
|
|
1478
|
+
icons: []
|
|
1479
|
+
};
|
|
1480
|
+
length = name.length;
|
|
1481
|
+
}
|
|
1482
|
+
item.icons.push(name);
|
|
1483
|
+
});
|
|
1484
|
+
results.push(item);
|
|
1485
|
+
return results;
|
|
1486
|
+
};
|
|
1487
|
+
/**
|
|
1488
|
+
* Get path
|
|
1489
|
+
*/
|
|
1490
|
+
function getPath(provider) {
|
|
1491
|
+
if (typeof provider === "string") {
|
|
1492
|
+
const config = getAPIConfig(provider);
|
|
1493
|
+
if (config) return config.path;
|
|
1494
|
+
}
|
|
1495
|
+
return "/";
|
|
1496
|
+
}
|
|
1497
|
+
/**
|
|
1498
|
+
* Load icons
|
|
1499
|
+
*/
|
|
1500
|
+
const send = (host, params, callback) => {
|
|
1501
|
+
if (!fetchModule) {
|
|
1502
|
+
callback("abort", 424);
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1505
|
+
let path = getPath(params.provider);
|
|
1506
|
+
switch (params.type) {
|
|
1507
|
+
case "icons": {
|
|
1508
|
+
const prefix = params.prefix;
|
|
1509
|
+
const iconsList = params.icons.join(",");
|
|
1510
|
+
const urlParams = new URLSearchParams({ icons: iconsList });
|
|
1511
|
+
path += prefix + ".json?" + urlParams.toString();
|
|
1512
|
+
break;
|
|
1513
|
+
}
|
|
1514
|
+
case "custom": {
|
|
1515
|
+
const uri = params.uri;
|
|
1516
|
+
path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
|
|
1517
|
+
break;
|
|
1518
|
+
}
|
|
1519
|
+
default:
|
|
1520
|
+
callback("abort", 400);
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
let defaultError = 503;
|
|
1524
|
+
fetchModule(host + path).then((response) => {
|
|
1525
|
+
const status = response.status;
|
|
1526
|
+
if (status !== 200) {
|
|
1527
|
+
setTimeout(() => {
|
|
1528
|
+
callback(shouldAbort(status) ? "abort" : "next", status);
|
|
1529
|
+
});
|
|
1530
|
+
return;
|
|
1531
|
+
}
|
|
1532
|
+
defaultError = 501;
|
|
1533
|
+
return response.json();
|
|
1534
|
+
}).then((data) => {
|
|
1535
|
+
if (typeof data !== "object" || data === null) {
|
|
1536
|
+
setTimeout(() => {
|
|
1537
|
+
if (data === 404) callback("abort", data);
|
|
1538
|
+
else callback("next", defaultError);
|
|
1539
|
+
});
|
|
1540
|
+
return;
|
|
1541
|
+
}
|
|
1542
|
+
setTimeout(() => {
|
|
1543
|
+
callback("success", data);
|
|
1544
|
+
});
|
|
1545
|
+
}).catch(() => {
|
|
1546
|
+
callback("next", defaultError);
|
|
1547
|
+
});
|
|
1548
|
+
};
|
|
1549
|
+
/**
|
|
1550
|
+
* Export module
|
|
1551
|
+
*/
|
|
1552
|
+
const fetchAPIModule = {
|
|
1553
|
+
prepare,
|
|
1554
|
+
send
|
|
1555
|
+
};
|
|
1556
|
+
|
|
1557
|
+
/**
|
|
1558
|
+
* Set custom loader for multiple icons
|
|
1559
|
+
*/
|
|
1560
|
+
function setCustomIconsLoader$1(loader, prefix, provider) {
|
|
1561
|
+
getStorage(provider || "", prefix).loadIcons = loader;
|
|
1562
|
+
}
|
|
1563
|
+
/**
|
|
1564
|
+
* Set custom loader for one icon
|
|
1565
|
+
*/
|
|
1566
|
+
function setCustomIconLoader$1(loader, prefix, provider) {
|
|
1567
|
+
getStorage(provider || "", prefix).loadIcon = loader;
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
/**
|
|
1571
|
+
* Attribute to add
|
|
1572
|
+
*/
|
|
1573
|
+
const nodeAttr = 'data-style';
|
|
1574
|
+
/**
|
|
1575
|
+
* Custom style to add to each node
|
|
1576
|
+
*/
|
|
1577
|
+
let customStyle = '';
|
|
1578
|
+
/**
|
|
1579
|
+
* Set custom style to add to all components
|
|
1580
|
+
*
|
|
1581
|
+
* Affects only components rendered after function call
|
|
1582
|
+
*/
|
|
1583
|
+
function appendCustomStyle(style) {
|
|
1584
|
+
customStyle = style;
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Add/update style node
|
|
1588
|
+
*/
|
|
1589
|
+
function updateStyle(parent, inline) {
|
|
1590
|
+
// Get node, create if needed
|
|
1591
|
+
let styleNode = Array.from(parent.childNodes).find((node) => node.hasAttribute &&
|
|
1592
|
+
node.hasAttribute(nodeAttr));
|
|
1593
|
+
if (!styleNode) {
|
|
1594
|
+
styleNode = document.createElement('style');
|
|
1595
|
+
styleNode.setAttribute(nodeAttr, nodeAttr);
|
|
1596
|
+
parent.appendChild(styleNode);
|
|
1597
|
+
}
|
|
1598
|
+
// Update content
|
|
1599
|
+
styleNode.textContent =
|
|
1600
|
+
':host{display:inline-block;vertical-align:' +
|
|
1601
|
+
(inline ? '-0.125em' : '0') +
|
|
1602
|
+
'}span,svg{display:block;margin:auto}' +
|
|
1603
|
+
customStyle;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
// Core
|
|
1607
|
+
/**
|
|
1608
|
+
* Get functions and initialise stuff
|
|
1609
|
+
*/
|
|
1610
|
+
function exportFunctions() {
|
|
1611
|
+
/**
|
|
1612
|
+
* Initialise stuff
|
|
1613
|
+
*/
|
|
1614
|
+
// Set API module
|
|
1615
|
+
setAPIModule('', fetchAPIModule);
|
|
1616
|
+
// Allow simple icon names
|
|
1617
|
+
allowSimpleNames(true);
|
|
1618
|
+
let _window;
|
|
1619
|
+
try {
|
|
1620
|
+
_window = window;
|
|
1621
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1622
|
+
}
|
|
1623
|
+
catch (err) {
|
|
1624
|
+
//
|
|
1625
|
+
}
|
|
1626
|
+
if (_window) {
|
|
1627
|
+
// Load icons from global "IconifyPreload"
|
|
1628
|
+
if (_window.IconifyPreload !== void 0) {
|
|
1629
|
+
const preload = _window.IconifyPreload;
|
|
1630
|
+
const err = 'Invalid IconifyPreload syntax.';
|
|
1631
|
+
if (typeof preload === 'object' && preload !== null) {
|
|
1632
|
+
(preload instanceof Array ? preload : [preload]).forEach((item) => {
|
|
1633
|
+
try {
|
|
1634
|
+
if (
|
|
1635
|
+
// Check if item is an object and not null/array
|
|
1636
|
+
typeof item !== 'object' ||
|
|
1637
|
+
item === null ||
|
|
1638
|
+
item instanceof Array ||
|
|
1639
|
+
// Check for 'icons' and 'prefix'
|
|
1640
|
+
typeof item.icons !== 'object' ||
|
|
1641
|
+
typeof item.prefix !== 'string' ||
|
|
1642
|
+
// Add icon set
|
|
1643
|
+
!addCollection$1(item)) {
|
|
1644
|
+
console.error(err);
|
|
1645
|
+
}
|
|
1646
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1647
|
+
}
|
|
1648
|
+
catch (e) {
|
|
1649
|
+
console.error(err);
|
|
1650
|
+
}
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
// Set API from global "IconifyProviders"
|
|
1655
|
+
if (_window.IconifyProviders !== void 0) {
|
|
1656
|
+
const providers = _window.IconifyProviders;
|
|
1657
|
+
if (typeof providers === 'object' && providers !== null) {
|
|
1658
|
+
for (const key in providers) {
|
|
1659
|
+
const err = 'IconifyProviders[' + key + '] is invalid.';
|
|
1660
|
+
try {
|
|
1661
|
+
const value = providers[key];
|
|
1662
|
+
if (typeof value !== 'object' ||
|
|
1663
|
+
!value ||
|
|
1664
|
+
value.resources === void 0) {
|
|
1665
|
+
continue;
|
|
1666
|
+
}
|
|
1667
|
+
if (!addAPIProvider$1(key, value)) {
|
|
1668
|
+
console.error(err);
|
|
1669
|
+
}
|
|
1670
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1671
|
+
}
|
|
1672
|
+
catch (e) {
|
|
1673
|
+
console.error(err);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
const _api = {
|
|
1680
|
+
getAPIConfig,
|
|
1681
|
+
setAPIModule,
|
|
1682
|
+
sendAPIQuery,
|
|
1683
|
+
setFetch,
|
|
1684
|
+
getFetch,
|
|
1685
|
+
listAPIProviders,
|
|
1686
|
+
};
|
|
1687
|
+
return {
|
|
1688
|
+
iconLoaded: iconLoaded$1,
|
|
1689
|
+
getIcon: getIcon$1,
|
|
1690
|
+
listIcons: listIcons$1,
|
|
1691
|
+
addIcon: addIcon$1,
|
|
1692
|
+
addCollection: addCollection$1,
|
|
1693
|
+
calculateSize: calculateSize$1,
|
|
1694
|
+
buildIcon: iconToSVG,
|
|
1695
|
+
iconToHTML: iconToHTML$1,
|
|
1696
|
+
svgToURL: svgToURL$1,
|
|
1697
|
+
loadIcons: loadIcons$1,
|
|
1698
|
+
loadIcon: loadIcon$1,
|
|
1699
|
+
addAPIProvider: addAPIProvider$1,
|
|
1700
|
+
setCustomIconLoader: setCustomIconLoader$1,
|
|
1701
|
+
setCustomIconsLoader: setCustomIconsLoader$1,
|
|
1702
|
+
appendCustomStyle,
|
|
1703
|
+
_api,
|
|
1704
|
+
};
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
// List of properties to apply
|
|
1708
|
+
const monotoneProps = {
|
|
1709
|
+
'background-color': 'currentColor',
|
|
1710
|
+
};
|
|
1711
|
+
const coloredProps = {
|
|
1712
|
+
'background-color': 'transparent',
|
|
1713
|
+
};
|
|
1714
|
+
// Dynamically add common props to variables above
|
|
1715
|
+
const propsToAdd = {
|
|
1716
|
+
image: 'var(--svg)',
|
|
1717
|
+
repeat: 'no-repeat',
|
|
1718
|
+
size: '100% 100%',
|
|
1719
|
+
};
|
|
1720
|
+
const propsToAddTo = {
|
|
1721
|
+
'-webkit-mask': monotoneProps,
|
|
1722
|
+
'mask': monotoneProps,
|
|
1723
|
+
'background': coloredProps,
|
|
1724
|
+
};
|
|
1725
|
+
for (const prefix in propsToAddTo) {
|
|
1726
|
+
const list = propsToAddTo[prefix];
|
|
1727
|
+
for (const prop in propsToAdd) {
|
|
1728
|
+
list[prefix + '-' + prop] = propsToAdd[prop];
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
/**
|
|
1732
|
+
* Fix size: add 'px' to numbers
|
|
1733
|
+
*/
|
|
1734
|
+
function fixSize(value) {
|
|
1735
|
+
return value ? value + (value.match(/^[-0-9.]+$/) ? 'px' : '') : 'inherit';
|
|
1736
|
+
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Render node as <span>
|
|
1739
|
+
*/
|
|
1740
|
+
function renderSPAN(data, icon, useMask) {
|
|
1741
|
+
const node = document.createElement('span');
|
|
1742
|
+
// Body
|
|
1743
|
+
let body = data.body;
|
|
1744
|
+
if (body.indexOf('<a') !== -1) {
|
|
1745
|
+
// Animated SVG: add something to fix timing bug
|
|
1746
|
+
body += '<!-- ' + Date.now() + ' -->';
|
|
1747
|
+
}
|
|
1748
|
+
// Generate SVG as URL
|
|
1749
|
+
const renderAttribs = data.attributes;
|
|
1750
|
+
const html = iconToHTML$1(body, {
|
|
1751
|
+
...renderAttribs,
|
|
1752
|
+
width: icon.width + '',
|
|
1753
|
+
height: icon.height + '',
|
|
1754
|
+
});
|
|
1755
|
+
const url = svgToURL$1(html);
|
|
1756
|
+
// Generate style
|
|
1757
|
+
const svgStyle = node.style;
|
|
1758
|
+
const styles = {
|
|
1759
|
+
'--svg': url,
|
|
1760
|
+
'width': fixSize(renderAttribs.width),
|
|
1761
|
+
'height': fixSize(renderAttribs.height),
|
|
1762
|
+
...(useMask ? monotoneProps : coloredProps),
|
|
1763
|
+
};
|
|
1764
|
+
// Apply style
|
|
1765
|
+
for (const prop in styles) {
|
|
1766
|
+
svgStyle.setProperty(prop, styles[prop]);
|
|
1767
|
+
}
|
|
1768
|
+
return node;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
let policy;
|
|
1772
|
+
/**
|
|
1773
|
+
* Attempt to create policy
|
|
1774
|
+
*/
|
|
1775
|
+
function createPolicy() {
|
|
1776
|
+
try {
|
|
1777
|
+
policy = window.trustedTypes.createPolicy("iconify", { createHTML: (s) => s });
|
|
1778
|
+
} catch (err) {
|
|
1779
|
+
policy = null;
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Clean up value for innerHTML assignment
|
|
1784
|
+
*
|
|
1785
|
+
* This code doesn't actually clean up anything.
|
|
1786
|
+
* It is intended be used with Iconify icon data, which has already been validated
|
|
1787
|
+
*/
|
|
1788
|
+
function cleanUpInnerHTML(html) {
|
|
1789
|
+
if (policy === void 0) createPolicy();
|
|
1790
|
+
return policy ? policy.createHTML(html) : html;
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
/**
|
|
1794
|
+
* Render node as <svg>
|
|
1795
|
+
*/
|
|
1796
|
+
function renderSVG(data) {
|
|
1797
|
+
const node = document.createElement('span');
|
|
1798
|
+
// Add style if needed
|
|
1799
|
+
const attr = data.attributes;
|
|
1800
|
+
let style = '';
|
|
1801
|
+
if (!attr.width) {
|
|
1802
|
+
style = 'width: inherit;';
|
|
1803
|
+
}
|
|
1804
|
+
if (!attr.height) {
|
|
1805
|
+
style += 'height: inherit;';
|
|
1806
|
+
}
|
|
1807
|
+
if (style) {
|
|
1808
|
+
attr.style = style;
|
|
1809
|
+
}
|
|
1810
|
+
// Generate SVG
|
|
1811
|
+
const html = iconToHTML$1(data.body, attr);
|
|
1812
|
+
node.innerHTML = cleanUpInnerHTML(html);
|
|
1813
|
+
return node.firstChild;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
/**
|
|
1817
|
+
* Find icon node
|
|
1818
|
+
*/
|
|
1819
|
+
function findIconElement(parent) {
|
|
1820
|
+
return Array.from(parent.childNodes).find((node) => {
|
|
1821
|
+
const tag = node.tagName &&
|
|
1822
|
+
node.tagName.toUpperCase();
|
|
1823
|
+
return tag === 'SPAN' || tag === 'SVG';
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
/**
|
|
1827
|
+
* Render icon
|
|
1828
|
+
*/
|
|
1829
|
+
function renderIcon(parent, state) {
|
|
1830
|
+
const iconData = state.icon.data;
|
|
1831
|
+
const customisations = state.customisations;
|
|
1832
|
+
// Render icon
|
|
1833
|
+
const renderData = iconToSVG(iconData, customisations);
|
|
1834
|
+
if (customisations.preserveAspectRatio) {
|
|
1835
|
+
renderData.attributes['preserveAspectRatio'] =
|
|
1836
|
+
customisations.preserveAspectRatio;
|
|
1837
|
+
}
|
|
1838
|
+
const mode = state.renderedMode;
|
|
1839
|
+
let node;
|
|
1840
|
+
switch (mode) {
|
|
1841
|
+
case 'svg':
|
|
1842
|
+
node = renderSVG(renderData);
|
|
1843
|
+
break;
|
|
1844
|
+
default:
|
|
1845
|
+
node = renderSPAN(renderData, {
|
|
1846
|
+
...defaultIconProps,
|
|
1847
|
+
...iconData,
|
|
1848
|
+
}, mode === 'mask');
|
|
1849
|
+
}
|
|
1850
|
+
// Set element
|
|
1851
|
+
const oldNode = findIconElement(parent);
|
|
1852
|
+
if (oldNode) {
|
|
1853
|
+
// Replace old element
|
|
1854
|
+
if (node.tagName === 'SPAN' && oldNode.tagName === node.tagName) {
|
|
1855
|
+
// Swap style instead of whole node
|
|
1856
|
+
oldNode.setAttribute('style', node.getAttribute('style'));
|
|
1857
|
+
}
|
|
1858
|
+
else {
|
|
1859
|
+
parent.replaceChild(node, oldNode);
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
else {
|
|
1863
|
+
// Add new element
|
|
1864
|
+
parent.appendChild(node);
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
/**
|
|
1869
|
+
* Set state to PendingState
|
|
1870
|
+
*/
|
|
1871
|
+
function setPendingState(icon, inline, lastState) {
|
|
1872
|
+
const lastRender = lastState &&
|
|
1873
|
+
(lastState.rendered
|
|
1874
|
+
? lastState
|
|
1875
|
+
: lastState.lastRender);
|
|
1876
|
+
return {
|
|
1877
|
+
rendered: false,
|
|
1878
|
+
inline,
|
|
1879
|
+
icon,
|
|
1880
|
+
lastRender,
|
|
1881
|
+
};
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
/**
|
|
1885
|
+
* Register 'iconify-icon' component, if it does not exist
|
|
1886
|
+
*/
|
|
1887
|
+
function defineIconifyIcon(name = 'iconify-icon') {
|
|
1888
|
+
// Check for custom elements registry and HTMLElement
|
|
1889
|
+
let customElements;
|
|
1890
|
+
let ParentClass;
|
|
1891
|
+
try {
|
|
1892
|
+
customElements = window.customElements;
|
|
1893
|
+
ParentClass = window.HTMLElement;
|
|
1894
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1895
|
+
}
|
|
1896
|
+
catch (err) {
|
|
1897
|
+
return;
|
|
1898
|
+
}
|
|
1899
|
+
// Make sure registry and HTMLElement exist
|
|
1900
|
+
if (!customElements || !ParentClass) {
|
|
1901
|
+
return;
|
|
1902
|
+
}
|
|
1903
|
+
// Check for duplicate
|
|
1904
|
+
const ConflictingClass = customElements.get(name);
|
|
1905
|
+
if (ConflictingClass) {
|
|
1906
|
+
return ConflictingClass;
|
|
1907
|
+
}
|
|
1908
|
+
// All attributes
|
|
1909
|
+
const attributes = [
|
|
1910
|
+
// Icon
|
|
1911
|
+
'icon',
|
|
1912
|
+
// Mode
|
|
1913
|
+
'mode',
|
|
1914
|
+
'inline',
|
|
1915
|
+
'noobserver',
|
|
1916
|
+
// Customisations
|
|
1917
|
+
'width',
|
|
1918
|
+
'height',
|
|
1919
|
+
'rotate',
|
|
1920
|
+
'flip',
|
|
1921
|
+
];
|
|
1922
|
+
/**
|
|
1923
|
+
* Component class
|
|
1924
|
+
*/
|
|
1925
|
+
const IconifyIcon = class extends ParentClass {
|
|
1926
|
+
// Root
|
|
1927
|
+
_shadowRoot;
|
|
1928
|
+
// Initialised
|
|
1929
|
+
_initialised = false;
|
|
1930
|
+
// Icon state
|
|
1931
|
+
_state;
|
|
1932
|
+
// Attributes check queued
|
|
1933
|
+
_checkQueued = false;
|
|
1934
|
+
// Connected
|
|
1935
|
+
_connected = false;
|
|
1936
|
+
// Observer
|
|
1937
|
+
_observer = null;
|
|
1938
|
+
_visible = true;
|
|
1939
|
+
/**
|
|
1940
|
+
* Constructor
|
|
1941
|
+
*/
|
|
1942
|
+
constructor() {
|
|
1943
|
+
super();
|
|
1944
|
+
// Attach shadow DOM
|
|
1945
|
+
const root = (this._shadowRoot = this.attachShadow({
|
|
1946
|
+
mode: 'open',
|
|
1947
|
+
}));
|
|
1948
|
+
// Add style
|
|
1949
|
+
const inline = this.hasAttribute('inline');
|
|
1950
|
+
updateStyle(root, inline);
|
|
1951
|
+
// Create empty state
|
|
1952
|
+
this._state = setPendingState({
|
|
1953
|
+
value: '',
|
|
1954
|
+
}, inline);
|
|
1955
|
+
// Queue icon render
|
|
1956
|
+
this._queueCheck();
|
|
1957
|
+
}
|
|
1958
|
+
/**
|
|
1959
|
+
* Connected to DOM
|
|
1960
|
+
*/
|
|
1961
|
+
connectedCallback() {
|
|
1962
|
+
this._connected = true;
|
|
1963
|
+
this.startObserver();
|
|
1964
|
+
}
|
|
1965
|
+
/**
|
|
1966
|
+
* Disconnected from DOM
|
|
1967
|
+
*/
|
|
1968
|
+
disconnectedCallback() {
|
|
1969
|
+
this._connected = false;
|
|
1970
|
+
this.stopObserver();
|
|
1971
|
+
}
|
|
1972
|
+
/**
|
|
1973
|
+
* Observed attributes
|
|
1974
|
+
*/
|
|
1975
|
+
static get observedAttributes() {
|
|
1976
|
+
return attributes.slice(0);
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
* Observed properties that are different from attributes
|
|
1980
|
+
*
|
|
1981
|
+
* Experimental! Need to test with various frameworks that support it
|
|
1982
|
+
*/
|
|
1983
|
+
/*
|
|
1984
|
+
static get properties() {
|
|
1985
|
+
return {
|
|
1986
|
+
inline: {
|
|
1987
|
+
type: Boolean,
|
|
1988
|
+
reflect: true,
|
|
1989
|
+
},
|
|
1990
|
+
// Not listing other attributes because they are strings or combination
|
|
1991
|
+
// of string and another type. Cannot have multiple types
|
|
1992
|
+
};
|
|
1993
|
+
}
|
|
1994
|
+
*/
|
|
1995
|
+
/**
|
|
1996
|
+
* Attribute has changed
|
|
1997
|
+
*/
|
|
1998
|
+
attributeChangedCallback(name) {
|
|
1999
|
+
switch (name) {
|
|
2000
|
+
case 'inline': {
|
|
2001
|
+
// Update immediately: not affected by other attributes
|
|
2002
|
+
const newInline = this.hasAttribute('inline');
|
|
2003
|
+
const state = this._state;
|
|
2004
|
+
if (newInline !== state.inline) {
|
|
2005
|
+
// Update style if inline mode changed
|
|
2006
|
+
state.inline = newInline;
|
|
2007
|
+
updateStyle(this._shadowRoot, newInline);
|
|
2008
|
+
}
|
|
2009
|
+
break;
|
|
2010
|
+
}
|
|
2011
|
+
case 'noobserver': {
|
|
2012
|
+
const value = this.hasAttribute('noobserver');
|
|
2013
|
+
if (value) {
|
|
2014
|
+
this.startObserver();
|
|
2015
|
+
}
|
|
2016
|
+
else {
|
|
2017
|
+
this.stopObserver();
|
|
2018
|
+
}
|
|
2019
|
+
break;
|
|
2020
|
+
}
|
|
2021
|
+
default:
|
|
2022
|
+
// Queue check for other attributes
|
|
2023
|
+
this._queueCheck();
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
/**
|
|
2027
|
+
* Get/set icon
|
|
2028
|
+
*/
|
|
2029
|
+
get icon() {
|
|
2030
|
+
const value = this.getAttribute('icon');
|
|
2031
|
+
if (value && value.slice(0, 1) === '{') {
|
|
2032
|
+
try {
|
|
2033
|
+
return JSON.parse(value);
|
|
2034
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2035
|
+
}
|
|
2036
|
+
catch (err) {
|
|
2037
|
+
//
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
return value;
|
|
2041
|
+
}
|
|
2042
|
+
set icon(value) {
|
|
2043
|
+
if (typeof value === 'object') {
|
|
2044
|
+
value = JSON.stringify(value);
|
|
2045
|
+
}
|
|
2046
|
+
this.setAttribute('icon', value);
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
2049
|
+
* Get/set inline
|
|
2050
|
+
*/
|
|
2051
|
+
get inline() {
|
|
2052
|
+
return this.hasAttribute('inline');
|
|
2053
|
+
}
|
|
2054
|
+
set inline(value) {
|
|
2055
|
+
if (value) {
|
|
2056
|
+
this.setAttribute('inline', 'true');
|
|
2057
|
+
}
|
|
2058
|
+
else {
|
|
2059
|
+
this.removeAttribute('inline');
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
/**
|
|
2063
|
+
* Get/set observer
|
|
2064
|
+
*/
|
|
2065
|
+
get observer() {
|
|
2066
|
+
return this.hasAttribute('observer');
|
|
2067
|
+
}
|
|
2068
|
+
set observer(value) {
|
|
2069
|
+
if (value) {
|
|
2070
|
+
this.setAttribute('observer', 'true');
|
|
2071
|
+
}
|
|
2072
|
+
else {
|
|
2073
|
+
this.removeAttribute('observer');
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
/**
|
|
2077
|
+
* Restart animation
|
|
2078
|
+
*/
|
|
2079
|
+
restartAnimation() {
|
|
2080
|
+
const state = this._state;
|
|
2081
|
+
if (state.rendered) {
|
|
2082
|
+
const root = this._shadowRoot;
|
|
2083
|
+
if (state.renderedMode === 'svg') {
|
|
2084
|
+
// Update root node
|
|
2085
|
+
try {
|
|
2086
|
+
root.lastChild.setCurrentTime(0);
|
|
2087
|
+
return;
|
|
2088
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2089
|
+
}
|
|
2090
|
+
catch (err) {
|
|
2091
|
+
// Failed: setCurrentTime() is not supported
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
renderIcon(root, state);
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
/**
|
|
2098
|
+
* Get status
|
|
2099
|
+
*/
|
|
2100
|
+
get status() {
|
|
2101
|
+
const state = this._state;
|
|
2102
|
+
return state.rendered
|
|
2103
|
+
? 'rendered'
|
|
2104
|
+
: state.icon.data === null
|
|
2105
|
+
? 'failed'
|
|
2106
|
+
: 'loading';
|
|
2107
|
+
}
|
|
2108
|
+
/**
|
|
2109
|
+
* Queue attributes re-check
|
|
2110
|
+
*/
|
|
2111
|
+
_queueCheck() {
|
|
2112
|
+
if (!this._checkQueued) {
|
|
2113
|
+
this._checkQueued = true;
|
|
2114
|
+
setTimeout(() => {
|
|
2115
|
+
this._check();
|
|
2116
|
+
});
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
/**
|
|
2120
|
+
* Check for changes
|
|
2121
|
+
*/
|
|
2122
|
+
_check() {
|
|
2123
|
+
if (!this._checkQueued) {
|
|
2124
|
+
return;
|
|
2125
|
+
}
|
|
2126
|
+
this._checkQueued = false;
|
|
2127
|
+
const state = this._state;
|
|
2128
|
+
// Get icon
|
|
2129
|
+
const newIcon = this.getAttribute('icon');
|
|
2130
|
+
if (newIcon !== state.icon.value) {
|
|
2131
|
+
this._iconChanged(newIcon);
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
// Ignore other attributes if icon is not rendered
|
|
2135
|
+
if (!state.rendered || !this._visible) {
|
|
2136
|
+
return;
|
|
2137
|
+
}
|
|
2138
|
+
// Check for mode and attribute changes
|
|
2139
|
+
const mode = this.getAttribute('mode');
|
|
2140
|
+
const customisations = getCustomisations(this);
|
|
2141
|
+
if (state.attrMode !== mode ||
|
|
2142
|
+
haveCustomisationsChanged(state.customisations, customisations) ||
|
|
2143
|
+
!findIconElement(this._shadowRoot)) {
|
|
2144
|
+
this._renderIcon(state.icon, customisations, mode);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
/**
|
|
2148
|
+
* Icon value has changed
|
|
2149
|
+
*/
|
|
2150
|
+
_iconChanged(newValue) {
|
|
2151
|
+
const icon = parseIconValue(newValue, (value, name, data) => {
|
|
2152
|
+
// Asynchronous callback: re-check values to make sure stuff wasn't changed
|
|
2153
|
+
const state = this._state;
|
|
2154
|
+
if (state.rendered || this.getAttribute('icon') !== value) {
|
|
2155
|
+
// Icon data is already available or icon attribute was changed
|
|
2156
|
+
return;
|
|
2157
|
+
}
|
|
2158
|
+
// Change icon
|
|
2159
|
+
const icon = {
|
|
2160
|
+
value,
|
|
2161
|
+
name,
|
|
2162
|
+
data,
|
|
2163
|
+
};
|
|
2164
|
+
if (icon.data) {
|
|
2165
|
+
// Render icon
|
|
2166
|
+
this._gotIconData(icon);
|
|
2167
|
+
}
|
|
2168
|
+
else {
|
|
2169
|
+
// Nothing to render: update icon in state
|
|
2170
|
+
state.icon = icon;
|
|
2171
|
+
}
|
|
2172
|
+
});
|
|
2173
|
+
if (icon.data) {
|
|
2174
|
+
// Icon is ready to render
|
|
2175
|
+
this._gotIconData(icon);
|
|
2176
|
+
}
|
|
2177
|
+
else {
|
|
2178
|
+
// Pending icon
|
|
2179
|
+
this._state = setPendingState(icon, this._state.inline, this._state);
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
/**
|
|
2183
|
+
* Force render icon on state change
|
|
2184
|
+
*/
|
|
2185
|
+
_forceRender() {
|
|
2186
|
+
if (!this._visible) {
|
|
2187
|
+
// Remove icon
|
|
2188
|
+
const node = findIconElement(this._shadowRoot);
|
|
2189
|
+
if (node) {
|
|
2190
|
+
this._shadowRoot.removeChild(node);
|
|
2191
|
+
}
|
|
2192
|
+
return;
|
|
2193
|
+
}
|
|
2194
|
+
// Re-render icon
|
|
2195
|
+
this._queueCheck();
|
|
2196
|
+
}
|
|
2197
|
+
/**
|
|
2198
|
+
* Got new icon data, icon is ready to (re)render
|
|
2199
|
+
*/
|
|
2200
|
+
_gotIconData(icon) {
|
|
2201
|
+
this._checkQueued = false;
|
|
2202
|
+
this._renderIcon(icon, getCustomisations(this), this.getAttribute('mode'));
|
|
2203
|
+
}
|
|
2204
|
+
/**
|
|
2205
|
+
* Re-render based on icon data
|
|
2206
|
+
*/
|
|
2207
|
+
_renderIcon(icon, customisations, attrMode) {
|
|
2208
|
+
// Get mode
|
|
2209
|
+
const renderedMode = getRenderMode(icon.data.body, attrMode);
|
|
2210
|
+
// Inline was not changed
|
|
2211
|
+
const inline = this._state.inline;
|
|
2212
|
+
// Set state and render
|
|
2213
|
+
renderIcon(this._shadowRoot, (this._state = {
|
|
2214
|
+
rendered: true,
|
|
2215
|
+
icon,
|
|
2216
|
+
inline,
|
|
2217
|
+
customisations,
|
|
2218
|
+
attrMode,
|
|
2219
|
+
renderedMode,
|
|
2220
|
+
}));
|
|
2221
|
+
}
|
|
2222
|
+
/**
|
|
2223
|
+
* Start observer
|
|
2224
|
+
*/
|
|
2225
|
+
startObserver() {
|
|
2226
|
+
if (!this._observer && !this.hasAttribute('noobserver')) {
|
|
2227
|
+
try {
|
|
2228
|
+
this._observer = new IntersectionObserver((entries) => {
|
|
2229
|
+
const intersecting = entries.some((entry) => entry.isIntersecting);
|
|
2230
|
+
if (intersecting !== this._visible) {
|
|
2231
|
+
this._visible = intersecting;
|
|
2232
|
+
this._forceRender();
|
|
2233
|
+
}
|
|
2234
|
+
});
|
|
2235
|
+
this._observer.observe(this);
|
|
2236
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2237
|
+
}
|
|
2238
|
+
catch (err) {
|
|
2239
|
+
// Something went wrong, possibly observer is not supported
|
|
2240
|
+
if (this._observer) {
|
|
2241
|
+
try {
|
|
2242
|
+
this._observer.disconnect();
|
|
2243
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2244
|
+
}
|
|
2245
|
+
catch (err) {
|
|
2246
|
+
//
|
|
2247
|
+
}
|
|
2248
|
+
this._observer = null;
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
/**
|
|
2254
|
+
* Stop observer
|
|
2255
|
+
*/
|
|
2256
|
+
stopObserver() {
|
|
2257
|
+
if (this._observer) {
|
|
2258
|
+
this._observer.disconnect();
|
|
2259
|
+
this._observer = null;
|
|
2260
|
+
this._visible = true;
|
|
2261
|
+
if (this._connected) {
|
|
2262
|
+
// Render icon
|
|
2263
|
+
this._forceRender();
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
};
|
|
2268
|
+
// Add getters and setters
|
|
2269
|
+
attributes.forEach((attr) => {
|
|
2270
|
+
if (!(attr in IconifyIcon.prototype)) {
|
|
2271
|
+
Object.defineProperty(IconifyIcon.prototype, attr, {
|
|
2272
|
+
get: function () {
|
|
2273
|
+
return this.getAttribute(attr);
|
|
2274
|
+
},
|
|
2275
|
+
set: function (value) {
|
|
2276
|
+
if (value !== null) {
|
|
2277
|
+
this.setAttribute(attr, value);
|
|
2278
|
+
}
|
|
2279
|
+
else {
|
|
2280
|
+
this.removeAttribute(attr);
|
|
2281
|
+
}
|
|
2282
|
+
},
|
|
2283
|
+
});
|
|
2284
|
+
}
|
|
2285
|
+
});
|
|
2286
|
+
// Add exported functions: both as static and instance methods
|
|
2287
|
+
const functions = exportFunctions();
|
|
2288
|
+
for (const key in functions) {
|
|
2289
|
+
IconifyIcon[key] = IconifyIcon.prototype[key] = functions[key];
|
|
2290
|
+
}
|
|
2291
|
+
// Define new component
|
|
2292
|
+
customElements.define(name, IconifyIcon);
|
|
2293
|
+
return IconifyIcon;
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
/**
|
|
2297
|
+
* Create exported data: either component instance or functions
|
|
2298
|
+
*/
|
|
2299
|
+
const IconifyIconComponent = defineIconifyIcon() || exportFunctions();
|
|
2300
|
+
/**
|
|
2301
|
+
* Export functions
|
|
2302
|
+
*/
|
|
2303
|
+
const { addIcon} = IconifyIconComponent;
|
|
2304
|
+
|
|
2305
|
+
exports.IconifyIconComponent = IconifyIconComponent;
|
|
2306
|
+
exports.addIcon = addIcon;
|
|
2307
|
+
exports.appendCustomStyle = appendCustomStyle;
|