Skip to content

feat: export default encoder/decoder for pre-setting table URL parameters#487

Merged
taro-28 merged 9 commits intomainfrom
export-encoder-and-decoder
Apr 27, 2025
Merged

feat: export default encoder/decoder for pre-setting table URL parameters#487
taro-28 merged 9 commits intomainfrom
export-encoder-and-decoder

Conversation

@taro-28
Copy link
Copy Markdown
Owner

@taro-28 taro-28 commented Apr 27, 2025

fixes #470

What’s new in this PR

  • Default encoder / decoder are now exported.
    You can import them from tanstack-table-search-params/encoder-decoder.

  • Use the default encoder when pre-setting URL parameters.
    When you need to navigate to a page that contains a table and want to attach query parameters ahead of time, you can now rely on the default encoder.

import { encodeSorting } from "tanstack-table-search-params/encoder-decoder";

<Link
  href={{
    pathname: "/some-page-with-table",
    query: {
      sorting: encodeSorting([{ id: "name", desc: true }]),
    },
  }}
>
  foo
</Link>

…default values

- Introduced a new `encoder-decoder` module to handle encoding and decoding of global filter values.
- Updated `encodeGlobalFilter` and `decodeGlobalFilter` functions to accept options for customizable default values.
- Modified `useGlobalFilter` to utilize the new options structure.
- Added tests to ensure correct functionality of the new encoder-decoder logic.
- Updated package.json and tsup.config.ts to include the new module in the build process.
@taro-28 taro-28 self-assigned this Apr 27, 2025
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tanstack-table-search-params-next-app-router ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 27, 2025 5:24am
tanstack-table-search-params-next-pages-router ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 27, 2025 5:24am

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 27, 2025

Deploying tanstack-table-search-params-tanstack-router with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4558440
Status: ✅  Deploy successful!
Preview URL: https://ba030567.tanstack-table-search-params-tanstack-router.pages.dev
Branch Preview URL: https://export-encoder-and-decoder.tanstack-table-search-params-tanstack-router.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 27, 2025

Deploying tanstack-table-search-params-react-router-lib with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4558440
Status: ✅  Deploy successful!
Preview URL: https://8876fdea.tanstack-table-search-params-react-router-lib.pages.dev
Branch Preview URL: https://export-encoder-and-decoder.tanstack-table-search-params-react-router-lib.pages.dev

View logs

taro-28 added 6 commits April 27, 2025 12:33
… values

- Updated `encodeSorting` and `decodeSorting` functions to accept an options parameter for customizable default values.
- Modified the `useSorting` hook to utilize the new options structure for decoding and encoding sorting parameters.
- Enhanced tests for sorting to validate the new options functionality.
- Updated the encoder-decoder index to export the new sorting functions.
- Modified `encodeGlobalFilter` and `decodeGlobalFilter` functions to accept an optional `defaultValue` parameter.
- Updated `encodeSorting` and `decodeSorting` functions similarly to enhance flexibility in handling sorting parameters.
- Ensured consistency across encoder-decoder modules for better usability.
…ult values

- Updated `encodePagination` and `decodePagination` functions to accept an options parameter for customizable default values.
- Modified the `usePagination` hook to utilize the new options structure for encoding and decoding pagination parameters.
- Enhanced tests for pagination to validate the new options functionality.
- Updated the encoder-decoder index to export the new pagination functions.
- Updated test cases for `globalFilter` and `sorting` to ensure consistent handling of `defaultValue` types.
- Refactored type definitions to improve clarity and maintainability across test files.
- Ensured that the tests accurately reflect the expected behavior of the encoder-decoder functions.
…fault values

- Updated `encodeColumnFilters` and `decodeColumnFilters` functions to accept an options parameter for customizable default values.
- Refactored the handling of default values in the `useColumnFilters` hook to align with the new options structure.
- Modified tests for columnFilters to validate the new options functionality.
- Updated the encoder-decoder index to export the enhanced columnFilters functions.
…ult values

- Updated `encodeColumnOrder` and `decodeColumnOrder` functions to accept an options parameter for customizable default values.
- Refactored the `useColumnOrder` hook to utilize the new options structure for encoding and decoding column order parameters.
- Modified tests for columnOrder to validate the new options functionality.
- Updated the encoder-decoder index to export the enhanced columnOrder functions.
taro-28 added 2 commits April 27, 2025 14:06
…ests

- Updated test cases for columnFilters, columnOrder, globalFilter, pagination, and sorting to ensure consistent handling of `defaultValue` types.
- Refactored type definitions to improve clarity and maintainability across all test files.
- Ensured that the tests accurately reflect the expected behavior of the encoder-decoder functions.
- Introduced a new FAQ section explaining how to preset query parameters when navigating to a page with a table.
- Provided a code example demonstrating the use of `encodeSorting` from the encoder-decoder module to set initial table state via URL.
- Updated both main and package-specific README files for consistency.
@taro-28 taro-28 force-pushed the export-encoder-and-decoder branch from 2d75ced to 4558440 Compare April 27, 2025 05:23
@taro-28 taro-28 changed the title feat: export default encoder and decoders feat: export default encoder/decoder for pre-setting table URL parameters Apr 27, 2025
@taro-28 taro-28 marked this pull request as ready for review April 27, 2025 05:35
@taro-28 taro-28 merged commit fd79299 into main Apr 27, 2025
9 checks passed
@taro-28 taro-28 deleted the export-encoder-and-decoder branch April 27, 2025 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export default encoding / decoding

1 participant