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.
π Linked issue
Resolves #818
β Type of change
π Description
This PR converts the
table
component to usescript setup
syntax to take advantage of generic types. The refactor involved some changes to properties formerly passed todefineComponent
that now needed to be defined w/ utility functions (defineOptions
/useAttrs
/ etc).The biggest change involved how prop defaults are handled due to the inability to reference local vars in the declaration. The PR inverts the current process by applying the defaults after props are defined rather than before, w/ the props defaulting to
undefined
which is automatically ignored bydefu
therefore the mapped local vars will inherit values from the defaults.Mapping the results to local vars should mean that the
template
will use those mapped values rather than the one inprops
. However, this caused conflict w/ some computed props that were slightly renamed and then modified to use the local vars but still checkingprops
to see if the user explicitly sets asnull
.The only other thing to note is that the column key could optionally by typed as
keyof Row
rather thanstring
, but this will create type conflicts for any user that adds custom column keys likeaction
in the examples so it was avoided. We could consider adding astring | keyof Row
type but the benefits of this are negligible unless we introduce a mechanism that allows the user to explicitly extend the available keys in the type.The library is designed to support components that use the
defineComponent
syntax so this additional feels out of place in contrast w/ the other components but it could serve as a POC for a broader implementation of generics that I think could improve the DX and might be worth building into v3.π Checklist