Implement USER_SELECT flow input in the JavaScript core and React SDK - #106
Dilusha-Madushan wants to merge 1 commit into
Conversation
Signed-off-by: Dilusha-Madushan <dilushamadushan9912@gmail.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Repository: thunder-id/javascript-sdks/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔀 Cross-SDK feature parityDoes this change need to ship in the other ThunderID SDKs too? This check stays red until one of these labels answers that:
Ports (DO NOT EDIT)
No sibling SDKs accounted for on this thread yet. Important Reply to this comment with this block, filled in. The boxes above tick A link can be a pull request or a tracked issue, written in full or as The contract is in the SDK development specification. |
Purpose
Adds a new built-in flow input,
USER_SELECT: a paginated, scrollable single-user picker that submits the selected user's ID. It supports both a consumer-suppliedfetchUsersloader and a default authenticated loader wired throughInviteUser/BaseInviteUser.Approach
@thunderid/javascript): aUserSelectmember onEmbeddedFlowComponentType, anendpoints.usersconfig key resolved through the existingresolveResourceEndpointprecedence, and agetUsersdirectory helper. Paging and label/value mapping live behind a genericPagedSelectcontract (PagedSelectOption/Page/Request,PagedSelectOptionMapping) rather than a user-specific one, so a futureEMAIL_SELECTonly needs a new loader — not a parallel set of utilities. Mapping rules: plain strings/numbers use themselves as both label and value; a configuredlabelAttributes/valueAttribute(orgetLabel/getValue) wins when set; an unconfigured object falls back by shape (a record withidlabels fromdisplay → username → email → id; an{label, value}object is used as-is; anything else uses its first text field for both).usePagedSelecthook (lazy first page, incremental paging, de-duplication, cancellation viaAbortController, a generation guard against stale responses) backs aPagedSelectprimitive (floating-ui popover,FormControl/InputLabelcomposition,role="listbox"/"option", anaria-livestatus region) and a thinUserSelectspecialization supplying the user loader's defaults and wording. Wired intoAuthOptionFactory.tsxas a newcase EmbeddedFlowComponentType.UserSelect, and a default authenticatedfetchUsersis threaded throughBaseInviteUser/InviteUserfor the case where a consumer doesn't supply their own loader.aria-label, empty/loading/retry/load-more text) and the generic load-failure fallback now resolve through the SDK's translation bundle instead of hardcoded English literals, with new keys added to all 9 locale bundles (the 8 non-English translations are a first pass and should get a native-speaker review before release).mapCredentialUpdateErrorconvention: a newmapPagedSelectErrorreturns{message?, messageKey}— aThunderIDError's message is trusted and shown as-is, anything else (a bareError, a custom loader's arbitrary throw) falls back to the generic, translatable message, so a picker never surfaces an unreviewed exception string.Related Issues
Related PRs
Checklist
breaking changelabel added.parity/prs-raisedorparity/prs-not-neededadded.parity/prs-raised, the port links are posted as a reply on the parity check's comment.Security checks