pax_global_header00006660000000000000000000000064151406352700014515gustar00rootroot0000000000000052 comment=0686d916bd1cb18aead107f34fba141ed5fa8a32 swup-fragment-plugin-0686d91/000077500000000000000000000000001514063527000160735ustar00rootroot00000000000000swup-fragment-plugin-0686d91/.editorconfig000077500000000000000000000004361514063527000205560ustar00rootroot00000000000000root = true [*] charset = utf-8 end_of_line = lf trim_trailing_whitespace = true insert_final_newline = true max_line_length = 100 [*.{js,mjs,ts}] indent_style = tab indent_size = 4 [*.{json,md,yaml,yml}] indent_style = space indent_size = 2 [*.md] trim_trailing_whitespace = false swup-fragment-plugin-0686d91/.github/000077500000000000000000000000001514063527000174335ustar00rootroot00000000000000swup-fragment-plugin-0686d91/.github/workflows/000077500000000000000000000000001514063527000214705ustar00rootroot00000000000000swup-fragment-plugin-0686d91/.github/workflows/e2e-tests.yml000066400000000000000000000012371514063527000240310ustar00rootroot00000000000000name: E2E tests on: push: branches: [main, next] pull_request: workflow_dispatch: jobs: run-tests: name: E2E tests runs-on: ubuntu-latest timeout-minutes: 5 steps: - name: Check out repo uses: actions/checkout@v3 - name: Set up node uses: actions/setup-node@v3 with: node-version: 18 - run: npm ci - run: npm run build - run: npx playwright install --with-deps - name: Run tests run: npx playwright test --config ./tests/config/playwright.config.ts - uses: daun/playwright-report-summary@v2 with: report-file: playwright-results.json swup-fragment-plugin-0686d91/.github/workflows/npm-publish.yml000066400000000000000000000007031514063527000244510ustar00rootroot00000000000000# This workflow publishes a package to NPM name: Publish package on: release: types: [published] jobs: publish-npm: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 16 registry-url: https://registry.npmjs.org - run: npm ci - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{secrets.npm_token}} swup-fragment-plugin-0686d91/.github/workflows/redeploy-docs.yml000066400000000000000000000002421514063527000247620ustar00rootroot00000000000000name: Redeploy Docs on: push: branches: [main] jobs: redeploy-docs: uses: swup/.github/.github/workflows/redeploy-docs.yml@main secrets: inherit swup-fragment-plugin-0686d91/.github/workflows/unit-tests.yml000066400000000000000000000007301514063527000243320ustar00rootroot00000000000000name: Unit tests on: push: branches: [main, next] pull_request: workflow_dispatch: jobs: run-tests: name: Run unit tests runs-on: ubuntu-latest timeout-minutes: 5 steps: - name: Check out repo uses: actions/checkout@v3 - name: Set up node uses: actions/setup-node@v3 with: node-version: 18 - run: npm ci - run: npm run build - name: Run tests run: npm run test:unit swup-fragment-plugin-0686d91/.github/workflows/version-update.yml000066400000000000000000000017131514063527000251620ustar00rootroot00000000000000# This workflow bumps the package.json version and creates a PR name: Update package version on: workflow_dispatch: inputs: segment: description: 'Semver segment to update' required: true default: 'patch' type: choice options: - minor - patch jobs: update-version: name: Update package version runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: node-version: 16 - run: echo "Updating ${{ inputs.segment }} version" - name: Update version run: npm --no-git-tag-version version ${{ inputs.segment }} - uses: peter-evans/create-pull-request@v4 with: base: main branch: 'version/automated' title: 'Update package version (automated)' commit-message: 'Update package version' body: 'Automated update to ${{ inputs.segment }} version' swup-fragment-plugin-0686d91/.gitignore000066400000000000000000000003471514063527000200670ustar00rootroot00000000000000.DS_Store *.DS_Store node_modules Thumbs.db .idea dist *.tgz src/packages # Testing tools and outputs /tests/reports/ /tests/results/ /tests/fixtures/dist/ /playwright/.cache/ /playwright-report/ /coverage .nyc_output report.json swup-fragment-plugin-0686d91/.husky/000077500000000000000000000000001514063527000173145ustar00rootroot00000000000000swup-fragment-plugin-0686d91/.husky/pre-commit000066400000000000000000000000201514063527000213030ustar00rootroot00000000000000npx lint-staged swup-fragment-plugin-0686d91/.lintstagedrc.js000066400000000000000000000001121514063527000211640ustar00rootroot00000000000000export default { '**/*.{js,ts,mjs,cjs,md,html}': ['prettier --write'] }; swup-fragment-plugin-0686d91/CHANGELOG.md000066400000000000000000000071511514063527000177100ustar00rootroot00000000000000# Changelog ## [1.3.0] - 2026-02-04 - Support `rule.scroll` to be set dynamically by a callback function (#94, thanks @ovenum) ## [1.2.0] - 2025-11-25 - Support multiple fragment selectors in `data-swup-link-to-fragment` attribute (#92, thanks @ovenum) ## [1.1.2] - 2025-05-30 - Only move `` elements with an `[open]` attribute to the top layer ## [1.1.1] - 2024-06-01 - Optimize logic of persisting fragment elements - Optimize API usage of `getFragmentVisit` ## [1.1.0] - 2024-05-29 - Match rules conditionally: [`rule.if`](https://swup.js.org/plugins/fragment-plugin/#rule-if) ## [1.0.2] - 2024-05-21 - always update the `href` of `a[data-swup-link-to-fragment]`, even if it's the current URL ## [1.0.1] - 2024-03-26 - Compatibility with swup 4.6.0 ## [1.0.0] - 2024-01-28 - Version 1.0.0 🍾 ## [0.3.7] - 2023-11-14 - Add playwright tests ## [0.3.6] - 2023-11-13 - Prevent `` fragments from being closed if pressing the Escape key ## [0.3.5] - 2023-11-11 - New [API methods](https://github.com/swup/fragment-plugin#api-methods): - `getFragmentVisit()` - `prependRule()` - `appendRule()` - `getRules()` - `setRules()` - Add vitest tests for many functions ## [0.3.4] - 2023-10-15 - Ignore fragment elements that are not children of swup's default `containers` ## [0.3.3] - 2023-10-05 - Refactor exports - Ensure all type definitions make it into `/dist` - Fix return type of `swup.getFragmentVisit()` ## [0.3.2] - 2023-09-26 - Use `@swup/cli` for bundling ## [0.3.1] - 2023-09-25 - Ignore fragment rules where any of the `containers` doesn't return a match ## [0.3.0] - 2023-09-07 - Make `visit.a11y.focus` adjustable ## [0.2.6] - 2023-08-09 - Support for fragment visits to the current URL (handy for @swup/fragment-plugin) ## [0.2.5] - 2023-08-04 - simplify `visit.fragmentVisit` #35 - new option `rule.scroll` #36 ## [0.2.4] - 2023-07-31 - Optimize exported types ## [0.2.3] - 2023-07-28 - Sort the `"exports"` field in package.json in the recommended way ## [0.2.2] - 2023-07-28 - use an `interface` for augmenting swup, so that multiple plugins can augment it ## [0.2.1] - 2023-07-26 - Initial Release [1.3.0]: https://github.com/swup/fragment-plugin/releases/tag/1.3.0 [1.2.0]: https://github.com/swup/fragment-plugin/releases/tag/1.2.0 [1.1.2]: https://github.com/swup/fragment-plugin/releases/tag/1.1.2 [1.1.1]: https://github.com/swup/fragment-plugin/releases/tag/1.1.1 [1.1.0]: https://github.com/swup/fragment-plugin/releases/tag/1.1.0 [1.0.2]: https://github.com/swup/fragment-plugin/releases/tag/1.0.2 [1.0.1]: https://github.com/swup/fragment-plugin/releases/tag/1.0.1 [1.0.0]: https://github.com/swup/fragment-plugin/releases/tag/1.0.0 [0.3.7]: https://github.com/swup/fragment-plugin/releases/tag/0.3.7 [0.3.6]: https://github.com/swup/fragment-plugin/releases/tag/0.3.6 [0.3.5]: https://github.com/swup/fragment-plugin/releases/tag/0.3.5 [0.3.4]: https://github.com/swup/fragment-plugin/releases/tag/0.3.4 [0.3.3]: https://github.com/swup/fragment-plugin/releases/tag/0.3.3 [0.3.2]: https://github.com/swup/fragment-plugin/releases/tag/0.3.2 [0.3.1]: https://github.com/swup/fragment-plugin/releases/tag/0.3.1 [0.3.0]: https://github.com/swup/fragment-plugin/releases/tag/0.3.0 [0.2.6]: https://github.com/swup/fragment-plugin/releases/tag/0.2.6 [0.2.5]: https://github.com/swup/fragment-plugin/releases/tag/0.2.5 [0.2.4]: https://github.com/swup/fragment-plugin/releases/tag/0.2.4 [0.2.3]: https://github.com/swup/fragment-plugin/releases/tag/0.2.3 [0.2.2]: https://github.com/swup/fragment-plugin/releases/tag/0.2.2 [0.2.1]: https://github.com/swup/fragment-plugin/releases/tag/0.2.1 swup-fragment-plugin-0686d91/LICENSE000077500000000000000000000021031514063527000170770ustar00rootroot00000000000000MIT License Copyright (c) 2023 Rasso Hilber Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. swup-fragment-plugin-0686d91/README.md000066400000000000000000000351261514063527000173610ustar00rootroot00000000000000# Swup Fragment Plugin [![npm version](https://img.shields.io/npm/v/@swup/fragment-plugin.svg)](https://www.npmjs.com/package/@swup/fragment-plugin) [![Unit Tests](https://img.shields.io/github/actions/workflow/status/swup/fragment-plugin/unit-tests.yml?branch=main&label=vitest)](https://github.com/swup/fragment-plugin/actions/workflows/unit-tests.yml) [![E2E Tests](https://img.shields.io/github/actions/workflow/status/swup/fragment-plugin/e2e-tests.yml?branch=main&label=playwright)](https://github.com/swup/fragment-plugin/actions/workflows/e2e-tests.yml) [![License](https://img.shields.io/github/license/swup/fragment-plugin.svg)](https://github.com/swup/fragment-plugin/blob/main/LICENSE) A [swup](https://swup.js.org) plugin for dynamically replacing containers based on rules 🧩 - Selectively replace containers instead of the main swup containers, based on custom rules - Improve orientation by animating only the parts of the page that have actually changed - Give your site the polish and snappiness of a single-page app ## Use cases All of the following scenarios require updating only a small content fragment instead of performing a full page transition: - a filter UI that live-updates its list of results on every interaction - a detail overlay that shows on top of the currently open content - a tab group that should update only itself when selecting one of the tabs If you are looking for selectively replacing forms on submission, you should have a look at [Forms Plugin](https://swup.js.org/plugins/forms-plugin/#inline-forms). ## Demo See the plugin in action in [this interactive demo](https://swup-fragment-plugin.netlify.app)
https://github.com/swup/fragment-plugin/assets/869813/ecaf15d7-ec72-43e8-898a-64f61330c6f5
## Table of contents - [Installation](#installation) - [How it works](#how-it-works) - [Example](#example) - [Options](#options) - [How rules are matched](#how-rules-are-matched) - [How fragment containers are found](#how-fragment-containers-are-found) - [Advanced use cases](#advanced-use-cases) - [Skip animations using `