Repository navigation
feat: 4.1.0 - #328
Merged
Merged
feat: 4.1.0#328
Conversation
commit: |
* feat(types): add defineVariants and let VariantProps read it A tv() config kept in its own variable stops compiling once it has compoundVariants: their values are inferred as string, which tv() rejects. defineVariants is an identity helper with tv()'s generics that keeps the literals, so the config is checked where it is written and passes back into tv() unchanged. - export TVOptions, the options type tv() and the lite tv() shared inline - export defineVariants from the default, lite and config entries - VariantProps accepts a defineVariants result, identical to its recipe's * feat(types): keep written fields required on defineVariants options The options defineVariants returns now carry only the fields that were written, as required keys, and type each default as any value its variant accepts, so app code can read one back: const size: 'sm' | 'lg' = buttonVariants.defaultVariants.size; VariantProps reads the fields directly instead of matching the old shape. * docs(types): call the defineVariants example config buttonTheme HeroUI names its tv() recipes buttonVariants, so the same name on a config read the wrong way round.
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.
Resolves #325
Description
Syncs
canaryintomainfor the next release (v4.1.0):defineVariants&VariantProps(feat(types): add defineVariants and let VariantProps read it #326): Adds a zero-runtimedefineVariantshelper (exported from.,/lite, and/config) so configs can be authored and typed outsidetv()and passed toVariantProps. TightensVariantPropswith a type-only brand so{}and plain objects still error, preservescompoundSlotswhen provided, keeps internal option types unexported, and documents usage inREADME.md.id,aria-label,onClick,children) hit the cache instead of busting or serializing, and adds a string fast path to compound matching.false/"false",1/"1") and prototype-named variants, copies effective props on cached slot results so later mutations don't leak, fixesnull/"null"and other cache-key collisions, and refreshes static results when non-variant compound defaults change in place..nvmrc), and Biome schema (2.6.8).Additional context
v4.0.2.pnpm typecheck,pnpm lint,pnpm test, andpnpm buildall pass).What is the purpose of this pull request?
Performance impact
pnpm benchmarksuite and reviewed the current TV versus released TV results.Before submitting the PR, please make sure you do the following
fixes #123).