feat: Svelte action + Solid directive (v0.5) - #15
Merged
Conversation
- @devslab/numkey/svelte: use:numkey action taking an options object, a decimals shorthand, or nothing (data-numkey* attributes). bind:value works via the new bind() resync option — Svelte registers its binding listener before the action runs, so a reformat re-dispatches input and the second (idempotent) pass lets the binding read the formatted value. bind:value therefore holds the DISPLAY value; onValue reports the CANONICAL one, mirroring React's onValueChange. Zero svelte imports, so no peer dependency. - @devslab/numkey/solid: use:numkey directive reactive to a signal (createRenderEffect + onCleanup) plus a useNumkey ref factory. No resync needed — Solid delegates input at the document level, so the element-level formatting listener runs first. - onValue dedupes: the resynced input event re-enters the listener, so it reports only when the canonical value actually changed. - vitest.config.ts aliases solid-js to its browser dev build; vitest otherwise resolves the node/SSR build, which has no reactivity. Solid also batches updates inside createRoot, so the reactive test drives the signal from outside the root. - Docs: Svelte/Solid sections in both READMEs, a framework entry-point table, and a proper Roadmap section (numkey had only a stray note line) recording v0.2-v0.5 as shipped with Indian lakh grouping left demand-gated. CHANGELOG 0.5.0, version bumped.
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.
numkey shipped Vue and React adapters only; its sibling kokey now covers four frameworks, so this closes the gap in the "-key family".
Svelte (
@devslab/numkey/svelte)use:numkeyaction — options object, decimals shorthand (use:numkey={2}), or nothing (data-numkey*attributes). Imports nothing fromsvelte, so there is no peer dependency at all.bind:valueworks via the newbind()resyncoption: Svelte registers its binding listener before the action runs, so a reformat re-dispatchesinputand the second (idempotent) pass lets the binding read the formatted value. That meansbind:valueholds the display value —onValuereports the canonical one, mirroring React'sonValueChange. It dedupes, since the resynced event re-enters the listener.Solid (
@devslab/numkey/solid)use:numkeydirective reactive to a signal (createRenderEffect+onCleanup), plus auseNumkeyref factory. No resync needed — Solid delegatesinputat the document level, so the element-level formatting listener runs first andonInputalready reads the formatted value.solid-jsis an optional peer.Docs
Svelte/Solid sections in both READMEs, a framework entry-point table, and a proper Roadmap section — numkey only had a stray "Roadmap: Indian lakh grouping" note line, so v0.2–v0.5 are now recorded as shipped with lakh grouping left demand-gated.
Verification
dist/svelte.*,dist/solid.*).vitest.config.tsaliasessolid-jsto its browser dev build — vitest otherwise resolves the node/SSR build, which has no reactivity. Solid also batches updates insidecreateRoot, so the reactive test drives the signal from outside the root..is not a decimal mark, so1234567.89→123,456,789— the documentedparse('1.5') === '15'contract.