Repository navigation
Add lists, tables, tiles, a router and JSON requests to the TypeScript package - #202
Merged
Merged
Conversation
…t package - api: request, a JSON request, beside requestStream - list: ListController, of a list an API returns a page at a time, sorted by the server, which follows its changes, and keeps its open item current - list/view: gs-table, a Carbon data table of a list's page, with sortable columns and pagination, whose rows open their items - list/tiles: gs-tiles, a row of tiles of a list, after one for all of them, of which one is chosen - router: Router, which shows the page of the location's hash Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues allow stale responses to overwrite pagination, filtered results, and selection, leave newly created lists incorrectly available during outages, and prevent keyboard-only users from opening items.
4 open issues
What changed in this PR
This PR expands the TypeScript package with reusable list controllers and views, JSON requests, and hash-based routing for server frontends.
Changes:
- Adds paginated, server-sorted lists with change-stream integration and selected-item refresh.
- Adds Carbon table and tile views, plus a hash router with route parameters.
- Exports the new modules and adds documentation and tests.
| File | Description |
|---|---|
frontend/test/router.test.ts |
Tests route parsing and parameter decoding. |
frontend/test/request.test.ts |
Tests JSON requests, errors, and empty responses. |
frontend/test/list.test.ts |
Tests list loading, pagination, sorting, selection, and errors. |
frontend/src/router/router.ts |
Implements hash parsing and page visibility routing. |
frontend/src/router/index.ts |
Exports the router API. |
frontend/src/list/view.ts |
Adds the sortable, paginated Carbon table view. |
frontend/src/list/tiles.ts |
Adds selectable tiles with selection events. |
frontend/src/list/index.ts |
Exports the list controller and types. |
frontend/src/list/controller.ts |
Manages list pages, sorting, selection, and change updates. |
frontend/src/api/request.ts |
Adds the JSON request helper. |
frontend/src/api/index.ts |
Exports the request helper and options. |
frontend/README.md |
Documents lists, views, and routing with examples. |
frontend/package.json |
Exposes list and router package entry points. |
Review effort: Balanced
…eyboard - ListController has a generation, which a reset, page, page size or sort changes, so a response to an earlier one isn't shown, nor changes the page, and the list is loaded again - An item which is opened, or closed, while the open one is loaded again stays as it is - A list made while the changes can't be watched is unavailable from the start, with ChangesController's new started - gs-table's rows have a button as their first cell, so they open from the keyboard, and its empty message is across the table Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds the pieces every server's frontend needs for its lists. They were first written in an app built on this package, and used there for about ten lists.
/apirequest, a JSON request, besiderequestStream. It throws anApiErrorwhen the response isn't ok, and returnsundefinedfor an empty body./listListController: a list an API returns a page at a time ({ count, body })/list/viewgs-table: a Carbon data table of a list's page/list/tilesgs-tiles: a row of tiles of a list, with an optional "all" tile first, of which one is chosen. It firesgs-tile-selectwith the tile's value./routerRouter: shows the page of the location's hash, with parameters (#database/shop)ListController:resetfor when a filter changes.ChangesController's changes to its tables, and is unavailable while the server can't be reached.gs-table:sortkey sorts the list when its header is clicked. Carbon's own sorting, which only sorts the rows on the page, is turned off.Also:
request,ListController(load, last page, reset, sort, the open item, errors) andparseRoute. 42 pass.litand@carbon/web-componentsstay optional peer dependencies, needed only by the views.The app's header and side navigation, and a helper that opens a list's item in a panel, stay in the app until a second app uses them.