Comments (2)
You are using useForwardProps
wrongly. It should be a computed or a ref, and not object of ref(s).
Check out https://stackblitz.com/edit/vitejs-vite-dgmjpq?file=src%2Fcomponents%2FBox.vue
from radix-vue.
@zernonia Apologies, I just realized my reproduction maybe was a bit too minimal to showcase the problem properly. 🙈
I have created a more realistic and extensive version of it. The following is working in 1.7.4, but can not build in 1.8.x:
1.7.4: https://stackblitz.com/edit/vitejs-vite-4xcuqh?file=src%2Fcomponents%2FText.vue
1.8.2: https://stackblitz.com/edit/vitejs-vite-ksc3vz?file=src%2Fcomponents%2FText.vue
sprinkles()
is just a stub for https://vanilla-extract.style/documentation/packages/sprinkles/ for demostration purposes. In reality the code for Text
looks something like this:
<script setup lang="ts">
import { defineProps, toRefs } from 'vue'
import { useForwardProps } from 'radix-vue'
import { Box, type BoxProps } from '../Box'
import { sprinkles, type Sprinkles } from '@/styles/sprinkles.css'
export interface TextProps extends BoxProps {
align?: Sprinkles['textAlign']
}
const props = defineProps<TextProps>()
const { align, ...rest } = toRefs(props)
const forwarded = useForwardProps(rest)
</script>
<template>
<Box
v-bind="forwarded"
:class="
sprinkles({
textAlign: align,
})
"
>
<slot />
</Box>
</template>
I think pulling out props for Text
and passing on the rest (BoxProps
) via a spread is a valid usecase for useForwardProps
:
const props = defineProps<TextProps>();
const { align, family, ...rest } = toRefs(props);
const forwarded = useForwardProps(rest);
As far as I understand in [email protected] we would be able to replace this with a destructuring assignment:
const { align, family, ...rest } = defineProps<TextProps>();
const forwarded = useForwardProps(rest);
and I believe this also would return every prop of type Ref
.
from radix-vue.
Related Issues (20)
- [Bug]: `SplitterPanel`: `oncollapse` will not be triggered when `collapsedSize` precision exceeds 10 digits
- [Bug]: Hover card Tooltip does not disappear when hover another hover card HOT 3
- [Feature]: Allow bringing your own date library. HOT 5
- [Feature]: Add ability to create circular progress bar HOT 1
- [Bug]: `SplitterPanel` works based on the old layout after props change
- [Bug]: `aria-selected` value in Select HOT 2
- [Bug]: `TreeItemEmits` is not exported
- [Bug]: Date Field does not update field focus order when locale changes
- [Bug]: Date Picker (and possibly all related components) are not handling `disabled` HOT 1
- [Feature]: Expose `data-highlight-start` and `data-highlight-end` on RangeCalendar triggers
- [Bug]: Navigation Menu got re-trigger (or force focus) on mobile
- [Feature]: Allow pass ref to `ComboboxInput` HOT 5
- [Feature]: Expose internal "Presence" for general use
- [Feature]: allow custom children list in `<TreeRoot />` HOT 1
- Dropdown Menu closing @mouseleave HOT 1
- [Bug]: avoidCollisions prop on Combobox content not avoiding collision with window
- [Bug]: Splitter doesn't seem to support As, or asChild, even though the documentation says they should
- [Bug]: RangeCalendarGrid does not have correct readonly and disabled state
- [Bug]: Async Search Combobox TypeError: s.filteredOptions.value.find is not a function
- [Bug]: DateField Component cannot input '00' in hours part
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from radix-vue.