Release 1.0.0-alpha1

This commit is contained in:
unknown 2020-12-30 15:22:44 +01:00
parent 173971edc0
commit 8ca578ca17
225 changed files with 8721 additions and 18122 deletions

Binary file not shown.

370
README.md
View File

@ -2,20 +2,15 @@
![MDB Logo](https://mdbootstrap.com/img/Marketing/general/logo/medium/mdb-r.png)
# MDB 5
# MDB 5 Alpha
### Bootstrap 5 & Material Design 2.0 UI KIT
**[>> Get Started in 3 steps](https://mdbootstrap.com/docs/standard/getting-started/installation/)**
**[>> Get Started](https://mdbootstrap.com/docs/standard/getting-started/installation/)**
**[>> Get Started with Webpack](https://github.com/mdbootstrap/mdb-webpack-starter)**
**[>> Demo](https://mdbootstrap.com/docs/standard/#demo)**
**[>> MDB 5 Demo](https://mdbootstrap.com/docs/standard/#demo)**
<a href="https://npmcharts.com/compare/mdbootstrap?minimal=true"> <img src="https://img.shields.io/npm/dm/mdbootstrap.svg?label=MDB%20Downloads" alt="Downloads"></a>
<a href="https://github.com/mdbootstrap/bootstrap-material-design/blob/master/License.pdf"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
<a href="https://twitter.com/intent/tweet/?text=Thanks+@mdbootstrap+for+creating+amazing+and+free+Material+Design+for+Bootstrap+4+UI+KIT%20https://mdbootstrap.com/docs/jquery/&hashtags=javascript,code,webdesign,bootstrap"><img src="https://img.shields.io/twitter/url/http/shields.io.svg?style=social&label=Let%20us%20know%20you%20were%20here%21&"></a>
<a href="https://www.youtube.com/watch?v=c9B4TPnak1A&t=6s"><img alt="YouTube Video Views" src="https://img.shields.io/youtube/views/c9B4TPnak1A?label=Bootstrap%205%20Tutorial%20Views&style=social"></a>
<a href="https://npmcharts.com/compare/mdbootstrap?minimal=true"> <img src="https://img.shields.io/npm/dm/mdbootstrap.svg" alt="Downloads"></a><a href="https://github.com/mdbootstrap/bootstrap-material-design/blob/master/License.pdf"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a> <a href="https://cdnjs.com/libraries/mdbootstrap"> <img src="https://img.shields.io/cdnjs/v/mdbootstrap.svg" alt="cdnjs"></a> <a href="https://badge.fury.io/js/mdbootstrap"><img src="https://badge.fury.io/js/mdbootstrap.svg" alt="npm"></a> <a href="https://twitter.com/intent/tweet/?text=Thanks+@mdbootstrap+for+creating+amazing+and+free+Material+Design+for+Bootstrap+4+UI+KIT%20https://mdbootstrap.com/docs/jquery/&hashtags=javascript,code,webdesign,bootstrap"> <img src="https://img.shields.io/twitter/url/http/shields.io.svg?style=social"></a>
___
<table>
@ -23,7 +18,7 @@ ___
<tr>
<td>
<a href="https://mdbootstrap.com/docs/standard/" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/about/assets/mdb5-about.jpg">
<img src="https://z9t4u9f6.stackpathcdn.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/about/assets/mdb5-about.jpg">
</a>
</td>
<td>
@ -92,356 +87,11 @@ ___
___
# Demo
#### Simplicity and ease of use are key features of MDB 5 UI Kit. You need only one minute to install and run it.
### Demo
###### Simplicity and ease of use are key features of MDB 5 UI Kit. You need only one minute to install and run it.
### Carousel
<a href="https://mdbootstrap.com/docs/standard/" alt="Bootstrap 5" rel="dofollow"><img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-loaders1.gif"></a>
<p>A slideshow component for cycling through elements—images or slides of text—like a carousel.</p>
<a href="https://mdbootstrap.com/docs/standard/" alt="Bootstrap 5" rel="dofollow"><img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-loaders2.gif"></a>
<a href="https://mdbootstrap.com/docs/standard/components/carousel/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-carousel.gif">
</p>
</a>
### Buttons
<p>Use MDB custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.</p>
<a href="https://mdbootstrap.com/docs/standard/components/buttons/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-buttons.gif">
</p>
</a>
<a href="https://mdbootstrap.com/docs/standard/components/buttons/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-social-buttons.png">
</p>
</a>
<a href="https://mdbootstrap.com/docs/standard/components/buttons/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-buttons2.png">
</p>
</a>
<a href="https://mdbootstrap.com/docs/standard/components/buttons/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-buttons-outline.gif">
</p>
</a>
### Spinners
<p>Indicate the loading state of a component or page with MDB spinners, built entirely with HTML, CSS, and no JavaScript.</p>
<a href="https://mdbootstrap.com/docs/standard/components/spinners/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-loader.gif">
</p>
</a>
<a href="https://mdbootstrap.com/docs/standard/components/spinners/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-color-spinners.gif">
</p>
</a>
### Cards
<p>A card is a flexible and extensible content container. It includes options for headers and footers, a wide variety of content, contextual background colors, and powerful display options.</p>
<a href="https://mdbootstrap.com/docs/standard/components/cards/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-cards.png">
</p>
</a>
### Validation
<p>Provide valuable, actionable feedback to your users with HTML5 form validation, via browser default behaviors or custom styles and JavaScript.</p>
<a href="https://mdbootstrap.com/docs/standard/forms/validation/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-validation.gif">
</p>
</a>
<a href="https://mdbootstrap.com/docs/standard/forms/validation/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-validation2.gif">
</p>
</a>
<a href="https://mdbootstrap.com/docs/standard/forms/validation/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-validation3.gif">
</p>
</a>
### Forms
<p>Examples and usage guidelines for form control styles, layout options, and custom components for creating a wide variety of forms.</p>
<a href="https://mdbootstrap.com/docs/standard/forms/overview/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-forms2.gif">
</p>
</a>
<a href="https://mdbootstrap.com/docs/standard/forms/overview/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-forms3.gif">
</p>
</a>
### Footer
<p>A footer is an additional navigation component. It can hold links, buttons, company info, copyrights, forms, and many other elements.</p>
<a href="https://mdbootstrap.com/docs/standard/navigation/footer/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-footer.png">
</p>
</a>
### Modal
<p>Use MDB modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.</p>
<a href="https://mdbootstrap.com/docs/standard/components/modal/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-modal.gif">
</p>
</a>
### Hover
<p>MDB hover effect appears when the user positions the computer cursor over an element without activating it. Hover effects make a website more interactive.</p>
<a href="https://mdbootstrap.com/docs/standard/content-styles/hover-effects/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-hover.gif">
</p>
</a>
<a href="https://mdbootstrap.com/docs/standard/content-styles/hover-effects/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-hover2.png">
</p>
</a>
### Tabs
<p>Tabs are quasi-navigation components which can highly improve website clarity and increase user experience.</p>
<a href="https://mdbootstrap.com/docs/standard/navigation/tabs/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-tabs.gif">
</p>
</a>
<a href="https://mdbootstrap.com/docs/standard/navigation/tabs/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-tabs2.gif">
</p>
</a>
### Notes
<p>Notes are small components very helpful in inserting an additional piece of information.</p>
<a href="https://mdbootstrap.com/docs/standard/content-styles/typography/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-alerts.png">
</p>
</a>
### ScrollSpy
<p>Automatically update Bootstrap navigation or list group components based on scroll position to indicate which link is currently active in the viewport.</p>
<a href="https://mdbootstrap.com/docs/standard/navigation/scrollspy/" alt="Bootstrap 5" rel="dofollow">
<p align="center">
<img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-scrollspy.gif">
</p>
</a>
-----------------------------
# MDB 5 Templates
<p>All the templates were created with MDB 5 UI KIT (Material Design for Bootstrap 5).</p>
<p>MDB is a free (MIT license) library, that provides extra features and significantly extends Bootstrap's capabilities.</p>
<table>
<tbody>
<tr>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/ecommerce.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/ecommerce.jpg">
</a>
<p align="center"><b>Ecommerce</b></p>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/full-carousel-cover.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/full-carousel-cover.jpg">
</a>
<p align="center"><b>Carousel Full Cover</b></p>
</tr>
</tbody>
<tbody>
<tr>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/full-image-cover.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/full-image-cover.jpg">
</a>
<p align="center"><b>Image Full Cover</b></p>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/portfolio.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/portfolio.jpg">
</a>
<p align="center"><b>Portfolio</b></p>
</tr>
</tbody>
<tbody>
<tr>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/post.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/post.jpg">
</a>
<p align="center"><b>Post</b></p>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/pricing.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/pricing.jpg">
</a>
<p align="center"><b>Pricing</b></p>
</tr>
</tbody>
<tbody>
<tr>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/full-video-cover.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/full-video-cover.jpg">
</a>
<p align="center"><b>Video Full Cover</b></p>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/half-carousel-cover.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/half-carousel-cover.jpg">
</a>
<p align="center"><b>Carousel Half Cover</b></p>
</tr>
</tbody>
<tbody>
<tr>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/half-video-cover.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/half-video-cover.jpg">
</a>
<p align="center"><b>Video Half Cover</b></p>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/login.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/login.jpg">
</a>
<p align="center"><b>Login</b></p>
</tr>
</tbody>
<tbody>
<tr>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/magazine.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/magazine.jpg">
</a>
<p align="center"><b>Mgazine</b></p>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/checkout.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/checkout.jpg">
</a>
<p align="center"><b>Checkout</b></p>
</tr>
</tbody>
<tbody>
<tr>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/blog.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/blog.jpg">
<p align="center"><b>Blog</b></p>
</a>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/product.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/product.jpg">
</a>
<p align="center"><b>Product</b></p>
</tr>
</tbody>
<tbody>
<tr>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/category.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/category.jpg">
<p align="center"><b>Category</b></p>
</a>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/landing-page.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/landing-page.jpg">
</a>
<p align="center"><b>Landing Page</b></p>
</tr>
</tbody>
<tbody>
<tr>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/admin.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/admin.jpg">
</a>
<p align="center"><b>Admin</b></p>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/coming-soon.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/coming-soon.jpg">
</a>
<p align="center"><b>Coming Soon</b></p>
</tr>
</tbody>
<tbody>
<tr>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/classic-jumbotron.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/classic-jumbotron.jpg">
</a>
<p align="center"><b>Classic Jumbotron</b></p>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/one-column.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/one-column.jpg">
</a>
<p align="center"><b>One Column</b></p>
</tr>
</tbody>
<tbody>
<tr>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/two-columns.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/two-columns.jpg">
</a>
<p align="center"><b>Two Columns</b></p>
<td>
<a href="https://mdbgo.dev/ascensus/MDB5-templates/three-columns.html" alt="Bootstrap 5" rel="dofollow">
<img src="https://mdbootstrap.com/wp-content/themes/mdbootstrap4/content/en/_mdb5/standard/general/templates/assets/three-columns.jpg">
</a>
<p align="center"><b>Three Columns</b></p>
</tr>
</tbody>
</table>
<a href="https://mdbootstrap.com/docs/standard/" alt="Bootstrap 5" rel="dofollow"><img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-mdb5.jpg"></a>

View File

@ -1,5 +1,5 @@
MDB5
Version: FREE 3.0.0
Version: FREE 1.0.0-alpha1
Documentation:
https://mdbootstrap.com/docs/standard/

14
css/mdb.min.css vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

22
css/mdb.rtl.min.css vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -17,171 +17,17 @@
<!-- MDB -->
<link rel="stylesheet" href="css/mdb.min.css" />
<!-- Custom styles -->
<style>
body{
background-color: #f6e0a2;
}
.icon-color {
background-color:#94536d !important;
}
</style>
<style></style>
</head>
<body>
<!-- Start your project here-->
<div class="container">
<div class="d-flex justify-content-center align-items-center" style="height: 100vh;">
<div class="text-center">
<h1 class=" text-one" style="color: #6a8255 ;">CHRISTMAS SALE!</h1>
<!-- Image -->
<svg id="e1a9485c-0f43-4303-9e0d-5e4a75181bc4" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="558.07" height="404.61" viewBox="0 0 858.07 804.61">
<defs>
<linearGradient id="fa2440bd-da04-40b7-bd3b-ddfb35b0a42b" x1="592.9" y1="385.11" x2="592.9" y2="236.35"
gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="gray" stop-opacity="0.25" />
<stop offset="0.54" stop-color="gray" stop-opacity="0.12" />
<stop offset="1" stop-color="gray" stop-opacity="0.1" />
</linearGradient>
<linearGradient id="07fe1e9f-5680-428a-971a-ff84304916dd" x1="420.04" y1="804.61" x2="420.04" y2="320.21"
xlink:href="#fa2440bd-da04-40b7-bd3b-ddfb35b0a42b" />
<linearGradient id="00ef2338-96af-4b11-80f8-5a4c3164adbb" x1="811.83" y1="471.54" x2="811.83" y2="185.81"
xlink:href="#fa2440bd-da04-40b7-bd3b-ddfb35b0a42b" />
</defs>
<title>gift1</title>
<g opacity="0.5">
<rect x="107.3" y="37.85" width="3.33" height="18.87" fill="#47e6b1" />
<rect x="276.52" y="77.53" width="3.33" height="18.87" transform="translate(195.93 -230.9) rotate(90)"
fill="#47e6b1" />
</g>
<g opacity="0.5">
<rect x="811.66" y="769.53" width="3.33" height="18.87" fill="#47e6b1" />
<rect x="980.89" y="809.21" width="3.33" height="18.87" transform="translate(1631.97 -203.59) rotate(90)"
fill="#47e6b1" />
</g>
<g opacity="0.5">
<rect x="812.98" y="215.34" width="3.33" height="18.87" fill="#47e6b1" />
<rect x="982.2" y="255.02" width="3.33" height="18.87" transform="translate(1079.1 -759.09) rotate(90)"
fill="#47e6b1" />
</g>
<g opacity="0.5">
<rect x="846.98" y="45.34" width="3.33" height="18.87" fill="#47e6b1" />
<rect x="1016.2" y="85.02" width="3.33" height="18.87" transform="translate(943.1 -963.09) rotate(90)"
fill="#47e6b1" />
</g>
<g opacity="0.5">
<rect x="267.08" y="36.27" width="3.33" height="18.87" fill="#47e6b1" />
<rect x="436.31" y="75.96" width="3.33" height="18.87" transform="translate(354.13 -392.27) rotate(90)"
fill="#47e6b1" />
</g>
<path
d="M230.44,357.88a4.08,4.08,0,0,1-2.27-4.93,2,2,0,0,0,.09-.45h0a2,2,0,0,0-3.67-1.36h0a2,2,0,0,0-.23.4,4.08,4.08,0,0,1-4.93,2.27,2,2,0,0,0-.45-.09h0a2,2,0,0,0-1.36,3.67h0a2,2,0,0,0,.4.23,4.08,4.08,0,0,1,2.27,4.93,2,2,0,0,0-.09.45h0a2,2,0,0,0,3.67,1.36h0a2,2,0,0,0,.23-.4,4.08,4.08,0,0,1,4.93-2.27,2,2,0,0,0,.45.09h0a2,2,0,0,0,1.36-3.67h0A2,2,0,0,0,230.44,357.88Z"
transform="translate(-169.23 -39.68)" fill="#4d8af0" opacity="0.5" />
<path
d="M291.92,736.22a4.08,4.08,0,0,1-2.27-4.93,2,2,0,0,0,.09-.45h0a2,2,0,0,0-3.67-1.36h0a2,2,0,0,0-.23.4,4.08,4.08,0,0,1-4.93,2.27,2,2,0,0,0-.45-.09h0a2,2,0,0,0-1.36,3.67h0a2,2,0,0,0,.4.23,4.08,4.08,0,0,1,2.27,4.93,2,2,0,0,0-.09.45h0a2,2,0,0,0,3.67,1.36h0a2,2,0,0,0,.23-.4,4.08,4.08,0,0,1,4.93-2.27,2,2,0,0,0,.45.09h0a2,2,0,0,0,1.36-3.67h0A2,2,0,0,0,291.92,736.22Z"
transform="translate(-169.23 -39.68)" fill="#4d8af0" opacity="0.5" />
<path
d="M850.92,235.22a4.08,4.08,0,0,1-2.27-4.93,2,2,0,0,0,.09-.45h0a2,2,0,0,0-3.67-1.36h0a2,2,0,0,0-.23.4,4.08,4.08,0,0,1-4.93,2.27,2,2,0,0,0-.45-.09h0a2,2,0,0,0-1.36,3.67h0a2,2,0,0,0,.4.23,4.08,4.08,0,0,1,2.27,4.93,2,2,0,0,0-.09.45h0a2,2,0,0,0,3.67,1.36h0a2,2,0,0,0,.23-.4,4.08,4.08,0,0,1,4.93-2.27,2,2,0,0,0,.45.09h0a2,2,0,0,0,1.36-3.67h0A2,2,0,0,0,850.92,235.22Z"
transform="translate(-169.23 -39.68)" fill="#4d8af0" opacity="0.5" />
<path
d="M843.47,325.61a4.08,4.08,0,0,1-2.27-4.93,2,2,0,0,0,.09-.45h0a2,2,0,0,0-3.67-1.36h0a2,2,0,0,0-.23.4,4.08,4.08,0,0,1-4.93,2.27,2,2,0,0,0-.45-.09h0a2,2,0,0,0-1.36,3.67h0a2,2,0,0,0,.4.23,4.08,4.08,0,0,1,2.27,4.93,2,2,0,0,0-.09.45h0a2,2,0,0,0,3.67,1.36h0a2,2,0,0,0,.23-.4,4.08,4.08,0,0,1,4.93-2.27,2,2,0,0,0,.45.09h0a2,2,0,0,0,1.36-3.67h0A2,2,0,0,0,843.47,325.61Z"
transform="translate(-169.23 -39.68)" fill="#4d8af0" opacity="0.5" />
<path
d="M844,47.24a4.08,4.08,0,0,1-2.27-4.93,2,2,0,0,0,.09-.45h0a2,2,0,0,0-3.67-1.36h0a2,2,0,0,0-.23.4A4.08,4.08,0,0,1,833,43.18a2,2,0,0,0-.45-.09h0a2,2,0,0,0-1.36,3.67h0a2,2,0,0,0,.4.23,4.08,4.08,0,0,1,2.27,4.93,2,2,0,0,0-.09.45h0a2,2,0,0,0,3.67,1.36h0a2,2,0,0,0,.23-.4A4.08,4.08,0,0,1,842.56,51a2,2,0,0,0,.45.09h0a2,2,0,0,0,1.36-3.67h0A2,2,0,0,0,844,47.24Z"
transform="translate(-169.23 -39.68)" fill="#4d8af0" opacity="0.5" />
<path
d="M1012.16,504.28a4.08,4.08,0,0,1-2.27-4.93,2,2,0,0,0,.09-.45h0a2,2,0,0,0-3.67-1.36h0a2,2,0,0,0-.23.4,4.08,4.08,0,0,1-4.93,2.27,2,2,0,0,0-.45-.09h0a2,2,0,0,0-1.36,3.67h0a2,2,0,0,0,.4.23A4.08,4.08,0,0,1,1002,509a2,2,0,0,0-.09.45h0a2,2,0,0,0,3.67,1.36h0a2,2,0,0,0,.23-.4,4.08,4.08,0,0,1,4.93-2.27,2,2,0,0,0,.45.09h0a2,2,0,0,0,1.36-3.67h0A2,2,0,0,0,1012.16,504.28Z"
transform="translate(-169.23 -39.68)" fill="#4d8af0" opacity="0.5" />
<circle cx="61.77" cy="166.12" r="6.66" fill="#f55f44" opacity="0.5" />
<circle cx="12.94" cy="644.43" r="6.66" fill="#f55f44" opacity="0.5" />
<circle cx="439.66" cy="45.68" r="6.66" fill="#f55f44" opacity="0.5" />
<circle cx="506.66" cy="172.68" r="6.66" fill="#f55f44" opacity="0.5" />
<circle cx="6.66" cy="478.68" r="6.66" fill="#f55f44" opacity="0.5" />
<circle cx="267.5" cy="155.34" r="6.66" fill="#47e6b1" opacity="0.5" />
<circle cx="725.6" cy="597.75" r="6.66" fill="#f55f44" opacity="0.5" />
<g opacity="0.5">
<path
d="M713.77,253.75c-12.9-12.94-31.71-18.09-53-14.5-19.89,3.36-39.79,14.13-56,30.33a65.49,65.49,0,0,0-11.72,16.08A65.64,65.64,0,0,0,581.43,269h0c-16-16.47-35.67-27.58-55.5-31.29-21.19-4-40.08.86-53.2,13.58S454.18,282.74,457.48,304C460.56,324,471,344,487,360.49,520.58,395.13,587.59,381.6,590.43,381l.84-.17,2.58.59c2.83.64,69.59,15.32,103.75-18.73,16.25-16.19,27.08-36.06,30.51-55.94C731.76,285.52,726.67,266.69,713.77,253.75ZM579.08,361c-16.19,2.18-56.55,5.14-76.59-15.53-12.88-13.29-21.31-29.19-23.71-44.75-2.2-14.2,1-26.27,8.94-34a29.93,29.93,0,0,1,10.92-6.69c6.68-2.37,14.63-2.81,23.32-1.18,15.48,2.89,31.1,11.81,44,25.1C586,304.67,581.76,344.92,579.08,361Zm127.78-57.93c-2.67,15.52-11.37,31.26-24.48,44.33-20.4,20.33-60.7,16.67-76.84,14.21-2.41-16.16-5.94-56.47,14.45-76.8,13.11-13.07,28.88-21.71,44.41-24.34,8.72-1.47,16.66-.9,23.3,1.58a29.93,29.93,0,0,1,10.8,6.88C706.33,276.82,709.3,288.94,706.86,303.09Z"
transform="translate(-169.23 -39.68)" fill="url(#fa2440bd-da04-40b7-bd3b-ddfb35b0a42b)" />
</g>
<path
d="M596.91,376.65,590.53,378c-2.71.57-66.83,13.51-99-19.63-15.28-15.76-25.31-34.95-28.26-54-3.15-20.38,2-38.31,14.58-50.48s30.64-16.78,50.91-13c19,3.55,37.84,14.18,53.11,29.94h0c32.12,33.15,17.18,96.83,16.52,99.52ZM502.7,262.26a28.64,28.64,0,0,0-10.45,6.4c-7.62,7.38-10.66,18.93-8.56,32.52,2.3,14.89,10.36,30.1,22.69,42.82,19.17,19.78,57.79,17,73.28,14.86,2.57-15.41,6.61-53.93-12.56-73.71h0c-12.33-12.72-27.28-21.25-42.09-24C516.71,259.57,509.1,260,502.7,262.26Z"
transform="translate(-169.23 -39.68)" fill="#e85656" />
<path
d="M587.45,376.93,586,370.57c-.61-2.71-14.45-66.64,18.24-99.22h0c15.54-15.5,34.59-25.8,53.62-29,20.33-3.44,38.33,1.49,50.68,13.87s17.21,30.4,13.71,50.72c-3.28,19-13.65,38-29.19,53.53C660.39,393,596.51,379,593.8,378.38Zm96.17-112.75c-6.36-2.38-14-2.93-22.29-1.52-14.86,2.51-30,10.78-42.5,23.29h0c-19.51,19.45-16.14,58-13.83,73.49,15.45,2.35,54,5.86,73.53-13.6,12.55-12.51,20.87-27.57,23.43-42.42,2.34-13.55-.5-25.15-8-32.66A28.64,28.64,0,0,0,683.61,264.18Z"
transform="translate(-169.23 -39.68)" fill="#e85656" />
<g opacity="0.5">
<polygon
points="730.87 320.21 109.21 320.21 109.21 444.6 141.51 444.6 141.51 804.61 698.57 804.61 698.57 444.6 730.87 444.6 730.87 320.21"
fill="url(#07fe1e9f-5680-428a-971a-ff84304916dd)" />
</g>
<rect x="148.56" y="357.82" width="542.96" height="440.67" fill="#f5f5f5" />
<rect x="368.89" y="436.51" width="102.3" height="361.98" fill="#e85656" />
<rect x="148.56" y="334.21" width="542.96" height="110.17" opacity="0.1" />
<rect x="117.08" y="326.34" width="605.91" height="110.17" fill="#f5f5f5" />
<rect x="368.89" y="326.34" width="102.3" height="110.17" fill="#e85656" />
<path
d="M951.92,375.92C950,370.37,929,386,929,386l-4.84-.29-9.31-8.62,6.5-6.5-54.59-46.79a13.77,13.77,0,0,0-10.67-3.21l-45.37,5.67c-.19-2.6-1.8-5.69-4.06-8.84-4.65-7.63-14.45-16.26-18.08-19.33l-5.53-37.31,4.7-7.05a23.73,23.73,0,0,1-2.56-.86l1-1.49-.37-.1.47-.54-.06,0L798,237.16a5.14,5.14,0,0,0-.39-7.12l-26.21-19.88a14.45,14.45,0,0,0,1.12-6c.2-4-1.56-8-7.5-10.94a57.9,57.9,0,0,0-11.48-4.05,37.67,37.67,0,0,0-19.85.29l-.34-.4c-8.07-9.22-18.64,4-19.05,4.55l-41.34,46A8.4,8.4,0,0,0,675,250.81l21.88,16.41-.07.14,1.24.93c-.94,1.84-2.19,3.07-3.86,3.25l3.35,1.68a3.86,3.86,0,0,1-1.78.67l15.34,7.67c0,8,.82,44.47,13.79,62.39A33.13,33.13,0,0,0,729.6,350s1.1-.6,3.12-1.57l2.32,4.63a27.11,27.11,0,0,0,28.09,14.72l72-10.29-.76,2.29.41-.06-23.34,70,3.86,1.29-.07.14.54.23-4.85,9.17-15.28,11.75S840.3,474.69,845,471.16s-16.46-18.81-16.46-18.81l-1.18-4.7,5.14-10.85,4.31,1.44L871.42,369h0l1.18-2.35L896,395.94l6.6-6.6.71.72.06-.06,9.15,9.26,6.63,18.1S953.87,381.46,951.92,375.92ZM770.24,241.31l-.46-.53a43.89,43.89,0,0,1-13.23,10.58v-3.85l.26-.23v-1.67A25.4,25.4,0,0,0,764,219.82l15.19,11.69Zm-51.61-43.4-.37-.37.37.36Zm-12.15,24.48q-.15,1.82-.12,3.68a38.28,38.28,0,0,0,.3,5.37c.78,6.22,3,11.3,7.6,13.72,4,2.1,6.63,2,8.31.55l.18.16a18,18,0,0,0,1.86,7,74,74,0,0,1-24.17-9.73s0,.31.06.87l-6.29-6.29Z"
transform="translate(-169.23 -39.68)" fill="url(#00ef2338-96af-4b11-80f8-5a4c3164adbb)" />
<polygon points="651.99 378.3 641.71 397.71 657.69 404.56 667.97 382.87 651.99 378.3" fill="#fda57d" />
<path d="M826.92,444.24l1.14,4.57s20.55,14.84,16,18.27-48-18.27-48-18.27l14.84-11.42Z"
transform="translate(-169.23 -39.68)" fill="#333" />
<polygon points="666.87 384.88 650.71 379.49 645.9 388.57 661.88 395.43 666.87 384.88" opacity="0.1" />
<polygon points="725 341.94 740.43 357.56 751.76 344.37 734.15 328.06 725 341.94" fill="#fda57d" />
<polygon points="734.78 328.82 725.63 342.7 731.48 348.63 743.35 336.76 734.78 328.82" opacity="0.1" />
<path d="M921,384.05l4.7.28s20.32-15.15,22.22-9.77-31.8,40.27-31.8,40.27l-6.44-17.58Z"
transform="translate(-169.23 -39.68)" fill="#333" />
<path d="M774.66,267.22l23.72-27.44a5,5,0,0,0-.38-6.91l-51.61-39.14-6.28,9.78,40,30.79-17,18.62Z"
transform="translate(-169.23 -39.68)" fill="#fda57d" />
<path d="M771.94,243.31l-8.3,9.1,11.53,14.31L787.06,253A34.67,34.67,0,0,1,771.94,243.31Z"
transform="translate(-169.23 -39.68)" opacity="0.1" />
<path d="M705.78,273.18,678.93,253a8.16,8.16,0,0,1-2-10.87l40.18-44.71,8.22,8.22-27.75,34.64L714,256.75Z"
transform="translate(-169.23 -39.68)" fill="#fda57d" />
<path d="M700.12,269.13l4.39,3.3L712.73,256l-10.32-10.32C702.63,249.18,703.25,262.76,700.12,269.13Z"
transform="translate(-169.23 -39.68)" opacity="0.1" />
<polygon points="666.87 313.25 642.22 387.19 666.87 395.41 707.95 313.25 675.09 305.04 666.87 313.25"
fill="#4d8af0" />
<polygon
points="665.73 315.53 664.5 319.23 690.38 315.53 700.49 328.17 706.81 315.53 673.94 307.32 665.73 315.53"
opacity="0.1" />
<path d="M717.07,197.51s10.53-13.57,18.52-4.44S723,203.34,723,203.34Z" transform="translate(-169.23 -39.68)"
fill="#fda57d" />
<path
d="M729.29,336.5l7.94,15.89a26.34,26.34,0,0,0,27.28,14.29l96.23-13.75L893.61,394l24.65-24.65-53-45.45a13.37,13.37,0,0,0-10.36-3.12Z"
transform="translate(-169.23 -39.68)" fill="#4d8af0" />
<path
d="M705.14,247.87s2.16,26.68-6.05,27.6l16.43,8.22s-.91,48.38,16.43,65.73c0,0,32-17.34,65.73-16.43s-8.22-32.86-8.22-32.86l-5.55-37.4,4.57-6.85a34.33,34.33,0,0,1-16-10.28h0c-4.57,5.71-15,13.45-24.12,13.45h-3.93c-13.53,0-27.92-2.73-39.32-10Z"
transform="translate(-169.23 -39.68)" opacity="0.1" />
<path
d="M703.62,245.59s2.16,26.68-6.05,27.6L714,281.4s-.91,48.38,16.43,65.73c0,0,32-17.34,65.73-16.43s-8.22-32.86-8.22-32.86l-5.55-37.4,4.57-6.85a34.33,34.33,0,0,1-16-10.28h0c-4.57,5.71-15,13.45-24.12,13.45h-3.93a74.73,74.73,0,0,1-39.32-11.17Z"
transform="translate(-169.23 -39.68)" fill="#3ad29f" />
<path d="M725.26,238.07v9.17a17.53,17.53,0,0,0,5.13,12.39l19.51,19.51,6.5-13a16.29,16.29,0,0,0,1.72-7.29v-20.8Z"
transform="translate(-169.23 -39.68)" fill="#fda57d" />
<path d="M725.51,248.63c0,.34,0,.67,0,1a24.64,24.64,0,0,0,32.83,0V239.46H725.51Z"
transform="translate(-169.23 -39.68)" opacity="0.1" />
<circle cx="572.46" cy="190.17" r="24.65" fill="#fda57d" />
<path
d="M725.26,222.9h41.08s16.43-16.43,0-24.65a56.24,56.24,0,0,0-11.15-3.94c-25-6.34-48.74,14.33-45.53,39.91.76,6,2.93,11,7.38,13.32C734.39,256.68,725.26,222.9,725.26,222.9Z"
transform="translate(-169.23 -39.68)" opacity="0.1" />
<path
d="M725.26,221.76h41.08s16.43-16.43,0-24.65a56.24,56.24,0,0,0-11.15-3.94c-25-6.34-48.74,14.33-45.53,39.91.76,6,2.93,11,7.38,13.32C734.39,255.54,725.26,221.76,725.26,221.76Z"
transform="translate(-169.23 -39.68)" fill="#333" />
<ellipse cx="557.23" cy="190.49" rx="2.28" ry="4" fill="#fda57d" />
<polygon points="544.67 241.3 545.81 237.87 549.23 240.16 544.67 241.3" opacity="0.1" />
<path d="M788,297.85s-12.43,6-15.86,11.67" transform="translate(-169.23 -39.68)" opacity="0.1" />
<polygon points="613.17 220.75 612.03 224.17 609.74 220.75 613.17 220.75" opacity="0.1" />
<path
d="M725.26,221.76h41.08s16.43-16.43,0-24.65a56.24,56.24,0,0,0-11.15-3.94c-25-6.34-48.74,14.33-45.53,39.91.76,6,2.93,11,7.38,13.32C734.39,255.54,725.26,221.76,725.26,221.76Z"
transform="translate(-169.23 -39.68)" fill="#333" />
</svg>
<!-- Image -->
<p class="mt-4 text-two">
Get Templates & Plugins as a gift!<br />Hurry up & don't
lose your chance.
</p>
<a type="button" class="btn btn-danger text-white btn-rounded btn-lg" href="https://mdbootstrap.com/sale/"><i
class="fas fa-gifts"></i> GET Your gift</a>
</div>
</div>
<div style="height: 100vh; text-align: center; margin-top: 150px;">
<img
src="https://mdbootstrap.com/img/logo/mdb-transparent-250px.png"
style="width: 250px; height: 90px;"
/>
<h5>Thank you for using our product. We're glad you're with us.</h5>
<p>MDB Team</p>
</div>
<!-- End your project here-->
</body>

29
js/mdb.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "mdb-ui-kit",
"version": "3.0.0",
"version": "1.0.0-alpha1",
"main": "js/mdb.min.js",
"repository": "https://github.com/mdbootstrap/mdb-ui-kit.git",
"author": "MDBootstrap",

View File

@ -1,5 +1,5 @@
/*!
* Bootstrap alert.js v5.0.0-beta1 (https://getbootstrap.com/)
* Bootstrap alert.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
@ -7,22 +7,20 @@
typeof exports === 'object' && typeof module !== 'undefined'
? (module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js')))
: typeof define === 'function' && define.amd
? define(['./dom/data', './dom/event-handler'], factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
(global.Alert = factory(global.Data, global.EventHandler)));
? define(['./dom/data.js', './dom/event-handler.js'], factory)
: ((global = global || self), (global.Alert = factory(global.Data, global.EventHandler)));
})(this, function (Data, EventHandler) {
'use strict';
function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : { default: e };
}
var Data__default = /*#__PURE__*/ _interopDefaultLegacy(Data);
var EventHandler__default = /*#__PURE__*/ _interopDefaultLegacy(EventHandler);
Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data;
EventHandler =
EventHandler && Object.prototype.hasOwnProperty.call(EventHandler, 'default')
? EventHandler['default']
: EventHandler;
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/index.js
* Bootstrap (v5.0.0-alpha1): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -30,7 +28,7 @@
var TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
var getSelector = function getSelector(element) {
var selector = element.getAttribute('data-bs-target');
var selector = element.getAttribute('data-target');
if (!selector || selector === '#') {
var hrefAttr = element.getAttribute('href');
@ -54,8 +52,8 @@
transitionDuration = _window$getComputedSt.transitionDuration,
transitionDelay = _window$getComputedSt.transitionDelay;
var floatTransitionDuration = Number.parseFloat(transitionDuration);
var floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
var floatTransitionDuration = parseFloat(transitionDuration);
var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
if (!floatTransitionDuration && !floatTransitionDelay) {
return 0;
@ -63,10 +61,7 @@
transitionDuration = transitionDuration.split(',')[0];
transitionDelay = transitionDelay.split(',')[0];
return (
(Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) *
MILLISECONDS_MULTIPLIER
);
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
};
var triggerTransitionEnd = function triggerTransitionEnd(element) {
@ -95,23 +90,13 @@
var _window = window,
jQuery = _window.jQuery;
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
return jQuery;
}
return null;
};
var onDOMContentLoaded = function onDOMContentLoaded(callback) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callback);
} else {
callback();
}
};
var isRTL = document.documentElement.dir === 'rtl';
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
@ -133,74 +118,12 @@
* ------------------------------------------------------------------------
*/
var VERSION = '5.0.0-beta1';
var BaseComponent = /*#__PURE__*/ (function () {
function BaseComponent(element) {
if (!element) {
return;
}
this._element = element;
Data__default['default'].setData(element, this.constructor.DATA_KEY, this);
}
var _proto = BaseComponent.prototype;
_proto.dispose = function dispose() {
Data__default['default'].removeData(this._element, this.constructor.DATA_KEY);
this._element = null;
};
/** Static */
BaseComponent.getInstance = function getInstance(element) {
return Data__default['default'].getData(element, this.DATA_KEY);
};
_createClass(BaseComponent, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
]);
return BaseComponent;
})();
function _defineProperties$1(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass$1(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
if (staticProps) _defineProperties$1(Constructor, staticProps);
return Constructor;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'alert';
var VERSION = '5.0.0-alpha1';
var DATA_KEY = 'bs.alert';
var EVENT_KEY = '.' + DATA_KEY;
var DATA_API_KEY = '.data-api';
var SELECTOR_DISMISS = '[data-bs-dismiss="alert"]';
var SELECTOR_DISMISS = '[data-dismiss="alert"]';
var EVENT_CLOSE = 'close' + EVENT_KEY;
var EVENT_CLOSED = 'closed' + EVENT_KEY;
var EVENT_CLICK_DATA_API = 'click' + EVENT_KEY + DATA_API_KEY;
@ -213,18 +136,24 @@
* ------------------------------------------------------------------------
*/
var Alert = /*#__PURE__*/ (function (_BaseComponent) {
_inheritsLoose(Alert, _BaseComponent);
var Alert = /*#__PURE__*/ (function () {
function Alert(element) {
this._element = element;
function Alert() {
return _BaseComponent.apply(this, arguments) || this;
}
if (this._element) {
Data.setData(element, DATA_KEY, this);
}
} // Getters
var _proto = Alert.prototype;
// Public
_proto.close = function close(element) {
var rootElement = element ? this._getRootElement(element) : this._element;
var rootElement = this._element;
if (element) {
rootElement = this._getRootElement(element);
}
var customEvent = this._triggerCloseEvent(rootElement);
@ -233,6 +162,11 @@
}
this._removeElement(rootElement);
};
_proto.dispose = function dispose() {
Data.removeData(this._element, DATA_KEY);
this._element = null;
}; // Private
_proto._getRootElement = function _getRootElement(element) {
@ -240,7 +174,7 @@
};
_proto._triggerCloseEvent = function _triggerCloseEvent(element) {
return EventHandler__default['default'].trigger(element, EVENT_CLOSE);
return EventHandler.trigger(element, EVENT_CLOSE);
};
_proto._removeElement = function _removeElement(element) {
@ -255,7 +189,7 @@
}
var transitionDuration = getTransitionDurationFromElement(element);
EventHandler__default['default'].one(element, TRANSITION_END, function () {
EventHandler.one(element, TRANSITION_END, function () {
return _this._destroyElement(element);
});
emulateTransitionEnd(element, transitionDuration);
@ -266,12 +200,12 @@
element.parentNode.removeChild(element);
}
EventHandler__default['default'].trigger(element, EVENT_CLOSED);
EventHandler.trigger(element, EVENT_CLOSED);
}; // Static
Alert.jQueryInterface = function jQueryInterface(config) {
return this.each(function () {
var data = Data__default['default'].getData(this, DATA_KEY);
var data = Data.getData(this, DATA_KEY);
if (!data) {
data = new Alert(this);
@ -293,52 +227,53 @@
};
};
_createClass$1(Alert, null, [
Alert.getInstance = function getInstance(element) {
return Data.getData(element, DATA_KEY);
};
_createClass(Alert, null, [
{
key: 'DATA_KEY',
// Getters
key: 'VERSION',
get: function get() {
return DATA_KEY;
return VERSION;
},
},
]);
return Alert;
})(BaseComponent);
})();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler__default['default'].on(
EventHandler.on(
document,
EVENT_CLICK_DATA_API,
SELECTOR_DISMISS,
Alert.handleDismiss(new Alert())
);
var $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Alert to jQuery only if jQuery is present
* add .alert to jQuery only if jQuery is present
*/
onDOMContentLoaded(function () {
var $ = getjQuery();
/* istanbul ignore if */
/* istanbul ignore if */
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Alert.jQueryInterface;
$.fn[NAME].Constructor = Alert;
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Alert.jQueryInterface;
$.fn[NAME].Constructor = Alert;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Alert.jQueryInterface;
};
}
});
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Alert.jQueryInterface;
};
}
return Alert;
});

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*!
* Bootstrap button.js v5.0.0-beta1 (https://getbootstrap.com/)
* Bootstrap button.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
@ -7,22 +7,20 @@
typeof exports === 'object' && typeof module !== 'undefined'
? (module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js')))
: typeof define === 'function' && define.amd
? define(['./dom/data', './dom/event-handler'], factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
(global.Button = factory(global.Data, global.EventHandler)));
? define(['./dom/data.js', './dom/event-handler.js'], factory)
: ((global = global || self), (global.Button = factory(global.Data, global.EventHandler)));
})(this, function (Data, EventHandler) {
'use strict';
function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : { default: e };
}
var Data__default = /*#__PURE__*/ _interopDefaultLegacy(Data);
var EventHandler__default = /*#__PURE__*/ _interopDefaultLegacy(EventHandler);
Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data;
EventHandler =
EventHandler && Object.prototype.hasOwnProperty.call(EventHandler, 'default')
? EventHandler['default']
: EventHandler;
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/index.js
* Bootstrap (v5.0.0-alpha1): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -31,23 +29,13 @@
var _window = window,
jQuery = _window.jQuery;
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
return jQuery;
}
return null;
};
var onDOMContentLoaded = function onDOMContentLoaded(callback) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callback);
} else {
callback();
}
};
var isRTL = document.documentElement.dir === 'rtl';
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
@ -69,75 +57,13 @@
* ------------------------------------------------------------------------
*/
var VERSION = '5.0.0-beta1';
var BaseComponent = /*#__PURE__*/ (function () {
function BaseComponent(element) {
if (!element) {
return;
}
this._element = element;
Data__default['default'].setData(element, this.constructor.DATA_KEY, this);
}
var _proto = BaseComponent.prototype;
_proto.dispose = function dispose() {
Data__default['default'].removeData(this._element, this.constructor.DATA_KEY);
this._element = null;
};
/** Static */
BaseComponent.getInstance = function getInstance(element) {
return Data__default['default'].getData(element, this.DATA_KEY);
};
_createClass(BaseComponent, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
]);
return BaseComponent;
})();
function _defineProperties$1(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass$1(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
if (staticProps) _defineProperties$1(Constructor, staticProps);
return Constructor;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'button';
var VERSION = '5.0.0-alpha1';
var DATA_KEY = 'bs.button';
var EVENT_KEY = '.' + DATA_KEY;
var DATA_API_KEY = '.data-api';
var CLASS_NAME_ACTIVE = 'active';
var SELECTOR_DATA_TOGGLE = '[data-bs-toggle="button"]';
var SELECTOR_DATA_TOGGLE = '[data-toggle="button"]';
var EVENT_CLICK_DATA_API = 'click' + EVENT_KEY + DATA_API_KEY;
/**
* ------------------------------------------------------------------------
@ -145,12 +71,11 @@
* ------------------------------------------------------------------------
*/
var Button = /*#__PURE__*/ (function (_BaseComponent) {
_inheritsLoose(Button, _BaseComponent);
function Button() {
return _BaseComponent.apply(this, arguments) || this;
}
var Button = /*#__PURE__*/ (function () {
function Button(element) {
this._element = element;
Data.setData(element, DATA_KEY, this);
} // Getters
var _proto = Button.prototype;
@ -158,11 +83,16 @@
_proto.toggle = function toggle() {
// Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE));
};
_proto.dispose = function dispose() {
Data.removeData(this._element, DATA_KEY);
this._element = null;
}; // Static
Button.jQueryInterface = function jQueryInterface(config) {
return this.each(function () {
var data = Data__default['default'].getData(this, DATA_KEY);
var data = Data.getData(this, DATA_KEY);
if (!data) {
data = new Button(this);
@ -174,62 +104,58 @@
});
};
_createClass$1(Button, null, [
Button.getInstance = function getInstance(element) {
return Data.getData(element, DATA_KEY);
};
_createClass(Button, null, [
{
key: 'DATA_KEY',
// Getters
key: 'VERSION',
get: function get() {
return DATA_KEY;
return VERSION;
},
},
]);
return Button;
})(BaseComponent);
})();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler__default['default'].on(
document,
EVENT_CLICK_DATA_API,
SELECTOR_DATA_TOGGLE,
function (event) {
event.preventDefault();
var button = event.target.closest(SELECTOR_DATA_TOGGLE);
var data = Data__default['default'].getData(button, DATA_KEY);
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
event.preventDefault();
var button = event.target.closest(SELECTOR_DATA_TOGGLE);
var data = Data.getData(button, DATA_KEY);
if (!data) {
data = new Button(button);
}
data.toggle();
if (!data) {
data = new Button(button);
}
);
data.toggle();
});
var $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Button to jQuery only if jQuery is present
* add .button to jQuery only if jQuery is present
*/
onDOMContentLoaded(function () {
var $ = getjQuery();
/* istanbul ignore if */
/* istanbul ignore if */
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Button.jQueryInterface;
$.fn[NAME].Constructor = Button;
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Button.jQueryInterface;
$.fn[NAME].Constructor = Button;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Button.jQueryInterface;
};
}
});
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Button.jQueryInterface;
};
}
return Button;
});

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*!
* Bootstrap carousel.js v5.0.0-beta1 (https://getbootstrap.com/)
* Bootstrap carousel.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
@ -13,12 +13,12 @@
))
: typeof define === 'function' && define.amd
? define([
'./dom/data',
'./dom/event-handler',
'./dom/manipulator',
'./dom/selector-engine',
'./dom/data.js',
'./dom/event-handler.js',
'./dom/manipulator.js',
'./dom/selector-engine.js',
], factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
: ((global = global || self),
(global.Carousel = factory(
global.Data,
global.EventHandler,
@ -28,18 +28,23 @@
})(this, function (Data, EventHandler, Manipulator, SelectorEngine) {
'use strict';
function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : { default: e };
}
var Data__default = /*#__PURE__*/ _interopDefaultLegacy(Data);
var EventHandler__default = /*#__PURE__*/ _interopDefaultLegacy(EventHandler);
var Manipulator__default = /*#__PURE__*/ _interopDefaultLegacy(Manipulator);
var SelectorEngine__default = /*#__PURE__*/ _interopDefaultLegacy(SelectorEngine);
Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data;
EventHandler =
EventHandler && Object.prototype.hasOwnProperty.call(EventHandler, 'default')
? EventHandler['default']
: EventHandler;
Manipulator =
Manipulator && Object.prototype.hasOwnProperty.call(Manipulator, 'default')
? Manipulator['default']
: Manipulator;
SelectorEngine =
SelectorEngine && Object.prototype.hasOwnProperty.call(SelectorEngine, 'default')
? SelectorEngine['default']
: SelectorEngine;
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/index.js
* Bootstrap (v5.0.0-alpha1): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -58,7 +63,7 @@
};
var getSelector = function getSelector(element) {
var selector = element.getAttribute('data-bs-target');
var selector = element.getAttribute('data-target');
if (!selector || selector === '#') {
var hrefAttr = element.getAttribute('href');
@ -82,8 +87,8 @@
transitionDuration = _window$getComputedSt.transitionDuration,
transitionDelay = _window$getComputedSt.transitionDelay;
var floatTransitionDuration = Number.parseFloat(transitionDuration);
var floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
var floatTransitionDuration = parseFloat(transitionDuration);
var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
if (!floatTransitionDuration && !floatTransitionDelay) {
return 0;
@ -91,10 +96,7 @@
transitionDuration = transitionDuration.split(',')[0];
transitionDelay = transitionDelay.split(',')[0];
return (
(Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) *
MILLISECONDS_MULTIPLIER
);
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
};
var triggerTransitionEnd = function triggerTransitionEnd(element) {
@ -166,22 +168,57 @@
var _window = window,
jQuery = _window.jQuery;
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
return jQuery;
}
return null;
};
var onDOMContentLoaded = function onDOMContentLoaded(callback) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callback);
} else {
callback();
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly)
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
};
return keys;
}
var isRTL = document.documentElement.dir === 'rtl';
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true,
});
} else {
obj[key] = value;
}
return obj;
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
@ -204,87 +241,8 @@
* ------------------------------------------------------------------------
*/
var VERSION = '5.0.0-beta1';
var BaseComponent = /*#__PURE__*/ (function () {
function BaseComponent(element) {
if (!element) {
return;
}
this._element = element;
Data__default['default'].setData(element, this.constructor.DATA_KEY, this);
}
var _proto = BaseComponent.prototype;
_proto.dispose = function dispose() {
Data__default['default'].removeData(this._element, this.constructor.DATA_KEY);
this._element = null;
};
/** Static */
BaseComponent.getInstance = function getInstance(element) {
return Data__default['default'].getData(element, this.DATA_KEY);
};
_createClass(BaseComponent, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
]);
return BaseComponent;
})();
function _extends() {
_extends =
Object.assign ||
function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _defineProperties$1(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass$1(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
if (staticProps) _defineProperties$1(Constructor, staticProps);
return Constructor;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'carousel';
var VERSION = '5.0.0-alpha1';
var DATA_KEY = 'bs.carousel';
var EVENT_KEY = '.' + DATA_KEY;
var DATA_API_KEY = '.data-api';
@ -329,8 +287,8 @@
var CLASS_NAME_CAROUSEL = 'carousel';
var CLASS_NAME_ACTIVE = 'active';
var CLASS_NAME_SLIDE = 'slide';
var CLASS_NAME_END = 'carousel-item-end';
var CLASS_NAME_START = 'carousel-item-start';
var CLASS_NAME_RIGHT = 'carousel-item-right';
var CLASS_NAME_LEFT = 'carousel-item-left';
var CLASS_NAME_NEXT = 'carousel-item-next';
var CLASS_NAME_PREV = 'carousel-item-prev';
var CLASS_NAME_POINTER_EVENT = 'pointer-event';
@ -340,8 +298,8 @@
var SELECTOR_ITEM_IMG = '.carousel-item img';
var SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
var SELECTOR_INDICATORS = '.carousel-indicators';
var SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
var SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
var SELECTOR_DATA_SLIDE = '[data-slide], [data-slide-to]';
var SELECTOR_DATA_RIDE = '[data-ride="carousel"]';
var PointerType = {
TOUCH: 'touch',
PEN: 'pen',
@ -352,33 +310,26 @@
* ------------------------------------------------------------------------
*/
var Carousel = /*#__PURE__*/ (function (_BaseComponent) {
_inheritsLoose(Carousel, _BaseComponent);
var Carousel = /*#__PURE__*/ (function () {
function Carousel(element, config) {
var _this;
_this = _BaseComponent.call(this, element) || this;
_this._items = null;
_this._interval = null;
_this._activeElement = null;
_this._isPaused = false;
_this._isSliding = false;
_this.touchTimeout = null;
_this.touchStartX = 0;
_this.touchDeltaX = 0;
_this._config = _this._getConfig(config);
_this._indicatorsElement = SelectorEngine__default['default'].findOne(
SELECTOR_INDICATORS,
_this._element
);
_this._touchSupported =
this._items = null;
this._interval = null;
this._activeElement = null;
this._isPaused = false;
this._isSliding = false;
this.touchTimeout = null;
this.touchStartX = 0;
this.touchDeltaX = 0;
this._config = this._getConfig(config);
this._element = element;
this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
this._touchSupported =
'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
_this._pointerEvent = Boolean(window.PointerEvent);
this._pointerEvent = Boolean(window.PointerEvent);
_this._addEventListeners();
this._addEventListeners();
return _this;
Data.setData(element, DATA_KEY, this);
} // Getters
var _proto = Carousel.prototype;
@ -409,7 +360,7 @@
this._isPaused = true;
}
if (SelectorEngine__default['default'].findOne(SELECTOR_NEXT_PREV, this._element)) {
if (SelectorEngine.findOne(SELECTOR_NEXT_PREV, this._element)) {
triggerTransitionEnd(this._element);
this.cycle(true);
}
@ -429,8 +380,6 @@
}
if (this._config && this._config.interval && !this._isPaused) {
this._updateInterval();
this._interval = setInterval(
(document.visibilityState ? this.nextWhenVisible : this.next).bind(this),
this._config.interval
@ -439,12 +388,9 @@
};
_proto.to = function to(index) {
var _this2 = this;
var _this = this;
this._activeElement = SelectorEngine__default['default'].findOne(
SELECTOR_ACTIVE_ITEM,
this._element
);
this._activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
var activeIndex = this._getItemIndex(this._activeElement);
@ -453,8 +399,8 @@
}
if (this._isSliding) {
EventHandler__default['default'].one(this._element, EVENT_SLID, function () {
return _this2.to(index);
EventHandler.one(this._element, EVENT_SLID, function () {
return _this.to(index);
});
return;
}
@ -471,11 +417,11 @@
};
_proto.dispose = function dispose() {
_BaseComponent.prototype.dispose.call(this);
EventHandler__default['default'].off(this._element, EVENT_KEY);
EventHandler.off(this._element, EVENT_KEY);
Data.removeData(this._element, DATA_KEY);
this._items = null;
this._config = null;
this._element = null;
this._interval = null;
this._isPaused = null;
this._isSliding = null;
@ -484,7 +430,7 @@
}; // Private
_proto._getConfig = function _getConfig(config) {
config = _extends({}, Default, config);
config = _objectSpread(_objectSpread({}, Default), config);
typeCheckConfig(NAME, config, DefaultType);
return config;
};
@ -509,20 +455,20 @@
};
_proto._addEventListeners = function _addEventListeners() {
var _this3 = this;
var _this2 = this;
if (this._config.keyboard) {
EventHandler__default['default'].on(this._element, EVENT_KEYDOWN, function (event) {
return _this3._keydown(event);
EventHandler.on(this._element, EVENT_KEYDOWN, function (event) {
return _this2._keydown(event);
});
}
if (this._config.pause === 'hover') {
EventHandler__default['default'].on(this._element, EVENT_MOUSEENTER, function (event) {
return _this3.pause(event);
EventHandler.on(this._element, EVENT_MOUSEENTER, function (event) {
return _this2.pause(event);
});
EventHandler__default['default'].on(this._element, EVENT_MOUSELEAVE, function (event) {
return _this3.cycle(event);
EventHandler.on(this._element, EVENT_MOUSELEAVE, function (event) {
return _this2.cycle(event);
});
}
@ -532,33 +478,33 @@
};
_proto._addTouchEventListeners = function _addTouchEventListeners() {
var _this4 = this;
var _this3 = this;
var start = function start(event) {
if (_this4._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
_this4.touchStartX = event.clientX;
} else if (!_this4._pointerEvent) {
_this4.touchStartX = event.touches[0].clientX;
if (_this3._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
_this3.touchStartX = event.clientX;
} else if (!_this3._pointerEvent) {
_this3.touchStartX = event.touches[0].clientX;
}
};
var move = function move(event) {
// ensure swiping with one touch and not pinching
if (event.touches && event.touches.length > 1) {
_this4.touchDeltaX = 0;
_this3.touchDeltaX = 0;
} else {
_this4.touchDeltaX = event.touches[0].clientX - _this4.touchStartX;
_this3.touchDeltaX = event.touches[0].clientX - _this3.touchStartX;
}
};
var end = function end(event) {
if (_this4._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
_this4.touchDeltaX = event.clientX - _this4.touchStartX;
if (_this3._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
_this3.touchDeltaX = event.clientX - _this3.touchStartX;
}
_this4._handleSwipe();
_this3._handleSwipe();
if (_this4._config.pause === 'hover') {
if (_this3._config.pause === 'hover') {
// If it's a touch-enabled device, mouseenter/leave are fired as
// part of the mouse compatibility events on first tap - the carousel
// would stop cycling until user tapped out of it;
@ -566,43 +512,41 @@
// (as if it's the second time we tap on it, mouseenter compat event
// is NOT fired) and after a timeout (to allow for mouse compatibility
// events to fire) we explicitly restart cycling
_this4.pause();
_this3.pause();
if (_this4.touchTimeout) {
clearTimeout(_this4.touchTimeout);
if (_this3.touchTimeout) {
clearTimeout(_this3.touchTimeout);
}
_this4.touchTimeout = setTimeout(function (event) {
return _this4.cycle(event);
}, TOUCHEVENT_COMPAT_WAIT + _this4._config.interval);
_this3.touchTimeout = setTimeout(function (event) {
return _this3.cycle(event);
}, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
}
};
SelectorEngine__default['default']
.find(SELECTOR_ITEM_IMG, this._element)
.forEach(function (itemImg) {
EventHandler__default['default'].on(itemImg, EVENT_DRAG_START, function (e) {
return e.preventDefault();
});
SelectorEngine.find(SELECTOR_ITEM_IMG, this._element).forEach(function (itemImg) {
EventHandler.on(itemImg, EVENT_DRAG_START, function (e) {
return e.preventDefault();
});
});
if (this._pointerEvent) {
EventHandler__default['default'].on(this._element, EVENT_POINTERDOWN, function (event) {
EventHandler.on(this._element, EVENT_POINTERDOWN, function (event) {
return start(event);
});
EventHandler__default['default'].on(this._element, EVENT_POINTERUP, function (event) {
EventHandler.on(this._element, EVENT_POINTERUP, function (event) {
return end(event);
});
this._element.classList.add(CLASS_NAME_POINTER_EVENT);
} else {
EventHandler__default['default'].on(this._element, EVENT_TOUCHSTART, function (event) {
EventHandler.on(this._element, EVENT_TOUCHSTART, function (event) {
return start(event);
});
EventHandler__default['default'].on(this._element, EVENT_TOUCHMOVE, function (event) {
EventHandler.on(this._element, EVENT_TOUCHMOVE, function (event) {
return move(event);
});
EventHandler__default['default'].on(this._element, EVENT_TOUCHEND, function (event) {
EventHandler.on(this._element, EVENT_TOUCHEND, function (event) {
return end(event);
});
}
@ -628,9 +572,7 @@
_proto._getItemIndex = function _getItemIndex(element) {
this._items =
element && element.parentNode
? SelectorEngine__default['default'].find(SELECTOR_ITEM, element.parentNode)
: [];
element && element.parentNode ? SelectorEngine.find(SELECTOR_ITEM, element.parentNode) : [];
return this._items.indexOf(element);
};
@ -658,10 +600,10 @@
var targetIndex = this._getItemIndex(relatedTarget);
var fromIndex = this._getItemIndex(
SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element)
SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element)
);
return EventHandler__default['default'].trigger(this._element, EVENT_SLIDE, {
return EventHandler.trigger(this._element, EVENT_SLIDE, {
relatedTarget: relatedTarget,
direction: eventDirectionName,
from: fromIndex,
@ -671,10 +613,7 @@
_proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
if (this._indicatorsElement) {
var indicators = SelectorEngine__default['default'].find(
SELECTOR_ACTIVE,
this._indicatorsElement
);
var indicators = SelectorEngine.find(SELECTOR_ACTIVE, this._indicatorsElement);
for (var i = 0; i < indicators.length; i++) {
indicators[i].classList.remove(CLASS_NAME_ACTIVE);
@ -688,32 +627,10 @@
}
};
_proto._updateInterval = function _updateInterval() {
var element =
this._activeElement ||
SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element);
if (!element) {
return;
}
var elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
if (elementInterval) {
this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
this._config.interval = elementInterval;
} else {
this._config.interval = this._config.defaultInterval || this._config.interval;
}
};
_proto._slide = function _slide(direction, element) {
var _this5 = this;
var _this4 = this;
var activeElement = SelectorEngine__default['default'].findOne(
SELECTOR_ACTIVE_ITEM,
this._element
);
var activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
var activeElementIndex = this._getItemIndex(activeElement);
@ -728,11 +645,11 @@
var eventDirectionName;
if (direction === DIRECTION_NEXT) {
directionalClassName = CLASS_NAME_START;
directionalClassName = CLASS_NAME_LEFT;
orderClassName = CLASS_NAME_NEXT;
eventDirectionName = DIRECTION_LEFT;
} else {
directionalClassName = CLASS_NAME_END;
directionalClassName = CLASS_NAME_RIGHT;
orderClassName = CLASS_NAME_PREV;
eventDirectionName = DIRECTION_RIGHT;
}
@ -761,21 +678,28 @@
this._setActiveIndicatorElement(nextElement);
this._activeElement = nextElement;
if (this._element.classList.contains(CLASS_NAME_SLIDE)) {
nextElement.classList.add(orderClassName);
reflow(nextElement);
activeElement.classList.add(directionalClassName);
nextElement.classList.add(directionalClassName);
var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
if (nextElementInterval) {
this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
this._config.interval = nextElementInterval;
} else {
this._config.interval = this._config.defaultInterval || this._config.interval;
}
var transitionDuration = getTransitionDurationFromElement(activeElement);
EventHandler__default['default'].one(activeElement, TRANSITION_END, function () {
EventHandler.one(activeElement, TRANSITION_END, function () {
nextElement.classList.remove(directionalClassName, orderClassName);
nextElement.classList.add(CLASS_NAME_ACTIVE);
activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName);
_this5._isSliding = false;
_this4._isSliding = false;
setTimeout(function () {
EventHandler__default['default'].trigger(_this5._element, EVENT_SLID, {
EventHandler.trigger(_this4._element, EVENT_SLID, {
relatedTarget: nextElement,
direction: eventDirectionName,
from: activeElementIndex,
@ -788,7 +712,7 @@
activeElement.classList.remove(CLASS_NAME_ACTIVE);
nextElement.classList.add(CLASS_NAME_ACTIVE);
this._isSliding = false;
EventHandler__default['default'].trigger(this._element, EVENT_SLID, {
EventHandler.trigger(this._element, EVENT_SLID, {
relatedTarget: nextElement,
direction: eventDirectionName,
from: activeElementIndex,
@ -802,16 +726,15 @@
}; // Static
Carousel.carouselInterface = function carouselInterface(element, config) {
var data = Data__default['default'].getData(element, DATA_KEY);
var data = Data.getData(element, DATA_KEY);
var _config = _extends(
{},
Default,
Manipulator__default['default'].getDataAttributes(element)
var _config = _objectSpread(
_objectSpread({}, Default),
Manipulator.getDataAttributes(element)
);
if (typeof config === 'object') {
_config = _extends({}, _config, config);
_config = _objectSpread(_objectSpread({}, _config), config);
}
var action = typeof config === 'string' ? config : _config.slide;
@ -847,13 +770,12 @@
return;
}
var config = _extends(
{},
Manipulator__default['default'].getDataAttributes(target),
Manipulator__default['default'].getDataAttributes(this)
var config = _objectSpread(
_objectSpread({}, Manipulator.getDataAttributes(target)),
Manipulator.getDataAttributes(this)
);
var slideIndex = this.getAttribute('data-bs-slide-to');
var slideIndex = this.getAttribute('data-slide-to');
if (slideIndex) {
config.interval = false;
@ -862,73 +784,72 @@
Carousel.carouselInterface(target, config);
if (slideIndex) {
Data__default['default'].getData(target, DATA_KEY).to(slideIndex);
Data.getData(target, DATA_KEY).to(slideIndex);
}
event.preventDefault();
};
_createClass$1(Carousel, null, [
Carousel.getInstance = function getInstance(element) {
return Data.getData(element, DATA_KEY);
};
_createClass(Carousel, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
{
key: 'Default',
get: function get() {
return Default;
},
},
{
key: 'DATA_KEY',
get: function get() {
return DATA_KEY;
},
},
]);
return Carousel;
})(BaseComponent);
})();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler__default['default'].on(
EventHandler.on(
document,
EVENT_CLICK_DATA_API,
SELECTOR_DATA_SLIDE,
Carousel.dataApiClickHandler
);
EventHandler__default['default'].on(window, EVENT_LOAD_DATA_API, function () {
var carousels = SelectorEngine__default['default'].find(SELECTOR_DATA_RIDE);
EventHandler.on(window, EVENT_LOAD_DATA_API, function () {
var carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
for (var i = 0, len = carousels.length; i < len; i++) {
Carousel.carouselInterface(
carousels[i],
Data__default['default'].getData(carousels[i], DATA_KEY)
);
Carousel.carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY));
}
});
var $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Carousel to jQuery only if jQuery is present
* add .carousel to jQuery only if jQuery is present
*/
onDOMContentLoaded(function () {
var $ = getjQuery();
/* istanbul ignore if */
/* istanbul ignore if */
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Carousel.jQueryInterface;
$.fn[NAME].Constructor = Carousel;
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Carousel.jQueryInterface;
$.fn[NAME].Constructor = Carousel;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Carousel.jQueryInterface;
};
}
});
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Carousel.jQueryInterface;
};
}
return Carousel;
});

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*!
* Bootstrap collapse.js v5.0.0-beta1 (https://getbootstrap.com/)
* Bootstrap collapse.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
@ -13,12 +13,12 @@
))
: typeof define === 'function' && define.amd
? define([
'./dom/data',
'./dom/event-handler',
'./dom/manipulator',
'./dom/selector-engine',
'./dom/data.js',
'./dom/event-handler.js',
'./dom/manipulator.js',
'./dom/selector-engine.js',
], factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
: ((global = global || self),
(global.Collapse = factory(
global.Data,
global.EventHandler,
@ -28,18 +28,23 @@
})(this, function (Data, EventHandler, Manipulator, SelectorEngine) {
'use strict';
function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : { default: e };
}
var Data__default = /*#__PURE__*/ _interopDefaultLegacy(Data);
var EventHandler__default = /*#__PURE__*/ _interopDefaultLegacy(EventHandler);
var Manipulator__default = /*#__PURE__*/ _interopDefaultLegacy(Manipulator);
var SelectorEngine__default = /*#__PURE__*/ _interopDefaultLegacy(SelectorEngine);
Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data;
EventHandler =
EventHandler && Object.prototype.hasOwnProperty.call(EventHandler, 'default')
? EventHandler['default']
: EventHandler;
Manipulator =
Manipulator && Object.prototype.hasOwnProperty.call(Manipulator, 'default')
? Manipulator['default']
: Manipulator;
SelectorEngine =
SelectorEngine && Object.prototype.hasOwnProperty.call(SelectorEngine, 'default')
? SelectorEngine['default']
: SelectorEngine;
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/index.js
* Bootstrap (v5.0.0-alpha1): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -58,7 +63,7 @@
};
var getSelector = function getSelector(element) {
var selector = element.getAttribute('data-bs-target');
var selector = element.getAttribute('data-target');
if (!selector || selector === '#') {
var hrefAttr = element.getAttribute('href');
@ -92,8 +97,8 @@
transitionDuration = _window$getComputedSt.transitionDuration,
transitionDelay = _window$getComputedSt.transitionDelay;
var floatTransitionDuration = Number.parseFloat(transitionDuration);
var floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
var floatTransitionDuration = parseFloat(transitionDuration);
var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
if (!floatTransitionDuration && !floatTransitionDelay) {
return 0;
@ -101,10 +106,7 @@
transitionDuration = transitionDuration.split(',')[0];
transitionDelay = transitionDelay.split(',')[0];
return (
(Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) *
MILLISECONDS_MULTIPLIER
);
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
};
var triggerTransitionEnd = function triggerTransitionEnd(element) {
@ -158,22 +160,57 @@
var _window = window,
jQuery = _window.jQuery;
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
return jQuery;
}
return null;
};
var onDOMContentLoaded = function onDOMContentLoaded(callback) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callback);
} else {
callback();
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly)
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
};
return keys;
}
var isRTL = document.documentElement.dir === 'rtl';
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true,
});
} else {
obj[key] = value;
}
return obj;
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
@ -196,87 +233,8 @@
* ------------------------------------------------------------------------
*/
var VERSION = '5.0.0-beta1';
var BaseComponent = /*#__PURE__*/ (function () {
function BaseComponent(element) {
if (!element) {
return;
}
this._element = element;
Data__default['default'].setData(element, this.constructor.DATA_KEY, this);
}
var _proto = BaseComponent.prototype;
_proto.dispose = function dispose() {
Data__default['default'].removeData(this._element, this.constructor.DATA_KEY);
this._element = null;
};
/** Static */
BaseComponent.getInstance = function getInstance(element) {
return Data__default['default'].getData(element, this.DATA_KEY);
};
_createClass(BaseComponent, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
]);
return BaseComponent;
})();
function _extends() {
_extends =
Object.assign ||
function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _defineProperties$1(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass$1(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
if (staticProps) _defineProperties$1(Constructor, staticProps);
return Constructor;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'collapse';
var VERSION = '5.0.0-alpha1';
var DATA_KEY = 'bs.collapse';
var EVENT_KEY = '.' + DATA_KEY;
var DATA_API_KEY = '.data-api';
@ -300,58 +258,52 @@
var WIDTH = 'width';
var HEIGHT = 'height';
var SELECTOR_ACTIVES = '.show, .collapsing';
var SELECTOR_DATA_TOGGLE = '[data-bs-toggle="collapse"]';
var SELECTOR_DATA_TOGGLE = '[data-toggle="collapse"]';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
var Collapse = /*#__PURE__*/ (function (_BaseComponent) {
_inheritsLoose(Collapse, _BaseComponent);
var Collapse = /*#__PURE__*/ (function () {
function Collapse(element, config) {
var _this;
_this = _BaseComponent.call(this, element) || this;
_this._isTransitioning = false;
_this._config = _this._getConfig(config);
_this._triggerArray = SelectorEngine__default['default'].find(
this._isTransitioning = false;
this._element = element;
this._config = this._getConfig(config);
this._triggerArray = SelectorEngine.find(
SELECTOR_DATA_TOGGLE +
'[href="#' +
element.id +
'"],' +
(SELECTOR_DATA_TOGGLE + '[data-bs-target="#' + element.id + '"]')
(SELECTOR_DATA_TOGGLE + '[data-target="#' + element.id + '"]')
);
var toggleList = SelectorEngine__default['default'].find(SELECTOR_DATA_TOGGLE);
var toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE);
for (var i = 0, len = toggleList.length; i < len; i++) {
var elem = toggleList[i];
var selector = getSelectorFromElement(elem);
var filterElement = SelectorEngine__default['default']
.find(selector)
.filter(function (foundElem) {
return foundElem === element;
});
var filterElement = SelectorEngine.find(selector).filter(function (foundElem) {
return foundElem === element;
});
if (selector !== null && filterElement.length) {
_this._selector = selector;
this._selector = selector;
_this._triggerArray.push(elem);
this._triggerArray.push(elem);
}
}
_this._parent = _this._config.parent ? _this._getParent() : null;
this._parent = this._config.parent ? this._getParent() : null;
if (!_this._config.parent) {
_this._addAriaAndCollapsedClass(_this._element, _this._triggerArray);
if (!this._config.parent) {
this._addAriaAndCollapsedClass(this._element, this._triggerArray);
}
if (_this._config.toggle) {
_this.toggle();
if (this._config.toggle) {
this.toggle();
}
return _this;
Data.setData(element, DATA_KEY, this);
} // Getters
var _proto = Collapse.prototype;
@ -366,7 +318,7 @@
};
_proto.show = function show() {
var _this2 = this;
var _this = this;
if (this._isTransitioning || this._element.classList.contains(CLASS_NAME_SHOW)) {
return;
@ -376,37 +328,33 @@
var activesData;
if (this._parent) {
actives = SelectorEngine__default['default']
.find(SELECTOR_ACTIVES, this._parent)
.filter(function (elem) {
if (typeof _this2._config.parent === 'string') {
return elem.getAttribute('data-bs-parent') === _this2._config.parent;
}
actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent).filter(function (elem) {
if (typeof _this._config.parent === 'string') {
return elem.getAttribute('data-parent') === _this._config.parent;
}
return elem.classList.contains(CLASS_NAME_COLLAPSE);
});
return elem.classList.contains(CLASS_NAME_COLLAPSE);
});
if (actives.length === 0) {
actives = null;
}
}
var container = SelectorEngine__default['default'].findOne(this._selector);
var container = SelectorEngine.findOne(this._selector);
if (actives) {
var tempActiveData = actives.find(function (elem) {
var tempActiveData = actives.filter(function (elem) {
return container !== elem;
});
activesData = tempActiveData
? Data__default['default'].getData(tempActiveData, DATA_KEY)
: null;
activesData = tempActiveData[0] ? Data.getData(tempActiveData[0], DATA_KEY) : null;
if (activesData && activesData._isTransitioning) {
return;
}
}
var startEvent = EventHandler__default['default'].trigger(this._element, EVENT_SHOW);
var startEvent = EventHandler.trigger(this._element, EVENT_SHOW);
if (startEvent.defaultPrevented) {
return;
@ -419,7 +367,7 @@
}
if (!activesData) {
Data__default['default'].setData(elemActive, DATA_KEY, null);
Data.setData(elemActive, DATA_KEY, null);
}
});
}
@ -442,33 +390,33 @@
this.setTransitioning(true);
var complete = function complete() {
_this2._element.classList.remove(CLASS_NAME_COLLAPSING);
_this._element.classList.remove(CLASS_NAME_COLLAPSING);
_this2._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
_this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
_this2._element.style[dimension] = '';
_this._element.style[dimension] = '';
_this2.setTransitioning(false);
_this.setTransitioning(false);
EventHandler__default['default'].trigger(_this2._element, EVENT_SHOWN);
EventHandler.trigger(_this._element, EVENT_SHOWN);
};
var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
var scrollSize = 'scroll' + capitalizedDimension;
var transitionDuration = getTransitionDurationFromElement(this._element);
EventHandler__default['default'].one(this._element, TRANSITION_END, complete);
EventHandler.one(this._element, TRANSITION_END, complete);
emulateTransitionEnd(this._element, transitionDuration);
this._element.style[dimension] = this._element[scrollSize] + 'px';
};
_proto.hide = function hide() {
var _this3 = this;
var _this2 = this;
if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW)) {
return;
}
var startEvent = EventHandler__default['default'].trigger(this._element, EVENT_HIDE);
var startEvent = EventHandler.trigger(this._element, EVENT_HIDE);
if (startEvent.defaultPrevented) {
return;
@ -500,18 +448,18 @@
this.setTransitioning(true);
var complete = function complete() {
_this3.setTransitioning(false);
_this2.setTransitioning(false);
_this3._element.classList.remove(CLASS_NAME_COLLAPSING);
_this2._element.classList.remove(CLASS_NAME_COLLAPSING);
_this3._element.classList.add(CLASS_NAME_COLLAPSE);
_this2._element.classList.add(CLASS_NAME_COLLAPSE);
EventHandler__default['default'].trigger(_this3._element, EVENT_HIDDEN);
EventHandler.trigger(_this2._element, EVENT_HIDDEN);
};
this._element.style[dimension] = '';
var transitionDuration = getTransitionDurationFromElement(this._element);
EventHandler__default['default'].one(this._element, TRANSITION_END, complete);
EventHandler.one(this._element, TRANSITION_END, complete);
emulateTransitionEnd(this._element, transitionDuration);
};
@ -520,16 +468,16 @@
};
_proto.dispose = function dispose() {
_BaseComponent.prototype.dispose.call(this);
Data.removeData(this._element, DATA_KEY);
this._config = null;
this._parent = null;
this._element = null;
this._triggerArray = null;
this._isTransitioning = null;
}; // Private
_proto._getConfig = function _getConfig(config) {
config = _extends({}, Default, config);
config = _objectSpread(_objectSpread({}, Default), config);
config.toggle = Boolean(config.toggle); // Coerce string values
typeCheckConfig(NAME, config, DefaultType);
@ -537,11 +485,13 @@
};
_proto._getDimension = function _getDimension() {
return this._element.classList.contains(WIDTH) ? WIDTH : HEIGHT;
var hasWidth = this._element.classList.contains(WIDTH);
return hasWidth ? WIDTH : HEIGHT;
};
_proto._getParent = function _getParent() {
var _this4 = this;
var _this3 = this;
var parent = this._config.parent;
@ -551,42 +501,41 @@
parent = parent[0];
}
} else {
parent = SelectorEngine__default['default'].findOne(parent);
parent = SelectorEngine.findOne(parent);
}
var selector = SELECTOR_DATA_TOGGLE + '[data-bs-parent="' + parent + '"]';
SelectorEngine__default['default'].find(selector, parent).forEach(function (element) {
var selector = SELECTOR_DATA_TOGGLE + '[data-parent="' + parent + '"]';
SelectorEngine.find(selector, parent).forEach(function (element) {
var selected = getElementFromSelector(element);
_this4._addAriaAndCollapsedClass(selected, [element]);
_this3._addAriaAndCollapsedClass(selected, [element]);
});
return parent;
};
_proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
if (!element || !triggerArray.length) {
return;
}
if (element) {
var isOpen = element.classList.contains(CLASS_NAME_SHOW);
var isOpen = element.classList.contains(CLASS_NAME_SHOW);
triggerArray.forEach(function (elem) {
if (isOpen) {
elem.classList.remove(CLASS_NAME_COLLAPSED);
} else {
elem.classList.add(CLASS_NAME_COLLAPSED);
if (triggerArray.length) {
triggerArray.forEach(function (elem) {
if (isOpen) {
elem.classList.remove(CLASS_NAME_COLLAPSED);
} else {
elem.classList.add(CLASS_NAME_COLLAPSED);
}
elem.setAttribute('aria-expanded', isOpen);
});
}
elem.setAttribute('aria-expanded', isOpen);
});
}
}; // Static
Collapse.collapseInterface = function collapseInterface(element, config) {
var data = Data__default['default'].getData(element, DATA_KEY);
var data = Data.getData(element, DATA_KEY);
var _config = _extends(
{},
Default,
Manipulator__default['default'].getDataAttributes(element),
var _config = _objectSpread(
_objectSpread(_objectSpread({}, Default), Manipulator.getDataAttributes(element)),
typeof config === 'object' && config ? config : {}
);
@ -613,84 +562,81 @@
});
};
_createClass$1(Collapse, null, [
Collapse.getInstance = function getInstance(element) {
return Data.getData(element, DATA_KEY);
};
_createClass(Collapse, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
{
key: 'Default',
get: function get() {
return Default;
},
},
{
key: 'DATA_KEY',
get: function get() {
return DATA_KEY;
},
},
]);
return Collapse;
})(BaseComponent);
})();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler__default['default'].on(
document,
EVENT_CLICK_DATA_API,
SELECTOR_DATA_TOGGLE,
function (event) {
// preventDefault only for <a> elements (which change the URL) not inside the collapsible element
if (event.target.tagName === 'A') {
event.preventDefault();
}
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
// preventDefault only for <a> elements (which change the URL) not inside the collapsible element
if (event.target.tagName === 'A') {
event.preventDefault();
}
var triggerData = Manipulator__default['default'].getDataAttributes(this);
var selector = getSelectorFromElement(this);
var selectorElements = SelectorEngine__default['default'].find(selector);
selectorElements.forEach(function (element) {
var data = Data__default['default'].getData(element, DATA_KEY);
var config;
var triggerData = Manipulator.getDataAttributes(this);
var selector = getSelectorFromElement(this);
var selectorElements = SelectorEngine.find(selector);
selectorElements.forEach(function (element) {
var data = Data.getData(element, DATA_KEY);
var config;
if (data) {
// update parent attribute
if (data._parent === null && typeof triggerData.parent === 'string') {
data._config.parent = triggerData.parent;
data._parent = data._getParent();
}
config = 'toggle';
} else {
config = triggerData;
if (data) {
// update parent attribute
if (data._parent === null && typeof triggerData.parent === 'string') {
data._config.parent = triggerData.parent;
data._parent = data._getParent();
}
Collapse.collapseInterface(element, config);
});
}
);
config = 'toggle';
} else {
config = triggerData;
}
Collapse.collapseInterface(element, config);
});
});
var $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Collapse to jQuery only if jQuery is present
* add .collapse to jQuery only if jQuery is present
*/
onDOMContentLoaded(function () {
var $ = getjQuery();
/* istanbul ignore if */
/* istanbul ignore if */
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Collapse.jQueryInterface;
$.fn[NAME].Constructor = Collapse;
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Collapse.jQueryInterface;
$.fn[NAME].Constructor = Collapse;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Collapse.jQueryInterface;
};
}
});
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Collapse.jQueryInterface;
};
}
return Collapse;
});

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*!
* Bootstrap data.js v5.0.0-beta1 (https://getbootstrap.com/)
* Bootstrap data.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
@ -8,14 +8,13 @@
? (module.exports = factory())
: typeof define === 'function' && define.amd
? define(factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
(global.Data = factory()));
: ((global = global || self), (global.Data = factory()));
})(this, function () {
'use strict';
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/data.js
* Bootstrap (v5.0.0-alpha1): dom/data.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -30,22 +29,22 @@
var id = 1;
return {
set: function set(element, key, data) {
if (typeof element.bsKey === 'undefined') {
element.bsKey = {
if (typeof element.key === 'undefined') {
element.key = {
key: key,
id: id,
};
id++;
}
storeData[element.bsKey.id] = data;
storeData[element.key.id] = data;
},
get: function get(element, key) {
if (!element || typeof element.bsKey === 'undefined') {
if (!element || typeof element.key === 'undefined') {
return null;
}
var keyProperties = element.bsKey;
var keyProperties = element.key;
if (keyProperties.key === key) {
return storeData[keyProperties.id];
@ -54,15 +53,15 @@
return null;
},
delete: function _delete(element, key) {
if (typeof element.bsKey === 'undefined') {
if (typeof element.key === 'undefined') {
return;
}
var keyProperties = element.bsKey;
var keyProperties = element.key;
if (keyProperties.key === key) {
delete storeData[keyProperties.id];
delete element.bsKey;
delete element.key;
}
},
};

View File

@ -1 +1 @@
{"version":3,"file":"data.js","sources":["../../src/dom/data.js"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap (v5.0.0-beta1): dom/data.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\n/**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\nconst mapData = (() => {\n const storeData = {}\n let id = 1\n return {\n set(element, key, data) {\n if (typeof element.bsKey === 'undefined') {\n element.bsKey = {\n key,\n id\n }\n id++\n }\n\n storeData[element.bsKey.id] = data\n },\n get(element, key) {\n if (!element || typeof element.bsKey === 'undefined') {\n return null\n }\n\n const keyProperties = element.bsKey\n if (keyProperties.key === key) {\n return storeData[keyProperties.id]\n }\n\n return null\n },\n delete(element, key) {\n if (typeof element.bsKey === 'undefined') {\n return\n }\n\n const keyProperties = element.bsKey\n if (keyProperties.key === key) {\n delete storeData[keyProperties.id]\n delete element.bsKey\n }\n }\n }\n})()\n\nconst Data = {\n setData(instance, key, data) {\n mapData.set(instance, key, data)\n },\n getData(instance, key) {\n return mapData.get(instance, key)\n },\n removeData(instance, key) {\n mapData.delete(instance, key)\n }\n}\n\nexport default Data\n"],"names":["mapData","storeData","id","set","element","key","data","bsKey","get","keyProperties","delete","Data","setData","instance","getData","removeData"],"mappings":";;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EAEA,IAAMA,OAAO,GAAI,YAAM;EACrB,MAAMC,SAAS,GAAG,EAAlB;EACA,MAAIC,EAAE,GAAG,CAAT;EACA,SAAO;EACLC,IAAAA,GADK,eACDC,OADC,EACQC,GADR,EACaC,IADb,EACmB;EACtB,UAAI,OAAOF,OAAO,CAACG,KAAf,KAAyB,WAA7B,EAA0C;EACxCH,QAAAA,OAAO,CAACG,KAAR,GAAgB;EACdF,UAAAA,GAAG,EAAHA,GADc;EAEdH,UAAAA,EAAE,EAAFA;EAFc,SAAhB;EAIAA,QAAAA,EAAE;EACH;;EAEDD,MAAAA,SAAS,CAACG,OAAO,CAACG,KAAR,CAAcL,EAAf,CAAT,GAA8BI,IAA9B;EACD,KAXI;EAYLE,IAAAA,GAZK,eAYDJ,OAZC,EAYQC,GAZR,EAYa;EAChB,UAAI,CAACD,OAAD,IAAY,OAAOA,OAAO,CAACG,KAAf,KAAyB,WAAzC,EAAsD;EACpD,eAAO,IAAP;EACD;;EAED,UAAME,aAAa,GAAGL,OAAO,CAACG,KAA9B;;EACA,UAAIE,aAAa,CAACJ,GAAd,KAAsBA,GAA1B,EAA+B;EAC7B,eAAOJ,SAAS,CAACQ,aAAa,CAACP,EAAf,CAAhB;EACD;;EAED,aAAO,IAAP;EACD,KAvBI;EAwBLQ,IAAAA,MAxBK,mBAwBEN,OAxBF,EAwBWC,GAxBX,EAwBgB;EACnB,UAAI,OAAOD,OAAO,CAACG,KAAf,KAAyB,WAA7B,EAA0C;EACxC;EACD;;EAED,UAAME,aAAa,GAAGL,OAAO,CAACG,KAA9B;;EACA,UAAIE,aAAa,CAACJ,GAAd,KAAsBA,GAA1B,EAA+B;EAC7B,eAAOJ,SAAS,CAACQ,aAAa,CAACP,EAAf,CAAhB;EACA,eAAOE,OAAO,CAACG,KAAf;EACD;EACF;EAlCI,GAAP;EAoCD,CAvCe,EAAhB;;MAyCMI,IAAI,GAAG;EACXC,EAAAA,OADW,mBACHC,QADG,EACOR,GADP,EACYC,IADZ,EACkB;EAC3BN,IAAAA,OAAO,CAACG,GAAR,CAAYU,QAAZ,EAAsBR,GAAtB,EAA2BC,IAA3B;EACD,GAHU;EAIXQ,EAAAA,OAJW,mBAIHD,QAJG,EAIOR,GAJP,EAIY;EACrB,WAAOL,OAAO,CAACQ,GAAR,CAAYK,QAAZ,EAAsBR,GAAtB,CAAP;EACD,GANU;EAOXU,EAAAA,UAPW,sBAOAF,QAPA,EAOUR,GAPV,EAOe;EACxBL,IAAAA,OAAO,CAACU,MAAR,CAAeG,QAAf,EAAyBR,GAAzB;EACD;EATU;;;;;;;;"}
{"version":3,"file":"data.js","sources":["../../src/dom/data.js"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap (v5.0.0-alpha1): dom/data.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\n/**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\nconst mapData = (() => {\n const storeData = {}\n let id = 1\n return {\n set(element, key, data) {\n if (typeof element.key === 'undefined') {\n element.key = {\n key,\n id\n }\n id++\n }\n\n storeData[element.key.id] = data\n },\n get(element, key) {\n if (!element || typeof element.key === 'undefined') {\n return null\n }\n\n const keyProperties = element.key\n if (keyProperties.key === key) {\n return storeData[keyProperties.id]\n }\n\n return null\n },\n delete(element, key) {\n if (typeof element.key === 'undefined') {\n return\n }\n\n const keyProperties = element.key\n if (keyProperties.key === key) {\n delete storeData[keyProperties.id]\n delete element.key\n }\n }\n }\n})()\n\nconst Data = {\n setData(instance, key, data) {\n mapData.set(instance, key, data)\n },\n getData(instance, key) {\n return mapData.get(instance, key)\n },\n removeData(instance, key) {\n mapData.delete(instance, key)\n }\n}\n\nexport default Data\n"],"names":["mapData","storeData","id","set","element","key","data","get","keyProperties","delete","Data","setData","instance","getData","removeData"],"mappings":";;;;;;;;;;;EAAA;;;;;;;EAOA;;;;;EAMA,IAAMA,OAAO,GAAI,YAAM;EACrB,MAAMC,SAAS,GAAG,EAAlB;EACA,MAAIC,EAAE,GAAG,CAAT;EACA,SAAO;EACLC,IAAAA,GADK,eACDC,OADC,EACQC,GADR,EACaC,IADb,EACmB;EACtB,UAAI,OAAOF,OAAO,CAACC,GAAf,KAAuB,WAA3B,EAAwC;EACtCD,QAAAA,OAAO,CAACC,GAAR,GAAc;EACZA,UAAAA,GAAG,EAAHA,GADY;EAEZH,UAAAA,EAAE,EAAFA;EAFY,SAAd;EAIAA,QAAAA,EAAE;EACH;;EAEDD,MAAAA,SAAS,CAACG,OAAO,CAACC,GAAR,CAAYH,EAAb,CAAT,GAA4BI,IAA5B;EACD,KAXI;EAYLC,IAAAA,GAZK,eAYDH,OAZC,EAYQC,GAZR,EAYa;EAChB,UAAI,CAACD,OAAD,IAAY,OAAOA,OAAO,CAACC,GAAf,KAAuB,WAAvC,EAAoD;EAClD,eAAO,IAAP;EACD;;EAED,UAAMG,aAAa,GAAGJ,OAAO,CAACC,GAA9B;;EACA,UAAIG,aAAa,CAACH,GAAd,KAAsBA,GAA1B,EAA+B;EAC7B,eAAOJ,SAAS,CAACO,aAAa,CAACN,EAAf,CAAhB;EACD;;EAED,aAAO,IAAP;EACD,KAvBI;EAwBLO,IAAAA,MAxBK,mBAwBEL,OAxBF,EAwBWC,GAxBX,EAwBgB;EACnB,UAAI,OAAOD,OAAO,CAACC,GAAf,KAAuB,WAA3B,EAAwC;EACtC;EACD;;EAED,UAAMG,aAAa,GAAGJ,OAAO,CAACC,GAA9B;;EACA,UAAIG,aAAa,CAACH,GAAd,KAAsBA,GAA1B,EAA+B;EAC7B,eAAOJ,SAAS,CAACO,aAAa,CAACN,EAAf,CAAhB;EACA,eAAOE,OAAO,CAACC,GAAf;EACD;EACF;EAlCI,GAAP;EAoCD,CAvCe,EAAhB;;MAyCMK,IAAI,GAAG;EACXC,EAAAA,OADW,mBACHC,QADG,EACOP,GADP,EACYC,IADZ,EACkB;EAC3BN,IAAAA,OAAO,CAACG,GAAR,CAAYS,QAAZ,EAAsBP,GAAtB,EAA2BC,IAA3B;EACD,GAHU;EAIXO,EAAAA,OAJW,mBAIHD,QAJG,EAIOP,GAJP,EAIY;EACrB,WAAOL,OAAO,CAACO,GAAR,CAAYK,QAAZ,EAAsBP,GAAtB,CAAP;EACD,GANU;EAOXS,EAAAA,UAPW,sBAOAF,QAPA,EAOUP,GAPV,EAOe;EACxBL,IAAAA,OAAO,CAACS,MAAR,CAAeG,QAAf,EAAyBP,GAAzB;EACD;EATU;;;;;;;;"}

View File

@ -1,21 +1,20 @@
/*!
* Bootstrap event-handler.js v5.0.0-beta1 (https://getbootstrap.com/)
* Bootstrap event-handler.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined'
? (module.exports = factory())
? (module.exports = factory(require('./polyfill.js')))
: typeof define === 'function' && define.amd
? define(factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
(global.EventHandler = factory()));
})(this, function () {
? define(['./polyfill.js'], factory)
: ((global = global || self), (global.EventHandler = factory(global.Polyfill)));
})(this, function (polyfill_js) {
'use strict';
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/index.js
* Bootstrap (v5.0.0-alpha1): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -24,18 +23,16 @@
var _window = window,
jQuery = _window.jQuery;
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
return jQuery;
}
return null;
};
var isRTL = document.documentElement.dir === 'rtl';
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/event-handler.js
* Bootstrap (v5.0.0-alpha1): dom/event-handler.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -45,6 +42,7 @@
* ------------------------------------------------------------------------
*/
var $ = getjQuery();
var namespaceRegex = /[^.]*(?=\..*)\.|.*/;
var stripNameRegex = /\..*/;
var stripUidRegex = /::\d+$/;
@ -55,7 +53,7 @@
mouseenter: 'mouseover',
mouseleave: 'mouseout',
};
var nativeEvents = new Set([
var nativeEvents = [
'click',
'dblclick',
'mouseup',
@ -102,7 +100,7 @@
'error',
'abort',
'scroll',
]);
];
/**
* ------------------------------------------------------------------------
* Private methods
@ -122,8 +120,6 @@
function bootstrapHandler(element, fn) {
return function handler(event) {
event.delegateTarget = element;
if (handler.oneOff) {
EventHandler.off(element, event.type, fn);
}
@ -139,8 +135,6 @@
for (var target = event.target; target && target !== this; target = target.parentNode) {
for (var i = domElements.length; i--; ) {
if (domElements[i] === target) {
event.delegateTarget = target;
if (handler.oneOff) {
EventHandler.off(element, event.type, fn);
}
@ -183,7 +177,7 @@
typeEvent = custom;
}
var isNative = nativeEvents.has(typeEvent);
var isNative = nativeEvents.indexOf(typeEvent) > -1;
if (!isNative) {
typeEvent = originalTypeEvent;
@ -242,7 +236,7 @@
function removeNamespacedHandlers(element, events, typeEvent, namespace) {
var storeElementEvent = events[typeEvent] || {};
Object.keys(storeElementEvent).forEach(function (handlerKey) {
if (handlerKey.includes(namespace)) {
if (handlerKey.indexOf(namespace) > -1) {
var event = storeElementEvent[handlerKey];
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector);
}
@ -268,7 +262,7 @@
var inNamespace = typeEvent !== originalTypeEvent;
var events = getEvent(element);
var isNamespace = originalTypeEvent.startsWith('.');
var isNamespace = originalTypeEvent.charAt(0) === '.';
if (typeof originalHandler !== 'undefined') {
// Simplest case: handler is passed, remove that listener ONLY.
@ -290,7 +284,7 @@
Object.keys(storeElementEvent).forEach(function (keyHandlers) {
var handlerKey = keyHandlers.replace(stripUidRegex, '');
if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
if (!inNamespace || originalTypeEvent.indexOf(handlerKey) > -1) {
var event = storeElementEvent[keyHandlers];
removeHandler(
element,
@ -307,10 +301,9 @@
return null;
}
var $ = getjQuery();
var typeEvent = event.replace(stripNameRegex, '');
var inNamespace = event !== typeEvent;
var isNative = nativeEvents.has(typeEvent);
var isNative = nativeEvents.indexOf(typeEvent) > -1;
var jQueryEvent;
var bubbles = true;
var nativeDispatch = true;
@ -333,7 +326,7 @@
bubbles: bubbles,
cancelable: true,
});
} // merge custom information in our event
} // merge custom informations in our event
if (typeof args !== 'undefined') {
Object.keys(args).forEach(function (key) {
@ -347,6 +340,14 @@
if (defaultPrevented) {
evt.preventDefault();
if (!polyfill_js.defaultPreventedPreservedOnDispatch) {
Object.defineProperty(evt, 'defaultPrevented', {
get: function get() {
return true;
},
});
}
}
if (nativeDispatch) {

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*!
* Bootstrap manipulator.js v5.0.0-beta1 (https://getbootstrap.com/)
* Bootstrap manipulator.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
@ -8,14 +8,58 @@
? (module.exports = factory())
: typeof define === 'function' && define.amd
? define(factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
(global.Manipulator = factory()));
: ((global = global || self), (global.Manipulator = factory()));
})(this, function () {
'use strict';
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly)
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true,
});
} else {
obj[key] = value;
}
return obj;
}
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/manipulator.js
* Bootstrap (v5.0.0-alpha1): dom/manipulator.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -47,30 +91,25 @@
var Manipulator = {
setDataAttribute: function setDataAttribute(element, key, value) {
element.setAttribute('data-bs-' + normalizeDataKey(key), value);
element.setAttribute('data-' + normalizeDataKey(key), value);
},
removeDataAttribute: function removeDataAttribute(element, key) {
element.removeAttribute('data-bs-' + normalizeDataKey(key));
element.removeAttribute('data-' + normalizeDataKey(key));
},
getDataAttributes: function getDataAttributes(element) {
if (!element) {
return {};
}
var attributes = {};
Object.keys(element.dataset)
.filter(function (key) {
return key.startsWith('bs');
})
.forEach(function (key) {
var pureKey = key.replace(/^bs/, '');
pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
attributes[pureKey] = normalizeData(element.dataset[key]);
});
var attributes = _objectSpread({}, element.dataset);
Object.keys(attributes).forEach(function (key) {
attributes[key] = normalizeData(attributes[key]);
});
return attributes;
},
getDataAttribute: function getDataAttribute(element, key) {
return normalizeData(element.getAttribute('data-bs-' + normalizeDataKey(key)));
return normalizeData(element.getAttribute('data-' + normalizeDataKey(key)));
},
offset: function offset(element) {
var rect = element.getBoundingClientRect();
@ -85,6 +124,17 @@
left: element.offsetLeft,
};
},
toggleClass: function toggleClass(element, className) {
if (!element) {
return;
}
if (element.classList.contains(className)) {
element.classList.remove(className);
} else {
element.classList.add(className);
}
},
};
return Manipulator;

View File

@ -1 +1 @@
{"version":3,"file":"manipulator.js","sources":["../../src/dom/manipulator.js"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap (v5.0.0-beta1): dom/manipulator.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nfunction normalizeData(val) {\n if (val === 'true') {\n return true\n }\n\n if (val === 'false') {\n return false\n }\n\n if (val === Number(val).toString()) {\n return Number(val)\n }\n\n if (val === '' || val === 'null') {\n return null\n }\n\n return val\n}\n\nfunction normalizeDataKey(key) {\n return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`)\n}\n\nconst Manipulator = {\n setDataAttribute(element, key, value) {\n element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value)\n },\n\n removeDataAttribute(element, key) {\n element.removeAttribute(`data-bs-${normalizeDataKey(key)}`)\n },\n\n getDataAttributes(element) {\n if (!element) {\n return {}\n }\n\n const attributes = {}\n\n Object.keys(element.dataset)\n .filter(key => key.startsWith('bs'))\n .forEach(key => {\n let pureKey = key.replace(/^bs/, '')\n pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length)\n attributes[pureKey] = normalizeData(element.dataset[key])\n })\n\n return attributes\n },\n\n getDataAttribute(element, key) {\n return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`))\n },\n\n offset(element) {\n const rect = element.getBoundingClientRect()\n\n return {\n top: rect.top + document.body.scrollTop,\n left: rect.left + document.body.scrollLeft\n }\n },\n\n position(element) {\n return {\n top: element.offsetTop,\n left: element.offsetLeft\n }\n }\n}\n\nexport default Manipulator\n"],"names":["normalizeData","val","Number","toString","normalizeDataKey","key","replace","chr","toLowerCase","Manipulator","setDataAttribute","element","value","setAttribute","removeDataAttribute","removeAttribute","getDataAttributes","attributes","Object","keys","dataset","filter","startsWith","forEach","pureKey","charAt","slice","length","getDataAttribute","getAttribute","offset","rect","getBoundingClientRect","top","document","body","scrollTop","left","scrollLeft","position","offsetTop","offsetLeft"],"mappings":";;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;EACA;EAEA,SAASA,aAAT,CAAuBC,GAAvB,EAA4B;EAC1B,MAAIA,GAAG,KAAK,MAAZ,EAAoB;EAClB,WAAO,IAAP;EACD;;EAED,MAAIA,GAAG,KAAK,OAAZ,EAAqB;EACnB,WAAO,KAAP;EACD;;EAED,MAAIA,GAAG,KAAKC,MAAM,CAACD,GAAD,CAAN,CAAYE,QAAZ,EAAZ,EAAoC;EAClC,WAAOD,MAAM,CAACD,GAAD,CAAb;EACD;;EAED,MAAIA,GAAG,KAAK,EAAR,IAAcA,GAAG,KAAK,MAA1B,EAAkC;EAChC,WAAO,IAAP;EACD;;EAED,SAAOA,GAAP;EACD;;EAED,SAASG,gBAAT,CAA0BC,GAA1B,EAA+B;EAC7B,SAAOA,GAAG,CAACC,OAAJ,CAAY,QAAZ,EAAsB,UAAAC,GAAG;EAAA,iBAAQA,GAAG,CAACC,WAAJ,EAAR;EAAA,GAAzB,CAAP;EACD;;MAEKC,WAAW,GAAG;EAClBC,EAAAA,gBADkB,4BACDC,OADC,EACQN,GADR,EACaO,KADb,EACoB;EACpCD,IAAAA,OAAO,CAACE,YAAR,cAAgCT,gBAAgB,CAACC,GAAD,CAAhD,EAAyDO,KAAzD;EACD,GAHiB;EAKlBE,EAAAA,mBALkB,+BAKEH,OALF,EAKWN,GALX,EAKgB;EAChCM,IAAAA,OAAO,CAACI,eAAR,cAAmCX,gBAAgB,CAACC,GAAD,CAAnD;EACD,GAPiB;EASlBW,EAAAA,iBATkB,6BASAL,OATA,EASS;EACzB,QAAI,CAACA,OAAL,EAAc;EACZ,aAAO,EAAP;EACD;;EAED,QAAMM,UAAU,GAAG,EAAnB;EAEAC,IAAAA,MAAM,CAACC,IAAP,CAAYR,OAAO,CAACS,OAApB,EACGC,MADH,CACU,UAAAhB,GAAG;EAAA,aAAIA,GAAG,CAACiB,UAAJ,CAAe,IAAf,CAAJ;EAAA,KADb,EAEGC,OAFH,CAEW,UAAAlB,GAAG,EAAI;EACd,UAAImB,OAAO,GAAGnB,GAAG,CAACC,OAAJ,CAAY,KAAZ,EAAmB,EAAnB,CAAd;EACAkB,MAAAA,OAAO,GAAGA,OAAO,CAACC,MAAR,CAAe,CAAf,EAAkBjB,WAAlB,KAAkCgB,OAAO,CAACE,KAAR,CAAc,CAAd,EAAiBF,OAAO,CAACG,MAAzB,CAA5C;EACAV,MAAAA,UAAU,CAACO,OAAD,CAAV,GAAsBxB,aAAa,CAACW,OAAO,CAACS,OAAR,CAAgBf,GAAhB,CAAD,CAAnC;EACD,KANH;EAQA,WAAOY,UAAP;EACD,GAzBiB;EA2BlBW,EAAAA,gBA3BkB,4BA2BDjB,OA3BC,EA2BQN,GA3BR,EA2Ba;EAC7B,WAAOL,aAAa,CAACW,OAAO,CAACkB,YAAR,cAAgCzB,gBAAgB,CAACC,GAAD,CAAhD,CAAD,CAApB;EACD,GA7BiB;EA+BlByB,EAAAA,MA/BkB,kBA+BXnB,OA/BW,EA+BF;EACd,QAAMoB,IAAI,GAAGpB,OAAO,CAACqB,qBAAR,EAAb;EAEA,WAAO;EACLC,MAAAA,GAAG,EAAEF,IAAI,CAACE,GAAL,GAAWC,QAAQ,CAACC,IAAT,CAAcC,SADzB;EAELC,MAAAA,IAAI,EAAEN,IAAI,CAACM,IAAL,GAAYH,QAAQ,CAACC,IAAT,CAAcG;EAF3B,KAAP;EAID,GAtCiB;EAwClBC,EAAAA,QAxCkB,oBAwCT5B,OAxCS,EAwCA;EAChB,WAAO;EACLsB,MAAAA,GAAG,EAAEtB,OAAO,CAAC6B,SADR;EAELH,MAAAA,IAAI,EAAE1B,OAAO,CAAC8B;EAFT,KAAP;EAID;EA7CiB;;;;;;;;"}
{"version":3,"file":"manipulator.js","sources":["../../src/dom/manipulator.js"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap (v5.0.0-alpha1): dom/manipulator.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nfunction normalizeData(val) {\n if (val === 'true') {\n return true\n }\n\n if (val === 'false') {\n return false\n }\n\n if (val === Number(val).toString()) {\n return Number(val)\n }\n\n if (val === '' || val === 'null') {\n return null\n }\n\n return val\n}\n\nfunction normalizeDataKey(key) {\n return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`)\n}\n\nconst Manipulator = {\n setDataAttribute(element, key, value) {\n element.setAttribute(`data-${normalizeDataKey(key)}`, value)\n },\n\n removeDataAttribute(element, key) {\n element.removeAttribute(`data-${normalizeDataKey(key)}`)\n },\n\n getDataAttributes(element) {\n if (!element) {\n return {}\n }\n\n const attributes = {\n ...element.dataset\n }\n\n Object.keys(attributes).forEach(key => {\n attributes[key] = normalizeData(attributes[key])\n })\n\n return attributes\n },\n\n getDataAttribute(element, key) {\n return normalizeData(element.getAttribute(`data-${normalizeDataKey(key)}`))\n },\n\n offset(element) {\n const rect = element.getBoundingClientRect()\n\n return {\n top: rect.top + document.body.scrollTop,\n left: rect.left + document.body.scrollLeft\n }\n },\n\n position(element) {\n return {\n top: element.offsetTop,\n left: element.offsetLeft\n }\n },\n\n toggleClass(element, className) {\n if (!element) {\n return\n }\n\n if (element.classList.contains(className)) {\n element.classList.remove(className)\n } else {\n element.classList.add(className)\n }\n }\n}\n\nexport default Manipulator\n"],"names":["normalizeData","val","Number","toString","normalizeDataKey","key","replace","chr","toLowerCase","Manipulator","setDataAttribute","element","value","setAttribute","removeDataAttribute","removeAttribute","getDataAttributes","attributes","dataset","Object","keys","forEach","getDataAttribute","getAttribute","offset","rect","getBoundingClientRect","top","document","body","scrollTop","left","scrollLeft","position","offsetTop","offsetLeft","toggleClass","className","classList","contains","remove","add"],"mappings":";;;;;;;;;;;;;;;;;EAAA;;;;;;EAOA,SAASA,aAAT,CAAuBC,GAAvB,EAA4B;EAC1B,MAAIA,GAAG,KAAK,MAAZ,EAAoB;EAClB,WAAO,IAAP;EACD;;EAED,MAAIA,GAAG,KAAK,OAAZ,EAAqB;EACnB,WAAO,KAAP;EACD;;EAED,MAAIA,GAAG,KAAKC,MAAM,CAACD,GAAD,CAAN,CAAYE,QAAZ,EAAZ,EAAoC;EAClC,WAAOD,MAAM,CAACD,GAAD,CAAb;EACD;;EAED,MAAIA,GAAG,KAAK,EAAR,IAAcA,GAAG,KAAK,MAA1B,EAAkC;EAChC,WAAO,IAAP;EACD;;EAED,SAAOA,GAAP;EACD;;EAED,SAASG,gBAAT,CAA0BC,GAA1B,EAA+B;EAC7B,SAAOA,GAAG,CAACC,OAAJ,CAAY,QAAZ,EAAsB,UAAAC,GAAG;EAAA,iBAAQA,GAAG,CAACC,WAAJ,EAAR;EAAA,GAAzB,CAAP;EACD;;MAEKC,WAAW,GAAG;EAClBC,EAAAA,gBADkB,4BACDC,OADC,EACQN,GADR,EACaO,KADb,EACoB;EACpCD,IAAAA,OAAO,CAACE,YAAR,WAA6BT,gBAAgB,CAACC,GAAD,CAA7C,EAAsDO,KAAtD;EACD,GAHiB;EAKlBE,EAAAA,mBALkB,+BAKEH,OALF,EAKWN,GALX,EAKgB;EAChCM,IAAAA,OAAO,CAACI,eAAR,WAAgCX,gBAAgB,CAACC,GAAD,CAAhD;EACD,GAPiB;EASlBW,EAAAA,iBATkB,6BASAL,OATA,EASS;EACzB,QAAI,CAACA,OAAL,EAAc;EACZ,aAAO,EAAP;EACD;;EAED,QAAMM,UAAU,qBACXN,OAAO,CAACO,OADG,CAAhB;;EAIAC,IAAAA,MAAM,CAACC,IAAP,CAAYH,UAAZ,EAAwBI,OAAxB,CAAgC,UAAAhB,GAAG,EAAI;EACrCY,MAAAA,UAAU,CAACZ,GAAD,CAAV,GAAkBL,aAAa,CAACiB,UAAU,CAACZ,GAAD,CAAX,CAA/B;EACD,KAFD;EAIA,WAAOY,UAAP;EACD,GAvBiB;EAyBlBK,EAAAA,gBAzBkB,4BAyBDX,OAzBC,EAyBQN,GAzBR,EAyBa;EAC7B,WAAOL,aAAa,CAACW,OAAO,CAACY,YAAR,WAA6BnB,gBAAgB,CAACC,GAAD,CAA7C,CAAD,CAApB;EACD,GA3BiB;EA6BlBmB,EAAAA,MA7BkB,kBA6BXb,OA7BW,EA6BF;EACd,QAAMc,IAAI,GAAGd,OAAO,CAACe,qBAAR,EAAb;EAEA,WAAO;EACLC,MAAAA,GAAG,EAAEF,IAAI,CAACE,GAAL,GAAWC,QAAQ,CAACC,IAAT,CAAcC,SADzB;EAELC,MAAAA,IAAI,EAAEN,IAAI,CAACM,IAAL,GAAYH,QAAQ,CAACC,IAAT,CAAcG;EAF3B,KAAP;EAID,GApCiB;EAsClBC,EAAAA,QAtCkB,oBAsCTtB,OAtCS,EAsCA;EAChB,WAAO;EACLgB,MAAAA,GAAG,EAAEhB,OAAO,CAACuB,SADR;EAELH,MAAAA,IAAI,EAAEpB,OAAO,CAACwB;EAFT,KAAP;EAID,GA3CiB;EA6ClBC,EAAAA,WA7CkB,uBA6CNzB,OA7CM,EA6CG0B,SA7CH,EA6Cc;EAC9B,QAAI,CAAC1B,OAAL,EAAc;EACZ;EACD;;EAED,QAAIA,OAAO,CAAC2B,SAAR,CAAkBC,QAAlB,CAA2BF,SAA3B,CAAJ,EAA2C;EACzC1B,MAAAA,OAAO,CAAC2B,SAAR,CAAkBE,MAAlB,CAAyBH,SAAzB;EACD,KAFD,MAEO;EACL1B,MAAAA,OAAO,CAAC2B,SAAR,CAAkBG,GAAlB,CAAsBJ,SAAtB;EACD;EACF;EAvDiB;;;;;;;;"}

112
src/js/bootstrap/dist/dom/polyfill.js vendored Normal file
View File

@ -0,0 +1,112 @@
/*!
* Bootstrap polyfill.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined'
? factory(exports)
: typeof define === 'function' && define.amd
? define(['exports'], factory)
: ((global = global || self), factory((global.Polyfill = {})));
})(this, function (exports) {
'use strict';
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-alpha1): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var MAX_UID = 1000000;
/**
* --------------------------------------------------------------------------
* Public Util Api
* --------------------------------------------------------------------------
*/
var getUID = function getUID(prefix) {
do {
prefix += Math.floor(Math.random() * MAX_UID);
} while (document.getElementById(prefix));
return prefix;
};
/* istanbul ignore file */
exports.find = Element.prototype.querySelectorAll;
exports.findOne = Element.prototype.querySelector; // MSEdge resets defaultPrevented flag upon dispatchEvent call if at least one listener is attached
var defaultPreventedPreservedOnDispatch = (function () {
var e = new CustomEvent('Bootstrap', {
cancelable: true,
});
var element = document.createElement('div');
element.addEventListener('Bootstrap', function () {
return null;
});
e.preventDefault();
element.dispatchEvent(e);
return e.defaultPrevented;
})();
var scopeSelectorRegex = /:scope\b/;
var supportScopeQuery = (function () {
var element = document.createElement('div');
try {
element.querySelectorAll(':scope *');
} catch (_) {
return false;
}
return true;
})();
if (!supportScopeQuery) {
exports.find = function find(selector) {
if (!scopeSelectorRegex.test(selector)) {
return this.querySelectorAll(selector);
}
var hasId = Boolean(this.id);
if (!hasId) {
this.id = getUID('scope');
}
var nodeList = null;
try {
selector = selector.replace(scopeSelectorRegex, '#' + this.id);
nodeList = this.querySelectorAll(selector);
} finally {
if (!hasId) {
this.removeAttribute('id');
}
}
return nodeList;
};
exports.findOne = function findOne(selector) {
if (!scopeSelectorRegex.test(selector)) {
return this.querySelector(selector);
}
var matches = exports.find.call(this, selector);
if (typeof matches[0] !== 'undefined') {
return matches[0];
}
return null;
};
}
exports.defaultPreventedPreservedOnDispatch = defaultPreventedPreservedOnDispatch;
Object.defineProperty(exports, '__esModule', { value: true });
});
//# sourceMappingURL=polyfill.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,30 +1,29 @@
/*!
* Bootstrap selector-engine.js v5.0.0-beta1 (https://getbootstrap.com/)
* Bootstrap selector-engine.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined'
? (module.exports = factory())
? (module.exports = factory(require('./polyfill.js')))
: typeof define === 'function' && define.amd
? define(factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
(global.SelectorEngine = factory()));
})(this, function () {
? define(['./polyfill.js'], factory)
: ((global = global || self), (global.SelectorEngine = factory(global.Polyfill)));
})(this, function (polyfill_js) {
'use strict';
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/selector-engine.js
* Bootstrap (v5.0.0-alpha1): dom/selector-engine.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NODE_TEXT = 3;
var SelectorEngine = {
matches: function matches(element, selector) {
@ -37,17 +36,14 @@
element = document.documentElement;
}
return (_ref = []).concat.apply(
_ref,
Element.prototype.querySelectorAll.call(element, selector)
);
return (_ref = []).concat.apply(_ref, polyfill_js.find.call(element, selector));
},
findOne: function findOne(selector, element) {
if (element === void 0) {
element = document.documentElement;
}
return Element.prototype.querySelector.call(element, selector);
return polyfill_js.findOne.call(element, selector);
},
children: function children(element, selector) {
var _ref2;

View File

@ -1 +1 @@
{"version":3,"file":"selector-engine.js","sources":["../../src/dom/selector-engine.js"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap (v5.0.0-beta1): dom/selector-engine.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\n/**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\nconst NODE_TEXT = 3\n\nconst SelectorEngine = {\n matches(element, selector) {\n return element.matches(selector)\n },\n\n find(selector, element = document.documentElement) {\n return [].concat(...Element.prototype.querySelectorAll.call(element, selector))\n },\n\n findOne(selector, element = document.documentElement) {\n return Element.prototype.querySelector.call(element, selector)\n },\n\n children(element, selector) {\n const children = [].concat(...element.children)\n\n return children.filter(child => child.matches(selector))\n },\n\n parents(element, selector) {\n const parents = []\n\n let ancestor = element.parentNode\n\n while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {\n if (this.matches(ancestor, selector)) {\n parents.push(ancestor)\n }\n\n ancestor = ancestor.parentNode\n }\n\n return parents\n },\n\n prev(element, selector) {\n let previous = element.previousElementSibling\n\n while (previous) {\n if (previous.matches(selector)) {\n return [previous]\n }\n\n previous = previous.previousElementSibling\n }\n\n return []\n },\n\n next(element, selector) {\n let next = element.nextElementSibling\n\n while (next) {\n if (this.matches(next, selector)) {\n return [next]\n }\n\n next = next.nextElementSibling\n }\n\n return []\n }\n}\n\nexport default SelectorEngine\n"],"names":["NODE_TEXT","SelectorEngine","matches","element","selector","find","document","documentElement","concat","Element","prototype","querySelectorAll","call","findOne","querySelector","children","filter","child","parents","ancestor","parentNode","nodeType","Node","ELEMENT_NODE","push","prev","previous","previousElementSibling","next","nextElementSibling"],"mappings":";;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EAEA,IAAMA,SAAS,GAAG,CAAlB;MAEMC,cAAc,GAAG;EACrBC,EAAAA,OADqB,mBACbC,OADa,EACJC,QADI,EACM;EACzB,WAAOD,OAAO,CAACD,OAAR,CAAgBE,QAAhB,CAAP;EACD,GAHoB;EAKrBC,EAAAA,IALqB,gBAKhBD,QALgB,EAKND,OALM,EAK8B;EAAA;;EAAA,QAApCA,OAAoC;EAApCA,MAAAA,OAAoC,GAA1BG,QAAQ,CAACC,eAAiB;EAAA;;EACjD,WAAO,YAAGC,MAAH,aAAaC,OAAO,CAACC,SAAR,CAAkBC,gBAAlB,CAAmCC,IAAnC,CAAwCT,OAAxC,EAAiDC,QAAjD,CAAb,CAAP;EACD,GAPoB;EASrBS,EAAAA,OATqB,mBASbT,QATa,EASHD,OATG,EASiC;EAAA,QAApCA,OAAoC;EAApCA,MAAAA,OAAoC,GAA1BG,QAAQ,CAACC,eAAiB;EAAA;;EACpD,WAAOE,OAAO,CAACC,SAAR,CAAkBI,aAAlB,CAAgCF,IAAhC,CAAqCT,OAArC,EAA8CC,QAA9C,CAAP;EACD,GAXoB;EAarBW,EAAAA,QAbqB,oBAaZZ,OAbY,EAaHC,QAbG,EAaO;EAAA;;EAC1B,QAAMW,QAAQ,GAAG,aAAGP,MAAH,cAAaL,OAAO,CAACY,QAArB,CAAjB;;EAEA,WAAOA,QAAQ,CAACC,MAAT,CAAgB,UAAAC,KAAK;EAAA,aAAIA,KAAK,CAACf,OAAN,CAAcE,QAAd,CAAJ;EAAA,KAArB,CAAP;EACD,GAjBoB;EAmBrBc,EAAAA,OAnBqB,mBAmBbf,OAnBa,EAmBJC,QAnBI,EAmBM;EACzB,QAAMc,OAAO,GAAG,EAAhB;EAEA,QAAIC,QAAQ,GAAGhB,OAAO,CAACiB,UAAvB;;EAEA,WAAOD,QAAQ,IAAIA,QAAQ,CAACE,QAAT,KAAsBC,IAAI,CAACC,YAAvC,IAAuDJ,QAAQ,CAACE,QAAT,KAAsBrB,SAApF,EAA+F;EAC7F,UAAI,KAAKE,OAAL,CAAaiB,QAAb,EAAuBf,QAAvB,CAAJ,EAAsC;EACpCc,QAAAA,OAAO,CAACM,IAAR,CAAaL,QAAb;EACD;;EAEDA,MAAAA,QAAQ,GAAGA,QAAQ,CAACC,UAApB;EACD;;EAED,WAAOF,OAAP;EACD,GAjCoB;EAmCrBO,EAAAA,IAnCqB,gBAmChBtB,OAnCgB,EAmCPC,QAnCO,EAmCG;EACtB,QAAIsB,QAAQ,GAAGvB,OAAO,CAACwB,sBAAvB;;EAEA,WAAOD,QAAP,EAAiB;EACf,UAAIA,QAAQ,CAACxB,OAAT,CAAiBE,QAAjB,CAAJ,EAAgC;EAC9B,eAAO,CAACsB,QAAD,CAAP;EACD;;EAEDA,MAAAA,QAAQ,GAAGA,QAAQ,CAACC,sBAApB;EACD;;EAED,WAAO,EAAP;EACD,GA/CoB;EAiDrBC,EAAAA,IAjDqB,gBAiDhBzB,OAjDgB,EAiDPC,QAjDO,EAiDG;EACtB,QAAIwB,IAAI,GAAGzB,OAAO,CAAC0B,kBAAnB;;EAEA,WAAOD,IAAP,EAAa;EACX,UAAI,KAAK1B,OAAL,CAAa0B,IAAb,EAAmBxB,QAAnB,CAAJ,EAAkC;EAChC,eAAO,CAACwB,IAAD,CAAP;EACD;;EAEDA,MAAAA,IAAI,GAAGA,IAAI,CAACC,kBAAZ;EACD;;EAED,WAAO,EAAP;EACD;EA7DoB;;;;;;;;"}
{"version":3,"file":"selector-engine.js","sources":["../../src/dom/selector-engine.js"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap (v5.0.0-alpha1): dom/selector-engine.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport { find as findFn, findOne } from './polyfill'\n\n/**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\nconst NODE_TEXT = 3\n\nconst SelectorEngine = {\n matches(element, selector) {\n return element.matches(selector)\n },\n\n find(selector, element = document.documentElement) {\n return [].concat(...findFn.call(element, selector))\n },\n\n findOne(selector, element = document.documentElement) {\n return findOne.call(element, selector)\n },\n\n children(element, selector) {\n const children = [].concat(...element.children)\n\n return children.filter(child => child.matches(selector))\n },\n\n parents(element, selector) {\n const parents = []\n\n let ancestor = element.parentNode\n\n while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {\n if (this.matches(ancestor, selector)) {\n parents.push(ancestor)\n }\n\n ancestor = ancestor.parentNode\n }\n\n return parents\n },\n\n prev(element, selector) {\n let previous = element.previousElementSibling\n\n while (previous) {\n if (previous.matches(selector)) {\n return [previous]\n }\n\n previous = previous.previousElementSibling\n }\n\n return []\n },\n\n next(element, selector) {\n let next = element.nextElementSibling\n\n while (next) {\n if (this.matches(next, selector)) {\n return [next]\n }\n\n next = next.nextElementSibling\n }\n\n return []\n }\n}\n\nexport default SelectorEngine\n"],"names":["NODE_TEXT","SelectorEngine","matches","element","selector","find","document","documentElement","concat","findFn","call","findOne","children","filter","child","parents","ancestor","parentNode","nodeType","Node","ELEMENT_NODE","push","prev","previous","previousElementSibling","next","nextElementSibling"],"mappings":";;;;;;;;;;;EAAA;;;;;;EASA;;;;;;EAMA,IAAMA,SAAS,GAAG,CAAlB;MAEMC,cAAc,GAAG;EACrBC,EAAAA,OADqB,mBACbC,OADa,EACJC,QADI,EACM;EACzB,WAAOD,OAAO,CAACD,OAAR,CAAgBE,QAAhB,CAAP;EACD,GAHoB;EAKrBC,EAAAA,IALqB,gBAKhBD,QALgB,EAKND,OALM,EAK8B;EAAA;;EAAA,QAApCA,OAAoC;EAApCA,MAAAA,OAAoC,GAA1BG,QAAQ,CAACC,eAAiB;EAAA;;EACjD,WAAO,YAAGC,MAAH,aAAaC,gBAAM,CAACC,IAAP,CAAYP,OAAZ,EAAqBC,QAArB,CAAb,CAAP;EACD,GAPoB;EASrBO,EAAAA,OATqB,mBASbP,QATa,EASHD,OATG,EASiC;EAAA,QAApCA,OAAoC;EAApCA,MAAAA,OAAoC,GAA1BG,QAAQ,CAACC,eAAiB;EAAA;;EACpD,WAAOI,mBAAO,CAACD,IAAR,CAAaP,OAAb,EAAsBC,QAAtB,CAAP;EACD,GAXoB;EAarBQ,EAAAA,QAbqB,oBAaZT,OAbY,EAaHC,QAbG,EAaO;EAAA;;EAC1B,QAAMQ,QAAQ,GAAG,aAAGJ,MAAH,cAAaL,OAAO,CAACS,QAArB,CAAjB;;EAEA,WAAOA,QAAQ,CAACC,MAAT,CAAgB,UAAAC,KAAK;EAAA,aAAIA,KAAK,CAACZ,OAAN,CAAcE,QAAd,CAAJ;EAAA,KAArB,CAAP;EACD,GAjBoB;EAmBrBW,EAAAA,OAnBqB,mBAmBbZ,OAnBa,EAmBJC,QAnBI,EAmBM;EACzB,QAAMW,OAAO,GAAG,EAAhB;EAEA,QAAIC,QAAQ,GAAGb,OAAO,CAACc,UAAvB;;EAEA,WAAOD,QAAQ,IAAIA,QAAQ,CAACE,QAAT,KAAsBC,IAAI,CAACC,YAAvC,IAAuDJ,QAAQ,CAACE,QAAT,KAAsBlB,SAApF,EAA+F;EAC7F,UAAI,KAAKE,OAAL,CAAac,QAAb,EAAuBZ,QAAvB,CAAJ,EAAsC;EACpCW,QAAAA,OAAO,CAACM,IAAR,CAAaL,QAAb;EACD;;EAEDA,MAAAA,QAAQ,GAAGA,QAAQ,CAACC,UAApB;EACD;;EAED,WAAOF,OAAP;EACD,GAjCoB;EAmCrBO,EAAAA,IAnCqB,gBAmChBnB,OAnCgB,EAmCPC,QAnCO,EAmCG;EACtB,QAAImB,QAAQ,GAAGpB,OAAO,CAACqB,sBAAvB;;EAEA,WAAOD,QAAP,EAAiB;EACf,UAAIA,QAAQ,CAACrB,OAAT,CAAiBE,QAAjB,CAAJ,EAAgC;EAC9B,eAAO,CAACmB,QAAD,CAAP;EACD;;EAEDA,MAAAA,QAAQ,GAAGA,QAAQ,CAACC,sBAApB;EACD;;EAED,WAAO,EAAP;EACD,GA/CoB;EAiDrBC,EAAAA,IAjDqB,gBAiDhBtB,OAjDgB,EAiDPC,QAjDO,EAiDG;EACtB,QAAIqB,IAAI,GAAGtB,OAAO,CAACuB,kBAAnB;;EAEA,WAAOD,IAAP,EAAa;EACX,UAAI,KAAKvB,OAAL,CAAauB,IAAb,EAAmBrB,QAAnB,CAAJ,EAAkC;EAChC,eAAO,CAACqB,IAAD,CAAP;EACD;;EAEDA,MAAAA,IAAI,GAAGA,IAAI,CAACC,kBAAZ;EACD;;EAED,WAAO,EAAP;EACD;EA7DoB;;;;;;;;"}

View File

@ -1,75 +1,55 @@
/*!
* Bootstrap dropdown.js v5.0.0-beta1 (https://getbootstrap.com/)
* Bootstrap dropdown.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined'
? (module.exports = factory(
require('@popperjs/core'),
require('./dom/data.js'),
require('./dom/event-handler.js'),
require('./dom/manipulator.js'),
require('popper.js'),
require('./dom/selector-engine.js')
))
: typeof define === 'function' && define.amd
? define([
'@popperjs/core',
'./dom/data',
'./dom/event-handler',
'./dom/manipulator',
'./dom/selector-engine',
'./dom/data.js',
'./dom/event-handler.js',
'./dom/manipulator.js',
'popper.js',
'./dom/selector-engine.js',
], factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
: ((global = global || self),
(global.Dropdown = factory(
global.Popper,
global.Data,
global.EventHandler,
global.Manipulator,
global.Popper,
global.SelectorEngine
)));
})(this, function (Popper, Data, EventHandler, Manipulator, SelectorEngine) {
})(this, function (Data, EventHandler, Manipulator, Popper, SelectorEngine) {
'use strict';
function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : { default: e };
}
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(
n,
k,
d.get
? d
: {
enumerable: true,
get: function () {
return e[k];
},
}
);
}
});
}
n['default'] = e;
return Object.freeze(n);
}
var Popper__namespace = /*#__PURE__*/ _interopNamespace(Popper);
var Data__default = /*#__PURE__*/ _interopDefaultLegacy(Data);
var EventHandler__default = /*#__PURE__*/ _interopDefaultLegacy(EventHandler);
var Manipulator__default = /*#__PURE__*/ _interopDefaultLegacy(Manipulator);
var SelectorEngine__default = /*#__PURE__*/ _interopDefaultLegacy(SelectorEngine);
Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data;
EventHandler =
EventHandler && Object.prototype.hasOwnProperty.call(EventHandler, 'default')
? EventHandler['default']
: EventHandler;
Manipulator =
Manipulator && Object.prototype.hasOwnProperty.call(Manipulator, 'default')
? Manipulator['default']
: Manipulator;
Popper =
Popper && Object.prototype.hasOwnProperty.call(Popper, 'default') ? Popper['default'] : Popper;
SelectorEngine =
SelectorEngine && Object.prototype.hasOwnProperty.call(SelectorEngine, 'default')
? SelectorEngine['default']
: SelectorEngine;
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/index.js
* Bootstrap (v5.0.0-alpha1): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -86,7 +66,7 @@
};
var getSelector = function getSelector(element) {
var selector = element.getAttribute('data-bs-target');
var selector = element.getAttribute('data-target');
if (!selector || selector === '#') {
var hrefAttr = element.getAttribute('href');
@ -148,22 +128,57 @@
var _window = window,
jQuery = _window.jQuery;
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
return jQuery;
}
return null;
};
var onDOMContentLoaded = function onDOMContentLoaded(callback) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callback);
} else {
callback();
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly)
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
};
return keys;
}
var isRTL = document.documentElement.dir === 'rtl';
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true,
});
} else {
obj[key] = value;
}
return obj;
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
@ -186,87 +201,8 @@
* ------------------------------------------------------------------------
*/
var VERSION = '5.0.0-beta1';
var BaseComponent = /*#__PURE__*/ (function () {
function BaseComponent(element) {
if (!element) {
return;
}
this._element = element;
Data__default['default'].setData(element, this.constructor.DATA_KEY, this);
}
var _proto = BaseComponent.prototype;
_proto.dispose = function dispose() {
Data__default['default'].removeData(this._element, this.constructor.DATA_KEY);
this._element = null;
};
/** Static */
BaseComponent.getInstance = function getInstance(element) {
return Data__default['default'].getData(element, this.DATA_KEY);
};
_createClass(BaseComponent, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
]);
return BaseComponent;
})();
function _extends() {
_extends =
Object.assign ||
function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _defineProperties$1(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass$1(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
if (staticProps) _defineProperties$1(Constructor, staticProps);
return Constructor;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'dropdown';
var VERSION = '5.0.0-alpha1';
var DATA_KEY = 'bs.dropdown';
var EVENT_KEY = '.' + DATA_KEY;
var DATA_API_KEY = '.data-api';
@ -289,24 +225,26 @@
var CLASS_NAME_DISABLED = 'disabled';
var CLASS_NAME_SHOW = 'show';
var CLASS_NAME_DROPUP = 'dropup';
var CLASS_NAME_DROPEND = 'dropend';
var CLASS_NAME_DROPSTART = 'dropstart';
var CLASS_NAME_DROPRIGHT = 'dropright';
var CLASS_NAME_DROPLEFT = 'dropleft';
var CLASS_NAME_MENURIGHT = 'dropdown-menu-right';
var CLASS_NAME_NAVBAR = 'navbar';
var SELECTOR_DATA_TOGGLE = '[data-bs-toggle="dropdown"]';
var CLASS_NAME_POSITION_STATIC = 'position-static';
var SELECTOR_DATA_TOGGLE = '[data-toggle="dropdown"]';
var SELECTOR_FORM_CHILD = '.dropdown form';
var SELECTOR_MENU = '.dropdown-menu';
var SELECTOR_NAVBAR_NAV = '.navbar-nav';
var SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
var PLACEMENT_TOP = isRTL ? 'top-end' : 'top-start';
var PLACEMENT_TOPEND = isRTL ? 'top-start' : 'top-end';
var PLACEMENT_BOTTOM = isRTL ? 'bottom-end' : 'bottom-start';
var PLACEMENT_BOTTOMEND = isRTL ? 'bottom-start' : 'bottom-end';
var PLACEMENT_RIGHT = isRTL ? 'left-start' : 'right-start';
var PLACEMENT_LEFT = isRTL ? 'right-start' : 'left-start';
var PLACEMENT_TOP = 'top-start';
var PLACEMENT_TOPEND = 'top-end';
var PLACEMENT_BOTTOM = 'bottom-start';
var PLACEMENT_BOTTOMEND = 'bottom-end';
var PLACEMENT_RIGHT = 'right-start';
var PLACEMENT_LEFT = 'left-start';
var Default = {
offset: 0,
flip: true,
boundary: 'clippingParents',
boundary: 'scrollParent',
reference: 'toggle',
display: 'dynamic',
popperConfig: null,
@ -325,21 +263,17 @@
* ------------------------------------------------------------------------
*/
var Dropdown = /*#__PURE__*/ (function (_BaseComponent) {
_inheritsLoose(Dropdown, _BaseComponent);
var Dropdown = /*#__PURE__*/ (function () {
function Dropdown(element, config) {
var _this;
this._element = element;
this._popper = null;
this._config = this._getConfig(config);
this._menu = this._getMenuElement();
this._inNavbar = this._detectNavbar();
_this = _BaseComponent.call(this, element) || this;
_this._popper = null;
_this._config = _this._getConfig(config);
_this._menu = _this._getMenuElement();
_this._inNavbar = _this._detectNavbar();
this._addEventListeners();
_this._addEventListeners();
return _this;
Data.setData(element, DATA_KEY, this);
} // Getters
var _proto = Dropdown.prototype;
@ -374,19 +308,15 @@
var relatedTarget = {
relatedTarget: this._element,
};
var showEvent = EventHandler__default['default'].trigger(
this._element,
EVENT_SHOW,
relatedTarget
);
var showEvent = EventHandler.trigger(this._element, EVENT_SHOW, relatedTarget);
if (showEvent.defaultPrevented) {
return;
} // Totally disable Popper for Dropdowns in Navbar
} // Disable totally Popper.js for Dropdown in Navbar
if (!this._inNavbar) {
if (typeof Popper__namespace === 'undefined') {
throw new TypeError("Bootstrap's dropdowns require Popper (https://popper.js.org)");
if (typeof Popper === 'undefined') {
throw new TypeError("Bootstrap's dropdowns require Popper.js (https://popper.js.org)");
}
var referenceElement = this._element;
@ -399,9 +329,15 @@
if (typeof this._config.reference.jquery !== 'undefined') {
referenceElement = this._config.reference[0];
}
} // If boundary is not `scrollParent`, then set position to `static`
// to allow the menu to "escape" the scroll parent's boundaries
// https://github.com/twbs/bootstrap/issues/24251
if (this._config.boundary !== 'scrollParent') {
parent.classList.add(CLASS_NAME_POSITION_STATIC);
}
this._popper = Popper.createPopper(referenceElement, this._menu, this._getPopperConfig());
this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
} // If this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
// only needed because of broken event delegation on iOS
@ -411,7 +347,7 @@
var _ref;
(_ref = []).concat.apply(_ref, document.body.children).forEach(function (elem) {
return EventHandler__default['default'].on(elem, 'mouseover', null, noop());
return EventHandler.on(elem, 'mouseover', null, noop());
});
}
@ -419,11 +355,9 @@
this._element.setAttribute('aria-expanded', true);
this._menu.classList.toggle(CLASS_NAME_SHOW);
this._element.classList.toggle(CLASS_NAME_SHOW);
EventHandler__default['default'].trigger(parent, EVENT_SHOWN, relatedTarget);
Manipulator.toggleClass(this._menu, CLASS_NAME_SHOW);
Manipulator.toggleClass(this._element, CLASS_NAME_SHOW);
EventHandler.trigger(parent, EVENT_SHOWN, relatedTarget);
};
_proto.hide = function hide() {
@ -439,7 +373,7 @@
var relatedTarget = {
relatedTarget: this._element,
};
var hideEvent = EventHandler__default['default'].trigger(parent, EVENT_HIDE, relatedTarget);
var hideEvent = EventHandler.trigger(parent, EVENT_HIDE, relatedTarget);
if (hideEvent.defaultPrevented) {
return;
@ -449,17 +383,15 @@
this._popper.destroy();
}
this._menu.classList.toggle(CLASS_NAME_SHOW);
this._element.classList.toggle(CLASS_NAME_SHOW);
EventHandler__default['default'].trigger(parent, EVENT_HIDDEN, relatedTarget);
Manipulator.toggleClass(this._menu, CLASS_NAME_SHOW);
Manipulator.toggleClass(this._element, CLASS_NAME_SHOW);
EventHandler.trigger(parent, EVENT_HIDDEN, relatedTarget);
};
_proto.dispose = function dispose() {
_BaseComponent.prototype.dispose.call(this);
EventHandler__default['default'].off(this._element, EVENT_KEY);
Data.removeData(this._element, DATA_KEY);
EventHandler.off(this._element, EVENT_KEY);
this._element = null;
this._menu = null;
if (this._popper) {
@ -473,26 +405,27 @@
this._inNavbar = this._detectNavbar();
if (this._popper) {
this._popper.update();
this._popper.scheduleUpdate();
}
}; // Private
_proto._addEventListeners = function _addEventListeners() {
var _this2 = this;
var _this = this;
EventHandler__default['default'].on(this._element, EVENT_CLICK, function (event) {
EventHandler.on(this._element, EVENT_CLICK, function (event) {
event.preventDefault();
event.stopPropagation();
_this2.toggle();
_this.toggle();
});
};
_proto._getConfig = function _getConfig(config) {
config = _extends(
{},
this.constructor.Default,
Manipulator__default['default'].getDataAttributes(this._element),
config = _objectSpread(
_objectSpread(
_objectSpread({}, this.constructor.Default),
Manipulator.getDataAttributes(this._element)
),
config
);
typeCheckConfig(NAME, config, this.constructor.DefaultType);
@ -500,61 +433,79 @@
};
_proto._getMenuElement = function _getMenuElement() {
return SelectorEngine__default['default'].next(this._element, SELECTOR_MENU)[0];
return SelectorEngine.next(this._element, SELECTOR_MENU)[0];
};
_proto._getPlacement = function _getPlacement() {
var parentDropdown = this._element.parentNode;
if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
return PLACEMENT_RIGHT;
}
if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
return PLACEMENT_LEFT;
} // We need to trim the value because custom properties can also include spaces
var isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
var placement = PLACEMENT_BOTTOM; // Handle dropup
if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
placement = PLACEMENT_TOP;
if (this._menu.classList.contains(CLASS_NAME_MENURIGHT)) {
placement = PLACEMENT_TOPEND;
}
} else if (parentDropdown.classList.contains(CLASS_NAME_DROPRIGHT)) {
placement = PLACEMENT_RIGHT;
} else if (parentDropdown.classList.contains(CLASS_NAME_DROPLEFT)) {
placement = PLACEMENT_LEFT;
} else if (this._menu.classList.contains(CLASS_NAME_MENURIGHT)) {
placement = PLACEMENT_BOTTOMEND;
}
return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
return placement;
};
_proto._detectNavbar = function _detectNavbar() {
return this._element.closest('.' + CLASS_NAME_NAVBAR) !== null;
return Boolean(this._element.closest('.' + CLASS_NAME_NAVBAR));
};
_proto._getOffset = function _getOffset() {
var _this2 = this;
var offset = {};
if (typeof this._config.offset === 'function') {
offset.fn = function (data) {
data.offsets = _objectSpread(
_objectSpread({}, data.offsets),
_this2._config.offset(data.offsets, _this2._element) || {}
);
return data;
};
} else {
offset.offset = this._config.offset;
}
return offset;
};
_proto._getPopperConfig = function _getPopperConfig() {
var popperConfig = {
placement: this._getPlacement(),
modifiers: [
{
name: 'preventOverflow',
options: {
altBoundary: this._config.flip,
rootBoundary: this._config.boundary,
},
modifiers: {
offset: this._getOffset(),
flip: {
enabled: this._config.flip,
},
],
}; // Disable Popper if we have a static display
preventOverflow: {
boundariesElement: this._config.boundary,
},
},
}; // Disable Popper.js if we have a static display
if (this._config.display === 'static') {
popperConfig.modifiers = [
{
name: 'applyStyles',
enabled: false,
},
];
popperConfig.modifiers.applyStyle = {
enabled: false,
};
}
return _extends({}, popperConfig, this._config.popperConfig);
return _objectSpread(_objectSpread({}, popperConfig), this._config.popperConfig);
}; // Static
Dropdown.dropdownInterface = function dropdownInterface(element, config) {
var data = Data__default['default'].getData(element, DATA_KEY);
var data = Data.getData(element, DATA_KEY);
var _config = typeof config === 'object' ? config : null;
@ -585,11 +536,11 @@
return;
}
var toggles = SelectorEngine__default['default'].find(SELECTOR_DATA_TOGGLE);
var toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE);
for (var i = 0, len = toggles.length; i < len; i++) {
var parent = Dropdown.getParentFromElement(toggles[i]);
var context = Data__default['default'].getData(toggles[i], DATA_KEY);
var context = Data.getData(toggles[i], DATA_KEY);
var relatedTarget = {
relatedTarget: toggles[i],
};
@ -617,7 +568,7 @@
continue;
}
var hideEvent = EventHandler__default['default'].trigger(parent, EVENT_HIDE, relatedTarget);
var hideEvent = EventHandler.trigger(parent, EVENT_HIDE, relatedTarget);
if (hideEvent.defaultPrevented) {
continue;
@ -628,7 +579,7 @@
var _ref2;
(_ref2 = []).concat.apply(_ref2, document.body.children).forEach(function (elem) {
return EventHandler__default['default'].off(elem, 'mouseover', null, noop());
return EventHandler.off(elem, 'mouseover', null, noop());
});
}
@ -640,7 +591,7 @@
dropdownMenu.classList.remove(CLASS_NAME_SHOW);
toggles[i].classList.remove(CLASS_NAME_SHOW);
EventHandler__default['default'].trigger(parent, EVENT_HIDDEN, relatedTarget);
EventHandler.trigger(parent, EVENT_HIDDEN, relatedTarget);
}
};
@ -680,7 +631,7 @@
if (event.key === ESCAPE_KEY) {
var button = this.matches(SELECTOR_DATA_TOGGLE)
? this
: SelectorEngine__default['default'].prev(this, SELECTOR_DATA_TOGGLE)[0];
: SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE)[0];
button.focus();
Dropdown.clearMenus();
return;
@ -691,21 +642,21 @@
return;
}
var items = SelectorEngine__default['default']
.find(SELECTOR_VISIBLE_ITEMS, parent)
.filter(isVisible);
var items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, parent).filter(isVisible);
if (!items.length) {
return;
}
var index = items.indexOf(event.target); // Up
var index = items.indexOf(event.target);
if (event.key === ARROW_UP_KEY && index > 0) {
// Up
index--;
} // Down
}
if (event.key === ARROW_DOWN_KEY && index < items.length - 1) {
// Down
index++;
} // index is -1 if the first keydown is an ArrowUp
@ -713,7 +664,17 @@
items[index].focus();
};
_createClass$1(Dropdown, null, [
Dropdown.getInstance = function getInstance(element) {
return Data.getData(element, DATA_KEY);
};
_createClass(Dropdown, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
{
key: 'Default',
get: function get() {
@ -726,76 +687,53 @@
return DefaultType;
},
},
{
key: 'DATA_KEY',
get: function get() {
return DATA_KEY;
},
},
]);
return Dropdown;
})(BaseComponent);
})();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler__default['default'].on(
EventHandler.on(
document,
EVENT_KEYDOWN_DATA_API,
SELECTOR_DATA_TOGGLE,
Dropdown.dataApiKeydownHandler
);
EventHandler__default['default'].on(
document,
EVENT_KEYDOWN_DATA_API,
SELECTOR_MENU,
Dropdown.dataApiKeydownHandler
);
EventHandler__default['default'].on(document, EVENT_CLICK_DATA_API, Dropdown.clearMenus);
EventHandler__default['default'].on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
EventHandler__default['default'].on(
document,
EVENT_CLICK_DATA_API,
SELECTOR_DATA_TOGGLE,
function (event) {
event.preventDefault();
event.stopPropagation();
Dropdown.dropdownInterface(this, 'toggle');
}
);
EventHandler__default['default'].on(
document,
EVENT_CLICK_DATA_API,
SELECTOR_FORM_CHILD,
function (e) {
return e.stopPropagation();
}
);
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
EventHandler.on(document, EVENT_CLICK_DATA_API, Dropdown.clearMenus);
EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
event.preventDefault();
event.stopPropagation();
Dropdown.dropdownInterface(this, 'toggle');
});
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_FORM_CHILD, function (e) {
return e.stopPropagation();
});
var $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Dropdown to jQuery only if jQuery is present
* add .dropdown to jQuery only if jQuery is present
*/
onDOMContentLoaded(function () {
var $ = getjQuery();
/* istanbul ignore if */
/* istanbul ignore if */
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Dropdown.jQueryInterface;
$.fn[NAME].Constructor = Dropdown;
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Dropdown.jQueryInterface;
$.fn[NAME].Constructor = Dropdown;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Dropdown.jQueryInterface;
};
}
});
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Dropdown.jQueryInterface;
};
}
return Dropdown;
});

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*!
* Bootstrap modal.js v5.0.0-beta1 (https://getbootstrap.com/)
* Bootstrap modal.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
@ -13,12 +13,12 @@
))
: typeof define === 'function' && define.amd
? define([
'./dom/data',
'./dom/event-handler',
'./dom/manipulator',
'./dom/selector-engine',
'./dom/data.js',
'./dom/event-handler.js',
'./dom/manipulator.js',
'./dom/selector-engine.js',
], factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
: ((global = global || self),
(global.Modal = factory(
global.Data,
global.EventHandler,
@ -28,18 +28,23 @@
})(this, function (Data, EventHandler, Manipulator, SelectorEngine) {
'use strict';
function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : { default: e };
}
var Data__default = /*#__PURE__*/ _interopDefaultLegacy(Data);
var EventHandler__default = /*#__PURE__*/ _interopDefaultLegacy(EventHandler);
var Manipulator__default = /*#__PURE__*/ _interopDefaultLegacy(Manipulator);
var SelectorEngine__default = /*#__PURE__*/ _interopDefaultLegacy(SelectorEngine);
Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data;
EventHandler =
EventHandler && Object.prototype.hasOwnProperty.call(EventHandler, 'default')
? EventHandler['default']
: EventHandler;
Manipulator =
Manipulator && Object.prototype.hasOwnProperty.call(Manipulator, 'default')
? Manipulator['default']
: Manipulator;
SelectorEngine =
SelectorEngine && Object.prototype.hasOwnProperty.call(SelectorEngine, 'default')
? SelectorEngine['default']
: SelectorEngine;
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/index.js
* Bootstrap (v5.0.0-alpha1): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -58,7 +63,7 @@
};
var getSelector = function getSelector(element) {
var selector = element.getAttribute('data-bs-target');
var selector = element.getAttribute('data-target');
if (!selector || selector === '#') {
var hrefAttr = element.getAttribute('href');
@ -82,8 +87,8 @@
transitionDuration = _window$getComputedSt.transitionDuration,
transitionDelay = _window$getComputedSt.transitionDelay;
var floatTransitionDuration = Number.parseFloat(transitionDuration);
var floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
var floatTransitionDuration = parseFloat(transitionDuration);
var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
if (!floatTransitionDuration && !floatTransitionDelay) {
return 0;
@ -91,10 +96,7 @@
transitionDuration = transitionDuration.split(',')[0];
transitionDelay = transitionDelay.split(',')[0];
return (
(Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) *
MILLISECONDS_MULTIPLIER
);
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
};
var triggerTransitionEnd = function triggerTransitionEnd(element) {
@ -166,22 +168,57 @@
var _window = window,
jQuery = _window.jQuery;
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
return jQuery;
}
return null;
};
var onDOMContentLoaded = function onDOMContentLoaded(callback) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callback);
} else {
callback();
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly)
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
};
return keys;
}
var isRTL = document.documentElement.dir === 'rtl';
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true,
});
} else {
obj[key] = value;
}
return obj;
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
@ -204,87 +241,8 @@
* ------------------------------------------------------------------------
*/
var VERSION = '5.0.0-beta1';
var BaseComponent = /*#__PURE__*/ (function () {
function BaseComponent(element) {
if (!element) {
return;
}
this._element = element;
Data__default['default'].setData(element, this.constructor.DATA_KEY, this);
}
var _proto = BaseComponent.prototype;
_proto.dispose = function dispose() {
Data__default['default'].removeData(this._element, this.constructor.DATA_KEY);
this._element = null;
};
/** Static */
BaseComponent.getInstance = function getInstance(element) {
return Data__default['default'].getData(element, this.DATA_KEY);
};
_createClass(BaseComponent, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
]);
return BaseComponent;
})();
function _extends() {
_extends =
Object.assign ||
function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _defineProperties$1(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass$1(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
if (staticProps) _defineProperties$1(Constructor, staticProps);
return Constructor;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'modal';
var VERSION = '5.0.0-alpha1';
var DATA_KEY = 'bs.modal';
var EVENT_KEY = '.' + DATA_KEY;
var DATA_API_KEY = '.data-api';
@ -293,11 +251,13 @@
backdrop: true,
keyboard: true,
focus: true,
show: true,
};
var DefaultType = {
backdrop: '(boolean|string)',
keyboard: 'boolean',
focus: 'boolean',
show: 'boolean',
};
var EVENT_HIDE = 'hide' + EVENT_KEY;
var EVENT_HIDE_PREVENTED = 'hidePrevented' + EVENT_KEY;
@ -319,8 +279,8 @@
var CLASS_NAME_STATIC = 'modal-static';
var SELECTOR_DIALOG = '.modal-dialog';
var SELECTOR_MODAL_BODY = '.modal-body';
var SELECTOR_DATA_TOGGLE = '[data-bs-toggle="modal"]';
var SELECTOR_DATA_DISMISS = '[data-bs-dismiss="modal"]';
var SELECTOR_DATA_TOGGLE = '[data-toggle="modal"]';
var SELECTOR_DATA_DISMISS = '[data-dismiss="modal"]';
var SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
var SELECTOR_STICKY_CONTENT = '.sticky-top';
/**
@ -329,22 +289,18 @@
* ------------------------------------------------------------------------
*/
var Modal = /*#__PURE__*/ (function (_BaseComponent) {
_inheritsLoose(Modal, _BaseComponent);
var Modal = /*#__PURE__*/ (function () {
function Modal(element, config) {
var _this;
_this = _BaseComponent.call(this, element) || this;
_this._config = _this._getConfig(config);
_this._dialog = SelectorEngine__default['default'].findOne(SELECTOR_DIALOG, element);
_this._backdrop = null;
_this._isShown = false;
_this._isBodyOverflowing = false;
_this._ignoreBackdropClick = false;
_this._isTransitioning = false;
_this._scrollbarWidth = 0;
return _this;
this._config = this._getConfig(config);
this._element = element;
this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, element);
this._backdrop = null;
this._isShown = false;
this._isBodyOverflowing = false;
this._ignoreBackdropClick = false;
this._isTransitioning = false;
this._scrollbarWidth = 0;
Data.setData(element, DATA_KEY, this);
} // Getters
var _proto = Modal.prototype;
@ -355,7 +311,7 @@
};
_proto.show = function show(relatedTarget) {
var _this2 = this;
var _this = this;
if (this._isShown || this._isTransitioning) {
return;
@ -365,7 +321,7 @@
this._isTransitioning = true;
}
var showEvent = EventHandler__default['default'].trigger(this._element, EVENT_SHOW, {
var showEvent = EventHandler.trigger(this._element, EVENT_SHOW, {
relatedTarget: relatedTarget,
});
@ -385,31 +341,24 @@
this._setResizeEvent();
EventHandler__default['default'].on(
this._element,
EVENT_CLICK_DISMISS,
SELECTOR_DATA_DISMISS,
function (event) {
return _this2.hide(event);
}
);
EventHandler__default['default'].on(this._dialog, EVENT_MOUSEDOWN_DISMISS, function () {
EventHandler__default['default'].one(_this2._element, EVENT_MOUSEUP_DISMISS, function (
event
) {
if (event.target === _this2._element) {
_this2._ignoreBackdropClick = true;
EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function (event) {
return _this.hide(event);
});
EventHandler.on(this._dialog, EVENT_MOUSEDOWN_DISMISS, function () {
EventHandler.one(_this._element, EVENT_MOUSEUP_DISMISS, function (event) {
if (event.target === _this._element) {
_this._ignoreBackdropClick = true;
}
});
});
this._showBackdrop(function () {
return _this2._showElement(relatedTarget);
return _this._showElement(relatedTarget);
});
};
_proto.hide = function hide(event) {
var _this3 = this;
var _this2 = this;
if (event) {
event.preventDefault();
@ -419,7 +368,7 @@
return;
}
var hideEvent = EventHandler__default['default'].trigger(this._element, EVENT_HIDE);
var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
if (hideEvent.defaultPrevented) {
return;
@ -437,17 +386,17 @@
this._setResizeEvent();
EventHandler__default['default'].off(document, EVENT_FOCUSIN);
EventHandler.off(document, EVENT_FOCUSIN);
this._element.classList.remove(CLASS_NAME_SHOW);
EventHandler__default['default'].off(this._element, EVENT_CLICK_DISMISS);
EventHandler__default['default'].off(this._dialog, EVENT_MOUSEDOWN_DISMISS);
EventHandler.off(this._element, EVENT_CLICK_DISMISS);
EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS);
if (transition) {
var transitionDuration = getTransitionDurationFromElement(this._element);
EventHandler__default['default'].one(this._element, TRANSITION_END, function (event) {
return _this3._hideModal(event);
EventHandler.one(this._element, TRANSITION_END, function (event) {
return _this2._hideModal(event);
});
emulateTransitionEnd(this._element, transitionDuration);
} else {
@ -457,18 +406,18 @@
_proto.dispose = function dispose() {
[window, this._element, this._dialog].forEach(function (htmlElement) {
return EventHandler__default['default'].off(htmlElement, EVENT_KEY);
return EventHandler.off(htmlElement, EVENT_KEY);
});
_BaseComponent.prototype.dispose.call(this);
/**
* `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
* Do not move `document` in `htmlElements` array
* It will remove `EVENT_CLICK_DATA_API` event that should remain
*/
EventHandler__default['default'].off(document, EVENT_FOCUSIN);
EventHandler.off(document, EVENT_FOCUSIN);
Data.removeData(this._element, DATA_KEY);
this._config = null;
this._element = null;
this._dialog = null;
this._backdrop = null;
this._isShown = null;
@ -483,17 +432,17 @@
}; // Private
_proto._getConfig = function _getConfig(config) {
config = _extends({}, Default, config);
config = _objectSpread(_objectSpread({}, Default), config);
typeCheckConfig(NAME, config, DefaultType);
return config;
};
_proto._showElement = function _showElement(relatedTarget) {
var _this4 = this;
var _this3 = this;
var transition = this._element.classList.contains(CLASS_NAME_FADE);
var modalBody = SelectorEngine__default['default'].findOne(SELECTOR_MODAL_BODY, this._dialog);
var modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
// Don't move modal's DOM position
@ -525,19 +474,19 @@
}
var transitionComplete = function transitionComplete() {
if (_this4._config.focus) {
_this4._element.focus();
if (_this3._config.focus) {
_this3._element.focus();
}
_this4._isTransitioning = false;
EventHandler__default['default'].trigger(_this4._element, EVENT_SHOWN, {
_this3._isTransitioning = false;
EventHandler.trigger(_this3._element, EVENT_SHOWN, {
relatedTarget: relatedTarget,
});
};
if (transition) {
var transitionDuration = getTransitionDurationFromElement(this._dialog);
EventHandler__default['default'].one(this._dialog, TRANSITION_END, transitionComplete);
EventHandler.one(this._dialog, TRANSITION_END, transitionComplete);
emulateTransitionEnd(this._dialog, transitionDuration);
} else {
transitionComplete();
@ -545,53 +494,53 @@
};
_proto._enforceFocus = function _enforceFocus() {
var _this5 = this;
var _this4 = this;
EventHandler__default['default'].off(document, EVENT_FOCUSIN); // guard against infinite focus loop
EventHandler.off(document, EVENT_FOCUSIN); // guard against infinite focus loop
EventHandler__default['default'].on(document, EVENT_FOCUSIN, function (event) {
EventHandler.on(document, EVENT_FOCUSIN, function (event) {
if (
document !== event.target &&
_this5._element !== event.target &&
!_this5._element.contains(event.target)
_this4._element !== event.target &&
!_this4._element.contains(event.target)
) {
_this5._element.focus();
_this4._element.focus();
}
});
};
_proto._setEscapeEvent = function _setEscapeEvent() {
var _this6 = this;
var _this5 = this;
if (this._isShown) {
EventHandler__default['default'].on(this._element, EVENT_KEYDOWN_DISMISS, function (event) {
if (_this6._config.keyboard && event.key === ESCAPE_KEY) {
EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, function (event) {
if (_this5._config.keyboard && event.key === ESCAPE_KEY) {
event.preventDefault();
_this6.hide();
} else if (!_this6._config.keyboard && event.key === ESCAPE_KEY) {
_this6._triggerBackdropTransition();
_this5.hide();
} else if (!_this5._config.keyboard && event.key === ESCAPE_KEY) {
_this5._triggerBackdropTransition();
}
});
} else {
EventHandler__default['default'].off(this._element, EVENT_KEYDOWN_DISMISS);
EventHandler.off(this._element, EVENT_KEYDOWN_DISMISS);
}
};
_proto._setResizeEvent = function _setResizeEvent() {
var _this7 = this;
var _this6 = this;
if (this._isShown) {
EventHandler__default['default'].on(window, EVENT_RESIZE, function () {
return _this7._adjustDialog();
EventHandler.on(window, EVENT_RESIZE, function () {
return _this6._adjustDialog();
});
} else {
EventHandler__default['default'].off(window, EVENT_RESIZE);
EventHandler.off(window, EVENT_RESIZE);
}
};
_proto._hideModal = function _hideModal() {
var _this8 = this;
var _this7 = this;
this._element.style.display = 'none';
@ -606,11 +555,11 @@
this._showBackdrop(function () {
document.body.classList.remove(CLASS_NAME_OPEN);
_this8._resetAdjustments();
_this7._resetAdjustments();
_this8._resetScrollbar();
_this7._resetScrollbar();
EventHandler__default['default'].trigger(_this8._element, EVENT_HIDDEN);
EventHandler.trigger(_this7._element, EVENT_HIDDEN);
});
};
@ -621,7 +570,7 @@
};
_proto._showBackdrop = function _showBackdrop(callback) {
var _this9 = this;
var _this8 = this;
var animate = this._element.classList.contains(CLASS_NAME_FADE) ? CLASS_NAME_FADE : '';
@ -634,9 +583,9 @@
}
document.body.appendChild(this._backdrop);
EventHandler__default['default'].on(this._element, EVENT_CLICK_DISMISS, function (event) {
if (_this9._ignoreBackdropClick) {
_this9._ignoreBackdropClick = false;
EventHandler.on(this._element, EVENT_CLICK_DISMISS, function (event) {
if (_this8._ignoreBackdropClick) {
_this8._ignoreBackdropClick = false;
return;
}
@ -644,11 +593,7 @@
return;
}
if (_this9._config.backdrop === 'static') {
_this9._triggerBackdropTransition();
} else {
_this9.hide();
}
_this8._triggerBackdropTransition();
});
if (animate) {
@ -663,13 +608,13 @@
}
var backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
EventHandler__default['default'].one(this._backdrop, TRANSITION_END, callback);
EventHandler.one(this._backdrop, TRANSITION_END, callback);
emulateTransitionEnd(this._backdrop, backdropTransitionDuration);
} else if (!this._isShown && this._backdrop) {
this._backdrop.classList.remove(CLASS_NAME_SHOW);
var callbackRemove = function callbackRemove() {
_this9._removeBackdrop();
_this8._removeBackdrop();
callback();
};
@ -677,7 +622,7 @@
if (this._element.classList.contains(CLASS_NAME_FADE)) {
var _backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
EventHandler__default['default'].one(this._backdrop, TRANSITION_END, callbackRemove);
EventHandler.one(this._backdrop, TRANSITION_END, callbackRemove);
emulateTransitionEnd(this._backdrop, _backdropTransitionDuration);
} else {
callbackRemove();
@ -688,37 +633,27 @@
};
_proto._triggerBackdropTransition = function _triggerBackdropTransition() {
var _this10 = this;
var _this9 = this;
var hideEvent = EventHandler__default['default'].trigger(this._element, EVENT_HIDE_PREVENTED);
if (this._config.backdrop === 'static') {
var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
if (hideEvent.defaultPrevented) {
return;
}
var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
if (!isModalOverflowing) {
this._element.style.overflowY = 'hidden';
}
this._element.classList.add(CLASS_NAME_STATIC);
var modalTransitionDuration = getTransitionDurationFromElement(this._dialog);
EventHandler__default['default'].off(this._element, TRANSITION_END);
EventHandler__default['default'].one(this._element, TRANSITION_END, function () {
_this10._element.classList.remove(CLASS_NAME_STATIC);
if (!isModalOverflowing) {
EventHandler__default['default'].one(_this10._element, TRANSITION_END, function () {
_this10._element.style.overflowY = '';
});
emulateTransitionEnd(_this10._element, modalTransitionDuration);
if (hideEvent.defaultPrevented) {
return;
}
});
emulateTransitionEnd(this._element, modalTransitionDuration);
this._element.focus();
this._element.classList.add(CLASS_NAME_STATIC);
var modalTransitionDuration = getTransitionDurationFromElement(this._element);
EventHandler.one(this._element, TRANSITION_END, function () {
_this9._element.classList.remove(CLASS_NAME_STATIC);
});
emulateTransitionEnd(this._element, modalTransitionDuration);
this._element.focus();
} else {
this.hide();
}
}; // ----------------------------------------------------------------------
// the following methods are used to handle overflowing modals
// ----------------------------------------------------------------------
@ -726,17 +661,11 @@
_proto._adjustDialog = function _adjustDialog() {
var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
if (
(!this._isBodyOverflowing && isModalOverflowing && !isRTL) ||
(this._isBodyOverflowing && !isModalOverflowing && isRTL)
) {
if (!this._isBodyOverflowing && isModalOverflowing) {
this._element.style.paddingLeft = this._scrollbarWidth + 'px';
}
if (
(this._isBodyOverflowing && !isModalOverflowing && !isRTL) ||
(!this._isBodyOverflowing && isModalOverflowing && isRTL)
) {
if (this._isBodyOverflowing && !isModalOverflowing) {
this._element.style.paddingRight = this._scrollbarWidth + 'px';
}
};
@ -753,39 +682,32 @@
};
_proto._setScrollbar = function _setScrollbar() {
var _this11 = this;
var _this10 = this;
if (this._isBodyOverflowing) {
// Note: DOMNode.style.paddingRight returns the actual value or '' if not set
// while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
// Adjust fixed content padding
SelectorEngine__default['default'].find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
var actualPadding = element.style.paddingRight;
var calculatedPadding = window.getComputedStyle(element)['padding-right'];
Manipulator__default['default'].setDataAttribute(element, 'padding-right', actualPadding);
Manipulator.setDataAttribute(element, 'padding-right', actualPadding);
element.style.paddingRight =
Number.parseFloat(calculatedPadding) + _this11._scrollbarWidth + 'px';
parseFloat(calculatedPadding) + _this10._scrollbarWidth + 'px';
}); // Adjust sticky content margin
SelectorEngine__default['default']
.find(SELECTOR_STICKY_CONTENT)
.forEach(function (element) {
var actualMargin = element.style.marginRight;
var calculatedMargin = window.getComputedStyle(element)['margin-right'];
Manipulator__default['default'].setDataAttribute(element, 'margin-right', actualMargin);
element.style.marginRight =
Number.parseFloat(calculatedMargin) - _this11._scrollbarWidth + 'px';
}); // Adjust body padding
SelectorEngine.find(SELECTOR_STICKY_CONTENT).forEach(function (element) {
var actualMargin = element.style.marginRight;
var calculatedMargin = window.getComputedStyle(element)['margin-right'];
Manipulator.setDataAttribute(element, 'margin-right', actualMargin);
element.style.marginRight = parseFloat(calculatedMargin) - _this10._scrollbarWidth + 'px';
}); // Adjust body padding
var actualPadding = document.body.style.paddingRight;
var calculatedPadding = window.getComputedStyle(document.body)['padding-right'];
Manipulator__default['default'].setDataAttribute(
document.body,
'padding-right',
actualPadding
);
Manipulator.setDataAttribute(document.body, 'padding-right', actualPadding);
document.body.style.paddingRight =
Number.parseFloat(calculatedPadding) + this._scrollbarWidth + 'px';
parseFloat(calculatedPadding) + this._scrollbarWidth + 'px';
}
document.body.classList.add(CLASS_NAME_OPEN);
@ -793,35 +715,30 @@
_proto._resetScrollbar = function _resetScrollbar() {
// Restore fixed content padding
SelectorEngine__default['default'].find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
var padding = Manipulator__default['default'].getDataAttribute(element, 'padding-right');
SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
var padding = Manipulator.getDataAttribute(element, 'padding-right');
if (typeof padding !== 'undefined') {
Manipulator__default['default'].removeDataAttribute(element, 'padding-right');
Manipulator.removeDataAttribute(element, 'padding-right');
element.style.paddingRight = padding;
}
}); // Restore sticky content and navbar-toggler margin
SelectorEngine__default['default']
.find('' + SELECTOR_STICKY_CONTENT)
.forEach(function (element) {
var margin = Manipulator__default['default'].getDataAttribute(element, 'margin-right');
SelectorEngine.find('' + SELECTOR_STICKY_CONTENT).forEach(function (element) {
var margin = Manipulator.getDataAttribute(element, 'margin-right');
if (typeof margin !== 'undefined') {
Manipulator__default['default'].removeDataAttribute(element, 'margin-right');
element.style.marginRight = margin;
}
}); // Restore body padding
if (typeof margin !== 'undefined') {
Manipulator.removeDataAttribute(element, 'margin-right');
element.style.marginRight = margin;
}
}); // Restore body padding
var padding = Manipulator__default['default'].getDataAttribute(
document.body,
'padding-right'
);
var padding = Manipulator.getDataAttribute(document.body, 'padding-right');
if (typeof padding === 'undefined') {
document.body.style.paddingRight = '';
} else {
Manipulator__default['default'].removeDataAttribute(document.body, 'padding-right');
Manipulator.removeDataAttribute(document.body, 'padding-right');
document.body.style.paddingRight = padding;
}
};
@ -838,12 +755,10 @@
Modal.jQueryInterface = function jQueryInterface(config, relatedTarget) {
return this.each(function () {
var data = Data__default['default'].getData(this, DATA_KEY);
var data = Data.getData(this, DATA_KEY);
var _config = _extends(
{},
Default,
Manipulator__default['default'].getDataAttributes(this),
var _config = _objectSpread(
_objectSpread(_objectSpread({}, Default), Manipulator.getDataAttributes(this)),
typeof config === 'object' && config ? config : {}
);
@ -857,95 +772,93 @@
}
data[config](relatedTarget);
} else if (_config.show) {
data.show(relatedTarget);
}
});
};
_createClass$1(Modal, null, [
Modal.getInstance = function getInstance(element) {
return Data.getData(element, DATA_KEY);
};
_createClass(Modal, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
{
key: 'Default',
get: function get() {
return Default;
},
},
{
key: 'DATA_KEY',
get: function get() {
return DATA_KEY;
},
},
]);
return Modal;
})(BaseComponent);
})();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler__default['default'].on(
document,
EVENT_CLICK_DATA_API,
SELECTOR_DATA_TOGGLE,
function (event) {
var _this12 = this;
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
var _this11 = this;
var target = getElementFromSelector(this);
var target = getElementFromSelector(this);
if (this.tagName === 'A' || this.tagName === 'AREA') {
event.preventDefault();
}
EventHandler__default['default'].one(target, EVENT_SHOW, function (showEvent) {
if (showEvent.defaultPrevented) {
// only register focus restorer if modal will actually get shown
return;
}
EventHandler__default['default'].one(target, EVENT_HIDDEN, function () {
if (isVisible(_this12)) {
_this12.focus();
}
});
});
var data = Data__default['default'].getData(target, DATA_KEY);
if (!data) {
var config = _extends(
{},
Manipulator__default['default'].getDataAttributes(target),
Manipulator__default['default'].getDataAttributes(this)
);
data = new Modal(target, config);
}
data.show(this);
if (this.tagName === 'A' || this.tagName === 'AREA') {
event.preventDefault();
}
);
EventHandler.one(target, EVENT_SHOW, function (showEvent) {
if (showEvent.defaultPrevented) {
// only register focus restorer if modal will actually get shown
return;
}
EventHandler.one(target, EVENT_HIDDEN, function () {
if (isVisible(_this11)) {
_this11.focus();
}
});
});
var data = Data.getData(target, DATA_KEY);
if (!data) {
var config = _objectSpread(
_objectSpread({}, Manipulator.getDataAttributes(target)),
Manipulator.getDataAttributes(this)
);
data = new Modal(target, config);
}
data.show(this);
});
var $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Modal to jQuery only if jQuery is present
* add .modal to jQuery only if jQuery is present
*/
onDOMContentLoaded(function () {
var $ = getjQuery();
/* istanbul ignore if */
/* istanbul ignore if */
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Modal.jQueryInterface;
$.fn[NAME].Constructor = Modal;
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Modal.jQueryInterface;
$.fn[NAME].Constructor = Modal;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Modal.jQueryInterface;
};
}
});
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Modal.jQueryInterface;
};
}
return Modal;
});

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*!
* Bootstrap popover.js v5.0.0-beta1 (https://getbootstrap.com/)
* Bootstrap popover.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
@ -11,23 +11,25 @@
require('./tooltip.js')
))
: typeof define === 'function' && define.amd
? define(['./dom/data', './dom/selector-engine', './tooltip'], factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
? define(['./dom/data.js', './dom/selector-engine.js', './tooltip.js'], factory)
: ((global = global || self),
(global.Popover = factory(global.Data, global.SelectorEngine, global.Tooltip)));
})(this, function (Data, SelectorEngine, Tooltip) {
'use strict';
function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : { default: e };
}
var Data__default = /*#__PURE__*/ _interopDefaultLegacy(Data);
var SelectorEngine__default = /*#__PURE__*/ _interopDefaultLegacy(SelectorEngine);
var Tooltip__default = /*#__PURE__*/ _interopDefaultLegacy(Tooltip);
Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data;
SelectorEngine =
SelectorEngine && Object.prototype.hasOwnProperty.call(SelectorEngine, 'default')
? SelectorEngine['default']
: SelectorEngine;
Tooltip =
Tooltip && Object.prototype.hasOwnProperty.call(Tooltip, 'default')
? Tooltip['default']
: Tooltip;
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/index.js
* Bootstrap (v5.0.0-alpha1): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -36,23 +38,13 @@
var _window = window,
jQuery = _window.jQuery;
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
return jQuery;
}
return null;
};
var onDOMContentLoaded = function onDOMContentLoaded(callback) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callback);
} else {
callback();
}
};
var isRTL = document.documentElement.dir === 'rtl';
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
@ -75,21 +67,49 @@
subClass.__proto__ = superClass;
}
function _extends() {
_extends =
Object.assign ||
function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly)
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true,
});
} else {
obj[key] = value;
}
return obj;
}
/**
* ------------------------------------------------------------------------
@ -98,26 +118,34 @@
*/
var NAME = 'popover';
var VERSION = '5.0.0-alpha1';
var DATA_KEY = 'bs.popover';
var EVENT_KEY = '.' + DATA_KEY;
var CLASS_PREFIX = 'bs-popover';
var BSCLS_PREFIX_REGEX = new RegExp('(^|\\s)' + CLASS_PREFIX + '\\S+', 'g');
var Default = _extends({}, Tooltip__default['default'].Default, {
placement: 'right',
trigger: 'click',
content: '',
template:
'<div class="popover" role="tooltip">' +
'<div class="popover-arrow"></div>' +
'<h3 class="popover-header"></h3>' +
'<div class="popover-body"></div>' +
'</div>',
});
var Default = _objectSpread(
_objectSpread({}, Tooltip.Default),
{},
{
placement: 'right',
trigger: 'click',
content: '',
template:
'<div class="popover" role="tooltip">' +
'<div class="popover-arrow"></div>' +
'<h3 class="popover-header"></h3>' +
'<div class="popover-body"></div></div>',
}
);
var DefaultType = _extends({}, Tooltip__default['default'].DefaultType, {
content: '(string|element|function)',
});
var DefaultType = _objectSpread(
_objectSpread({}, Tooltip.DefaultType),
{},
{
content: '(string|element|function)',
}
);
var Event = {
HIDE: 'hide' + EVENT_KEY,
@ -158,30 +186,24 @@
_proto.setContent = function setContent() {
var tip = this.getTipElement(); // we use append for html objects to maintain js events
this.setElementContent(
SelectorEngine__default['default'].findOne(SELECTOR_TITLE, tip),
this.getTitle()
);
this.setElementContent(SelectorEngine.findOne(SELECTOR_TITLE, tip), this.getTitle());
var content = this._getContent();
if (typeof content === 'function') {
content = content.call(this._element);
content = content.call(this.element);
}
this.setElementContent(
SelectorEngine__default['default'].findOne(SELECTOR_CONTENT, tip),
content
);
this.setElementContent(SelectorEngine.findOne(SELECTOR_CONTENT, tip), content);
tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW);
}; // Private
_proto._addAttachmentClass = function _addAttachmentClass(attachment) {
this.getTipElement().classList.add(CLASS_PREFIX + '-' + this.updateAttachment(attachment));
};
_proto._addAttachmentClass = function _addAttachmentClass(attachment) {
this.getTipElement().classList.add(CLASS_PREFIX + '-' + attachment);
}; // Private
_proto._getContent = function _getContent() {
return this._element.getAttribute('data-bs-content') || this.config.content;
return this.element.getAttribute('data-content') || this.config.content;
};
_proto._cleanTipClass = function _cleanTipClass() {
@ -201,7 +223,7 @@
Popover.jQueryInterface = function jQueryInterface(config) {
return this.each(function () {
var data = Data__default['default'].getData(this, DATA_KEY);
var data = Data.getData(this, DATA_KEY);
var _config = typeof config === 'object' ? config : null;
@ -211,7 +233,7 @@
if (!data) {
data = new Popover(this, _config);
Data__default['default'].setData(this, DATA_KEY, data);
Data.setData(this, DATA_KEY, data);
}
if (typeof config === 'string') {
@ -224,10 +246,20 @@
});
};
Popover.getInstance = function getInstance(element) {
return Data.getData(element, DATA_KEY);
};
_createClass(Popover, null, [
{
key: 'Default',
key: 'VERSION',
// Getters
get: function get() {
return VERSION;
},
},
{
key: 'Default',
get: function get() {
return Default;
},
@ -265,29 +297,27 @@
]);
return Popover;
})(Tooltip__default['default']);
})(Tooltip);
var $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Popover to jQuery only if jQuery is present
*/
onDOMContentLoaded(function () {
var $ = getjQuery();
/* istanbul ignore if */
/* istanbul ignore if */
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Popover.jQueryInterface;
$.fn[NAME].Constructor = Popover;
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Popover.jQueryInterface;
$.fn[NAME].Constructor = Popover;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Popover.jQueryInterface;
};
}
});
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Popover.jQueryInterface;
};
}
return Popover;
});

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*!
* Bootstrap scrollspy.js v5.0.0-beta1 (https://getbootstrap.com/)
* Bootstrap scrollspy.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
@ -13,12 +13,12 @@
))
: typeof define === 'function' && define.amd
? define([
'./dom/data',
'./dom/event-handler',
'./dom/manipulator',
'./dom/selector-engine',
'./dom/data.js',
'./dom/event-handler.js',
'./dom/manipulator.js',
'./dom/selector-engine.js',
], factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
: ((global = global || self),
(global.ScrollSpy = factory(
global.Data,
global.EventHandler,
@ -28,18 +28,23 @@
})(this, function (Data, EventHandler, Manipulator, SelectorEngine) {
'use strict';
function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : { default: e };
}
var Data__default = /*#__PURE__*/ _interopDefaultLegacy(Data);
var EventHandler__default = /*#__PURE__*/ _interopDefaultLegacy(EventHandler);
var Manipulator__default = /*#__PURE__*/ _interopDefaultLegacy(Manipulator);
var SelectorEngine__default = /*#__PURE__*/ _interopDefaultLegacy(SelectorEngine);
Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data;
EventHandler =
EventHandler && Object.prototype.hasOwnProperty.call(EventHandler, 'default')
? EventHandler['default']
: EventHandler;
Manipulator =
Manipulator && Object.prototype.hasOwnProperty.call(Manipulator, 'default')
? Manipulator['default']
: Manipulator;
SelectorEngine =
SelectorEngine && Object.prototype.hasOwnProperty.call(SelectorEngine, 'default')
? SelectorEngine['default']
: SelectorEngine;
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/index.js
* Bootstrap (v5.0.0-alpha1): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -70,7 +75,7 @@
};
var getSelector = function getSelector(element) {
var selector = element.getAttribute('data-bs-target');
var selector = element.getAttribute('data-target');
if (!selector || selector === '#') {
var hrefAttr = element.getAttribute('href');
@ -115,22 +120,57 @@
var _window = window,
jQuery = _window.jQuery;
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
return jQuery;
}
return null;
};
var onDOMContentLoaded = function onDOMContentLoaded(callback) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callback);
} else {
callback();
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly)
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
};
return keys;
}
var isRTL = document.documentElement.dir === 'rtl';
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true,
});
} else {
obj[key] = value;
}
return obj;
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
@ -153,87 +193,8 @@
* ------------------------------------------------------------------------
*/
var VERSION = '5.0.0-beta1';
var BaseComponent = /*#__PURE__*/ (function () {
function BaseComponent(element) {
if (!element) {
return;
}
this._element = element;
Data__default['default'].setData(element, this.constructor.DATA_KEY, this);
}
var _proto = BaseComponent.prototype;
_proto.dispose = function dispose() {
Data__default['default'].removeData(this._element, this.constructor.DATA_KEY);
this._element = null;
};
/** Static */
BaseComponent.getInstance = function getInstance(element) {
return Data__default['default'].getData(element, this.DATA_KEY);
};
_createClass(BaseComponent, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
]);
return BaseComponent;
})();
function _extends() {
_extends =
Object.assign ||
function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _defineProperties$1(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass$1(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
if (staticProps) _defineProperties$1(Constructor, staticProps);
return Constructor;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'scrollspy';
var VERSION = '5.0.0-alpha1';
var DATA_KEY = 'bs.scrollspy';
var EVENT_KEY = '.' + DATA_KEY;
var DATA_API_KEY = '.data-api';
@ -252,7 +213,7 @@
var EVENT_LOAD_DATA_API = 'load' + EVENT_KEY + DATA_API_KEY;
var CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
var CLASS_NAME_ACTIVE = 'active';
var SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
var SELECTOR_DATA_SPY = '[data-spy="scroll"]';
var SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
var SELECTOR_NAV_LINKS = '.nav-link';
var SELECTOR_NAV_ITEMS = '.nav-item';
@ -267,40 +228,32 @@
* ------------------------------------------------------------------------
*/
var ScrollSpy = /*#__PURE__*/ (function (_BaseComponent) {
_inheritsLoose(ScrollSpy, _BaseComponent);
var ScrollSpy = /*#__PURE__*/ (function () {
function ScrollSpy(element, config) {
var _this;
var _this = this;
_this = _BaseComponent.call(this, element) || this;
_this._scrollElement = element.tagName === 'BODY' ? window : element;
_this._config = _this._getConfig(config);
_this._selector =
_this._config.target +
this._element = element;
this._scrollElement = element.tagName === 'BODY' ? window : element;
this._config = this._getConfig(config);
this._selector =
this._config.target +
' ' +
SELECTOR_NAV_LINKS +
', ' +
_this._config.target +
' ' +
SELECTOR_LIST_ITEMS +
', ' +
_this._config.target +
' .' +
CLASS_NAME_DROPDOWN_ITEM;
_this._offsets = [];
_this._targets = [];
_this._activeTarget = null;
_this._scrollHeight = 0;
EventHandler__default['default'].on(_this._scrollElement, EVENT_SCROLL, function (event) {
',' +
(this._config.target + ' ' + SELECTOR_LIST_ITEMS + ',') +
(this._config.target + ' .' + CLASS_NAME_DROPDOWN_ITEM);
this._offsets = [];
this._targets = [];
this._activeTarget = null;
this._scrollHeight = 0;
EventHandler.on(this._scrollElement, EVENT_SCROLL, function (event) {
return _this._process(event);
});
this.refresh();
_this.refresh();
this._process();
_this._process();
return _this;
Data.setData(element, DATA_KEY, this);
} // Getters
var _proto = ScrollSpy.prototype;
@ -316,22 +269,21 @@
this._offsets = [];
this._targets = [];
this._scrollHeight = this._getScrollHeight();
var targets = SelectorEngine__default['default'].find(this._selector);
var targets = SelectorEngine.find(this._selector);
targets
.map(function (element) {
var target;
var targetSelector = getSelectorFromElement(element);
var target = targetSelector
? SelectorEngine__default['default'].findOne(targetSelector)
: null;
if (targetSelector) {
target = SelectorEngine.findOne(targetSelector);
}
if (target) {
var targetBCR = target.getBoundingClientRect();
if (targetBCR.width || targetBCR.height) {
return [
Manipulator__default['default'][offsetMethod](target).top + offsetBase,
targetSelector,
];
return [Manipulator[offsetMethod](target).top + offsetBase, targetSelector];
}
}
@ -351,9 +303,9 @@
};
_proto.dispose = function dispose() {
_BaseComponent.prototype.dispose.call(this);
EventHandler__default['default'].off(this._scrollElement, EVENT_KEY);
Data.removeData(this._element, DATA_KEY);
EventHandler.off(this._scrollElement, EVENT_KEY);
this._element = null;
this._scrollElement = null;
this._config = null;
this._selector = null;
@ -364,7 +316,10 @@
}; // Private
_proto._getConfig = function _getConfig(config) {
config = _extends({}, Default, typeof config === 'object' && config ? config : {});
config = _objectSpread(
_objectSpread({}, Default),
typeof config === 'object' && config ? config : {}
);
if (typeof config.target !== 'string' && isElement(config.target)) {
var id = config.target.id;
@ -447,52 +402,44 @@
this._clear();
var queries = this._selector.split(',').map(function (selector) {
return (
selector + '[data-bs-target="' + target + '"],' + selector + '[href="' + target + '"]'
);
return selector + '[data-target="' + target + '"],' + selector + '[href="' + target + '"]';
});
var link = SelectorEngine__default['default'].findOne(queries.join(','));
var link = SelectorEngine.findOne(queries.join(','));
if (link.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
SelectorEngine__default['default']
.findOne(SELECTOR_DROPDOWN_TOGGLE, link.closest(SELECTOR_DROPDOWN))
.classList.add(CLASS_NAME_ACTIVE);
SelectorEngine.findOne(
SELECTOR_DROPDOWN_TOGGLE,
link.closest(SELECTOR_DROPDOWN)
).classList.add(CLASS_NAME_ACTIVE);
link.classList.add(CLASS_NAME_ACTIVE);
} else {
// Set triggered link as active
link.classList.add(CLASS_NAME_ACTIVE);
SelectorEngine__default['default']
.parents(link, SELECTOR_NAV_LIST_GROUP)
.forEach(function (listGroup) {
// Set triggered links parents as active
// With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
SelectorEngine__default['default']
.prev(listGroup, SELECTOR_NAV_LINKS + ', ' + SELECTOR_LIST_ITEMS)
.forEach(function (item) {
return item.classList.add(CLASS_NAME_ACTIVE);
}); // Handle special case when .nav-link is inside .nav-item
SelectorEngine.parents(link, SELECTOR_NAV_LIST_GROUP).forEach(function (listGroup) {
// Set triggered links parents as active
// With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
SelectorEngine.prev(listGroup, SELECTOR_NAV_LINKS + ', ' + SELECTOR_LIST_ITEMS).forEach(
function (item) {
return item.classList.add(CLASS_NAME_ACTIVE);
}
); // Handle special case when .nav-link is inside .nav-item
SelectorEngine__default['default']
.prev(listGroup, SELECTOR_NAV_ITEMS)
.forEach(function (navItem) {
SelectorEngine__default['default']
.children(navItem, SELECTOR_NAV_LINKS)
.forEach(function (item) {
return item.classList.add(CLASS_NAME_ACTIVE);
});
});
SelectorEngine.prev(listGroup, SELECTOR_NAV_ITEMS).forEach(function (navItem) {
SelectorEngine.children(navItem, SELECTOR_NAV_LINKS).forEach(function (item) {
return item.classList.add(CLASS_NAME_ACTIVE);
});
});
});
}
EventHandler__default['default'].trigger(this._scrollElement, EVENT_ACTIVATE, {
EventHandler.trigger(this._scrollElement, EVENT_ACTIVATE, {
relatedTarget: target,
});
};
_proto._clear = function _clear() {
SelectorEngine__default['default']
.find(this._selector)
SelectorEngine.find(this._selector)
.filter(function (node) {
return node.classList.contains(CLASS_NAME_ACTIVE);
})
@ -503,7 +450,7 @@
ScrollSpy.jQueryInterface = function jQueryInterface(config) {
return this.each(function () {
var data = Data__default['default'].getData(this, DATA_KEY);
var data = Data.getData(this, DATA_KEY);
var _config = typeof config === 'object' && config;
@ -521,56 +468,57 @@
});
};
_createClass$1(ScrollSpy, null, [
ScrollSpy.getInstance = function getInstance(element) {
return Data.getData(element, DATA_KEY);
};
_createClass(ScrollSpy, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
{
key: 'Default',
get: function get() {
return Default;
},
},
{
key: 'DATA_KEY',
get: function get() {
return DATA_KEY;
},
},
]);
return ScrollSpy;
})(BaseComponent);
})();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler__default['default'].on(window, EVENT_LOAD_DATA_API, function () {
SelectorEngine__default['default'].find(SELECTOR_DATA_SPY).forEach(function (spy) {
return new ScrollSpy(spy, Manipulator__default['default'].getDataAttributes(spy));
EventHandler.on(window, EVENT_LOAD_DATA_API, function () {
SelectorEngine.find(SELECTOR_DATA_SPY).forEach(function (spy) {
return new ScrollSpy(spy, Manipulator.getDataAttributes(spy));
});
});
var $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .ScrollSpy to jQuery only if jQuery is present
*/
onDOMContentLoaded(function () {
var $ = getjQuery();
/* istanbul ignore if */
/* istanbul ignore if */
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = ScrollSpy.jQueryInterface;
$.fn[NAME].Constructor = ScrollSpy;
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = ScrollSpy.jQueryInterface;
$.fn[NAME].Constructor = ScrollSpy;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return ScrollSpy.jQueryInterface;
};
}
});
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return ScrollSpy.jQueryInterface;
};
}
return ScrollSpy;
});

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*!
* Bootstrap tab.js v5.0.0-beta1 (https://getbootstrap.com/)
* Bootstrap tab.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
@ -11,23 +11,25 @@
require('./dom/selector-engine.js')
))
: typeof define === 'function' && define.amd
? define(['./dom/data', './dom/event-handler', './dom/selector-engine'], factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
? define(['./dom/data.js', './dom/event-handler.js', './dom/selector-engine.js'], factory)
: ((global = global || self),
(global.Tab = factory(global.Data, global.EventHandler, global.SelectorEngine)));
})(this, function (Data, EventHandler, SelectorEngine) {
'use strict';
function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : { default: e };
}
var Data__default = /*#__PURE__*/ _interopDefaultLegacy(Data);
var EventHandler__default = /*#__PURE__*/ _interopDefaultLegacy(EventHandler);
var SelectorEngine__default = /*#__PURE__*/ _interopDefaultLegacy(SelectorEngine);
Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data;
EventHandler =
EventHandler && Object.prototype.hasOwnProperty.call(EventHandler, 'default')
? EventHandler['default']
: EventHandler;
SelectorEngine =
SelectorEngine && Object.prototype.hasOwnProperty.call(SelectorEngine, 'default')
? SelectorEngine['default']
: SelectorEngine;
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/index.js
* Bootstrap (v5.0.0-alpha1): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -35,7 +37,7 @@
var TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
var getSelector = function getSelector(element) {
var selector = element.getAttribute('data-bs-target');
var selector = element.getAttribute('data-target');
if (!selector || selector === '#') {
var hrefAttr = element.getAttribute('href');
@ -59,8 +61,8 @@
transitionDuration = _window$getComputedSt.transitionDuration,
transitionDelay = _window$getComputedSt.transitionDelay;
var floatTransitionDuration = Number.parseFloat(transitionDuration);
var floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
var floatTransitionDuration = parseFloat(transitionDuration);
var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
if (!floatTransitionDuration && !floatTransitionDelay) {
return 0;
@ -68,10 +70,7 @@
transitionDuration = transitionDuration.split(',')[0];
transitionDelay = transitionDelay.split(',')[0];
return (
(Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) *
MILLISECONDS_MULTIPLIER
);
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
};
var triggerTransitionEnd = function triggerTransitionEnd(element) {
@ -104,23 +103,13 @@
var _window = window,
jQuery = _window.jQuery;
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
return jQuery;
}
return null;
};
var onDOMContentLoaded = function onDOMContentLoaded(callback) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callback);
} else {
callback();
}
};
var isRTL = document.documentElement.dir === 'rtl';
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
@ -142,70 +131,8 @@
* ------------------------------------------------------------------------
*/
var VERSION = '5.0.0-beta1';
var BaseComponent = /*#__PURE__*/ (function () {
function BaseComponent(element) {
if (!element) {
return;
}
this._element = element;
Data__default['default'].setData(element, this.constructor.DATA_KEY, this);
}
var _proto = BaseComponent.prototype;
_proto.dispose = function dispose() {
Data__default['default'].removeData(this._element, this.constructor.DATA_KEY);
this._element = null;
};
/** Static */
BaseComponent.getInstance = function getInstance(element) {
return Data__default['default'].getData(element, this.DATA_KEY);
};
_createClass(BaseComponent, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
]);
return BaseComponent;
})();
function _defineProperties$1(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass$1(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
if (staticProps) _defineProperties$1(Constructor, staticProps);
return Constructor;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'tab';
var VERSION = '5.0.0-alpha1';
var DATA_KEY = 'bs.tab';
var EVENT_KEY = '.' + DATA_KEY;
var DATA_API_KEY = '.data-api';
@ -223,8 +150,7 @@
var SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
var SELECTOR_ACTIVE = '.active';
var SELECTOR_ACTIVE_UL = ':scope > li > .active';
var SELECTOR_DATA_TOGGLE =
'[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]';
var SELECTOR_DATA_TOGGLE = '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]';
var SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
var SELECTOR_DROPDOWN_ACTIVE_CHILD = ':scope > .dropdown-menu .active';
/**
@ -233,12 +159,11 @@
* ------------------------------------------------------------------------
*/
var Tab = /*#__PURE__*/ (function (_BaseComponent) {
_inheritsLoose(Tab, _BaseComponent);
function Tab() {
return _BaseComponent.apply(this, arguments) || this;
}
var Tab = /*#__PURE__*/ (function () {
function Tab(element) {
this._element = element;
Data.setData(this._element, DATA_KEY, this);
} // Getters
var _proto = Tab.prototype;
@ -265,19 +190,19 @@
listElement.nodeName === 'UL' || listElement.nodeName === 'OL'
? SELECTOR_ACTIVE_UL
: SELECTOR_ACTIVE;
previous = SelectorEngine__default['default'].find(itemSelector, listElement);
previous = SelectorEngine.find(itemSelector, listElement);
previous = previous[previous.length - 1];
}
var hideEvent = null;
if (previous) {
hideEvent = EventHandler__default['default'].trigger(previous, EVENT_HIDE, {
hideEvent = EventHandler.trigger(previous, EVENT_HIDE, {
relatedTarget: this._element,
});
}
var showEvent = EventHandler__default['default'].trigger(this._element, EVENT_SHOW, {
var showEvent = EventHandler.trigger(this._element, EVENT_SHOW, {
relatedTarget: previous,
});
@ -288,10 +213,10 @@
this._activate(this._element, listElement);
var complete = function complete() {
EventHandler__default['default'].trigger(previous, EVENT_HIDDEN, {
EventHandler.trigger(previous, EVENT_HIDDEN, {
relatedTarget: _this._element,
});
EventHandler__default['default'].trigger(_this._element, EVENT_SHOWN, {
EventHandler.trigger(_this._element, EVENT_SHOWN, {
relatedTarget: previous,
});
};
@ -301,6 +226,11 @@
} else {
complete();
}
};
_proto.dispose = function dispose() {
Data.removeData(this._element, DATA_KEY);
this._element = null;
}; // Private
_proto._activate = function _activate(element, container, callback) {
@ -308,8 +238,8 @@
var activeElements =
container && (container.nodeName === 'UL' || container.nodeName === 'OL')
? SelectorEngine__default['default'].find(SELECTOR_ACTIVE_UL, container)
: SelectorEngine__default['default'].children(container, SELECTOR_ACTIVE);
? SelectorEngine.find(SELECTOR_ACTIVE_UL, container)
: SelectorEngine.children(container, SELECTOR_ACTIVE);
var active = activeElements[0];
var isTransitioning = callback && active && active.classList.contains(CLASS_NAME_FADE);
@ -320,7 +250,7 @@
if (active && isTransitioning) {
var transitionDuration = getTransitionDurationFromElement(active);
active.classList.remove(CLASS_NAME_SHOW);
EventHandler__default['default'].one(active, TRANSITION_END, complete);
EventHandler.one(active, TRANSITION_END, complete);
emulateTransitionEnd(active, transitionDuration);
} else {
complete();
@ -330,7 +260,7 @@
_proto._transitionComplete = function _transitionComplete(element, active, callback) {
if (active) {
active.classList.remove(CLASS_NAME_ACTIVE);
var dropdownChild = SelectorEngine__default['default'].findOne(
var dropdownChild = SelectorEngine.findOne(
SELECTOR_DROPDOWN_ACTIVE_CHILD,
active.parentNode
);
@ -360,11 +290,9 @@
var dropdownElement = element.closest(SELECTOR_DROPDOWN);
if (dropdownElement) {
SelectorEngine__default['default']
.find(SELECTOR_DROPDOWN_TOGGLE)
.forEach(function (dropdown) {
return dropdown.classList.add(CLASS_NAME_ACTIVE);
});
SelectorEngine.find(SELECTOR_DROPDOWN_TOGGLE).forEach(function (dropdown) {
return dropdown.classList.add(CLASS_NAME_ACTIVE);
});
}
element.setAttribute('aria-expanded', true);
@ -377,7 +305,7 @@
Tab.jQueryInterface = function jQueryInterface(config) {
return this.each(function () {
var data = Data__default['default'].getData(this, DATA_KEY) || new Tab(this);
var data = Data.getData(this, DATA_KEY) || new Tab(this);
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
@ -389,56 +317,52 @@
});
};
_createClass$1(Tab, null, [
Tab.getInstance = function getInstance(element) {
return Data.getData(element, DATA_KEY);
};
_createClass(Tab, null, [
{
key: 'DATA_KEY',
// Getters
key: 'VERSION',
get: function get() {
return DATA_KEY;
return VERSION;
},
},
]);
return Tab;
})(BaseComponent);
})();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler__default['default'].on(
document,
EVENT_CLICK_DATA_API,
SELECTOR_DATA_TOGGLE,
function (event) {
event.preventDefault();
var data = Data__default['default'].getData(this, DATA_KEY) || new Tab(this);
data.show();
}
);
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
event.preventDefault();
var data = Data.getData(this, DATA_KEY) || new Tab(this);
data.show();
});
var $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Tab to jQuery only if jQuery is present
* add .tab to jQuery only if jQuery is present
*/
onDOMContentLoaded(function () {
var $ = getjQuery();
/* istanbul ignore if */
/* istanbul ignore if */
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Tab.jQueryInterface;
$.fn[NAME].Constructor = Tab;
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Tab.jQueryInterface;
$.fn[NAME].Constructor = Tab;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Tab.jQueryInterface;
};
}
});
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Tab.jQueryInterface;
};
}
return Tab;
});

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*!
* Bootstrap toast.js v5.0.0-beta1 (https://getbootstrap.com/)
* Bootstrap toast.js v5.0.0-alpha1 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
@ -11,23 +11,25 @@
require('./dom/manipulator.js')
))
: typeof define === 'function' && define.amd
? define(['./dom/data', './dom/event-handler', './dom/manipulator'], factory)
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
? define(['./dom/data.js', './dom/event-handler.js', './dom/manipulator.js'], factory)
: ((global = global || self),
(global.Toast = factory(global.Data, global.EventHandler, global.Manipulator)));
})(this, function (Data, EventHandler, Manipulator) {
'use strict';
function _interopDefaultLegacy(e) {
return e && typeof e === 'object' && 'default' in e ? e : { default: e };
}
var Data__default = /*#__PURE__*/ _interopDefaultLegacy(Data);
var EventHandler__default = /*#__PURE__*/ _interopDefaultLegacy(EventHandler);
var Manipulator__default = /*#__PURE__*/ _interopDefaultLegacy(Manipulator);
Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data;
EventHandler =
EventHandler && Object.prototype.hasOwnProperty.call(EventHandler, 'default')
? EventHandler['default']
: EventHandler;
Manipulator =
Manipulator && Object.prototype.hasOwnProperty.call(Manipulator, 'default')
? Manipulator['default']
: Manipulator;
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/index.js
* Bootstrap (v5.0.0-alpha1): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -54,8 +56,8 @@
transitionDuration = _window$getComputedSt.transitionDuration,
transitionDelay = _window$getComputedSt.transitionDelay;
var floatTransitionDuration = Number.parseFloat(transitionDuration);
var floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
var floatTransitionDuration = parseFloat(transitionDuration);
var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
if (!floatTransitionDuration && !floatTransitionDelay) {
return 0;
@ -63,10 +65,7 @@
transitionDuration = transitionDuration.split(',')[0];
transitionDelay = transitionDelay.split(',')[0];
return (
(Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) *
MILLISECONDS_MULTIPLIER
);
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
};
var triggerTransitionEnd = function triggerTransitionEnd(element) {
@ -120,22 +119,57 @@
var _window = window,
jQuery = _window.jQuery;
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
return jQuery;
}
return null;
};
var onDOMContentLoaded = function onDOMContentLoaded(callback) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callback);
} else {
callback();
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly)
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
};
return keys;
}
var isRTL = document.documentElement.dir === 'rtl';
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true,
});
} else {
obj[key] = value;
}
return obj;
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
@ -158,87 +192,8 @@
* ------------------------------------------------------------------------
*/
var VERSION = '5.0.0-beta1';
var BaseComponent = /*#__PURE__*/ (function () {
function BaseComponent(element) {
if (!element) {
return;
}
this._element = element;
Data__default['default'].setData(element, this.constructor.DATA_KEY, this);
}
var _proto = BaseComponent.prototype;
_proto.dispose = function dispose() {
Data__default['default'].removeData(this._element, this.constructor.DATA_KEY);
this._element = null;
};
/** Static */
BaseComponent.getInstance = function getInstance(element) {
return Data__default['default'].getData(element, this.DATA_KEY);
};
_createClass(BaseComponent, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
]);
return BaseComponent;
})();
function _extends() {
_extends =
Object.assign ||
function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _defineProperties$1(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass$1(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
if (staticProps) _defineProperties$1(Constructor, staticProps);
return Constructor;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'toast';
var VERSION = '5.0.0-alpha1';
var DATA_KEY = 'bs.toast';
var EVENT_KEY = '.' + DATA_KEY;
var EVENT_CLICK_DISMISS = 'click.dismiss' + EVENT_KEY;
@ -258,59 +213,53 @@
var Default = {
animation: true,
autohide: true,
delay: 5000,
delay: 500,
};
var SELECTOR_DATA_DISMISS = '[data-bs-dismiss="toast"]';
var SELECTOR_DATA_DISMISS = '[data-dismiss="toast"]';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
var Toast = /*#__PURE__*/ (function (_BaseComponent) {
_inheritsLoose(Toast, _BaseComponent);
var Toast = /*#__PURE__*/ (function () {
function Toast(element, config) {
var _this;
this._element = element;
this._config = this._getConfig(config);
this._timeout = null;
_this = _BaseComponent.call(this, element) || this;
_this._config = _this._getConfig(config);
_this._timeout = null;
this._setListeners();
_this._setListeners();
return _this;
Data.setData(element, DATA_KEY, this);
} // Getters
var _proto = Toast.prototype;
// Public
_proto.show = function show() {
var _this2 = this;
var _this = this;
var showEvent = EventHandler__default['default'].trigger(this._element, EVENT_SHOW);
var showEvent = EventHandler.trigger(this._element, EVENT_SHOW);
if (showEvent.defaultPrevented) {
return;
}
this._clearTimeout();
if (this._config.animation) {
this._element.classList.add(CLASS_NAME_FADE);
}
var complete = function complete() {
_this2._element.classList.remove(CLASS_NAME_SHOWING);
_this._element.classList.remove(CLASS_NAME_SHOWING);
_this2._element.classList.add(CLASS_NAME_SHOW);
_this._element.classList.add(CLASS_NAME_SHOW);
EventHandler__default['default'].trigger(_this2._element, EVENT_SHOWN);
EventHandler.trigger(_this._element, EVENT_SHOWN);
if (_this2._config.autohide) {
_this2._timeout = setTimeout(function () {
_this2.hide();
}, _this2._config.delay);
if (_this._config.autohide) {
_this._timeout = setTimeout(function () {
_this.hide();
}, _this._config.delay);
}
};
@ -322,7 +271,7 @@
if (this._config.animation) {
var transitionDuration = getTransitionDurationFromElement(this._element);
EventHandler__default['default'].one(this._element, TRANSITION_END, complete);
EventHandler.one(this._element, TRANSITION_END, complete);
emulateTransitionEnd(this._element, transitionDuration);
} else {
complete();
@ -330,29 +279,29 @@
};
_proto.hide = function hide() {
var _this3 = this;
var _this2 = this;
if (!this._element.classList.contains(CLASS_NAME_SHOW)) {
return;
}
var hideEvent = EventHandler__default['default'].trigger(this._element, EVENT_HIDE);
var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
if (hideEvent.defaultPrevented) {
return;
}
var complete = function complete() {
_this3._element.classList.add(CLASS_NAME_HIDE);
_this2._element.classList.add(CLASS_NAME_HIDE);
EventHandler__default['default'].trigger(_this3._element, EVENT_HIDDEN);
EventHandler.trigger(_this2._element, EVENT_HIDDEN);
};
this._element.classList.remove(CLASS_NAME_SHOW);
if (this._config.animation) {
var transitionDuration = getTransitionDurationFromElement(this._element);
EventHandler__default['default'].one(this._element, TRANSITION_END, complete);
EventHandler.one(this._element, TRANSITION_END, complete);
emulateTransitionEnd(this._element, transitionDuration);
} else {
complete();
@ -360,24 +309,22 @@
};
_proto.dispose = function dispose() {
this._clearTimeout();
clearTimeout(this._timeout);
this._timeout = null;
if (this._element.classList.contains(CLASS_NAME_SHOW)) {
this._element.classList.remove(CLASS_NAME_SHOW);
}
EventHandler__default['default'].off(this._element, EVENT_CLICK_DISMISS);
_BaseComponent.prototype.dispose.call(this);
EventHandler.off(this._element, EVENT_CLICK_DISMISS);
Data.removeData(this._element, DATA_KEY);
this._element = null;
this._config = null;
}; // Private
_proto._getConfig = function _getConfig(config) {
config = _extends(
{},
Default,
Manipulator__default['default'].getDataAttributes(this._element),
config = _objectSpread(
_objectSpread(_objectSpread({}, Default), Manipulator.getDataAttributes(this._element)),
typeof config === 'object' && config ? config : {}
);
typeCheckConfig(NAME, config, this.constructor.DefaultType);
@ -385,26 +332,16 @@
};
_proto._setListeners = function _setListeners() {
var _this4 = this;
var _this3 = this;
EventHandler__default['default'].on(
this._element,
EVENT_CLICK_DISMISS,
SELECTOR_DATA_DISMISS,
function () {
return _this4.hide();
}
);
};
_proto._clearTimeout = function _clearTimeout() {
clearTimeout(this._timeout);
this._timeout = null;
EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function () {
return _this3.hide();
});
}; // Static
Toast.jQueryInterface = function jQueryInterface(config) {
return this.each(function () {
var data = Data__default['default'].getData(this, DATA_KEY);
var data = Data.getData(this, DATA_KEY);
var _config = typeof config === 'object' && config;
@ -422,7 +359,17 @@
});
};
_createClass$1(Toast, null, [
Toast.getInstance = function getInstance(element) {
return Data.getData(element, DATA_KEY);
};
_createClass(Toast, null, [
{
key: 'VERSION',
get: function get() {
return VERSION;
},
},
{
key: 'DefaultType',
get: function get() {
@ -435,38 +382,31 @@
return Default;
},
},
{
key: 'DATA_KEY',
get: function get() {
return DATA_KEY;
},
},
]);
return Toast;
})(BaseComponent);
})();
var $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Toast to jQuery only if jQuery is present
* add .toast to jQuery only if jQuery is present
*/
onDOMContentLoaded(function () {
var $ = getjQuery();
/* istanbul ignore if */
/* istanbul ignore if */
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Toast.jQueryInterface;
$.fn[NAME].Constructor = Toast;
if ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Toast.jQueryInterface;
$.fn[NAME].Constructor = Toast;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Toast.jQueryInterface;
};
}
});
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Toast.jQueryInterface;
};
}
return Toast;
});

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,154 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): alert.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import {
getjQuery,
onDOMContentLoaded,
TRANSITION_END,
emulateTransitionEnd,
getElementFromSelector,
getTransitionDurationFromElement,
} from './util/index';
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'alert';
const DATA_KEY = 'bs.alert';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
const SELECTOR_DISMISS = '[data-mdb-dismiss="alert"]';
const EVENT_CLOSE = `close${EVENT_KEY}`;
const EVENT_CLOSED = `closed${EVENT_KEY}`;
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
const CLASSNAME_ALERT = 'alert';
const CLASSNAME_FADE = 'fade';
const CLASSNAME_SHOW = 'show';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Alert extends BaseComponent {
// Getters
static get DATA_KEY() {
return DATA_KEY;
}
// Public
close(element) {
const rootElement = element ? this._getRootElement(element) : this._element;
const customEvent = this._triggerCloseEvent(rootElement);
if (customEvent === null || customEvent.defaultPrevented) {
return;
}
this._removeElement(rootElement);
}
// Private
_getRootElement(element) {
return getElementFromSelector(element) || element.closest(`.${CLASSNAME_ALERT}`);
}
_triggerCloseEvent(element) {
return EventHandler.trigger(element, EVENT_CLOSE);
}
_removeElement(element) {
element.classList.remove(CLASSNAME_SHOW);
if (!element.classList.contains(CLASSNAME_FADE)) {
this._destroyElement(element);
return;
}
const transitionDuration = getTransitionDurationFromElement(element);
EventHandler.one(element, TRANSITION_END, () => this._destroyElement(element));
emulateTransitionEnd(element, transitionDuration);
}
_destroyElement(element) {
if (element.parentNode) {
element.parentNode.removeChild(element);
}
EventHandler.trigger(element, EVENT_CLOSED);
}
// Static
static jQueryInterface(config) {
return this.each(function () {
let data = Data.getData(this, DATA_KEY);
if (!data) {
data = new Alert(this);
}
if (config === 'close') {
data[config](this);
}
});
}
static handleDismiss(alertInstance) {
return function (event) {
if (event) {
event.preventDefault();
}
alertInstance.close(this);
};
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DISMISS, Alert.handleDismiss(new Alert()));
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Alert to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Alert.jQueryInterface;
$.fn[NAME].Constructor = Alert;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Alert.jQueryInterface;
};
}
});
export default Alert;

View File

@ -1,44 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): base-component.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import Data from './dom/data';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const VERSION = '5.0.0-beta1';
class BaseComponent {
constructor(element) {
if (!element) {
return;
}
this._element = element;
Data.setData(element, this.constructor.DATA_KEY, this);
}
dispose() {
Data.removeData(this._element, this.constructor.DATA_KEY);
this._element = null;
}
/** Static */
static getInstance(element) {
return Data.getData(element, this.DATA_KEY);
}
static get VERSION() {
return VERSION;
}
}
export default BaseComponent;

View File

@ -1,108 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): button.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import { getjQuery, onDOMContentLoaded } from './util/index';
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'button';
const DATA_KEY = 'bs.button';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
const CLASS_NAME_ACTIVE = 'active';
const SELECTOR_DATA_TOGGLE = '[data-mdb-toggle="button"]';
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Button extends BaseComponent {
// Getters
static get DATA_KEY() {
return DATA_KEY;
}
// Public
toggle() {
// Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE));
}
// Static
static jQueryInterface(config) {
return this.each(function () {
let data = Data.getData(this, DATA_KEY);
if (!data) {
data = new Button(this);
}
if (config === 'toggle') {
data[config]();
}
});
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, (event) => {
event.preventDefault();
const button = event.target.closest(SELECTOR_DATA_TOGGLE);
let data = Data.getData(button, DATA_KEY);
if (!data) {
data = new Button(button);
}
data.toggle();
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Button to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Button.jQueryInterface;
$.fn[NAME].Constructor = Button;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Button.jQueryInterface;
};
}
});
export default Button;

View File

@ -1,632 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): carousel.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import {
getjQuery,
onDOMContentLoaded,
TRANSITION_END,
emulateTransitionEnd,
getElementFromSelector,
getTransitionDurationFromElement,
isVisible,
reflow,
triggerTransitionEnd,
typeCheckConfig,
} from './util/index';
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import Manipulator from './dom/manipulator';
import SelectorEngine from './dom/selector-engine';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'carousel';
const DATA_KEY = 'bs.carousel';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
const ARROW_LEFT_KEY = 'ArrowLeft';
const ARROW_RIGHT_KEY = 'ArrowRight';
const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
const SWIPE_THRESHOLD = 40;
const Default = {
interval: 5000,
keyboard: true,
slide: false,
pause: 'hover',
wrap: true,
touch: true,
};
const DefaultType = {
interval: '(number|boolean)',
keyboard: 'boolean',
slide: '(boolean|string)',
pause: '(string|boolean)',
wrap: 'boolean',
touch: 'boolean',
};
const DIRECTION_NEXT = 'next';
const DIRECTION_PREV = 'prev';
const DIRECTION_LEFT = 'left';
const DIRECTION_RIGHT = 'right';
const EVENT_SLIDE = `slide${EVENT_KEY}`;
const EVENT_SLID = `slid${EVENT_KEY}`;
const EVENT_KEYDOWN = `keydown${EVENT_KEY}`;
const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY}`;
const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY}`;
const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`;
const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`;
const EVENT_TOUCHEND = `touchend${EVENT_KEY}`;
const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY}`;
const EVENT_POINTERUP = `pointerup${EVENT_KEY}`;
const EVENT_DRAG_START = `dragstart${EVENT_KEY}`;
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
const CLASS_NAME_CAROUSEL = 'carousel';
const CLASS_NAME_ACTIVE = 'active';
const CLASS_NAME_SLIDE = 'slide';
const CLASS_NAME_END = 'carousel-item-end';
const CLASS_NAME_START = 'carousel-item-start';
const CLASS_NAME_NEXT = 'carousel-item-next';
const CLASS_NAME_PREV = 'carousel-item-prev';
const CLASS_NAME_POINTER_EVENT = 'pointer-event';
const SELECTOR_ACTIVE = '.active';
const SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
const SELECTOR_ITEM = '.carousel-item';
const SELECTOR_ITEM_IMG = '.carousel-item img';
const SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
const SELECTOR_INDICATORS = '.carousel-indicators';
const SELECTOR_DATA_SLIDE = '[data-mdb-slide], [data-mdb-slide-to]';
const SELECTOR_DATA_RIDE = '[data-mdb-ride="carousel"]';
const PointerType = {
TOUCH: 'touch',
PEN: 'pen',
};
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Carousel extends BaseComponent {
constructor(element, config) {
super(element);
this._items = null;
this._interval = null;
this._activeElement = null;
this._isPaused = false;
this._isSliding = false;
this.touchTimeout = null;
this.touchStartX = 0;
this.touchDeltaX = 0;
this._config = this._getConfig(config);
this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
this._touchSupported =
'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
this._pointerEvent = Boolean(window.PointerEvent);
this._addEventListeners();
}
// Getters
static get Default() {
return Default;
}
static get DATA_KEY() {
return DATA_KEY;
}
// Public
next() {
if (!this._isSliding) {
this._slide(DIRECTION_NEXT);
}
}
nextWhenVisible() {
// Don't call next when the page isn't visible
// or the carousel or its parent isn't visible
if (!document.hidden && isVisible(this._element)) {
this.next();
}
}
prev() {
if (!this._isSliding) {
this._slide(DIRECTION_PREV);
}
}
pause(event) {
if (!event) {
this._isPaused = true;
}
if (SelectorEngine.findOne(SELECTOR_NEXT_PREV, this._element)) {
triggerTransitionEnd(this._element);
this.cycle(true);
}
clearInterval(this._interval);
this._interval = null;
}
cycle(event) {
if (!event) {
this._isPaused = false;
}
if (this._interval) {
clearInterval(this._interval);
this._interval = null;
}
if (this._config && this._config.interval && !this._isPaused) {
this._updateInterval();
this._interval = setInterval(
(document.visibilityState ? this.nextWhenVisible : this.next).bind(this),
this._config.interval
);
}
}
to(index) {
this._activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
const activeIndex = this._getItemIndex(this._activeElement);
if (index > this._items.length - 1 || index < 0) {
return;
}
if (this._isSliding) {
EventHandler.one(this._element, EVENT_SLID, () => this.to(index));
return;
}
if (activeIndex === index) {
this.pause();
this.cycle();
return;
}
const direction = index > activeIndex ? DIRECTION_NEXT : DIRECTION_PREV;
this._slide(direction, this._items[index]);
}
dispose() {
super.dispose();
EventHandler.off(this._element, EVENT_KEY);
this._items = null;
this._config = null;
this._interval = null;
this._isPaused = null;
this._isSliding = null;
this._activeElement = null;
this._indicatorsElement = null;
}
// Private
_getConfig(config) {
config = {
...Default,
...config,
};
typeCheckConfig(NAME, config, DefaultType);
return config;
}
_handleSwipe() {
const absDeltax = Math.abs(this.touchDeltaX);
if (absDeltax <= SWIPE_THRESHOLD) {
return;
}
const direction = absDeltax / this.touchDeltaX;
this.touchDeltaX = 0;
// swipe left
if (direction > 0) {
this.prev();
}
// swipe right
if (direction < 0) {
this.next();
}
}
_addEventListeners() {
if (this._config.keyboard) {
EventHandler.on(this._element, EVENT_KEYDOWN, (event) => this._keydown(event));
}
if (this._config.pause === 'hover') {
EventHandler.on(this._element, EVENT_MOUSEENTER, (event) => this.pause(event));
EventHandler.on(this._element, EVENT_MOUSELEAVE, (event) => this.cycle(event));
}
if (this._config.touch && this._touchSupported) {
this._addTouchEventListeners();
}
}
_addTouchEventListeners() {
const start = (event) => {
if (this._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
this.touchStartX = event.clientX;
} else if (!this._pointerEvent) {
this.touchStartX = event.touches[0].clientX;
}
};
const move = (event) => {
// ensure swiping with one touch and not pinching
if (event.touches && event.touches.length > 1) {
this.touchDeltaX = 0;
} else {
this.touchDeltaX = event.touches[0].clientX - this.touchStartX;
}
};
const end = (event) => {
if (this._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
this.touchDeltaX = event.clientX - this.touchStartX;
}
this._handleSwipe();
if (this._config.pause === 'hover') {
// If it's a touch-enabled device, mouseenter/leave are fired as
// part of the mouse compatibility events on first tap - the carousel
// would stop cycling until user tapped out of it;
// here, we listen for touchend, explicitly pause the carousel
// (as if it's the second time we tap on it, mouseenter compat event
// is NOT fired) and after a timeout (to allow for mouse compatibility
// events to fire) we explicitly restart cycling
this.pause();
if (this.touchTimeout) {
clearTimeout(this.touchTimeout);
}
this.touchTimeout = setTimeout(
(event) => this.cycle(event),
TOUCHEVENT_COMPAT_WAIT + this._config.interval
);
}
};
SelectorEngine.find(SELECTOR_ITEM_IMG, this._element).forEach((itemImg) => {
EventHandler.on(itemImg, EVENT_DRAG_START, (e) => e.preventDefault());
});
if (this._pointerEvent) {
EventHandler.on(this._element, EVENT_POINTERDOWN, (event) => start(event));
EventHandler.on(this._element, EVENT_POINTERUP, (event) => end(event));
this._element.classList.add(CLASS_NAME_POINTER_EVENT);
} else {
EventHandler.on(this._element, EVENT_TOUCHSTART, (event) => start(event));
EventHandler.on(this._element, EVENT_TOUCHMOVE, (event) => move(event));
EventHandler.on(this._element, EVENT_TOUCHEND, (event) => end(event));
}
}
_keydown(event) {
if (/input|textarea/i.test(event.target.tagName)) {
return;
}
switch (event.key) {
case ARROW_LEFT_KEY:
event.preventDefault();
this.prev();
break;
case ARROW_RIGHT_KEY:
event.preventDefault();
this.next();
break;
default:
}
}
_getItemIndex(element) {
this._items =
element && element.parentNode ? SelectorEngine.find(SELECTOR_ITEM, element.parentNode) : [];
return this._items.indexOf(element);
}
_getItemByDirection(direction, activeElement) {
const isNextDirection = direction === DIRECTION_NEXT;
const isPrevDirection = direction === DIRECTION_PREV;
const activeIndex = this._getItemIndex(activeElement);
const lastItemIndex = this._items.length - 1;
const isGoingToWrap =
(isPrevDirection && activeIndex === 0) || (isNextDirection && activeIndex === lastItemIndex);
if (isGoingToWrap && !this._config.wrap) {
return activeElement;
}
const delta = direction === DIRECTION_PREV ? -1 : 1;
const itemIndex = (activeIndex + delta) % this._items.length;
return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
}
_triggerSlideEvent(relatedTarget, eventDirectionName) {
const targetIndex = this._getItemIndex(relatedTarget);
const fromIndex = this._getItemIndex(
SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element)
);
return EventHandler.trigger(this._element, EVENT_SLIDE, {
relatedTarget,
direction: eventDirectionName,
from: fromIndex,
to: targetIndex,
});
}
_setActiveIndicatorElement(element) {
if (this._indicatorsElement) {
const indicators = SelectorEngine.find(SELECTOR_ACTIVE, this._indicatorsElement);
for (let i = 0; i < indicators.length; i++) {
indicators[i].classList.remove(CLASS_NAME_ACTIVE);
}
const nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
if (nextIndicator) {
nextIndicator.classList.add(CLASS_NAME_ACTIVE);
}
}
}
_updateInterval() {
const element =
this._activeElement || SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
if (!element) {
return;
}
const elementInterval = Number.parseInt(element.getAttribute('data-mdb-interval'), 10);
if (elementInterval) {
this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
this._config.interval = elementInterval;
} else {
this._config.interval = this._config.defaultInterval || this._config.interval;
}
}
_slide(direction, element) {
const activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
const activeElementIndex = this._getItemIndex(activeElement);
const nextElement =
element || (activeElement && this._getItemByDirection(direction, activeElement));
const nextElementIndex = this._getItemIndex(nextElement);
const isCycling = Boolean(this._interval);
let directionalClassName;
let orderClassName;
let eventDirectionName;
if (direction === DIRECTION_NEXT) {
directionalClassName = CLASS_NAME_START;
orderClassName = CLASS_NAME_NEXT;
eventDirectionName = DIRECTION_LEFT;
} else {
directionalClassName = CLASS_NAME_END;
orderClassName = CLASS_NAME_PREV;
eventDirectionName = DIRECTION_RIGHT;
}
if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE)) {
this._isSliding = false;
return;
}
const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
if (slideEvent.defaultPrevented) {
return;
}
if (!activeElement || !nextElement) {
// Some weirdness is happening, so we bail
return;
}
this._isSliding = true;
if (isCycling) {
this.pause();
}
this._setActiveIndicatorElement(nextElement);
this._activeElement = nextElement;
if (this._element.classList.contains(CLASS_NAME_SLIDE)) {
nextElement.classList.add(orderClassName);
reflow(nextElement);
activeElement.classList.add(directionalClassName);
nextElement.classList.add(directionalClassName);
const transitionDuration = getTransitionDurationFromElement(activeElement);
EventHandler.one(activeElement, TRANSITION_END, () => {
nextElement.classList.remove(directionalClassName, orderClassName);
nextElement.classList.add(CLASS_NAME_ACTIVE);
activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName);
this._isSliding = false;
setTimeout(() => {
EventHandler.trigger(this._element, EVENT_SLID, {
relatedTarget: nextElement,
direction: eventDirectionName,
from: activeElementIndex,
to: nextElementIndex,
});
}, 0);
});
emulateTransitionEnd(activeElement, transitionDuration);
} else {
activeElement.classList.remove(CLASS_NAME_ACTIVE);
nextElement.classList.add(CLASS_NAME_ACTIVE);
this._isSliding = false;
EventHandler.trigger(this._element, EVENT_SLID, {
relatedTarget: nextElement,
direction: eventDirectionName,
from: activeElementIndex,
to: nextElementIndex,
});
}
if (isCycling) {
this.cycle();
}
}
// Static
static carouselInterface(element, config) {
let data = Data.getData(element, DATA_KEY);
let _config = {
...Default,
...Manipulator.getDataAttributes(element),
};
if (typeof config === 'object') {
_config = {
..._config,
...config,
};
}
const action = typeof config === 'string' ? config : _config.slide;
if (!data) {
data = new Carousel(element, _config);
}
if (typeof config === 'number') {
data.to(config);
} else if (typeof action === 'string') {
if (typeof data[action] === 'undefined') {
throw new TypeError(`No method named "${action}"`);
}
data[action]();
} else if (_config.interval && _config.ride) {
data.pause();
data.cycle();
}
}
static jQueryInterface(config) {
return this.each(function () {
Carousel.carouselInterface(this, config);
});
}
static dataApiClickHandler(event) {
const target = getElementFromSelector(this);
if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
return;
}
const config = {
...Manipulator.getDataAttributes(target),
...Manipulator.getDataAttributes(this),
};
const slideIndex = this.getAttribute('data-mdb-slide-to');
if (slideIndex) {
config.interval = false;
}
Carousel.carouselInterface(target, config);
if (slideIndex) {
Data.getData(target, DATA_KEY).to(slideIndex);
}
event.preventDefault();
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler);
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
for (let i = 0, len = carousels.length; i < len; i++) {
Carousel.carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY));
}
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Carousel to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Carousel.jQueryInterface;
$.fn[NAME].Constructor = Carousel;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Carousel.jQueryInterface;
};
}
});
export default Carousel;

View File

@ -1,420 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): collapse.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import {
getjQuery,
onDOMContentLoaded,
TRANSITION_END,
emulateTransitionEnd,
getSelectorFromElement,
getElementFromSelector,
getTransitionDurationFromElement,
isElement,
reflow,
typeCheckConfig,
} from './util/index';
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import Manipulator from './dom/manipulator';
import SelectorEngine from './dom/selector-engine';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'collapse';
const DATA_KEY = 'bs.collapse';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
const Default = {
toggle: true,
parent: '',
};
const DefaultType = {
toggle: 'boolean',
parent: '(string|element)',
};
const EVENT_SHOW = `show${EVENT_KEY}`;
const EVENT_SHOWN = `shown${EVENT_KEY}`;
const EVENT_HIDE = `hide${EVENT_KEY}`;
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
const CLASS_NAME_SHOW = 'show';
const CLASS_NAME_COLLAPSE = 'collapse';
const CLASS_NAME_COLLAPSING = 'collapsing';
const CLASS_NAME_COLLAPSED = 'collapsed';
const WIDTH = 'width';
const HEIGHT = 'height';
const SELECTOR_ACTIVES = '.show, .collapsing';
const SELECTOR_DATA_TOGGLE = '[data-mdb-toggle="collapse"]';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Collapse extends BaseComponent {
constructor(element, config) {
super(element);
this._isTransitioning = false;
this._config = this._getConfig(config);
this._triggerArray = SelectorEngine.find(
`${SELECTOR_DATA_TOGGLE}[href="#${element.id}"],` +
`${SELECTOR_DATA_TOGGLE}[data-mdb-target="#${element.id}"]`
);
const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE);
for (let i = 0, len = toggleList.length; i < len; i++) {
const elem = toggleList[i];
const selector = getSelectorFromElement(elem);
const filterElement = SelectorEngine.find(selector).filter(
(foundElem) => foundElem === element
);
if (selector !== null && filterElement.length) {
this._selector = selector;
this._triggerArray.push(elem);
}
}
this._parent = this._config.parent ? this._getParent() : null;
if (!this._config.parent) {
this._addAriaAndCollapsedClass(this._element, this._triggerArray);
}
if (this._config.toggle) {
this.toggle();
}
}
// Getters
static get Default() {
return Default;
}
static get DATA_KEY() {
return DATA_KEY;
}
// Public
toggle() {
if (this._element.classList.contains(CLASS_NAME_SHOW)) {
this.hide();
} else {
this.show();
}
}
show() {
if (this._isTransitioning || this._element.classList.contains(CLASS_NAME_SHOW)) {
return;
}
let actives;
let activesData;
if (this._parent) {
actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent).filter((elem) => {
if (typeof this._config.parent === 'string') {
return elem.getAttribute('data-mdb-parent') === this._config.parent;
}
return elem.classList.contains(CLASS_NAME_COLLAPSE);
});
if (actives.length === 0) {
actives = null;
}
}
const container = SelectorEngine.findOne(this._selector);
if (actives) {
const tempActiveData = actives.find((elem) => container !== elem);
activesData = tempActiveData ? Data.getData(tempActiveData, DATA_KEY) : null;
if (activesData && activesData._isTransitioning) {
return;
}
}
const startEvent = EventHandler.trigger(this._element, EVENT_SHOW);
if (startEvent.defaultPrevented) {
return;
}
if (actives) {
actives.forEach((elemActive) => {
if (container !== elemActive) {
Collapse.collapseInterface(elemActive, 'hide');
}
if (!activesData) {
Data.setData(elemActive, DATA_KEY, null);
}
});
}
const dimension = this._getDimension();
this._element.classList.remove(CLASS_NAME_COLLAPSE);
this._element.classList.add(CLASS_NAME_COLLAPSING);
this._element.style[dimension] = 0;
if (this._triggerArray.length) {
this._triggerArray.forEach((element) => {
element.classList.remove(CLASS_NAME_COLLAPSED);
element.setAttribute('aria-expanded', true);
});
}
this.setTransitioning(true);
const complete = () => {
this._element.classList.remove(CLASS_NAME_COLLAPSING);
this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
this._element.style[dimension] = '';
this.setTransitioning(false);
EventHandler.trigger(this._element, EVENT_SHOWN);
};
const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
const scrollSize = `scroll${capitalizedDimension}`;
const transitionDuration = getTransitionDurationFromElement(this._element);
EventHandler.one(this._element, TRANSITION_END, complete);
emulateTransitionEnd(this._element, transitionDuration);
this._element.style[dimension] = `${this._element[scrollSize]}px`;
}
hide() {
if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW)) {
return;
}
const startEvent = EventHandler.trigger(this._element, EVENT_HIDE);
if (startEvent.defaultPrevented) {
return;
}
const dimension = this._getDimension();
this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`;
reflow(this._element);
this._element.classList.add(CLASS_NAME_COLLAPSING);
this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
const triggerArrayLength = this._triggerArray.length;
if (triggerArrayLength > 0) {
for (let i = 0; i < triggerArrayLength; i++) {
const trigger = this._triggerArray[i];
const elem = getElementFromSelector(trigger);
if (elem && !elem.classList.contains(CLASS_NAME_SHOW)) {
trigger.classList.add(CLASS_NAME_COLLAPSED);
trigger.setAttribute('aria-expanded', false);
}
}
}
this.setTransitioning(true);
const complete = () => {
this.setTransitioning(false);
this._element.classList.remove(CLASS_NAME_COLLAPSING);
this._element.classList.add(CLASS_NAME_COLLAPSE);
EventHandler.trigger(this._element, EVENT_HIDDEN);
};
this._element.style[dimension] = '';
const transitionDuration = getTransitionDurationFromElement(this._element);
EventHandler.one(this._element, TRANSITION_END, complete);
emulateTransitionEnd(this._element, transitionDuration);
}
setTransitioning(isTransitioning) {
this._isTransitioning = isTransitioning;
}
dispose() {
super.dispose();
this._config = null;
this._parent = null;
this._triggerArray = null;
this._isTransitioning = null;
}
// Private
_getConfig(config) {
config = {
...Default,
...config,
};
config.toggle = Boolean(config.toggle); // Coerce string values
typeCheckConfig(NAME, config, DefaultType);
return config;
}
_getDimension() {
return this._element.classList.contains(WIDTH) ? WIDTH : HEIGHT;
}
_getParent() {
let { parent } = this._config;
if (isElement(parent)) {
// it's a jQuery object
if (typeof parent.jquery !== 'undefined' || typeof parent[0] !== 'undefined') {
parent = parent[0];
}
} else {
parent = SelectorEngine.findOne(parent);
}
const selector = `${SELECTOR_DATA_TOGGLE}[data-mdb-parent="${parent}"]`;
SelectorEngine.find(selector, parent).forEach((element) => {
const selected = getElementFromSelector(element);
this._addAriaAndCollapsedClass(selected, [element]);
});
return parent;
}
_addAriaAndCollapsedClass(element, triggerArray) {
if (!element || !triggerArray.length) {
return;
}
const isOpen = element.classList.contains(CLASS_NAME_SHOW);
triggerArray.forEach((elem) => {
if (isOpen) {
elem.classList.remove(CLASS_NAME_COLLAPSED);
} else {
elem.classList.add(CLASS_NAME_COLLAPSED);
}
elem.setAttribute('aria-expanded', isOpen);
});
}
// Static
static collapseInterface(element, config) {
let data = Data.getData(element, DATA_KEY);
const _config = {
...Default,
...Manipulator.getDataAttributes(element),
...(typeof config === 'object' && config ? config : {}),
};
if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) {
_config.toggle = false;
}
if (!data) {
data = new Collapse(element, _config);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
data[config]();
}
}
static jQueryInterface(config) {
return this.each(function () {
Collapse.collapseInterface(this, config);
});
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
// preventDefault only for <a> elements (which change the URL) not inside the collapsible element
if (event.target.tagName === 'A') {
event.preventDefault();
}
const triggerData = Manipulator.getDataAttributes(this);
const selector = getSelectorFromElement(this);
const selectorElements = SelectorEngine.find(selector);
selectorElements.forEach((element) => {
const data = Data.getData(element, DATA_KEY);
let config;
if (data) {
// update parent attribute
if (data._parent === null && typeof triggerData.parent === 'string') {
data._config.parent = triggerData.parent;
data._parent = data._getParent();
}
config = 'toggle';
} else {
config = triggerData;
}
Collapse.collapseInterface(element, config);
});
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Collapse to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Collapse.jQueryInterface;
$.fn[NAME].Constructor = Collapse;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Collapse.jQueryInterface;
};
}
});
export default Collapse;

View File

@ -1,67 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/data.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const mapData = (() => {
const storeData = {};
let id = 1;
return {
set(element, key, data) {
if (typeof element.bsKey === 'undefined') {
element.bsKey = {
key,
id,
};
id++;
}
storeData[element.bsKey.id] = data;
},
get(element, key) {
if (!element || typeof element.bsKey === 'undefined') {
return null;
}
const keyProperties = element.bsKey;
if (keyProperties.key === key) {
return storeData[keyProperties.id];
}
return null;
},
delete(element, key) {
if (typeof element.bsKey === 'undefined') {
return;
}
const keyProperties = element.bsKey;
if (keyProperties.key === key) {
delete storeData[keyProperties.id];
delete element.bsKey;
}
},
};
})();
const Data = {
setData(instance, key, data) {
mapData.set(instance, key, data);
},
getData(instance, key) {
return mapData.get(instance, key);
},
removeData(instance, key) {
mapData.delete(instance, key);
},
};
export default Data;

View File

@ -1,338 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/event-handler.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import { getjQuery } from '../util/index';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const namespaceRegex = /[^.]*(?=\..*)\.|.*/;
const stripNameRegex = /\..*/;
const stripUidRegex = /::\d+$/;
const eventRegistry = {}; // Events storage
let uidEvent = 1;
const customEvents = {
mouseenter: 'mouseover',
mouseleave: 'mouseout',
};
const nativeEvents = new Set([
'click',
'dblclick',
'mouseup',
'mousedown',
'contextmenu',
'mousewheel',
'DOMMouseScroll',
'mouseover',
'mouseout',
'mousemove',
'selectstart',
'selectend',
'keydown',
'keypress',
'keyup',
'orientationchange',
'touchstart',
'touchmove',
'touchend',
'touchcancel',
'pointerdown',
'pointermove',
'pointerup',
'pointerleave',
'pointercancel',
'gesturestart',
'gesturechange',
'gestureend',
'focus',
'blur',
'change',
'reset',
'select',
'submit',
'focusin',
'focusout',
'load',
'unload',
'beforeunload',
'resize',
'move',
'DOMContentLoaded',
'readystatechange',
'error',
'abort',
'scroll',
]);
/**
* ------------------------------------------------------------------------
* Private methods
* ------------------------------------------------------------------------
*/
function getUidEvent(element, uid) {
return (uid && `${uid}::${uidEvent++}`) || element.uidEvent || uidEvent++;
}
function getEvent(element) {
const uid = getUidEvent(element);
element.uidEvent = uid;
eventRegistry[uid] = eventRegistry[uid] || {};
return eventRegistry[uid];
}
function bootstrapHandler(element, fn) {
return function handler(event) {
event.delegateTarget = element;
if (handler.oneOff) {
EventHandler.off(element, event.type, fn);
}
return fn.apply(element, [event]);
};
}
function bootstrapDelegationHandler(element, selector, fn) {
return function handler(event) {
const domElements = element.querySelectorAll(selector);
for (let { target } = event; target && target !== this; target = target.parentNode) {
for (let i = domElements.length; i--; ) {
if (domElements[i] === target) {
event.delegateTarget = target;
if (handler.oneOff) {
EventHandler.off(element, event.type, fn);
}
return fn.apply(target, [event]);
}
}
}
// To please ESLint
return null;
};
}
function findHandler(events, handler, delegationSelector = null) {
const uidEventList = Object.keys(events);
for (let i = 0, len = uidEventList.length; i < len; i++) {
const event = events[uidEventList[i]];
if (event.originalHandler === handler && event.delegationSelector === delegationSelector) {
return event;
}
}
return null;
}
function normalizeParams(originalTypeEvent, handler, delegationFn) {
const delegation = typeof handler === 'string';
const originalHandler = delegation ? delegationFn : handler;
// allow to get the native events from namespaced events ('click.bs.button' --> 'click')
let typeEvent = originalTypeEvent.replace(stripNameRegex, '');
const custom = customEvents[typeEvent];
if (custom) {
typeEvent = custom;
}
const isNative = nativeEvents.has(typeEvent);
if (!isNative) {
typeEvent = originalTypeEvent;
}
return [delegation, originalHandler, typeEvent];
}
function addHandler(element, originalTypeEvent, handler, delegationFn, oneOff) {
if (typeof originalTypeEvent !== 'string' || !element) {
return;
}
if (!handler) {
handler = delegationFn;
delegationFn = null;
}
const [delegation, originalHandler, typeEvent] = normalizeParams(
originalTypeEvent,
handler,
delegationFn
);
const events = getEvent(element);
const handlers = events[typeEvent] || (events[typeEvent] = {});
const previousFn = findHandler(handlers, originalHandler, delegation ? handler : null);
if (previousFn) {
previousFn.oneOff = previousFn.oneOff && oneOff;
return;
}
const uid = getUidEvent(originalHandler, originalTypeEvent.replace(namespaceRegex, ''));
const fn = delegation
? bootstrapDelegationHandler(element, handler, delegationFn)
: bootstrapHandler(element, handler);
fn.delegationSelector = delegation ? handler : null;
fn.originalHandler = originalHandler;
fn.oneOff = oneOff;
fn.uidEvent = uid;
handlers[uid] = fn;
element.addEventListener(typeEvent, fn, delegation);
}
function removeHandler(element, events, typeEvent, handler, delegationSelector) {
const fn = findHandler(events[typeEvent], handler, delegationSelector);
if (!fn) {
return;
}
element.removeEventListener(typeEvent, fn, Boolean(delegationSelector));
delete events[typeEvent][fn.uidEvent];
}
function removeNamespacedHandlers(element, events, typeEvent, namespace) {
const storeElementEvent = events[typeEvent] || {};
Object.keys(storeElementEvent).forEach((handlerKey) => {
if (handlerKey.includes(namespace)) {
const event = storeElementEvent[handlerKey];
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector);
}
});
}
const EventHandler = {
on(element, event, handler, delegationFn) {
addHandler(element, event, handler, delegationFn, false);
},
one(element, event, handler, delegationFn) {
addHandler(element, event, handler, delegationFn, true);
},
off(element, originalTypeEvent, handler, delegationFn) {
if (typeof originalTypeEvent !== 'string' || !element) {
return;
}
const [delegation, originalHandler, typeEvent] = normalizeParams(
originalTypeEvent,
handler,
delegationFn
);
const inNamespace = typeEvent !== originalTypeEvent;
const events = getEvent(element);
const isNamespace = originalTypeEvent.startsWith('.');
if (typeof originalHandler !== 'undefined') {
// Simplest case: handler is passed, remove that listener ONLY.
if (!events || !events[typeEvent]) {
return;
}
removeHandler(element, events, typeEvent, originalHandler, delegation ? handler : null);
return;
}
if (isNamespace) {
Object.keys(events).forEach((elementEvent) => {
removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1));
});
}
const storeElementEvent = events[typeEvent] || {};
Object.keys(storeElementEvent).forEach((keyHandlers) => {
const handlerKey = keyHandlers.replace(stripUidRegex, '');
if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
const event = storeElementEvent[keyHandlers];
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector);
}
});
},
trigger(element, event, args) {
if (typeof event !== 'string' || !element) {
return null;
}
const $ = getjQuery();
const typeEvent = event.replace(stripNameRegex, '');
const inNamespace = event !== typeEvent;
const isNative = nativeEvents.has(typeEvent);
let jQueryEvent;
let bubbles = true;
let nativeDispatch = true;
let defaultPrevented = false;
let evt = null;
if (inNamespace && $) {
jQueryEvent = $.Event(event, args);
$(element).trigger(jQueryEvent);
bubbles = !jQueryEvent.isPropagationStopped();
nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
defaultPrevented = jQueryEvent.isDefaultPrevented();
}
if (isNative) {
evt = document.createEvent('HTMLEvents');
evt.initEvent(typeEvent, bubbles, true);
} else {
evt = new CustomEvent(event, {
bubbles,
cancelable: true,
});
}
// merge custom information in our event
if (typeof args !== 'undefined') {
Object.keys(args).forEach((key) => {
Object.defineProperty(evt, key, {
get() {
return args[key];
},
});
});
}
if (defaultPrevented) {
evt.preventDefault();
}
if (nativeDispatch) {
element.dispatchEvent(evt);
}
if (evt.defaultPrevented && typeof jQueryEvent !== 'undefined') {
jQueryEvent.preventDefault();
}
return evt;
},
};
export default EventHandler;

View File

@ -1,80 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/manipulator.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
function normalizeData(val) {
if (val === 'true') {
return true;
}
if (val === 'false') {
return false;
}
if (val === Number(val).toString()) {
return Number(val);
}
if (val === '' || val === 'null') {
return null;
}
return val;
}
function normalizeDataKey(key) {
return key.replace(/[A-Z]/g, (chr) => `-${chr.toLowerCase()}`);
}
const Manipulator = {
setDataAttribute(element, key, value) {
element.setAttribute(`data-mdb-${normalizeDataKey(key)}`, value);
},
removeDataAttribute(element, key) {
element.removeAttribute(`data-mdb-${normalizeDataKey(key)}`);
},
getDataAttributes(element) {
if (!element) {
return {};
}
const attributes = {};
Object.keys(element.dataset)
.filter((key) => key.startsWith('mdb'))
.forEach((key) => {
let pureKey = key.replace(/^mdb/, '');
pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
attributes[pureKey] = normalizeData(element.dataset[key]);
});
return attributes;
},
getDataAttribute(element, key) {
return normalizeData(element.getAttribute(`data-mdb-${normalizeDataKey(key)}`));
},
offset(element) {
const rect = element.getBoundingClientRect();
return {
top: rect.top + document.body.scrollTop,
left: rect.left + document.body.scrollLeft,
};
},
position(element) {
return {
top: element.offsetTop,
left: element.offsetLeft,
};
},
};
export default Manipulator;

View File

@ -1,80 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/selector-engine.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NODE_TEXT = 3;
const SelectorEngine = {
matches(element, selector) {
return element.matches(selector);
},
find(selector, element = document.documentElement) {
return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
},
findOne(selector, element = document.documentElement) {
return Element.prototype.querySelector.call(element, selector);
},
children(element, selector) {
const children = [].concat(...element.children);
return children.filter((child) => child.matches(selector));
},
parents(element, selector) {
const parents = [];
let ancestor = element.parentNode;
while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {
if (this.matches(ancestor, selector)) {
parents.push(ancestor);
}
ancestor = ancestor.parentNode;
}
return parents;
},
prev(element, selector) {
let previous = element.previousElementSibling;
while (previous) {
if (previous.matches(selector)) {
return [previous];
}
previous = previous.previousElementSibling;
}
return [];
},
next(element, selector) {
let next = element.nextElementSibling;
while (next) {
if (this.matches(next, selector)) {
return [next];
}
next = next.nextElementSibling;
}
return [];
},
};
export default SelectorEngine;

View File

@ -1,535 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dropdown.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import * as Popper from '@popperjs/core';
import {
getjQuery,
onDOMContentLoaded,
getElementFromSelector,
isElement,
isVisible,
isRTL,
noop,
typeCheckConfig,
} from './util/index';
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import Manipulator from './dom/manipulator';
import SelectorEngine from './dom/selector-engine';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'dropdown';
const DATA_KEY = 'bs.dropdown';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
const ESCAPE_KEY = 'Escape';
const SPACE_KEY = 'Space';
const TAB_KEY = 'Tab';
const ARROW_UP_KEY = 'ArrowUp';
const ARROW_DOWN_KEY = 'ArrowDown';
const RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button
const REGEXP_KEYDOWN = new RegExp(`${ARROW_UP_KEY}|${ARROW_DOWN_KEY}|${ESCAPE_KEY}`);
const EVENT_HIDE = `hide${EVENT_KEY}`;
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
const EVENT_SHOW = `show${EVENT_KEY}`;
const EVENT_SHOWN = `shown${EVENT_KEY}`;
const EVENT_CLICK = `click${EVENT_KEY}`;
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY}${DATA_API_KEY}`;
const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY}${DATA_API_KEY}`;
const CLASS_NAME_DISABLED = 'disabled';
const CLASS_NAME_SHOW = 'show';
const CLASS_NAME_DROPUP = 'dropup';
const CLASS_NAME_DROPEND = 'dropend';
const CLASS_NAME_DROPSTART = 'dropstart';
const CLASS_NAME_NAVBAR = 'navbar';
const SELECTOR_DATA_TOGGLE = '[data-mdb-toggle="dropdown"]';
const SELECTOR_FORM_CHILD = '.dropdown form';
const SELECTOR_MENU = '.dropdown-menu';
const SELECTOR_NAVBAR_NAV = '.navbar-nav';
const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
const PLACEMENT_TOP = isRTL ? 'top-end' : 'top-start';
const PLACEMENT_TOPEND = isRTL ? 'top-start' : 'top-end';
const PLACEMENT_BOTTOM = isRTL ? 'bottom-end' : 'bottom-start';
const PLACEMENT_BOTTOMEND = isRTL ? 'bottom-start' : 'bottom-end';
const PLACEMENT_RIGHT = isRTL ? 'left-start' : 'right-start';
const PLACEMENT_LEFT = isRTL ? 'right-start' : 'left-start';
const Default = {
offset: 0,
flip: true,
boundary: 'clippingParents',
reference: 'toggle',
display: 'dynamic',
popperConfig: null,
};
const DefaultType = {
offset: '(number|string|function)',
flip: 'boolean',
boundary: '(string|element)',
reference: '(string|element)',
display: 'string',
popperConfig: '(null|object)',
};
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Dropdown extends BaseComponent {
constructor(element, config) {
super(element);
this._popper = null;
this._config = this._getConfig(config);
this._menu = this._getMenuElement();
this._inNavbar = this._detectNavbar();
this._addEventListeners();
}
// Getters
static get Default() {
return Default;
}
static get DefaultType() {
return DefaultType;
}
static get DATA_KEY() {
return DATA_KEY;
}
// Public
toggle() {
if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED)) {
return;
}
const isActive = this._element.classList.contains(CLASS_NAME_SHOW);
Dropdown.clearMenus();
if (isActive) {
return;
}
this.show();
}
show() {
if (
this._element.disabled ||
this._element.classList.contains(CLASS_NAME_DISABLED) ||
this._menu.classList.contains(CLASS_NAME_SHOW)
) {
return;
}
const parent = Dropdown.getParentFromElement(this._element);
const relatedTarget = {
relatedTarget: this._element,
};
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, relatedTarget);
if (showEvent.defaultPrevented) {
return;
}
// Totally disable Popper for Dropdowns in Navbar
if (!this._inNavbar) {
if (typeof Popper === 'undefined') {
throw new TypeError("Bootstrap's dropdowns require Popper (https://popper.js.org)");
}
let referenceElement = this._element;
if (this._config.reference === 'parent') {
referenceElement = parent;
} else if (isElement(this._config.reference)) {
referenceElement = this._config.reference;
// Check if it's jQuery element
if (typeof this._config.reference.jquery !== 'undefined') {
referenceElement = this._config.reference[0];
}
}
this._popper = Popper.createPopper(referenceElement, this._menu, this._getPopperConfig());
}
// If this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
// only needed because of broken event delegation on iOS
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
if ('ontouchstart' in document.documentElement && !parent.closest(SELECTOR_NAVBAR_NAV)) {
[]
.concat(...document.body.children)
.forEach((elem) => EventHandler.on(elem, 'mouseover', null, noop()));
}
this._element.focus();
this._element.setAttribute('aria-expanded', true);
this._menu.classList.toggle(CLASS_NAME_SHOW);
this._element.classList.toggle(CLASS_NAME_SHOW);
EventHandler.trigger(parent, EVENT_SHOWN, relatedTarget);
}
hide() {
if (
this._element.disabled ||
this._element.classList.contains(CLASS_NAME_DISABLED) ||
!this._menu.classList.contains(CLASS_NAME_SHOW)
) {
return;
}
const parent = Dropdown.getParentFromElement(this._element);
const relatedTarget = {
relatedTarget: this._element,
};
const hideEvent = EventHandler.trigger(parent, EVENT_HIDE, relatedTarget);
if (hideEvent.defaultPrevented) {
return;
}
if (this._popper) {
this._popper.destroy();
}
this._menu.classList.toggle(CLASS_NAME_SHOW);
this._element.classList.toggle(CLASS_NAME_SHOW);
EventHandler.trigger(parent, EVENT_HIDDEN, relatedTarget);
}
dispose() {
super.dispose();
EventHandler.off(this._element, EVENT_KEY);
this._menu = null;
if (this._popper) {
this._popper.destroy();
this._popper = null;
}
}
update() {
this._inNavbar = this._detectNavbar();
if (this._popper) {
this._popper.update();
}
}
// Private
_addEventListeners() {
EventHandler.on(this._element, EVENT_CLICK, (event) => {
event.preventDefault();
event.stopPropagation();
this.toggle();
});
}
_getConfig(config) {
config = {
...this.constructor.Default,
...Manipulator.getDataAttributes(this._element),
...config,
};
typeCheckConfig(NAME, config, this.constructor.DefaultType);
return config;
}
_getMenuElement() {
return SelectorEngine.next(this._element, SELECTOR_MENU)[0];
}
_getPlacement() {
const parentDropdown = this._element.parentNode;
if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
return PLACEMENT_RIGHT;
}
if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
return PLACEMENT_LEFT;
}
// We need to trim the value because custom properties can also include spaces
const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
}
return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
}
_detectNavbar() {
return this._element.closest(`.${CLASS_NAME_NAVBAR}`) !== null;
}
_getPopperConfig() {
const popperConfig = {
placement: this._getPlacement(),
modifiers: [
{
name: 'preventOverflow',
options: {
altBoundary: this._config.flip,
rootBoundary: this._config.boundary,
},
},
],
};
// Disable Popper if we have a static display
if (this._config.display === 'static') {
popperConfig.modifiers = [
{
name: 'applyStyles',
enabled: false,
},
];
}
return {
...popperConfig,
...this._config.popperConfig,
};
}
// Static
static dropdownInterface(element, config) {
let data = Data.getData(element, DATA_KEY);
const _config = typeof config === 'object' ? config : null;
if (!data) {
data = new Dropdown(element, _config);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
data[config]();
}
}
static jQueryInterface(config) {
return this.each(function () {
Dropdown.dropdownInterface(this, config);
});
}
static clearMenus(event) {
if (
event &&
(event.button === RIGHT_MOUSE_BUTTON || (event.type === 'keyup' && event.key !== TAB_KEY))
) {
return;
}
const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE);
for (let i = 0, len = toggles.length; i < len; i++) {
const parent = Dropdown.getParentFromElement(toggles[i]);
const context = Data.getData(toggles[i], DATA_KEY);
const relatedTarget = {
relatedTarget: toggles[i],
};
if (event && event.type === 'click') {
relatedTarget.clickEvent = event;
}
if (!context) {
continue;
}
const dropdownMenu = context._menu;
if (!toggles[i].classList.contains(CLASS_NAME_SHOW)) {
continue;
}
if (
event &&
((event.type === 'click' && /input|textarea/i.test(event.target.tagName)) ||
(event.type === 'keyup' && event.key === TAB_KEY)) &&
dropdownMenu.contains(event.target)
) {
continue;
}
const hideEvent = EventHandler.trigger(parent, EVENT_HIDE, relatedTarget);
if (hideEvent.defaultPrevented) {
continue;
}
// If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
if ('ontouchstart' in document.documentElement) {
[]
.concat(...document.body.children)
.forEach((elem) => EventHandler.off(elem, 'mouseover', null, noop()));
}
toggles[i].setAttribute('aria-expanded', 'false');
if (context._popper) {
context._popper.destroy();
}
dropdownMenu.classList.remove(CLASS_NAME_SHOW);
toggles[i].classList.remove(CLASS_NAME_SHOW);
EventHandler.trigger(parent, EVENT_HIDDEN, relatedTarget);
}
}
static getParentFromElement(element) {
return getElementFromSelector(element) || element.parentNode;
}
static dataApiKeydownHandler(event) {
// If not input/textarea:
// - And not a key in REGEXP_KEYDOWN => not a dropdown command
// If input/textarea:
// - If space key => not a dropdown command
// - If key is other than escape
// - If key is not up or down => not a dropdown command
// - If trigger inside the menu => not a dropdown command
if (
/input|textarea/i.test(event.target.tagName)
? event.key === SPACE_KEY ||
(event.key !== ESCAPE_KEY &&
((event.key !== ARROW_DOWN_KEY && event.key !== ARROW_UP_KEY) ||
event.target.closest(SELECTOR_MENU)))
: !REGEXP_KEYDOWN.test(event.key)
) {
return;
}
event.preventDefault();
event.stopPropagation();
if (this.disabled || this.classList.contains(CLASS_NAME_DISABLED)) {
return;
}
const parent = Dropdown.getParentFromElement(this);
const isActive = this.classList.contains(CLASS_NAME_SHOW);
if (event.key === ESCAPE_KEY) {
const button = this.matches(SELECTOR_DATA_TOGGLE)
? this
: SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE)[0];
button.focus();
Dropdown.clearMenus();
return;
}
if (!isActive || event.key === SPACE_KEY) {
Dropdown.clearMenus();
return;
}
const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, parent).filter(isVisible);
if (!items.length) {
return;
}
let index = items.indexOf(event.target);
// Up
if (event.key === ARROW_UP_KEY && index > 0) {
index--;
}
// Down
if (event.key === ARROW_DOWN_KEY && index < items.length - 1) {
index++;
}
// index is -1 if the first keydown is an ArrowUp
index = index === -1 ? 0 : index;
items[index].focus();
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler.on(
document,
EVENT_KEYDOWN_DATA_API,
SELECTOR_DATA_TOGGLE,
Dropdown.dataApiKeydownHandler
);
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
EventHandler.on(document, EVENT_CLICK_DATA_API, Dropdown.clearMenus);
EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
event.preventDefault();
event.stopPropagation();
Dropdown.dropdownInterface(this, 'toggle');
});
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_FORM_CHILD, (e) => e.stopPropagation());
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Dropdown to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Dropdown.jQueryInterface;
$.fn[NAME].Constructor = Dropdown;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Dropdown.jQueryInterface;
};
}
});
export default Dropdown;

View File

@ -1,632 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): modal.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import {
getjQuery,
onDOMContentLoaded,
TRANSITION_END,
emulateTransitionEnd,
getElementFromSelector,
getTransitionDurationFromElement,
isVisible,
isRTL,
reflow,
typeCheckConfig,
} from './util/index';
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import Manipulator from './dom/manipulator';
import SelectorEngine from './dom/selector-engine';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'modal';
const DATA_KEY = 'bs.modal';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
const ESCAPE_KEY = 'Escape';
const Default = {
backdrop: true,
keyboard: true,
focus: true,
};
const DefaultType = {
backdrop: '(boolean|string)',
keyboard: 'boolean',
focus: 'boolean',
};
const EVENT_HIDE = `hide${EVENT_KEY}`;
const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY}`;
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
const EVENT_SHOW = `show${EVENT_KEY}`;
const EVENT_SHOWN = `shown${EVENT_KEY}`;
const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
const EVENT_RESIZE = `resize${EVENT_KEY}`;
const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`;
const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`;
const EVENT_MOUSEUP_DISMISS = `mouseup.dismiss${EVENT_KEY}`;
const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY}`;
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
const CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure';
const CLASS_NAME_BACKDROP = 'modal-backdrop';
const CLASS_NAME_OPEN = 'modal-open';
const CLASS_NAME_FADE = 'fade';
const CLASS_NAME_SHOW = 'show';
const CLASS_NAME_STATIC = 'modal-static';
const SELECTOR_DIALOG = '.modal-dialog';
const SELECTOR_MODAL_BODY = '.modal-body';
const SELECTOR_DATA_TOGGLE = '[data-mdb-toggle="modal"]';
const SELECTOR_DATA_DISMISS = '[data-mdb-dismiss="modal"]';
const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
const SELECTOR_STICKY_CONTENT = '.sticky-top';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Modal extends BaseComponent {
constructor(element, config) {
super(element);
this._config = this._getConfig(config);
this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, element);
this._backdrop = null;
this._isShown = false;
this._isBodyOverflowing = false;
this._ignoreBackdropClick = false;
this._isTransitioning = false;
this._scrollbarWidth = 0;
}
// Getters
static get Default() {
return Default;
}
static get DATA_KEY() {
return DATA_KEY;
}
// Public
toggle(relatedTarget) {
return this._isShown ? this.hide() : this.show(relatedTarget);
}
show(relatedTarget) {
if (this._isShown || this._isTransitioning) {
return;
}
if (this._element.classList.contains(CLASS_NAME_FADE)) {
this._isTransitioning = true;
}
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, {
relatedTarget,
});
if (this._isShown || showEvent.defaultPrevented) {
return;
}
this._isShown = true;
this._checkScrollbar();
this._setScrollbar();
this._adjustDialog();
this._setEscapeEvent();
this._setResizeEvent();
EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, (event) =>
this.hide(event)
);
EventHandler.on(this._dialog, EVENT_MOUSEDOWN_DISMISS, () => {
EventHandler.one(this._element, EVENT_MOUSEUP_DISMISS, (event) => {
if (event.target === this._element) {
this._ignoreBackdropClick = true;
}
});
});
this._showBackdrop(() => this._showElement(relatedTarget));
}
hide(event) {
if (event) {
event.preventDefault();
}
if (!this._isShown || this._isTransitioning) {
return;
}
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
if (hideEvent.defaultPrevented) {
return;
}
this._isShown = false;
const transition = this._element.classList.contains(CLASS_NAME_FADE);
if (transition) {
this._isTransitioning = true;
}
this._setEscapeEvent();
this._setResizeEvent();
EventHandler.off(document, EVENT_FOCUSIN);
this._element.classList.remove(CLASS_NAME_SHOW);
EventHandler.off(this._element, EVENT_CLICK_DISMISS);
EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS);
if (transition) {
const transitionDuration = getTransitionDurationFromElement(this._element);
EventHandler.one(this._element, TRANSITION_END, (event) => this._hideModal(event));
emulateTransitionEnd(this._element, transitionDuration);
} else {
this._hideModal();
}
}
dispose() {
[window, this._element, this._dialog].forEach((htmlElement) =>
EventHandler.off(htmlElement, EVENT_KEY)
);
super.dispose();
/**
* `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
* Do not move `document` in `htmlElements` array
* It will remove `EVENT_CLICK_DATA_API` event that should remain
*/
EventHandler.off(document, EVENT_FOCUSIN);
this._config = null;
this._dialog = null;
this._backdrop = null;
this._isShown = null;
this._isBodyOverflowing = null;
this._ignoreBackdropClick = null;
this._isTransitioning = null;
this._scrollbarWidth = null;
}
handleUpdate() {
this._adjustDialog();
}
// Private
_getConfig(config) {
config = {
...Default,
...Manipulator.getDataAttributes(this._element),
...config,
};
typeCheckConfig(NAME, config, DefaultType);
return config;
}
_showElement(relatedTarget) {
const transition = this._element.classList.contains(CLASS_NAME_FADE);
const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
// Don't move modal's DOM position
document.body.appendChild(this._element);
}
this._element.style.display = 'block';
this._element.removeAttribute('aria-hidden');
this._element.setAttribute('aria-modal', true);
this._element.setAttribute('role', 'dialog');
this._element.scrollTop = 0;
if (modalBody) {
modalBody.scrollTop = 0;
}
if (transition) {
reflow(this._element);
}
this._element.classList.add(CLASS_NAME_SHOW);
if (this._config.focus) {
this._enforceFocus();
}
const transitionComplete = () => {
if (this._config.focus) {
this._element.focus();
}
this._isTransitioning = false;
EventHandler.trigger(this._element, EVENT_SHOWN, {
relatedTarget,
});
};
if (transition) {
const transitionDuration = getTransitionDurationFromElement(this._dialog);
EventHandler.one(this._dialog, TRANSITION_END, transitionComplete);
emulateTransitionEnd(this._dialog, transitionDuration);
} else {
transitionComplete();
}
}
_enforceFocus() {
EventHandler.off(document, EVENT_FOCUSIN); // guard against infinite focus loop
EventHandler.on(document, EVENT_FOCUSIN, (event) => {
if (
document !== event.target &&
this._element !== event.target &&
!this._element.contains(event.target)
) {
this._element.focus();
}
});
}
_setEscapeEvent() {
if (this._isShown) {
EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, (event) => {
if (this._config.keyboard && event.key === ESCAPE_KEY) {
event.preventDefault();
this.hide();
} else if (!this._config.keyboard && event.key === ESCAPE_KEY) {
this._triggerBackdropTransition();
}
});
} else {
EventHandler.off(this._element, EVENT_KEYDOWN_DISMISS);
}
}
_setResizeEvent() {
if (this._isShown) {
EventHandler.on(window, EVENT_RESIZE, () => this._adjustDialog());
} else {
EventHandler.off(window, EVENT_RESIZE);
}
}
_hideModal() {
this._element.style.display = 'none';
this._element.setAttribute('aria-hidden', true);
this._element.removeAttribute('aria-modal');
this._element.removeAttribute('role');
this._isTransitioning = false;
this._showBackdrop(() => {
document.body.classList.remove(CLASS_NAME_OPEN);
this._resetAdjustments();
this._resetScrollbar();
EventHandler.trigger(this._element, EVENT_HIDDEN);
});
}
_removeBackdrop() {
this._backdrop.parentNode.removeChild(this._backdrop);
this._backdrop = null;
}
_showBackdrop(callback) {
const animate = this._element.classList.contains(CLASS_NAME_FADE) ? CLASS_NAME_FADE : '';
if (this._isShown && this._config.backdrop) {
this._backdrop = document.createElement('div');
this._backdrop.className = CLASS_NAME_BACKDROP;
if (animate) {
this._backdrop.classList.add(animate);
}
document.body.appendChild(this._backdrop);
EventHandler.on(this._element, EVENT_CLICK_DISMISS, (event) => {
if (this._ignoreBackdropClick) {
this._ignoreBackdropClick = false;
return;
}
if (event.target !== event.currentTarget) {
return;
}
if (this._config.backdrop === 'static') {
this._triggerBackdropTransition();
} else {
this.hide();
}
});
if (animate) {
reflow(this._backdrop);
}
this._backdrop.classList.add(CLASS_NAME_SHOW);
if (!animate) {
callback();
return;
}
const backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
EventHandler.one(this._backdrop, TRANSITION_END, callback);
emulateTransitionEnd(this._backdrop, backdropTransitionDuration);
} else if (!this._isShown && this._backdrop) {
this._backdrop.classList.remove(CLASS_NAME_SHOW);
const callbackRemove = () => {
this._removeBackdrop();
callback();
};
if (this._element.classList.contains(CLASS_NAME_FADE)) {
const backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
EventHandler.one(this._backdrop, TRANSITION_END, callbackRemove);
emulateTransitionEnd(this._backdrop, backdropTransitionDuration);
} else {
callbackRemove();
}
} else {
callback();
}
}
_triggerBackdropTransition() {
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
if (hideEvent.defaultPrevented) {
return;
}
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
if (!isModalOverflowing) {
this._element.style.overflowY = 'hidden';
}
this._element.classList.add(CLASS_NAME_STATIC);
const modalTransitionDuration = getTransitionDurationFromElement(this._dialog);
EventHandler.off(this._element, TRANSITION_END);
EventHandler.one(this._element, TRANSITION_END, () => {
this._element.classList.remove(CLASS_NAME_STATIC);
if (!isModalOverflowing) {
EventHandler.one(this._element, TRANSITION_END, () => {
this._element.style.overflowY = '';
});
emulateTransitionEnd(this._element, modalTransitionDuration);
}
});
emulateTransitionEnd(this._element, modalTransitionDuration);
this._element.focus();
}
// ----------------------------------------------------------------------
// the following methods are used to handle overflowing modals
// ----------------------------------------------------------------------
_adjustDialog() {
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
if (
(!this._isBodyOverflowing && isModalOverflowing && !isRTL) ||
(this._isBodyOverflowing && !isModalOverflowing && isRTL)
) {
this._element.style.paddingLeft = `${this._scrollbarWidth}px`;
}
if (
(this._isBodyOverflowing && !isModalOverflowing && !isRTL) ||
(!this._isBodyOverflowing && isModalOverflowing && isRTL)
) {
this._element.style.paddingRight = `${this._scrollbarWidth}px`;
}
}
_resetAdjustments() {
this._element.style.paddingLeft = '';
this._element.style.paddingRight = '';
}
_checkScrollbar() {
const rect = document.body.getBoundingClientRect();
this._isBodyOverflowing = Math.round(rect.left + rect.right) < window.innerWidth;
this._scrollbarWidth = this._getScrollbarWidth();
}
_setScrollbar() {
if (this._isBodyOverflowing) {
// Note: DOMNode.style.paddingRight returns the actual value or '' if not set
// while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
// Adjust fixed content padding
SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach((element) => {
const actualPadding = element.style.paddingRight;
const calculatedPadding = window.getComputedStyle(element)['padding-right'];
Manipulator.setDataAttribute(element, 'padding-right', actualPadding);
element.style.paddingRight = `${
Number.parseFloat(calculatedPadding) + this._scrollbarWidth
}px`;
});
// Adjust sticky content margin
SelectorEngine.find(SELECTOR_STICKY_CONTENT).forEach((element) => {
const actualMargin = element.style.marginRight;
const calculatedMargin = window.getComputedStyle(element)['margin-right'];
Manipulator.setDataAttribute(element, 'margin-right', actualMargin);
element.style.marginRight = `${
Number.parseFloat(calculatedMargin) - this._scrollbarWidth
}px`;
});
// Adjust body padding
const actualPadding = document.body.style.paddingRight;
const calculatedPadding = window.getComputedStyle(document.body)['padding-right'];
Manipulator.setDataAttribute(document.body, 'padding-right', actualPadding);
document.body.style.paddingRight = `${
Number.parseFloat(calculatedPadding) + this._scrollbarWidth
}px`;
}
document.body.classList.add(CLASS_NAME_OPEN);
}
_resetScrollbar() {
// Restore fixed content padding
SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach((element) => {
const padding = Manipulator.getDataAttribute(element, 'padding-right');
if (typeof padding !== 'undefined') {
Manipulator.removeDataAttribute(element, 'padding-right');
element.style.paddingRight = padding;
}
});
// Restore sticky content and navbar-toggler margin
SelectorEngine.find(`${SELECTOR_STICKY_CONTENT}`).forEach((element) => {
const margin = Manipulator.getDataAttribute(element, 'margin-right');
if (typeof margin !== 'undefined') {
Manipulator.removeDataAttribute(element, 'margin-right');
element.style.marginRight = margin;
}
});
// Restore body padding
const padding = Manipulator.getDataAttribute(document.body, 'padding-right');
if (typeof padding === 'undefined') {
document.body.style.paddingRight = '';
} else {
Manipulator.removeDataAttribute(document.body, 'padding-right');
document.body.style.paddingRight = padding;
}
}
_getScrollbarWidth() {
// thx d.walsh
const scrollDiv = document.createElement('div');
scrollDiv.className = CLASS_NAME_SCROLLBAR_MEASURER;
document.body.appendChild(scrollDiv);
const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
return scrollbarWidth;
}
// Static
static jQueryInterface(config, relatedTarget) {
return this.each(function () {
let data = Data.getData(this, DATA_KEY);
const _config = {
...Default,
...Manipulator.getDataAttributes(this),
...(typeof config === 'object' && config ? config : {}),
};
if (!data) {
data = new Modal(this, _config);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
data[config](relatedTarget);
}
});
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
const target = getElementFromSelector(this);
if (this.tagName === 'A' || this.tagName === 'AREA') {
event.preventDefault();
}
EventHandler.one(target, EVENT_SHOW, (showEvent) => {
if (showEvent.defaultPrevented) {
// only register focus restorer if modal will actually get shown
return;
}
EventHandler.one(target, EVENT_HIDDEN, () => {
if (isVisible(this)) {
this.focus();
}
});
});
let data = Data.getData(target, DATA_KEY);
if (!data) {
const config = {
...Manipulator.getDataAttributes(target),
...Manipulator.getDataAttributes(this),
};
data = new Modal(target, config);
}
data.show(this);
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Modal to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Modal.jQueryInterface;
$.fn[NAME].Constructor = Modal;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Modal.jQueryInterface;
};
}
});
export default Modal;

View File

@ -1,182 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): popover.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import { getjQuery, onDOMContentLoaded } from './util/index';
import Data from './dom/data';
import SelectorEngine from './dom/selector-engine';
import Tooltip from './tooltip';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'popover';
const DATA_KEY = 'bs.popover';
const EVENT_KEY = `.${DATA_KEY}`;
const CLASS_PREFIX = 'bs-popover';
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g');
const Default = {
...Tooltip.Default,
placement: 'right',
trigger: 'click',
content: '',
template:
'<div class="popover" role="tooltip">' +
'<div class="popover-arrow"></div>' +
'<h3 class="popover-header"></h3>' +
'<div class="popover-body"></div>' +
'</div>',
};
const DefaultType = {
...Tooltip.DefaultType,
content: '(string|element|function)',
};
const Event = {
HIDE: `hide${EVENT_KEY}`,
HIDDEN: `hidden${EVENT_KEY}`,
SHOW: `show${EVENT_KEY}`,
SHOWN: `shown${EVENT_KEY}`,
INSERTED: `inserted${EVENT_KEY}`,
CLICK: `click${EVENT_KEY}`,
FOCUSIN: `focusin${EVENT_KEY}`,
FOCUSOUT: `focusout${EVENT_KEY}`,
MOUSEENTER: `mouseenter${EVENT_KEY}`,
MOUSELEAVE: `mouseleave${EVENT_KEY}`,
};
const CLASS_NAME_FADE = 'fade';
const CLASS_NAME_SHOW = 'show';
const SELECTOR_TITLE = '.popover-header';
const SELECTOR_CONTENT = '.popover-body';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Popover extends Tooltip {
// Getters
static get Default() {
return Default;
}
static get NAME() {
return NAME;
}
static get DATA_KEY() {
return DATA_KEY;
}
static get Event() {
return Event;
}
static get EVENT_KEY() {
return EVENT_KEY;
}
static get DefaultType() {
return DefaultType;
}
// Overrides
isWithContent() {
return this.getTitle() || this._getContent();
}
setContent() {
const tip = this.getTipElement();
// we use append for html objects to maintain js events
this.setElementContent(SelectorEngine.findOne(SELECTOR_TITLE, tip), this.getTitle());
let content = this._getContent();
if (typeof content === 'function') {
content = content.call(this._element);
}
this.setElementContent(SelectorEngine.findOne(SELECTOR_CONTENT, tip), content);
tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW);
}
// Private
_addAttachmentClass(attachment) {
this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`);
}
_getContent() {
return this._element.getAttribute('data-mdb-content') || this.config.content;
}
_cleanTipClass() {
const tip = this.getTipElement();
const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX);
if (tabClass !== null && tabClass.length > 0) {
tabClass.map((token) => token.trim()).forEach((tClass) => tip.classList.remove(tClass));
}
}
// Static
static jQueryInterface(config) {
return this.each(function () {
let data = Data.getData(this, DATA_KEY);
const _config = typeof config === 'object' ? config : null;
if (!data && /dispose|hide/.test(config)) {
return;
}
if (!data) {
data = new Popover(this, _config);
Data.setData(this, DATA_KEY, data);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
data[config]();
}
});
}
}
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Popover to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Popover.jQueryInterface;
$.fn[NAME].Constructor = Popover;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Popover.jQueryInterface;
};
}
});
export default Popover;

View File

@ -1,331 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): scrollspy.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import {
getjQuery,
onDOMContentLoaded,
getSelectorFromElement,
getUID,
isElement,
typeCheckConfig,
} from './util/index';
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import Manipulator from './dom/manipulator';
import SelectorEngine from './dom/selector-engine';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'scrollspy';
const DATA_KEY = 'bs.scrollspy';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
const Default = {
offset: 10,
method: 'auto',
target: '',
};
const DefaultType = {
offset: 'number',
method: 'string',
target: '(string|element)',
};
const EVENT_ACTIVATE = `activate${EVENT_KEY}`;
const EVENT_SCROLL = `scroll${EVENT_KEY}`;
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
const CLASS_NAME_ACTIVE = 'active';
const SELECTOR_DATA_SPY = '[data-mdb-spy="scroll"]';
const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
const SELECTOR_NAV_LINKS = '.nav-link';
const SELECTOR_NAV_ITEMS = '.nav-item';
const SELECTOR_LIST_ITEMS = '.list-group-item';
const SELECTOR_DROPDOWN = '.dropdown';
const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
const METHOD_OFFSET = 'offset';
const METHOD_POSITION = 'position';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class ScrollSpy extends BaseComponent {
constructor(element, config) {
super(element);
this._scrollElement = element.tagName === 'BODY' ? window : element;
this._config = this._getConfig(config);
this._selector = `${this._config.target} ${SELECTOR_NAV_LINKS}, ${this._config.target} ${SELECTOR_LIST_ITEMS}, ${this._config.target} .${CLASS_NAME_DROPDOWN_ITEM}`;
this._offsets = [];
this._targets = [];
this._activeTarget = null;
this._scrollHeight = 0;
EventHandler.on(this._scrollElement, EVENT_SCROLL, (event) => this._process(event));
this.refresh();
this._process();
}
// Getters
static get Default() {
return Default;
}
static get DATA_KEY() {
return DATA_KEY;
}
// Public
refresh() {
const autoMethod =
this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION;
const offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
const offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0;
this._offsets = [];
this._targets = [];
this._scrollHeight = this._getScrollHeight();
const targets = SelectorEngine.find(this._selector);
targets
.map((element) => {
const targetSelector = getSelectorFromElement(element);
const target = targetSelector ? SelectorEngine.findOne(targetSelector) : null;
if (target) {
const targetBCR = target.getBoundingClientRect();
if (targetBCR.width || targetBCR.height) {
return [Manipulator[offsetMethod](target).top + offsetBase, targetSelector];
}
}
return null;
})
.filter((item) => item)
.sort((a, b) => a[0] - b[0])
.forEach((item) => {
this._offsets.push(item[0]);
this._targets.push(item[1]);
});
}
dispose() {
super.dispose();
EventHandler.off(this._scrollElement, EVENT_KEY);
this._scrollElement = null;
this._config = null;
this._selector = null;
this._offsets = null;
this._targets = null;
this._activeTarget = null;
this._scrollHeight = null;
}
// Private
_getConfig(config) {
config = {
...Default,
...(typeof config === 'object' && config ? config : {}),
};
if (typeof config.target !== 'string' && isElement(config.target)) {
let { id } = config.target;
if (!id) {
id = getUID(NAME);
config.target.id = id;
}
config.target = `#${id}`;
}
typeCheckConfig(NAME, config, DefaultType);
return config;
}
_getScrollTop() {
return this._scrollElement === window
? this._scrollElement.pageYOffset
: this._scrollElement.scrollTop;
}
_getScrollHeight() {
return (
this._scrollElement.scrollHeight ||
Math.max(document.body.scrollHeight, document.documentElement.scrollHeight)
);
}
_getOffsetHeight() {
return this._scrollElement === window
? window.innerHeight
: this._scrollElement.getBoundingClientRect().height;
}
_process() {
const scrollTop = this._getScrollTop() + this._config.offset;
const scrollHeight = this._getScrollHeight();
const maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
if (this._scrollHeight !== scrollHeight) {
this.refresh();
}
if (scrollTop >= maxScroll) {
const target = this._targets[this._targets.length - 1];
if (this._activeTarget !== target) {
this._activate(target);
}
return;
}
if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
this._activeTarget = null;
this._clear();
return;
}
for (let i = this._offsets.length; i--; ) {
const isActiveTarget =
this._activeTarget !== this._targets[i] &&
scrollTop >= this._offsets[i] &&
(typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
if (isActiveTarget) {
this._activate(this._targets[i]);
}
}
}
_activate(target) {
this._activeTarget = target;
this._clear();
const queries = this._selector
.split(',')
.map((selector) => `${selector}[data-mdb-target="${target}"],${selector}[href="${target}"]`);
const link = SelectorEngine.findOne(queries.join(','));
if (link.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
SelectorEngine.findOne(
SELECTOR_DROPDOWN_TOGGLE,
link.closest(SELECTOR_DROPDOWN)
).classList.add(CLASS_NAME_ACTIVE);
link.classList.add(CLASS_NAME_ACTIVE);
} else {
// Set triggered link as active
link.classList.add(CLASS_NAME_ACTIVE);
SelectorEngine.parents(link, SELECTOR_NAV_LIST_GROUP).forEach((listGroup) => {
// Set triggered links parents as active
// With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
SelectorEngine.prev(
listGroup,
`${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`
).forEach((item) => item.classList.add(CLASS_NAME_ACTIVE));
// Handle special case when .nav-link is inside .nav-item
SelectorEngine.prev(listGroup, SELECTOR_NAV_ITEMS).forEach((navItem) => {
SelectorEngine.children(navItem, SELECTOR_NAV_LINKS).forEach((item) =>
item.classList.add(CLASS_NAME_ACTIVE)
);
});
});
}
EventHandler.trigger(this._scrollElement, EVENT_ACTIVATE, {
relatedTarget: target,
});
}
_clear() {
SelectorEngine.find(this._selector)
.filter((node) => node.classList.contains(CLASS_NAME_ACTIVE))
.forEach((node) => node.classList.remove(CLASS_NAME_ACTIVE));
}
// Static
static jQueryInterface(config) {
return this.each(function () {
let data = Data.getData(this, DATA_KEY);
const _config = typeof config === 'object' && config;
if (!data) {
data = new ScrollSpy(this, _config);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
data[config]();
}
});
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
SelectorEngine.find(SELECTOR_DATA_SPY).forEach(
(spy) => new ScrollSpy(spy, Manipulator.getDataAttributes(spy))
);
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .ScrollSpy to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = ScrollSpy.jQueryInterface;
$.fn[NAME].Constructor = ScrollSpy;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return ScrollSpy.jQueryInterface;
};
}
});
export default ScrollSpy;

View File

@ -1,247 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): tab.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import {
getjQuery,
onDOMContentLoaded,
TRANSITION_END,
emulateTransitionEnd,
getElementFromSelector,
getTransitionDurationFromElement,
reflow,
} from './util/index';
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import SelectorEngine from './dom/selector-engine';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'tab';
const DATA_KEY = 'bs.tab';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
const EVENT_HIDE = `hide${EVENT_KEY}`;
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
const EVENT_SHOW = `show${EVENT_KEY}`;
const EVENT_SHOWN = `shown${EVENT_KEY}`;
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
const CLASS_NAME_DROPDOWN_MENU = 'dropdown-menu';
const CLASS_NAME_ACTIVE = 'active';
const CLASS_NAME_DISABLED = 'disabled';
const CLASS_NAME_FADE = 'fade';
const CLASS_NAME_SHOW = 'show';
const SELECTOR_DROPDOWN = '.dropdown';
const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
const SELECTOR_ACTIVE = '.active';
const SELECTOR_ACTIVE_UL = ':scope > li > .active';
const SELECTOR_DATA_TOGGLE =
'[data-mdb-toggle="tab"], [data-mdb-toggle="pill"], [data-mdb-toggle="list"]';
const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
const SELECTOR_DROPDOWN_ACTIVE_CHILD = ':scope > .dropdown-menu .active';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Tab extends BaseComponent {
// Getters
static get DATA_KEY() {
return DATA_KEY;
}
// Public
show() {
if (
(this._element.parentNode &&
this._element.parentNode.nodeType === Node.ELEMENT_NODE &&
this._element.classList.contains(CLASS_NAME_ACTIVE)) ||
this._element.classList.contains(CLASS_NAME_DISABLED)
) {
return;
}
let previous;
const target = getElementFromSelector(this._element);
const listElement = this._element.closest(SELECTOR_NAV_LIST_GROUP);
if (listElement) {
const itemSelector =
listElement.nodeName === 'UL' || listElement.nodeName === 'OL'
? SELECTOR_ACTIVE_UL
: SELECTOR_ACTIVE;
previous = SelectorEngine.find(itemSelector, listElement);
previous = previous[previous.length - 1];
}
let hideEvent = null;
if (previous) {
hideEvent = EventHandler.trigger(previous, EVENT_HIDE, {
relatedTarget: this._element,
});
}
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, {
relatedTarget: previous,
});
if (showEvent.defaultPrevented || (hideEvent !== null && hideEvent.defaultPrevented)) {
return;
}
this._activate(this._element, listElement);
const complete = () => {
EventHandler.trigger(previous, EVENT_HIDDEN, {
relatedTarget: this._element,
});
EventHandler.trigger(this._element, EVENT_SHOWN, {
relatedTarget: previous,
});
};
if (target) {
this._activate(target, target.parentNode, complete);
} else {
complete();
}
}
// Private
_activate(element, container, callback) {
const activeElements =
container && (container.nodeName === 'UL' || container.nodeName === 'OL')
? SelectorEngine.find(SELECTOR_ACTIVE_UL, container)
: SelectorEngine.children(container, SELECTOR_ACTIVE);
const active = activeElements[0];
const isTransitioning = callback && active && active.classList.contains(CLASS_NAME_FADE);
const complete = () => this._transitionComplete(element, active, callback);
if (active && isTransitioning) {
const transitionDuration = getTransitionDurationFromElement(active);
active.classList.remove(CLASS_NAME_SHOW);
EventHandler.one(active, TRANSITION_END, complete);
emulateTransitionEnd(active, transitionDuration);
} else {
complete();
}
}
_transitionComplete(element, active, callback) {
if (active) {
active.classList.remove(CLASS_NAME_ACTIVE);
const dropdownChild = SelectorEngine.findOne(
SELECTOR_DROPDOWN_ACTIVE_CHILD,
active.parentNode
);
if (dropdownChild) {
dropdownChild.classList.remove(CLASS_NAME_ACTIVE);
}
if (active.getAttribute('role') === 'tab') {
active.setAttribute('aria-selected', false);
}
}
element.classList.add(CLASS_NAME_ACTIVE);
if (element.getAttribute('role') === 'tab') {
element.setAttribute('aria-selected', true);
}
reflow(element);
if (element.classList.contains(CLASS_NAME_FADE)) {
element.classList.add(CLASS_NAME_SHOW);
}
if (element.parentNode && element.parentNode.classList.contains(CLASS_NAME_DROPDOWN_MENU)) {
const dropdownElement = element.closest(SELECTOR_DROPDOWN);
if (dropdownElement) {
SelectorEngine.find(SELECTOR_DROPDOWN_TOGGLE).forEach((dropdown) =>
dropdown.classList.add(CLASS_NAME_ACTIVE)
);
}
element.setAttribute('aria-expanded', true);
}
if (callback) {
callback();
}
}
// Static
static jQueryInterface(config) {
return this.each(function () {
const data = Data.getData(this, DATA_KEY) || new Tab(this);
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
data[config]();
}
});
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
event.preventDefault();
const data = Data.getData(this, DATA_KEY) || new Tab(this);
data.show();
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Tab to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Tab.jQueryInterface;
$.fn[NAME].Constructor = Tab;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Tab.jQueryInterface;
};
}
});
export default Tab;

View File

@ -1,233 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): toast.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import {
getjQuery,
onDOMContentLoaded,
TRANSITION_END,
emulateTransitionEnd,
getTransitionDurationFromElement,
reflow,
typeCheckConfig,
} from './util/index';
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import Manipulator from './dom/manipulator';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'toast';
const DATA_KEY = 'bs.toast';
const EVENT_KEY = `.${DATA_KEY}`;
const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`;
const EVENT_HIDE = `hide${EVENT_KEY}`;
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
const EVENT_SHOW = `show${EVENT_KEY}`;
const EVENT_SHOWN = `shown${EVENT_KEY}`;
const CLASS_NAME_FADE = 'fade';
const CLASS_NAME_HIDE = 'hide';
const CLASS_NAME_SHOW = 'show';
const CLASS_NAME_SHOWING = 'showing';
const DefaultType = {
animation: 'boolean',
autohide: 'boolean',
delay: 'number',
};
const Default = {
animation: true,
autohide: true,
delay: 5000,
};
const SELECTOR_DATA_DISMISS = '[data-mdb-dismiss="toast"]';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Toast extends BaseComponent {
constructor(element, config) {
super(element);
this._config = this._getConfig(config);
this._timeout = null;
this._setListeners();
}
// Getters
static get DefaultType() {
return DefaultType;
}
static get Default() {
return Default;
}
static get DATA_KEY() {
return DATA_KEY;
}
// Public
show() {
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW);
if (showEvent.defaultPrevented) {
return;
}
this._clearTimeout();
if (this._config.animation) {
this._element.classList.add(CLASS_NAME_FADE);
}
const complete = () => {
this._element.classList.remove(CLASS_NAME_SHOWING);
this._element.classList.add(CLASS_NAME_SHOW);
EventHandler.trigger(this._element, EVENT_SHOWN);
if (this._config.autohide) {
this._timeout = setTimeout(() => {
this.hide();
}, this._config.delay);
}
};
this._element.classList.remove(CLASS_NAME_HIDE);
reflow(this._element);
this._element.classList.add(CLASS_NAME_SHOWING);
if (this._config.animation) {
const transitionDuration = getTransitionDurationFromElement(this._element);
EventHandler.one(this._element, TRANSITION_END, complete);
emulateTransitionEnd(this._element, transitionDuration);
} else {
complete();
}
}
hide() {
if (!this._element.classList.contains(CLASS_NAME_SHOW)) {
return;
}
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
if (hideEvent.defaultPrevented) {
return;
}
const complete = () => {
this._element.classList.add(CLASS_NAME_HIDE);
EventHandler.trigger(this._element, EVENT_HIDDEN);
};
this._element.classList.remove(CLASS_NAME_SHOW);
if (this._config.animation) {
const transitionDuration = getTransitionDurationFromElement(this._element);
EventHandler.one(this._element, TRANSITION_END, complete);
emulateTransitionEnd(this._element, transitionDuration);
} else {
complete();
}
}
dispose() {
this._clearTimeout();
if (this._element.classList.contains(CLASS_NAME_SHOW)) {
this._element.classList.remove(CLASS_NAME_SHOW);
}
EventHandler.off(this._element, EVENT_CLICK_DISMISS);
super.dispose();
this._config = null;
}
// Private
_getConfig(config) {
config = {
...Default,
...Manipulator.getDataAttributes(this._element),
...(typeof config === 'object' && config ? config : {}),
};
typeCheckConfig(NAME, config, this.constructor.DefaultType);
return config;
}
_setListeners() {
EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, () => this.hide());
}
_clearTimeout() {
clearTimeout(this._timeout);
this._timeout = null;
}
// Static
static jQueryInterface(config) {
return this.each(function () {
let data = Data.getData(this, DATA_KEY);
const _config = typeof config === 'object' && config;
if (!data) {
data = new Toast(this, _config);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
data[config](this);
}
});
}
}
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Toast to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Toast.jQueryInterface;
$.fn[NAME].Constructor = Toast;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Toast.jQueryInterface;
};
}
});
export default Toast;

View File

@ -1,818 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): tooltip.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import * as Popper from '@popperjs/core';
import {
getjQuery,
onDOMContentLoaded,
TRANSITION_END,
emulateTransitionEnd,
findShadowRoot,
getTransitionDurationFromElement,
getUID,
isElement,
isRTL,
noop,
typeCheckConfig,
} from './util/index';
import { DefaultAllowlist, sanitizeHtml } from './util/sanitizer';
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import Manipulator from './dom/manipulator';
import SelectorEngine from './dom/selector-engine';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'tooltip';
const DATA_KEY = 'bs.tooltip';
const EVENT_KEY = `.${DATA_KEY}`;
const CLASS_PREFIX = 'bs-tooltip';
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g');
const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
const DefaultType = {
animation: 'boolean',
template: 'string',
title: '(string|element|function)',
trigger: 'string',
delay: '(number|object)',
html: 'boolean',
selector: '(string|boolean)',
placement: '(string|function)',
container: '(string|element|boolean)',
fallbackPlacements: '(null|array)',
boundary: '(string|element)',
customClass: '(string|function)',
sanitize: 'boolean',
sanitizeFn: '(null|function)',
allowList: 'object',
popperConfig: '(null|object)',
};
const AttachmentMap = {
AUTO: 'auto',
TOP: 'top',
RIGHT: isRTL ? 'left' : 'right',
BOTTOM: 'bottom',
LEFT: isRTL ? 'right' : 'left',
};
const Default = {
animation: true,
template:
'<div class="tooltip" role="tooltip">' +
'<div class="tooltip-arrow"></div>' +
'<div class="tooltip-inner"></div>' +
'</div>',
trigger: 'hover focus',
title: '',
delay: 0,
html: false,
selector: false,
placement: 'top',
container: false,
fallbackPlacements: null,
boundary: 'clippingParents',
customClass: '',
sanitize: true,
sanitizeFn: null,
allowList: DefaultAllowlist,
popperConfig: null,
};
const Event = {
HIDE: `hide${EVENT_KEY}`,
HIDDEN: `hidden${EVENT_KEY}`,
SHOW: `show${EVENT_KEY}`,
SHOWN: `shown${EVENT_KEY}`,
INSERTED: `inserted${EVENT_KEY}`,
CLICK: `click${EVENT_KEY}`,
FOCUSIN: `focusin${EVENT_KEY}`,
FOCUSOUT: `focusout${EVENT_KEY}`,
MOUSEENTER: `mouseenter${EVENT_KEY}`,
MOUSELEAVE: `mouseleave${EVENT_KEY}`,
};
const CLASS_NAME_FADE = 'fade';
const CLASS_NAME_MODAL = 'modal';
const CLASS_NAME_SHOW = 'show';
const HOVER_STATE_SHOW = 'show';
const HOVER_STATE_OUT = 'out';
const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
const TRIGGER_HOVER = 'hover';
const TRIGGER_FOCUS = 'focus';
const TRIGGER_CLICK = 'click';
const TRIGGER_MANUAL = 'manual';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Tooltip extends BaseComponent {
constructor(element, config) {
if (typeof Popper === 'undefined') {
throw new TypeError("Bootstrap's tooltips require Popper (https://popper.js.org)");
}
super(element);
// private
this._isEnabled = true;
this._timeout = 0;
this._hoverState = '';
this._activeTrigger = {};
this._popper = null;
// Protected
this.config = this._getConfig(config);
this.tip = null;
this._setListeners();
}
// Getters
static get Default() {
return Default;
}
static get NAME() {
return NAME;
}
static get DATA_KEY() {
return DATA_KEY;
}
static get Event() {
return Event;
}
static get EVENT_KEY() {
return EVENT_KEY;
}
static get DefaultType() {
return DefaultType;
}
// Public
enable() {
this._isEnabled = true;
}
disable() {
this._isEnabled = false;
}
toggleEnabled() {
this._isEnabled = !this._isEnabled;
}
toggle(event) {
if (!this._isEnabled) {
return;
}
if (event) {
const dataKey = this.constructor.DATA_KEY;
let context = Data.getData(event.delegateTarget, dataKey);
if (!context) {
context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
Data.setData(event.delegateTarget, dataKey, context);
}
context._activeTrigger.click = !context._activeTrigger.click;
if (context._isWithActiveTrigger()) {
context._enter(null, context);
} else {
context._leave(null, context);
}
} else {
if (this.getTipElement().classList.contains(CLASS_NAME_SHOW)) {
this._leave(null, this);
return;
}
this._enter(null, this);
}
}
dispose() {
clearTimeout(this._timeout);
EventHandler.off(this._element, this.constructor.EVENT_KEY);
EventHandler.off(
this._element.closest(`.${CLASS_NAME_MODAL}`),
'hide.bs.modal',
this._hideModalHandler
);
if (this.tip) {
this.tip.parentNode.removeChild(this.tip);
}
this._isEnabled = null;
this._timeout = null;
this._hoverState = null;
this._activeTrigger = null;
if (this._popper) {
this._popper.destroy();
}
this._popper = null;
this.config = null;
this.tip = null;
super.dispose();
}
show() {
if (this._element.style.display === 'none') {
throw new Error('Please use show on visible elements');
}
if (this.isWithContent() && this._isEnabled) {
const showEvent = EventHandler.trigger(this._element, this.constructor.Event.SHOW);
const shadowRoot = findShadowRoot(this._element);
const isInTheDom =
shadowRoot === null
? this._element.ownerDocument.documentElement.contains(this._element)
: shadowRoot.contains(this._element);
if (showEvent.defaultPrevented || !isInTheDom) {
return;
}
const tip = this.getTipElement();
const tipId = getUID(this.constructor.NAME);
tip.setAttribute('id', tipId);
this._element.setAttribute('aria-describedby', tipId);
this.setContent();
if (this.config.animation) {
tip.classList.add(CLASS_NAME_FADE);
}
const placement =
typeof this.config.placement === 'function'
? this.config.placement.call(this, tip, this._element)
: this.config.placement;
const attachment = this._getAttachment(placement);
this._addAttachmentClass(attachment);
const container = this._getContainer();
Data.setData(tip, this.constructor.DATA_KEY, this);
if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
container.appendChild(tip);
}
EventHandler.trigger(this._element, this.constructor.Event.INSERTED);
this._popper = Popper.createPopper(this._element, tip, this._getPopperConfig(attachment));
tip.classList.add(CLASS_NAME_SHOW);
const customClass =
typeof this.config.customClass === 'function'
? this.config.customClass()
: this.config.customClass;
if (customClass) {
tip.classList.add(...customClass.split(' '));
}
// If this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
// only needed because of broken event delegation on iOS
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
if ('ontouchstart' in document.documentElement) {
[].concat(...document.body.children).forEach((element) => {
EventHandler.on(element, 'mouseover', noop());
});
}
const complete = () => {
const prevHoverState = this._hoverState;
this._hoverState = null;
EventHandler.trigger(this._element, this.constructor.Event.SHOWN);
if (prevHoverState === HOVER_STATE_OUT) {
this._leave(null, this);
}
};
if (this.tip.classList.contains(CLASS_NAME_FADE)) {
const transitionDuration = getTransitionDurationFromElement(this.tip);
EventHandler.one(this.tip, TRANSITION_END, complete);
emulateTransitionEnd(this.tip, transitionDuration);
} else {
complete();
}
}
}
hide() {
if (!this._popper) {
return;
}
const tip = this.getTipElement();
const complete = () => {
if (this._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
tip.parentNode.removeChild(tip);
}
this._cleanTipClass();
this._element.removeAttribute('aria-describedby');
EventHandler.trigger(this._element, this.constructor.Event.HIDDEN);
if (this._popper) {
this._popper.destroy();
this._popper = null;
}
};
const hideEvent = EventHandler.trigger(this._element, this.constructor.Event.HIDE);
if (hideEvent.defaultPrevented) {
return;
}
tip.classList.remove(CLASS_NAME_SHOW);
// If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
if ('ontouchstart' in document.documentElement) {
[]
.concat(...document.body.children)
.forEach((element) => EventHandler.off(element, 'mouseover', noop));
}
this._activeTrigger[TRIGGER_CLICK] = false;
this._activeTrigger[TRIGGER_FOCUS] = false;
this._activeTrigger[TRIGGER_HOVER] = false;
if (this.tip.classList.contains(CLASS_NAME_FADE)) {
const transitionDuration = getTransitionDurationFromElement(tip);
EventHandler.one(tip, TRANSITION_END, complete);
emulateTransitionEnd(tip, transitionDuration);
} else {
complete();
}
this._hoverState = '';
}
update() {
if (this._popper !== null) {
this._popper.update();
}
}
// Protected
isWithContent() {
return Boolean(this.getTitle());
}
getTipElement() {
if (this.tip) {
return this.tip;
}
const element = document.createElement('div');
element.innerHTML = this.config.template;
this.tip = element.children[0];
return this.tip;
}
setContent() {
const tip = this.getTipElement();
this.setElementContent(SelectorEngine.findOne(SELECTOR_TOOLTIP_INNER, tip), this.getTitle());
tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW);
}
setElementContent(element, content) {
if (element === null) {
return;
}
if (typeof content === 'object' && isElement(content)) {
if (content.jquery) {
content = content[0];
}
// content is a DOM node or a jQuery
if (this.config.html) {
if (content.parentNode !== element) {
element.innerHTML = '';
element.appendChild(content);
}
} else {
element.textContent = content.textContent;
}
return;
}
if (this.config.html) {
if (this.config.sanitize) {
content = sanitizeHtml(content, this.config.allowList, this.config.sanitizeFn);
}
element.innerHTML = content;
} else {
element.textContent = content;
}
}
getTitle() {
let title = this._element.getAttribute('data-mdb-original-title');
if (!title) {
title =
typeof this.config.title === 'function'
? this.config.title.call(this._element)
: this.config.title;
}
return title;
}
updateAttachment(attachment) {
if (attachment === 'right') {
return 'end';
}
if (attachment === 'left') {
return 'start';
}
return attachment;
}
// Private
_getPopperConfig(attachment) {
const flipModifier = {
name: 'flip',
options: {
altBoundary: true,
},
};
if (this.config.fallbackPlacements) {
flipModifier.options.fallbackPlacements = this.config.fallbackPlacements;
}
const defaultBsConfig = {
placement: attachment,
modifiers: [
flipModifier,
{
name: 'preventOverflow',
options: {
rootBoundary: this.config.boundary,
},
},
{
name: 'arrow',
options: {
element: `.${this.constructor.NAME}-arrow`,
},
},
{
name: 'onChange',
enabled: true,
phase: 'afterWrite',
fn: (data) => this._handlePopperPlacementChange(data),
},
],
onFirstUpdate: (data) => {
if (data.options.placement !== data.placement) {
this._handlePopperPlacementChange(data);
}
},
};
return {
...defaultBsConfig,
...this.config.popperConfig,
};
}
_addAttachmentClass(attachment) {
this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`);
}
_getContainer() {
if (this.config.container === false) {
return document.body;
}
if (isElement(this.config.container)) {
return this.config.container;
}
return SelectorEngine.findOne(this.config.container);
}
_getAttachment(placement) {
return AttachmentMap[placement.toUpperCase()];
}
_setListeners() {
const triggers = this.config.trigger.split(' ');
triggers.forEach((trigger) => {
if (trigger === 'click') {
EventHandler.on(
this._element,
this.constructor.Event.CLICK,
this.config.selector,
(event) => this.toggle(event)
);
} else if (trigger !== TRIGGER_MANUAL) {
const eventIn =
trigger === TRIGGER_HOVER
? this.constructor.Event.MOUSEENTER
: this.constructor.Event.FOCUSIN;
const eventOut =
trigger === TRIGGER_HOVER
? this.constructor.Event.MOUSELEAVE
: this.constructor.Event.FOCUSOUT;
EventHandler.on(this._element, eventIn, this.config.selector, (event) =>
this._enter(event)
);
EventHandler.on(this._element, eventOut, this.config.selector, (event) =>
this._leave(event)
);
}
});
this._hideModalHandler = () => {
if (this._element) {
this.hide();
}
};
EventHandler.on(
this._element.closest(`.${CLASS_NAME_MODAL}`),
'hide.bs.modal',
this._hideModalHandler
);
if (this.config.selector) {
this.config = {
...this.config,
trigger: 'manual',
selector: '',
};
} else {
this._fixTitle();
}
}
_fixTitle() {
const title = this._element.getAttribute('title');
const originalTitleType = typeof this._element.getAttribute('data-mdb-original-title');
if (title || originalTitleType !== 'string') {
this._element.setAttribute('data-mdb-original-title', title || '');
if (title && !this._element.getAttribute('aria-label') && !this._element.textContent) {
this._element.setAttribute('aria-label', title);
}
this._element.setAttribute('title', '');
}
}
_enter(event, context) {
const dataKey = this.constructor.DATA_KEY;
context = context || Data.getData(event.delegateTarget, dataKey);
if (!context) {
context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
Data.setData(event.delegateTarget, dataKey, context);
}
if (event) {
context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
}
if (
context.getTipElement().classList.contains(CLASS_NAME_SHOW) ||
context._hoverState === HOVER_STATE_SHOW
) {
context._hoverState = HOVER_STATE_SHOW;
return;
}
clearTimeout(context._timeout);
context._hoverState = HOVER_STATE_SHOW;
if (!context.config.delay || !context.config.delay.show) {
context.show();
return;
}
context._timeout = setTimeout(() => {
if (context._hoverState === HOVER_STATE_SHOW) {
context.show();
}
}, context.config.delay.show);
}
_leave(event, context) {
const dataKey = this.constructor.DATA_KEY;
context = context || Data.getData(event.delegateTarget, dataKey);
if (!context) {
context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
Data.setData(event.delegateTarget, dataKey, context);
}
if (event) {
context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = false;
}
if (context._isWithActiveTrigger()) {
return;
}
clearTimeout(context._timeout);
context._hoverState = HOVER_STATE_OUT;
if (!context.config.delay || !context.config.delay.hide) {
context.hide();
return;
}
context._timeout = setTimeout(() => {
if (context._hoverState === HOVER_STATE_OUT) {
context.hide();
}
}, context.config.delay.hide);
}
_isWithActiveTrigger() {
for (const trigger in this._activeTrigger) {
if (this._activeTrigger[trigger]) {
return true;
}
}
return false;
}
_getConfig(config) {
const dataAttributes = Manipulator.getDataAttributes(this._element);
Object.keys(dataAttributes).forEach((dataAttr) => {
if (DISALLOWED_ATTRIBUTES.has(dataAttr)) {
delete dataAttributes[dataAttr];
}
});
if (config && typeof config.container === 'object' && config.container.jquery) {
config.container = config.container[0];
}
config = {
...this.constructor.Default,
...dataAttributes,
...(typeof config === 'object' && config ? config : {}),
};
if (typeof config.delay === 'number') {
config.delay = {
show: config.delay,
hide: config.delay,
};
}
if (typeof config.title === 'number') {
config.title = config.title.toString();
}
if (typeof config.content === 'number') {
config.content = config.content.toString();
}
typeCheckConfig(NAME, config, this.constructor.DefaultType);
if (config.sanitize) {
config.template = sanitizeHtml(config.template, config.allowList, config.sanitizeFn);
}
return config;
}
_getDelegateConfig() {
const config = {};
if (this.config) {
for (const key in this.config) {
if (this.constructor.Default[key] !== this.config[key]) {
config[key] = this.config[key];
}
}
}
return config;
}
_cleanTipClass() {
const tip = this.getTipElement();
const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX);
if (tabClass !== null && tabClass.length > 0) {
tabClass.map((token) => token.trim()).forEach((tClass) => tip.classList.remove(tClass));
}
}
_handlePopperPlacementChange(popperData) {
const { state } = popperData;
if (!state) {
return;
}
this.tip = state.elements.popper;
this._cleanTipClass();
this._addAttachmentClass(this._getAttachment(state.placement));
}
// Static
static jQueryInterface(config) {
return this.each(function () {
let data = Data.getData(this, DATA_KEY);
const _config = typeof config === 'object' && config;
if (!data && /dispose|hide/.test(config)) {
return;
}
if (!data) {
data = new Tooltip(this, _config);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
data[config]();
}
});
}
}
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Tooltip to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Tooltip.jQueryInterface;
$.fn[NAME].Constructor = Tooltip;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Tooltip.jQueryInterface;
};
}
});
export default Tooltip;

View File

@ -1,215 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
const MAX_UID = 1000000;
const MILLISECONDS_MULTIPLIER = 1000;
const TRANSITION_END = 'transitionend';
// Shoutout AngusCroll (https://goo.gl/pxwQGp)
const toType = (obj) => {
if (obj === null || obj === undefined) {
return `${obj}`;
}
return {}.toString
.call(obj)
.match(/\s([a-z]+)/i)[1]
.toLowerCase();
};
/**
* --------------------------------------------------------------------------
* Public Util Api
* --------------------------------------------------------------------------
*/
const getUID = (prefix) => {
do {
prefix += Math.floor(Math.random() * MAX_UID);
} while (document.getElementById(prefix));
return prefix;
};
const getSelector = (element) => {
let selector = element.getAttribute('data-mdb-target');
if (!selector || selector === '#') {
const hrefAttr = element.getAttribute('href');
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
}
return selector;
};
const getSelectorFromElement = (element) => {
const selector = getSelector(element);
if (selector) {
return document.querySelector(selector) ? selector : null;
}
return null;
};
const getElementFromSelector = (element) => {
const selector = getSelector(element);
return selector ? document.querySelector(selector) : null;
};
const getTransitionDurationFromElement = (element) => {
if (!element) {
return 0;
}
// Get transition-duration of the element
let { transitionDuration, transitionDelay } = window.getComputedStyle(element);
const floatTransitionDuration = Number.parseFloat(transitionDuration);
const floatTransitionDelay = Number.parseFloat(transitionDelay);
// Return 0 if element or transition duration is not found
if (!floatTransitionDuration && !floatTransitionDelay) {
return 0;
}
// If multiple durations are defined, take the first
transitionDuration = transitionDuration.split(',')[0];
transitionDelay = transitionDelay.split(',')[0];
return (
(Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) *
MILLISECONDS_MULTIPLIER
);
};
const triggerTransitionEnd = (element) => {
element.dispatchEvent(new Event(TRANSITION_END));
};
const isElement = (obj) => (obj[0] || obj).nodeType;
const emulateTransitionEnd = (element, duration) => {
let called = false;
const durationPadding = 5;
const emulatedDuration = duration + durationPadding;
function listener() {
called = true;
element.removeEventListener(TRANSITION_END, listener);
}
element.addEventListener(TRANSITION_END, listener);
setTimeout(() => {
if (!called) {
triggerTransitionEnd(element);
}
}, emulatedDuration);
};
const typeCheckConfig = (componentName, config, configTypes) => {
Object.keys(configTypes).forEach((property) => {
const expectedTypes = configTypes[property];
const value = config[property];
const valueType = value && isElement(value) ? 'element' : toType(value);
if (!new RegExp(expectedTypes).test(valueType)) {
throw new Error(
`${componentName.toUpperCase()}: ` +
`Option "${property}" provided type "${valueType}" ` +
`but expected type "${expectedTypes}".`
);
}
});
};
const isVisible = (element) => {
if (!element) {
return false;
}
if (element.style && element.parentNode && element.parentNode.style) {
const elementStyle = getComputedStyle(element);
const parentNodeStyle = getComputedStyle(element.parentNode);
return (
elementStyle.display !== 'none' &&
parentNodeStyle.display !== 'none' &&
elementStyle.visibility !== 'hidden'
);
}
return false;
};
const findShadowRoot = (element) => {
if (!document.documentElement.attachShadow) {
return null;
}
// Can find the shadow root otherwise it'll return the document
if (typeof element.getRootNode === 'function') {
const root = element.getRootNode();
return root instanceof ShadowRoot ? root : null;
}
if (element instanceof ShadowRoot) {
return element;
}
// when we don't find a shadow root
if (!element.parentNode) {
return null;
}
return findShadowRoot(element.parentNode);
};
const noop = () => function () {};
const reflow = (element) => element.offsetHeight;
const getjQuery = () => {
const { jQuery } = window;
if (jQuery && !document.body.hasAttribute('data-mdb-no-jquery')) {
return jQuery;
}
return null;
};
const onDOMContentLoaded = (callback) => {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callback);
} else {
callback();
}
};
const isRTL = document.documentElement.dir === 'rtl';
export {
TRANSITION_END,
getUID,
getSelectorFromElement,
getElementFromSelector,
getTransitionDurationFromElement,
triggerTransitionEnd,
isElement,
emulateTransitionEnd,
typeCheckConfig,
isVisible,
findShadowRoot,
noop,
reflow,
getjQuery,
onDOMContentLoaded,
isRTL,
};

View File

@ -1,129 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/sanitizer.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
const uriAttrs = new Set([
'background',
'cite',
'href',
'itemtype',
'longdesc',
'poster',
'src',
'xlink:href',
]);
const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
/**
* A pattern that recognizes a commonly useful subset of URLs that are safe.
*
* Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
*/
const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/gi;
/**
* A pattern that matches safe data URLs. Only matches image, video and audio types.
*
* Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
*/
const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i;
const allowedAttribute = (attr, allowedAttributeList) => {
const attrName = attr.nodeName.toLowerCase();
if (allowedAttributeList.includes(attrName)) {
if (uriAttrs.has(attrName)) {
return Boolean(
attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)
);
}
return true;
}
const regExp = allowedAttributeList.filter((attrRegex) => attrRegex instanceof RegExp);
// Check if a regular expression validates the attribute.
for (let i = 0, len = regExp.length; i < len; i++) {
if (attrName.match(regExp[i])) {
return true;
}
}
return false;
};
export const DefaultAllowlist = {
// Global attributes allowed on any supplied element below.
'*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
a: ['target', 'href', 'title', 'rel'],
area: [],
b: [],
br: [],
col: [],
code: [],
div: [],
em: [],
hr: [],
h1: [],
h2: [],
h3: [],
h4: [],
h5: [],
h6: [],
i: [],
img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
li: [],
ol: [],
p: [],
pre: [],
s: [],
small: [],
span: [],
sub: [],
sup: [],
strong: [],
u: [],
ul: [],
};
export function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
if (!unsafeHtml.length) {
return unsafeHtml;
}
if (sanitizeFn && typeof sanitizeFn === 'function') {
return sanitizeFn(unsafeHtml);
}
const domParser = new window.DOMParser();
const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
const allowlistKeys = Object.keys(allowList);
const elements = [].concat(...createdDocument.body.querySelectorAll('*'));
for (let i = 0, len = elements.length; i < len; i++) {
const el = elements[i];
const elName = el.nodeName.toLowerCase();
if (!allowlistKeys.includes(elName)) {
el.parentNode.removeChild(el);
continue;
}
const attributeList = [].concat(...el.attributes);
const allowedAttributes = [].concat(allowList['*'] || [], allowList[elName] || []);
attributeList.forEach((attr) => {
if (!allowedAttribute(attr, allowedAttributes)) {
el.removeAttribute(attr.nodeName);
}
});
}
return createdDocument.body.innerHTML;
}

View File

@ -1,13 +1,12 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): alert.js
* Bootstrap (v5.0.0-alpha1): alert.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import {
getjQuery,
onDOMContentLoaded,
TRANSITION_END,
emulateTransitionEnd,
getElementFromSelector,
@ -15,7 +14,6 @@ import {
} from './util/index';
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
@ -24,11 +22,12 @@ import BaseComponent from './base-component';
*/
const NAME = 'alert';
const VERSION = '5.0.0-alpha1';
const DATA_KEY = 'bs.alert';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
const SELECTOR_DISMISS = '[data-bs-dismiss="alert"]';
const SELECTOR_DISMISS = '[data-dismiss="alert"]';
const EVENT_CLOSE = `close${EVENT_KEY}`;
const EVENT_CLOSED = `closed${EVENT_KEY}`;
@ -44,17 +43,29 @@ const CLASSNAME_SHOW = 'show';
* ------------------------------------------------------------------------
*/
class Alert extends BaseComponent {
class Alert {
constructor(element) {
this._element = element;
if (this._element) {
Data.setData(element, DATA_KEY, this);
}
}
// Getters
static get DATA_KEY() {
return DATA_KEY;
static get VERSION() {
return VERSION;
}
// Public
close(element) {
const rootElement = element ? this._getRootElement(element) : this._element;
let rootElement = this._element;
if (element) {
rootElement = this._getRootElement(element);
}
const customEvent = this._triggerCloseEvent(rootElement);
if (customEvent === null || customEvent.defaultPrevented) {
@ -64,6 +75,11 @@ class Alert extends BaseComponent {
this._removeElement(rootElement);
}
dispose() {
Data.removeData(this._element, DATA_KEY);
this._element = null;
}
// Private
_getRootElement(element) {
@ -121,6 +137,10 @@ class Alert extends BaseComponent {
alertInstance.close(this);
};
}
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
}
/**
@ -130,25 +150,24 @@ class Alert extends BaseComponent {
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DISMISS, Alert.handleDismiss(new Alert()));
const $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Alert to jQuery only if jQuery is present
* add .alert to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Alert.jQueryInterface;
$.fn[NAME].Constructor = Alert;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Alert.jQueryInterface;
};
}
});
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Alert.jQueryInterface;
$.fn[NAME].Constructor = Alert;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Alert.jQueryInterface;
};
}
export default Alert;

View File

@ -1,44 +0,0 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): base-component.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import Data from './dom/data';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const VERSION = '5.0.0-beta1';
class BaseComponent {
constructor(element) {
if (!element) {
return;
}
this._element = element;
Data.setData(element, this.constructor.DATA_KEY, this);
}
dispose() {
Data.removeData(this._element, this.constructor.DATA_KEY);
this._element = null;
}
/** Static */
static getInstance(element) {
return Data.getData(element, this.DATA_KEY);
}
static get VERSION() {
return VERSION;
}
}
export default BaseComponent;

View File

@ -1,14 +1,13 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): button.js
* Bootstrap (v5.0.0-alpha1): button.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import { getjQuery, onDOMContentLoaded } from './util/index';
import { getjQuery } from './util/index';
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
@ -17,13 +16,14 @@ import BaseComponent from './base-component';
*/
const NAME = 'button';
const VERSION = '5.0.0-alpha1';
const DATA_KEY = 'bs.button';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
const CLASS_NAME_ACTIVE = 'active';
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="button"]';
const SELECTOR_DATA_TOGGLE = '[data-toggle="button"]';
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
@ -33,11 +33,16 @@ const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
* ------------------------------------------------------------------------
*/
class Button extends BaseComponent {
class Button {
constructor(element) {
this._element = element;
Data.setData(element, DATA_KEY, this);
}
// Getters
static get DATA_KEY() {
return DATA_KEY;
static get VERSION() {
return VERSION;
}
// Public
@ -47,6 +52,11 @@ class Button extends BaseComponent {
this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE));
}
dispose() {
Data.removeData(this._element, DATA_KEY);
this._element = null;
}
// Static
static jQueryInterface(config) {
@ -62,6 +72,10 @@ class Button extends BaseComponent {
}
});
}
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
}
/**
@ -83,26 +97,24 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, (event) =>
data.toggle();
});
const $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Button to jQuery only if jQuery is present
* add .button to jQuery only if jQuery is present
*/
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Button.jQueryInterface;
$.fn[NAME].Constructor = Button;
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Button.jQueryInterface;
$.fn[NAME].Constructor = Button;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Button.jQueryInterface;
};
}
});
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Button.jQueryInterface;
};
}
export default Button;

View File

@ -1,13 +1,12 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): carousel.js
* Bootstrap (v5.0.0-alpha1): carousel.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import {
getjQuery,
onDOMContentLoaded,
TRANSITION_END,
emulateTransitionEnd,
getElementFromSelector,
@ -21,7 +20,6 @@ import Data from './dom/data';
import EventHandler from './dom/event-handler';
import Manipulator from './dom/manipulator';
import SelectorEngine from './dom/selector-engine';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
@ -30,6 +28,7 @@ import BaseComponent from './base-component';
*/
const NAME = 'carousel';
const VERSION = '5.0.0-alpha1';
const DATA_KEY = 'bs.carousel';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
@ -79,8 +78,8 @@ const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
const CLASS_NAME_CAROUSEL = 'carousel';
const CLASS_NAME_ACTIVE = 'active';
const CLASS_NAME_SLIDE = 'slide';
const CLASS_NAME_END = 'carousel-item-end';
const CLASS_NAME_START = 'carousel-item-start';
const CLASS_NAME_RIGHT = 'carousel-item-right';
const CLASS_NAME_LEFT = 'carousel-item-left';
const CLASS_NAME_NEXT = 'carousel-item-next';
const CLASS_NAME_PREV = 'carousel-item-prev';
const CLASS_NAME_POINTER_EVENT = 'pointer-event';
@ -91,8 +90,8 @@ const SELECTOR_ITEM = '.carousel-item';
const SELECTOR_ITEM_IMG = '.carousel-item img';
const SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
const SELECTOR_INDICATORS = '.carousel-indicators';
const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
const SELECTOR_DATA_SLIDE = '[data-slide], [data-slide-to]';
const SELECTOR_DATA_RIDE = '[data-ride="carousel"]';
const PointerType = {
TOUCH: 'touch',
@ -104,10 +103,8 @@ const PointerType = {
* Class Definition
* ------------------------------------------------------------------------
*/
class Carousel extends BaseComponent {
class Carousel {
constructor(element, config) {
super(element);
this._items = null;
this._interval = null;
this._activeElement = null;
@ -118,22 +115,24 @@ class Carousel extends BaseComponent {
this.touchDeltaX = 0;
this._config = this._getConfig(config);
this._element = element;
this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
this._touchSupported =
'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
this._pointerEvent = Boolean(window.PointerEvent);
this._addEventListeners();
Data.setData(element, DATA_KEY, this);
}
// Getters
static get Default() {
return Default;
static get VERSION() {
return VERSION;
}
static get DATA_KEY() {
return DATA_KEY;
static get Default() {
return Default;
}
// Public
@ -183,8 +182,6 @@ class Carousel extends BaseComponent {
}
if (this._config && this._config.interval && !this._isPaused) {
this._updateInterval();
this._interval = setInterval(
(document.visibilityState ? this.nextWhenVisible : this.next).bind(this),
this._config.interval
@ -217,11 +214,12 @@ class Carousel extends BaseComponent {
}
dispose() {
super.dispose();
EventHandler.off(this._element, EVENT_KEY);
Data.removeData(this._element, DATA_KEY);
this._items = null;
this._config = null;
this._element = null;
this._interval = null;
this._isPaused = null;
this._isSliding = null;
@ -398,7 +396,6 @@ class Carousel extends BaseComponent {
_setActiveIndicatorElement(element) {
if (this._indicatorsElement) {
const indicators = SelectorEngine.find(SELECTOR_ACTIVE, this._indicatorsElement);
for (let i = 0; i < indicators.length; i++) {
indicators[i].classList.remove(CLASS_NAME_ACTIVE);
}
@ -411,24 +408,6 @@ class Carousel extends BaseComponent {
}
}
_updateInterval() {
const element =
this._activeElement || SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
if (!element) {
return;
}
const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
if (elementInterval) {
this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
this._config.interval = elementInterval;
} else {
this._config.interval = this._config.defaultInterval || this._config.interval;
}
}
_slide(direction, element) {
const activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
const activeElementIndex = this._getItemIndex(activeElement);
@ -443,11 +422,11 @@ class Carousel extends BaseComponent {
let eventDirectionName;
if (direction === DIRECTION_NEXT) {
directionalClassName = CLASS_NAME_START;
directionalClassName = CLASS_NAME_LEFT;
orderClassName = CLASS_NAME_NEXT;
eventDirectionName = DIRECTION_LEFT;
} else {
directionalClassName = CLASS_NAME_END;
directionalClassName = CLASS_NAME_RIGHT;
orderClassName = CLASS_NAME_PREV;
eventDirectionName = DIRECTION_RIGHT;
}
@ -474,7 +453,6 @@ class Carousel extends BaseComponent {
}
this._setActiveIndicatorElement(nextElement);
this._activeElement = nextElement;
if (this._element.classList.contains(CLASS_NAME_SLIDE)) {
nextElement.classList.add(orderClassName);
@ -484,6 +462,14 @@ class Carousel extends BaseComponent {
activeElement.classList.add(directionalClassName);
nextElement.classList.add(directionalClassName);
const nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
if (nextElementInterval) {
this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
this._config.interval = nextElementInterval;
} else {
this._config.interval = this._config.defaultInterval || this._config.interval;
}
const transitionDuration = getTransitionDurationFromElement(activeElement);
EventHandler.one(activeElement, TRANSITION_END, () => {
@ -576,7 +562,7 @@ class Carousel extends BaseComponent {
...Manipulator.getDataAttributes(target),
...Manipulator.getDataAttributes(this),
};
const slideIndex = this.getAttribute('data-bs-slide-to');
const slideIndex = this.getAttribute('data-slide-to');
if (slideIndex) {
config.interval = false;
@ -590,6 +576,10 @@ class Carousel extends BaseComponent {
event.preventDefault();
}
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
}
/**
@ -608,25 +598,23 @@ EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
}
});
const $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Carousel to jQuery only if jQuery is present
* add .carousel to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Carousel.jQueryInterface;
$.fn[NAME].Constructor = Carousel;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Carousel.jQueryInterface;
};
}
});
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Carousel.jQueryInterface;
$.fn[NAME].Constructor = Carousel;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Carousel.jQueryInterface;
};
}
export default Carousel;

View File

@ -1,13 +1,12 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): collapse.js
* Bootstrap (v5.0.0-alpha1): collapse.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import {
getjQuery,
onDOMContentLoaded,
TRANSITION_END,
emulateTransitionEnd,
getSelectorFromElement,
@ -21,7 +20,6 @@ import Data from './dom/data';
import EventHandler from './dom/event-handler';
import Manipulator from './dom/manipulator';
import SelectorEngine from './dom/selector-engine';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
@ -30,6 +28,7 @@ import BaseComponent from './base-component';
*/
const NAME = 'collapse';
const VERSION = '5.0.0-alpha1';
const DATA_KEY = 'bs.collapse';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
@ -59,7 +58,7 @@ const WIDTH = 'width';
const HEIGHT = 'height';
const SELECTOR_ACTIVES = '.show, .collapsing';
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="collapse"]';
const SELECTOR_DATA_TOGGLE = '[data-toggle="collapse"]';
/**
* ------------------------------------------------------------------------
@ -67,15 +66,14 @@ const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="collapse"]';
* ------------------------------------------------------------------------
*/
class Collapse extends BaseComponent {
class Collapse {
constructor(element, config) {
super(element);
this._isTransitioning = false;
this._element = element;
this._config = this._getConfig(config);
this._triggerArray = SelectorEngine.find(
`${SELECTOR_DATA_TOGGLE}[href="#${element.id}"],` +
`${SELECTOR_DATA_TOGGLE}[data-bs-target="#${element.id}"]`
`${SELECTOR_DATA_TOGGLE}[data-target="#${element.id}"]`
);
const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE);
@ -102,16 +100,18 @@ class Collapse extends BaseComponent {
if (this._config.toggle) {
this.toggle();
}
Data.setData(element, DATA_KEY, this);
}
// Getters
static get Default() {
return Default;
static get VERSION() {
return VERSION;
}
static get DATA_KEY() {
return DATA_KEY;
static get Default() {
return Default;
}
// Public
@ -135,7 +135,7 @@ class Collapse extends BaseComponent {
if (this._parent) {
actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent).filter((elem) => {
if (typeof this._config.parent === 'string') {
return elem.getAttribute('data-bs-parent') === this._config.parent;
return elem.getAttribute('data-parent') === this._config.parent;
}
return elem.classList.contains(CLASS_NAME_COLLAPSE);
@ -148,8 +148,8 @@ class Collapse extends BaseComponent {
const container = SelectorEngine.findOne(this._selector);
if (actives) {
const tempActiveData = actives.find((elem) => container !== elem);
activesData = tempActiveData ? Data.getData(tempActiveData, DATA_KEY) : null;
const tempActiveData = actives.filter((elem) => container !== elem);
activesData = tempActiveData[0] ? Data.getData(tempActiveData[0], DATA_KEY) : null;
if (activesData && activesData._isTransitioning) {
return;
@ -263,9 +263,11 @@ class Collapse extends BaseComponent {
}
dispose() {
super.dispose();
Data.removeData(this._element, DATA_KEY);
this._config = null;
this._parent = null;
this._element = null;
this._triggerArray = null;
this._isTransitioning = null;
}
@ -283,7 +285,8 @@ class Collapse extends BaseComponent {
}
_getDimension() {
return this._element.classList.contains(WIDTH) ? WIDTH : HEIGHT;
const hasWidth = this._element.classList.contains(WIDTH);
return hasWidth ? WIDTH : HEIGHT;
}
_getParent() {
@ -298,7 +301,7 @@ class Collapse extends BaseComponent {
parent = SelectorEngine.findOne(parent);
}
const selector = `${SELECTOR_DATA_TOGGLE}[data-bs-parent="${parent}"]`;
const selector = `${SELECTOR_DATA_TOGGLE}[data-parent="${parent}"]`;
SelectorEngine.find(selector, parent).forEach((element) => {
const selected = getElementFromSelector(element);
@ -310,21 +313,21 @@ class Collapse extends BaseComponent {
}
_addAriaAndCollapsedClass(element, triggerArray) {
if (!element || !triggerArray.length) {
return;
}
if (element) {
const isOpen = element.classList.contains(CLASS_NAME_SHOW);
const isOpen = element.classList.contains(CLASS_NAME_SHOW);
if (triggerArray.length) {
triggerArray.forEach((elem) => {
if (isOpen) {
elem.classList.remove(CLASS_NAME_COLLAPSED);
} else {
elem.classList.add(CLASS_NAME_COLLAPSED);
}
triggerArray.forEach((elem) => {
if (isOpen) {
elem.classList.remove(CLASS_NAME_COLLAPSED);
} else {
elem.classList.add(CLASS_NAME_COLLAPSED);
elem.setAttribute('aria-expanded', isOpen);
});
}
elem.setAttribute('aria-expanded', isOpen);
});
}
}
// Static
@ -359,6 +362,10 @@ class Collapse extends BaseComponent {
Collapse.collapseInterface(this, config);
});
}
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
}
/**
@ -396,25 +403,23 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
});
});
const $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Collapse to jQuery only if jQuery is present
* add .collapse to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Collapse.jQueryInterface;
$.fn[NAME].Constructor = Collapse;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Collapse.jQueryInterface;
};
}
});
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Collapse.jQueryInterface;
$.fn[NAME].Constructor = Collapse;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Collapse.jQueryInterface;
};
}
export default Collapse;

View File

@ -1,6 +1,6 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/data.js
* Bootstrap (v5.0.0-alpha1): dom/data.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -16,22 +16,22 @@ const mapData = (() => {
let id = 1;
return {
set(element, key, data) {
if (typeof element.bsKey === 'undefined') {
element.bsKey = {
if (typeof element.key === 'undefined') {
element.key = {
key,
id,
};
id++;
}
storeData[element.bsKey.id] = data;
storeData[element.key.id] = data;
},
get(element, key) {
if (!element || typeof element.bsKey === 'undefined') {
if (!element || typeof element.key === 'undefined') {
return null;
}
const keyProperties = element.bsKey;
const keyProperties = element.key;
if (keyProperties.key === key) {
return storeData[keyProperties.id];
}
@ -39,14 +39,14 @@ const mapData = (() => {
return null;
},
delete(element, key) {
if (typeof element.bsKey === 'undefined') {
if (typeof element.key === 'undefined') {
return;
}
const keyProperties = element.bsKey;
const keyProperties = element.key;
if (keyProperties.key === key) {
delete storeData[keyProperties.id];
delete element.bsKey;
delete element.key;
}
},
};

View File

@ -1,11 +1,12 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/event-handler.js
* Bootstrap (v5.0.0-alpha1): dom/event-handler.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import { getjQuery } from '../util/index';
import { defaultPreventedPreservedOnDispatch } from './polyfill';
/**
* ------------------------------------------------------------------------
@ -13,6 +14,7 @@ import { getjQuery } from '../util/index';
* ------------------------------------------------------------------------
*/
const $ = getjQuery();
const namespaceRegex = /[^.]*(?=\..*)\.|.*/;
const stripNameRegex = /\..*/;
const stripUidRegex = /::\d+$/;
@ -22,7 +24,7 @@ const customEvents = {
mouseenter: 'mouseover',
mouseleave: 'mouseout',
};
const nativeEvents = new Set([
const nativeEvents = [
'click',
'dblclick',
'mouseup',
@ -69,7 +71,7 @@ const nativeEvents = new Set([
'error',
'abort',
'scroll',
]);
];
/**
* ------------------------------------------------------------------------
@ -92,8 +94,6 @@ function getEvent(element) {
function bootstrapHandler(element, fn) {
return function handler(event) {
event.delegateTarget = element;
if (handler.oneOff) {
EventHandler.off(element, event.type, fn);
}
@ -109,8 +109,6 @@ function bootstrapDelegationHandler(element, selector, fn) {
for (let { target } = event; target && target !== this; target = target.parentNode) {
for (let i = domElements.length; i--; ) {
if (domElements[i] === target) {
event.delegateTarget = target;
if (handler.oneOff) {
EventHandler.off(element, event.type, fn);
}
@ -151,7 +149,7 @@ function normalizeParams(originalTypeEvent, handler, delegationFn) {
typeEvent = custom;
}
const isNative = nativeEvents.has(typeEvent);
const isNative = nativeEvents.indexOf(typeEvent) > -1;
if (!isNative) {
typeEvent = originalTypeEvent;
@ -214,7 +212,7 @@ function removeNamespacedHandlers(element, events, typeEvent, namespace) {
const storeElementEvent = events[typeEvent] || {};
Object.keys(storeElementEvent).forEach((handlerKey) => {
if (handlerKey.includes(namespace)) {
if (handlerKey.indexOf(namespace) > -1) {
const event = storeElementEvent[handlerKey];
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector);
@ -243,7 +241,7 @@ const EventHandler = {
);
const inNamespace = typeEvent !== originalTypeEvent;
const events = getEvent(element);
const isNamespace = originalTypeEvent.startsWith('.');
const isNamespace = originalTypeEvent.charAt(0) === '.';
if (typeof originalHandler !== 'undefined') {
// Simplest case: handler is passed, remove that listener ONLY.
@ -265,7 +263,7 @@ const EventHandler = {
Object.keys(storeElementEvent).forEach((keyHandlers) => {
const handlerKey = keyHandlers.replace(stripUidRegex, '');
if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
if (!inNamespace || originalTypeEvent.indexOf(handlerKey) > -1) {
const event = storeElementEvent[keyHandlers];
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector);
@ -278,10 +276,9 @@ const EventHandler = {
return null;
}
const $ = getjQuery();
const typeEvent = event.replace(stripNameRegex, '');
const inNamespace = event !== typeEvent;
const isNative = nativeEvents.has(typeEvent);
const isNative = nativeEvents.indexOf(typeEvent) > -1;
let jQueryEvent;
let bubbles = true;
@ -308,7 +305,7 @@ const EventHandler = {
});
}
// merge custom information in our event
// merge custom informations in our event
if (typeof args !== 'undefined') {
Object.keys(args).forEach((key) => {
Object.defineProperty(evt, key, {
@ -321,6 +318,12 @@ const EventHandler = {
if (defaultPrevented) {
evt.preventDefault();
if (!defaultPreventedPreservedOnDispatch) {
Object.defineProperty(evt, 'defaultPrevented', {
get: () => true,
});
}
}
if (nativeDispatch) {

View File

@ -1,6 +1,6 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/manipulator.js
* Bootstrap (v5.0.0-alpha1): dom/manipulator.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -31,11 +31,11 @@ function normalizeDataKey(key) {
const Manipulator = {
setDataAttribute(element, key, value) {
element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value);
element.setAttribute(`data-${normalizeDataKey(key)}`, value);
},
removeDataAttribute(element, key) {
element.removeAttribute(`data-bs-${normalizeDataKey(key)}`);
element.removeAttribute(`data-${normalizeDataKey(key)}`);
},
getDataAttributes(element) {
@ -43,21 +43,19 @@ const Manipulator = {
return {};
}
const attributes = {};
const attributes = {
...element.dataset,
};
Object.keys(element.dataset)
.filter((key) => key.startsWith('bs'))
.forEach((key) => {
let pureKey = key.replace(/^bs/, '');
pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
attributes[pureKey] = normalizeData(element.dataset[key]);
});
Object.keys(attributes).forEach((key) => {
attributes[key] = normalizeData(attributes[key]);
});
return attributes;
},
getDataAttribute(element, key) {
return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`));
return normalizeData(element.getAttribute(`data-${normalizeDataKey(key)}`));
},
offset(element) {
@ -75,6 +73,18 @@ const Manipulator = {
left: element.offsetLeft,
};
},
toggleClass(element, className) {
if (!element) {
return;
}
if (element.classList.contains(className)) {
element.classList.remove(className);
} else {
element.classList.add(className);
}
},
};
export default Manipulator;

View File

@ -0,0 +1,82 @@
/* istanbul ignore file */
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-alpha1): dom/polyfill.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import { getUID } from '../util/index';
let find = Element.prototype.querySelectorAll;
let findOne = Element.prototype.querySelector;
// MSEdge resets defaultPrevented flag upon dispatchEvent call if at least one listener is attached
const defaultPreventedPreservedOnDispatch = (() => {
const e = new CustomEvent('Bootstrap', {
cancelable: true,
});
const element = document.createElement('div');
element.addEventListener('Bootstrap', () => null);
e.preventDefault();
element.dispatchEvent(e);
return e.defaultPrevented;
})();
const scopeSelectorRegex = /:scope\b/;
const supportScopeQuery = (() => {
const element = document.createElement('div');
try {
element.querySelectorAll(':scope *');
} catch (_) {
return false;
}
return true;
})();
if (!supportScopeQuery) {
find = function (selector) {
if (!scopeSelectorRegex.test(selector)) {
return this.querySelectorAll(selector);
}
const hasId = Boolean(this.id);
if (!hasId) {
this.id = getUID('scope');
}
let nodeList = null;
try {
selector = selector.replace(scopeSelectorRegex, `#${this.id}`);
nodeList = this.querySelectorAll(selector);
} finally {
if (!hasId) {
this.removeAttribute('id');
}
}
return nodeList;
};
findOne = function (selector) {
if (!scopeSelectorRegex.test(selector)) {
return this.querySelector(selector);
}
const matches = find.call(this, selector);
if (typeof matches[0] !== 'undefined') {
return matches[0];
}
return null;
};
}
export { find, findOne, defaultPreventedPreservedOnDispatch };

View File

@ -1,10 +1,12 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/selector-engine.js
* Bootstrap (v5.0.0-alpha1): dom/selector-engine.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import { find as findFn, findOne } from './polyfill';
/**
* ------------------------------------------------------------------------
* Constants
@ -19,11 +21,11 @@ const SelectorEngine = {
},
find(selector, element = document.documentElement) {
return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
return [].concat(...findFn.call(element, selector));
},
findOne(selector, element = document.documentElement) {
return Element.prototype.querySelector.call(element, selector);
return findOne.call(element, selector);
},
children(element, selector) {

View File

@ -1,27 +1,23 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dropdown.js
* Bootstrap (v5.0.0-alpha1): dropdown.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import * as Popper from '@popperjs/core';
import {
getjQuery,
onDOMContentLoaded,
getElementFromSelector,
isElement,
isVisible,
isRTL,
noop,
typeCheckConfig,
} from './util/index';
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import Manipulator from './dom/manipulator';
import Popper from 'popper.js';
import SelectorEngine from './dom/selector-engine';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
@ -30,6 +26,7 @@ import BaseComponent from './base-component';
*/
const NAME = 'dropdown';
const VERSION = '5.0.0-alpha1';
const DATA_KEY = 'bs.dropdown';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
@ -55,27 +52,29 @@ const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY}${DATA_API_KEY}`;
const CLASS_NAME_DISABLED = 'disabled';
const CLASS_NAME_SHOW = 'show';
const CLASS_NAME_DROPUP = 'dropup';
const CLASS_NAME_DROPEND = 'dropend';
const CLASS_NAME_DROPSTART = 'dropstart';
const CLASS_NAME_DROPRIGHT = 'dropright';
const CLASS_NAME_DROPLEFT = 'dropleft';
const CLASS_NAME_MENURIGHT = 'dropdown-menu-right';
const CLASS_NAME_NAVBAR = 'navbar';
const CLASS_NAME_POSITION_STATIC = 'position-static';
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="dropdown"]';
const SELECTOR_DATA_TOGGLE = '[data-toggle="dropdown"]';
const SELECTOR_FORM_CHILD = '.dropdown form';
const SELECTOR_MENU = '.dropdown-menu';
const SELECTOR_NAVBAR_NAV = '.navbar-nav';
const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
const PLACEMENT_TOP = isRTL ? 'top-end' : 'top-start';
const PLACEMENT_TOPEND = isRTL ? 'top-start' : 'top-end';
const PLACEMENT_BOTTOM = isRTL ? 'bottom-end' : 'bottom-start';
const PLACEMENT_BOTTOMEND = isRTL ? 'bottom-start' : 'bottom-end';
const PLACEMENT_RIGHT = isRTL ? 'left-start' : 'right-start';
const PLACEMENT_LEFT = isRTL ? 'right-start' : 'left-start';
const PLACEMENT_TOP = 'top-start';
const PLACEMENT_TOPEND = 'top-end';
const PLACEMENT_BOTTOM = 'bottom-start';
const PLACEMENT_BOTTOMEND = 'bottom-end';
const PLACEMENT_RIGHT = 'right-start';
const PLACEMENT_LEFT = 'left-start';
const Default = {
offset: 0,
flip: true,
boundary: 'clippingParents',
boundary: 'scrollParent',
reference: 'toggle',
display: 'dynamic',
popperConfig: null,
@ -96,20 +95,24 @@ const DefaultType = {
* ------------------------------------------------------------------------
*/
class Dropdown extends BaseComponent {
class Dropdown {
constructor(element, config) {
super(element);
this._element = element;
this._popper = null;
this._config = this._getConfig(config);
this._menu = this._getMenuElement();
this._inNavbar = this._detectNavbar();
this._addEventListeners();
Data.setData(element, DATA_KEY, this);
}
// Getters
static get VERSION() {
return VERSION;
}
static get Default() {
return Default;
}
@ -118,10 +121,6 @@ class Dropdown extends BaseComponent {
return DefaultType;
}
static get DATA_KEY() {
return DATA_KEY;
}
// Public
toggle() {
@ -160,10 +159,10 @@ class Dropdown extends BaseComponent {
return;
}
// Totally disable Popper for Dropdowns in Navbar
// Disable totally Popper.js for Dropdown in Navbar
if (!this._inNavbar) {
if (typeof Popper === 'undefined') {
throw new TypeError("Bootstrap's dropdowns require Popper (https://popper.js.org)");
throw new TypeError("Bootstrap's dropdowns require Popper.js (https://popper.js.org)");
}
let referenceElement = this._element;
@ -179,7 +178,14 @@ class Dropdown extends BaseComponent {
}
}
this._popper = Popper.createPopper(referenceElement, this._menu, this._getPopperConfig());
// If boundary is not `scrollParent`, then set position to `static`
// to allow the menu to "escape" the scroll parent's boundaries
// https://github.com/twbs/bootstrap/issues/24251
if (this._config.boundary !== 'scrollParent') {
parent.classList.add(CLASS_NAME_POSITION_STATIC);
}
this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
}
// If this is a touch-enabled device we add extra
@ -195,8 +201,8 @@ class Dropdown extends BaseComponent {
this._element.focus();
this._element.setAttribute('aria-expanded', true);
this._menu.classList.toggle(CLASS_NAME_SHOW);
this._element.classList.toggle(CLASS_NAME_SHOW);
Manipulator.toggleClass(this._menu, CLASS_NAME_SHOW);
Manipulator.toggleClass(this._element, CLASS_NAME_SHOW);
EventHandler.trigger(parent, EVENT_SHOWN, relatedTarget);
}
@ -224,16 +230,16 @@ class Dropdown extends BaseComponent {
this._popper.destroy();
}
this._menu.classList.toggle(CLASS_NAME_SHOW);
this._element.classList.toggle(CLASS_NAME_SHOW);
Manipulator.toggleClass(this._menu, CLASS_NAME_SHOW);
Manipulator.toggleClass(this._element, CLASS_NAME_SHOW);
EventHandler.trigger(parent, EVENT_HIDDEN, relatedTarget);
}
dispose() {
super.dispose();
Data.removeData(this._element, DATA_KEY);
EventHandler.off(this._element, EVENT_KEY);
this._element = null;
this._menu = null;
if (this._popper) {
this._popper.destroy();
this._popper = null;
@ -243,7 +249,7 @@ class Dropdown extends BaseComponent {
update() {
this._inNavbar = this._detectNavbar();
if (this._popper) {
this._popper.update();
this._popper.scheduleUpdate();
}
}
@ -275,51 +281,67 @@ class Dropdown extends BaseComponent {
_getPlacement() {
const parentDropdown = this._element.parentNode;
let placement = PLACEMENT_BOTTOM;
if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
return PLACEMENT_RIGHT;
}
if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
return PLACEMENT_LEFT;
}
// We need to trim the value because custom properties can also include spaces
const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
// Handle dropup
if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
placement = PLACEMENT_TOP;
if (this._menu.classList.contains(CLASS_NAME_MENURIGHT)) {
placement = PLACEMENT_TOPEND;
}
} else if (parentDropdown.classList.contains(CLASS_NAME_DROPRIGHT)) {
placement = PLACEMENT_RIGHT;
} else if (parentDropdown.classList.contains(CLASS_NAME_DROPLEFT)) {
placement = PLACEMENT_LEFT;
} else if (this._menu.classList.contains(CLASS_NAME_MENURIGHT)) {
placement = PLACEMENT_BOTTOMEND;
}
return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
return placement;
}
_detectNavbar() {
return this._element.closest(`.${CLASS_NAME_NAVBAR}`) !== null;
return Boolean(this._element.closest(`.${CLASS_NAME_NAVBAR}`));
}
_getOffset() {
const offset = {};
if (typeof this._config.offset === 'function') {
offset.fn = (data) => {
data.offsets = {
...data.offsets,
...(this._config.offset(data.offsets, this._element) || {}),
};
return data;
};
} else {
offset.offset = this._config.offset;
}
return offset;
}
_getPopperConfig() {
const popperConfig = {
placement: this._getPlacement(),
modifiers: [
{
name: 'preventOverflow',
options: {
altBoundary: this._config.flip,
rootBoundary: this._config.boundary,
},
modifiers: {
offset: this._getOffset(),
flip: {
enabled: this._config.flip,
},
],
preventOverflow: {
boundariesElement: this._config.boundary,
},
},
};
// Disable Popper if we have a static display
// Disable Popper.js if we have a static display
if (this._config.display === 'static') {
popperConfig.modifiers = [
{
name: 'applyStyles',
enabled: false,
},
];
popperConfig.modifiers.applyStyle = {
enabled: false,
};
}
return {
@ -472,13 +494,13 @@ class Dropdown extends BaseComponent {
let index = items.indexOf(event.target);
// Up
if (event.key === ARROW_UP_KEY && index > 0) {
// Up
index--;
}
// Down
if (event.key === ARROW_DOWN_KEY && index < items.length - 1) {
// Down
index++;
}
@ -487,6 +509,10 @@ class Dropdown extends BaseComponent {
items[index].focus();
}
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
}
/**
@ -511,25 +537,23 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
});
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_FORM_CHILD, (e) => e.stopPropagation());
const $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Dropdown to jQuery only if jQuery is present
* add .dropdown to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Dropdown.jQueryInterface;
$.fn[NAME].Constructor = Dropdown;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Dropdown.jQueryInterface;
};
}
});
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Dropdown.jQueryInterface;
$.fn[NAME].Constructor = Dropdown;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Dropdown.jQueryInterface;
};
}
export default Dropdown;

View File

@ -1,19 +1,17 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): modal.js
* Bootstrap (v5.0.0-alpha1): modal.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import {
getjQuery,
onDOMContentLoaded,
TRANSITION_END,
emulateTransitionEnd,
getElementFromSelector,
getTransitionDurationFromElement,
isVisible,
isRTL,
reflow,
typeCheckConfig,
} from './util/index';
@ -21,7 +19,6 @@ import Data from './dom/data';
import EventHandler from './dom/event-handler';
import Manipulator from './dom/manipulator';
import SelectorEngine from './dom/selector-engine';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
@ -30,6 +27,7 @@ import BaseComponent from './base-component';
*/
const NAME = 'modal';
const VERSION = '5.0.0-alpha1';
const DATA_KEY = 'bs.modal';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
@ -39,12 +37,14 @@ const Default = {
backdrop: true,
keyboard: true,
focus: true,
show: true,
};
const DefaultType = {
backdrop: '(boolean|string)',
keyboard: 'boolean',
focus: 'boolean',
show: 'boolean',
};
const EVENT_HIDE = `hide${EVENT_KEY}`;
@ -69,8 +69,8 @@ const CLASS_NAME_STATIC = 'modal-static';
const SELECTOR_DIALOG = '.modal-dialog';
const SELECTOR_MODAL_BODY = '.modal-body';
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="modal"]';
const SELECTOR_DATA_DISMISS = '[data-bs-dismiss="modal"]';
const SELECTOR_DATA_TOGGLE = '[data-toggle="modal"]';
const SELECTOR_DATA_DISMISS = '[data-dismiss="modal"]';
const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
const SELECTOR_STICKY_CONTENT = '.sticky-top';
@ -80,11 +80,10 @@ const SELECTOR_STICKY_CONTENT = '.sticky-top';
* ------------------------------------------------------------------------
*/
class Modal extends BaseComponent {
class Modal {
constructor(element, config) {
super(element);
this._config = this._getConfig(config);
this._element = element;
this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, element);
this._backdrop = null;
this._isShown = false;
@ -92,16 +91,17 @@ class Modal extends BaseComponent {
this._ignoreBackdropClick = false;
this._isTransitioning = false;
this._scrollbarWidth = 0;
Data.setData(element, DATA_KEY, this);
}
// Getters
static get Default() {
return Default;
static get VERSION() {
return VERSION;
}
static get DATA_KEY() {
return DATA_KEY;
static get Default() {
return Default;
}
// Public
@ -199,8 +199,6 @@ class Modal extends BaseComponent {
EventHandler.off(htmlElement, EVENT_KEY)
);
super.dispose();
/**
* `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
* Do not move `document` in `htmlElements` array
@ -208,7 +206,10 @@ class Modal extends BaseComponent {
*/
EventHandler.off(document, EVENT_FOCUSIN);
Data.removeData(this._element, DATA_KEY);
this._config = null;
this._element = null;
this._dialog = null;
this._backdrop = null;
this._isShown = null;
@ -361,11 +362,7 @@ class Modal extends BaseComponent {
return;
}
if (this._config.backdrop === 'static') {
this._triggerBackdropTransition();
} else {
this.hide();
}
this._triggerBackdropTransition();
});
if (animate) {
@ -404,31 +401,22 @@ class Modal extends BaseComponent {
}
_triggerBackdropTransition() {
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
if (hideEvent.defaultPrevented) {
return;
}
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
if (!isModalOverflowing) {
this._element.style.overflowY = 'hidden';
}
this._element.classList.add(CLASS_NAME_STATIC);
const modalTransitionDuration = getTransitionDurationFromElement(this._dialog);
EventHandler.off(this._element, TRANSITION_END);
EventHandler.one(this._element, TRANSITION_END, () => {
this._element.classList.remove(CLASS_NAME_STATIC);
if (!isModalOverflowing) {
EventHandler.one(this._element, TRANSITION_END, () => {
this._element.style.overflowY = '';
});
emulateTransitionEnd(this._element, modalTransitionDuration);
if (this._config.backdrop === 'static') {
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
if (hideEvent.defaultPrevented) {
return;
}
});
emulateTransitionEnd(this._element, modalTransitionDuration);
this._element.focus();
this._element.classList.add(CLASS_NAME_STATIC);
const modalTransitionDuration = getTransitionDurationFromElement(this._element);
EventHandler.one(this._element, TRANSITION_END, () => {
this._element.classList.remove(CLASS_NAME_STATIC);
});
emulateTransitionEnd(this._element, modalTransitionDuration);
this._element.focus();
} else {
this.hide();
}
}
// ----------------------------------------------------------------------
@ -438,17 +426,11 @@ class Modal extends BaseComponent {
_adjustDialog() {
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
if (
(!this._isBodyOverflowing && isModalOverflowing && !isRTL) ||
(this._isBodyOverflowing && !isModalOverflowing && isRTL)
) {
if (!this._isBodyOverflowing && isModalOverflowing) {
this._element.style.paddingLeft = `${this._scrollbarWidth}px`;
}
if (
(this._isBodyOverflowing && !isModalOverflowing && !isRTL) ||
(!this._isBodyOverflowing && isModalOverflowing && isRTL)
) {
if (this._isBodyOverflowing && !isModalOverflowing) {
this._element.style.paddingRight = `${this._scrollbarWidth}px`;
}
}
@ -474,9 +456,7 @@ class Modal extends BaseComponent {
const actualPadding = element.style.paddingRight;
const calculatedPadding = window.getComputedStyle(element)['padding-right'];
Manipulator.setDataAttribute(element, 'padding-right', actualPadding);
element.style.paddingRight = `${
Number.parseFloat(calculatedPadding) + this._scrollbarWidth
}px`;
element.style.paddingRight = `${parseFloat(calculatedPadding) + this._scrollbarWidth}px`;
});
// Adjust sticky content margin
@ -484,9 +464,7 @@ class Modal extends BaseComponent {
const actualMargin = element.style.marginRight;
const calculatedMargin = window.getComputedStyle(element)['margin-right'];
Manipulator.setDataAttribute(element, 'margin-right', actualMargin);
element.style.marginRight = `${
Number.parseFloat(calculatedMargin) - this._scrollbarWidth
}px`;
element.style.marginRight = `${parseFloat(calculatedMargin) - this._scrollbarWidth}px`;
});
// Adjust body padding
@ -495,7 +473,7 @@ class Modal extends BaseComponent {
Manipulator.setDataAttribute(document.body, 'padding-right', actualPadding);
document.body.style.paddingRight = `${
Number.parseFloat(calculatedPadding) + this._scrollbarWidth
parseFloat(calculatedPadding) + this._scrollbarWidth
}px`;
}
@ -562,9 +540,15 @@ class Modal extends BaseComponent {
}
data[config](relatedTarget);
} else if (_config.show) {
data.show(relatedTarget);
}
});
}
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
}
/**
@ -606,25 +590,23 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
data.show(this);
});
const $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Modal to jQuery only if jQuery is present
* add .modal to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Modal.jQueryInterface;
$.fn[NAME].Constructor = Modal;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Modal.jQueryInterface;
};
}
});
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Modal.jQueryInterface;
$.fn[NAME].Constructor = Modal;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Modal.jQueryInterface;
};
}
export default Modal;

View File

@ -1,11 +1,11 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): popover.js
* Bootstrap (v5.0.0-alpha1): popover.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import { getjQuery, onDOMContentLoaded } from './util/index';
import { getjQuery } from './util/index';
import Data from './dom/data';
import SelectorEngine from './dom/selector-engine';
import Tooltip from './tooltip';
@ -17,6 +17,7 @@ import Tooltip from './tooltip';
*/
const NAME = 'popover';
const VERSION = '5.0.0-alpha1';
const DATA_KEY = 'bs.popover';
const EVENT_KEY = `.${DATA_KEY}`;
const CLASS_PREFIX = 'bs-popover';
@ -31,8 +32,7 @@ const Default = {
'<div class="popover" role="tooltip">' +
'<div class="popover-arrow"></div>' +
'<h3 class="popover-header"></h3>' +
'<div class="popover-body"></div>' +
'</div>',
'<div class="popover-body"></div></div>',
};
const DefaultType = {
@ -68,6 +68,10 @@ const SELECTOR_CONTENT = '.popover-body';
class Popover extends Tooltip {
// Getters
static get VERSION() {
return VERSION;
}
static get Default() {
return Default;
}
@ -105,7 +109,7 @@ class Popover extends Tooltip {
this.setElementContent(SelectorEngine.findOne(SELECTOR_TITLE, tip), this.getTitle());
let content = this._getContent();
if (typeof content === 'function') {
content = content.call(this._element);
content = content.call(this.element);
}
this.setElementContent(SelectorEngine.findOne(SELECTOR_CONTENT, tip), content);
@ -113,14 +117,14 @@ class Popover extends Tooltip {
tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW);
}
// Private
_addAttachmentClass(attachment) {
this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`);
this.getTipElement().classList.add(`${CLASS_PREFIX}-${attachment}`);
}
// Private
_getContent() {
return this._element.getAttribute('data-bs-content') || this.config.content;
return this.element.getAttribute('data-content') || this.config.content;
}
_cleanTipClass() {
@ -156,27 +160,28 @@ class Popover extends Tooltip {
}
});
}
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
}
const $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Popover to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Popover.jQueryInterface;
$.fn[NAME].Constructor = Popover;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Popover.jQueryInterface;
};
}
});
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Popover.jQueryInterface;
$.fn[NAME].Constructor = Popover;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Popover.jQueryInterface;
};
}
export default Popover;

View File

@ -1,13 +1,12 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): scrollspy.js
* Bootstrap (v5.0.0-alpha1): scrollspy.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import {
getjQuery,
onDOMContentLoaded,
getSelectorFromElement,
getUID,
isElement,
@ -17,7 +16,6 @@ import Data from './dom/data';
import EventHandler from './dom/event-handler';
import Manipulator from './dom/manipulator';
import SelectorEngine from './dom/selector-engine';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
@ -26,6 +24,7 @@ import BaseComponent from './base-component';
*/
const NAME = 'scrollspy';
const VERSION = '5.0.0-alpha1';
const DATA_KEY = 'bs.scrollspy';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
@ -49,7 +48,7 @@ const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
const CLASS_NAME_ACTIVE = 'active';
const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
const SELECTOR_DATA_SPY = '[data-spy="scroll"]';
const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
const SELECTOR_NAV_LINKS = '.nav-link';
const SELECTOR_NAV_ITEMS = '.nav-item';
@ -66,12 +65,15 @@ const METHOD_POSITION = 'position';
* ------------------------------------------------------------------------
*/
class ScrollSpy extends BaseComponent {
class ScrollSpy {
constructor(element, config) {
super(element);
this._element = element;
this._scrollElement = element.tagName === 'BODY' ? window : element;
this._config = this._getConfig(config);
this._selector = `${this._config.target} ${SELECTOR_NAV_LINKS}, ${this._config.target} ${SELECTOR_LIST_ITEMS}, ${this._config.target} .${CLASS_NAME_DROPDOWN_ITEM}`;
this._selector =
`${this._config.target} ${SELECTOR_NAV_LINKS},` +
`${this._config.target} ${SELECTOR_LIST_ITEMS},` +
`${this._config.target} .${CLASS_NAME_DROPDOWN_ITEM}`;
this._offsets = [];
this._targets = [];
this._activeTarget = null;
@ -81,16 +83,18 @@ class ScrollSpy extends BaseComponent {
this.refresh();
this._process();
Data.setData(element, DATA_KEY, this);
}
// Getters
static get Default() {
return Default;
static get VERSION() {
return VERSION;
}
static get DATA_KEY() {
return DATA_KEY;
static get Default() {
return Default;
}
// Public
@ -105,14 +109,19 @@ class ScrollSpy extends BaseComponent {
this._offsets = [];
this._targets = [];
this._scrollHeight = this._getScrollHeight();
const targets = SelectorEngine.find(this._selector);
targets
.map((element) => {
let target;
const targetSelector = getSelectorFromElement(element);
const target = targetSelector ? SelectorEngine.findOne(targetSelector) : null;
if (targetSelector) {
target = SelectorEngine.findOne(targetSelector);
}
if (target) {
const targetBCR = target.getBoundingClientRect();
@ -132,9 +141,10 @@ class ScrollSpy extends BaseComponent {
}
dispose() {
super.dispose();
Data.removeData(this._element, DATA_KEY);
EventHandler.off(this._scrollElement, EVENT_KEY);
this._element = null;
this._scrollElement = null;
this._config = null;
this._selector = null;
@ -230,7 +240,7 @@ class ScrollSpy extends BaseComponent {
const queries = this._selector
.split(',')
.map((selector) => `${selector}[data-bs-target="${target}"],${selector}[href="${target}"]`);
.map((selector) => `${selector}[data-target="${target}"],${selector}[href="${target}"]`);
const link = SelectorEngine.findOne(queries.join(','));
@ -293,6 +303,10 @@ class ScrollSpy extends BaseComponent {
}
});
}
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
}
/**
@ -307,25 +321,22 @@ EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
);
});
const $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .ScrollSpy to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = ScrollSpy.jQueryInterface;
$.fn[NAME].Constructor = ScrollSpy;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return ScrollSpy.jQueryInterface;
};
}
});
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = ScrollSpy.jQueryInterface;
$.fn[NAME].Constructor = ScrollSpy;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return ScrollSpy.jQueryInterface;
};
}
export default ScrollSpy;

View File

@ -1,13 +1,12 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): tab.js
* Bootstrap (v5.0.0-alpha1): tab.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import {
getjQuery,
onDOMContentLoaded,
TRANSITION_END,
emulateTransitionEnd,
getElementFromSelector,
@ -17,7 +16,6 @@ import {
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import SelectorEngine from './dom/selector-engine';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
@ -26,6 +24,7 @@ import BaseComponent from './base-component';
*/
const NAME = 'tab';
const VERSION = '5.0.0-alpha1';
const DATA_KEY = 'bs.tab';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
@ -46,8 +45,7 @@ const SELECTOR_DROPDOWN = '.dropdown';
const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
const SELECTOR_ACTIVE = '.active';
const SELECTOR_ACTIVE_UL = ':scope > li > .active';
const SELECTOR_DATA_TOGGLE =
'[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]';
const SELECTOR_DATA_TOGGLE = '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]';
const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
const SELECTOR_DROPDOWN_ACTIVE_CHILD = ':scope > .dropdown-menu .active';
@ -57,11 +55,17 @@ const SELECTOR_DROPDOWN_ACTIVE_CHILD = ':scope > .dropdown-menu .active';
* ------------------------------------------------------------------------
*/
class Tab extends BaseComponent {
class Tab {
constructor(element) {
this._element = element;
Data.setData(this._element, DATA_KEY, this);
}
// Getters
static get DATA_KEY() {
return DATA_KEY;
static get VERSION() {
return VERSION;
}
// Public
@ -123,6 +127,11 @@ class Tab extends BaseComponent {
}
}
dispose() {
Data.removeData(this._element, DATA_KEY);
this._element = null;
}
// Private
_activate(element, container, callback) {
@ -208,6 +217,10 @@ class Tab extends BaseComponent {
}
});
}
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
}
/**
@ -223,25 +236,23 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
data.show();
});
const $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Tab to jQuery only if jQuery is present
* add .tab to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Tab.jQueryInterface;
$.fn[NAME].Constructor = Tab;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Tab.jQueryInterface;
};
}
});
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Tab.jQueryInterface;
$.fn[NAME].Constructor = Tab;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Tab.jQueryInterface;
};
}
export default Tab;

View File

@ -1,13 +1,12 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): toast.js
* Bootstrap (v5.0.0-alpha1): toast.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import {
getjQuery,
onDOMContentLoaded,
TRANSITION_END,
emulateTransitionEnd,
getTransitionDurationFromElement,
@ -17,7 +16,6 @@ import {
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import Manipulator from './dom/manipulator';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
@ -26,6 +24,7 @@ import BaseComponent from './base-component';
*/
const NAME = 'toast';
const VERSION = '5.0.0-alpha1';
const DATA_KEY = 'bs.toast';
const EVENT_KEY = `.${DATA_KEY}`;
@ -49,10 +48,10 @@ const DefaultType = {
const Default = {
animation: true,
autohide: true,
delay: 5000,
delay: 500,
};
const SELECTOR_DATA_DISMISS = '[data-bs-dismiss="toast"]';
const SELECTOR_DATA_DISMISS = '[data-dismiss="toast"]';
/**
* ------------------------------------------------------------------------
@ -60,17 +59,21 @@ const SELECTOR_DATA_DISMISS = '[data-bs-dismiss="toast"]';
* ------------------------------------------------------------------------
*/
class Toast extends BaseComponent {
class Toast {
constructor(element, config) {
super(element);
this._element = element;
this._config = this._getConfig(config);
this._timeout = null;
this._setListeners();
Data.setData(element, DATA_KEY, this);
}
// Getters
static get VERSION() {
return VERSION;
}
static get DefaultType() {
return DefaultType;
}
@ -79,10 +82,6 @@ class Toast extends BaseComponent {
return Default;
}
static get DATA_KEY() {
return DATA_KEY;
}
// Public
show() {
@ -92,8 +91,6 @@ class Toast extends BaseComponent {
return;
}
this._clearTimeout();
if (this._config.animation) {
this._element.classList.add(CLASS_NAME_FADE);
}
@ -152,15 +149,17 @@ class Toast extends BaseComponent {
}
dispose() {
this._clearTimeout();
clearTimeout(this._timeout);
this._timeout = null;
if (this._element.classList.contains(CLASS_NAME_SHOW)) {
this._element.classList.remove(CLASS_NAME_SHOW);
}
EventHandler.off(this._element, EVENT_CLICK_DISMISS);
Data.removeData(this._element, DATA_KEY);
super.dispose();
this._element = null;
this._config = null;
}
@ -182,11 +181,6 @@ class Toast extends BaseComponent {
EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, () => this.hide());
}
_clearTimeout() {
clearTimeout(this._timeout);
this._timeout = null;
}
// Static
static jQueryInterface(config) {
@ -207,27 +201,29 @@ class Toast extends BaseComponent {
}
});
}
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
}
const $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Toast to jQuery only if jQuery is present
* add .toast to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Toast.jQueryInterface;
$.fn[NAME].Constructor = Toast;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Toast.jQueryInterface;
};
}
});
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Toast.jQueryInterface;
$.fn[NAME].Constructor = Toast;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Toast.jQueryInterface;
};
}
export default Toast;

View File

@ -1,31 +1,27 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): tooltip.js
* Bootstrap (v5.0.0-alpha1): tooltip.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import * as Popper from '@popperjs/core';
import {
getjQuery,
onDOMContentLoaded,
TRANSITION_END,
emulateTransitionEnd,
findShadowRoot,
getTransitionDurationFromElement,
getUID,
isElement,
isRTL,
noop,
typeCheckConfig,
} from './util/index';
import { DefaultAllowlist, sanitizeHtml } from './util/sanitizer';
import { DefaultWhitelist, sanitizeHtml } from './util/sanitizer';
import Data from './dom/data';
import EventHandler from './dom/event-handler';
import Manipulator from './dom/manipulator';
import Popper from 'popper.js';
import SelectorEngine from './dom/selector-engine';
import BaseComponent from './base-component';
/**
* ------------------------------------------------------------------------
@ -34,11 +30,12 @@ import BaseComponent from './base-component';
*/
const NAME = 'tooltip';
const VERSION = '5.0.0-alpha1';
const DATA_KEY = 'bs.tooltip';
const EVENT_KEY = `.${DATA_KEY}`;
const CLASS_PREFIX = 'bs-tooltip';
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g');
const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
const DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
const DefaultType = {
animation: 'boolean',
@ -49,22 +46,22 @@ const DefaultType = {
html: 'boolean',
selector: '(string|boolean)',
placement: '(string|function)',
offset: '(number|string|function)',
container: '(string|element|boolean)',
fallbackPlacements: '(null|array)',
fallbackPlacement: '(string|array)',
boundary: '(string|element)',
customClass: '(string|function)',
sanitize: 'boolean',
sanitizeFn: '(null|function)',
allowList: 'object',
whiteList: 'object',
popperConfig: '(null|object)',
};
const AttachmentMap = {
AUTO: 'auto',
TOP: 'top',
RIGHT: isRTL ? 'left' : 'right',
RIGHT: 'right',
BOTTOM: 'bottom',
LEFT: isRTL ? 'right' : 'left',
LEFT: 'left',
};
const Default = {
@ -72,21 +69,20 @@ const Default = {
template:
'<div class="tooltip" role="tooltip">' +
'<div class="tooltip-arrow"></div>' +
'<div class="tooltip-inner"></div>' +
'</div>',
'<div class="tooltip-inner"></div></div>',
trigger: 'hover focus',
title: '',
delay: 0,
html: false,
selector: false,
placement: 'top',
offset: 0,
container: false,
fallbackPlacements: null,
boundary: 'clippingParents',
customClass: '',
fallbackPlacement: 'flip',
boundary: 'scrollParent',
sanitize: true,
sanitizeFn: null,
allowList: DefaultAllowlist,
whiteList: DefaultWhitelist,
popperConfig: null,
};
@ -123,14 +119,12 @@ const TRIGGER_MANUAL = 'manual';
* ------------------------------------------------------------------------
*/
class Tooltip extends BaseComponent {
class Tooltip {
constructor(element, config) {
if (typeof Popper === 'undefined') {
throw new TypeError("Bootstrap's tooltips require Popper (https://popper.js.org)");
throw new TypeError("Bootstrap's tooltips require Popper.js (https://popper.js.org)");
}
super(element);
// private
this._isEnabled = true;
this._timeout = 0;
@ -139,14 +133,20 @@ class Tooltip extends BaseComponent {
this._popper = null;
// Protected
this.element = element;
this.config = this._getConfig(config);
this.tip = null;
this._setListeners();
Data.setData(element, this.constructor.DATA_KEY, this);
}
// Getters
static get VERSION() {
return VERSION;
}
static get Default() {
return Default;
}
@ -192,11 +192,11 @@ class Tooltip extends BaseComponent {
if (event) {
const dataKey = this.constructor.DATA_KEY;
let context = Data.getData(event.delegateTarget, dataKey);
let context = Data.getData(event.target, dataKey);
if (!context) {
context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
Data.setData(event.delegateTarget, dataKey, context);
context = new this.constructor(event.target, this._getDelegateConfig());
Data.setData(event.target, dataKey, context);
}
context._activeTrigger.click = !context._activeTrigger.click;
@ -219,9 +219,11 @@ class Tooltip extends BaseComponent {
dispose() {
clearTimeout(this._timeout);
EventHandler.off(this._element, this.constructor.EVENT_KEY);
Data.removeData(this.element, this.constructor.DATA_KEY);
EventHandler.off(this.element, this.constructor.EVENT_KEY);
EventHandler.off(
this._element.closest(`.${CLASS_NAME_MODAL}`),
this.element.closest(`.${CLASS_NAME_MODAL}`),
'hide.bs.modal',
this._hideModalHandler
);
@ -239,23 +241,23 @@ class Tooltip extends BaseComponent {
}
this._popper = null;
this.element = null;
this.config = null;
this.tip = null;
super.dispose();
}
show() {
if (this._element.style.display === 'none') {
if (this.element.style.display === 'none') {
throw new Error('Please use show on visible elements');
}
if (this.isWithContent() && this._isEnabled) {
const showEvent = EventHandler.trigger(this._element, this.constructor.Event.SHOW);
const shadowRoot = findShadowRoot(this._element);
const showEvent = EventHandler.trigger(this.element, this.constructor.Event.SHOW);
const shadowRoot = findShadowRoot(this.element);
const isInTheDom =
shadowRoot === null
? this._element.ownerDocument.documentElement.contains(this._element)
: shadowRoot.contains(this._element);
? this.element.ownerDocument.documentElement.contains(this.element)
: shadowRoot.contains(this.element);
if (showEvent.defaultPrevented || !isInTheDom) {
return;
@ -265,7 +267,7 @@ class Tooltip extends BaseComponent {
const tipId = getUID(this.constructor.NAME);
tip.setAttribute('id', tipId);
this._element.setAttribute('aria-describedby', tipId);
this.element.setAttribute('aria-describedby', tipId);
this.setContent();
@ -275,7 +277,7 @@ class Tooltip extends BaseComponent {
const placement =
typeof this.config.placement === 'function'
? this.config.placement.call(this, tip, this._element)
? this.config.placement.call(this, tip, this.element)
: this.config.placement;
const attachment = this._getAttachment(placement);
@ -284,24 +286,16 @@ class Tooltip extends BaseComponent {
const container = this._getContainer();
Data.setData(tip, this.constructor.DATA_KEY, this);
if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
if (!this.element.ownerDocument.documentElement.contains(this.tip)) {
container.appendChild(tip);
}
EventHandler.trigger(this._element, this.constructor.Event.INSERTED);
EventHandler.trigger(this.element, this.constructor.Event.INSERTED);
this._popper = Popper.createPopper(this._element, tip, this._getPopperConfig(attachment));
this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
tip.classList.add(CLASS_NAME_SHOW);
const customClass =
typeof this.config.customClass === 'function'
? this.config.customClass()
: this.config.customClass;
if (customClass) {
tip.classList.add(...customClass.split(' '));
}
// If this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
// only needed because of broken event delegation on iOS
@ -313,10 +307,14 @@ class Tooltip extends BaseComponent {
}
const complete = () => {
const prevHoverState = this._hoverState;
if (this.config.animation) {
this._fixTransition();
}
const prevHoverState = this._hoverState;
this._hoverState = null;
EventHandler.trigger(this._element, this.constructor.Event.SHOWN);
EventHandler.trigger(this.element, this.constructor.Event.SHOWN);
if (prevHoverState === HOVER_STATE_OUT) {
this._leave(null, this);
@ -334,10 +332,6 @@ class Tooltip extends BaseComponent {
}
hide() {
if (!this._popper) {
return;
}
const tip = this.getTipElement();
const complete = () => {
if (this._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
@ -345,16 +339,12 @@ class Tooltip extends BaseComponent {
}
this._cleanTipClass();
this._element.removeAttribute('aria-describedby');
EventHandler.trigger(this._element, this.constructor.Event.HIDDEN);
if (this._popper) {
this._popper.destroy();
this._popper = null;
}
this.element.removeAttribute('aria-describedby');
EventHandler.trigger(this.element, this.constructor.Event.HIDDEN);
this._popper.destroy();
};
const hideEvent = EventHandler.trigger(this._element, this.constructor.Event.HIDE);
const hideEvent = EventHandler.trigger(this.element, this.constructor.Event.HIDE);
if (hideEvent.defaultPrevented) {
return;
}
@ -387,7 +377,7 @@ class Tooltip extends BaseComponent {
update() {
if (this._popper !== null) {
this._popper.update();
this._popper.scheduleUpdate();
}
}
@ -440,7 +430,7 @@ class Tooltip extends BaseComponent {
if (this.config.html) {
if (this.config.sanitize) {
content = sanitizeHtml(content, this.config.allowList, this.config.sanitizeFn);
content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
}
element.innerHTML = content;
@ -450,72 +440,41 @@ class Tooltip extends BaseComponent {
}
getTitle() {
let title = this._element.getAttribute('data-bs-original-title');
let title = this.element.getAttribute('data-original-title');
if (!title) {
title =
typeof this.config.title === 'function'
? this.config.title.call(this._element)
? this.config.title.call(this.element)
: this.config.title;
}
return title;
}
updateAttachment(attachment) {
if (attachment === 'right') {
return 'end';
}
if (attachment === 'left') {
return 'start';
}
return attachment;
}
// Private
_getPopperConfig(attachment) {
const flipModifier = {
name: 'flip',
options: {
altBoundary: true,
},
};
if (this.config.fallbackPlacements) {
flipModifier.options.fallbackPlacements = this.config.fallbackPlacements;
}
const defaultBsConfig = {
placement: attachment,
modifiers: [
flipModifier,
{
name: 'preventOverflow',
options: {
rootBoundary: this.config.boundary,
},
modifiers: {
offset: this._getOffset(),
flip: {
behavior: this.config.fallbackPlacement,
},
{
name: 'arrow',
options: {
element: `.${this.constructor.NAME}-arrow`,
},
arrow: {
element: `.${this.constructor.NAME}-arrow`,
},
{
name: 'onChange',
enabled: true,
phase: 'afterWrite',
fn: (data) => this._handlePopperPlacementChange(data),
preventOverflow: {
boundariesElement: this.config.boundary,
},
],
onFirstUpdate: (data) => {
if (data.options.placement !== data.placement) {
},
onCreate: (data) => {
if (data.originalPlacement !== data.placement) {
this._handlePopperPlacementChange(data);
}
},
onUpdate: (data) => this._handlePopperPlacementChange(data),
};
return {
@ -525,7 +484,26 @@ class Tooltip extends BaseComponent {
}
_addAttachmentClass(attachment) {
this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`);
this.getTipElement().classList.add(`${CLASS_PREFIX}-${attachment}`);
}
_getOffset() {
const offset = {};
if (typeof this.config.offset === 'function') {
offset.fn = (data) => {
data.offsets = {
...data.offsets,
...(this.config.offset(data.offsets, this.element) || {}),
};
return data;
};
} else {
offset.offset = this.config.offset;
}
return offset;
}
_getContainer() {
@ -549,11 +527,8 @@ class Tooltip extends BaseComponent {
triggers.forEach((trigger) => {
if (trigger === 'click') {
EventHandler.on(
this._element,
this.constructor.Event.CLICK,
this.config.selector,
(event) => this.toggle(event)
EventHandler.on(this.element, this.constructor.Event.CLICK, this.config.selector, (event) =>
this.toggle(event)
);
} else if (trigger !== TRIGGER_MANUAL) {
const eventIn =
@ -565,23 +540,21 @@ class Tooltip extends BaseComponent {
? this.constructor.Event.MOUSELEAVE
: this.constructor.Event.FOCUSOUT;
EventHandler.on(this._element, eventIn, this.config.selector, (event) =>
this._enter(event)
);
EventHandler.on(this._element, eventOut, this.config.selector, (event) =>
EventHandler.on(this.element, eventIn, this.config.selector, (event) => this._enter(event));
EventHandler.on(this.element, eventOut, this.config.selector, (event) =>
this._leave(event)
);
}
});
this._hideModalHandler = () => {
if (this._element) {
if (this.element) {
this.hide();
}
};
EventHandler.on(
this._element.closest(`.${CLASS_NAME_MODAL}`),
this.element.closest(`.${CLASS_NAME_MODAL}`),
'hide.bs.modal',
this._hideModalHandler
);
@ -598,26 +571,22 @@ class Tooltip extends BaseComponent {
}
_fixTitle() {
const title = this._element.getAttribute('title');
const originalTitleType = typeof this._element.getAttribute('data-bs-original-title');
const titleType = typeof this.element.getAttribute('data-original-title');
if (title || originalTitleType !== 'string') {
this._element.setAttribute('data-bs-original-title', title || '');
if (title && !this._element.getAttribute('aria-label') && !this._element.textContent) {
this._element.setAttribute('aria-label', title);
}
if (this.element.getAttribute('title') || titleType !== 'string') {
this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
this._element.setAttribute('title', '');
this.element.setAttribute('title', '');
}
}
_enter(event, context) {
const dataKey = this.constructor.DATA_KEY;
context = context || Data.getData(event.delegateTarget, dataKey);
context = context || Data.getData(event.target, dataKey);
if (!context) {
context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
Data.setData(event.delegateTarget, dataKey, context);
context = new this.constructor(event.target, this._getDelegateConfig());
Data.setData(event.target, dataKey, context);
}
if (event) {
@ -650,11 +619,11 @@ class Tooltip extends BaseComponent {
_leave(event, context) {
const dataKey = this.constructor.DATA_KEY;
context = context || Data.getData(event.delegateTarget, dataKey);
context = context || Data.getData(event.target, dataKey);
if (!context) {
context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
Data.setData(event.delegateTarget, dataKey, context);
context = new this.constructor(event.target, this._getDelegateConfig());
Data.setData(event.target, dataKey, context);
}
if (event) {
@ -692,10 +661,10 @@ class Tooltip extends BaseComponent {
}
_getConfig(config) {
const dataAttributes = Manipulator.getDataAttributes(this._element);
const dataAttributes = Manipulator.getDataAttributes(this.element);
Object.keys(dataAttributes).forEach((dataAttr) => {
if (DISALLOWED_ATTRIBUTES.has(dataAttr)) {
if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
delete dataAttributes[dataAttr];
}
});
@ -728,7 +697,7 @@ class Tooltip extends BaseComponent {
typeCheckConfig(NAME, config, this.constructor.DefaultType);
if (config.sanitize) {
config.template = sanitizeHtml(config.template, config.allowList, config.sanitizeFn);
config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
}
return config;
@ -757,15 +726,24 @@ class Tooltip extends BaseComponent {
}
_handlePopperPlacementChange(popperData) {
const { state } = popperData;
const popperInstance = popperData.instance;
this.tip = popperInstance.popper;
this._cleanTipClass();
this._addAttachmentClass(this._getAttachment(popperData.placement));
}
if (!state) {
_fixTransition() {
const tip = this.getTipElement();
const initConfigAnimation = this.config.animation;
if (tip.getAttribute('x-placement') !== null) {
return;
}
this.tip = state.elements.popper;
this._cleanTipClass();
this._addAttachmentClass(this._getAttachment(state.placement));
tip.classList.remove(CLASS_NAME_FADE);
this.config.animation = false;
this.hide();
this.show();
this.config.animation = initConfigAnimation;
}
// Static
@ -792,27 +770,29 @@ class Tooltip extends BaseComponent {
}
});
}
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
}
const $ = getjQuery();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Tooltip to jQuery only if jQuery is present
* add .tooltip to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Tooltip.jQueryInterface;
$.fn[NAME].Constructor = Tooltip;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Tooltip.jQueryInterface;
};
}
});
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Tooltip.jQueryInterface;
$.fn[NAME].Constructor = Tooltip;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Tooltip.jQueryInterface;
};
}
export default Tooltip;

View File

@ -1,6 +1,6 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/index.js
* Bootstrap (v5.0.0-alpha1): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@ -36,7 +36,7 @@ const getUID = (prefix) => {
};
const getSelector = (element) => {
let selector = element.getAttribute('data-bs-target');
let selector = element.getAttribute('data-target');
if (!selector || selector === '#') {
const hrefAttr = element.getAttribute('href');
@ -71,8 +71,8 @@ const getTransitionDurationFromElement = (element) => {
// Get transition-duration of the element
let { transitionDuration, transitionDelay } = window.getComputedStyle(element);
const floatTransitionDuration = Number.parseFloat(transitionDuration);
const floatTransitionDelay = Number.parseFloat(transitionDelay);
const floatTransitionDuration = parseFloat(transitionDuration);
const floatTransitionDelay = parseFloat(transitionDelay);
// Return 0 if element or transition duration is not found
if (!floatTransitionDuration && !floatTransitionDelay) {
@ -83,10 +83,7 @@ const getTransitionDurationFromElement = (element) => {
transitionDuration = transitionDuration.split(',')[0];
transitionDelay = transitionDelay.split(',')[0];
return (
(Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) *
MILLISECONDS_MULTIPLIER
);
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
};
const triggerTransitionEnd = (element) => {
@ -99,7 +96,6 @@ const emulateTransitionEnd = (element, duration) => {
let called = false;
const durationPadding = 5;
const emulatedDuration = duration + durationPadding;
function listener() {
called = true;
element.removeEventListener(TRANSITION_END, listener);
@ -178,24 +174,15 @@ const reflow = (element) => element.offsetHeight;
const getjQuery = () => {
const { jQuery } = window;
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
return jQuery;
}
return null;
};
const onDOMContentLoaded = (callback) => {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callback);
} else {
callback();
}
};
const isRTL = document.documentElement.dir === 'rtl';
export {
getjQuery,
TRANSITION_END,
getUID,
getSelectorFromElement,
@ -209,7 +196,4 @@ export {
findShadowRoot,
noop,
reflow,
getjQuery,
onDOMContentLoaded,
isRTL,
};

View File

@ -1,11 +1,11 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): util/sanitizer.js
* Bootstrap (v5.0.0-alpha1): util/sanitizer.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
const uriAttrs = new Set([
const uriAttrs = [
'background',
'cite',
'href',
@ -14,7 +14,7 @@ const uriAttrs = new Set([
'poster',
'src',
'xlink:href',
]);
];
const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
@ -35,8 +35,8 @@ const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|vid
const allowedAttribute = (attr, allowedAttributeList) => {
const attrName = attr.nodeName.toLowerCase();
if (allowedAttributeList.includes(attrName)) {
if (uriAttrs.has(attrName)) {
if (allowedAttributeList.indexOf(attrName) !== -1) {
if (uriAttrs.indexOf(attrName) !== -1) {
return Boolean(
attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)
);
@ -57,7 +57,7 @@ const allowedAttribute = (attr, allowedAttributeList) => {
return false;
};
export const DefaultAllowlist = {
export const DefaultWhitelist = {
// Global attributes allowed on any supplied element below.
'*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
a: ['target', 'href', 'title', 'rel'],
@ -91,7 +91,7 @@ export const DefaultAllowlist = {
ul: [],
};
export function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
export function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
if (!unsafeHtml.length) {
return unsafeHtml;
}
@ -102,24 +102,24 @@ export function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
const domParser = new window.DOMParser();
const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
const allowlistKeys = Object.keys(allowList);
const whitelistKeys = Object.keys(whiteList);
const elements = [].concat(...createdDocument.body.querySelectorAll('*'));
for (let i = 0, len = elements.length; i < len; i++) {
const el = elements[i];
const elName = el.nodeName.toLowerCase();
if (!allowlistKeys.includes(elName)) {
if (whitelistKeys.indexOf(elName) === -1) {
el.parentNode.removeChild(el);
continue;
}
const attributeList = [].concat(...el.attributes);
const allowedAttributes = [].concat(allowList['*'] || [], allowList[elName] || []);
const whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
attributeList.forEach((attr) => {
if (!allowedAttribute(attr, allowedAttributes)) {
if (!allowedAttribute(attr, whitelistedAttributes)) {
el.removeAttribute(attr.nodeName);
}
});

View File

@ -1,95 +0,0 @@
import { getjQuery, onDOMContentLoaded } from '../mdb/util/index';
import EventHandler from '../mdb/dom/event-handler';
import SelectorEngine from '../mdb/dom/selector-engine';
import BSAlert from '../bootstrap/mdb-prefix/alert';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'alert';
const DATA_KEY = `mdb.${NAME}`;
const EVENT_KEY = `.${DATA_KEY}`;
const EVENT_CLOSE_BS = 'close.bs.alert';
const EVENT_CLOSED_BS = 'closed.bs.alert';
const EVENT_CLOSE = `close${EVENT_KEY}`;
const EVENT_CLOSED = `closed${EVENT_KEY}`;
const SELECTOR_ALERT = '.alert';
class Alert extends BSAlert {
constructor(element, data = {}) {
super(element, data);
this._init();
}
dispose() {
EventHandler.off(this._element, EVENT_CLOSE_BS);
EventHandler.off(this._element, EVENT_CLOSED_BS);
super.dispose();
}
// Getters
static get NAME() {
return NAME;
}
// Private
_init() {
this._bindCloseEvent();
this._bindClosedEvent();
}
_bindCloseEvent() {
EventHandler.on(this._element, EVENT_CLOSE_BS, () => {
EventHandler.trigger(this._element, EVENT_CLOSE);
});
}
_bindClosedEvent() {
EventHandler.on(this._element, EVENT_CLOSED_BS, () => {
EventHandler.trigger(this._element, EVENT_CLOSED);
});
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation - auto initialization
* ------------------------------------------------------------------------
*/
SelectorEngine.find(SELECTOR_ALERT).forEach((el) => {
let instance = Alert.getInstance(el);
if (!instance) {
instance = new Alert(el);
}
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .rating to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Alert.jQueryInterface;
$.fn[NAME].Constructor = Alert;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Alert.jQueryInterface;
};
}
});
export default Alert;

298
src/js/free/animate.js Normal file
View File

@ -0,0 +1,298 @@
import { getjQuery, typeCheckConfig } from '../mdb/util/index';
import Data from '../mdb/dom/data';
import Manipulator from '../mdb/dom/manipulator';
import SelectorEngine from '../mdb/dom/selector-engine';
import EventHandler from '../mdb/dom/event-handler';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'animate';
const DATA_KEY = 'mdb.animate';
const SELECTOR_EXPAND = '[data-toggle="animation"]';
const DefaultType = {
animation: 'string',
onStart: '(null|function)',
onEnd: '(null|function)',
onHide: '(null|function)',
onShow: '(null|function)',
animateonscroll: '(boolean|string)',
windowHeight: 'number',
offset: '(number|string)',
delay: '(number|string)',
duration: '(number|string)',
reverse: 'boolean',
interval: '(number|string)',
repeat: '(number|boolean)',
};
const Default = {
animation: 'fade',
onStart: null,
onEnd: null,
onHide: null,
onShow: null,
animateonscroll: false,
windowHeight: 0,
offset: 0,
delay: 0,
duration: 500,
reverse: false,
interval: 0,
repeat: false,
};
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Animate {
constructor(element, options) {
this._element = element;
this._animateElement = this._getAnimateElement();
this._isFirstScroll = true;
this._repeatAnimateOnScroll = true;
this._options = this._getConfig(options);
if (this._element) {
Data.setData(element, DATA_KEY, this);
}
}
// Getters
static get NAME() {
return NAME;
}
// Public
init() {
this._init();
}
dispose() {
Data.removeData(this._element, DATA_KEY);
this._element = null;
}
// Private
_init() {
if (this._options.animateonscroll) {
this._bindScrollEvents();
} else {
this._bindClickEvents();
this._bindResetAnimationAfterFinish();
}
}
_getAnimateElement() {
const targetId = Manipulator.getDataAttribute(this._element, 'target');
return targetId ? SelectorEngine.find(targetId)[0] : this._element;
}
_getConfig(config) {
const dataAttributes = Manipulator.getDataAttributes(this._animateElement);
config = {
...Default,
...dataAttributes,
...config,
};
typeCheckConfig(NAME, config, DefaultType);
return config;
}
_animateOnScroll() {
const elementOffsetTop = Manipulator.offset(this._animateElement).top;
const elementHeight = this._animateElement.offsetHeight;
const windowHeight = window.innerHeight;
const shouldBeVisible =
elementOffsetTop + this._options.offset <= windowHeight &&
elementOffsetTop + this._options.offset + elementHeight >= 0;
const isElementVisible = this._animateElement.style.visibility === 'visible';
switch (true) {
case shouldBeVisible && this._isFirstScroll:
this._isFirstScroll = false;
this._startAnimation();
break;
case !shouldBeVisible && this._isFirstScroll:
this._isFirstScroll = false;
this._hideAnimateElement();
break;
case shouldBeVisible && !isElementVisible && this._repeatAnimateOnScroll:
if (this._options.animateonscroll !== 'repeat') {
this._repeatAnimateOnScroll = false;
}
this._callback(this._options.onShow);
this._showAnimateElement();
this._startAnimation();
break;
case !shouldBeVisible && isElementVisible && this._repeatAnimateOnScroll:
this._hideAnimateElement();
this._clearAnimationClass();
this._callback(this._options.onHide);
break;
default:
break;
}
}
_addAnimatedClass() {
Manipulator.addClass(this._animateElement, 'animated');
Manipulator.addClass(this._animateElement, this._options.animation);
}
_clearAnimationClass() {
this._animateElement.classList.remove(this._options.animation, 'animated');
}
_startAnimation() {
this._callback(this._options.onStart);
this._addAnimatedClass();
if (this._options.repeat && !this._options.interval) {
this._setAnimationRepeat();
}
if (this._options.reverse) {
this._setAnimationReverse();
}
if (this._options.delay) {
this._setAnimationDelay();
}
if (this._options.duration) {
this._setAnimationDuration();
}
if (this._options.interval) {
this._setAnimationInterval();
}
}
_setAnimationReverse() {
Manipulator.style(this._animateElement, {
animationIterationCount: this._options.repeat === true ? 'infinite' : '2',
animationDirection: 'alternate',
});
}
_setAnimationDuration() {
Manipulator.style(this._animateElement, {
animationDuration: `${this._options.duration}ms`,
});
}
_setAnimationDelay() {
Manipulator.style(this._animateElement, {
animationDelay: `${this._options.delay}ms`,
});
}
_setAnimationRepeat() {
Manipulator.style(this._animateElement, {
animationIterationCount: this._options.repeat === true ? 'infinite' : this._options.repeat,
});
}
_setAnimationInterval() {
EventHandler.on(this._animateElement, 'animationend', () => {
this._callback(this._options.onEnd);
this._clearAnimationClass();
setTimeout(() => {
this._addAnimatedClass();
}, this._options.interval);
});
}
_hideAnimateElement() {
Manipulator.style(this._animateElement, { visibility: 'hidden' });
}
_showAnimateElement() {
Manipulator.style(this._animateElement, { visibility: 'visible' });
}
_bindResetAnimationAfterFinish() {
EventHandler.on(this._animateElement, 'animationend', () => {
this._callback(this._options.onEnd);
this._clearAnimationClass();
});
}
_bindScrollEvents() {
const scrollPositionOnPageLoad = window.scrollY;
EventHandler.on(window, 'scroll', () => {
if (scrollPositionOnPageLoad !== window.scrollY) {
this._animateOnScroll();
}
});
}
_bindClickEvents() {
EventHandler.on(this._element, 'mousedown', () => {
this._startAnimation();
});
}
_callback(fn) {
if (fn instanceof Function) {
fn();
}
}
// Static
static autoInit(instance) {
instance._init();
}
static jQueryInterface(options) {
const animate = new Animate(this[0], options);
animate.init();
}
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation - auto initialization
* ------------------------------------------------------------------------
*/
SelectorEngine.find(SELECTOR_EXPAND).forEach((el) => {
Animate.autoInit(new Animate(el));
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .animate to jQuery only if jQuery is present
*/
const $ = getjQuery();
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Animate.jQueryInterface;
$.fn[NAME].Constructor = Animate;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Animate.jQueryInterface;
};
}
export default Animate;

View File

@ -1,106 +0,0 @@
import { getjQuery, onDOMContentLoaded } from '../mdb/util/index';
import EventHandler from '../mdb/dom/event-handler';
import SelectorEngine from '../mdb/dom/selector-engine';
import BSCarousel from '../bootstrap/mdb-prefix/carousel';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'carousel';
const DATA_KEY = `mdb.${NAME}`;
const EVENT_KEY = `.${DATA_KEY}`;
const EVENT_SLIDE_BS = 'slide.bs.carousel';
const EVENT_SLID_BS = 'slid.bs.carousel';
const EVENT_SLIDE = `slide${EVENT_KEY}`;
const EVENT_SLID = `slid${EVENT_KEY}`;
const SELECTOR_DATA_RIDE = '[data-mdb-ride="carousel"]';
class Carousel extends BSCarousel {
constructor(element, data) {
super(element, data);
this._init();
}
dispose() {
EventHandler.off(this._element, EVENT_SLIDE_BS);
EventHandler.off(this._element, EVENT_SLID_BS);
super.dispose();
}
// Getters
static get NAME() {
return NAME;
}
// Private
_init() {
this._bindSlideEvent();
this._bindSlidEvent();
}
_bindSlideEvent() {
EventHandler.on(this._element, EVENT_SLIDE_BS, (e) => {
EventHandler.trigger(this._element, EVENT_SLIDE, {
relatedTarget: e.relatedTarget,
direction: e.direction,
from: e.from,
to: e.to,
});
});
}
_bindSlidEvent() {
EventHandler.on(this._element, EVENT_SLID_BS, (e) => {
EventHandler.trigger(this._element, EVENT_SLID, {
relatedTarget: e.relatedTarget,
direction: e.direction,
from: e.from,
to: e.to,
});
});
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation - auto initialization
* ------------------------------------------------------------------------
*/
SelectorEngine.find(SELECTOR_DATA_RIDE).forEach((el) => {
let instance = Carousel.getInstance(el);
if (!instance) {
instance = new Carousel(el);
}
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .rating to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Carousel.jQueryInterface;
$.fn[NAME].Constructor = Carousel;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Carousel.jQueryInterface;
};
}
});
export default Carousel;

View File

@ -1,244 +0,0 @@
import { getjQuery, typeCheckConfig, onDOMContentLoaded } from '../mdb/util/index';
import EventHandler from '../mdb/dom/event-handler';
import SelectorEngine from '../mdb/dom/selector-engine';
import Manipulator from '../mdb/dom/manipulator';
import BSDropdown from '../bootstrap/mdb-prefix/dropdown';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'dropdown';
const DATA_KEY = `mdb.${NAME}`;
const EVENT_KEY = `.${DATA_KEY}`;
const SELECTOR_EXPAND = '[data-mdb-toggle="dropdown"]';
const Default = {
offset: 0,
flip: true,
boundary: 'scrollParent',
reference: 'toggle',
display: 'dynamic',
popperConfig: null,
dropdownAnimation: 'on',
};
const DefaultType = {
offset: '(number|string|function)',
flip: 'boolean',
boundary: '(string|element)',
reference: '(string|element)',
display: 'string',
popperConfig: '(null|object)',
dropdownAnimation: 'string',
};
const EVENT_HIDE = 'hide.bs.dropdown';
const EVENT_HIDDEN = 'hidden.bs.dropdown';
const EVENT_SHOW = 'show.bs.dropdown';
const EVENT_SHOWN = 'shown.bs.dropdown';
const EVENT_HIDE_MDB = `hide${EVENT_KEY}`;
const EVENT_HIDDEN_MDB = `hidden${EVENT_KEY}`;
const EVENT_SHOW_MDB = `show${EVENT_KEY}`;
const EVENT_SHOWN_MDB = `shown${EVENT_KEY}`;
const ANIMATION_CLASS = 'animation';
const ANIMATION_SHOW_CLASS = 'fade-in';
const ANIMATION_HIDE_CLASS = 'fade-out';
class Dropdown extends BSDropdown {
constructor(element, data) {
super(element, data);
this._config = this._getConfig(data);
this._parent = Dropdown.getParentFromElement(this._element);
this._menuStyle = '';
this._popperPlacement = '';
//* prevents dropdown close issue when system animation is turned off
const isPrefersReducedMotionSet = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (this._config.dropdownAnimation === 'on' && !isPrefersReducedMotionSet) {
this._init();
}
}
dispose() {
EventHandler.off(this._element, EVENT_SHOW);
EventHandler.off(this._parent, EVENT_SHOWN);
EventHandler.off(this._parent, EVENT_HIDE);
EventHandler.off(this._parent, EVENT_HIDDEN);
super.dispose();
}
// Getters
static get NAME() {
return NAME;
}
// Private
_init() {
this._bindShowEvent();
this._bindShownEvent();
this._bindHideEvent();
this._bindHiddenEvent();
}
_getConfig(options) {
const config = {
...Default,
...Manipulator.getDataAttributes(this._element),
...options,
};
typeCheckConfig(NAME, config, DefaultType);
return config;
}
_getOffset() {
const offset = [];
if (Manipulator.getDataAttribute(this._element, 'offset')) {
Manipulator.getDataAttribute(this._element, 'offset')
.split(',')
.forEach((value) => {
offset.push(parseInt(value, 10));
});
}
return offset;
}
_getPopperConfig() {
const popperConfig = {
placement: this._getPlacement(),
modifiers: [
{
name: 'preventOverflow',
options: {
altBoundary: this._config.flip,
rootBoundary: this._config.boundary,
},
},
{
name: 'offset',
options: {
offset: this._getOffset(),
},
},
],
};
// Disable Popper if we have a static display
if (this._config.display === 'static') {
popperConfig.modifiers = [
{
name: 'applyStyles',
enabled: false,
},
];
}
return {
...popperConfig,
...this._config.popperConfig,
};
}
_bindShowEvent() {
EventHandler.on(this._element, EVENT_SHOW, (e) => {
EventHandler.trigger(this._element, EVENT_SHOW_MDB, { relatedTarget: e.relatedTarget });
this._dropdownAnimationStart('show');
});
}
_bindShownEvent() {
EventHandler.on(this._parent, EVENT_SHOWN, (e) => {
EventHandler.trigger(this._parent, EVENT_SHOWN_MDB, { relatedTarget: e.relatedTarget });
});
}
_bindHideEvent() {
EventHandler.on(this._parent, EVENT_HIDE, (e) => {
EventHandler.trigger(this._parent, EVENT_HIDE_MDB, { relatedTarget: e.relatedTarget });
this._menuStyle = this._menu.style.cssText;
this._popperPlacement = this._menu.getAttribute('data-popper-placement');
});
}
_bindHiddenEvent() {
EventHandler.on(this._parent, EVENT_HIDDEN, (e) => {
EventHandler.trigger(this._parent, EVENT_HIDDEN_MDB, { relatedTarget: e.relatedTarget });
if (this._config.display !== 'static' && this._menuStyle !== '') {
this._menu.style.cssText = this._menuStyle;
}
this._menu.setAttribute('data-popper-placement', this._popperPlacement);
this._dropdownAnimationStart('hide');
});
}
_dropdownAnimationStart(action) {
switch (action) {
case 'show':
this._menu.classList.add(ANIMATION_CLASS, ANIMATION_SHOW_CLASS);
this._menu.classList.remove(ANIMATION_HIDE_CLASS);
break;
default:
// hide
this._menu.classList.add(ANIMATION_CLASS, ANIMATION_HIDE_CLASS);
this._menu.classList.remove(ANIMATION_SHOW_CLASS);
break;
}
this._bindAnimationEnd();
}
_bindAnimationEnd() {
EventHandler.one(this._menu, 'animationend', () => {
this._menu.classList.remove(ANIMATION_CLASS, ANIMATION_HIDE_CLASS, ANIMATION_SHOW_CLASS);
});
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation - auto initialization
* ------------------------------------------------------------------------
*/
SelectorEngine.find(SELECTOR_EXPAND).forEach((el) => {
let instance = Dropdown.getInstance(el);
if (!instance) {
instance = new Dropdown(el);
}
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .rating to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Dropdown.jQueryInterface;
$.fn[NAME].Constructor = Dropdown;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Dropdown.jQueryInterface;
};
}
});
export default Dropdown;

View File

@ -1,9 +1,8 @@
import { element, getjQuery, onDOMContentLoaded } from '../mdb/util/index';
import { element } from '../mdb/util/index';
import Data from '../mdb/dom/data';
import EventHandler from '../mdb/dom/event-handler';
import EventHandler from '../bootstrap/src/dom/event-handler';
import Manipulator from '../mdb/dom/manipulator';
import SelectorEngine from '../mdb/dom/selector-engine';
import 'detect-autofill';
/**
* ------------------------------------------------------------------------
@ -14,18 +13,7 @@ import 'detect-autofill';
const NAME = 'input';
const DATA_KEY = 'mdb.input';
const CLASSNAME_WRAPPER = 'form-outline';
const CLASSNAME_ACTIVE = 'active';
const CLASSNAME_NOTCH = 'form-notch';
const CLASSNAME_NOTCH_LEADING = 'form-notch-leading';
const CLASSNAME_NOTCH_MIDDLE = 'form-notch-middle';
const CLASSNAME_NOTCH_TRAILING = 'form-notch-trailing';
const CLASSNAME_PLACEHOLDER_ACTIVE = 'placeholder-active';
const SELECTOR_OUTLINE_INPUT = `.${CLASSNAME_WRAPPER} input`;
const SELECTOR_OUTLINE_TEXTAREA = `.${CLASSNAME_WRAPPER} textarea`;
const SELECTOR_NOTCH = `.${CLASSNAME_NOTCH}`;
const SELECTOR_NOTCH_LEADING = `.${CLASSNAME_NOTCH_LEADING}`;
const SELECTOR_NOTCH_MIDDLE = `.${CLASSNAME_NOTCH_MIDDLE}`;
const OUTLINE_INPUT = `.${CLASSNAME_WRAPPER} input`;
/**
* ------------------------------------------------------------------------
@ -36,17 +24,11 @@ const SELECTOR_NOTCH_MIDDLE = `.${CLASSNAME_NOTCH_MIDDLE}`;
class Input {
constructor(element) {
this._element = element;
this._label = null;
this._labelWidth = 0;
this._labelMarginLeft = 0;
this._notchLeading = null;
this._notchMiddle = null;
this._notchTrailing = null;
this._initiated = false;
if (this._element) {
Data.setData(element, DATA_KEY, this);
this.init();
}
}
@ -55,290 +37,79 @@ class Input {
return NAME;
}
get input() {
const inputElement =
SelectorEngine.findOne('input', this._element) ||
SelectorEngine.findOne('textarea', this._element);
return inputElement;
}
// Public
init() {
if (this._initiated) {
return;
}
this._getLabelData();
this._calculateLabelWidth();
this._applyDivs();
this._applyNotch();
this._activate();
this._initiated = true;
}
update() {
this._getLabelData();
this._getNotchData();
this._applyNotch();
this._activate();
}
forceActive() {
Manipulator.addClass(this.input, CLASSNAME_ACTIVE);
}
forceInactive() {
Manipulator.removeClass(this.input, CLASSNAME_ACTIVE);
this._applyNotchWidth();
this._applyActiveClass();
}
dispose() {
this._removeBorder();
Data.removeData(this._element, DATA_KEY);
this._element = null;
}
// Private
_getLabelData() {
this._label = SelectorEngine.findOne('label', this._element);
if (this._label === null) {
this._showPlaceholder();
} else {
this._getLabelWidth();
this._getLabelPositionInInputGroup();
}
}
_showPlaceholder() {
Manipulator.addClass(this.input, CLASSNAME_PLACEHOLDER_ACTIVE);
}
_getNotchData() {
this._notchMiddle = SelectorEngine.findOne(SELECTOR_NOTCH_MIDDLE, this._element);
this._notchLeading = SelectorEngine.findOne(SELECTOR_NOTCH_LEADING, this._element);
}
_getLabelWidth() {
this._labelWidth = this._label.clientWidth * 0.8 + 8;
}
_getLabelPositionInInputGroup() {
this._labelMarginLeft = 0;
if (!this._element.classList.contains('input-group')) return;
const input = this.input;
const prefix = SelectorEngine.prev(input, '.input-group-text')[0];
if (prefix === undefined) {
this._labelMarginLeft = 0;
} else {
this._labelMarginLeft = prefix.offsetWidth - 1;
}
_calculateLabelWidth() {
const label = SelectorEngine.findOne('label.form-label', this._element);
this._labelWidth = label.clientWidth * 0.8 + 8;
}
_applyDivs() {
const notchWrapper = element('div');
Manipulator.addClass(notchWrapper, CLASSNAME_NOTCH);
this._notchLeading = element('div');
Manipulator.addClass(this._notchLeading, CLASSNAME_NOTCH_LEADING);
Manipulator.addClass(notchWrapper, 'form-notch');
const notchLeading = element('div');
Manipulator.addClass(notchLeading, 'form-notch-leading');
this._notchMiddle = element('div');
Manipulator.addClass(this._notchMiddle, CLASSNAME_NOTCH_MIDDLE);
this._notchTrailing = element('div');
Manipulator.addClass(this._notchTrailing, CLASSNAME_NOTCH_TRAILING);
Manipulator.addClass(this._notchMiddle, 'form-notch-middle');
const notchTrailing = element('div');
Manipulator.addClass(notchTrailing, 'form-notch-trailing');
notchWrapper.append(this._notchLeading);
notchWrapper.append(notchLeading);
notchWrapper.append(this._notchMiddle);
notchWrapper.append(this._notchTrailing);
notchWrapper.append(notchTrailing);
this._element.append(notchWrapper);
}
_applyNotch() {
_applyNotchWidth() {
this._notchMiddle.style.width = `${this._labelWidth}px`;
this._notchLeading.style.width = `${this._labelMarginLeft + 9}px`;
if (this._label === null) return;
this._label.style.marginLeft = `${this._labelMarginLeft}px`;
}
_removeBorder() {
const border = SelectorEngine.findOne(SELECTOR_NOTCH, this._element);
if (border) border.remove();
}
_activate(event) {
this._getElements(event);
const input = event ? event.target : this.input;
_applyActiveClass(event) {
const input = event ? event.target : SelectorEngine.findOne('input', this._element);
if (input.value !== '') {
Manipulator.addClass(input, CLASSNAME_ACTIVE);
Manipulator.addClass(input, 'active');
}
}
_getElements(event) {
if (event) {
this._element = event.target.parentNode;
this._label = SelectorEngine.findOne('label', this._element);
}
if (event && this._label) {
const prevLabelWidth = this._labelWidth;
this._getLabelData();
if (prevLabelWidth !== this._labelWidth) {
this._notchMiddle = SelectorEngine.findOne('.form-notch-middle', event.target.parentNode);
this._notchLeading = SelectorEngine.findOne(
SELECTOR_NOTCH_LEADING,
event.target.parentNode
);
this._applyNotch();
}
}
}
_deactivate(event) {
const input = event ? event.target : this.input;
_removeActiveClass(event) {
const input = event ? event.target : SelectorEngine.findOne('input', this._element);
if (input.value === '') {
input.classList.remove(CLASSNAME_ACTIVE);
input.classList.remove('active');
}
}
static activate(instance) {
static applyActiveClass(instance) {
return function (event) {
instance._activate(event);
instance._applyActiveClass(event);
};
}
static deactivate(instance) {
static removeActiveClass(instance) {
return function (event) {
instance._deactivate(event);
instance._removeActiveClass(event);
};
}
static jQueryInterface(config, options) {
return this.each(function () {
let data = Data.getData(this, DATA_KEY);
const _config = typeof config === 'object' && config;
if (!data && /dispose/.test(config)) {
return;
}
if (!data) {
data = new Input(this, _config);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
data[config](options);
}
});
}
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
}
EventHandler.on(document, 'focus', SELECTOR_OUTLINE_INPUT, Input.activate(new Input()));
EventHandler.on(document, 'input', SELECTOR_OUTLINE_INPUT, Input.activate(new Input()));
EventHandler.on(document, 'blur', SELECTOR_OUTLINE_INPUT, Input.deactivate(new Input()));
EventHandler.on(document, 'focus', SELECTOR_OUTLINE_TEXTAREA, Input.activate(new Input()));
EventHandler.on(document, 'input', SELECTOR_OUTLINE_TEXTAREA, Input.activate(new Input()));
EventHandler.on(document, 'blur', SELECTOR_OUTLINE_TEXTAREA, Input.deactivate(new Input()));
EventHandler.on(window, 'shown.bs.modal', (e) => {
SelectorEngine.find(SELECTOR_OUTLINE_INPUT, e.target).forEach((element) => {
const instance = Input.getInstance(element.parentNode);
if (!instance) {
return;
}
instance.update();
});
SelectorEngine.find(SELECTOR_OUTLINE_TEXTAREA, e.target).forEach((element) => {
const instance = Input.getInstance(element.parentNode);
if (!instance) {
return;
}
instance.update();
});
});
EventHandler.on(window, 'shown.bs.dropdown', (e) => {
SelectorEngine.find(SELECTOR_OUTLINE_INPUT, e.target).forEach((element) => {
const instance = Input.getInstance(element.parentNode);
if (!instance) {
return;
}
instance.update();
});
SelectorEngine.find(SELECTOR_OUTLINE_TEXTAREA, e.target).forEach((element) => {
const instance = Input.getInstance(element.parentNode);
if (!instance) {
return;
}
instance.update();
});
});
EventHandler.on(window, 'shown.bs.tab', (e) => {
const targetId = e.target.href.split('#')[1];
const target = SelectorEngine.findOne(`#${targetId}`);
SelectorEngine.find(SELECTOR_OUTLINE_INPUT, target).forEach((element) => {
const instance = Input.getInstance(element.parentNode);
if (!instance) {
return;
}
instance.update();
});
SelectorEngine.find(SELECTOR_OUTLINE_TEXTAREA, target).forEach((element) => {
const instance = Input.getInstance(element.parentNode);
if (!instance) {
return;
}
instance.update();
});
});
EventHandler.on(document, 'focus', OUTLINE_INPUT, Input.applyActiveClass(new Input()));
EventHandler.on(document, 'input', OUTLINE_INPUT, Input.applyActiveClass(new Input()));
EventHandler.on(document, 'blur', OUTLINE_INPUT, Input.removeActiveClass(new Input()));
// auto-init
SelectorEngine.find(`.${CLASSNAME_WRAPPER}`).map((element) => new Input(element));
// form reset handler
EventHandler.on(window, 'reset', (e) => {
SelectorEngine.find(SELECTOR_OUTLINE_INPUT, e.target).forEach((element) => {
const instance = Input.getInstance(element.parentNode);
if (!instance) {
return;
}
instance.forceInactive();
});
SelectorEngine.find(SELECTOR_OUTLINE_TEXTAREA, e.target).forEach((element) => {
const instance = Input.getInstance(element.parentNode);
if (!instance) {
return;
}
instance.forceInactive();
});
});
// auto-fill
EventHandler.on(window, 'onautocomplete', (e) => {
const instance = Input.getInstance(e.target.parentNode);
if (!instance || !e.cancelable) {
return;
}
instance.forceActive();
});
onDOMContentLoaded(() => {
const $ = getjQuery();
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Input.jQueryInterface;
$.fn[NAME].Constructor = Input;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Input.jQueryInterface;
};
}
SelectorEngine.find(`.${CLASSNAME_WRAPPER}`).forEach((input) => {
new Input(input).init();
});
export default Input;

View File

@ -1,129 +0,0 @@
import { getjQuery, getSelectorFromElement, onDOMContentLoaded } from '../mdb/util/index';
import EventHandler from '../mdb/dom/event-handler';
import SelectorEngine from '../mdb/dom/selector-engine';
import BSModal from '../bootstrap/mdb-prefix/modal';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'modal';
const DATA_KEY = `mdb.${NAME}`;
const EVENT_KEY = `.${DATA_KEY}`;
const EVENT_HIDE_BS = 'hide.bs.modal';
const EVENT_HIDE_PREVENTED_BS = 'hidePrevented.bs.modal';
const EVENT_HIDDEN_BS = 'hidden.bs.modal';
const EVENT_SHOW_BS = 'show.bs.modal';
const EVENT_SHOWN_BS = 'shown.bs.modal';
const EVENT_HIDE = `hide${EVENT_KEY}`;
const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY}`;
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
const EVENT_SHOW = `show${EVENT_KEY}`;
const EVENT_SHOWN = `shown${EVENT_KEY}`;
const SELECTOR_DATA_TOGGLE = '[data-mdb-toggle="modal"]';
class Modal extends BSModal {
constructor(element, data) {
super(element, data);
this._init();
}
dispose() {
EventHandler.off(this._element, EVENT_SHOW_BS);
EventHandler.off(this._element, EVENT_SHOWN_BS);
EventHandler.off(this._element, EVENT_HIDE_BS);
EventHandler.off(this._element, EVENT_HIDDEN_BS);
EventHandler.off(this._element, EVENT_HIDE_PREVENTED_BS);
super.dispose();
}
// Getters
static get NAME() {
return NAME;
}
// Private
_init() {
this._bindShowEvent();
this._bindShownEvent();
this._bindHideEvent();
this._bindHiddenEvent();
this._bindHidePreventedEvent();
}
_bindShowEvent() {
EventHandler.on(this._element, EVENT_SHOW_BS, (e) => {
EventHandler.trigger(this._element, EVENT_SHOW, { relatedTarget: e.relatedTarget });
});
}
_bindShownEvent() {
EventHandler.on(this._element, EVENT_SHOWN_BS, (e) => {
EventHandler.trigger(this._element, EVENT_SHOWN, { relatedTarget: e.relatedTarget });
});
}
_bindHideEvent() {
EventHandler.on(this._element, EVENT_HIDE_BS, () => {
EventHandler.trigger(this._element, EVENT_HIDE);
});
}
_bindHiddenEvent() {
EventHandler.on(this._element, EVENT_HIDDEN_BS, () => {
EventHandler.trigger(this._element, EVENT_HIDDEN);
});
}
_bindHidePreventedEvent() {
EventHandler.on(this._element, EVENT_HIDE_PREVENTED_BS, () => {
EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
});
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation - auto initialization
* ------------------------------------------------------------------------
*/
SelectorEngine.find(SELECTOR_DATA_TOGGLE).forEach((el) => {
const selector = getSelectorFromElement(el);
const selectorElement = SelectorEngine.findOne(selector);
let instance = Modal.getInstance(selectorElement);
if (!instance) {
instance = new Modal(selectorElement);
}
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .modal to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Modal.jQueryInterface;
$.fn[NAME].Constructor = Modal;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Modal.jQueryInterface;
};
}
});
export default Modal;

View File

@ -1,126 +0,0 @@
import { getjQuery, onDOMContentLoaded } from '../mdb/util/index';
import EventHandler from '../mdb/dom/event-handler';
import SelectorEngine from '../mdb/dom/selector-engine';
import BSPopover from '../bootstrap/mdb-prefix/popover';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'popover';
const DATA_KEY = `mdb.${NAME}`;
const EVENT_KEY = `.${DATA_KEY}`;
const EVENT_SHOW_BS = 'show.bs.popover';
const EVENT_SHOWN_BS = 'shown.bs.popover';
const EVENT_HIDE_BS = 'hide.bs.popover';
const EVENT_HIDDEN_BS = 'hidden.bs.popover';
const EVENT_INSERTED_BS = 'inserted.bs.popover';
const EVENT_SHOW = `show${EVENT_KEY}`;
const EVENT_SHOWN = `shown${EVENT_KEY}`;
const EVENT_HIDE = `hide${EVENT_KEY}`;
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
const EVENT_INSERTED = `inserted${EVENT_KEY}`;
const SELECTOR_DATA_TOGGLE = '[data-mdb-toggle="popover"]';
class Popover extends BSPopover {
constructor(element, data) {
super(element, data);
this._init();
}
dispose() {
EventHandler.off(this.element, EVENT_SHOW_BS);
EventHandler.off(this.element, EVENT_SHOWN_BS);
EventHandler.off(this.element, EVENT_HIDE_BS);
EventHandler.off(this.element, EVENT_HIDDEN_BS);
EventHandler.off(this.element, EVENT_INSERTED_BS);
super.dispose();
}
// Getters
static get NAME() {
return NAME;
}
// Private
_init() {
this._bindShowEvent();
this._bindShownEvent();
this._bindHideEvent();
this._bindHiddenEvent();
this._bindInsertedEvent();
}
_bindShowEvent() {
EventHandler.on(this.element, EVENT_SHOW_BS, () => {
EventHandler.trigger(this.element, EVENT_SHOW);
});
}
_bindShownEvent() {
EventHandler.on(this.element, EVENT_SHOWN_BS, () => {
EventHandler.trigger(this.element, EVENT_SHOWN);
});
}
_bindHideEvent() {
EventHandler.on(this.element, EVENT_HIDE_BS, () => {
EventHandler.trigger(this.element, EVENT_HIDE);
});
}
_bindHiddenEvent() {
EventHandler.on(this.element, EVENT_HIDDEN_BS, () => {
EventHandler.trigger(this.element, EVENT_HIDDEN);
});
}
_bindInsertedEvent() {
EventHandler.on(this.element, EVENT_INSERTED_BS, () => {
EventHandler.trigger(this.element, EVENT_INSERTED);
});
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation - auto initialization
* ------------------------------------------------------------------------
*/
SelectorEngine.find(SELECTOR_DATA_TOGGLE).forEach((el) => {
let instance = Popover.getInstance(el);
if (!instance) {
instance = new Popover(el);
}
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .rating to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Popover.jQueryInterface;
$.fn[NAME].Constructor = Popover;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Popover.jQueryInterface;
};
}
});
export default Popover;

View File

@ -1,159 +0,0 @@
import { getjQuery, element, onDOMContentLoaded } from '../mdb/util/index';
import Data from '../mdb/dom/data';
import EventHandler from '../mdb/dom/event-handler';
import Manipulator from '../mdb/dom/manipulator';
import SelectorEngine from '../mdb/dom/selector-engine';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'range';
const DATA_KEY = 'mdb.range';
const CLASSNAME_THUMB = 'thumb';
const CLASSNAME_WRAPPER = 'range';
const CLASSNAME_ACTIVE = 'thumb-active';
const CLASSNAME_THUMB_VALUE = 'thumb-value';
const SELECTOR_THUMB_VALUE = `.${CLASSNAME_THUMB_VALUE}`;
const SELECTOR_WRAPPER = `.${CLASSNAME_WRAPPER}`;
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Range {
constructor(element) {
this._element = element;
this._initiated = false;
if (this._element) {
Data.setData(element, DATA_KEY, this);
this.init();
}
}
// Getters
static get NAME() {
return NAME;
}
get rangeInput() {
return SelectorEngine.findOne('input[type=range]', this._element);
}
// Public
init() {
if (this._initiated) {
return;
}
this._addThumb();
this._updateValue();
this._thumbPositionUpdate();
this._handleEvents();
this._initiated = true;
}
dispose() {
this._disposeEvents();
Data.removeData(this._element, DATA_KEY);
this._element = null;
}
// Private
_addThumb() {
const RANGE_THUMB = element('span');
Manipulator.addClass(RANGE_THUMB, CLASSNAME_THUMB);
RANGE_THUMB.innerHTML = '<span class="thumb-value"></span>';
this._element.append(RANGE_THUMB);
}
_updateValue() {
const thumbValue = SelectorEngine.findOne(SELECTOR_THUMB_VALUE, this._element);
thumbValue.textContent = this.rangeInput.value;
this.rangeInput.oninput = () => (thumbValue.textContent = this.rangeInput.value);
}
_handleEvents() {
EventHandler.on(this.rangeInput, 'mousedown', () => this._showThumb());
EventHandler.on(this.rangeInput, 'mouseup', () => this._hideThumb());
EventHandler.on(this.rangeInput, 'touchstart', () => this._showThumb());
EventHandler.on(this.rangeInput, 'touchend', () => this._hideThumb());
EventHandler.on(this.rangeInput, 'input', () => this._thumbPositionUpdate());
}
_disposeEvents() {
EventHandler.off(this.rangeInput, 'mousedown', this._showThumb);
EventHandler.off(this.rangeInput, 'mouseup', this._hideThumb);
EventHandler.off(this.rangeInput, 'touchstart', this._showThumb);
EventHandler.off(this.rangeInput, 'touchend', this._hideThumb);
EventHandler.off(this.rangeInput, 'input', this._thumbPositionUpdate);
}
_showThumb() {
Manipulator.addClass(this._element.lastElementChild, CLASSNAME_ACTIVE);
}
_hideThumb() {
Manipulator.removeClass(this._element.lastElementChild, CLASSNAME_ACTIVE);
}
_thumbPositionUpdate() {
const rangeInput = this.rangeInput;
const inputValue = rangeInput.value;
const minValue = rangeInput.min ? rangeInput.min : 0;
const maxValue = rangeInput.max ? rangeInput.max : 100;
const thumb = this._element.lastElementChild;
const newValue = Number(((inputValue - minValue) * 100) / (maxValue - minValue));
thumb.firstElementChild.textContent = inputValue;
Manipulator.style(thumb, { left: `calc(${newValue}% + (${8 - newValue * 0.15}px))` });
}
// Static
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
static jQueryInterface(config, options) {
return this.each(function () {
let data = Data.getData(this, DATA_KEY);
const _config = typeof config === 'object' && config;
if (!data && /dispose/.test(config)) {
return;
}
if (!data) {
data = new Range(this, _config);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
data[config](options);
}
});
}
}
// auto-init
SelectorEngine.find(SELECTOR_WRAPPER).map((element) => new Range(element));
// jQuery init
onDOMContentLoaded(() => {
const $ = getjQuery();
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Range.jQueryInterface;
$.fn[NAME].Constructor = Range;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Range.jQueryInterface;
};
}
});
export default Range;

View File

@ -1,6 +1,6 @@
import { element, getjQuery, typeCheckConfig, onDOMContentLoaded } from '../mdb/util/index';
import { element, getjQuery, typeCheckConfig } from '../mdb/util/index';
import Data from '../mdb/dom/data';
import EventHandler from '../mdb/dom/event-handler';
import EventHandler from '../bootstrap/src/dom/event-handler';
import Manipulator from '../mdb/dom/manipulator';
import SelectorEngine from '../mdb/dom/selector-engine';
@ -31,24 +31,24 @@ const BOOTSTRAP_COLORS = [
'dark',
];
// Sets value when run opacity transition
// Sets walue when run opacity transition
// Hide element after 50% (0.5) time of animation and finish on 100%
const TRANSITION_BREAK_OPACITY = 0.5;
const Default = {
rippleCentered: false,
rippleColor: '',
rippleDuration: '500ms',
rippleRadius: 0,
rippleUnbound: false,
centered: false,
color: '',
duration: '500ms',
radius: 0,
unbound: false,
};
const DefaultType = {
rippleCentered: 'boolean',
rippleColor: 'string',
rippleDuration: 'string',
rippleRadius: 'number',
rippleUnbound: 'boolean',
centered: 'boolean',
color: 'string',
duration: 'string',
radius: 'number',
unbound: 'boolean',
};
/**
@ -66,8 +66,6 @@ class Ripple {
Manipulator.addClass(this._element, CLASSNAME_RIPPLE);
}
this._clickHandler = this._createRipple.bind(this);
this.init();
}
@ -85,9 +83,9 @@ class Ripple {
dispose() {
Data.removeData(this._element, DATA_KEY);
EventHandler.off(this._element, 'click', this._clickHandler);
this._element = null;
this._options = null;
EventHandler.off(this._element, 'click', '');
}
// Private
@ -105,24 +103,24 @@ class Ripple {
}
_addClickEvent(target) {
EventHandler.on(target, 'mousedown', this._clickHandler);
EventHandler.on(target, 'click', '', (event) => {
this._createRipple(event);
});
}
_createRipple(event) {
const { layerX, layerY } = event;
const offsetX = layerX;
const offsetY = layerY;
const { offsetX, offsetY } = event;
const height = this._element.offsetHeight;
const width = this._element.offsetWidth;
const duration = this._durationToMsNumber(this._options.rippleDuration);
const duration = this._durationToMsNumber(this._options.duration);
const diameterOptions = {
offsetX: this._options.rippleCentered ? height / 2 : offsetX,
offsetY: this._options.rippleCentered ? width / 2 : offsetY,
offsetX: this._options.centered ? height / 2 : offsetX,
offsetY: this._options.centered ? width / 2 : offsetY,
height,
width,
};
const diameter = this._getDiameter(diameterOptions);
const radiusValue = this._options.rippleRadius || diameter / 2;
const radiusValue = this._options.radius || diameter / 2;
const opacity = {
delay: duration * TRANSITION_BREAK_OPACITY,
@ -130,14 +128,10 @@ class Ripple {
};
const styles = {
left: this._options.rippleCentered
? `${width / 2 - radiusValue}px`
: `${offsetX - radiusValue}px`,
top: this._options.rippleCentered
? `${height / 2 - radiusValue}px`
: `${offsetY - radiusValue}px`,
height: `${this._options.rippleRadius * 2 || diameter}px`,
width: `${this._options.rippleRadius * 2 || diameter}px`,
left: this._options.centered ? `${width / 2 - radiusValue}px` : `${offsetX - radiusValue}px`,
top: this._options.centered ? `${height / 2 - radiusValue}px` : `${offsetY - radiusValue}px`,
height: `${this._options.radius * 2 || diameter}px`,
width: `${this._options.radius * 2 || diameter}px`,
transitionDelay: `0s, ${opacity.delay}ms`,
transitionDuration: `${duration}ms, ${opacity.duration}ms`,
};
@ -145,13 +139,13 @@ class Ripple {
const rippleHTML = element('div');
this._createHTMLRipple({ wrapper: this._element, ripple: rippleHTML, styles });
this._removeHTMLRipple({ ripple: rippleHTML, duration });
this._removeHTMLRipple({ wrapper: this._element, ripple: rippleHTML, duration });
}
_createHTMLRipple({ wrapper, ripple, styles }) {
Object.keys(styles).forEach((property) => (ripple.style[property] = styles[property]));
ripple.classList.add(CLASSNAME_RIPPLE_WAVE);
if (this._options.rippleColor !== '') {
if (this._options.color !== '') {
this._removeOldColorClasses(wrapper);
this._addColor(ripple, wrapper);
}
@ -160,11 +154,9 @@ class Ripple {
this._appendRipple(ripple, wrapper);
}
_removeHTMLRipple({ ripple, duration }) {
_removeHTMLRipple({ wrapper, ripple, duration }) {
setTimeout(() => {
if (ripple) {
ripple.remove();
}
wrapper.removeChild(ripple);
}, duration);
}
@ -221,7 +213,7 @@ class Ripple {
}
_appendRipple(target, parent) {
const FIX_ADD_RIPPLE_EFFECT = 50; // delay for active animations
const FIX_ADD_RIPPLE_EFFECT = 50; // We need delay for active animations
parent.appendChild(target);
setTimeout(() => {
Manipulator.addClass(target, 'active');
@ -229,7 +221,7 @@ class Ripple {
}
_toggleUnbound(target) {
if (this._options.rippleUnbound === true) {
if (this._options.unbound === true) {
Manipulator.addClass(target, CLASSNAME_UNBOUND);
} else {
target.classList.remove(CLASSNAME_UNBOUND);
@ -238,16 +230,13 @@ class Ripple {
_addColor(target, parent) {
const IS_BOOTSTRAP_COLOR = BOOTSTRAP_COLORS.find(
(color) => color === this._options.rippleColor.toLowerCase()
(color) => color === this._options.color.toLowerCase()
);
if (IS_BOOTSTRAP_COLOR) {
Manipulator.addClass(
parent,
`${CLASSNAME_RIPPLE}-${this._options.rippleColor.toLowerCase()}`
);
Manipulator.addClass(parent, `${CLASSNAME_RIPPLE}-${this._options.color.toLowerCase()}`);
} else {
const rgbValue = this._colorToRGB(this._options.rippleColor).join(',');
const rgbValue = this._colorToRGB(this._options.color).join(',');
const gradientImage = GRADIENT.split('{{color}}').join(`${rgbValue}`);
target.style.backgroundImage = `radial-gradient(circle, ${gradientImage})`;
}
@ -314,12 +303,19 @@ class Ripple {
}
// Static
static autoInitial(instance) {
return function (event) {
instance._autoInit(event);
};
}
static staticMethod(instance) {
return function (event) {
instance._method(event);
};
}
static jQueryInterface(options) {
return this.each(function () {
const data = Data.getData(this, DATA_KEY);
@ -342,8 +338,8 @@ class Ripple {
* ------------------------------------------------------------------------
*/
SELECTOR_COMPONENT.forEach((selector) => {
EventHandler.one(document, 'mousedown', selector, Ripple.autoInitial(new Ripple()));
SELECTOR_COMPONENT.forEach((slector) => {
EventHandler.one(document, 'click', slector, Ripple.autoInitial(new Ripple()));
});
/**
@ -353,18 +349,16 @@ SELECTOR_COMPONENT.forEach((selector) => {
* add .ripple to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
const $ = getjQuery();
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Ripple.jQueryInterface;
$.fn[NAME].Constructor = Ripple;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Ripple.jQueryInterface;
};
}
});
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Ripple.jQueryInterface;
$.fn[NAME].Constructor = Ripple;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Ripple.jQueryInterface;
};
}
export default Ripple;

View File

@ -1,96 +0,0 @@
import { getjQuery, onDOMContentLoaded } from '../mdb/util/index';
import EventHandler from '../mdb/dom/event-handler';
import SelectorEngine from '../mdb/dom/selector-engine';
import Manipulator from '../mdb/dom/manipulator';
import BSScrollSpy from '../bootstrap/mdb-prefix/scrollspy';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'scrollspy';
const DATA_KEY = `mdb.${NAME}`;
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
const EVENT_ACTIVATE_BS = 'activate.bs.scrollspy';
const EVENT_ACTIVATE = `activate${EVENT_KEY}`;
const SELECTOR_DATA_SPY = '[data-mdb-spy="scroll"]';
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
class ScrollSpy extends BSScrollSpy {
constructor(element, data) {
super(element, data);
this._scrollElement = element.tagName === 'BODY' ? window : element;
this._init();
}
dispose() {
EventHandler.off(this._scrollElement, EVENT_ACTIVATE_BS);
this._scrollElement = null;
super.dispose();
}
// Getters
static get NAME() {
return NAME;
}
// Private
_init() {
this._bindActivateEvent();
}
_bindActivateEvent() {
EventHandler.on(this._scrollElement, EVENT_ACTIVATE_BS, (e) => {
EventHandler.trigger(this._scrollElement, EVENT_ACTIVATE, {
relatedTarget: e.relatedTarget,
});
});
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation - auto initialization
* ------------------------------------------------------------------------
*/
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
SelectorEngine.find(SELECTOR_DATA_SPY).forEach((el) => {
let instance = ScrollSpy.getInstance(el);
if (!instance) {
instance = new ScrollSpy(el, Manipulator.getDataAttributes(el));
}
});
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .rating to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = ScrollSpy.jQueryInterface;
$.fn[NAME].Constructor = ScrollSpy;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return ScrollSpy.jQueryInterface;
};
}
});
export default ScrollSpy;

View File

@ -1,198 +0,0 @@
import { getjQuery, getElementFromSelector, onDOMContentLoaded } from '../mdb/util/index';
import EventHandler from '../mdb/dom/event-handler';
import SelectorEngine from '../mdb/dom/selector-engine';
import BSTab from '../bootstrap/mdb-prefix/tab';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'tab';
const DATA_KEY = `mdb.${NAME}`;
const EVENT_KEY = `.${DATA_KEY}`;
const EVENT_SHOW_BS = 'show.bs.tab';
const EVENT_SHOWN_BS = 'shown.bs.tab';
const EVENT_HIDE_BS = 'hide.bs.tab';
const EVENT_HIDDEN_BS = 'hidden.bs.tab';
const EVENT_SHOW = `show${EVENT_KEY}`;
const EVENT_SHOWN = `shown${EVENT_KEY}`;
const EVENT_HIDE = `hide${EVENT_KEY}`;
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
const CLASS_NAME_ACTIVE = 'active';
const CLASS_NAME_DISABLED = 'disabled';
const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
const SELECTOR_ACTIVE = '.active';
const SELECTOR_ACTIVE_UL = ':scope > li > .active';
const SELECTOR_DATA_TOGGLE =
'[data-mdb-toggle="tab"], [data-mdb-toggle="pill"], [data-mdb-toggle="list"]';
class Tab extends BSTab {
constructor(element) {
super(element);
this._previous = null;
this._init();
}
dispose() {
EventHandler.off(this._element, EVENT_SHOW_BS);
EventHandler.off(this._element, EVENT_SHOWN_BS);
super.dispose();
}
// Getters
static get NAME() {
return NAME;
}
// Override
show() {
if (
(this._element.parentNode &&
this._element.parentNode.nodeType === Node.ELEMENT_NODE &&
this._element.classList.contains(CLASS_NAME_ACTIVE)) ||
this._element.classList.contains(CLASS_NAME_DISABLED)
) {
return;
}
const target = getElementFromSelector(this._element);
const listElement = this._element.closest(SELECTOR_NAV_LIST_GROUP);
if (listElement) {
const itemSelector =
listElement.nodeName === 'UL' || listElement.nodeName === 'OL'
? SELECTOR_ACTIVE_UL
: SELECTOR_ACTIVE;
this._previous = SelectorEngine.find(itemSelector, listElement);
this._previous = this._previous[this._previous.length - 1];
}
let hideEvent = null;
let hideEventMdb = null;
if (this._previous) {
hideEvent = EventHandler.trigger(this._previous, EVENT_HIDE_BS, {
relatedTarget: this._element,
});
hideEventMdb = EventHandler.trigger(this._previous, EVENT_HIDE, {
relatedTarget: this._element,
});
}
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW_BS, {
relatedTarget: this._previous,
});
if (
showEvent.defaultPrevented ||
(hideEvent !== null && hideEvent.defaultPrevented) ||
(hideEventMdb !== null && hideEventMdb.defaultPrevented)
) {
return;
}
this._activate(this._element, listElement);
const complete = () => {
EventHandler.trigger(this._previous, EVENT_HIDDEN_BS, {
relatedTarget: this._element,
});
EventHandler.trigger(this._previous, EVENT_HIDDEN, {
relatedTarget: this._element,
});
EventHandler.trigger(this._element, EVENT_SHOWN_BS, {
relatedTarget: this._previous,
});
};
if (target) {
this._activate(target, target.parentNode, complete);
} else {
complete();
}
}
// Private
_init() {
this._bindShowEvent();
this._bindShownEvent();
this._bindHideEvent();
this._bindHiddenEvent();
}
_bindShowEvent() {
EventHandler.on(this._element, EVENT_SHOW_BS, (e) => {
EventHandler.trigger(this._element, EVENT_SHOW, {
relatedTarget: e.relatedTarget,
});
});
}
_bindShownEvent() {
EventHandler.on(this._element, EVENT_SHOWN_BS, (e) => {
EventHandler.trigger(this._element, EVENT_SHOWN, {
relatedTarget: e.relatedTarget,
});
});
}
_bindHideEvent() {
EventHandler.on(this._previous, EVENT_HIDE_BS, () => {
EventHandler.trigger(this._previous, EVENT_HIDE);
});
}
_bindHiddenEvent() {
EventHandler.on(this._previous, EVENT_HIDDEN_BS, () => {
EventHandler.trigger(this._previous, EVENT_HIDDEN);
});
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation - auto initialization
* ------------------------------------------------------------------------
*/
SelectorEngine.find(SELECTOR_DATA_TOGGLE).forEach((el) => {
let instance = Tab.getInstance(el);
if (!instance) {
instance = new Tab(el);
}
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .rating to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Tab.jQueryInterface;
$.fn[NAME].Constructor = Tab;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Tab.jQueryInterface;
};
}
});
export default Tab;

View File

@ -1,116 +0,0 @@
import { getjQuery, onDOMContentLoaded } from '../mdb/util/index';
import EventHandler from '../mdb/dom/event-handler';
import SelectorEngine from '../mdb/dom/selector-engine';
import BSToast from '../bootstrap/mdb-prefix/toast';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'toast';
const DATA_KEY = `mdb.${NAME}`;
const EVENT_KEY = `.${DATA_KEY}`;
const EVENT_SHOW_BS = 'show.bs.toast';
const EVENT_SHOWN_BS = 'shown.bs.toast';
const EVENT_HIDE_BS = 'hide.bs.toast';
const EVENT_HIDDEN_BS = 'hidden.bs.toast';
const EVENT_SHOW = `show${EVENT_KEY}`;
const EVENT_SHOWN = `shown${EVENT_KEY}`;
const EVENT_HIDE = `hide${EVENT_KEY}`;
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
const SELECTOR_TOAST = '.toast';
class Toast extends BSToast {
constructor(element, data) {
super(element, data);
this._init();
}
dispose() {
EventHandler.off(this._element, EVENT_SHOW_BS);
EventHandler.off(this._element, EVENT_SHOWN_BS);
EventHandler.off(this._element, EVENT_HIDE_BS);
EventHandler.off(this._element, EVENT_HIDDEN_BS);
super.dispose();
}
// Getters
static get NAME() {
return NAME;
}
// Private
_init() {
this._bindShowEvent();
this._bindShownEvent();
this._bindHideEvent();
this._bindHiddenEvent();
}
_bindShowEvent() {
EventHandler.on(this._element, EVENT_SHOW_BS, () => {
EventHandler.trigger(this._element, EVENT_SHOW);
});
}
_bindShownEvent() {
EventHandler.on(this._element, EVENT_SHOWN_BS, () => {
EventHandler.trigger(this._element, EVENT_SHOWN);
});
}
_bindHideEvent() {
EventHandler.on(this._element, EVENT_HIDE_BS, () => {
EventHandler.trigger(this._element, EVENT_HIDE);
});
}
_bindHiddenEvent() {
EventHandler.on(this._element, EVENT_HIDDEN_BS, () => {
EventHandler.trigger(this._element, EVENT_HIDDEN);
});
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation - auto initialization
* ------------------------------------------------------------------------
*/
SelectorEngine.find(SELECTOR_TOAST).forEach((el) => {
let instance = Toast.getInstance(el);
if (!instance) {
instance = new Toast(el);
}
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .rating to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Toast.jQueryInterface;
$.fn[NAME].Constructor = Toast;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Toast.jQueryInterface;
};
}
});
export default Toast;

View File

@ -1,126 +0,0 @@
import { getjQuery, onDOMContentLoaded } from '../mdb/util/index';
import EventHandler from '../mdb/dom/event-handler';
import BSTooltip from '../bootstrap/mdb-prefix/tooltip';
import SelectorEngine from '../mdb/dom/selector-engine';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'tooltip';
const DATA_KEY = `mdb.${NAME}`;
const EVENT_KEY = `.${DATA_KEY}`;
const EVENT_HIDE_BS = 'hide.bs.tooltip';
const EVENT_HIDDEN_BS = 'hidden.bs.tooltip';
const EVENT_SHOW_BS = 'show.bs.tooltip';
const EVENT_SHOWN_BS = 'shown.bs.tooltip';
const EVENT_INSERTED_BS = 'inserted.bs.tooltip';
const EVENT_HIDE = `hide${EVENT_KEY}`;
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
const EVENT_SHOW = `show${EVENT_KEY}`;
const EVENT_SHOWN = `shown${EVENT_KEY}`;
const EVENT_INSERTED = `inserted${EVENT_KEY}`;
const SELECTOR_DATA_TOGGLE = '[data-mdb-toggle="tooltip"]';
class Tooltip extends BSTooltip {
constructor(element, data) {
super(element, data);
this._init();
}
dispose() {
EventHandler.off(this._element, EVENT_SHOW_BS);
EventHandler.off(this._element, EVENT_SHOWN_BS);
EventHandler.off(this._element, EVENT_HIDE_BS);
EventHandler.off(this._element, EVENT_HIDDEN_BS);
EventHandler.off(this._element, EVENT_INSERTED_BS);
super.dispose();
}
// Getters
static get NAME() {
return NAME;
}
// Private
_init() {
this._bindShowEvent();
this._bindShownEvent();
this._bindHideEvent();
this._bindHiddenEvent();
this._bindHidePreventedEvent();
}
_bindShowEvent() {
EventHandler.on(this.element, EVENT_SHOW_BS, () => {
EventHandler.trigger(this.element, EVENT_SHOW);
});
}
_bindShownEvent() {
EventHandler.on(this.element, EVENT_SHOWN_BS, () => {
EventHandler.trigger(this.element, EVENT_SHOWN);
});
}
_bindHideEvent() {
EventHandler.on(this.element, EVENT_HIDE_BS, () => {
EventHandler.trigger(this.element, EVENT_HIDE);
});
}
_bindHiddenEvent() {
EventHandler.on(this.element, EVENT_HIDDEN_BS, () => {
EventHandler.trigger(this.element, EVENT_HIDDEN);
});
}
_bindHidePreventedEvent() {
EventHandler.on(this.element, EVENT_INSERTED_BS, () => {
EventHandler.trigger(this.element, EVENT_INSERTED);
});
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation - auto initialization
* ------------------------------------------------------------------------
*/
SelectorEngine.find(SELECTOR_DATA_TOGGLE).forEach((el) => {
let instance = Tooltip.getInstance(el);
if (!instance) {
instance = new Tooltip(el);
}
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .rating to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Tooltip.jQueryInterface;
$.fn[NAME].Constructor = Tooltip;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Tooltip.jQueryInterface;
};
}
});
export default Tooltip;

187
src/js/free/treeview.js Normal file
View File

@ -0,0 +1,187 @@
import { element, getjQuery } from '../mdb/util/index';
import Data from '../mdb/dom/data';
import EventHandler from '../bootstrap/src/dom/event-handler';
import Manipulator from '../mdb/dom/manipulator';
import SelectorEngine from '../mdb/dom/selector-engine';
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'treeview';
const DATA_KEY = 'mdb.treeview';
const CLASSNAME_TREEVIEW = 'treeview';
const SELECTOR_EXPAND = '[data-toggle="treeview"]';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Treeview {
constructor(element, data) {
this._element = element;
if (this._element) {
this._data = data ? this._createHTMLNodes(data, element) : this._setData(element);
Data.setData(element, DATA_KEY, this);
Manipulator.addClass(this._element, CLASSNAME_TREEVIEW);
this._constructTreeview(this._data);
}
}
// Getters
static get NAME() {
return NAME;
}
// Public
collapse() {
const [, ...innerLists] = SelectorEngine.find('ul', this._element);
innerLists.forEach((node) => (node.style.display = 'none'));
}
dispose() {
Data.removeData(this._element, DATA_KEY);
this._element = null;
}
// Private
_toggleSubmenu(e) {
e.stopPropagation();
const li = e.target.nodeName === 'I' ? e.target.parentNode : e.target;
const [ul] =
li.nodeName === 'I'
? SelectorEngine.children(li.parentNode, 'ul')
: SelectorEngine.children(li, 'ul');
if (ul) {
ul.style.display = window.getComputedStyle(ul).display === 'none' ? 'block' : 'none';
this._toggleIcon(li);
}
}
_toggleIcon(el, icon1 = 'fa-caret-down', icon2 = 'fa-caret-up') {
const [i] = SelectorEngine.children(el, 'i');
if (!i) return;
const faClasses = [icon1, icon2];
const [current, next] = i.classList.contains(icon1) ? faClasses : faClasses.reverse();
i.classList.remove(current);
i.classList.add(next);
}
_constructTreeview(data) {
data.forEach((el) => {
el.node.addEventListener('click', this._toggleSubmenu.bind(this));
if (el.children && el.children.length > 0) {
const arrow = element('i');
arrow.classList = ['fas fa-caret-down'];
el.node.appendChild(arrow);
this._constructTreeview(el.children);
}
});
}
_setData(el) {
const [list] = SelectorEngine.children(el, 'ul');
if (!list) return [];
return SelectorEngine.children(list, 'li').map((node) => {
const children = this._setData(node);
return {
name: node.innerText ? node.innerText.split('\n')[0] : '',
node,
children,
};
});
}
_createHTMLNodes(data, parent) {
const ul = element('ul');
return data.map((item) => {
const li = element('li');
li.innerText = item.name;
let children = item.children;
if (children && children.length > 0) {
children = this._createHTMLNodes(item.children, li);
}
ul.appendChild(li);
parent.appendChild(ul);
return {
...item,
children,
node: li,
};
});
}
static toggleSubmenu(instance) {
return function (event) {
instance._toggleSubmenu(event);
};
}
static jQueryInterface(options) {
return this.each(function () {
const data = Data.getData(this, DATA_KEY);
if (!data) {
return new Treeview(this, options);
}
return null;
});
}
static getInstance(element) {
return Data.getData(element, DATA_KEY);
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation - auto initialization
* ------------------------------------------------------------------------
*/
EventHandler.on(document, 'click', SELECTOR_EXPAND, Treeview.toggleSubmenu(new Treeview()));
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .treeview to jQuery only if jQuery is present
*/
const $ = getjQuery();
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Treeview.jQueryInterface;
$.fn[NAME].Constructor = Treeview;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Treeview.jQueryInterface;
};
}
export default Treeview;

View File

@ -1,23 +1,25 @@
// BOOTSTRAP CORE COMPONENTS
import Button from './bootstrap/mdb-prefix/button';
import Collapse from './bootstrap/mdb-prefix/collapse';
import Alert from './free/alert';
import Carousel from './free/carousel';
import Modal from './free/modal';
import Popover from './free/popover';
import ScrollSpy from './free/scrollspy';
import Tab from './free/tab';
import Tooltip from './free/tooltip';
import Toast from './free/toast';
import Alert from './bootstrap/src/alert';
import Button from './bootstrap/src/button';
import Carousel from './bootstrap/src/carousel';
import Collapse from './bootstrap/src/collapse';
import Dropdown from './bootstrap/src/dropdown';
import Modal from './bootstrap/src/modal';
import Popover from './bootstrap/src/popover';
import ScrollSpy from './bootstrap/src/scrollspy';
import Tab from './bootstrap/src/tab';
import Toast from './bootstrap/src/toast';
import Tooltip from './bootstrap/src/tooltip';
// MDB FREE COMPONENTS
import Input from './free/input';
import Dropdown from './free/dropdown';
import Animate from './free/animate';
import Treeview from './free/treeview';
import Ripple from './free/ripple';
import Range from './free/range';
export {
Alert,
Animate,
Button,
Carousel,
Collapse,
@ -30,5 +32,5 @@ export {
Tab,
Toast,
Tooltip,
Range,
Treeview,
};

View File

@ -1,6 +1,6 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/data.js
* Bootstrap (v5.0.0-alpha1): dom/data.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
@ -16,22 +16,22 @@ const mapData = (() => {
let id = 1;
return {
set(element, key, data) {
if (typeof element[key] === 'undefined') {
element[key] = {
if (typeof element.key === 'undefined') {
element.key = {
key,
id,
};
id++;
}
storeData[element[key].id] = data;
storeData[element.key.id] = data;
},
get(element, key) {
if (!element || typeof element[key] === 'undefined') {
if (!element || typeof element.key === 'undefined') {
return null;
}
const keyProperties = element[key];
const keyProperties = element.key;
if (keyProperties.key === key) {
return storeData[keyProperties.id];
}
@ -39,14 +39,14 @@ const mapData = (() => {
return null;
},
delete(element, key) {
if (typeof element[key] === 'undefined') {
if (typeof element.key === 'undefined') {
return;
}
const keyProperties = element[key];
const keyProperties = element.key;
if (keyProperties.key === key) {
delete storeData[keyProperties.id];
delete element[key];
delete element.key;
}
},
};

View File

@ -1,10 +1,11 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/event-handler.js
* Bootstrap (v5.0.0-alpha1): dom/event-handler.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
import { defaultPreventedPreservedOnDispatch } from './polyfill';
import { getjQuery } from '../util/index';
/**
@ -93,8 +94,6 @@ function getEvent(element) {
function bootstrapHandler(element, fn) {
return function handler(event) {
event.delegateTarget = element;
if (handler.oneOff) {
EventHandler.off(element, event.type, fn);
}
@ -110,8 +109,6 @@ function bootstrapDelegationHandler(element, selector, fn) {
for (let { target } = event; target && target !== this; target = target.parentNode) {
for (let i = domElements.length; i--; '') {
if (domElements[i] === target) {
event.delegateTarget = target;
if (handler.oneOff) {
EventHandler.off(element, event.type, fn);
}
@ -321,6 +318,12 @@ const EventHandler = {
if (defaultPrevented) {
evt.preventDefault();
if (!defaultPreventedPreservedOnDispatch) {
Object.defineProperty(evt, 'defaultPrevented', {
get: () => true,
});
}
}
if (nativeDispatch) {
@ -335,21 +338,4 @@ const EventHandler = {
},
};
export const EventHandlerMulti = {
on(element, eventsName, handler, delegationFn) {
const events = eventsName.split(' ');
for (let i = 0; i < events.length; i++) {
EventHandler.on(element, events[i], handler, delegationFn);
}
},
off(element, originalTypeEvent, handler, delegationFn) {
const events = originalTypeEvent.split(' ');
for (let i = 0; i < events.length; i++) {
EventHandler.off(element, events[i], handler, delegationFn);
}
},
};
export default EventHandler;

View File

@ -1,7 +1,7 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/manipulator.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* Bootstrap (v5.0.0-alpha1): dom/manipulator.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
@ -31,11 +31,11 @@ function normalizeDataKey(key) {
const Manipulator = {
setDataAttribute(element, key, value) {
element.setAttribute(`data-mdb-${normalizeDataKey(key)}`, value);
element.setAttribute(`data-${normalizeDataKey(key)}`, value);
},
removeDataAttribute(element, key) {
element.removeAttribute(`data-mdb-${normalizeDataKey(key)}`);
element.removeAttribute(`data-${normalizeDataKey(key)}`);
},
getDataAttributes(element) {
@ -47,19 +47,15 @@ const Manipulator = {
...element.dataset,
};
Object.keys(attributes)
.filter((key) => key.startsWith('mdb'))
.forEach((key) => {
let pureKey = key.replace(/^mdb/, '');
pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
attributes[pureKey] = normalizeData(attributes[key]);
});
Object.keys(attributes).forEach((key) => {
attributes[key] = normalizeData(attributes[key]);
});
return attributes;
},
getDataAttribute(element, key) {
return normalizeData(element.getAttribute(`data-mdb-${normalizeDataKey(key)}`));
return normalizeData(element.getAttribute(`data-${normalizeDataKey(key)}`));
},
offset(element) {
@ -104,15 +100,6 @@ const Manipulator = {
element.style[property] = style[property];
});
},
removeClass(element, className) {
if (!element.classList.contains(className)) return;
element.classList.remove(className);
},
hasClass(element, className) {
return element.classList.contains(className);
},
};
export default Manipulator;

View File

@ -0,0 +1,85 @@
/* istanbul ignore file */
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-alpha1): dom/polyfill.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
import { getUID } from '../util/index';
let findElements = Element.prototype.querySelectorAll;
let findElement = Element.prototype.querySelector;
// MSEdge resets defaultPrevented flag upon dispatchEvent call if at least one listener is attached
const defaultPreventedPreservedOnDispatch = (() => {
const e = new CustomEvent('Bootstrap', {
cancelable: true,
});
const element = document.createElement('div');
element.addEventListener('Bootstrap', () => null);
e.preventDefault();
element.dispatchEvent(e);
return e.defaultPrevented;
})();
const scopeSelectorRegex = /:scope\b/;
const supportScopeQuery = (() => {
const element = document.createElement('div');
try {
element.querySelectorAll(':scope *');
} catch (_) {
return false;
}
return true;
})();
if (!supportScopeQuery) {
findElements = function (selector) {
if (!scopeSelectorRegex.test(selector)) {
return this.querySelectorAll(selector);
}
const hasId = Boolean(this.id);
if (!hasId) {
this.id = getUID('scope');
}
let nodeList = null;
try {
selector = selector.replace(scopeSelectorRegex, `#${this.id}`);
nodeList = this.querySelectorAll(selector);
} finally {
if (!hasId) {
this.removeAttribute('id');
}
}
return nodeList;
};
findElement = function (selector) {
if (!scopeSelectorRegex.test(selector)) {
return this.querySelector(selector);
}
const matches = find.call(this, selector);
if (typeof matches[0] !== 'undefined') {
return matches[0];
}
return null;
};
}
const find = findElements;
const findOne = findElement;
export { find, findOne, defaultPreventedPreservedOnDispatch };

View File

@ -1,10 +1,12 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): dom/selector-engine.js
* Bootstrap (v5.0.0-alpha1): dom/selector-engine.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
import { find as findFn, findOne } from './polyfill';
/**
* ------------------------------------------------------------------------
* Constants
@ -23,11 +25,11 @@ const SelectorEngine = {
},
find(selector, element = document.documentElement) {
return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
return [].concat(...findFn.call(element, selector));
},
findOne(selector, element = document.documentElement) {
return Element.prototype.querySelector.call(element, selector);
return findOne.call(element, selector);
},
children(element, selector) {

Some files were not shown because too many files have changed in this diff Show More