diff --git a/.babelrc.js b/.babelrc.js index 44a509954105..51399697f4e5 100644 --- a/.babelrc.js +++ b/.babelrc.js @@ -1,20 +1,12 @@ module.exports = { presets: [ [ - '@babel/env', + '@babel/preset-env', { loose: true, - modules: false, - exclude: ['transform-typeof-symbol'] + bugfixes: true, + modules: false } ] - ], - plugins: [ - '@babel/plugin-proposal-object-rest-spread' - ], - env: { - test: { - plugins: [ 'istanbul' ] - } - } + ] }; diff --git a/.browserslistrc b/.browserslistrc index 1bfd19753050..c17ce9049c9c 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -3,11 +3,10 @@ >= 1% last 1 major version not dead -Chrome >= 45 -Firefox >= 38 -Edge >= 12 -Explorer >= 10 -iOS >= 9 -Safari >= 9 -Android >= 4.4 -Opera >= 30 +Chrome >= 60 +Firefox >= 60 +Edge >= 16 +iOS >= 10 +Safari >= 10 +Android >= 6 +not Explorer <= 11 diff --git a/.bundlewatch.config.json b/.bundlewatch.config.json new file mode 100644 index 000000000000..b89e0207b783 --- /dev/null +++ b/.bundlewatch.config.json @@ -0,0 +1,66 @@ +{ + "files": [ + { + "path": "./dist/css/bootstrap-grid.css", + "maxSize": "7 kB" + }, + { + "path": "./dist/css/bootstrap-grid.min.css", + "maxSize": "6 kB" + }, + { + "path": "./dist/css/bootstrap-reboot.css", + "maxSize": "2 kB" + }, + { + "path": "./dist/css/bootstrap-reboot.min.css", + "maxSize": "2 kB" + }, + { + "path": "./dist/css/bootstrap-utilities.css", + "maxSize": "7 kB" + }, + { + "path": "./dist/css/bootstrap-utilities.min.css", + "maxSize": "6 kB" + }, + { + "path": "./dist/css/bootstrap.css", + "maxSize": "24 kB" + }, + { + "path": "./dist/css/bootstrap.min.css", + "maxSize": "21.5 kB" + }, + { + "path": "./dist/js/bootstrap.bundle.js", + "maxSize": "51 kB" + }, + { + "path": "./dist/js/bootstrap.bundle.min.js", + "maxSize": "22.5 kB" + }, + { + "path": "./dist/js/bootstrap.esm.js", + "maxSize": "28 kB" + }, + { + "path": "./dist/js/bootstrap.esm.min.js", + "maxSize": "19 kB" + }, + { + "path": "./dist/js/bootstrap.js", + "maxSize": "29 kB" + }, + { + "path": "./dist/js/bootstrap.min.js", + "maxSize": "16 kB" + } + ], + "ci": { + "trackBranches": [ + "main", + "v4-dev" + ] + } +} diff --git a/.editorconfig b/.editorconfig index 9d5248e86f37..f29d257cc590 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,6 +9,3 @@ indent_size = 2 indent_style = space insert_final_newline = true trim_trailing_whitespace = true - -[*.md] -trim_trailing_whitespace = false diff --git a/.eslintignore b/.eslintignore index 9eb685cbe476..6d874bc3658d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,4 +3,5 @@ **/vendor/ /_gh_pages/ /js/coverage/ +/site/static/sw.js /package.js diff --git a/.eslintrc.json b/.eslintrc.json index bfd2d333ae60..59fe70f56405 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,233 +1,58 @@ { "root": true, - "parser": "babel-eslint", - "env": { - "browser": true, - "es6": true - }, - "extends": ["eslint:recommended"], + "extends": [ + "plugin:import/errors", + "plugin:import/warnings", + "plugin:unicorn/recommended", + "xo/esnext", + "xo/browser" + ], "rules": { - // Possible Errors - "no-await-in-loop": "error", - "no-extra-parens": "error", - "no-prototype-builtins": "error", - "no-template-curly-in-string": "error", - "valid-jsdoc": "error", - - // Best Practices - "accessor-pairs": "error", - "array-callback-return": "error", - "block-scoped-var": "error", - "class-methods-use-this": "off", - "complexity": "error", - "consistent-return": "error", - "curly": "error", - "default-case": "error", - "dot-location": ["error", "property"], - "dot-notation": "error", - "eqeqeq": "error", - "guard-for-in": "error", - "no-alert": "error", - "no-caller": "error", - "no-div-regex": "error", - "no-else-return": "error", - "no-empty-function": "error", - "no-eq-null": "error", - "no-eval": "error", - "no-extend-native": "error", - "no-extra-bind": "error", - "no-extra-label": "error", - "no-floating-decimal": "error", - "no-implicit-coercion": "error", - "no-implicit-globals": "error", - "no-implied-eval": "error", - "no-invalid-this": "off", - "no-iterator": "error", - "no-labels": "error", - "no-lone-blocks": "error", - "no-loop-func": "error", - "no-magic-numbers": ["error", { - "ignore": [-1, 0, 1], - "ignoreArrayIndexes": true + "capitalized-comments": "off", + "indent": [ + "error", + 2, + { + "MemberExpression": "off", + "SwitchCase": 1 } ], - "no-multi-spaces": ["error", { - "ignoreEOLComments": true, - "exceptions": { - "AssignmentExpression": true, - "ArrowFunctionExpression": true, - "CallExpression": true, - "VariableDeclarator": true - } - } + "max-params": [ + "warn", + 5 ], - "no-multi-str": "error", - "no-new": "error", - "no-new-func": "error", - "no-new-wrappers": "error", - "no-octal-escape": "error", - "no-param-reassign": "off", - "no-proto": "error", - "no-restricted-properties": "error", - "no-return-assign": "error", - "no-return-await": "error", - "no-script-url": "error", - "no-self-compare": "error", - "no-sequences": "error", - "no-throw-literal": "error", - "no-unmodified-loop-condition": "error", - "no-unused-expressions": "error", - "no-useless-call": "error", - "no-useless-concat": "error", - "no-useless-return": "error", - "no-void": "error", - "no-warning-comments": "off", - "no-with": "error", - "prefer-promise-reject-errors": "error", - "radix": "error", - "require-await": "error", - "vars-on-top": "error", - "wrap-iife": "error", - "yoda": "error", - - // Strict Mode - "strict": "error", - - // Variables - "init-declarations": "off", - "no-catch-shadow": "error", - "no-label-var": "error", - "no-restricted-globals": "error", - "no-shadow": "off", - "no-shadow-restricted-names": "error", - "no-undef-init": "error", - "no-undefined": "error", - "no-use-before-define": "off", - - // Node.js and CommonJS - "callback-return": "off", - "global-require": "error", - "handle-callback-err": "error", - "no-mixed-requires": "error", - "no-new-require": "error", - "no-path-concat": "error", - "no-process-env": "error", - "no-process-exit": "error", - "no-restricted-modules": "error", - "no-sync": "error", - - // Stylistic Issues - "array-bracket-spacing": "error", - "block-spacing": "error", - "brace-style": "error", - "camelcase": "error", - "capitalized-comments": "off", - "comma-dangle": "error", - "comma-spacing": "error", - "comma-style": "error", - "computed-property-spacing": "error", - "consistent-this": "error", - "eol-last": "error", - "func-call-spacing": "error", - "func-name-matching": "error", - "func-names": "off", - "func-style": ["error", "declaration"], - "id-blacklist": "error", - "id-length": "off", - "id-match": "error", - "indent": ["error", 2, { "SwitchCase": 1 }], - "jsx-quotes": "error", - "key-spacing": "off", - "keyword-spacing": "error", - "linebreak-style": ["error", "unix"], - "line-comment-position": "off", - "lines-around-comment": "off", - "lines-around-directive": "error", - "max-depth": ["error", 10], - "max-len": "off", - "max-lines": "off", - "max-nested-callbacks": "error", - "max-params": "off", - "max-statements": "off", - "max-statements-per-line": "error", - "multiline-ternary": "off", - "new-cap": ["error", { "capIsNewExceptionPattern": "$.*" }], - "newline-after-var": "off", - "newline-per-chained-call": ["error", { "ignoreChainWithDepth": 5 }], - "new-parens": "error", - "no-array-constructor": "error", - "no-bitwise": "error", - "no-continue": "off", - "no-inline-comments": "off", - "no-lonely-if": "error", - "no-mixed-operators": "off", - "no-multi-assign": "error", - "no-multiple-empty-lines": "error", - "nonblock-statement-body-position": "error", - "no-negated-condition": "off", - "no-nested-ternary": "error", - "no-new-object": "error", - "no-plusplus": "off", - "no-restricted-syntax": "error", - "no-tabs": "error", - "no-ternary": "off", - "no-trailing-spaces": "error", - "no-underscore-dangle": "off", - "no-unneeded-ternary": "error", - "no-whitespace-before-property": "error", - "object-curly-newline": ["error", { "minProperties": 1 }], - "object-curly-spacing": ["error", "always"], - "object-property-newline": "error", - "one-var": ["error", "never"], - "one-var-declaration-per-line": "error", - "operator-assignment": "error", - "operator-linebreak": "error", - "padded-blocks": ["error", "never"], - "padding-line-between-statements": "off", - "quote-props": ["error", "as-needed"], - "quotes": ["error", "single"], - "require-jsdoc": "off", - "semi": ["error", "never"], - "semi-spacing": "error", - "sort-keys": "off", - "sort-vars": "error", - "space-before-blocks": "error", - "space-before-function-paren": ["error", { - "anonymous": "always", - "named": "never" - }], - "space-in-parens": "error", - "space-infix-ops": "error", - "space-unary-ops": "error", - "spaced-comment": "error", - "template-tag-spacing": "error", - "unicode-bom": "error", - "wrap-regex": "off", - - // ECMAScript 6 - "arrow-body-style": ["error", "as-needed"], - "arrow-parens": "error", - "arrow-spacing": "error", - "generator-star-spacing": "error", - "no-confusing-arrow": "error", - "no-duplicate-imports": "error", - "no-restricted-imports": "error", - "no-useless-computed-key": "error", - "no-useless-constructor": "error", - "no-useless-rename": "error", - "no-var": "error", - "object-shorthand": "error", - "prefer-arrow-callback": "error", - "prefer-const": "error", - "prefer-destructuring": "off", - "prefer-numeric-literals": "error", - "prefer-rest-params": "error", - "prefer-spread": "error", - "prefer-template": "error", - "rest-spread-spacing": "error", - "sort-imports": "error", - "symbol-description": "error", - "template-curly-spacing": "error", - "yield-star-spacing": "error" + "multiline-ternary": [ + "error", + "always-multiline" + ], + "new-cap": "off", + "no-console": "error", + "object-curly-spacing": [ + "error", + "always" + ], + "prefer-named-capture-group": "off", + "semi": [ + "error", + "never" + ], + "unicorn/consistent-function-scoping": "off", + "unicorn/explicit-length-check": "off", + "unicorn/import-index": "off", + "unicorn/no-fn-reference-in-iterator": "off", + "unicorn/no-for-loop": "off", + "unicorn/no-null": "off", + "unicorn/no-unused-properties": "error", + "unicorn/no-useless-undefined": "off", + "unicorn/prefer-array-find": "off", + "unicorn/prefer-dataset": "off", + "unicorn/prefer-includes": "off", + "unicorn/prefer-node-append": "off", + "unicorn/prefer-node-remove": "off", + "unicorn/prefer-number-properties": "off", + "unicorn/prefer-optional-catch-binding": "off", + "unicorn/prefer-query-selector": "off", + "unicorn/prefer-set-has": "off", + "unicorn/prevent-abbreviations": "off" } } diff --git a/.gitattributes b/.gitattributes index 39813c758947..40b1c37421a0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,18 +1,8 @@ # Enforce Unix newlines -*.css text eol=lf -*.html text eol=lf -*.js text eol=lf -*.json text eol=lf -*.md text eol=lf -*.rb text eol=lf -*.scss text eol=lf -*.svg text eol=lf -*.txt text eol=lf -*.xml text eol=lf -*.yml text eol=lf +* text=auto eol=lf # Don't diff or textually merge source maps -*.map binary +*.map binary bootstrap.css linguist-vendored=false bootstrap.js linguist-vendored=false diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f579111bd41a..34da5de09133 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -19,7 +19,8 @@ and [submitting pull requests](#pull-requests), but please respect the following restrictions: * Please **do not** use the issue tracker for personal support requests. Stack - Overflow ([`bootstrap-4`](https://stackoverflow.com/questions/tagged/bootstrap-4) tag), [Slack](https://bootstrap-slack.herokuapp.com/) or [IRC](README.md#community) are better places to get help. + Overflow ([`bootstrap-5`](https://stackoverflow.com/questions/tagged/bootstrap-5) tag), + [Slack](https://bootstrap-slack.herokuapp.com/) or [IRC](README.md#community) are better places to get help. * Please **do not** derail or troll issues. Keep the discussion on topic and respect the opinions of others. @@ -57,15 +58,14 @@ Good bug reports are extremely helpful, so thanks! Guidelines for bug reports: -0. **Validate and lint your code** — [validate your HTML](https://html5.validator.nu/) - and [lint your HTML](https://github.com/twbs/bootlint) to ensure your +0. **[Validate your HTML](https://html5.validator.nu/)** to ensure your problem isn't caused by a simple error in your own code. 1. **Use the GitHub issue search** — check if the issue has already been reported. 2. **Check if the issue has been fixed** — try to reproduce it using the - latest `master` or development branch in the repository. + latest `main` (or `v4-dev` branch if the issue is about v4) in the repository. 3. **Isolate the problem** — ideally create a [reduced test case](https://css-tricks.com/reduced-test-cases/) and a live example. @@ -100,7 +100,6 @@ Example: ### Reporting upstream browser bugs Sometimes bugs reported to us are actually caused by bugs in the browser(s) themselves, not bugs in Bootstrap per se. -When feasible, we aim to report such upstream bugs to the relevant browser vendor(s), and then list them on our [Wall of Browser Bugs](https://getbootstrap.com/browser-bugs/) and [document them in MDN](https://developer.mozilla.org/en-US/docs/Web). | Vendor(s) | Browser(s) | Rendering engine | Bug reporting website(s) | Notes | | ------------- | ---------------------------- | ---------------- | ------------------------------------------------------------------------------------- | -------------------------------------------------------- | @@ -109,10 +108,6 @@ When feasible, we aim to report such upstream bugs to the relevant browser vendo | Google, Opera | Chrome, Chromium, Opera v15+ | Blink | https://bugs.chromium.org/p/chromium/issues/list | Click the "New issue" button. | | Microsoft | Edge | EdgeHTML | https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/ | | -### Issues bots - -[@twbs-lmvtfy](https://github.com/twbs-lmvtfy) is a Bootstrap bot that hangs out in our GitHub issue tracker and automatically checks for HTML validation errors in live examples (e.g. jsFiddles, JS Bins, Bootplys, Plunks, CodePens, etc.) posted in issue comments. If it finds any errors, it will post a follow-up comment on the issue and point out the errors. If this happens with an example you've posted, please fix the errors and post an updated live example. If you opened a bug report, please check whether the bug still occurs with your revised, valid live example. If the bug no longer occurs, it was probably due to your invalid HTML rather than something in Bootstrap and we'd appreciate it if you could close out the GitHub issue. - ## Feature requests @@ -139,12 +134,12 @@ project (indentation, accurate comments, etc.) and any other requirements **Do not edit `bootstrap.css`, or `bootstrap.js` directly!** Those files are automatically generated. You should edit the -source files in [`/bootstrap/scss/`](https://github.com/twbs/bootstrap/tree/master/scss) -and/or [`/bootstrap/js/`](https://github.com/twbs/bootstrap/tree/master/js) instead. +source files in [`/bootstrap/scss/`](https://github.com/twbs/bootstrap/tree/main/scss) +and/or [`/bootstrap/js/src/`](https://github.com/twbs/bootstrap/tree/main/js/src) instead. Similarly, when contributing to Bootstrap's documentation, you should edit the documentation source files in -[the `/bootstrap/docs/` directory of the `master` branch](https://github.com/twbs/bootstrap/tree/master/docs). +[the `/bootstrap/site/content/docs/` directory of the `main` branch](https://github.com/twbs/bootstrap/tree/main/site/content/docs). **Do not edit the `gh-pages` branch.** That branch is generated from the documentation source files and is managed separately by the Bootstrap Core Team. @@ -166,8 +161,8 @@ included in the project: 2. If you cloned a while ago, get the latest changes from upstream: ```bash - git checkout master - git pull upstream master + git checkout main + git pull upstream main ``` 3. Create a new topic branch (off the main project development branch) to @@ -186,7 +181,7 @@ included in the project: 5. Locally merge (or rebase) the upstream development branch into your topic branch: ```bash - git pull [--rebase] upstream master + git pull [--rebase] upstream main ``` 6. Push your topic branch up to your fork: @@ -196,12 +191,12 @@ included in the project: ``` 7. [Open a Pull Request](https://help.github.com/articles/about-pull-requests/) - with a clear title and description against the `master` branch. + with a clear title and description against the `main` branch. **IMPORTANT**: By submitting a patch, you agree to allow the project owners to -license your work under the terms of the [MIT License](LICENSE) (if it +license your work under the terms of the [MIT License](../LICENSE) (if it includes code changes) and under the terms of the -[Creative Commons Attribution 3.0 Unported License](docs/LICENSE) +[Creative Commons Attribution 3.0 Unported License](https://creativecommons.org/licenses/by/3.0/) (if it includes documentation changes). @@ -209,7 +204,7 @@ includes code changes) and under the terms of the ### HTML -[Adhere to the Code Guide.](http://codeguide.co/#html) +[Adhere to the Code Guide.](https://codeguide.co/#html) - Use tags and elements appropriate for an HTML5 doctype (e.g., self-closing tags). - Use CDNs and HTTPS for third-party JS when possible. We don't use protocol-relative URLs in this case because they break when viewing the page locally via `file://`. @@ -217,10 +212,10 @@ includes code changes) and under the terms of the ### CSS -[Adhere to the Code Guide.](http://codeguide.co/#css) +[Adhere to the Code Guide.](https://codeguide.co/#css) - When feasible, default color palettes should comply with [WCAG color contrast guidelines](https://www.w3.org/TR/WCAG20/#visual-audio-contrast). -- Except in rare cases, don't remove default `:focus` styles (via e.g. `outline: none;`) without providing alternative styles. See [this A11Y Project post](https://a11yproject.com/posts/never-remove-css-outlines/) for more details. +- Except in rare cases, don't remove default `:focus` styles (via e.g. `outline: none;`) without providing alternative styles. See [this A11Y Project post](https://www.a11yproject.com/posts/2013-01-25-never-remove-css-outlines/) for more details. ### JS @@ -228,7 +223,6 @@ includes code changes) and under the terms of the - 2 spaces (no tabs) - strict mode - "Attractive" -- Don't use [jQuery event alias convenience methods](https://github.com/jquery/jquery/blob/master/src/event/alias.js) (such as `$().focus()`). Instead, use [`$().trigger(eventType, ...)`](https://api.jquery.com/trigger/) or [`$().on(eventType, ...)`](https://api.jquery.com/on/), depending on whether you're firing an event or listening for an event. (For example, `$().trigger('focus')` or `$().on('focus', function (event) { /* handle focus event */ })`) We do this to be compatible with custom builds of jQuery where the event aliases module has been excluded. ### Checking coding style @@ -237,7 +231,7 @@ Run `npm run test` before committing to ensure your changes follow our coding st ## License -By contributing your code, you agree to license your contribution under the [MIT License](LICENSE). -By contributing to the documentation, you agree to license your contribution under the [Creative Commons Attribution 3.0 Unported License](docs/LICENSE). +By contributing your code, you agree to license your contribution under the [MIT License](../LICENSE). +By contributing to the documentation, you agree to license your contribution under the [Creative Commons Attribution 3.0 Unported License](https://creativecommons.org/licenses/by/3.0/). Prior to v3.1.0, Bootstrap's code was released under the Apache License v2.0. diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000000..43ea984bab4f --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +open_collective: bootstrap diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md deleted file mode 100644 index 8e1285515d00..000000000000 --- a/.github/ISSUE_TEMPLATE/bug.md +++ /dev/null @@ -1,11 +0,0 @@ -Before opening: - -- [Search for duplicate or closed issues](https://github.com/twbs/bootstrap/issues?utf8=%E2%9C%93&q=is%3Aissue) -- [Validate](https://html5.validator.nu/) and [lint](https://github.com/twbs/bootlint#in-the-browser) any HTML to avoid common problems -- Read the [contributing guidelines](https://github.com/twbs/bootstrap/blob/master/CONTRIBUTING.md) - -Bug reports must include: - -- Operating system and version (Windows, macOS, Android, iOS, Win10 Mobile) -- Browser and version (Chrome, Firefox, Safari, IE, MS Edge, Opera 15+, Android Browser) -- [Reduced test case](https://css-tricks.com/reduced-test-cases/) and suggested fix using [CodePen](https://codepen.io/) or [JS Bin](https://jsbin.com/) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index ab363e0cac6c..70dcfd53281a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,17 +1,20 @@ --- name: Bug report about: Tell us about a bug you may have identified in Bootstrap. +title: '' +labels: '' +assignees: '' --- Before opening: - [Search for duplicate or closed issues](https://github.com/twbs/bootstrap/issues?utf8=%E2%9C%93&q=is%3Aissue) -- [Validate](https://html5.validator.nu/) and [lint](https://github.com/twbs/bootlint#in-the-browser) any HTML to avoid common problems -- Read the [contributing guidelines](https://github.com/twbs/bootstrap/blob/master/CONTRIBUTING.md) +- [Validate](https://html5.validator.nu/) any HTML to avoid common problems +- Read the [contributing guidelines](https://github.com/twbs/bootstrap/blob/main/.github/CONTRIBUTING.md) Bug reports must include: -- Operating system and version (Windows, macOS, Android, iOS, Win10 Mobile) -- Browser and version (Chrome, Firefox, Safari, IE, MS Edge, Opera 15+, Android Browser) -- [Reduced test case](https://css-tricks.com/reduced-test-cases/) and suggested fix using [CodePen](https://codepen.io/) or [JS Bin](https://jsbin.com/) +- Operating system and version (Windows, macOS, Android, iOS) +- Browser and version (Chrome, Firefox, Safari, Microsoft Edge, Opera, Android Browser) +- A [reduced test case](https://css-tricks.com/reduced-test-cases/) or suggested fix using [CodePen](https://codepen.io/) or [JS Bin](https://jsbin.com/) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000000..2913b45f02ed --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,4 @@ +contact_links: + - name: Ask a question + url: https://github.com/twbs/bootstrap/discussions/new + about: Ask and discuss questions with other Bootstrap community members diff --git a/.github/ISSUE_TEMPLATE/feature.md b/.github/ISSUE_TEMPLATE/feature.md deleted file mode 100644 index 4f866e2141e9..000000000000 --- a/.github/ISSUE_TEMPLATE/feature.md +++ /dev/null @@ -1,9 +0,0 @@ -Before opening: - -- [Search for duplicate or closed issues](https://github.com/twbs/bootstrap/issues?utf8=%E2%9C%93&q=is%3Aissue) -- Read the [contributing guidelines](https://github.com/twbs/bootstrap/blob/master/CONTRIBUTING.md) - -Feature requests must include: - -- As much detail as possible for what we should add and why it's important to Bootstrap -- Relevant links to prior art, screenshots, or live demos whenever possible diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 389bd4345ae8..422fa2bb4c3c 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,13 +1,16 @@ --- name: Feature request about: Suggest an idea for a new feature in Bootstrap. +title: '' +labels: feature +assignees: '' --- Before opening: - [Search for duplicate or closed issues](https://github.com/twbs/bootstrap/issues?utf8=%E2%9C%93&q=is%3Aissue) -- Read the [contributing guidelines](https://github.com/twbs/bootstrap/blob/master/CONTRIBUTING.md) +- Read the [contributing guidelines](https://github.com/twbs/bootstrap/blob/main/.github/CONTRIBUTING.md) Feature requests must include: diff --git a/.github/SUPPORT.md b/.github/SUPPORT.md index de3c4b552e9a..c30bed3b4511 100644 --- a/.github/SUPPORT.md +++ b/.github/SUPPORT.md @@ -8,4 +8,4 @@ For general troubleshooting or help getting started: - Join [the official Slack room](https://bootstrap-slack.herokuapp.com/). - Chat with fellow Bootstrappers in IRC. On the `irc.freenode.net` server, in the `##bootstrap` channel. -- Ask and explore Stack Overflow with the [`bootstrap-4`](https://stackoverflow.com/questions/tagged/bootstrap-4) tag. +- Ask and explore Stack Overflow with the [`bootstrap-5`](https://stackoverflow.com/questions/tagged/bootstrap-5) tag. diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000000..31976021e8af --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: "/" + schedule: + interval: weekly + day: tuesday + time: "12:00" + timezone: Europe/Athens + open-pull-requests-limit: 10 + reviewers: + - XhmikosR + labels: + - dependencies + - v5 + versioning-strategy: increase + rebase-strategy: disabled diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 000000000000..ae1367c89296 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,40 @@ +name-template: 'v$NEXT_MAJOR_VERSION' +tag-template: 'v$NEXT_MAJOR_VERSION' +prerelease: true +exclude-labels: + - 'skip-changelog' +categories: + - title: '๐Ÿš€ Features' + labels: + - 'new-feature' + - 'feature' + - 'enhancement' + - title: '๐Ÿ› Bug fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: '๐ŸŽจ CSS' + labels: + - 'css' + - title: 'โ˜•๏ธ JavaScript' + labels: + - 'js' + - title: '๐Ÿ“– Docs' + labels: + - 'docs' + - title: '๐ŸŒŽ Accessibility' + labels: + - 'accessibility' + - title: '๐Ÿงฐ Misc' + labels: + - 'build' + - 'meta' + - 'chore' + - title: '๐Ÿ“ฆ Dependencies' + labels: + - 'dependencies' +change-template: '- #$NUMBER: $TITLE' +template: | + ## Changes + $CHANGES diff --git a/.github/workflows/browserstack.yml b/.github/workflows/browserstack.yml new file mode 100644 index 000000000000..f709b98da4f6 --- /dev/null +++ b/.github/workflows/browserstack.yml @@ -0,0 +1,40 @@ +name: BrowserStack +on: [push] +env: + CI: true + NODE: 12.x + +jobs: + browserstack: + runs-on: ubuntu-latest + if: github.repository == 'twbs/bootstrap' + + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - name: Set Node.js version + uses: actions/setup-node@v1 + with: + node-version: "${{ env.NODE }}" + + - name: Set up npm cache + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + ${{ runner.OS }}-node-v${{ env.NODE }}- + + - name: Install npm dependencies + run: npm ci + + - name: Run dist + run: npm run dist + + - name: Run BrowserStack tests + run: npm run js-test-cloud + env: + BROWSER_STACK_ACCESS_KEY: "${{ secrets.BROWSER_STACK_ACCESS_KEY }}" + BROWSER_STACK_USERNAME: "${{ secrets.BROWSER_STACK_USERNAME }}" diff --git a/.github/workflows/bundlewatch.yml b/.github/workflows/bundlewatch.yml new file mode 100644 index 000000000000..f09cc9667df0 --- /dev/null +++ b/.github/workflows/bundlewatch.yml @@ -0,0 +1,39 @@ +name: Bundlewatch +on: [push, pull_request] +env: + CI: true + NODE: 12.x + +jobs: + bundlewatch: + runs-on: ubuntu-latest + + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - name: Set Node.js version + uses: actions/setup-node@v1 + with: + node-version: "${{ env.NODE }}" + + - name: Set up npm cache + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + ${{ runner.OS }}-node-v${{ env.NODE }}- + + - name: Install npm dependencies + run: npm ci + + - name: Run dist + run: npm run dist + + - name: Run bundlewatch + run: npm run bundlewatch + env: + BUNDLEWATCH_GITHUB_TOKEN: "${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}" + CI_BRANCH_BASE: main diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000000..777d812d6d2d --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,25 @@ +name: "Code Scanning - Action" + +on: + push: + schedule: + - cron: "0 0 * * 0" + +jobs: + CodeQL-Build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: javascript + + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/css.yml b/.github/workflows/css.yml new file mode 100644 index 000000000000..390bffc966e9 --- /dev/null +++ b/.github/workflows/css.yml @@ -0,0 +1,33 @@ +name: CSS +on: [push, pull_request] +env: + CI: true + NODE: 12.x + +jobs: + css: + runs-on: ubuntu-latest + + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - name: Set Node.js version + uses: actions/setup-node@v1 + with: + node-version: "${{ env.NODE }}" + + - name: Set up npm cache + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + ${{ runner.OS }}-node-v${{ env.NODE }}- + + - name: Install npm dependencies + run: npm ci + + - name: Build CSS + run: npm run css diff --git a/.github/workflows/dart-sass.yml b/.github/workflows/dart-sass.yml new file mode 100644 index 000000000000..8482a152ef56 --- /dev/null +++ b/.github/workflows/dart-sass.yml @@ -0,0 +1,24 @@ +name: CSS (Dart Sass) +on: [push, pull_request] +env: + CI: true + NODE: 12.x + +jobs: + css: + runs-on: ubuntu-latest + + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - name: Set Node.js version + uses: actions/setup-node@v1 + with: + node-version: "${{ env.NODE }}" + + - name: Build CSS with Dart Sass + run: | + npx --package sass@latest sass --version + npx --package sass@latest sass --style expanded --source-map --embed-sources --no-error-css scss/:dist-sass/css/ + ls -Al dist-sass/css diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 000000000000..652e27a7d0a2 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,35 @@ +name: Docs +on: [push, pull_request] +env: + CI: true + NODE: 12.x + +jobs: + docs: + runs-on: ubuntu-latest + + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - name: Set Node.js version + uses: actions/setup-node@v1 + with: + node-version: "${{ env.NODE }}" + + - run: java -version + + - name: Set up npm cache + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + ${{ runner.OS }}-node-v${{ env.NODE }}- + + - name: Install npm dependencies + run: npm ci + + - name: Test docs + run: npm run docs diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml new file mode 100644 index 000000000000..543172ccb2fe --- /dev/null +++ b/.github/workflows/js.yml @@ -0,0 +1,48 @@ +name: JS Tests +on: [push, pull_request] +env: + CI: true + +jobs: + run: + name: Node ${{ matrix.node }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node: [10, 12] + + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - name: Set Node.js version + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + + - name: Set up npm cache + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-v${{ matrix.node }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}} + restore-keys: | + ${{ runner.OS }}-node-v${{ matrix.node }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + ${{ runner.OS }}-node-v${{ matrix.node }}- + + - name: Install npm dependencies + run: npm ci + + - name: Run dist + run: npm run js + + - name: Run JS tests + run: npm run js-test + + - name: Run Coveralls + uses: coverallsapp/github-action@master + if: matrix.node == 12 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + path-to-lcov: "./js/coverage/lcov.info" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000000..f3d00d69ff97 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,33 @@ +name: Lint +on: [push, pull_request] +env: + CI: true + NODE: 12.x + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - name: Set Node.js version + uses: actions/setup-node@v1 + with: + node-version: "${{ env.NODE }}" + + - name: Set up npm cache + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + ${{ runner.OS }}-node-v${{ env.NODE }}- + + - name: Install npm dependencies + run: npm ci + + - name: Lint + run: npm run lint diff --git a/.github/workflows/release-notes.yml b/.github/workflows/release-notes.yml new file mode 100644 index 000000000000..1c4f4be9b8e3 --- /dev/null +++ b/.github/workflows/release-notes.yml @@ -0,0 +1,14 @@ +name: Release notes + +on: + push: + branches: + - main + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 455ebd1b24b5..6208c57d7037 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,15 @@ # Ignore docs files /_gh_pages/ -/site/.jekyll-metadata +# This is the old Jekyll docs dist folder; +# keeping it here so that when we switch branches it doesn't show up /site/docs/**/dist/ +# Jekyll's cache folder; keeping it for the same reason as above +/site/.jekyll-cache/ +# Hugo resources folder +/resources/ -# Ignore ruby/bundler files +# Ignore ruby/bundler files; +# keeping them here so that when we switch branches they don't show up /.bundle/ /vendor/ /.ruby-version @@ -33,6 +39,9 @@ *.sublime-workspace nbproject Thumbs.db +/.vscode/ +# Local Netlify folder +.netlify # Komodo .komodotools diff --git a/.stylelintignore b/.stylelintignore index 7bc488e5f871..e42e88938400 100644 --- a/.stylelintignore +++ b/.stylelintignore @@ -2,3 +2,4 @@ **/dist/ **/vendor/ /_gh_pages/ +/js/coverage/ diff --git a/.stylelintrc b/.stylelintrc index 50a9473ce34f..1c9ee181161c 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -3,13 +3,25 @@ "stylelint-config-twbs-bootstrap/scss" ], "rules": { - "property-blacklist": [ + "function-disallowed-list": [ + "calc", + "lighten", + "darken" + ], + "property-disallowed-list": [ "border-radius", "border-top-left-radius", "border-top-right-radius", "border-bottom-right-radius", "border-bottom-left-radius", "transition" - ] + ], + "scss/dollar-variable-default": [ + true, + { + "ignore": "local" + } + ], + "scss/selector-no-union-class-name": true } } diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b8d19ad258ec..000000000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -addons: - chrome: stable -language: node_js -git: - depth: 3 -node_js: - - "6" - - "8" -install: - - bundle install --deployment --jobs=3 --retry=3 --clean - - npm install -before_script: - - google-chrome-stable --product-version -script: - - npm test || travis_terminate 1 - - if [[ "$TRAVIS_NODE_VERSION" = "8" ]]; then npm run check-broken-links; fi - - if [[ "$TRAVIS_NODE_VERSION" = "8" && "$TRAVIS_EVENT_TYPE" = "push" && ! `git log --format=%B --no-merges -n 1 | grep '\[skip browser\]'` ]]; then npm run js-test-cloud; fi -after_success: - - if [[ "$TRAVIS_NODE_VERSION" = "8" ]]; then npm run coveralls; fi -cache: - directories: - - node_modules - - vendor/bundle -notifications: - email: false diff --git a/CNAME b/CNAME deleted file mode 100644 index 52c853392c25..000000000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -getbootstrap.com diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 9d9922f25f4d..963db62fe3fb 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting +- The use of sexualized language or imagery and unwelcome sexual attention or advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities diff --git a/Gemfile b/Gemfile deleted file mode 100644 index d4fdb3b90778..000000000000 --- a/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -source 'https://rubygems.org' - -group :development, :test do - gem 'jekyll', '~> 3.8.5' - gem 'jekyll-redirect-from', '~> 0.14.0' - gem 'jekyll-sitemap', '~> 1.2.0' - gem 'jekyll-toc', '~> 0.9.1' - gem 'wdm', '~> 0.1.1', :install_if => Gem.win_platform? -end diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 6a308fcd9371..000000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,82 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - addressable (2.6.0) - public_suffix (>= 2.0.2, < 4.0) - colorator (1.1.0) - concurrent-ruby (1.1.4) - em-websocket (0.5.1) - eventmachine (>= 0.12.9) - http_parser.rb (~> 0.6.0) - eventmachine (1.2.7) - eventmachine (1.2.7-x64-mingw32) - ffi (1.10.0) - ffi (1.10.0-x64-mingw32) - forwardable-extended (2.6.0) - http_parser.rb (0.6.0) - i18n (0.9.5) - concurrent-ruby (~> 1.0) - jekyll (3.8.5) - addressable (~> 2.4) - colorator (~> 1.0) - em-websocket (~> 0.5) - i18n (~> 0.7) - jekyll-sass-converter (~> 1.0) - jekyll-watch (~> 2.0) - kramdown (~> 1.14) - liquid (~> 4.0) - mercenary (~> 0.3.3) - pathutil (~> 0.9) - rouge (>= 1.7, < 4) - safe_yaml (~> 1.0) - jekyll-redirect-from (0.14.0) - jekyll (~> 3.3) - jekyll-sass-converter (1.5.2) - sass (~> 3.4) - jekyll-sitemap (1.2.0) - jekyll (~> 3.3) - jekyll-toc (0.9.1) - nokogiri (~> 1.8) - jekyll-watch (2.1.2) - listen (~> 3.0) - kramdown (1.17.0) - liquid (4.0.1) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - mercenary (0.3.6) - mini_portile2 (2.4.0) - nokogiri (1.10.1) - mini_portile2 (~> 2.4.0) - nokogiri (1.10.1-x64-mingw32) - mini_portile2 (~> 2.4.0) - pathutil (0.16.2) - forwardable-extended (~> 2.6) - public_suffix (3.0.3) - rb-fsevent (0.10.3) - rb-inotify (0.10.0) - ffi (~> 1.0) - rouge (3.3.0) - ruby_dep (1.5.0) - safe_yaml (1.0.4) - sass (3.7.3) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - wdm (0.1.1) - -PLATFORMS - ruby - x64-mingw32 - -DEPENDENCIES - jekyll (~> 3.8.5) - jekyll-redirect-from (~> 0.14.0) - jekyll-sitemap (~> 1.2.0) - jekyll-toc (~> 0.9.1) - wdm (~> 0.1.1) - -BUNDLED WITH - 1.17.3 diff --git a/LICENSE b/LICENSE index 7d1e2311f44f..173a9ebbbd7a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ The MIT License (MIT) -Copyright (c) 2011-2019 Twitter, Inc. -Copyright (c) 2011-2019 The Bootstrap Authors +Copyright (c) 2011-2020 Twitter, Inc. +Copyright (c) 2011-2020 The Bootstrap Authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 9fa8f536a53f..4ce841c2b5c7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- - Bootstrap logo + + Bootstrap logo

@@ -9,12 +9,12 @@

Sleek, intuitive, and powerful front-end framework for faster and easier web development.
- Explore Bootstrap docs ยป + Explore Bootstrap docs ยป

- Report bug + Report bug ยท - Request feature + Request feature ยท Themes ยท @@ -22,6 +22,11 @@

+## Bootstrap 4 + +Our default branch is for development of our upcoming Bootstrap 5 release. Head to the [`v4-dev` branch](https://github.com/twbs/bootstrap/tree/v4-dev) to view the readme, documentation, and source code for Bootstrap 4. + + ## Table of contents - [Quick start](#quick-start) @@ -41,33 +46,35 @@ Several quick start options are available: -- [Download the latest release.](https://github.com/twbs/bootstrap/archive/v4.3.1.zip) +- [Download the latest release](https://github.com/twbs/bootstrap/archive/v5.0.0-alpha2.zip) - Clone the repo: `git clone https://github.com/twbs/bootstrap.git` -- Install with [npm](https://www.npmjs.com/): `npm install bootstrap` -- Install with [yarn](https://yarnpkg.com/): `yarn add bootstrap@4.3.1` -- Install with [Composer](https://getcomposer.org/): `composer require twbs/bootstrap:4.3.1` +- Install with [npm](https://www.npmjs.com/): `npm install bootstrap@next` +- Install with [yarn](https://yarnpkg.com/): `yarn add bootstrap@next` +- Install with [Composer](https://getcomposer.org/): `composer require twbs/bootstrap:5.0.0-alpha2` - Install with [NuGet](https://www.nuget.org/): CSS: `Install-Package bootstrap` Sass: `Install-Package bootstrap.sass` -Read the [Getting started page](https://getbootstrap.com/docs/4.3/getting-started/introduction/) for information on the framework contents, templates and examples, and more. +Read the [Getting started page](https://v5.getbootstrap.com/docs/5.0/getting-started/introduction/) for information on the framework contents, templates and examples, and more. ## Status [![Slack](https://bootstrap-slack.herokuapp.com/badge.svg)](https://bootstrap-slack.herokuapp.com/) -[![Build Status](https://img.shields.io/travis/twbs/bootstrap/v4-dev.svg)](https://travis-ci.org/twbs/bootstrap) -[![npm version](https://img.shields.io/npm/v/bootstrap.svg)](https://www.npmjs.com/package/bootstrap) -[![Gem version](https://img.shields.io/gem/v/bootstrap.svg)](https://rubygems.org/gems/bootstrap) -[![Meteor Atmosphere](https://img.shields.io/badge/meteor-twbs%3Abootstrap-blue.svg)](https://atmospherejs.com/twbs/bootstrap) -[![Packagist Prerelease](https://img.shields.io/packagist/vpre/twbs/bootstrap.svg)](https://packagist.org/packages/twbs/bootstrap) -[![NuGet](https://img.shields.io/nuget/vpre/bootstrap.svg)](https://www.nuget.org/packages/bootstrap/absoluteLatest) -[![peerDependencies Status](https://img.shields.io/david/peer/twbs/bootstrap.svg)](https://david-dm.org/twbs/bootstrap?type=peer) -[![devDependency Status](https://img.shields.io/david/dev/twbs/bootstrap.svg)](https://david-dm.org/twbs/bootstrap?type=dev) -[![Coverage Status](https://img.shields.io/coveralls/github/twbs/bootstrap/v4-dev.svg)](https://coveralls.io/github/twbs/bootstrap?branch=v4-dev) -[![CSS gzip size](https://img.badgesize.io/twbs/bootstrap/v4-dev/dist/css/bootstrap.min.css?compression=gzip&label=CSS+gzip+size)](https://github.com/twbs/bootstrap/tree/v4-dev/dist/css/bootstrap.min.css) -[![JS gzip size](https://img.badgesize.io/twbs/bootstrap/v4-dev/dist/js/bootstrap.min.js?compression=gzip&label=JS+gzip+size)](https://github.com/twbs/bootstrap/tree/v4-dev/dist/js/bootstrap.min.js) +[![Build Status](https://github.com/twbs/bootstrap/workflows/JS%20Tests/badge.svg?branch=main)](https://github.com/twbs/bootstrap/actions?query=workflow%3AJS+Tests+branch%3Amain) +[![npm version](https://img.shields.io/npm/v/bootstrap)](https://www.npmjs.com/package/bootstrap) +[![Gem version](https://img.shields.io/gem/v/bootstrap)](https://rubygems.org/gems/bootstrap) +[![Meteor Atmosphere](https://img.shields.io/badge/meteor-twbs%3Abootstrap-blue)](https://atmospherejs.com/twbs/bootstrap) +[![Packagist Prerelease](https://img.shields.io/packagist/vpre/twbs/bootstrap)](https://packagist.org/packages/twbs/bootstrap) +[![NuGet](https://img.shields.io/nuget/vpre/bootstrap)](https://www.nuget.org/packages/bootstrap/absoluteLatest) +[![peerDependencies Status](https://img.shields.io/david/peer/twbs/bootstrap)](https://david-dm.org/twbs/bootstrap?type=peer) +[![devDependency Status](https://img.shields.io/david/dev/twbs/bootstrap)](https://david-dm.org/twbs/bootstrap?type=dev) +[![Coverage Status](https://img.shields.io/coveralls/github/twbs/bootstrap/main)](https://coveralls.io/github/twbs/bootstrap?branch=main) +[![CSS gzip size](https://img.badgesize.io/twbs/bootstrap/main/dist/css/bootstrap.min.css?compression=gzip&label=CSS%20gzip%20size)](https://github.com/twbs/bootstrap/blob/main/dist/css/bootstrap.min.css) +[![CSS Brotli size](https://img.badgesize.io/twbs/bootstrap/main/dist/css/bootstrap.min.css?compression=brotli&label=CSS%20Brotli%20size)](https://github.com/twbs/bootstrap/blob/main/dist/css/bootstrap.min.css) +[![JS gzip size](https://img.badgesize.io/twbs/bootstrap/main/dist/js/bootstrap.min.js?compression=gzip&label=JS%20gzip%20size)](https://github.com/twbs/bootstrap/blob/main/dist/js/bootstrap.min.js) +[![JS Brotli size](https://img.badgesize.io/twbs/bootstrap/main/dist/js/bootstrap.min.js?compression=brotli&label=JS%20Brotli%20size)](https://github.com/twbs/bootstrap/blob/main/dist/js/bootstrap.min.js) [![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=SkxZcStBeExEdVJqQ2hWYnlWckpkNmNEY213SFp6WHFETWk2bGFuY3pCbz0tLXhqbHJsVlZhQnRBdEpod3NLSDMzaHc9PQ==--3d0b75245708616eb93113221beece33e680b229)](https://www.browserstack.com/automate/public-build/SkxZcStBeExEdVJqQ2hWYnlWckpkNmNEY213SFp6WHFETWk2bGFuY3pCbz0tLXhqbHJsVlZhQnRBdEpod3NLSDMzaHc9PQ==--3d0b75245708616eb93113221beece33e680b229) -[![Backers on Open Collective](https://opencollective.com/bootstrap/backers/badge.svg)](#backers) -[![Sponsors on Open Collective](https://opencollective.com/bootstrap/sponsors/badge.svg)](#sponsors) +[![Backers on Open Collective](https://img.shields.io/opencollective/backers/bootstrap)](#backers) +[![Sponsors on Open Collective](https://img.shields.io/opencollective/sponsors/bootstrap)](#sponsors) ## What's included @@ -86,6 +93,10 @@ bootstrap/ โ”‚ โ”œโ”€โ”€ bootstrap-reboot.css.map โ”‚ โ”œโ”€โ”€ bootstrap-reboot.min.css โ”‚ โ”œโ”€โ”€ bootstrap-reboot.min.css.map + โ”‚ โ”œโ”€โ”€ bootstrap-utilities.css + โ”‚ โ”œโ”€โ”€ bootstrap-utilities.css.map + โ”‚ โ”œโ”€โ”€ bootstrap-utilities.min.css + โ”‚ โ”œโ”€โ”€ bootstrap-utilities.min.css.map โ”‚ โ”œโ”€โ”€ bootstrap.css โ”‚ โ”œโ”€โ”€ bootstrap.css.map โ”‚ โ”œโ”€โ”€ bootstrap.min.css @@ -95,54 +106,53 @@ bootstrap/ โ”œโ”€โ”€ bootstrap.bundle.js.map โ”œโ”€โ”€ bootstrap.bundle.min.js โ”œโ”€โ”€ bootstrap.bundle.min.js.map + โ”œโ”€โ”€ bootstrap.esm.js + โ”œโ”€โ”€ bootstrap.esm.js.map + โ”œโ”€โ”€ bootstrap.esm.min.js + โ”œโ”€โ”€ bootstrap.esm.min.js.map โ”œโ”€โ”€ bootstrap.js โ”œโ”€โ”€ bootstrap.js.map โ”œโ”€โ”€ bootstrap.min.js โ””โ”€โ”€ bootstrap.min.js.map ``` -We provide compiled CSS and JS (`bootstrap.*`), as well as compiled and minified CSS and JS (`bootstrap.min.*`). [source maps](https://developers.google.com/web/tools/chrome-devtools/javascript/source-maps) (`bootstrap.*.map`) are available for use with certain browsers' developer tools. Bundled JS files (`bootstrap.bundle.js` and minified `bootstrap.bundle.min.js`) include [Popper](https://popper.js.org/), but not [jQuery](https://jquery.com/). +We provide compiled CSS and JS (`bootstrap.*`), as well as compiled and minified CSS and JS (`bootstrap.min.*`). [source maps](https://developers.google.com/web/tools/chrome-devtools/javascript/source-maps) (`bootstrap.*.map`) are available for use with certain browsers' developer tools. Bundled JS files (`bootstrap.bundle.js` and minified `bootstrap.bundle.min.js`) include [Popper](https://popper.js.org/). ## Bugs and feature requests -Have a bug or a feature request? Please first read the [issue guidelines](https://github.com/twbs/bootstrap/blob/master/CONTRIBUTING.md#using-the-issue-tracker) and search for existing and closed issues. If your problem or idea is not addressed yet, [please open a new issue](https://github.com/twbs/bootstrap/issues/new). +Have a bug or a feature request? Please first read the [issue guidelines](https://github.com/twbs/bootstrap/blob/main/.github/CONTRIBUTING.md#using-the-issue-tracker) and search for existing and closed issues. If your problem or idea is not addressed yet, [please open a new issue](https://github.com/twbs/bootstrap/issues/new). ## Documentation -Bootstrap's documentation, included in this repo in the root directory, is built with [Jekyll](https://jekyllrb.com/) and publicly hosted on GitHub Pages at . The docs may also be run locally. +Bootstrap's documentation, included in this repo in the root directory, is built with [Hugo](https://gohugo.io/) and publicly hosted on GitHub Pages at . The docs may also be run locally. -Documentation search is powered by [Algolia's DocSearch](https://community.algolia.com/docsearch/). Working on our search? Be sure to set `debug: true` in `site/docs/4.3/assets/js/src/search.js` file. +Documentation search is powered by [Algolia's DocSearch](https://community.algolia.com/docsearch/). Working on our search? Be sure to set `debug: true` in `site/assets/js/src/search.js` file. ### Running documentation locally -1. Run through the [tooling setup](https://getbootstrap.com/docs/4.3/getting-started/build-tools/#tooling-setup) to install Jekyll (the site builder) and other Ruby dependencies with `bundle install`. -2. Run `npm install` to install Node.js dependencies. -3. Run `npm start` to compile CSS and JavaScript files, generate our docs, and watch for changes. -4. Open `http://localhost:9001` in your browser, and voilร . +1. Run `npm install` to install the Node.js dependencies, including Hugo (the site builder). +2. Run `npm run test` (or a specific npm script) to rebuild distributed CSS and JavaScript files, as well as our docs assets. +3. From the root `/bootstrap` directory, run `npm run docs-serve` in the command line. +4. Open `http://localhost:9001/` in your browser, and voilร . -Learn more about using Jekyll by reading its [documentation](https://jekyllrb.com/docs/). +Learn more about using Hugo by reading its [documentation](https://gohugo.io/documentation/). ### Documentation for previous releases -- For v2.3.2: -- For v3.3.x: -- For v3.4.0: -- For v4.0.x: -- For v4.1.x: -- For v4.2.x: +You can find all our previous releases docs on . [Previous releases](https://github.com/twbs/bootstrap/releases) and their documentation are also available for download. ## Contributing -Please read through our [contributing guidelines](https://github.com/twbs/bootstrap/blob/master/CONTRIBUTING.md). Included are directions for opening issues, coding standards, and notes on development. +Please read through our [contributing guidelines](https://github.com/twbs/bootstrap/blob/main/.github/CONTRIBUTING.md). Included are directions for opening issues, coding standards, and notes on development. -Moreover, if your pull request contains JavaScript patches or features, you must include [relevant unit tests](https://github.com/twbs/bootstrap/tree/master/js/tests). All HTML and CSS should conform to the [Code Guide](https://github.com/mdo/code-guide), maintained by [Mark Otto](https://github.com/mdo). +Moreover, if your pull request contains JavaScript patches or features, you must include [relevant unit tests](https://github.com/twbs/bootstrap/tree/main/js/tests). All HTML and CSS should conform to the [Code Guide](https://github.com/mdo/code-guide), maintained by [Mark Otto](https://github.com/mdo). -Editor preferences are available in the [editor config](https://github.com/twbs/bootstrap/blob/master/.editorconfig) for easy use in common text editors. Read more and download plugins at . +Editor preferences are available in the [editor config](https://github.com/twbs/bootstrap/blob/main/.editorconfig) for easy use in common text editors. Read more and download plugins at . ## Community @@ -153,7 +163,7 @@ Get updates on Bootstrap's development and chat with the project maintainers and - Read and subscribe to [The Official Bootstrap Blog](https://blog.getbootstrap.com/). - Join [the official Slack room](https://bootstrap-slack.herokuapp.com/). - Chat with fellow Bootstrappers in IRC. On the `irc.freenode.net` server, in the `##bootstrap` channel. -- Implementation help may be found at Stack Overflow (tagged [`bootstrap-4`](https://stackoverflow.com/questions/tagged/bootstrap-4)). +- Implementation help may be found at Stack Overflow (tagged [`bootstrap-5`](https://stackoverflow.com/questions/tagged/bootstrap-5)). - Developers should use the keyword `bootstrap` on packages which modify or add to the functionality of Bootstrap when distributing through [npm](https://www.npmjs.com/browse/keyword/bootstrap) or similar delivery mechanisms for maximum discoverability. @@ -186,29 +196,29 @@ See [the Releases section of our GitHub project](https://github.com/twbs/bootstr Thanks to [BrowserStack](https://www.browserstack.com/) for providing the infrastructure that allows us to test in real browsers! -## Backers +## Sponsors -Thank you to all our backers! ๐Ÿ™ [[Become a backer](https://opencollective.com/bootstrap#backer)] +Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/bootstrap#sponsor)] -[![Bakers](https://opencollective.com/bootstrap/backers.svg?width=890)](https://opencollective.com/bootstrap#backers) +[![OC sponsor 0](https://opencollective.com/bootstrap/sponsor/0/avatar.svg)](https://opencollective.com/bootstrap/sponsor/0/website) +[![OC sponsor 1](https://opencollective.com/bootstrap/sponsor/1/avatar.svg)](https://opencollective.com/bootstrap/sponsor/1/website) +[![OC sponsor 2](https://opencollective.com/bootstrap/sponsor/2/avatar.svg)](https://opencollective.com/bootstrap/sponsor/2/website) +[![OC sponsor 3](https://opencollective.com/bootstrap/sponsor/3/avatar.svg)](https://opencollective.com/bootstrap/sponsor/3/website) +[![OC sponsor 4](https://opencollective.com/bootstrap/sponsor/4/avatar.svg)](https://opencollective.com/bootstrap/sponsor/4/website) +[![OC sponsor 5](https://opencollective.com/bootstrap/sponsor/5/avatar.svg)](https://opencollective.com/bootstrap/sponsor/5/website) +[![OC sponsor 6](https://opencollective.com/bootstrap/sponsor/6/avatar.svg)](https://opencollective.com/bootstrap/sponsor/6/website) +[![OC sponsor 7](https://opencollective.com/bootstrap/sponsor/7/avatar.svg)](https://opencollective.com/bootstrap/sponsor/7/website) +[![OC sponsor 8](https://opencollective.com/bootstrap/sponsor/8/avatar.svg)](https://opencollective.com/bootstrap/sponsor/8/website) +[![OC sponsor 9](https://opencollective.com/bootstrap/sponsor/9/avatar.svg)](https://opencollective.com/bootstrap/sponsor/9/website) -## Sponsors +## Backers -Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/bootstrap#sponsor)] +Thank you to all our backers! ๐Ÿ™ [[Become a backer](https://opencollective.com/bootstrap#backer)] -[![](https://opencollective.com/bootstrap/sponsor/0/avatar.svg)](https://opencollective.com/bootstrap/sponsor/0/website) -[![](https://opencollective.com/bootstrap/sponsor/1/avatar.svg)](https://opencollective.com/bootstrap/sponsor/1/website) -[![](https://opencollective.com/bootstrap/sponsor/2/avatar.svg)](https://opencollective.com/bootstrap/sponsor/2/website) -[![](https://opencollective.com/bootstrap/sponsor/3/avatar.svg)](https://opencollective.com/bootstrap/sponsor/3/website) -[![](https://opencollective.com/bootstrap/sponsor/4/avatar.svg)](https://opencollective.com/bootstrap/sponsor/4/website) -[![](https://opencollective.com/bootstrap/sponsor/5/avatar.svg)](https://opencollective.com/bootstrap/sponsor/5/website) -[![](https://opencollective.com/bootstrap/sponsor/6/avatar.svg)](https://opencollective.com/bootstrap/sponsor/6/website) -[![](https://opencollective.com/bootstrap/sponsor/7/avatar.svg)](https://opencollective.com/bootstrap/sponsor/7/website) -[![](https://opencollective.com/bootstrap/sponsor/8/avatar.svg)](https://opencollective.com/bootstrap/sponsor/8/website) -[![](https://opencollective.com/bootstrap/sponsor/9/avatar.svg)](https://opencollective.com/bootstrap/sponsor/9/website) +[![Backers](https://opencollective.com/bootstrap/backers.svg?width=890)](https://opencollective.com/bootstrap#backers) ## Copyright and license -Code and documentation copyright 2011-2019 the [Bootstrap Authors](https://github.com/twbs/bootstrap/graphs/contributors) and [Twitter, Inc.](https://twitter.com) Code released under the [MIT License](https://github.com/twbs/bootstrap/blob/master/LICENSE). Docs released under [Creative Commons](https://github.com/twbs/bootstrap/blob/master/docs/LICENSE). +Code and documentation copyright 2011โ€“2020 the [Bootstrap Authors](https://github.com/twbs/bootstrap/graphs/contributors) and [Twitter, Inc.](https://twitter.com) Code released under the [MIT License](https://github.com/twbs/bootstrap/blob/main/LICENSE). Docs released under [Creative Commons](https://creativecommons.org/licenses/by/3.0/). diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000000..e79dcd8d2038 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,7 @@ +# Reporting Security Issues + +The Bootstrap team and community take security issues in Bootstrap seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions. + +To report a security issue, email [security@getbootstrap.com](mailto:security@getbootstrap.com) and include the word "SECURITY" in the subject line. + +We'll endeavor to respond quickly, and will keep you updated throughout the process. diff --git a/_config.yml b/_config.yml deleted file mode 100644 index 7aa8f5d5cede..000000000000 --- a/_config.yml +++ /dev/null @@ -1,68 +0,0 @@ -# Dependencies -markdown: kramdown -highlighter: rouge - -kramdown: - auto_ids: true - -# Permalinks -permalink: pretty - -# Server -source: "site" -destination: ./_gh_pages -host: "localhost" -port: 9001 -baseurl: "" -url: "https://getbootstrap.com" -encoding: UTF-8 -exclude: - - docs/4.3/assets/scss/ - -plugins: - - jekyll-redirect-from - - jekyll-sitemap - - jekyll-toc - -# Social -title: Bootstrap -description: "The most popular HTML, CSS, and JS library in the world." -twitter: getbootstrap -authors: "Mark Otto, Jacob Thornton, and Bootstrap contributors" -social_image_path: /docs/4.3/assets/brand/bootstrap-social.png -social_logo_path: /docs/4.3/assets/brand/bootstrap-social-logo.png - -# Custom variables -current_version: 4.3.1 -current_ruby_version: 4.3.1 -docs_version: 4.3 -repo: "https://github.com/twbs/bootstrap" -slack: "https://bootstrap-slack.herokuapp.com" -opencollective: "https://opencollective.com/bootstrap" -blog: "https://blog.getbootstrap.com" -expo: "https://expo.getbootstrap.com" -themes: "https://themes.getbootstrap.com" - -download: - source: "https://github.com/twbs/bootstrap/archive/v4.3.1.zip" - dist: "https://github.com/twbs/bootstrap/releases/download/v4.3.1/bootstrap-4.3.1-dist.zip" - -cdn: - # See https://www.srihash.org for info on how to generate the hashes - css: "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" - css_hash: "sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" - js: "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" - js_hash: "sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" - js_bundle: "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js" - js_bundle_hash: "sha384-xrRywqdh3PHs8keKZN+8zzc5TX0GRTLCcmivcbNJWm2rs5C8PRhcEn3czEjhAO9o" - jquery: "https://code.jquery.com/jquery-3.3.1.slim.min.js" - jquery_hash: "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" - popper: "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" - popper_hash: "sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" - -toc: - min_level: 2 - max_level: 4 - no_toc_section_class: - - "bd-callout" - - "bd-example" diff --git a/build/.eslintrc.json b/build/.eslintrc.json index 76e7f37b6348..679bd26f7ba2 100644 --- a/build/.eslintrc.json +++ b/build/.eslintrc.json @@ -8,13 +8,7 @@ }, "extends": "../.eslintrc.json", "rules": { - "consistent-return": "off", - "func-style": "off", "no-console": "off", - "no-magic-numbers": "off", - "no-process-env": "off", - "no-process-exit": "off", - "no-sync": "off", - "spaced-comment": "off" + "strict": "error" } } diff --git a/build/banner.js b/build/banner.js index 453fc3b6e0b2..df82ff32edf3 100644 --- a/build/banner.js +++ b/build/banner.js @@ -7,7 +7,7 @@ function getBanner(pluginFilename) { return `/*! * Bootstrap${pluginFilename ? ` ${pluginFilename}` : ''} v${pkg.version} (${pkg.homepage}) * Copyright 2011-${year} ${pkg.author} - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */` } diff --git a/build/build-plugins.js b/build/build-plugins.js index abcbc5e2f577..c5c357645bc7 100644 --- a/build/build-plugins.js +++ b/build/build-plugins.js @@ -1,31 +1,33 @@ +#!/usr/bin/env node + /*! * Script to build our plugins to use them separately. - * Copyright 2019 The Bootstrap Authors - * Copyright 2019 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * Copyright 2020 The Bootstrap Authors + * Copyright 2020 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ 'use strict' -const path = require('path') -const rollup = require('rollup') -const babel = require('rollup-plugin-babel') -const banner = require('./banner.js') +const path = require('path') +const rollup = require('rollup') +const { babel } = require('@rollup/plugin-babel') +const banner = require('./banner.js') -const TEST = process.env.NODE_ENV === 'test' const plugins = [ babel({ - exclude: 'node_modules/**', // Only transpile our source code - externalHelpersWhitelist: [ // Include only required helpers - 'defineProperties', - 'createClass', - 'inheritsLoose', - 'defineProperty', - 'objectSpread' - ] + // Only transpile our source code + exclude: 'node_modules/**', + // Inline the required helpers in each file + babelHelpers: 'inline' }) ] const bsPlugins = { + Data: path.resolve(__dirname, '../js/src/dom/data.js'), + EventHandler: path.resolve(__dirname, '../js/src/dom/event-handler.js'), + Manipulator: path.resolve(__dirname, '../js/src/dom/manipulator.js'), + Polyfill: path.resolve(__dirname, '../js/src/dom/polyfill.js'), + SelectorEngine: path.resolve(__dirname, '../js/src/dom/selector-engine.js'), Alert: path.resolve(__dirname, '../js/src/alert.js'), Button: path.resolve(__dirname, '../js/src/button.js'), Carousel: path.resolve(__dirname, '../js/src/carousel.js'), @@ -36,50 +38,151 @@ const bsPlugins = { ScrollSpy: path.resolve(__dirname, '../js/src/scrollspy.js'), Tab: path.resolve(__dirname, '../js/src/tab.js'), Toast: path.resolve(__dirname, '../js/src/toast.js'), - Tooltip: path.resolve(__dirname, '../js/src/tooltip.js'), - Util: path.resolve(__dirname, '../js/src/util.js') + Tooltip: path.resolve(__dirname, '../js/src/tooltip.js') } -const rootPath = TEST ? '../js/coverage/dist/' : '../js/dist/' +const rootPath = path.resolve(__dirname, '../js/dist/') -function build(plugin) { - console.log(`Building ${plugin} plugin...`) +const defaultPluginConfig = { + external: [ + bsPlugins.Data, + bsPlugins.EventHandler, + bsPlugins.SelectorEngine + ], + globals: { + [bsPlugins.Data]: 'Data', + [bsPlugins.EventHandler]: 'EventHandler', + [bsPlugins.SelectorEngine]: 'SelectorEngine' + } +} + +const getConfigByPluginKey = pluginKey => { + if ( + pluginKey === 'Data' || + pluginKey === 'Manipulator' || + pluginKey === 'EventHandler' || + pluginKey === 'Polyfill' || + pluginKey === 'SelectorEngine' || + pluginKey === 'Util' || + pluginKey === 'Sanitizer' + ) { + return { + external: [bsPlugins.Polyfill], + globals: { + [bsPlugins.Polyfill]: 'Polyfill' + } + } + } + + if (pluginKey === 'Alert' || pluginKey === 'Tab') { + return defaultPluginConfig + } + + if ( + pluginKey === 'Button' || + pluginKey === 'Carousel' || + pluginKey === 'Collapse' || + pluginKey === 'Modal' || + pluginKey === 'ScrollSpy' + ) { + const config = Object.assign(defaultPluginConfig) + config.external.push(bsPlugins.Manipulator) + config.globals[bsPlugins.Manipulator] = 'Manipulator' + return config + } - const external = ['jquery', 'popper.js'] - const globals = { - jquery: 'jQuery', // Ensure we use jQuery which is always available even in noConflict mode - 'popper.js': 'Popper' + if (pluginKey === 'Dropdown' || pluginKey === 'Tooltip') { + const config = Object.assign(defaultPluginConfig) + config.external.push(bsPlugins.Manipulator, 'popper.js') + config.globals[bsPlugins.Manipulator] = 'Manipulator' + config.globals['popper.js'] = 'Popper' + return config } - // Do not bundle Util in plugins - if (plugin !== 'Util') { - external.push(bsPlugins.Util) - globals[bsPlugins.Util] = 'Util' + if (pluginKey === 'Popover') { + return { + external: [ + bsPlugins.Data, + bsPlugins.SelectorEngine, + bsPlugins.Tooltip + ], + globals: { + [bsPlugins.Data]: 'Data', + [bsPlugins.SelectorEngine]: 'SelectorEngine', + [bsPlugins.Tooltip]: 'Tooltip' + } + } } - // Do not bundle Tooltip in Popover - if (plugin === 'Popover') { - external.push(bsPlugins.Tooltip) - globals[bsPlugins.Tooltip] = 'Tooltip' + if (pluginKey === 'Toast') { + return { + external: [ + bsPlugins.Data, + bsPlugins.EventHandler, + bsPlugins.Manipulator + ], + globals: { + [bsPlugins.Data]: 'Data', + [bsPlugins.EventHandler]: 'EventHandler', + [bsPlugins.Manipulator]: 'Manipulator' + } + } + } +} + +const utilObjects = [ + 'Util', + 'Sanitizer' +] + +const domObjects = [ + 'Data', + 'EventHandler', + 'Manipulator', + 'Polyfill', + 'SelectorEngine' +] + +const build = async plugin => { + console.log(`Building ${plugin} plugin...`) + + const { external, globals } = getConfigByPluginKey(plugin) + const pluginFilename = path.basename(bsPlugins[plugin]) + let pluginPath = rootPath + + if (utilObjects.includes(plugin)) { + pluginPath = `${rootPath}/util/` } - const pluginFilename = `${plugin.toLowerCase()}.js` + if (domObjects.includes(plugin)) { + pluginPath = `${rootPath}/dom/` + } - rollup.rollup({ + const bundle = await rollup.rollup({ input: bsPlugins[plugin], plugins, external - }).then((bundle) => { - bundle.write({ - banner: banner(pluginFilename), - format: 'umd', - name: plugin, - sourcemap: true, - globals, - file: path.resolve(__dirname, `${rootPath}${pluginFilename}`) - }) - .then(() => console.log(`Building ${plugin} plugin... Done!`)) - .catch((err) => console.error(`${plugin}: ${err}`)) }) + + await bundle.write({ + banner: banner(pluginFilename), + format: 'umd', + name: plugin, + sourcemap: true, + globals, + file: path.resolve(__dirname, `${pluginPath}/${pluginFilename}`) + }) + + console.log(`Building ${plugin} plugin... Done!`) +} + +const main = async () => { + try { + await Promise.all(Object.keys(bsPlugins).map(plugin => build(plugin))) + } catch (error) { + console.error(error) + + process.exit(1) + } } -Object.keys(bsPlugins).forEach((plugin) => build(plugin)) +main() diff --git a/build/change-version.js b/build/change-version.js old mode 100755 new mode 100644 index f1b4f747a784..b8a640fa8ee3 --- a/build/change-version.js +++ b/build/change-version.js @@ -2,9 +2,9 @@ /*! * Script to update version number references in the project. - * Copyright 2017-2019 The Bootstrap Authors - * Copyright 2017-2019 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * Copyright 2017-2020 The Bootstrap Authors + * Copyright 2017-2020 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ 'use strict' @@ -17,11 +17,11 @@ sh.config.fatal = true // Blame TC39... https://github.com/benjamingr/RegExp.escape/issues/37 function regExpQuote(string) { - return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&') + return string.replace(/[$()*+-.?[\\\]^{|}]/g, '\\$&') } function regExpQuoteReplacement(string) { - return string.replace(/[$]/g, '$$') + return string.replace(/\$/g, '$$') } const DRY_RUN = false @@ -30,18 +30,21 @@ function walkAsync(directory, excludedDirectories, fileCallback, errback) { if (excludedDirectories.has(path.parse(directory).base)) { return } + fs.readdir(directory, (err, names) => { if (err) { errback(err) return } - names.forEach((name) => { + + names.forEach(name => { const filepath = path.join(directory, name) fs.lstat(filepath, (err, stats) => { if (err) { process.nextTick(errback, err) return } + if (stats.isDirectory()) { process.nextTick(walkAsync, filepath, excludedDirectories, fileCallback, errback) } else if (stats.isFile()) { @@ -55,18 +58,21 @@ function walkAsync(directory, excludedDirectories, fileCallback, errback) { function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) { original = new RegExp(regExpQuote(original), 'g') replacement = regExpQuoteReplacement(replacement) - const updateFile = DRY_RUN ? (filepath) => { - if (allowedExtensions.has(path.parse(filepath).ext)) { - console.log(`FILE: ${filepath}`) - } else { - console.log(`EXCLUDED:${filepath}`) - } - } : (filepath) => { - if (allowedExtensions.has(path.parse(filepath).ext)) { - sh.sed('-i', original, replacement, filepath) + const updateFile = DRY_RUN ? + filepath => { + if (allowedExtensions.has(path.parse(filepath).ext)) { + console.log(`FILE: ${filepath}`) + } else { + console.log(`EXCLUDED:${filepath}`) + } + } : + filepath => { + if (allowedExtensions.has(path.parse(filepath).ext)) { + sh.sed('-i', original, replacement, filepath) + } } - } - walkAsync(directory, excludedDirectories, updateFile, (err) => { + + walkAsync(directory, excludedDirectories, updateFile, err => { console.error('ERROR while traversing directory!:') console.error(err) process.exit(1) @@ -79,15 +85,17 @@ function main(args) { console.error('Got arguments:', args) process.exit(1) } + const oldVersion = args[0] const newVersion = args[1] const EXCLUDED_DIRS = new Set([ '.git', + '_gh_pages', 'node_modules', 'vendor' ]) const INCLUDED_EXTENSIONS = new Set([ - // This extension whitelist is how we avoid modifying binary files + // This extension allowlist is how we avoid modifying binary files '', '.css', '.html', diff --git a/build/generate-sri.js b/build/generate-sri.js index a93f3e538d8c..cfbf3777161e 100644 --- a/build/generate-sri.js +++ b/build/generate-sri.js @@ -5,9 +5,9 @@ * Remember to use the same vendor files as the CDN ones, * otherwise the hashes won't match! * - * Copyright 2017-2019 The Bootstrap Authors - * Copyright 2017-2019 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * Copyright 2017-2020 The Bootstrap Authors + * Copyright 2017-2020 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ 'use strict' @@ -17,15 +17,13 @@ const fs = require('fs') const path = require('path') const sh = require('shelljs') -const pkg = require('../package.json') - sh.config.fatal = true -const configFile = path.join(__dirname, '../_config.yml') +const configFile = path.join(__dirname, '../config.yml') // Array of objects which holds the files to generate SRI hashes for. // `file` is the path from the root folder -// `configPropertyName` is the _config.yml variable's name of the file +// `configPropertyName` is the config.yml variable's name of the file const files = [ { file: 'dist/css/bootstrap.min.css', @@ -39,17 +37,13 @@ const files = [ file: 'dist/js/bootstrap.bundle.min.js', configPropertyName: 'js_bundle_hash' }, - { - file: `site/docs/${pkg.version_short}/assets/js/vendor/jquery-slim.min.js`, - configPropertyName: 'jquery_hash' - }, { file: 'node_modules/popper.js/dist/umd/popper.min.js', configPropertyName: 'popper_hash' } ] -files.forEach((file) => { +files.forEach(file => { fs.readFile(file.file, 'utf8', (err, data) => { if (err) { throw err diff --git a/build/postcss.config.js b/build/postcss.config.js index 157291ffd2e2..56b7d94cc1fa 100644 --- a/build/postcss.config.js +++ b/build/postcss.config.js @@ -1,11 +1,13 @@ 'use strict' -module.exports = (ctx) => ({ - map: ctx.file.dirname.includes('examples') ? false : { - inline: false, - annotation: true, - sourcesContent: true - }, +module.exports = ctx => ({ + map: ctx.file.dirname.includes('examples') ? + false : + { + inline: false, + annotation: true, + sourcesContent: true + }, plugins: { autoprefixer: { cascade: false diff --git a/build/rollup.config.js b/build/rollup.config.js index e81a07ef58b2..1ee67455232f 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -1,48 +1,49 @@ 'use strict' -const path = require('path') -const babel = require('rollup-plugin-babel') -const resolve = require('rollup-plugin-node-resolve') -const banner = require('./banner.js') +const path = require('path') +const { babel } = require('@rollup/plugin-babel') +const { nodeResolve } = require('@rollup/plugin-node-resolve') +const banner = require('./banner.js') -const BUNDLE = process.env.BUNDLE === 'true' +const BUNDLE = process.env.BUNDLE === 'true' +const ESM = process.env.ESM === 'true' -let fileDest = 'bootstrap.js' -const external = ['jquery', 'popper.js'] +let fileDest = `bootstrap${ESM ? '.esm' : ''}` +const external = ['popper.js'] const plugins = [ babel({ - exclude: 'node_modules/**', // Only transpile our source code - externalHelpersWhitelist: [ // Include only required helpers - 'defineProperties', - 'createClass', - 'inheritsLoose', - 'defineProperty', - 'objectSpread' - ] + // Only transpile our source code + exclude: 'node_modules/**', + // Include the helpers in the bundle, at most one copy of each + babelHelpers: 'bundled' }) ] const globals = { - jquery: 'jQuery', // Ensure we use jQuery which is always available even in noConflict mode 'popper.js': 'Popper' } if (BUNDLE) { - fileDest = 'bootstrap.bundle.js' + fileDest += '.bundle' // Remove last entry in external array to bundle Popper external.pop() delete globals['popper.js'] - plugins.push(resolve()) + plugins.push(nodeResolve()) } -module.exports = { - input: path.resolve(__dirname, '../js/src/index.js'), +const rollupConfig = { + input: path.resolve(__dirname, `../js/index.${ESM ? 'esm' : 'umd'}.js`), output: { banner, - file: path.resolve(__dirname, `../dist/js/${fileDest}`), - format: 'umd', - globals, - name: 'bootstrap' + file: path.resolve(__dirname, `../dist/js/${fileDest}.js`), + format: ESM ? 'esm' : 'umd', + globals }, external, plugins } + +if (!ESM) { + rollupConfig.output.name = 'bootstrap' +} + +module.exports = rollupConfig diff --git a/build/ship.sh b/build/ship.sh old mode 100755 new mode 100644 index 2892843839cd..da5a03bcd15c --- a/build/ship.sh +++ b/build/ship.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash + +set -e + # # Usage # --------------- @@ -18,35 +21,35 @@ end=$'\e[0m' current_version=$(node -p "require('./package.json').version") if [[ $# -lt 1 ]]; then - printf "\n%sโš ๏ธ Shipping aborted. You must specify a version.\n%s" $red $end + printf "\n%sโš ๏ธ Shipping aborted. You must specify a version.\n%s" "$red" "$end" exit 1 fi # Pulling latest changes, just to be sure -printf "\n%s=======================================================%s" $magenta $end -printf "\n%sPulling latest changes...%s" $magenta $end -printf "\n%s=======================================================\n\n%s" $magenta $end -git pull origin v4-dev +printf "\n%s=======================================================%s" "$magenta" "$end" +printf "\n%sPulling latest changes...%s" "$magenta" "$end" +printf "\n%s=======================================================\n\n%s" "$magenta" "$end" +git pull origin main # Update version number -printf "\n%s=======================================================%s" $magenta $end -printf "\n%sUpdating version number...%s" $magenta $end -printf "\n%s=======================================================\n%s" $magenta $end +printf "\n%s=======================================================%s" "$magenta" "$end" +printf "\n%sUpdating version number...%s" "$magenta" "$end" +printf "\n%s=======================================================\n%s" "$magenta" "$end" npm run release-version "$current_version" "$1" # Build release -printf "\n%s=======================================================%s" $magenta $end -printf "\n%sBuilding release...%s" $magenta $end -printf "\n%s=======================================================\n%s" $magenta $end +printf "\n%s=======================================================%s" "$magenta" "$end" +printf "\n%sBuilding release...%s" "$magenta" "$end" +printf "\n%s=======================================================\n%s" "$magenta" "$end" npm run release # Copy the contents of the built docs site over to `bs-docs` repo -printf "\n%s=======================================================%s" $magenta $end -printf "\n%sCopy it over...%s" $magenta $end -printf "\n%s=======================================================\n%s" $magenta $end +printf "\n%s=======================================================%s" "$magenta" "$end" +printf "\n%sCopy it over...%s" "$magenta" "$end" +printf "\n%s=======================================================\n%s" "$magenta" "$end" cp -rf _gh_pages/. ../bs-docs/ printf "\nDone!\n" -printf "\n%s=======================================================%s" $green $end -printf "\n%sSuccess, $1 is ready to review and publish.%s" $green $end -printf "\n%s=======================================================\n\n%s" $green $end +printf "\n%s=======================================================%s" "$green" "$end" +printf "\n%sSuccess, $1 is ready to review and publish.%s" "$green" "$end" +printf "\n%s=======================================================\n\n%s" "$green" "$end" diff --git a/build/svgo.yml b/build/svgo.yml index 047e6947f0ce..67940d393ee3 100644 --- a/build/svgo.yml +++ b/build/svgo.yml @@ -15,10 +15,9 @@ js2svg: indent: 2 plugins: - # remove this with IE 11 is no longer supported - - addAttributesToSVGElement: - attributes: - - focusable: false +# - addAttributesToSVGElement: +# attributes: +# - focusable: false - cleanupAttrs: true - cleanupEnableBackground: true - cleanupIDs: true @@ -35,6 +34,9 @@ plugins: - minifyStyles: true - moveElemsAttrsToGroup: true - moveGroupAttrsToElems: true + - removeAttrs: + attrs: + - "data-name" - removeComments: true - removeDesc: true - removeDoctype: true diff --git a/build/vnu-jar.js b/build/vnu-jar.js index 7d549cb01913..90c1a12ab9c5 100644 --- a/build/vnu-jar.js +++ b/build/vnu-jar.js @@ -2,9 +2,9 @@ /*! * Script to run vnu-jar if Java is available. - * Copyright 2017-2019 The Bootstrap Authors - * Copyright 2017-2019 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * Copyright 2017-2020 The Bootstrap Authors + * Copyright 2017-2020 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ 'use strict' @@ -18,7 +18,7 @@ childProcess.exec('java -version', (error, stdout, stderr) => { return } - const is32bitJava = !stderr.match(/64-Bit/) + const is32bitJava = !/64-Bit/.test(stderr) // vnu-jar accepts multiple ignores joined with a `|`. // Also note that the ignores are regular expressions. @@ -33,12 +33,11 @@ childProcess.exec('java -version', (error, stdout, stderr) => { // Content โ†’ Reboot uses various date/time inputs as a visual example. // Documentation does not rely on them being usable. 'The โ€œdateโ€ input type is not supported in all browsers.*', - 'The โ€œtimeโ€ input type is not supported in all browsers.*', - // IE11 doesn't recognise
/ give the element an implicit "main" landmark. - // Explicit role="main" is redundant for other modern browsers, but still valid. - 'The โ€œmainโ€ role is unnecessary for element โ€œmainโ€.', - // Ignore the wrong lanuage code warnings for now; they happen randomly. - 'This document appears to be written in.*' + 'The โ€œweekโ€ input type is not supported in all browsers.*', + 'The โ€œmonthโ€ input type is not supported in all browsers.*', + 'The โ€œcolorโ€ input type is not supported in all browsers.*', + 'The โ€œdatetime-localโ€ input type is not supported in all browsers.*', + 'The โ€œtimeโ€ input type is not supported in all browsers.*' ].join('|') const args = [ @@ -46,6 +45,8 @@ childProcess.exec('java -version', (error, stdout, stderr) => { vnu, '--asciiquotes', '--skip-non-html', + // Ignore the language code warnings + '--no-langdetect', '--Werror', `--filterpattern "${ignores}"`, '_gh_pages/', diff --git a/build/zip-examples.js b/build/zip-examples.js new file mode 100644 index 000000000000..bf50a0af6fe9 --- /dev/null +++ b/build/zip-examples.js @@ -0,0 +1,59 @@ +#!/usr/bin/env node + +/*! + * Script to create the built examples zip archive; + * requires the `zip` command to be present! + * Copyright 2020 The Bootstrap Authors + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ + +'use strict' + +const path = require('path') +const sh = require('shelljs') + +const { version, version_short: versionShort } = require('../package.json') + +const folderName = `bootstrap-${version}-examples` + +sh.config.fatal = true + +if (!sh.test('-d', '_gh_pages')) { + throw new Error('The "_gh_pages" folder does not exist, did you forget building the docs?') +} + +// switch to the root dir +sh.cd(path.join(__dirname, '..')) + +// remove any previously created folder with the same name +sh.rm('-rf', folderName) +// create any folders so that `cp` works +sh.mkdir('-p', folderName) +sh.mkdir('-p', `${folderName}/assets/brand/`) + +sh.cp('-Rf', `_gh_pages/docs/${versionShort}/examples/*`, folderName) +sh.cp('-Rf', `_gh_pages/docs/${versionShort}/dist/`, `${folderName}/assets/`) +// also copy the two brand images we use in the examples +sh.cp('-f', [ + `_gh_pages/docs/${versionShort}/assets/brand/bootstrap-logo.svg`, + `_gh_pages/docs/${versionShort}/assets/brand/bootstrap-logo-white.svg` +], `${folderName}/assets/brand/`) +sh.rm(`${folderName}/index.html`) + +// get all examples' HTML files +sh.find(`${folderName}/**/*.html`).forEach(file => { + const fileContents = sh.cat(file) + .toString() + .replace(new RegExp(`"/docs/${versionShort}/`, 'g'), '"../') + .replace(/"..\/dist\//g, '"../assets/dist/') + .replace(/(/g, '$1>') + .replace(/(') + .replace(/( +) 'click') - if (!floatTransitionDuration && !floatTransitionDelay) { - return 0; - } // If multiple durations are defined, take the first + var typeEvent = originalTypeEvent.replace(stripNameRegex, ''); + var custom = customEvents[typeEvent]; + if (custom) { + typeEvent = custom; + } - transitionDuration = transitionDuration.split(',')[0]; - transitionDelay = transitionDelay.split(',')[0]; - return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER; - }, - reflow: function reflow(element) { - return element.offsetHeight; - }, - triggerTransitionEnd: function triggerTransitionEnd(element) { - $(element).trigger(TRANSITION_END); - }, - // TODO: Remove in v5 - supportsTransitionEnd: function supportsTransitionEnd() { - return Boolean(TRANSITION_END); + var isNative = nativeEvents.indexOf(typeEvent) > -1; + + 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; + } + + var _normalizeParams = normalizeParams(originalTypeEvent, handler, delegationFn), + delegation = _normalizeParams[0], + originalHandler = _normalizeParams[1], + typeEvent = _normalizeParams[2]; + + var events = getEvent(element); + var handlers = events[typeEvent] || (events[typeEvent] = {}); + var previousFn = findHandler(handlers, originalHandler, delegation ? handler : null); + + if (previousFn) { + previousFn.oneOff = previousFn.oneOff && oneOff; + return; + } + + var uid = getUidEvent(originalHandler, originalTypeEvent.replace(namespaceRegex, '')); + var 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) { + var 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) { + var storeElementEvent = events[typeEvent] || {}; + Object.keys(storeElementEvent).forEach(function (handlerKey) { + if (handlerKey.indexOf(namespace) > -1) { + var event = storeElementEvent[handlerKey]; + removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector); + } + }); + } + + var EventHandler = { + on: function on(element, event, handler, delegationFn) { + addHandler(element, event, handler, delegationFn, false); }, - isElement: function isElement(obj) { - return (obj[0] || obj).nodeType; + one: function one(element, event, handler, delegationFn) { + addHandler(element, event, handler, delegationFn, true); }, - typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) { - for (var property in configTypes) { - if (Object.prototype.hasOwnProperty.call(configTypes, property)) { - var expectedTypes = configTypes[property]; - var value = config[property]; - var valueType = value && Util.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 + "\".")); - } + off: function off(element, originalTypeEvent, handler, delegationFn) { + if (typeof originalTypeEvent !== 'string' || !element) { + return; + } + + var _normalizeParams2 = normalizeParams(originalTypeEvent, handler, delegationFn), + delegation = _normalizeParams2[0], + originalHandler = _normalizeParams2[1], + typeEvent = _normalizeParams2[2]; + + var inNamespace = typeEvent !== originalTypeEvent; + var events = getEvent(element); + var isNamespace = originalTypeEvent.charAt(0) === '.'; + + 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(function (elementEvent) { + removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1)); + }); } + + var storeElementEvent = events[typeEvent] || {}; + Object.keys(storeElementEvent).forEach(function (keyHandlers) { + var handlerKey = keyHandlers.replace(stripUidRegex, ''); + + if (!inNamespace || originalTypeEvent.indexOf(handlerKey) > -1) { + var event = storeElementEvent[keyHandlers]; + removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector); + } + }); }, - findShadowRoot: function findShadowRoot(element) { - if (!document.documentElement.attachShadow) { + trigger: function trigger(element, event, args) { + if (typeof event !== 'string' || !element) { return null; - } // Can find the shadow root otherwise it'll return the document + } + var typeEvent = event.replace(stripNameRegex, ''); + var inNamespace = event !== typeEvent; + var isNative = nativeEvents.indexOf(typeEvent) > -1; + var jQueryEvent; + var bubbles = true; + var nativeDispatch = true; + var defaultPrevented = false; + var evt = null; - if (typeof element.getRootNode === 'function') { - var root = element.getRootNode(); - return root instanceof ShadowRoot ? root : null; + if (inNamespace && $) { + jQueryEvent = $.Event(event, args); + $(element).trigger(jQueryEvent); + bubbles = !jQueryEvent.isPropagationStopped(); + nativeDispatch = !jQueryEvent.isImmediatePropagationStopped(); + defaultPrevented = jQueryEvent.isDefaultPrevented(); } - if (element instanceof ShadowRoot) { - return element; - } // when we don't find a shadow root + if (isNative) { + evt = document.createEvent('HTMLEvents'); + evt.initEvent(typeEvent, bubbles, true); + } else { + evt = new CustomEvent(event, { + bubbles: bubbles, + cancelable: true + }); + } // merge custom information in our event - if (!element.parentNode) { - return null; + if (typeof args !== 'undefined') { + Object.keys(args).forEach(function (key) { + Object.defineProperty(evt, key, { + get: function get() { + return args[key]; + } + }); + }); } - return Util.findShadowRoot(element.parentNode); + if (defaultPrevented) { + evt.preventDefault(); + + if (!defaultPreventedPreservedOnDispatch) { + Object.defineProperty(evt, 'defaultPrevented', { + get: function get() { + return true; + } + }); + } + } + + if (nativeDispatch) { + element.dispatchEvent(evt); + } + + if (evt.defaultPrevented && typeof jQueryEvent !== 'undefined') { + jQueryEvent.preventDefault(); + } + + return evt; } }; - setTransitionEndSupport(); /** * ------------------------------------------------------------------------ @@ -229,36 +653,30 @@ */ var NAME = 'alert'; - var VERSION = '4.3.1'; + var VERSION = '5.0.0-alpha2'; var DATA_KEY = 'bs.alert'; var EVENT_KEY = "." + DATA_KEY; var DATA_API_KEY = '.data-api'; - var JQUERY_NO_CONFLICT = $.fn[NAME]; - var Selector = { - DISMISS: '[data-dismiss="alert"]' - }; - var Event = { - CLOSE: "close" + EVENT_KEY, - CLOSED: "closed" + EVENT_KEY, - CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY - }; - var ClassName = { - ALERT: 'alert', - FADE: 'fade', - SHOW: 'show' - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ - - }; + 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; + var CLASSNAME_ALERT = 'alert'; + var CLASSNAME_FADE = 'fade'; + var CLASSNAME_SHOW = 'show'; + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - var Alert = - /*#__PURE__*/ - function () { + var Alert = /*#__PURE__*/function () { function Alert(element) { this._element = element; + + if (this._element) { + Data.setData(element, DATA_KEY, this); + } } // Getters @@ -266,15 +684,11 @@ // Public _proto.close = function close(element) { - var rootElement = this._element; - - if (element) { - rootElement = this._getRootElement(element); - } + var rootElement = element ? this._getRootElement(element) : this._element; var customEvent = this._triggerCloseEvent(rootElement); - if (customEvent.isDefaultPrevented()) { + if (customEvent === null || customEvent.defaultPrevented) { return; } @@ -282,62 +696,52 @@ }; _proto.dispose = function dispose() { - $.removeData(this._element, DATA_KEY); + Data.removeData(this._element, DATA_KEY); this._element = null; } // Private ; _proto._getRootElement = function _getRootElement(element) { - var selector = Util.getSelectorFromElement(element); - var parent = false; - - if (selector) { - parent = document.querySelector(selector); - } - - if (!parent) { - parent = $(element).closest("." + ClassName.ALERT)[0]; - } - - return parent; + return getElementFromSelector(element) || element.closest("." + CLASSNAME_ALERT); }; _proto._triggerCloseEvent = function _triggerCloseEvent(element) { - var closeEvent = $.Event(Event.CLOSE); - $(element).trigger(closeEvent); - return closeEvent; + return EventHandler.trigger(element, EVENT_CLOSE); }; _proto._removeElement = function _removeElement(element) { var _this = this; - $(element).removeClass(ClassName.SHOW); + element.classList.remove(CLASSNAME_SHOW); - if (!$(element).hasClass(ClassName.FADE)) { + if (!element.classList.contains(CLASSNAME_FADE)) { this._destroyElement(element); return; } - var transitionDuration = Util.getTransitionDurationFromElement(element); - $(element).one(Util.TRANSITION_END, function (event) { - return _this._destroyElement(element, event); - }).emulateTransitionEnd(transitionDuration); + var transitionDuration = getTransitionDurationFromElement(element); + EventHandler.one(element, TRANSITION_END, function () { + return _this._destroyElement(element); + }); + emulateTransitionEnd(element, transitionDuration); }; _proto._destroyElement = function _destroyElement(element) { - $(element).detach().trigger(Event.CLOSED).remove(); + if (element.parentNode) { + element.parentNode.removeChild(element); + } + + EventHandler.trigger(element, EVENT_CLOSED); } // Static ; - Alert._jQueryInterface = function _jQueryInterface(config) { + Alert.jQueryInterface = function jQueryInterface(config) { return this.each(function () { - var $element = $(this); - var data = $element.data(DATA_KEY); + var data = Data.getData(this, DATA_KEY); if (!data) { data = new Alert(this); - $element.data(DATA_KEY, data); } if (config === 'close') { @@ -346,7 +750,7 @@ }); }; - Alert._handleDismiss = function _handleDismiss(alertInstance) { + Alert.handleDismiss = function handleDismiss(alertInstance) { return function (event) { if (event) { event.preventDefault(); @@ -356,6 +760,10 @@ }; }; + Alert.getInstance = function getInstance(element) { + return Data.getData(element, DATA_KEY); + }; + _createClass(Alert, null, [{ key: "VERSION", get: function get() { @@ -372,20 +780,27 @@ */ - $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert())); + EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DISMISS, Alert.handleDismiss(new Alert())); + var $$1 = getjQuery(); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ + * add .alert to jQuery only if jQuery is present */ - $.fn[NAME] = Alert._jQueryInterface; - $.fn[NAME].Constructor = Alert; + /* istanbul ignore if */ - $.fn[NAME].noConflict = function () { - $.fn[NAME] = JQUERY_NO_CONFLICT; - return Alert._jQueryInterface; - }; + if ($$1) { + var JQUERY_NO_CONFLICT = $$1.fn[NAME]; + $$1.fn[NAME] = Alert.jQueryInterface; + $$1.fn[NAME].Constructor = Alert; + + $$1.fn[NAME].noConflict = function () { + $$1.fn[NAME] = JQUERY_NO_CONFLICT; + return Alert.jQueryInterface; + }; + } /** * ------------------------------------------------------------------------ @@ -394,39 +809,23 @@ */ var NAME$1 = 'button'; - var VERSION$1 = '4.3.1'; + var VERSION$1 = '5.0.0-alpha2'; var DATA_KEY$1 = 'bs.button'; var EVENT_KEY$1 = "." + DATA_KEY$1; var DATA_API_KEY$1 = '.data-api'; - var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1]; - var ClassName$1 = { - ACTIVE: 'active', - BUTTON: 'btn', - FOCUS: 'focus' - }; - var Selector$1 = { - DATA_TOGGLE_CARROT: '[data-toggle^="button"]', - DATA_TOGGLE: '[data-toggle="buttons"]', - INPUT: 'input:not([type="hidden"])', - ACTIVE: '.active', - BUTTON: '.btn' - }; - var Event$1 = { - CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1, - FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1) - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ - - }; + var CLASS_NAME_ACTIVE = 'active'; + var SELECTOR_DATA_TOGGLE = '[data-toggle="button"]'; + var EVENT_CLICK_DATA_API$1 = "click" + EVENT_KEY$1 + DATA_API_KEY$1; + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - var Button = - /*#__PURE__*/ - function () { + var Button = /*#__PURE__*/function () { function Button(element) { this._element = element; + Data.setData(element, DATA_KEY$1, this); } // Getters @@ -434,62 +833,22 @@ // Public _proto.toggle = function toggle() { - var triggerChangeEvent = true; - var addAriaPressed = true; - var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLE)[0]; - - if (rootElement) { - var input = this._element.querySelector(Selector$1.INPUT); - - if (input) { - if (input.type === 'radio') { - if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) { - triggerChangeEvent = false; - } else { - var activeElement = rootElement.querySelector(Selector$1.ACTIVE); - - if (activeElement) { - $(activeElement).removeClass(ClassName$1.ACTIVE); - } - } - } - - if (triggerChangeEvent) { - if (input.hasAttribute('disabled') || rootElement.hasAttribute('disabled') || input.classList.contains('disabled') || rootElement.classList.contains('disabled')) { - return; - } - - input.checked = !this._element.classList.contains(ClassName$1.ACTIVE); - $(input).trigger('change'); - } - - input.focus(); - addAriaPressed = false; - } - } - - if (addAriaPressed) { - this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE)); - } - - if (triggerChangeEvent) { - $(this._element).toggleClass(ClassName$1.ACTIVE); - } + // 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() { - $.removeData(this._element, DATA_KEY$1); + Data.removeData(this._element, DATA_KEY$1); this._element = null; } // Static ; - Button._jQueryInterface = function _jQueryInterface(config) { + Button.jQueryInterface = function jQueryInterface(config) { return this.each(function () { - var data = $(this).data(DATA_KEY$1); + var data = Data.getData(this, DATA_KEY$1); if (!data) { data = new Button(this); - $(this).data(DATA_KEY$1, data); } if (config === 'toggle') { @@ -498,6 +857,10 @@ }); }; + Button.getInstance = function getInstance(element) { + return Data.getData(element, DATA_KEY$1); + }; + _createClass(Button, null, [{ key: "VERSION", get: function get() { @@ -514,31 +877,200 @@ */ - $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) { + EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE, function (event) { event.preventDefault(); - var button = event.target; + var button = event.target.closest(SELECTOR_DATA_TOGGLE); + var data = Data.getData(button, DATA_KEY$1); - if (!$(button).hasClass(ClassName$1.BUTTON)) { - button = $(button).closest(Selector$1.BUTTON); + if (!data) { + data = new Button(button); } - Button._jQueryInterface.call($(button), 'toggle'); - }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) { - var button = $(event.target).closest(Selector$1.BUTTON)[0]; - $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type)); + data.toggle(); }); + var $$2 = getjQuery(); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ + * add .button to jQuery only if jQuery is present + */ + + /* istanbul ignore if */ + + if ($$2) { + var JQUERY_NO_CONFLICT$1 = $$2.fn[NAME$1]; + $$2.fn[NAME$1] = Button.jQueryInterface; + $$2.fn[NAME$1].Constructor = Button; + + $$2.fn[NAME$1].noConflict = function () { + $$2.fn[NAME$1] = JQUERY_NO_CONFLICT$1; + return Button.jQueryInterface; + }; + } + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.0.0-alpha2): 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, function (chr) { + return "-" + chr.toLowerCase(); + }); + } + + var Manipulator = { + setDataAttribute: function setDataAttribute(element, key, value) { + element.setAttribute("data-" + normalizeDataKey(key), value); + }, + removeDataAttribute: function removeDataAttribute(element, key) { + element.removeAttribute("data-" + normalizeDataKey(key)); + }, + getDataAttributes: function getDataAttributes(element) { + if (!element) { + return {}; + } + + var attributes = _extends({}, 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-" + normalizeDataKey(key))); + }, + offset: function offset(element) { + var rect = element.getBoundingClientRect(); + return { + top: rect.top + document.body.scrollTop, + left: rect.left + document.body.scrollLeft + }; + }, + position: function position(element) { + return { + top: element.offsetTop, + 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); + } + } + }; + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.0.0-alpha2): dom/selector-engine.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ */ - $.fn[NAME$1] = Button._jQueryInterface; - $.fn[NAME$1].Constructor = Button; + var NODE_TEXT = 3; + var SelectorEngine = { + matches: function matches(element, selector) { + return element.matches(selector); + }, + find: function find$1(selector, element) { + var _ref; + + if (element === void 0) { + element = document.documentElement; + } + + return (_ref = []).concat.apply(_ref, find.call(element, selector)); + }, + findOne: function findOne$1(selector, element) { + if (element === void 0) { + element = document.documentElement; + } + + return findOne.call(element, selector); + }, + children: function children(element, selector) { + var _ref2; + + var children = (_ref2 = []).concat.apply(_ref2, element.children); + + return children.filter(function (child) { + return child.matches(selector); + }); + }, + parents: function parents(element, selector) { + var parents = []; + var 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: function prev(element, selector) { + var previous = element.previousElementSibling; + + while (previous) { + if (previous.matches(selector)) { + return [previous]; + } - $.fn[NAME$1].noConflict = function () { - $.fn[NAME$1] = JQUERY_NO_CONFLICT$1; - return Button._jQueryInterface; + previous = previous.previousElementSibling; + } + + return []; + }, + next: function next(element, selector) { + var next = element.nextElementSibling; + + while (next) { + if (this.matches(next, selector)) { + return [next]; + } + + next = next.nextElementSibling; + } + + return []; + } }; /** @@ -548,15 +1080,12 @@ */ var NAME$2 = 'carousel'; - var VERSION$2 = '4.3.1'; + var VERSION$2 = '5.0.0-alpha2'; var DATA_KEY$2 = 'bs.carousel'; var EVENT_KEY$2 = "." + DATA_KEY$2; var DATA_API_KEY$2 = '.data-api'; - var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2]; - var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key - - var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key - + var ARROW_LEFT_KEY = 'ArrowLeft'; + var ARROW_RIGHT_KEY = 'ArrowRight'; var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch var SWIPE_THRESHOLD = 40; @@ -576,62 +1105,50 @@ wrap: 'boolean', touch: 'boolean' }; - var Direction = { - NEXT: 'next', - PREV: 'prev', - LEFT: 'left', - RIGHT: 'right' - }; - var Event$2 = { - SLIDE: "slide" + EVENT_KEY$2, - SLID: "slid" + EVENT_KEY$2, - KEYDOWN: "keydown" + EVENT_KEY$2, - MOUSEENTER: "mouseenter" + EVENT_KEY$2, - MOUSELEAVE: "mouseleave" + EVENT_KEY$2, - TOUCHSTART: "touchstart" + EVENT_KEY$2, - TOUCHMOVE: "touchmove" + EVENT_KEY$2, - TOUCHEND: "touchend" + EVENT_KEY$2, - POINTERDOWN: "pointerdown" + EVENT_KEY$2, - POINTERUP: "pointerup" + EVENT_KEY$2, - DRAG_START: "dragstart" + EVENT_KEY$2, - LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2, - CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2 - }; - var ClassName$2 = { - CAROUSEL: 'carousel', - ACTIVE: 'active', - SLIDE: 'slide', - RIGHT: 'carousel-item-right', - LEFT: 'carousel-item-left', - NEXT: 'carousel-item-next', - PREV: 'carousel-item-prev', - ITEM: 'carousel-item', - POINTER_EVENT: 'pointer-event' - }; - var Selector$2 = { - ACTIVE: '.active', - ACTIVE_ITEM: '.active.carousel-item', - ITEM: '.carousel-item', - ITEM_IMG: '.carousel-item img', - NEXT_PREV: '.carousel-item-next, .carousel-item-prev', - INDICATORS: '.carousel-indicators', - DATA_SLIDE: '[data-slide], [data-slide-to]', - DATA_RIDE: '[data-ride="carousel"]' - }; + var DIRECTION_NEXT = 'next'; + var DIRECTION_PREV = 'prev'; + var DIRECTION_LEFT = 'left'; + var DIRECTION_RIGHT = 'right'; + var EVENT_SLIDE = "slide" + EVENT_KEY$2; + var EVENT_SLID = "slid" + EVENT_KEY$2; + var EVENT_KEYDOWN = "keydown" + EVENT_KEY$2; + var EVENT_MOUSEENTER = "mouseenter" + EVENT_KEY$2; + var EVENT_MOUSELEAVE = "mouseleave" + EVENT_KEY$2; + var EVENT_TOUCHSTART = "touchstart" + EVENT_KEY$2; + var EVENT_TOUCHMOVE = "touchmove" + EVENT_KEY$2; + var EVENT_TOUCHEND = "touchend" + EVENT_KEY$2; + var EVENT_POINTERDOWN = "pointerdown" + EVENT_KEY$2; + var EVENT_POINTERUP = "pointerup" + EVENT_KEY$2; + var EVENT_DRAG_START = "dragstart" + EVENT_KEY$2; + var EVENT_LOAD_DATA_API = "load" + EVENT_KEY$2 + DATA_API_KEY$2; + var EVENT_CLICK_DATA_API$2 = "click" + EVENT_KEY$2 + DATA_API_KEY$2; + var CLASS_NAME_CAROUSEL = 'carousel'; + var CLASS_NAME_ACTIVE$1 = 'active'; + var CLASS_NAME_SLIDE = 'slide'; + 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'; + var SELECTOR_ACTIVE = '.active'; + var SELECTOR_ACTIVE_ITEM = '.active.carousel-item'; + var SELECTOR_ITEM = '.carousel-item'; + 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-slide], [data-slide-to]'; + var SELECTOR_DATA_RIDE = '[data-ride="carousel"]'; var PointerType = { TOUCH: 'touch', PEN: 'pen' - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ - }; + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - var Carousel = - /*#__PURE__*/ - function () { + var Carousel = /*#__PURE__*/function () { function Carousel(element, config) { this._items = null; this._interval = null; @@ -643,11 +1160,13 @@ this.touchDeltaX = 0; this._config = this._getConfig(config); this._element = element; - this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS); + this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element); this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0; - this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent); + this._pointerEvent = Boolean(window.PointerEvent); this._addEventListeners(); + + Data.setData(element, DATA_KEY$2, this); } // Getters @@ -656,21 +1175,21 @@ // Public _proto.next = function next() { if (!this._isSliding) { - this._slide(Direction.NEXT); + this._slide(DIRECTION_NEXT); } }; _proto.nextWhenVisible = function nextWhenVisible() { // Don't call next when the page isn't visible // or the carousel or its parent isn't visible - if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') { + if (!document.hidden && isVisible(this._element)) { this.next(); } }; _proto.prev = function prev() { if (!this._isSliding) { - this._slide(Direction.PREV); + this._slide(DIRECTION_PREV); } }; @@ -679,8 +1198,8 @@ this._isPaused = true; } - if (this._element.querySelector(Selector$2.NEXT_PREV)) { - Util.triggerTransitionEnd(this._element); + if (SelectorEngine.findOne(SELECTOR_NEXT_PREV, this._element)) { + triggerTransitionEnd(this._element); this.cycle(true); } @@ -698,7 +1217,7 @@ this._interval = null; } - if (this._config.interval && !this._isPaused) { + if (this._config && this._config.interval && !this._isPaused) { this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval); } }; @@ -706,7 +1225,7 @@ _proto.to = function to(index) { var _this = this; - this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM); + this._activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element); var activeIndex = this._getItemIndex(this._activeElement); @@ -715,7 +1234,7 @@ } if (this._isSliding) { - $(this._element).one(Event$2.SLID, function () { + EventHandler.one(this._element, EVENT_SLID, function () { return _this.to(index); }); return; @@ -727,14 +1246,14 @@ return; } - var direction = index > activeIndex ? Direction.NEXT : Direction.PREV; + var direction = index > activeIndex ? DIRECTION_NEXT : DIRECTION_PREV; this._slide(direction, this._items[index]); }; _proto.dispose = function dispose() { - $(this._element).off(EVENT_KEY$2); - $.removeData(this._element, DATA_KEY$2); + EventHandler.off(this._element, EVENT_KEY$2); + Data.removeData(this._element, DATA_KEY$2); this._items = null; this._config = null; this._element = null; @@ -747,8 +1266,8 @@ ; _proto._getConfig = function _getConfig(config) { - config = _objectSpread({}, Default, config); - Util.typeCheckConfig(NAME$2, config, DefaultType); + config = _extends({}, Default, config); + typeCheckConfig(NAME$2, config, DefaultType); return config; }; @@ -759,7 +1278,8 @@ return; } - var direction = absDeltax / this.touchDeltaX; // swipe left + var direction = absDeltax / this.touchDeltaX; + this.touchDeltaX = 0; // swipe left if (direction > 0) { this.prev(); @@ -775,20 +1295,21 @@ var _this2 = this; if (this._config.keyboard) { - $(this._element).on(Event$2.KEYDOWN, function (event) { + EventHandler.on(this._element, EVENT_KEYDOWN, function (event) { return _this2._keydown(event); }); } if (this._config.pause === 'hover') { - $(this._element).on(Event$2.MOUSEENTER, function (event) { + EventHandler.on(this._element, EVENT_MOUSEENTER, function (event) { return _this2.pause(event); - }).on(Event$2.MOUSELEAVE, function (event) { + }); + EventHandler.on(this._element, EVENT_MOUSELEAVE, function (event) { return _this2.cycle(event); }); } - if (this._config.touch) { + if (this._config.touch && this._touchSupported) { this._addTouchEventListeners(); } }; @@ -796,30 +1317,26 @@ _proto._addTouchEventListeners = function _addTouchEventListeners() { var _this3 = this; - if (!this._touchSupported) { - return; - } - var start = function start(event) { - if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) { - _this3.touchStartX = event.originalEvent.clientX; + if (_this3._pointerEvent && PointerType[event.pointerType.toUpperCase()]) { + _this3.touchStartX = event.clientX; } else if (!_this3._pointerEvent) { - _this3.touchStartX = event.originalEvent.touches[0].clientX; + _this3.touchStartX = event.touches[0].clientX; } }; var move = function move(event) { // ensure swiping with one touch and not pinching - if (event.originalEvent.touches && event.originalEvent.touches.length > 1) { + if (event.touches && event.touches.length > 1) { _this3.touchDeltaX = 0; } else { - _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX; + _this3.touchDeltaX = event.touches[0].clientX - _this3.touchStartX; } }; var end = function end(event) { - if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) { - _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX; + if (_this3._pointerEvent && PointerType[event.pointerType.toUpperCase()]) { + _this3.touchDeltaX = event.clientX - _this3.touchStartX; } _this3._handleSwipe(); @@ -844,27 +1361,29 @@ } }; - $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.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) { - $(this._element).on(Event$2.POINTERDOWN, function (event) { + EventHandler.on(this._element, EVENT_POINTERDOWN, function (event) { return start(event); }); - $(this._element).on(Event$2.POINTERUP, function (event) { + EventHandler.on(this._element, EVENT_POINTERUP, function (event) { return end(event); }); - this._element.classList.add(ClassName$2.POINTER_EVENT); + this._element.classList.add(CLASS_NAME_POINTER_EVENT); } else { - $(this._element).on(Event$2.TOUCHSTART, function (event) { + EventHandler.on(this._element, EVENT_TOUCHSTART, function (event) { return start(event); }); - $(this._element).on(Event$2.TOUCHMOVE, function (event) { + EventHandler.on(this._element, EVENT_TOUCHMOVE, function (event) { return move(event); }); - $(this._element).on(Event$2.TOUCHEND, function (event) { + EventHandler.on(this._element, EVENT_TOUCHEND, function (event) { return end(event); }); } @@ -875,29 +1394,27 @@ return; } - switch (event.which) { - case ARROW_LEFT_KEYCODE: + switch (event.key) { + case ARROW_LEFT_KEY: event.preventDefault(); this.prev(); break; - case ARROW_RIGHT_KEYCODE: + case ARROW_RIGHT_KEY: event.preventDefault(); this.next(); break; - - default: } }; _proto._getItemIndex = function _getItemIndex(element) { - this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : []; + this._items = element && element.parentNode ? SelectorEngine.find(SELECTOR_ITEM, element.parentNode) : []; return this._items.indexOf(element); }; _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) { - var isNextDirection = direction === Direction.NEXT; - var isPrevDirection = direction === Direction.PREV; + var isNextDirection = direction === DIRECTION_NEXT; + var isPrevDirection = direction === DIRECTION_PREV; var activeIndex = this._getItemIndex(activeElement); @@ -908,7 +1425,7 @@ return activeElement; } - var delta = direction === Direction.PREV ? -1 : 1; + var delta = direction === DIRECTION_PREV ? -1 : 1; var itemIndex = (activeIndex + delta) % this._items.length; return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex]; }; @@ -916,27 +1433,28 @@ _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) { var targetIndex = this._getItemIndex(relatedTarget); - var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM)); + var fromIndex = this._getItemIndex(SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element)); - var slideEvent = $.Event(Event$2.SLIDE, { + return EventHandler.trigger(this._element, EVENT_SLIDE, { relatedTarget: relatedTarget, direction: eventDirectionName, from: fromIndex, to: targetIndex }); - $(this._element).trigger(slideEvent); - return slideEvent; }; _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) { if (this._indicatorsElement) { - var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE)); - $(indicators).removeClass(ClassName$2.ACTIVE); + var indicators = SelectorEngine.find(SELECTOR_ACTIVE, this._indicatorsElement); + + for (var i = 0; i < indicators.length; i++) { + indicators[i].classList.remove(CLASS_NAME_ACTIVE$1); + } var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)]; if (nextIndicator) { - $(nextIndicator).addClass(ClassName$2.ACTIVE); + nextIndicator.classList.add(CLASS_NAME_ACTIVE$1); } } }; @@ -944,7 +1462,7 @@ _proto._slide = function _slide(direction, element) { var _this4 = this; - var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM); + var activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element); var activeElementIndex = this._getItemIndex(activeElement); @@ -957,24 +1475,24 @@ var orderClassName; var eventDirectionName; - if (direction === Direction.NEXT) { - directionalClassName = ClassName$2.LEFT; - orderClassName = ClassName$2.NEXT; - eventDirectionName = Direction.LEFT; + if (direction === DIRECTION_NEXT) { + directionalClassName = CLASS_NAME_LEFT; + orderClassName = CLASS_NAME_NEXT; + eventDirectionName = DIRECTION_LEFT; } else { - directionalClassName = ClassName$2.RIGHT; - orderClassName = ClassName$2.PREV; - eventDirectionName = Direction.RIGHT; + directionalClassName = CLASS_NAME_RIGHT; + orderClassName = CLASS_NAME_PREV; + eventDirectionName = DIRECTION_RIGHT; } - if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) { + if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE$1)) { this._isSliding = false; return; } var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName); - if (slideEvent.isDefaultPrevented()) { + if (slideEvent.defaultPrevented) { return; } @@ -991,18 +1509,11 @@ this._setActiveIndicatorElement(nextElement); - var slidEvent = $.Event(Event$2.SLID, { - relatedTarget: nextElement, - direction: eventDirectionName, - from: activeElementIndex, - to: nextElementIndex - }); - - if ($(this._element).hasClass(ClassName$2.SLIDE)) { - $(nextElement).addClass(orderClassName); - Util.reflow(nextElement); - $(activeElement).addClass(directionalClassName); - $(nextElement).addClass(directionalClassName); + 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) { @@ -1012,20 +1523,32 @@ this._config.interval = this._config.defaultInterval || this._config.interval; } - var transitionDuration = Util.getTransitionDurationFromElement(activeElement); - $(activeElement).one(Util.TRANSITION_END, function () { - $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE); - $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName); + var transitionDuration = getTransitionDurationFromElement(activeElement); + EventHandler.one(activeElement, TRANSITION_END, function () { + nextElement.classList.remove(directionalClassName, orderClassName); + nextElement.classList.add(CLASS_NAME_ACTIVE$1); + activeElement.classList.remove(CLASS_NAME_ACTIVE$1, orderClassName, directionalClassName); _this4._isSliding = false; setTimeout(function () { - return $(_this4._element).trigger(slidEvent); + EventHandler.trigger(_this4._element, EVENT_SLID, { + relatedTarget: nextElement, + direction: eventDirectionName, + from: activeElementIndex, + to: nextElementIndex + }); }, 0); - }).emulateTransitionEnd(transitionDuration); + }); + emulateTransitionEnd(activeElement, transitionDuration); } else { - $(activeElement).removeClass(ClassName$2.ACTIVE); - $(nextElement).addClass(ClassName$2.ACTIVE); + activeElement.classList.remove(CLASS_NAME_ACTIVE$1); + nextElement.classList.add(CLASS_NAME_ACTIVE$1); this._isSliding = false; - $(this._element).trigger(slidEvent); + EventHandler.trigger(this._element, EVENT_SLID, { + relatedTarget: nextElement, + direction: eventDirectionName, + from: activeElementIndex, + to: nextElementIndex + }); } if (isCycling) { @@ -1034,52 +1557,49 @@ } // Static ; - Carousel._jQueryInterface = function _jQueryInterface(config) { - return this.each(function () { - var data = $(this).data(DATA_KEY$2); + Carousel.carouselInterface = function carouselInterface(element, config) { + var data = Data.getData(element, DATA_KEY$2); - var _config = _objectSpread({}, Default, $(this).data()); + var _config = _extends({}, Default, Manipulator.getDataAttributes(element)); - if (typeof config === 'object') { - _config = _objectSpread({}, _config, config); - } + if (typeof config === 'object') { + _config = _extends({}, _config, config); + } - var action = typeof config === 'string' ? config : _config.slide; + var action = typeof config === 'string' ? config : _config.slide; - if (!data) { - data = new Carousel(this, _config); - $(this).data(DATA_KEY$2, data); + 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 + "\""); } - 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(); + } + }; - data[action](); - } else if (_config.interval && _config.ride) { - data.pause(); - data.cycle(); - } + Carousel.jQueryInterface = function jQueryInterface(config) { + return this.each(function () { + Carousel.carouselInterface(this, config); }); }; - Carousel._dataApiClickHandler = function _dataApiClickHandler(event) { - var selector = Util.getSelectorFromElement(this); - - if (!selector) { - return; - } - - var target = $(selector)[0]; + Carousel.dataApiClickHandler = function dataApiClickHandler(event) { + var target = getElementFromSelector(this); - if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) { + if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) { return; } - var config = _objectSpread({}, $(target).data(), $(this).data()); + var config = _extends({}, Manipulator.getDataAttributes(target), Manipulator.getDataAttributes(this)); var slideIndex = this.getAttribute('data-slide-to'); @@ -1087,15 +1607,19 @@ config.interval = false; } - Carousel._jQueryInterface.call($(target), config); + Carousel.carouselInterface(target, config); if (slideIndex) { - $(target).data(DATA_KEY$2).to(slideIndex); + Data.getData(target, DATA_KEY$2).to(slideIndex); } event.preventDefault(); }; + Carousel.getInstance = function getInstance(element) { + return Data.getData(element, DATA_KEY$2); + }; + _createClass(Carousel, null, [{ key: "VERSION", get: function get() { @@ -1117,29 +1641,34 @@ */ - $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler); - $(window).on(Event$2.LOAD_DATA_API, function () { - var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE)); + EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler); + 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++) { - var $carousel = $(carousels[i]); - - Carousel._jQueryInterface.call($carousel, $carousel.data()); + Carousel.carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY$2)); } }); + var $$3 = getjQuery(); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ + * add .carousel to jQuery only if jQuery is present */ - $.fn[NAME$2] = Carousel._jQueryInterface; - $.fn[NAME$2].Constructor = Carousel; + /* istanbul ignore if */ - $.fn[NAME$2].noConflict = function () { - $.fn[NAME$2] = JQUERY_NO_CONFLICT$2; - return Carousel._jQueryInterface; - }; + if ($$3) { + var JQUERY_NO_CONFLICT$2 = $$3.fn[NAME$2]; + $$3.fn[NAME$2] = Carousel.jQueryInterface; + $$3.fn[NAME$2].Constructor = Carousel; + + $$3.fn[NAME$2].noConflict = function () { + $$3.fn[NAME$2] = JQUERY_NO_CONFLICT$2; + return Carousel.jQueryInterface; + }; + } /** * ------------------------------------------------------------------------ @@ -1148,11 +1677,10 @@ */ var NAME$3 = 'collapse'; - var VERSION$3 = '4.3.1'; + var VERSION$3 = '5.0.0-alpha2'; var DATA_KEY$3 = 'bs.collapse'; var EVENT_KEY$3 = "." + DATA_KEY$3; var DATA_API_KEY$3 = '.data-api'; - var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3]; var Default$1 = { toggle: true, parent: '' @@ -1161,52 +1689,41 @@ toggle: 'boolean', parent: '(string|element)' }; - var Event$3 = { - SHOW: "show" + EVENT_KEY$3, - SHOWN: "shown" + EVENT_KEY$3, - HIDE: "hide" + EVENT_KEY$3, - HIDDEN: "hidden" + EVENT_KEY$3, - CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3 - }; - var ClassName$3 = { - SHOW: 'show', - COLLAPSE: 'collapse', - COLLAPSING: 'collapsing', - COLLAPSED: 'collapsed' - }; - var Dimension = { - WIDTH: 'width', - HEIGHT: 'height' - }; - var Selector$3 = { - ACTIVES: '.show, .collapsing', - DATA_TOGGLE: '[data-toggle="collapse"]' - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ - - }; + var EVENT_SHOW = "show" + EVENT_KEY$3; + var EVENT_SHOWN = "shown" + EVENT_KEY$3; + var EVENT_HIDE = "hide" + EVENT_KEY$3; + var EVENT_HIDDEN = "hidden" + EVENT_KEY$3; + var EVENT_CLICK_DATA_API$3 = "click" + EVENT_KEY$3 + DATA_API_KEY$3; + var CLASS_NAME_SHOW = 'show'; + var CLASS_NAME_COLLAPSE = 'collapse'; + var CLASS_NAME_COLLAPSING = 'collapsing'; + var CLASS_NAME_COLLAPSED = 'collapsed'; + var WIDTH = 'width'; + var HEIGHT = 'height'; + var SELECTOR_ACTIVES = '.show, .collapsing'; + var SELECTOR_DATA_TOGGLE$1 = '[data-toggle="collapse"]'; + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - var Collapse = - /*#__PURE__*/ - function () { + var Collapse = /*#__PURE__*/function () { function Collapse(element, config) { this._isTransitioning = false; this._element = element; this._config = this._getConfig(config); - this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]"))); - var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE)); + this._triggerArray = SelectorEngine.find(SELECTOR_DATA_TOGGLE$1 + "[href=\"#" + element.id + "\"]," + (SELECTOR_DATA_TOGGLE$1 + "[data-target=\"#" + element.id + "\"]")); + var toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$1); for (var i = 0, len = toggleList.length; i < len; i++) { var elem = toggleList[i]; - var selector = Util.getSelectorFromElement(elem); - var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) { + var selector = getSelectorFromElement(elem); + var filterElement = SelectorEngine.find(selector).filter(function (foundElem) { return foundElem === element; }); - if (selector !== null && filterElement.length > 0) { + if (selector !== null && filterElement.length) { this._selector = selector; this._triggerArray.push(elem); @@ -1222,6 +1739,8 @@ if (this._config.toggle) { this.toggle(); } + + Data.setData(element, DATA_KEY$3, this); } // Getters @@ -1229,7 +1748,7 @@ // Public _proto.toggle = function toggle() { - if ($(this._element).hasClass(ClassName$3.SHOW)) { + if (this._element.classList.contains(CLASS_NAME_SHOW)) { this.hide(); } else { this.show(); @@ -1239,7 +1758,7 @@ _proto.show = function show() { var _this = this; - if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) { + if (this._isTransitioning || this._element.classList.contains(CLASS_NAME_SHOW)) { return; } @@ -1247,12 +1766,12 @@ var activesData; if (this._parent) { - actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) { + 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(ClassName$3.COLLAPSE); + return elem.classList.contains(CLASS_NAME_COLLAPSE); }); if (actives.length === 0) { @@ -1260,88 +1779,106 @@ } } + var container = SelectorEngine.findOne(this._selector); + if (actives) { - activesData = $(actives).not(this._selector).data(DATA_KEY$3); + var tempActiveData = actives.filter(function (elem) { + return container !== elem; + }); + activesData = tempActiveData[0] ? Data.getData(tempActiveData[0], DATA_KEY$3) : null; if (activesData && activesData._isTransitioning) { return; } } - var startEvent = $.Event(Event$3.SHOW); - $(this._element).trigger(startEvent); + var startEvent = EventHandler.trigger(this._element, EVENT_SHOW); - if (startEvent.isDefaultPrevented()) { + if (startEvent.defaultPrevented) { return; } if (actives) { - Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide'); + actives.forEach(function (elemActive) { + if (container !== elemActive) { + Collapse.collapseInterface(elemActive, 'hide'); + } - if (!activesData) { - $(actives).data(DATA_KEY$3, null); - } + if (!activesData) { + Data.setData(elemActive, DATA_KEY$3, null); + } + }); } var dimension = this._getDimension(); - $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING); + 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).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true); + this._triggerArray.forEach(function (element) { + element.classList.remove(CLASS_NAME_COLLAPSED); + element.setAttribute('aria-expanded', true); + }); } this.setTransitioning(true); var complete = function complete() { - $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW); + _this._element.classList.remove(CLASS_NAME_COLLAPSING); + + _this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW); + _this._element.style[dimension] = ''; _this.setTransitioning(false); - $(_this._element).trigger(Event$3.SHOWN); + EventHandler.trigger(_this._element, EVENT_SHOWN); }; var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); var scrollSize = "scroll" + capitalizedDimension; - var transitionDuration = Util.getTransitionDurationFromElement(this._element); - $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); + var transitionDuration = getTransitionDurationFromElement(this._element); + EventHandler.one(this._element, TRANSITION_END, complete); + emulateTransitionEnd(this._element, transitionDuration); this._element.style[dimension] = this._element[scrollSize] + "px"; }; _proto.hide = function hide() { var _this2 = this; - if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) { + if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW)) { return; } - var startEvent = $.Event(Event$3.HIDE); - $(this._element).trigger(startEvent); + var startEvent = EventHandler.trigger(this._element, EVENT_HIDE); - if (startEvent.isDefaultPrevented()) { + if (startEvent.defaultPrevented) { return; } var dimension = this._getDimension(); this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px"; - Util.reflow(this._element); - $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW); + reflow(this._element); + + this._element.classList.add(CLASS_NAME_COLLAPSING); + + this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW); + var triggerArrayLength = this._triggerArray.length; if (triggerArrayLength > 0) { for (var i = 0; i < triggerArrayLength; i++) { var trigger = this._triggerArray[i]; - var selector = Util.getSelectorFromElement(trigger); + var elem = getElementFromSelector(trigger); - if (selector !== null) { - var $elem = $([].slice.call(document.querySelectorAll(selector))); - - if (!$elem.hasClass(ClassName$3.SHOW)) { - $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false); - } + if (elem && !elem.classList.contains(CLASS_NAME_SHOW)) { + trigger.classList.add(CLASS_NAME_COLLAPSED); + trigger.setAttribute('aria-expanded', false); } } } @@ -1351,12 +1888,17 @@ var complete = function complete() { _this2.setTransitioning(false); - $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN); + _this2._element.classList.remove(CLASS_NAME_COLLAPSING); + + _this2._element.classList.add(CLASS_NAME_COLLAPSE); + + EventHandler.trigger(_this2._element, EVENT_HIDDEN); }; this._element.style[dimension] = ''; - var transitionDuration = Util.getTransitionDurationFromElement(this._element); - $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); + var transitionDuration = getTransitionDurationFromElement(this._element); + EventHandler.one(this._element, TRANSITION_END, complete); + emulateTransitionEnd(this._element, transitionDuration); }; _proto.setTransitioning = function setTransitioning(isTransitioning) { @@ -1364,7 +1906,7 @@ }; _proto.dispose = function dispose() { - $.removeData(this._element, DATA_KEY$3); + Data.removeData(this._element, DATA_KEY$3); this._config = null; this._parent = null; this._element = null; @@ -1374,81 +1916,90 @@ ; _proto._getConfig = function _getConfig(config) { - config = _objectSpread({}, Default$1, config); + config = _extends({}, Default$1, config); config.toggle = Boolean(config.toggle); // Coerce string values - Util.typeCheckConfig(NAME$3, config, DefaultType$1); + typeCheckConfig(NAME$3, config, DefaultType$1); return config; }; _proto._getDimension = function _getDimension() { - var hasWidth = $(this._element).hasClass(Dimension.WIDTH); - return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT; + return this._element.classList.contains(WIDTH) ? WIDTH : HEIGHT; }; _proto._getParent = function _getParent() { var _this3 = this; - var parent; - - if (Util.isElement(this._config.parent)) { - parent = this._config.parent; // It's a jQuery object + var parent = this._config.parent; - if (typeof this._config.parent.jquery !== 'undefined') { - parent = this._config.parent[0]; + if (isElement(parent)) { + // it's a jQuery object + if (typeof parent.jquery !== 'undefined' || typeof parent[0] !== 'undefined') { + parent = parent[0]; } } else { - parent = document.querySelector(this._config.parent); + parent = SelectorEngine.findOne(parent); } - var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]"; - var children = [].slice.call(parent.querySelectorAll(selector)); - $(children).each(function (i, element) { - _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); + var selector = SELECTOR_DATA_TOGGLE$1 + "[data-parent=\"" + parent + "\"]"; + SelectorEngine.find(selector, parent).forEach(function (element) { + var selected = getElementFromSelector(element); + + _this3._addAriaAndCollapsedClass(selected, [element]); }); return parent; }; _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) { - var isOpen = $(element).hasClass(ClassName$3.SHOW); - - if (triggerArray.length) { - $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen); + if (!element || !triggerArray.length) { + return; } + + 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); + } + + elem.setAttribute('aria-expanded', isOpen); + }); } // Static ; - Collapse._getTargetFromElement = function _getTargetFromElement(element) { - var selector = Util.getSelectorFromElement(element); - return selector ? document.querySelector(selector) : null; - }; + Collapse.collapseInterface = function collapseInterface(element, config) { + var data = Data.getData(element, DATA_KEY$3); - Collapse._jQueryInterface = function _jQueryInterface(config) { - return this.each(function () { - var $this = $(this); - var data = $this.data(DATA_KEY$3); + var _config = _extends({}, Default$1, Manipulator.getDataAttributes(element), typeof config === 'object' && config ? config : {}); - var _config = _objectSpread({}, Default$1, $this.data(), typeof config === 'object' && config ? config : {}); + if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) { + _config.toggle = false; + } - if (!data && _config.toggle && /show|hide/.test(config)) { - _config.toggle = false; - } + if (!data) { + data = new Collapse(element, _config); + } - if (!data) { - data = new Collapse(this, _config); - $this.data(DATA_KEY$3, data); + if (typeof config === 'string') { + if (typeof data[config] === 'undefined') { + throw new TypeError("No method named \"" + config + "\""); } - if (typeof config === 'string') { - if (typeof data[config] === 'undefined') { - throw new TypeError("No method named \"" + config + "\""); - } + data[config](); + } + }; - data[config](); - } + Collapse.jQueryInterface = function jQueryInterface(config) { + return this.each(function () { + Collapse.collapseInterface(this, config); }); }; + Collapse.getInstance = function getInstance(element) { + return Data.getData(element, DATA_KEY$3); + }; + _createClass(Collapse, null, [{ key: "VERSION", get: function get() { @@ -1470,40 +2021,58 @@ */ - $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) { + EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$1, function (event) { // preventDefault only for elements (which change the URL) not inside the collapsible element - if (event.currentTarget.tagName === 'A') { + if (event.target.tagName === 'A') { event.preventDefault(); } - var $trigger = $(this); - var selector = Util.getSelectorFromElement(this); - var selectors = [].slice.call(document.querySelectorAll(selector)); - $(selectors).each(function () { - var $target = $(this); - var data = $target.data(DATA_KEY$3); - var config = data ? 'toggle' : $trigger.data(); + 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$3); + 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; + } - Collapse._jQueryInterface.call($target, config); + Collapse.collapseInterface(element, config); }); }); + var $$4 = getjQuery(); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ + * add .collapse to jQuery only if jQuery is present */ - $.fn[NAME$3] = Collapse._jQueryInterface; - $.fn[NAME$3].Constructor = Collapse; + /* istanbul ignore if */ - $.fn[NAME$3].noConflict = function () { - $.fn[NAME$3] = JQUERY_NO_CONFLICT$3; - return Collapse._jQueryInterface; - }; + if ($$4) { + var JQUERY_NO_CONFLICT$3 = $$4.fn[NAME$3]; + $$4.fn[NAME$3] = Collapse.jQueryInterface; + $$4.fn[NAME$3].Constructor = Collapse; + + $$4.fn[NAME$3].noConflict = function () { + $$4.fn[NAME$3] = JQUERY_NO_CONFLICT$3; + return Collapse.jQueryInterface; + }; + } /**! * @fileOverview Kickass library to create and place poppers near their reference elements. - * @version 1.14.7 + * @version 1.16.1 * @license * Copyright (c) 2016 Federico Zivolo and contributors * @@ -1525,16 +2094,17 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined'; - - var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox']; - var timeoutDuration = 0; - for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) { - if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) { - timeoutDuration = 1; - break; + var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined'; + + var timeoutDuration = function () { + var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox']; + for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) { + if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) { + return 1; + } } - } + return 0; + }(); function microtaskDebounce(fn) { var called = false; @@ -1654,6 +2224,17 @@ return getScrollParent(getParentNode(element)); } + /** + * Returns the reference node of the reference object, or the reference object itself. + * @method + * @memberof Popper.Utils + * @param {Element|Object} reference - the reference element (the popper will be relative to this) + * @returns {Element} parent + */ + function getReferenceNode(reference) { + return reference && reference.referenceNode ? reference.referenceNode : reference; + } + var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode); var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent); @@ -1837,7 +2418,7 @@ var sideA = axis === 'x' ? 'Left' : 'Top'; var sideB = sideA === 'Left' ? 'Right' : 'Bottom'; - return parseFloat(styles['border' + sideA + 'Width'], 10) + parseFloat(styles['border' + sideB + 'Width'], 10); + return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']); } function getSize(axis, body, html, computedStyle) { @@ -1898,7 +2479,7 @@ return obj; }; - var _extends = Object.assign || function (target) { + var _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; @@ -1920,7 +2501,7 @@ * @returns {Object} ClientRect like output */ function getClientRect(offsets) { - return _extends({}, offsets, { + return _extends$1({}, offsets, { right: offsets.left + offsets.width, bottom: offsets.top + offsets.height }); @@ -1962,8 +2543,8 @@ // subtract scrollbar size from sizes var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {}; - var width = sizes.width || element.clientWidth || result.right - result.left; - var height = sizes.height || element.clientHeight || result.bottom - result.top; + var width = sizes.width || element.clientWidth || result.width; + var height = sizes.height || element.clientHeight || result.height; var horizScrollbar = element.offsetWidth - width; var vertScrollbar = element.offsetHeight - height; @@ -1992,8 +2573,8 @@ var scrollParent = getScrollParent(children); var styles = getStyleComputedProperty(parent); - var borderTopWidth = parseFloat(styles.borderTopWidth, 10); - var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10); + var borderTopWidth = parseFloat(styles.borderTopWidth); + var borderLeftWidth = parseFloat(styles.borderLeftWidth); // In cases where the parent is fixed, we must ignore negative scroll in offset calc if (fixedPosition && isHTML) { @@ -2014,8 +2595,8 @@ // differently when margins are applied to it. The margins are included in // the box of the documentElement, in the other cases not. if (!isIE10 && isHTML) { - var marginTop = parseFloat(styles.marginTop, 10); - var marginLeft = parseFloat(styles.marginLeft, 10); + var marginTop = parseFloat(styles.marginTop); + var marginLeft = parseFloat(styles.marginLeft); offsets.top -= borderTopWidth - marginTop; offsets.bottom -= borderTopWidth - marginTop; @@ -2115,7 +2696,7 @@ // NOTE: 1 DOM access here var boundaries = { top: 0, left: 0 }; - var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference); + var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference)); // Handle viewport case if (boundariesElement === 'viewport') { @@ -2208,7 +2789,7 @@ }; var sortedAreas = Object.keys(rects).map(function (key) { - return _extends({ + return _extends$1({ key: key }, rects[key], { area: getArea(rects[key]) @@ -2243,7 +2824,7 @@ function getReferenceOffsets(state, popper, reference) { var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference); + var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference)); return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition); } @@ -2328,7 +2909,7 @@ * @argument value * @returns index or -1 */ - function find(arr, check) { + function find$1(arr, check) { // use native find if supported if (Array.prototype.find) { return arr.find(check); @@ -2356,7 +2937,7 @@ } // use `find` + `indexOf` if `findIndex` isn't supported - var match = find(arr, function (obj) { + var match = find$1(arr, function (obj) { return obj[prop] === value; }); return arr.indexOf(match); @@ -2505,7 +3086,7 @@ this.disableEventListeners(); - // remove the popper if user explicity asked for the deletion on destroy + // remove the popper if user explicitly asked for the deletion on destroy // do not use `remove` because IE11 doesn't support it if (this.options.removeOnDestroy) { this.popper.parentNode.removeChild(this.popper); @@ -2773,7 +3354,7 @@ // Remove this legacy support in Popper.js v2 - var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) { + var legacyGpuAccelerationOption = find$1(data.instance.modifiers, function (modifier) { return modifier.name === 'applyStyle'; }).gpuAcceleration; if (legacyGpuAccelerationOption !== undefined) { @@ -2850,9 +3431,9 @@ }; // Update `data` attributes, styles and arrowStyles - data.attributes = _extends({}, attributes, data.attributes); - data.styles = _extends({}, styles, data.styles); - data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles); + data.attributes = _extends$1({}, attributes, data.attributes); + data.styles = _extends$1({}, styles, data.styles); + data.arrowStyles = _extends$1({}, data.offsets.arrow, data.arrowStyles); return data; } @@ -2868,7 +3449,7 @@ * @returns {Boolean} */ function isModifierRequired(modifiers, requestingName, requestedName) { - var requesting = find(modifiers, function (_ref) { + var requesting = find$1(modifiers, function (_ref) { var name = _ref.name; return name === requestingName; }); @@ -2954,8 +3535,8 @@ // Compute the sideValue using the updated popper offsets // take popper margin in account because we don't have this info available var css = getStyleComputedProperty(data.instance.popper); - var popperMarginSide = parseFloat(css['margin' + sideCapitalized], 10); - var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width'], 10); + var popperMarginSide = parseFloat(css['margin' + sideCapitalized]); + var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']); var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide; // prevent arrowElement from being placed not contiguously to its popper @@ -3107,7 +3688,14 @@ // flip the variation if required var isVertical = ['top', 'bottom'].indexOf(placement) !== -1; - var flippedVariation = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom); + + // flips variation if reference element overflows boundaries + var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom); + + // flips variation if popper content overflows boundaries + var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop); + + var flippedVariation = flippedVariationByRef || flippedVariationByContent; if (overlapsRef || overflowsBoundaries || flippedVariation) { // this boolean to detect any flip loop @@ -3125,7 +3713,7 @@ // this object contains `position`, we want to preserve it along with // any additional property we may add in the future - data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement)); + data.offsets.popper = _extends$1({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement)); data = runModifiers(data.instance.modifiers, data, 'flip'); } @@ -3242,7 +3830,7 @@ // Detect if the offset string contains a pair of values or a single one // they could be separated by comma or space - var divider = fragments.indexOf(find(fragments, function (frag) { + var divider = fragments.indexOf(find$1(fragments, function (frag) { return frag.search(/,|\s/) !== -1; })); @@ -3399,7 +3987,7 @@ order.forEach(function (placement) { var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary'; - popper = _extends({}, popper, check[side](placement)); + popper = _extends$1({}, popper, check[side](placement)); }); data.offsets.popper = popper; @@ -3434,7 +4022,7 @@ end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement]) }; - data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]); + data.offsets.popper = _extends$1({}, popper, shiftOffsets[shiftvariation]); } return data; @@ -3453,7 +4041,7 @@ } var refRect = data.offsets.reference; - var bound = find(data.instance.modifiers, function (modifier) { + var bound = find$1(data.instance.modifiers, function (modifier) { return modifier.name === 'preventOverflow'; }).boundaries; @@ -3714,7 +4302,23 @@ * The popper will never be placed outside of the defined boundaries * (except if `keepTogether` is enabled) */ - boundariesElement: 'viewport' + boundariesElement: 'viewport', + /** + * @prop {Boolean} flipVariations=false + * The popper will switch placement variation between `-start` and `-end` when + * the reference element overlaps its boundaries. + * + * The original placement should have a set variation. + */ + flipVariations: false, + /** + * @prop {Boolean} flipVariationsByContent=false + * The popper will switch placement variation between `-start` and `-end` when + * the popper element overlaps its reference boundaries. + * + * The original placement should have a set variation. + */ + flipVariationsByContent: false }, /** @@ -3931,8 +4535,8 @@ /** * Creates a new Popper.js instance. * @class Popper - * @param {HTMLElement|referenceObject} reference - The reference element used to position the popper - * @param {HTMLElement} popper - The HTML element used as the popper + * @param {Element|referenceObject} reference - The reference element used to position the popper + * @param {Element} popper - The HTML / XML element used as the popper * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults) * @return {Object} instance - The generated Popper.js instance */ @@ -3950,7 +4554,7 @@ this.update = debounce(this.update.bind(this)); // with {} we create a new object with the options inside it - this.options = _extends({}, Popper.Defaults, options); + this.options = _extends$1({}, Popper.Defaults, options); // init state this.state = { @@ -3965,13 +4569,13 @@ // Deep merge modifiers options this.options.modifiers = {}; - Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) { - _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {}); + Object.keys(_extends$1({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) { + _this.options.modifiers[name] = _extends$1({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {}); }); // Refactoring modifiers' list (Object => Array) this.modifiers = Object.keys(this.options.modifiers).map(function (name) { - return _extends({ + return _extends$1({ name: name }, _this.options.modifiers[name]); }) @@ -4087,85 +4691,68 @@ */ var NAME$4 = 'dropdown'; - var VERSION$4 = '4.3.1'; + var VERSION$4 = '5.0.0-alpha2'; var DATA_KEY$4 = 'bs.dropdown'; var EVENT_KEY$4 = "." + DATA_KEY$4; var DATA_API_KEY$4 = '.data-api'; - var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4]; - var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key - - var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key - - var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key - - var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key - - var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key - - var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse) - - var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE); - var Event$4 = { - HIDE: "hide" + EVENT_KEY$4, - HIDDEN: "hidden" + EVENT_KEY$4, - SHOW: "show" + EVENT_KEY$4, - SHOWN: "shown" + EVENT_KEY$4, - CLICK: "click" + EVENT_KEY$4, - CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4, - KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4, - KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4 - }; - var ClassName$4 = { - DISABLED: 'disabled', - SHOW: 'show', - DROPUP: 'dropup', - DROPRIGHT: 'dropright', - DROPLEFT: 'dropleft', - MENURIGHT: 'dropdown-menu-right', - MENULEFT: 'dropdown-menu-left', - POSITION_STATIC: 'position-static' - }; - var Selector$4 = { - DATA_TOGGLE: '[data-toggle="dropdown"]', - FORM_CHILD: '.dropdown form', - MENU: '.dropdown-menu', - NAVBAR_NAV: '.navbar-nav', - VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)' - }; - var AttachmentMap = { - TOP: 'top-start', - TOPEND: 'top-end', - BOTTOM: 'bottom-start', - BOTTOMEND: 'bottom-end', - RIGHT: 'right-start', - RIGHTEND: 'right-end', - LEFT: 'left-start', - LEFTEND: 'left-end' - }; + var ESCAPE_KEY = 'Escape'; + var SPACE_KEY = 'Space'; + var TAB_KEY = 'Tab'; + var ARROW_UP_KEY = 'ArrowUp'; + var ARROW_DOWN_KEY = 'ArrowDown'; + var RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button + + var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEY + "|" + ARROW_DOWN_KEY + "|" + ESCAPE_KEY); + var EVENT_HIDE$1 = "hide" + EVENT_KEY$4; + var EVENT_HIDDEN$1 = "hidden" + EVENT_KEY$4; + var EVENT_SHOW$1 = "show" + EVENT_KEY$4; + var EVENT_SHOWN$1 = "shown" + EVENT_KEY$4; + var EVENT_CLICK = "click" + EVENT_KEY$4; + var EVENT_CLICK_DATA_API$4 = "click" + EVENT_KEY$4 + DATA_API_KEY$4; + var EVENT_KEYDOWN_DATA_API = "keydown" + EVENT_KEY$4 + DATA_API_KEY$4; + var EVENT_KEYUP_DATA_API = "keyup" + EVENT_KEY$4 + DATA_API_KEY$4; + var CLASS_NAME_DISABLED = 'disabled'; + var CLASS_NAME_SHOW$1 = 'show'; + var CLASS_NAME_DROPUP = 'dropup'; + var CLASS_NAME_DROPRIGHT = 'dropright'; + var CLASS_NAME_DROPLEFT = 'dropleft'; + var CLASS_NAME_MENURIGHT = 'dropdown-menu-right'; + var CLASS_NAME_NAVBAR = 'navbar'; + var CLASS_NAME_POSITION_STATIC = 'position-static'; + var SELECTOR_DATA_TOGGLE$2 = '[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 = '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$2 = { offset: 0, flip: true, boundary: 'scrollParent', reference: 'toggle', - display: 'dynamic' + display: 'dynamic', + popperConfig: null }; var DefaultType$2 = { offset: '(number|string|function)', flip: 'boolean', boundary: '(string|element)', reference: '(string|element)', - display: 'string' - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ - + display: 'string', + popperConfig: '(null|object)' }; + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - var Dropdown = - /*#__PURE__*/ - function () { + var Dropdown = /*#__PURE__*/function () { function Dropdown(element, config) { this._element = element; this._popper = null; @@ -4174,6 +4761,8 @@ this._inNavbar = this._detectNavbar(); this._addEventListeners(); + + Data.setData(element, DATA_KEY$4, this); } // Getters @@ -4181,45 +4770,47 @@ // Public _proto.toggle = function toggle() { - if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) { + if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED)) { return; } - var parent = Dropdown._getParentFromElement(this._element); + var isActive = this._element.classList.contains(CLASS_NAME_SHOW$1); - var isActive = $(this._menu).hasClass(ClassName$4.SHOW); - - Dropdown._clearMenus(); + Dropdown.clearMenus(); if (isActive) { return; } + this.show(); + }; + + _proto.show = function show() { + if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED) || this._menu.classList.contains(CLASS_NAME_SHOW$1)) { + return; + } + + var parent = Dropdown.getParentFromElement(this._element); var relatedTarget = { relatedTarget: this._element }; - var showEvent = $.Event(Event$4.SHOW, relatedTarget); - $(parent).trigger(showEvent); + var showEvent = EventHandler.trigger(this._element, EVENT_SHOW$1, relatedTarget); - if (showEvent.isDefaultPrevented()) { + if (showEvent.defaultPrevented) { return; } // Disable totally Popper.js for Dropdown in Navbar if (!this._inNavbar) { - /** - * Check for Popper dependency - * Popper - https://popper.js.org - */ if (typeof Popper === 'undefined') { - throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)'); + throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org)'); } var referenceElement = this._element; if (this._config.reference === 'parent') { referenceElement = parent; - } else if (Util.isElement(this._config.reference)) { + } else if (isElement(this._config.reference)) { referenceElement = this._config.reference; // Check if it's jQuery element if (typeof this._config.reference.jquery !== 'undefined') { @@ -4231,7 +4822,7 @@ if (this._config.boundary !== 'scrollParent') { - $(parent).addClass(ClassName$4.POSITION_STATIC); + parent.classList.add(CLASS_NAME_POSITION_STATIC); } this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig()); @@ -4241,69 +4832,54 @@ // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html - if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) { - $(document.body).children().on('mouseover', null, $.noop); + if ('ontouchstart' in document.documentElement && !parent.closest(SELECTOR_NAVBAR_NAV)) { + var _ref; + + (_ref = []).concat.apply(_ref, document.body.children).forEach(function (elem) { + return EventHandler.on(elem, 'mouseover', null, noop()); + }); } this._element.focus(); this._element.setAttribute('aria-expanded', true); - $(this._menu).toggleClass(ClassName$4.SHOW); - $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget)); + Manipulator.toggleClass(this._menu, CLASS_NAME_SHOW$1); + Manipulator.toggleClass(this._element, CLASS_NAME_SHOW$1); + EventHandler.trigger(parent, EVENT_SHOWN$1, relatedTarget); }; - _proto.show = function show() { - if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) { + _proto.hide = function hide() { + if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED) || !this._menu.classList.contains(CLASS_NAME_SHOW$1)) { return; } + var parent = Dropdown.getParentFromElement(this._element); var relatedTarget = { relatedTarget: this._element }; - var showEvent = $.Event(Event$4.SHOW, relatedTarget); - - var parent = Dropdown._getParentFromElement(this._element); - - $(parent).trigger(showEvent); - - if (showEvent.isDefaultPrevented()) { - return; - } - - $(this._menu).toggleClass(ClassName$4.SHOW); - $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget)); - }; + var hideEvent = EventHandler.trigger(parent, EVENT_HIDE$1, relatedTarget); - _proto.hide = function hide() { - if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) { + if (hideEvent.defaultPrevented) { return; } - var relatedTarget = { - relatedTarget: this._element - }; - var hideEvent = $.Event(Event$4.HIDE, relatedTarget); - - var parent = Dropdown._getParentFromElement(this._element); - - $(parent).trigger(hideEvent); - - if (hideEvent.isDefaultPrevented()) { - return; + if (this._popper) { + this._popper.destroy(); } - $(this._menu).toggleClass(ClassName$4.SHOW); - $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget)); + Manipulator.toggleClass(this._menu, CLASS_NAME_SHOW$1); + Manipulator.toggleClass(this._element, CLASS_NAME_SHOW$1); + EventHandler.trigger(parent, EVENT_HIDDEN$1, relatedTarget); }; _proto.dispose = function dispose() { - $.removeData(this._element, DATA_KEY$4); - $(this._element).off(EVENT_KEY$4); + Data.removeData(this._element, DATA_KEY$4); + EventHandler.off(this._element, EVENT_KEY$4); this._element = null; this._menu = null; - if (this._popper !== null) { + if (this._popper) { this._popper.destroy(); this._popper = null; @@ -4313,7 +4889,7 @@ _proto.update = function update() { this._inNavbar = this._detectNavbar(); - if (this._popper !== null) { + if (this._popper) { this._popper.scheduleUpdate(); } } // Private @@ -4322,7 +4898,7 @@ _proto._addEventListeners = function _addEventListeners() { var _this = this; - $(this._element).on(Event$4.CLICK, function (event) { + EventHandler.on(this._element, EVENT_CLICK, function (event) { event.preventDefault(); event.stopPropagation(); @@ -4331,46 +4907,38 @@ }; _proto._getConfig = function _getConfig(config) { - config = _objectSpread({}, this.constructor.Default, $(this._element).data(), config); - Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType); + config = _extends({}, this.constructor.Default, Manipulator.getDataAttributes(this._element), config); + typeCheckConfig(NAME$4, config, this.constructor.DefaultType); return config; }; _proto._getMenuElement = function _getMenuElement() { - if (!this._menu) { - var parent = Dropdown._getParentFromElement(this._element); - - if (parent) { - this._menu = parent.querySelector(Selector$4.MENU); - } - } - - return this._menu; + return SelectorEngine.next(this._element, SELECTOR_MENU)[0]; }; _proto._getPlacement = function _getPlacement() { - var $parentDropdown = $(this._element.parentNode); - var placement = AttachmentMap.BOTTOM; // Handle dropup + var parentDropdown = this._element.parentNode; + var placement = PLACEMENT_BOTTOM; // Handle dropup - if ($parentDropdown.hasClass(ClassName$4.DROPUP)) { - placement = AttachmentMap.TOP; + if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) { + placement = PLACEMENT_TOP; - if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) { - placement = AttachmentMap.TOPEND; + if (this._menu.classList.contains(CLASS_NAME_MENURIGHT)) { + placement = PLACEMENT_TOPEND; } - } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) { - placement = AttachmentMap.RIGHT; - } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) { - placement = AttachmentMap.LEFT; - } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) { - placement = AttachmentMap.BOTTOMEND; + } 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 placement; }; _proto._detectNavbar = function _detectNavbar() { - return $(this._element).closest('.navbar').length > 0; + return Boolean(this._element.closest("." + CLASS_NAME_NAVBAR)); }; _proto._getOffset = function _getOffset() { @@ -4380,7 +4948,7 @@ if (typeof this._config.offset === 'function') { offset.fn = function (data) { - data.offsets = _objectSpread({}, data.offsets, _this2._config.offset(data.offsets, _this2._element) || {}); + data.offsets = _extends({}, data.offsets, _this2._config.offset(data.offsets, _this2._element) || {}); return data; }; } else { @@ -4401,9 +4969,8 @@ preventOverflow: { boundariesElement: this._config.boundary } - } // Disable Popper.js if we have a static display - - }; + } + }; // Disable Popper.js if we have a static display if (this._config.display === 'static') { popperConfig.modifiers.applyStyle = { @@ -4411,42 +4978,44 @@ }; } - return popperConfig; + return _extends({}, popperConfig, this._config.popperConfig); } // Static ; - Dropdown._jQueryInterface = function _jQueryInterface(config) { - return this.each(function () { - var data = $(this).data(DATA_KEY$4); + Dropdown.dropdownInterface = function dropdownInterface(element, config) { + var data = Data.getData(element, DATA_KEY$4); - var _config = typeof config === 'object' ? config : null; + var _config = typeof config === 'object' ? config : null; - if (!data) { - data = new Dropdown(this, _config); - $(this).data(DATA_KEY$4, data); + if (!data) { + data = new Dropdown(element, _config); + } + + if (typeof config === 'string') { + if (typeof data[config] === 'undefined') { + throw new TypeError("No method named \"" + config + "\""); } - if (typeof config === 'string') { - if (typeof data[config] === 'undefined') { - throw new TypeError("No method named \"" + config + "\""); - } + data[config](); + } + }; - data[config](); - } + Dropdown.jQueryInterface = function jQueryInterface(config) { + return this.each(function () { + Dropdown.dropdownInterface(this, config); }); }; - Dropdown._clearMenus = function _clearMenus(event) { - if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) { + Dropdown.clearMenus = function clearMenus(event) { + if (event && (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY)) { return; } - var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE)); + var toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE$2); for (var i = 0, len = toggles.length; i < len; i++) { - var parent = Dropdown._getParentFromElement(toggles[i]); - - var context = $(toggles[i]).data(DATA_KEY$4); + var parent = Dropdown.getParentFromElement(toggles[i]); + var context = Data.getData(toggles[i], DATA_KEY$4); var relatedTarget = { relatedTarget: toggles[i] }; @@ -4461,46 +5030,47 @@ var dropdownMenu = context._menu; - if (!$(parent).hasClass(ClassName$4.SHOW)) { + if (!toggles[i].classList.contains(CLASS_NAME_SHOW$1)) { continue; } - if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) { + if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.key === TAB_KEY) && dropdownMenu.contains(event.target)) { continue; } - var hideEvent = $.Event(Event$4.HIDE, relatedTarget); - $(parent).trigger(hideEvent); + var hideEvent = EventHandler.trigger(parent, EVENT_HIDE$1, relatedTarget); - if (hideEvent.isDefaultPrevented()) { + 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) { - $(document.body).children().off('mouseover', null, $.noop); + var _ref2; + + (_ref2 = []).concat.apply(_ref2, document.body.children).forEach(function (elem) { + return EventHandler.off(elem, 'mouseover', null, noop()); + }); } toggles[i].setAttribute('aria-expanded', 'false'); - $(dropdownMenu).removeClass(ClassName$4.SHOW); - $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget)); - } - }; - Dropdown._getParentFromElement = function _getParentFromElement(element) { - var parent; - var selector = Util.getSelectorFromElement(element); + if (context._popper) { + context._popper.destroy(); + } - if (selector) { - parent = document.querySelector(selector); + dropdownMenu.classList.remove(CLASS_NAME_SHOW$1); + toggles[i].classList.remove(CLASS_NAME_SHOW$1); + EventHandler.trigger(parent, EVENT_HIDDEN$1, relatedTarget); } + }; - return parent || element.parentNode; - } // eslint-disable-next-line complexity - ; + Dropdown.getParentFromElement = function getParentFromElement(element) { + return getElementFromSelector(element) || element.parentNode; + }; - Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) { + Dropdown.dataApiKeydownHandler = function dataApiKeydownHandler(event) { // If not input/textarea: // - And not a key in REGEXP_KEYDOWN => not a dropdown command // If input/textarea: @@ -4508,56 +5078,59 @@ // - 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.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $(event.target).closest(Selector$4.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) { + 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).hasClass(ClassName$4.DISABLED)) { + if (this.disabled || this.classList.contains(CLASS_NAME_DISABLED)) { return; } - var parent = Dropdown._getParentFromElement(this); + var parent = Dropdown.getParentFromElement(this); + var isActive = this.classList.contains(CLASS_NAME_SHOW$1); - var isActive = $(parent).hasClass(ClassName$4.SHOW); - - if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) { - if (event.which === ESCAPE_KEYCODE) { - var toggle = parent.querySelector(Selector$4.DATA_TOGGLE); - $(toggle).trigger('focus'); - } + if (event.key === ESCAPE_KEY) { + var button = this.matches(SELECTOR_DATA_TOGGLE$2) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$2)[0]; + button.focus(); + Dropdown.clearMenus(); + return; + } - $(this).trigger('click'); + if (!isActive || event.key === SPACE_KEY) { + Dropdown.clearMenus(); return; } - var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)); + var items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, parent).filter(isVisible); - if (items.length === 0) { + if (!items.length) { return; } var index = items.indexOf(event.target); - if (event.which === ARROW_UP_KEYCODE && index > 0) { + if (event.key === ARROW_UP_KEY && index > 0) { // Up index--; } - if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { + if (event.key === ARROW_DOWN_KEY && index < items.length - 1) { // Down index++; - } + } // index is -1 if the first keydown is an ArrowUp - if (index < 0) { - index = 0; - } + index = index === -1 ? 0 : index; items[index].focus(); }; + Dropdown.getInstance = function getInstance(element) { + return Data.getData(element, DATA_KEY$4); + }; + _createClass(Dropdown, null, [{ key: "VERSION", get: function get() { @@ -4584,27 +5157,38 @@ */ - $(document).on(Event$4.KEYDOWN_DATA_API, Selector$4.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event$4.KEYDOWN_DATA_API, Selector$4.MENU, Dropdown._dataApiKeydownHandler).on(Event$4.CLICK_DATA_API + " " + Event$4.KEYUP_DATA_API, Dropdown._clearMenus).on(Event$4.CLICK_DATA_API, Selector$4.DATA_TOGGLE, function (event) { + EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$2, Dropdown.dataApiKeydownHandler); + EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler); + EventHandler.on(document, EVENT_CLICK_DATA_API$4, Dropdown.clearMenus); + EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus); + EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$2, function (event) { event.preventDefault(); event.stopPropagation(); - - Dropdown._jQueryInterface.call($(this), 'toggle'); - }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) { - e.stopPropagation(); + Dropdown.dropdownInterface(this, 'toggle'); + }); + EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_FORM_CHILD, function (e) { + return e.stopPropagation(); }); + var $$5 = getjQuery(); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ + * add .dropdown to jQuery only if jQuery is present */ - $.fn[NAME$4] = Dropdown._jQueryInterface; - $.fn[NAME$4].Constructor = Dropdown; + /* istanbul ignore if */ - $.fn[NAME$4].noConflict = function () { - $.fn[NAME$4] = JQUERY_NO_CONFLICT$4; - return Dropdown._jQueryInterface; - }; + if ($$5) { + var JQUERY_NO_CONFLICT$4 = $$5.fn[NAME$4]; + $$5.fn[NAME$4] = Dropdown.jQueryInterface; + $$5.fn[NAME$4].Constructor = Dropdown; + + $$5.fn[NAME$4].noConflict = function () { + $$5.fn[NAME$4] = JQUERY_NO_CONFLICT$4; + return Dropdown.jQueryInterface; + }; + } /** * ------------------------------------------------------------------------ @@ -4613,13 +5197,11 @@ */ var NAME$5 = 'modal'; - var VERSION$5 = '4.3.1'; + var VERSION$5 = '5.0.0-alpha2'; var DATA_KEY$5 = 'bs.modal'; var EVENT_KEY$5 = "." + DATA_KEY$5; var DATA_API_KEY$5 = '.data-api'; - var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5]; - var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key - + var ESCAPE_KEY$1 = 'Escape'; var Default$3 = { backdrop: true, keyboard: true, @@ -4632,55 +5214,48 @@ focus: 'boolean', show: 'boolean' }; - var Event$5 = { - HIDE: "hide" + EVENT_KEY$5, - HIDDEN: "hidden" + EVENT_KEY$5, - SHOW: "show" + EVENT_KEY$5, - SHOWN: "shown" + EVENT_KEY$5, - FOCUSIN: "focusin" + EVENT_KEY$5, - RESIZE: "resize" + EVENT_KEY$5, - CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5, - KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5, - MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5, - MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5, - CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5 - }; - var ClassName$5 = { - SCROLLABLE: 'modal-dialog-scrollable', - SCROLLBAR_MEASURER: 'modal-scrollbar-measure', - BACKDROP: 'modal-backdrop', - OPEN: 'modal-open', - FADE: 'fade', - SHOW: 'show' - }; - var Selector$5 = { - DIALOG: '.modal-dialog', - MODAL_BODY: '.modal-body', - DATA_TOGGLE: '[data-toggle="modal"]', - DATA_DISMISS: '[data-dismiss="modal"]', - FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top', - STICKY_CONTENT: '.sticky-top' - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ - - }; + var EVENT_HIDE$2 = "hide" + EVENT_KEY$5; + var EVENT_HIDE_PREVENTED = "hidePrevented" + EVENT_KEY$5; + var EVENT_HIDDEN$2 = "hidden" + EVENT_KEY$5; + var EVENT_SHOW$2 = "show" + EVENT_KEY$5; + var EVENT_SHOWN$2 = "shown" + EVENT_KEY$5; + var EVENT_FOCUSIN = "focusin" + EVENT_KEY$5; + var EVENT_RESIZE = "resize" + EVENT_KEY$5; + var EVENT_CLICK_DISMISS = "click.dismiss" + EVENT_KEY$5; + var EVENT_KEYDOWN_DISMISS = "keydown.dismiss" + EVENT_KEY$5; + var EVENT_MOUSEUP_DISMISS = "mouseup.dismiss" + EVENT_KEY$5; + var EVENT_MOUSEDOWN_DISMISS = "mousedown.dismiss" + EVENT_KEY$5; + var EVENT_CLICK_DATA_API$5 = "click" + EVENT_KEY$5 + DATA_API_KEY$5; + var CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure'; + var CLASS_NAME_BACKDROP = 'modal-backdrop'; + var CLASS_NAME_OPEN = 'modal-open'; + var CLASS_NAME_FADE = 'fade'; + var CLASS_NAME_SHOW$2 = 'show'; + var CLASS_NAME_STATIC = 'modal-static'; + var SELECTOR_DIALOG = '.modal-dialog'; + var SELECTOR_MODAL_BODY = '.modal-body'; + var SELECTOR_DATA_TOGGLE$3 = '[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'; + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - var Modal = - /*#__PURE__*/ - function () { + var Modal = /*#__PURE__*/function () { function Modal(element, config) { this._config = this._getConfig(config); this._element = element; - this._dialog = element.querySelector(Selector$5.DIALOG); + 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$5, this); } // Getters @@ -4698,16 +5273,15 @@ return; } - if ($(this._element).hasClass(ClassName$5.FADE)) { + if (this._element.classList.contains(CLASS_NAME_FADE)) { this._isTransitioning = true; } - var showEvent = $.Event(Event$5.SHOW, { + var showEvent = EventHandler.trigger(this._element, EVENT_SHOW$2, { relatedTarget: relatedTarget }); - $(this._element).trigger(showEvent); - if (this._isShown || showEvent.isDefaultPrevented()) { + if (this._isShown || showEvent.defaultPrevented) { return; } @@ -4723,12 +5297,12 @@ this._setResizeEvent(); - $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) { + EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function (event) { return _this.hide(event); }); - $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () { - $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) { - if ($(event.target).is(_this._element)) { + 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; } }); @@ -4750,15 +5324,15 @@ return; } - var hideEvent = $.Event(Event$5.HIDE); - $(this._element).trigger(hideEvent); + var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$2); - if (!this._isShown || hideEvent.isDefaultPrevented()) { + if (hideEvent.defaultPrevented) { return; } this._isShown = false; - var transition = $(this._element).hasClass(ClassName$5.FADE); + + var transition = this._element.classList.contains(CLASS_NAME_FADE); if (transition) { this._isTransitioning = true; @@ -4768,16 +5342,19 @@ this._setResizeEvent(); - $(document).off(Event$5.FOCUSIN); - $(this._element).removeClass(ClassName$5.SHOW); - $(this._element).off(Event$5.CLICK_DISMISS); - $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS); + EventHandler.off(document, EVENT_FOCUSIN); + + this._element.classList.remove(CLASS_NAME_SHOW$2); + + EventHandler.off(this._element, EVENT_CLICK_DISMISS); + EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS); if (transition) { - var transitionDuration = Util.getTransitionDurationFromElement(this._element); - $(this._element).one(Util.TRANSITION_END, function (event) { + var transitionDuration = getTransitionDurationFromElement(this._element); + EventHandler.one(this._element, TRANSITION_END, function (event) { return _this2._hideModal(event); - }).emulateTransitionEnd(transitionDuration); + }); + emulateTransitionEnd(this._element, transitionDuration); } else { this._hideModal(); } @@ -4785,16 +5362,16 @@ _proto.dispose = function dispose() { [window, this._element, this._dialog].forEach(function (htmlElement) { - return $(htmlElement).off(EVENT_KEY$5); + return EventHandler.off(htmlElement, EVENT_KEY$5); }); /** - * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API` + * `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 + * It will remove `EVENT_CLICK_DATA_API` event that should remain */ - $(document).off(Event$5.FOCUSIN); - $.removeData(this._element, DATA_KEY$5); + EventHandler.off(document, EVENT_FOCUSIN); + Data.removeData(this._element, DATA_KEY$5); this._config = null; this._element = null; this._dialog = null; @@ -4812,15 +5389,17 @@ ; _proto._getConfig = function _getConfig(config) { - config = _objectSpread({}, Default$3, config); - Util.typeCheckConfig(NAME$5, config, DefaultType$3); + config = _extends({}, Default$3, config); + typeCheckConfig(NAME$5, config, DefaultType$3); return config; }; _proto._showElement = function _showElement(relatedTarget) { var _this3 = this; - var transition = $(this._element).hasClass(ClassName$5.FADE); + var transition = this._element.classList.contains(CLASS_NAME_FADE); + + 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 @@ -4833,38 +5412,39 @@ this._element.setAttribute('aria-modal', true); - if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE)) { - this._dialog.querySelector(Selector$5.MODAL_BODY).scrollTop = 0; - } else { - this._element.scrollTop = 0; + this._element.setAttribute('role', 'dialog'); + + this._element.scrollTop = 0; + + if (modalBody) { + modalBody.scrollTop = 0; } if (transition) { - Util.reflow(this._element); + reflow(this._element); } - $(this._element).addClass(ClassName$5.SHOW); + this._element.classList.add(CLASS_NAME_SHOW$2); if (this._config.focus) { this._enforceFocus(); } - var shownEvent = $.Event(Event$5.SHOWN, { - relatedTarget: relatedTarget - }); - var transitionComplete = function transitionComplete() { if (_this3._config.focus) { _this3._element.focus(); } _this3._isTransitioning = false; - $(_this3._element).trigger(shownEvent); + EventHandler.trigger(_this3._element, EVENT_SHOWN$2, { + relatedTarget: relatedTarget + }); }; if (transition) { - var transitionDuration = Util.getTransitionDurationFromElement(this._dialog); - $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration); + var transitionDuration = getTransitionDurationFromElement(this._dialog); + EventHandler.one(this._dialog, TRANSITION_END, transitionComplete); + emulateTransitionEnd(this._dialog, transitionDuration); } else { transitionComplete(); } @@ -4873,9 +5453,10 @@ _proto._enforceFocus = function _enforceFocus() { var _this4 = this; - $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop - .on(Event$5.FOCUSIN, function (event) { - if (document !== event.target && _this4._element !== event.target && $(_this4._element).has(event.target).length === 0) { + EventHandler.off(document, EVENT_FOCUSIN); // guard against infinite focus loop + + EventHandler.on(document, EVENT_FOCUSIN, function (event) { + if (document !== event.target && _this4._element !== event.target && !_this4._element.contains(event.target)) { _this4._element.focus(); } }); @@ -4884,16 +5465,18 @@ _proto._setEscapeEvent = function _setEscapeEvent() { var _this5 = this; - if (this._isShown && this._config.keyboard) { - $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) { - if (event.which === ESCAPE_KEYCODE$1) { + if (this._isShown) { + EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, function (event) { + if (_this5._config.keyboard && event.key === ESCAPE_KEY$1) { event.preventDefault(); _this5.hide(); + } else if (!_this5._config.keyboard && event.key === ESCAPE_KEY$1) { + _this5._triggerBackdropTransition(); } }); - } else if (!this._isShown) { - $(this._element).off(Event$5.KEYDOWN_DISMISS); + } else { + EventHandler.off(this._element, EVENT_KEYDOWN_DISMISS); } }; @@ -4901,11 +5484,11 @@ var _this6 = this; if (this._isShown) { - $(window).on(Event$5.RESIZE, function (event) { - return _this6.handleUpdate(event); + EventHandler.on(window, EVENT_RESIZE, function () { + return _this6._adjustDialog(); }); } else { - $(window).off(Event$5.RESIZE); + EventHandler.off(window, EVENT_RESIZE); } }; @@ -4918,41 +5501,42 @@ this._element.removeAttribute('aria-modal'); + this._element.removeAttribute('role'); + this._isTransitioning = false; this._showBackdrop(function () { - $(document.body).removeClass(ClassName$5.OPEN); + document.body.classList.remove(CLASS_NAME_OPEN); _this7._resetAdjustments(); _this7._resetScrollbar(); - $(_this7._element).trigger(Event$5.HIDDEN); + EventHandler.trigger(_this7._element, EVENT_HIDDEN$2); }); }; _proto._removeBackdrop = function _removeBackdrop() { - if (this._backdrop) { - $(this._backdrop).remove(); - this._backdrop = null; - } + this._backdrop.parentNode.removeChild(this._backdrop); + + this._backdrop = null; }; _proto._showBackdrop = function _showBackdrop(callback) { var _this8 = this; - var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : ''; + var 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 = ClassName$5.BACKDROP; + this._backdrop.className = CLASS_NAME_BACKDROP; if (animate) { this._backdrop.classList.add(animate); } - $(this._backdrop).appendTo(document.body); - $(this._element).on(Event$5.CLICK_DISMISS, function (event) { + document.body.appendChild(this._backdrop); + EventHandler.on(this._element, EVENT_CLICK_DISMISS, function (event) { if (_this8._ignoreBackdropClick) { _this8._ignoreBackdropClick = false; return; @@ -4962,54 +5546,83 @@ return; } - if (_this8._config.backdrop === 'static') { - _this8._element.focus(); - } else { - _this8.hide(); - } + _this8._triggerBackdropTransition(); }); if (animate) { - Util.reflow(this._backdrop); + reflow(this._backdrop); } - $(this._backdrop).addClass(ClassName$5.SHOW); - - if (!callback) { - return; - } + this._backdrop.classList.add(CLASS_NAME_SHOW$2); if (!animate) { callback(); return; } - var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop); - $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration); + var backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop); + EventHandler.one(this._backdrop, TRANSITION_END, callback); + emulateTransitionEnd(this._backdrop, backdropTransitionDuration); } else if (!this._isShown && this._backdrop) { - $(this._backdrop).removeClass(ClassName$5.SHOW); + this._backdrop.classList.remove(CLASS_NAME_SHOW$2); var callbackRemove = function callbackRemove() { _this8._removeBackdrop(); - if (callback) { - callback(); - } + callback(); }; - if ($(this._element).hasClass(ClassName$5.FADE)) { - var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop); + if (this._element.classList.contains(CLASS_NAME_FADE)) { + var _backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop); - $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration); + EventHandler.one(this._backdrop, TRANSITION_END, callbackRemove); + emulateTransitionEnd(this._backdrop, _backdropTransitionDuration); } else { callbackRemove(); } - } else if (callback) { + } else { callback(); } + }; + + _proto._triggerBackdropTransition = function _triggerBackdropTransition() { + var _this9 = this; + + 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.off(this._element, TRANSITION_END); + EventHandler.one(this._element, TRANSITION_END, function () { + _this9._element.classList.remove(CLASS_NAME_STATIC); + + if (!isModalOverflowing) { + EventHandler.one(_this9._element, TRANSITION_END, function () { + _this9._element.style.overflowY = ''; + }); + emulateTransitionEnd(_this9._element, modalTransitionDuration); + } + }); + emulateTransitionEnd(this._element, modalTransitionDuration); + + this._element.focus(); + } else { + this.hide(); + } } // ---------------------------------------------------------------------- // the following methods are used to handle overflowing modals - // todo (fat): these should probably be refactored out of modal.js // ---------------------------------------------------------------------- ; @@ -5032,66 +5645,74 @@ _proto._checkScrollbar = function _checkScrollbar() { var rect = document.body.getBoundingClientRect(); - this._isBodyOverflowing = rect.left + rect.right < window.innerWidth; + this._isBodyOverflowing = Math.round(rect.left + rect.right) < window.innerWidth; this._scrollbarWidth = this._getScrollbarWidth(); }; _proto._setScrollbar = function _setScrollbar() { - var _this9 = 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 - var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT)); - var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding - - $(fixedContent).each(function (index, element) { + // Adjust fixed content padding + SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) { var actualPadding = element.style.paddingRight; - var calculatedPadding = $(element).css('padding-right'); - $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this9._scrollbarWidth + "px"); + var calculatedPadding = window.getComputedStyle(element)['padding-right']; + Manipulator.setDataAttribute(element, 'padding-right', actualPadding); + element.style.paddingRight = parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px"; }); // Adjust sticky content margin - $(stickyContent).each(function (index, element) { + SelectorEngine.find(SELECTOR_STICKY_CONTENT).forEach(function (element) { var actualMargin = element.style.marginRight; - var calculatedMargin = $(element).css('margin-right'); - $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this9._scrollbarWidth + "px"); + 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 = $(document.body).css('padding-right'); - $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px"); + var calculatedPadding = window.getComputedStyle(document.body)['padding-right']; + Manipulator.setDataAttribute(document.body, 'padding-right', actualPadding); + document.body.style.paddingRight = parseFloat(calculatedPadding) + this._scrollbarWidth + "px"; } - $(document.body).addClass(ClassName$5.OPEN); + document.body.classList.add(CLASS_NAME_OPEN); }; _proto._resetScrollbar = function _resetScrollbar() { // Restore fixed content padding - var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT)); - $(fixedContent).each(function (index, element) { - var padding = $(element).data('padding-right'); - $(element).removeData('padding-right'); - element.style.paddingRight = padding ? padding : ''; - }); // Restore sticky content + SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) { + var padding = Manipulator.getDataAttribute(element, 'padding-right'); - var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT)); - $(elements).each(function (index, element) { - var margin = $(element).data('margin-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(function (element) { + var margin = Manipulator.getDataAttribute(element, 'margin-right'); if (typeof margin !== 'undefined') { - $(element).css('margin-right', margin).removeData('margin-right'); + Manipulator.removeDataAttribute(element, 'margin-right'); + element.style.marginRight = margin; } }); // Restore body padding - var padding = $(document.body).data('padding-right'); - $(document.body).removeData('padding-right'); - document.body.style.paddingRight = padding ? padding : ''; + var 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; + } }; _proto._getScrollbarWidth = function _getScrollbarWidth() { // thx d.walsh var scrollDiv = document.createElement('div'); - scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER; + scrollDiv.className = CLASS_NAME_SCROLLBAR_MEASURER; document.body.appendChild(scrollDiv); var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth; document.body.removeChild(scrollDiv); @@ -5099,15 +5720,14 @@ } // Static ; - Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) { + Modal.jQueryInterface = function jQueryInterface(config, relatedTarget) { return this.each(function () { - var data = $(this).data(DATA_KEY$5); + var data = Data.getData(this, DATA_KEY$5); - var _config = _objectSpread({}, Default$3, $(this).data(), typeof config === 'object' && config ? config : {}); + var _config = _extends({}, Default$3, Manipulator.getDataAttributes(this), typeof config === 'object' && config ? config : {}); if (!data) { data = new Modal(this, _config); - $(this).data(DATA_KEY$5, data); } if (typeof config === 'string') { @@ -5122,6 +5742,10 @@ }); }; + Modal.getInstance = function getInstance(element) { + return Data.getData(element, DATA_KEY$5); + }; + _createClass(Modal, null, [{ key: "VERSION", get: function get() { @@ -5143,60 +5767,106 @@ */ - $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) { - var _this10 = this; - - var target; - var selector = Util.getSelectorFromElement(this); + EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_TOGGLE$3, function (event) { + var _this11 = this; - if (selector) { - target = document.querySelector(selector); - } - - var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread({}, $(target).data(), $(this).data()); + var target = getElementFromSelector(this); if (this.tagName === 'A' || this.tagName === 'AREA') { event.preventDefault(); } - var $target = $(target).one(Event$5.SHOW, function (showEvent) { - if (showEvent.isDefaultPrevented()) { - // Only register focus restorer if modal will actually get shown + EventHandler.one(target, EVENT_SHOW$2, function (showEvent) { + if (showEvent.defaultPrevented) { + // only register focus restorer if modal will actually get shown return; } - $target.one(Event$5.HIDDEN, function () { - if ($(_this10).is(':visible')) { - _this10.focus(); + EventHandler.one(target, EVENT_HIDDEN$2, function () { + if (isVisible(_this11)) { + _this11.focus(); } }); }); + var data = Data.getData(target, DATA_KEY$5); + + if (!data) { + var config = _extends({}, Manipulator.getDataAttributes(target), Manipulator.getDataAttributes(this)); - Modal._jQueryInterface.call($(target), config, this); + data = new Modal(target, config); + } + + data.show(this); }); + var $$6 = getjQuery(); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ + * add .modal to jQuery only if jQuery is present */ - $.fn[NAME$5] = Modal._jQueryInterface; - $.fn[NAME$5].Constructor = Modal; + /* istanbul ignore if */ - $.fn[NAME$5].noConflict = function () { - $.fn[NAME$5] = JQUERY_NO_CONFLICT$5; - return Modal._jQueryInterface; - }; + if ($$6) { + var JQUERY_NO_CONFLICT$5 = $$6.fn[NAME$5]; + $$6.fn[NAME$5] = Modal.jQueryInterface; + $$6.fn[NAME$5].Constructor = Modal; + + $$6.fn[NAME$5].noConflict = function () { + $$6.fn[NAME$5] = JQUERY_NO_CONFLICT$5; + return Modal.jQueryInterface; + }; + } /** * -------------------------------------------------------------------------- - * Bootstrap (v4.3.1): tools/sanitizer.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * Bootstrap (v5.0.0-alpha2): util/sanitizer.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']; var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; - var DefaultWhitelist = { + /** + * 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 + */ + + var 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 + */ + + var 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; + + var allowedAttribute = function allowedAttribute(attr, allowedAttributeList) { + var attrName = attr.nodeName.toLowerCase(); + + if (allowedAttributeList.indexOf(attrName) !== -1) { + if (uriAttrs.indexOf(attrName) !== -1) { + return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)); + } + + return true; + } + + var regExp = allowedAttributeList.filter(function (attrRegex) { + return attrRegex instanceof RegExp; + }); // Check if a regular expression validates the attribute. + + for (var i = 0, len = regExp.length; i < len; i++) { + if (attrName.match(regExp[i])) { + return true; + } + } + + return false; + }; + + var DefaultAllowlist = { // Global attributes allowed on any supplied element below. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN], a: ['target', 'href', 'title', 'rel'], @@ -5215,7 +5885,7 @@ h5: [], h6: [], i: [], - img: ['src', 'alt', 'title', 'width', 'height'], + img: ['src', 'srcset', 'alt', 'title', 'width', 'height'], li: [], ol: [], p: [], @@ -5228,48 +5898,11 @@ strong: [], u: [], ul: [] - /** - * 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 - */ - }; - var 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 - */ - - var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i; - - function allowedAttribute(attr, allowedAttributeList) { - var attrName = attr.nodeName.toLowerCase(); - - if (allowedAttributeList.indexOf(attrName) !== -1) { - if (uriAttrs.indexOf(attrName) !== -1) { - return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)); - } - - return true; - } - - var regExp = allowedAttributeList.filter(function (attrRegex) { - return attrRegex instanceof RegExp; - }); // Check if a regular expression validates the attribute. - - for (var i = 0, l = regExp.length; i < l; i++) { - if (attrName.match(regExp[i])) { - return true; - } - } - - return false; - } + function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) { + var _ref; - function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) { - if (unsafeHtml.length === 0) { + if (!unsafeHtml.length) { return unsafeHtml; } @@ -5279,29 +5912,33 @@ var domParser = new window.DOMParser(); var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html'); - var whitelistKeys = Object.keys(whiteList); - var elements = [].slice.call(createdDocument.body.querySelectorAll('*')); + var allowlistKeys = Object.keys(allowList); + + var elements = (_ref = []).concat.apply(_ref, createdDocument.body.querySelectorAll('*')); var _loop = function _loop(i, len) { + var _ref2; + var el = elements[i]; var elName = el.nodeName.toLowerCase(); - if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) { + if (allowlistKeys.indexOf(elName) === -1) { el.parentNode.removeChild(el); return "continue"; } - var attributeList = [].slice.call(el.attributes); - var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []); + var attributeList = (_ref2 = []).concat.apply(_ref2, el.attributes); + + var allowedAttributes = [].concat(allowList['*'] || [], allowList[elName] || []); attributeList.forEach(function (attr) { - if (!allowedAttribute(attr, whitelistedAttributes)) { + if (!allowedAttribute(attr, allowedAttributes)) { el.removeAttribute(attr.nodeName); } }); }; for (var i = 0, len = elements.length; i < len; i++) { - var _ret = _loop(i, len); + var _ret = _loop(i); if (_ret === "continue") continue; } @@ -5316,13 +5953,12 @@ */ var NAME$6 = 'tooltip'; - var VERSION$6 = '4.3.1'; + var VERSION$6 = '5.0.0-alpha2'; var DATA_KEY$6 = 'bs.tooltip'; var EVENT_KEY$6 = "." + DATA_KEY$6; - var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6]; var CLASS_PREFIX = 'bs-tooltip'; var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g'); - var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn']; + var DISALLOWED_ATTRIBUTES = ['sanitize', 'allowList', 'sanitizeFn']; var DefaultType$4 = { animation: 'boolean', template: 'string', @@ -5338,9 +5974,10 @@ boundary: '(string|element)', sanitize: 'boolean', sanitizeFn: '(null|function)', - whiteList: 'object' + allowList: 'object', + popperConfig: '(null|object)' }; - var AttachmentMap$1 = { + var AttachmentMap = { AUTO: 'auto', TOP: 'top', RIGHT: 'right', @@ -5349,7 +5986,7 @@ }; var Default$4 = { animation: true, - template: '', + template: '', trigger: 'hover focus', title: '', delay: 0, @@ -5362,13 +5999,10 @@ boundary: 'scrollParent', sanitize: true, sanitizeFn: null, - whiteList: DefaultWhitelist + allowList: DefaultAllowlist, + popperConfig: null }; - var HoverState = { - SHOW: 'show', - OUT: 'out' - }; - var Event$6 = { + var Event$1 = { HIDE: "hide" + EVENT_KEY$6, HIDDEN: "hidden" + EVENT_KEY$6, SHOW: "show" + EVENT_KEY$6, @@ -5380,38 +6014,26 @@ MOUSEENTER: "mouseenter" + EVENT_KEY$6, MOUSELEAVE: "mouseleave" + EVENT_KEY$6 }; - var ClassName$6 = { - FADE: 'fade', - SHOW: 'show' - }; - var Selector$6 = { - TOOLTIP: '.tooltip', - TOOLTIP_INNER: '.tooltip-inner', - ARROW: '.arrow' - }; - var Trigger = { - HOVER: 'hover', - FOCUS: 'focus', - CLICK: 'click', - MANUAL: 'manual' - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ - - }; + var CLASS_NAME_FADE$1 = 'fade'; + var CLASS_NAME_MODAL = 'modal'; + var CLASS_NAME_SHOW$3 = 'show'; + var HOVER_STATE_SHOW = 'show'; + var HOVER_STATE_OUT = 'out'; + var SELECTOR_TOOLTIP_INNER = '.tooltip-inner'; + var TRIGGER_HOVER = 'hover'; + var TRIGGER_FOCUS = 'focus'; + var TRIGGER_CLICK = 'click'; + var TRIGGER_MANUAL = 'manual'; + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - var Tooltip = - /*#__PURE__*/ - function () { + var Tooltip = /*#__PURE__*/function () { function Tooltip(element, config) { - /** - * Check for Popper dependency - * Popper - https://popper.js.org - */ if (typeof Popper === 'undefined') { - throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)'); + throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org)'); } // private @@ -5426,6 +6048,8 @@ this.tip = null; this._setListeners(); + + Data.setData(element, this.constructor.DATA_KEY, this); } // Getters @@ -5451,11 +6075,11 @@ if (event) { var dataKey = this.constructor.DATA_KEY; - var context = $(event.currentTarget).data(dataKey); + var context = Data.getData(event.delegateTarget, dataKey); if (!context) { - context = new this.constructor(event.currentTarget, this._getDelegateConfig()); - $(event.currentTarget).data(dataKey, context); + context = new this.constructor(event.delegateTarget, this._getDelegateConfig()); + Data.setData(event.delegateTarget, dataKey, context); } context._activeTrigger.click = !context._activeTrigger.click; @@ -5466,7 +6090,7 @@ context._leave(null, context); } } else { - if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) { + if (this.getTipElement().classList.contains(CLASS_NAME_SHOW$3)) { this._leave(null, this); return; @@ -5478,12 +6102,12 @@ _proto.dispose = function dispose() { clearTimeout(this._timeout); - $.removeData(this.element, this.constructor.DATA_KEY); - $(this.element).off(this.constructor.EVENT_KEY); - $(this.element).closest('.modal').off('hide.bs.modal'); + Data.removeData(this.element, this.constructor.DATA_KEY); + 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).remove(); + this.tip.parentNode.removeChild(this.tip); } this._isEnabled = null; @@ -5491,7 +6115,7 @@ this._hoverState = null; this._activeTrigger = null; - if (this._popper !== null) { + if (this._popper) { this._popper.destroy(); } @@ -5504,76 +6128,56 @@ _proto.show = function show() { var _this = this; - if ($(this.element).css('display') === 'none') { + if (this.element.style.display === 'none') { throw new Error('Please use show on visible elements'); } - var showEvent = $.Event(this.constructor.Event.SHOW); - if (this.isWithContent() && this._isEnabled) { - $(this.element).trigger(showEvent); - var shadowRoot = Util.findShadowRoot(this.element); - var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element); + var showEvent = EventHandler.trigger(this.element, this.constructor.Event.SHOW); + var shadowRoot = findShadowRoot(this.element); + var isInTheDom = shadowRoot === null ? this.element.ownerDocument.documentElement.contains(this.element) : shadowRoot.contains(this.element); - if (showEvent.isDefaultPrevented() || !isInTheDom) { + if (showEvent.defaultPrevented || !isInTheDom) { return; } var tip = this.getTipElement(); - var tipId = Util.getUID(this.constructor.NAME); + var tipId = getUID(this.constructor.NAME); tip.setAttribute('id', tipId); this.element.setAttribute('aria-describedby', tipId); this.setContent(); if (this.config.animation) { - $(tip).addClass(ClassName$6.FADE); + tip.classList.add(CLASS_NAME_FADE$1); } var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement; var attachment = this._getAttachment(placement); - this.addAttachmentClass(attachment); + this._addAttachmentClass(attachment); var container = this._getContainer(); - $(tip).data(this.constructor.DATA_KEY, this); + Data.setData(tip, this.constructor.DATA_KEY, this); - if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) { - $(tip).appendTo(container); + if (!this.element.ownerDocument.documentElement.contains(this.tip)) { + container.appendChild(tip); } - $(this.element).trigger(this.constructor.Event.INSERTED); - this._popper = new Popper(this.element, tip, { - placement: attachment, - modifiers: { - offset: this._getOffset(), - flip: { - behavior: this.config.fallbackPlacement - }, - arrow: { - element: Selector$6.ARROW - }, - preventOverflow: { - boundariesElement: this.config.boundary - } - }, - onCreate: function onCreate(data) { - if (data.originalPlacement !== data.placement) { - _this._handlePopperPlacementChange(data); - } - }, - onUpdate: function onUpdate(data) { - return _this._handlePopperPlacementChange(data); - } - }); - $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra + EventHandler.trigger(this.element, this.constructor.Event.INSERTED); + this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment)); + tip.classList.add(CLASS_NAME_SHOW$3); // 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) { - $(document.body).children().on('mouseover', null, $.noop); + var _ref; + + (_ref = []).concat.apply(_ref, document.body.children).forEach(function (element) { + EventHandler.on(element, 'mouseover', noop()); + }); } var complete = function complete() { @@ -5583,30 +6187,34 @@ var prevHoverState = _this._hoverState; _this._hoverState = null; - $(_this.element).trigger(_this.constructor.Event.SHOWN); + EventHandler.trigger(_this.element, _this.constructor.Event.SHOWN); - if (prevHoverState === HoverState.OUT) { + if (prevHoverState === HOVER_STATE_OUT) { _this._leave(null, _this); } }; - if ($(this.tip).hasClass(ClassName$6.FADE)) { - var transitionDuration = Util.getTransitionDurationFromElement(this.tip); - $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); + if (this.tip.classList.contains(CLASS_NAME_FADE$1)) { + var transitionDuration = getTransitionDurationFromElement(this.tip); + EventHandler.one(this.tip, TRANSITION_END, complete); + emulateTransitionEnd(this.tip, transitionDuration); } else { complete(); } } }; - _proto.hide = function hide(callback) { + _proto.hide = function hide() { var _this2 = this; + if (!this._popper) { + return; + } + var tip = this.getTipElement(); - var hideEvent = $.Event(this.constructor.Event.HIDE); var complete = function complete() { - if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) { + if (_this2._hoverState !== HOVER_STATE_SHOW && tip.parentNode) { tip.parentNode.removeChild(tip); } @@ -5614,37 +6222,36 @@ _this2.element.removeAttribute('aria-describedby'); - $(_this2.element).trigger(_this2.constructor.Event.HIDDEN); - - if (_this2._popper !== null) { - _this2._popper.destroy(); - } + EventHandler.trigger(_this2.element, _this2.constructor.Event.HIDDEN); - if (callback) { - callback(); - } + _this2._popper.destroy(); }; - $(this.element).trigger(hideEvent); + var hideEvent = EventHandler.trigger(this.element, this.constructor.Event.HIDE); - if (hideEvent.isDefaultPrevented()) { + if (hideEvent.defaultPrevented) { return; } - $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra + tip.classList.remove(CLASS_NAME_SHOW$3); // If this is a touch-enabled device we remove the extra // empty mouseover listeners we added for iOS support if ('ontouchstart' in document.documentElement) { - $(document.body).children().off('mouseover', null, $.noop); + var _ref2; + + (_ref2 = []).concat.apply(_ref2, document.body.children).forEach(function (element) { + return EventHandler.off(element, 'mouseover', noop); + }); } - this._activeTrigger[Trigger.CLICK] = false; - this._activeTrigger[Trigger.FOCUS] = false; - this._activeTrigger[Trigger.HOVER] = false; + this._activeTrigger[TRIGGER_CLICK] = false; + this._activeTrigger[TRIGGER_FOCUS] = false; + this._activeTrigger[TRIGGER_HOVER] = false; - if ($(this.tip).hasClass(ClassName$6.FADE)) { - var transitionDuration = Util.getTransitionDurationFromElement(tip); - $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); + if (this.tip.classList.contains(CLASS_NAME_FADE$1)) { + var transitionDuration = getTransitionDurationFromElement(tip); + EventHandler.one(tip, TRANSITION_END, complete); + emulateTransitionEnd(tip, transitionDuration); } else { complete(); } @@ -5663,30 +6270,41 @@ return Boolean(this.getTitle()); }; - _proto.addAttachmentClass = function addAttachmentClass(attachment) { - $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment); - }; - _proto.getTipElement = function getTipElement() { - this.tip = this.tip || $(this.config.template)[0]; + if (this.tip) { + return this.tip; + } + + var element = document.createElement('div'); + element.innerHTML = this.config.template; + this.tip = element.children[0]; return this.tip; }; _proto.setContent = function setContent() { var tip = this.getTipElement(); - this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle()); - $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW); + this.setElementContent(SelectorEngine.findOne(SELECTOR_TOOLTIP_INNER, tip), this.getTitle()); + tip.classList.remove(CLASS_NAME_FADE$1, CLASS_NAME_SHOW$3); }; - _proto.setElementContent = function setElementContent($element, content) { - if (typeof content === 'object' && (content.nodeType || content.jquery)) { - // Content is a DOM node or a jQuery + _proto.setElementContent = function 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).parent().is($element)) { - $element.empty().append(content); + if (content.parentNode !== element) { + element.innerHTML = ''; + element.appendChild(content); } } else { - $element.text($(content).text()); + element.textContent = content.textContent; } return; @@ -5694,12 +6312,12 @@ if (this.config.html) { if (this.config.sanitize) { - content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn); + content = sanitizeHtml(content, this.config.allowList, this.config.sanitizeFn); } - $element.html(content); + element.innerHTML = content; } else { - $element.text(content); + element.textContent = content; } }; @@ -5714,14 +6332,47 @@ } // Private ; - _proto._getOffset = function _getOffset() { + _proto._getPopperConfig = function _getPopperConfig(attachment) { var _this3 = this; + var defaultBsConfig = { + placement: attachment, + modifiers: { + offset: this._getOffset(), + flip: { + behavior: this.config.fallbackPlacement + }, + arrow: { + element: "." + this.constructor.NAME + "-arrow" + }, + preventOverflow: { + boundariesElement: this.config.boundary + } + }, + onCreate: function onCreate(data) { + if (data.originalPlacement !== data.placement) { + _this3._handlePopperPlacementChange(data); + } + }, + onUpdate: function onUpdate(data) { + return _this3._handlePopperPlacementChange(data); + } + }; + return _extends({}, defaultBsConfig, this.config.popperConfig); + }; + + _proto._addAttachmentClass = function _addAttachmentClass(attachment) { + this.getTipElement().classList.add(CLASS_PREFIX + "-" + attachment); + }; + + _proto._getOffset = function _getOffset() { + var _this4 = this; + var offset = {}; if (typeof this.config.offset === 'function') { offset.fn = function (data) { - data.offsets = _objectSpread({}, data.offsets, _this3.config.offset(data.offsets, _this3.element) || {}); + data.offsets = _extends({}, data.offsets, _this4.config.offset(data.offsets, _this4.element) || {}); return data; }; } else { @@ -5736,44 +6387,48 @@ return document.body; } - if (Util.isElement(this.config.container)) { - return $(this.config.container); + if (isElement(this.config.container)) { + return this.config.container; } - return $(document).find(this.config.container); + return SelectorEngine.findOne(this.config.container); }; _proto._getAttachment = function _getAttachment(placement) { - return AttachmentMap$1[placement.toUpperCase()]; + return AttachmentMap[placement.toUpperCase()]; }; _proto._setListeners = function _setListeners() { - var _this4 = this; + var _this5 = this; var triggers = this.config.trigger.split(' '); triggers.forEach(function (trigger) { if (trigger === 'click') { - $(_this4.element).on(_this4.constructor.Event.CLICK, _this4.config.selector, function (event) { - return _this4.toggle(event); + EventHandler.on(_this5.element, _this5.constructor.Event.CLICK, _this5.config.selector, function (event) { + return _this5.toggle(event); + }); + } else if (trigger !== TRIGGER_MANUAL) { + var eventIn = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN; + var eventOut = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT; + EventHandler.on(_this5.element, eventIn, _this5.config.selector, function (event) { + return _this5._enter(event); }); - } else if (trigger !== Trigger.MANUAL) { - var eventIn = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSEENTER : _this4.constructor.Event.FOCUSIN; - var eventOut = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSELEAVE : _this4.constructor.Event.FOCUSOUT; - $(_this4.element).on(eventIn, _this4.config.selector, function (event) { - return _this4._enter(event); - }).on(eventOut, _this4.config.selector, function (event) { - return _this4._leave(event); + EventHandler.on(_this5.element, eventOut, _this5.config.selector, function (event) { + return _this5._leave(event); }); } }); - $(this.element).closest('.modal').on('hide.bs.modal', function () { - if (_this4.element) { - _this4.hide(); + + this._hideModalHandler = function () { + if (_this5.element) { + _this5.hide(); } - }); + }; + + EventHandler.on(this.element.closest("." + CLASS_NAME_MODAL), 'hide.bs.modal', this._hideModalHandler); if (this.config.selector) { - this.config = _objectSpread({}, this.config, { + this.config = _extends({}, this.config, { trigger: 'manual', selector: '' }); @@ -5793,24 +6448,24 @@ _proto._enter = function _enter(event, context) { var dataKey = this.constructor.DATA_KEY; - context = context || $(event.currentTarget).data(dataKey); + context = context || Data.getData(event.delegateTarget, dataKey); if (!context) { - context = new this.constructor(event.currentTarget, this._getDelegateConfig()); - $(event.currentTarget).data(dataKey, 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; + context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true; } - if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) { - context._hoverState = HoverState.SHOW; + if (context.getTipElement().classList.contains(CLASS_NAME_SHOW$3) || context._hoverState === HOVER_STATE_SHOW) { + context._hoverState = HOVER_STATE_SHOW; return; } clearTimeout(context._timeout); - context._hoverState = HoverState.SHOW; + context._hoverState = HOVER_STATE_SHOW; if (!context.config.delay || !context.config.delay.show) { context.show(); @@ -5818,7 +6473,7 @@ } context._timeout = setTimeout(function () { - if (context._hoverState === HoverState.SHOW) { + if (context._hoverState === HOVER_STATE_SHOW) { context.show(); } }, context.config.delay.show); @@ -5826,15 +6481,15 @@ _proto._leave = function _leave(event, context) { var dataKey = this.constructor.DATA_KEY; - context = context || $(event.currentTarget).data(dataKey); + context = context || Data.getData(event.delegateTarget, dataKey); if (!context) { - context = new this.constructor(event.currentTarget, this._getDelegateConfig()); - $(event.currentTarget).data(dataKey, 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; + context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = false; } if (context._isWithActiveTrigger()) { @@ -5842,7 +6497,7 @@ } clearTimeout(context._timeout); - context._hoverState = HoverState.OUT; + context._hoverState = HOVER_STATE_OUT; if (!context.config.delay || !context.config.delay.hide) { context.hide(); @@ -5850,7 +6505,7 @@ } context._timeout = setTimeout(function () { - if (context._hoverState === HoverState.OUT) { + if (context._hoverState === HOVER_STATE_OUT) { context.hide(); } }, context.config.delay.hide); @@ -5867,13 +6522,18 @@ }; _proto._getConfig = function _getConfig(config) { - var dataAttributes = $(this.element).data(); + var dataAttributes = Manipulator.getDataAttributes(this.element); Object.keys(dataAttributes).forEach(function (dataAttr) { if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) { delete dataAttributes[dataAttr]; } }); - config = _objectSpread({}, this.constructor.Default, dataAttributes, typeof config === 'object' && config ? config : {}); + + if (config && typeof config.container === 'object' && config.container.jquery) { + config.container = config.container[0]; + } + + config = _extends({}, this.constructor.Default, dataAttributes, typeof config === 'object' && config ? config : {}); if (typeof config.delay === 'number') { config.delay = { @@ -5890,10 +6550,10 @@ config.content = config.content.toString(); } - Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType); + typeCheckConfig(NAME$6, config, this.constructor.DefaultType); if (config.sanitize) { - config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn); + config.template = sanitizeHtml(config.template, config.allowList, config.sanitizeFn); } return config; @@ -5914,21 +6574,24 @@ }; _proto._cleanTipClass = function _cleanTipClass() { - var $tip = $(this.getTipElement()); - var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX); + var tip = this.getTipElement(); + var tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX); - if (tabClass !== null && tabClass.length) { - $tip.removeClass(tabClass.join('')); + if (tabClass !== null && tabClass.length > 0) { + tabClass.map(function (token) { + return token.trim(); + }).forEach(function (tClass) { + return tip.classList.remove(tClass); + }); } }; _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) { - var popperInstance = popperData.instance; - this.tip = popperInstance.popper; + this.tip = popperData.instance.popper; this._cleanTipClass(); - this.addAttachmentClass(this._getAttachment(popperData.placement)); + this._addAttachmentClass(this._getAttachment(popperData.placement)); }; _proto._fixTransition = function _fixTransition() { @@ -5939,7 +6602,7 @@ return; } - $(tip).removeClass(ClassName$6.FADE); + tip.classList.remove(CLASS_NAME_FADE$1); this.config.animation = false; this.hide(); this.show(); @@ -5947,9 +6610,9 @@ } // Static ; - Tooltip._jQueryInterface = function _jQueryInterface(config) { + Tooltip.jQueryInterface = function jQueryInterface(config) { return this.each(function () { - var data = $(this).data(DATA_KEY$6); + var data = Data.getData(this, DATA_KEY$6); var _config = typeof config === 'object' && config; @@ -5959,7 +6622,6 @@ if (!data) { data = new Tooltip(this, _config); - $(this).data(DATA_KEY$6, data); } if (typeof config === 'string') { @@ -5972,6 +6634,10 @@ }); }; + Tooltip.getInstance = function getInstance(element) { + return Data.getData(element, DATA_KEY$6); + }; + _createClass(Tooltip, null, [{ key: "VERSION", get: function get() { @@ -5995,7 +6661,7 @@ }, { key: "Event", get: function get() { - return Event$6; + return Event$1; } }, { key: "EVENT_KEY", @@ -6011,20 +6677,27 @@ return Tooltip; }(); + + var $$7 = getjQuery(); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ + * add .tooltip to jQuery only if jQuery is present */ + /* istanbul ignore if */ - $.fn[NAME$6] = Tooltip._jQueryInterface; - $.fn[NAME$6].Constructor = Tooltip; + if ($$7) { + var JQUERY_NO_CONFLICT$6 = $$7.fn[NAME$6]; + $$7.fn[NAME$6] = Tooltip.jQueryInterface; + $$7.fn[NAME$6].Constructor = Tooltip; - $.fn[NAME$6].noConflict = function () { - $.fn[NAME$6] = JQUERY_NO_CONFLICT$6; - return Tooltip._jQueryInterface; - }; + $$7.fn[NAME$6].noConflict = function () { + $$7.fn[NAME$6] = JQUERY_NO_CONFLICT$6; + return Tooltip.jQueryInterface; + }; + } /** * ------------------------------------------------------------------------ @@ -6033,33 +6706,24 @@ */ var NAME$7 = 'popover'; - var VERSION$7 = '4.3.1'; + var VERSION$7 = '5.0.0-alpha2'; var DATA_KEY$7 = 'bs.popover'; var EVENT_KEY$7 = "." + DATA_KEY$7; - var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7]; var CLASS_PREFIX$1 = 'bs-popover'; var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g'); - var Default$5 = _objectSpread({}, Tooltip.Default, { + var Default$5 = _extends({}, Tooltip.Default, { placement: 'right', trigger: 'click', content: '', - template: '' + template: '' }); - var DefaultType$5 = _objectSpread({}, Tooltip.DefaultType, { + var DefaultType$5 = _extends({}, Tooltip.DefaultType, { content: '(string|element|function)' }); - var ClassName$7 = { - FADE: 'fade', - SHOW: 'show' - }; - var Selector$7 = { - TITLE: '.popover-header', - CONTENT: '.popover-body' - }; - var Event$7 = { + var Event$2 = { HIDE: "hide" + EVENT_KEY$7, HIDDEN: "hidden" + EVENT_KEY$7, SHOW: "show" + EVENT_KEY$7, @@ -6070,17 +6734,18 @@ FOCUSOUT: "focusout" + EVENT_KEY$7, MOUSEENTER: "mouseenter" + EVENT_KEY$7, MOUSELEAVE: "mouseleave" + EVENT_KEY$7 - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ - }; + var CLASS_NAME_FADE$2 = 'fade'; + var CLASS_NAME_SHOW$4 = 'show'; + var SELECTOR_TITLE = '.popover-header'; + var SELECTOR_CONTENT = '.popover-body'; + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - var Popover = - /*#__PURE__*/ - function (_Tooltip) { + var Popover = /*#__PURE__*/function (_Tooltip) { _inheritsLoose(Popover, _Tooltip); function Popover() { @@ -6094,19 +6759,10 @@ return this.getTitle() || this._getContent(); }; - _proto.addAttachmentClass = function addAttachmentClass(attachment) { - $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment); - }; - - _proto.getTipElement = function getTipElement() { - this.tip = this.tip || $(this.config.template)[0]; - return this.tip; - }; - _proto.setContent = function setContent() { - var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events + var tip = this.getTipElement(); // we use append for html objects to maintain js events - this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle()); + this.setElementContent(SelectorEngine.findOne(SELECTOR_TITLE, tip), this.getTitle()); var content = this._getContent(); @@ -6114,28 +6770,36 @@ content = content.call(this.element); } - this.setElementContent($tip.find(Selector$7.CONTENT), content); - $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW); + this.setElementContent(SelectorEngine.findOne(SELECTOR_CONTENT, tip), content); + tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$4); } // Private ; + _proto._addAttachmentClass = function _addAttachmentClass(attachment) { + this.getTipElement().classList.add(CLASS_PREFIX$1 + "-" + attachment); + }; + _proto._getContent = function _getContent() { return this.element.getAttribute('data-content') || this.config.content; }; _proto._cleanTipClass = function _cleanTipClass() { - var $tip = $(this.getTipElement()); - var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1); + var tip = this.getTipElement(); + var tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX$1); if (tabClass !== null && tabClass.length > 0) { - $tip.removeClass(tabClass.join('')); + tabClass.map(function (token) { + return token.trim(); + }).forEach(function (tClass) { + return tip.classList.remove(tClass); + }); } } // Static ; - Popover._jQueryInterface = function _jQueryInterface(config) { + Popover.jQueryInterface = function jQueryInterface(config) { return this.each(function () { - var data = $(this).data(DATA_KEY$7); + var data = Data.getData(this, DATA_KEY$7); var _config = typeof config === 'object' ? config : null; @@ -6145,7 +6809,7 @@ if (!data) { data = new Popover(this, _config); - $(this).data(DATA_KEY$7, data); + Data.setData(this, DATA_KEY$7, data); } if (typeof config === 'string') { @@ -6158,6 +6822,10 @@ }); }; + Popover.getInstance = function getInstance(element) { + return Data.getData(element, DATA_KEY$7); + }; + _createClass(Popover, null, [{ key: "VERSION", // Getters @@ -6182,7 +6850,7 @@ }, { key: "Event", get: function get() { - return Event$7; + return Event$2; } }, { key: "EVENT_KEY", @@ -6198,20 +6866,26 @@ return Popover; }(Tooltip); + + var $$8 = getjQuery(); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ */ + /* istanbul ignore if */ - $.fn[NAME$7] = Popover._jQueryInterface; - $.fn[NAME$7].Constructor = Popover; + if ($$8) { + var JQUERY_NO_CONFLICT$7 = $$8.fn[NAME$7]; + $$8.fn[NAME$7] = Popover.jQueryInterface; + $$8.fn[NAME$7].Constructor = Popover; - $.fn[NAME$7].noConflict = function () { - $.fn[NAME$7] = JQUERY_NO_CONFLICT$7; - return Popover._jQueryInterface; - }; + $$8.fn[NAME$7].noConflict = function () { + $$8.fn[NAME$7] = JQUERY_NO_CONFLICT$7; + return Popover.jQueryInterface; + }; + } /** * ------------------------------------------------------------------------ @@ -6220,11 +6894,10 @@ */ var NAME$8 = 'scrollspy'; - var VERSION$8 = '4.3.1'; + var VERSION$8 = '5.0.0-alpha2'; var DATA_KEY$8 = 'bs.scrollspy'; var EVENT_KEY$8 = "." + DATA_KEY$8; var DATA_API_KEY$6 = '.data-api'; - var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8]; var Default$6 = { offset: 10, method: 'auto', @@ -6235,58 +6908,46 @@ method: 'string', target: '(string|element)' }; - var Event$8 = { - ACTIVATE: "activate" + EVENT_KEY$8, - SCROLL: "scroll" + EVENT_KEY$8, - LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6 - }; - var ClassName$8 = { - DROPDOWN_ITEM: 'dropdown-item', - DROPDOWN_MENU: 'dropdown-menu', - ACTIVE: 'active' - }; - var Selector$8 = { - DATA_SPY: '[data-spy="scroll"]', - ACTIVE: '.active', - NAV_LIST_GROUP: '.nav, .list-group', - NAV_LINKS: '.nav-link', - NAV_ITEMS: '.nav-item', - LIST_ITEMS: '.list-group-item', - DROPDOWN: '.dropdown', - DROPDOWN_ITEMS: '.dropdown-item', - DROPDOWN_TOGGLE: '.dropdown-toggle' - }; - var OffsetMethod = { - OFFSET: 'offset', - POSITION: 'position' - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ - - }; + var EVENT_ACTIVATE = "activate" + EVENT_KEY$8; + var EVENT_SCROLL = "scroll" + EVENT_KEY$8; + var EVENT_LOAD_DATA_API$1 = "load" + EVENT_KEY$8 + DATA_API_KEY$6; + var CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item'; + var CLASS_NAME_ACTIVE$2 = 'active'; + 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'; + var SELECTOR_LIST_ITEMS = '.list-group-item'; + var SELECTOR_DROPDOWN = '.dropdown'; + var SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'; + var METHOD_OFFSET = 'offset'; + var METHOD_POSITION = 'position'; + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - var ScrollSpy = - /*#__PURE__*/ - function () { + var ScrollSpy = /*#__PURE__*/function () { function ScrollSpy(element, config) { var _this = this; this._element = element; this._scrollElement = element.tagName === 'BODY' ? window : element; this._config = this._getConfig(config); - this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS); + 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; - $(this._scrollElement).on(Event$8.SCROLL, function (event) { + EventHandler.on(this._scrollElement, EVENT_SCROLL, function (event) { return _this._process(event); }); this.refresh(); this._process(); + + Data.setData(element, DATA_KEY$8, this); } // Getters @@ -6296,27 +6957,22 @@ _proto.refresh = function refresh() { var _this2 = this; - var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION; + var autoMethod = this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION; var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method; - var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0; + var offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0; this._offsets = []; this._targets = []; this._scrollHeight = this._getScrollHeight(); - var targets = [].slice.call(document.querySelectorAll(this._selector)); + var targets = SelectorEngine.find(this._selector); targets.map(function (element) { - var target; - var targetSelector = Util.getSelectorFromElement(element); - - if (targetSelector) { - target = document.querySelector(targetSelector); - } + var targetSelector = getSelectorFromElement(element); + var target = targetSelector ? SelectorEngine.findOne(targetSelector) : null; if (target) { var targetBCR = target.getBoundingClientRect(); if (targetBCR.width || targetBCR.height) { - // TODO (fat): remove sketch reliance on jQuery position/offset - return [$(target)[offsetMethod]().top + offsetBase, targetSelector]; + return [Manipulator[offsetMethod](target).top + offsetBase, targetSelector]; } } @@ -6333,8 +6989,8 @@ }; _proto.dispose = function dispose() { - $.removeData(this._element, DATA_KEY$8); - $(this._scrollElement).off(EVENT_KEY$8); + Data.removeData(this._element, DATA_KEY$8); + EventHandler.off(this._scrollElement, EVENT_KEY$8); this._element = null; this._scrollElement = null; this._config = null; @@ -6347,20 +7003,20 @@ ; _proto._getConfig = function _getConfig(config) { - config = _objectSpread({}, Default$6, typeof config === 'object' && config ? config : {}); + config = _extends({}, Default$6, typeof config === 'object' && config ? config : {}); - if (typeof config.target !== 'string') { - var id = $(config.target).attr('id'); + if (typeof config.target !== 'string' && isElement(config.target)) { + var id = config.target.id; if (!id) { - id = Util.getUID(NAME$8); - $(config.target).attr('id', id); + id = getUID(NAME$8); + config.target.id = id; } config.target = "#" + id; } - Util.typeCheckConfig(NAME$8, config, DefaultType$6); + typeCheckConfig(NAME$8, config, DefaultType$6); return config; }; @@ -6405,9 +7061,7 @@ return; } - var offsetLength = this._offsets.length; - - for (var i = offsetLength; i--;) { + for (var i = this._offsets.length; i--;) { var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]); if (isActiveTarget) { @@ -6425,44 +7079,51 @@ return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]"; }); - var $link = $([].slice.call(document.querySelectorAll(queries.join(',')))); + var link = SelectorEngine.findOne(queries.join(',')); - if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) { - $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE); - $link.addClass(ClassName$8.ACTIVE); + if (link.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) { + SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE, link.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE$2); + link.classList.add(CLASS_NAME_ACTIVE$2); } else { // Set triggered link as active - $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active - // With both