diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 063585f2b..fdc3b1308 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -151,6 +151,7 @@ export default defineConfig({ { text: 'Toggle Group', link: '/components/toggle-group' }, { text: 'Toolbar', link: '/components/toolbar' }, { text: 'Tooltip', link: '/components/tooltip' }, + { text: `Tree ${BadgeHTML('Alpha')}`, link: '/components/tree' }, ], }, { diff --git a/docs/components/Demos.vue b/docs/components/Demos.vue index c493f1471..15b1ceacf 100644 --- a/docs/components/Demos.vue +++ b/docs/components/Demos.vue @@ -39,6 +39,7 @@ import ToggleDemo from './demo/Toggle/tailwind/index.vue' import ToggleGroupDemo from './demo/ToggleGroup/tailwind/index.vue' import ToolbarDemo from './demo/Toolbar/tailwind/index.vue' import TooltipDemo from './demo/Tooltip/tailwind/index.vue' +import TreeDemo from './demo/Tree/tailwind/index.vue' import DemoContainer from './DemoContainer.vue' @@ -171,5 +172,8 @@ import DemoContainer from './DemoContainer.vue' + + + diff --git a/docs/components/demo/CalendarYearIncrement/css/index.vue b/docs/components/demo/CalendarYearIncrement/css/index.vue index 5f5a14d6c..3abf2fce7 100644 --- a/docs/components/demo/CalendarYearIncrement/css/index.vue +++ b/docs/components/demo/CalendarYearIncrement/css/index.vue @@ -2,16 +2,16 @@ import { Icon } from '@iconify/vue' import { CalendarCell, CalendarCellTrigger, CalendarGrid, CalendarGridBody, CalendarGridHead, CalendarGridRow, CalendarHeadCell, CalendarHeader, CalendarHeading, CalendarNext, CalendarPrev, CalendarRoot, type CalendarRootProps } from 'radix-vue' import './styles.css' -import type { DateValue } from '@internationalized/date'; +import type { DateValue } from '@internationalized/date' const isDateUnavailable: CalendarRootProps['isDateUnavailable'] = (date) => { return date.day === 17 || date.day === 18 } -const pagingFunc = (date: DateValue, sign: -1 | 1) => { +function pagingFunc(date: DateValue, sign: -1 | 1) { if (sign === -1) - return date.subtract({ years: 1}) - return date.add({ years: 1}) + return date.subtract({ years: 1 }) + return date.add({ years: 1 }) } diff --git a/docs/components/demo/CalendarYearIncrement/tailwind/index.vue b/docs/components/demo/CalendarYearIncrement/tailwind/index.vue index dc6c26c03..05b6b6f91 100644 --- a/docs/components/demo/CalendarYearIncrement/tailwind/index.vue +++ b/docs/components/demo/CalendarYearIncrement/tailwind/index.vue @@ -1,16 +1,16 @@ diff --git a/docs/components/demo/Tree/css/index.vue b/docs/components/demo/Tree/css/index.vue new file mode 100644 index 000000000..f1e314efb --- /dev/null +++ b/docs/components/demo/Tree/css/index.vue @@ -0,0 +1,61 @@ + + + diff --git a/docs/components/demo/Tree/tailwind/index.vue b/docs/components/demo/Tree/tailwind/index.vue new file mode 100644 index 000000000..0adb0d0ea --- /dev/null +++ b/docs/components/demo/Tree/tailwind/index.vue @@ -0,0 +1,74 @@ + + + diff --git a/docs/components/demo/Tree/tailwind/tailwind.config.js b/docs/components/demo/Tree/tailwind/tailwind.config.js new file mode 100644 index 000000000..b84aff59e --- /dev/null +++ b/docs/components/demo/Tree/tailwind/tailwind.config.js @@ -0,0 +1,15 @@ +const { green, grass } = require('@radix-ui/colors') + +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: ['./**/*.vue'], + theme: { + extend: { + colors: { + ...green, + ...grass, + }, + }, + }, + plugins: [], +} diff --git a/docs/content/components/number-field.md b/docs/content/components/number-field.md index c5002c5d6..c272d9d18 100644 --- a/docs/content/components/number-field.md +++ b/docs/content/components/number-field.md @@ -8,6 +8,8 @@ aria: https://www.w3.org/WAI/ARIA/apg/patterns/spinbutton # Number Field +Alpha + A number field allows a user to enter a number and increment or decrement the value using stepper buttons. diff --git a/docs/content/components/tree.md b/docs/content/components/tree.md new file mode 100644 index 000000000..d27220b58 --- /dev/null +++ b/docs/content/components/tree.md @@ -0,0 +1,319 @@ +--- + +title: Tree +description: A tree view widget displays a hierarchical list of items that can be expanded or collapsed to show or hide their child items, such as in a file system navigator. +name: tree +aria: https://www.w3.org/WAI/ARIA/apg/patterns/treeview/ +--- + +# Tree + +Alpha + + +A tree view widget displays a hierarchical list of items that can be expanded or collapsed to show or hide their child items, such as in a file system navigator. + + + + +## Features + + + +## Installation + +Install the component from your command line. + + + +## Anatomy + +Import all parts and piece them together. + +```vue + + + +``` + +## API Reference + +### Root + +Contains all the parts of a tree. + + + +### Item + +The item component. + + + + + +### Virtualizer + +Virtual container to achieve list virtualization. + + + +## Examples + +### Selecting multiple items + +The `Tree` component allows you to select multiple items. You can enable this by providing an array of values instead of a single value. + +```vue line=12,16 + + + +``` + +### Virtual List + +Rendering a long list of item can slow down the app, thus using virtualization would significantly improve the performance. + +```vue line=9-16 + + + +``` + +### With Checkbox + +Some `Tree` component might want to show `toggled/indeterminate` checkbox. We can change the behavior of the `Tree` component by using a few props and `preventDefault` event. + +We set `propagateSelect` to `true` because we want the parent checkbox to select/deselect it's descendants. Then, we add a checkbox that triggers `select` event. + +```vue line=10-11,17-25,29-33 + + + +``` + +### Nested Tree Node + +The default example shows flatten tree items and nodes, this enables [Virtualization](/components/tree.html#virtual-list) and custom feature such as Drag & Drop easier. However, you can also build it to have nested DOM node. + +In `Tree.vue`, + +```vue + + + +``` + +In `CustomTree.vue` + +```vue + +``` + +### Draggable/Sortable Tree + +For more complex draggable `Tree` component, in this example we will be using [pragmatic-drag-and-drop](https://github.com/atlassian/pragmatic-drag-and-drop), as the core package for handling dnd. + +[Stackblitz Demo](https://stackblitz.com/edit/github-8f3fzs?file=src%2FTreeDND.vue) + +## Accessibility + +Adheres to the [Tree WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/treeview/). + +### Keyboard Interactions + + diff --git a/docs/content/meta/ComboboxRoot.md b/docs/content/meta/ComboboxRoot.md index b25e8c2eb..ed10617b8 100644 --- a/docs/content/meta/ComboboxRoot.md +++ b/docs/content/meta/ComboboxRoot.md @@ -86,6 +86,12 @@ 'description': '

The controlled search term of the Combobox. Can be binded-with with v-model:searchTerm.

\n', 'type': 'string', 'required': false + }, + { + 'name': 'selectedValue', + 'description': '

The current highlighted value of the COmbobox. Can be binded-with v-model:selectedValue.

\n', + 'type': 'AcceptableValue', + 'required': false } ]" /> @@ -104,6 +110,11 @@ 'name': 'update:searchTerm', 'description': '

Event handler called when the searchTerm of the combobox changes.

\n', 'type': '[value: string]' + }, + { + 'name': 'update:selectedValue', + 'description': '

Event handler called when the highlighted value of the combobox changes

\n', + 'type': '[value: AcceptableValue]' } ]" /> diff --git a/docs/content/meta/ListboxRoot.md b/docs/content/meta/ListboxRoot.md index 46ca8f927..69149737f 100644 --- a/docs/content/meta/ListboxRoot.md +++ b/docs/content/meta/ListboxRoot.md @@ -72,7 +72,7 @@ { 'name': 'selectionBehavior', 'description': '

How multiple selection should behave in the collection.

\n', - 'type': '\'toggle\' | \'replace\'', + 'type': '\'replace\' | \'toggle\'', 'required': false, 'default': '\'toggle\'' } diff --git a/docs/content/meta/ToggleGroupRoot.md b/docs/content/meta/ToggleGroupRoot.md index 6cde41ee6..f96c34159 100644 --- a/docs/content/meta/ToggleGroupRoot.md +++ b/docs/content/meta/ToggleGroupRoot.md @@ -71,7 +71,7 @@ { 'name': 'update:modelValue', 'description': '

Event handler called when the value changes.

\n', - 'type': '[payload: string]' + 'type': '[payload: string | string[]]' } ]" /> diff --git a/docs/content/meta/ToolbarToggleGroup.md b/docs/content/meta/ToolbarToggleGroup.md index 62ebc8b2c..589daa2fe 100644 --- a/docs/content/meta/ToolbarToggleGroup.md +++ b/docs/content/meta/ToolbarToggleGroup.md @@ -68,6 +68,6 @@ { 'name': 'update:modelValue', 'description': '

Event handler called when the value changes.

\n', - 'type': '[payload: string]' + 'type': '[payload: string | string[]]' } ]" /> diff --git a/docs/content/meta/TreeItem.md b/docs/content/meta/TreeItem.md new file mode 100644 index 000000000..323ef97b7 --- /dev/null +++ b/docs/content/meta/TreeItem.md @@ -0,0 +1,70 @@ + + + + + + + diff --git a/docs/content/meta/TreeRoot.md b/docs/content/meta/TreeRoot.md new file mode 100644 index 000000000..729d102c3 --- /dev/null +++ b/docs/content/meta/TreeRoot.md @@ -0,0 +1,115 @@ + + + + + + + diff --git a/docs/content/meta/TreeVirtualizer.md b/docs/content/meta/TreeVirtualizer.md new file mode 100644 index 000000000..9f479e4e0 --- /dev/null +++ b/docs/content/meta/TreeVirtualizer.md @@ -0,0 +1,24 @@ + + + + + diff --git a/packages/plugins/src/namespaced/index.ts b/packages/plugins/src/namespaced/index.ts index d286248bf..439698d70 100644 --- a/packages/plugins/src/namespaced/index.ts +++ b/packages/plugins/src/namespaced/index.ts @@ -1,4 +1,4 @@ -import { AccordionContent, AccordionHeader, AccordionItem, AccordionRoot, AccordionTrigger, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogOverlay, AlertDialogPortal, AlertDialogRoot, AlertDialogTitle, AlertDialogTrigger, AspectRatio, AvatarFallback, AvatarImage, AvatarRoot, CalendarCell, CalendarCellTrigger, CalendarGrid, CalendarGridBody, CalendarGridHead, CalendarGridRow, CalendarHeadCell, CalendarHeader, CalendarHeading, CalendarNext, CalendarPrev, CalendarRoot, CheckboxIndicator, CheckboxRoot, CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, ComboboxAnchor, ComboboxArrow, ComboboxCancel, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxLabel, ComboboxPortal, ComboboxRoot, ComboboxSeparator, ComboboxTrigger, ComboboxViewport, ContextMenuArrow, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuItemIndicator, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuRoot, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DateFieldInput, DateFieldRoot, DatePickerAnchor, DatePickerArrow, DatePickerCalendar, DatePickerCell, DatePickerCellTrigger, DatePickerClose, DatePickerContent, DatePickerField, DatePickerGrid, DatePickerGridBody, DatePickerGridHead, DatePickerGridRow, DatePickerHeadCell, DatePickerHeader, DatePickerHeading, DatePickerInput, DatePickerNext, DatePickerPrev, DatePickerRoot, DatePickerTrigger, DateRangeFieldInput, DateRangeFieldRoot, DateRangePickerAnchor, DateRangePickerArrow, DateRangePickerCalendar, DateRangePickerCell, DateRangePickerCellTrigger, DateRangePickerClose, DateRangePickerContent, DateRangePickerField, DateRangePickerGrid, DateRangePickerGridBody, DateRangePickerGridHead, DateRangePickerGridRow, DateRangePickerHeadCell, DateRangePickerHeader, DateRangePickerHeading, DateRangePickerInput, DateRangePickerNext, DateRangePickerPrev, DateRangePickerRoot, DateRangePickerTrigger, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogRoot, DialogTitle, DialogTrigger, DropdownMenuArrow, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuItemIndicator, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuRoot, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditableArea, EditableCancelTrigger, EditableEditTrigger, EditableInput, EditablePreview, EditableRoot, EditableSubmitTrigger, HoverCardArrow, HoverCardContent, HoverCardPortal, HoverCardRoot, HoverCardTrigger, Label, ListboxContent, ListboxFilter, ListboxGroup, ListboxGroupLabel, ListboxItem, ListboxItemIndicator, ListboxRoot, ListboxVirtualizer, MenubarArrow, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarItemIndicator, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarRoot, MenubarSeparator, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuRoot, NavigationMenuSub, NavigationMenuTrigger, NavigationMenuViewport, NumberFieldDecrement, NumberFieldIncrement, NumberFieldInput, NumberFieldRoot, PaginationEllipsis, PaginationFirst, PaginationLast, PaginationList, PaginationListItem, PaginationNext, PaginationPrev, PaginationRoot, PinInputInput, PinInputRoot, PopoverAnchor, PopoverArrow, PopoverClose, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger, ProgressIndicator, ProgressRoot, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, RangeCalendarCell, RangeCalendarCellTrigger, RangeCalendarGrid, RangeCalendarGridBody, RangeCalendarGridHead, RangeCalendarGridRow, RangeCalendarHeadCell, RangeCalendarHeader, RangeCalendarHeading, RangeCalendarNext, RangeCalendarPrev, RangeCalendarRoot, ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport, SelectArrow, SelectContent, SelectGroup, SelectIcon, SelectItem, SelectItemIndicator, SelectItemText, SelectLabel, SelectPortal, SelectRoot, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SelectViewport, Separator, SliderRange, SliderRoot, SliderThumb, SliderTrack, SplitterGroup, SplitterPanel, SplitterResizeHandle, SwitchRoot, SwitchThumb, TabsContent, TabsIndicator, TabsList, TabsRoot, TabsTrigger, TagsInputClear, TagsInputInput, TagsInputItem, TagsInputItemDelete, TagsInputItemText, TagsInputRoot, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastRoot, ToastTitle, ToastViewport, Toggle, ToggleGroupItem, ToggleGroupRoot, ToolbarButton, ToolbarLink, ToolbarRoot, ToolbarSeparator, ToolbarToggleGroup, ToolbarToggleItem, TooltipArrow, TooltipContent, TooltipPortal, TooltipProvider, TooltipRoot, TooltipTrigger, Viewport } from 'radix-vue' +import { AccordionContent, AccordionHeader, AccordionItem, AccordionRoot, AccordionTrigger, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogOverlay, AlertDialogPortal, AlertDialogRoot, AlertDialogTitle, AlertDialogTrigger, AspectRatio, AvatarFallback, AvatarImage, AvatarRoot, CalendarCell, CalendarCellTrigger, CalendarGrid, CalendarGridBody, CalendarGridHead, CalendarGridRow, CalendarHeadCell, CalendarHeader, CalendarHeading, CalendarNext, CalendarPrev, CalendarRoot, CheckboxIndicator, CheckboxRoot, CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, ComboboxAnchor, ComboboxArrow, ComboboxCancel, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxLabel, ComboboxPortal, ComboboxRoot, ComboboxSeparator, ComboboxTrigger, ComboboxViewport, ConfigProvider, ContextMenuArrow, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuItemIndicator, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuRoot, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DateFieldInput, DateFieldRoot, DatePickerAnchor, DatePickerArrow, DatePickerCalendar, DatePickerCell, DatePickerCellTrigger, DatePickerClose, DatePickerContent, DatePickerField, DatePickerGrid, DatePickerGridBody, DatePickerGridHead, DatePickerGridRow, DatePickerHeadCell, DatePickerHeader, DatePickerHeading, DatePickerInput, DatePickerNext, DatePickerPrev, DatePickerRoot, DatePickerTrigger, DateRangeFieldInput, DateRangeFieldRoot, DateRangePickerAnchor, DateRangePickerArrow, DateRangePickerCalendar, DateRangePickerCell, DateRangePickerCellTrigger, DateRangePickerClose, DateRangePickerContent, DateRangePickerField, DateRangePickerGrid, DateRangePickerGridBody, DateRangePickerGridHead, DateRangePickerGridRow, DateRangePickerHeadCell, DateRangePickerHeader, DateRangePickerHeading, DateRangePickerInput, DateRangePickerNext, DateRangePickerPrev, DateRangePickerRoot, DateRangePickerTrigger, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogRoot, DialogTitle, DialogTrigger, DropdownMenuArrow, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuItemIndicator, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuRoot, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditableArea, EditableCancelTrigger, EditableEditTrigger, EditableInput, EditablePreview, EditableRoot, EditableSubmitTrigger, HoverCardArrow, HoverCardContent, HoverCardPortal, HoverCardRoot, HoverCardTrigger, Label, ListboxContent, ListboxFilter, ListboxGroup, ListboxGroupLabel, ListboxItem, ListboxItemIndicator, ListboxRoot, ListboxVirtualizer, MenubarArrow, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarItemIndicator, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarRoot, MenubarSeparator, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuRoot, NavigationMenuSub, NavigationMenuTrigger, NavigationMenuViewport, NumberFieldDecrement, NumberFieldIncrement, NumberFieldInput, NumberFieldRoot, PaginationEllipsis, PaginationFirst, PaginationLast, PaginationList, PaginationListItem, PaginationNext, PaginationPrev, PaginationRoot, PinInputInput, PinInputRoot, PopoverAnchor, PopoverArrow, PopoverClose, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger, Primitive, ProgressIndicator, ProgressRoot, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, RangeCalendarCell, RangeCalendarCellTrigger, RangeCalendarGrid, RangeCalendarGridBody, RangeCalendarGridHead, RangeCalendarGridRow, RangeCalendarHeadCell, RangeCalendarHeader, RangeCalendarHeading, RangeCalendarNext, RangeCalendarPrev, RangeCalendarRoot, ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport, SelectArrow, SelectContent, SelectGroup, SelectIcon, SelectItem, SelectItemIndicator, SelectItemText, SelectLabel, SelectPortal, SelectRoot, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SelectViewport, Separator, SliderRange, SliderRoot, SliderThumb, SliderTrack, Slot, SplitterGroup, SplitterPanel, SplitterResizeHandle, SwitchRoot, SwitchThumb, TabsContent, TabsIndicator, TabsList, TabsRoot, TabsTrigger, TagsInputClear, TagsInputInput, TagsInputItem, TagsInputItemDelete, TagsInputItemText, TagsInputRoot, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastRoot, ToastTitle, ToastViewport, Toggle, ToggleGroupItem, ToggleGroupRoot, ToolbarButton, ToolbarLink, ToolbarRoot, ToolbarSeparator, ToolbarToggleGroup, ToolbarToggleItem, TooltipArrow, TooltipContent, TooltipPortal, TooltipProvider, TooltipRoot, TooltipTrigger, TreeItem, TreeRoot, TreeVirtualizer, Viewport, VisuallyHidden } from 'radix-vue' export const Accordion = { Content: AccordionContent, @@ -714,4 +714,14 @@ export const Tooltip = { Provider: typeof TooltipProvider } +export const Tree = { + Root: TreeRoot, + Item: TreeItem, + Virtualizer: TreeVirtualizer, +} as { + Root: typeof TreeRoot + Item: typeof TreeItem + Virtualizer: typeof TreeVirtualizer +} + export { Viewport } diff --git a/packages/radix-vue/constant/components.ts b/packages/radix-vue/constant/components.ts index 446b5f64d..d5766cacd 100644 --- a/packages/radix-vue/constant/components.ts +++ b/packages/radix-vue/constant/components.ts @@ -408,6 +408,12 @@ export const components = { 'TooltipProvider', ], + tree: [ + 'TreeRoot', + 'TreeItem', + 'TreeVirtualizer', + ], + viewport: [ 'Viewport', ], diff --git a/packages/radix-vue/src/Calendar/CalendarNext.vue b/packages/radix-vue/src/Calendar/CalendarNext.vue index cb7e9fd57..77b3b439c 100644 --- a/packages/radix-vue/src/Calendar/CalendarNext.vue +++ b/packages/radix-vue/src/Calendar/CalendarNext.vue @@ -4,11 +4,12 @@ import type { CalendarIncrement } from '@/shared/date' import type { DateValue } from '@internationalized/date' export interface CalendarNextProps extends PrimitiveProps { -/** The calendar unit to go forward -* @deprecated Use `nextPage` instead -*/ +/** + * The calendar unit to go forward + * @deprecated Use `nextPage` instead + */ step?: CalendarIncrement -/** The function to be used for the next page. Overwrites the `nextPage` function set on the `CalendarRoot`. */ + /** The function to be used for the next page. Overwrites the `nextPage` function set on the `CalendarRoot`. */ nextPage?: (placeholder: DateValue) => DateValue } diff --git a/packages/radix-vue/src/Calendar/CalendarPrev.vue b/packages/radix-vue/src/Calendar/CalendarPrev.vue index bf6f38588..41597c335 100644 --- a/packages/radix-vue/src/Calendar/CalendarPrev.vue +++ b/packages/radix-vue/src/Calendar/CalendarPrev.vue @@ -4,11 +4,12 @@ import type { CalendarIncrement } from '@/shared/date' import type { DateValue } from '@internationalized/date' export interface CalendarPrevProps extends PrimitiveProps { -/** The calendar unit to go back -* @deprecated Use `prevPage` instead -*/ +/** + * The calendar unit to go back + * @deprecated Use `prevPage` instead + */ step?: CalendarIncrement -/** The function to be used for the prev page. Overwrites the `prevPage` function set on the `CalendarRoot`. */ + /** The function to be used for the prev page. Overwrites the `prevPage` function set on the `CalendarRoot`. */ prevPage?: (placeholder: DateValue) => DateValue } diff --git a/packages/radix-vue/src/Calendar/story/CalendarChromatic.story.vue b/packages/radix-vue/src/Calendar/story/CalendarChromatic.story.vue index 6e511ec64..5387aee9b 100644 --- a/packages/radix-vue/src/Calendar/story/CalendarChromatic.story.vue +++ b/packages/radix-vue/src/Calendar/story/CalendarChromatic.story.vue @@ -8,7 +8,7 @@ const modelValue = ref(defaultValue) as Ref const placeholder = ref(new CalendarDate(2024, 4, 1)) as Ref -const paging = (date: DateValue, sign: -1 | 1) => { +function paging(date: DateValue, sign: -1 | 1) { if (sign === -1) return date.subtract({ years: 1 }) return date.add({ years: 1 }) @@ -79,7 +79,11 @@ const paging = (date: DateValue, sign: -1 | 1) => { - + diff --git a/packages/radix-vue/src/Calendar/story/CalendarYearIncrement.story.vue b/packages/radix-vue/src/Calendar/story/CalendarYearIncrement.story.vue index e73d888c3..75b0f2737 100644 --- a/packages/radix-vue/src/Calendar/story/CalendarYearIncrement.story.vue +++ b/packages/radix-vue/src/Calendar/story/CalendarYearIncrement.story.vue @@ -1,9 +1,9 @@ diff --git a/packages/radix-vue/src/Collection/Collection.ts b/packages/radix-vue/src/Collection/Collection.ts index faba925b1..8f4255bdc 100644 --- a/packages/radix-vue/src/Collection/Collection.ts +++ b/packages/radix-vue/src/Collection/Collection.ts @@ -5,7 +5,7 @@ import { Slot, usePrimitiveElement } from '@/Primitive' interface CollectionContext { collectionRef: Ref - itemMap: Ref> + itemMap: Ref> attrName: string } @@ -46,20 +46,21 @@ export const CollectionSlot = defineComponent({ export const CollectionItem = defineComponent({ name: 'CollectionItem', + inheritAttrs: false, setup(_, { slots, attrs }) { const context = injectCollectionContext() const { primitiveElement, currentElement } = usePrimitiveElement() - const vm = getCurrentInstance() + const { value, ...restAttrs } = attrs watchEffect((cleanupFn) => { if (currentElement.value) { const key = markRaw(currentElement.value) - context.itemMap.value.set(key, { ref: currentElement.value!, ...(markRaw(vm?.parent?.props ?? {})) }) + context.itemMap.value.set(key, { ref: currentElement.value!, value }) cleanupFn(() => context.itemMap.value.delete(key)) } }) - return () => h(Slot, { ...attrs, [context.attrName]: '', ref: primitiveElement }, slots) + return () => h(Slot, { ...restAttrs, [context.attrName]: '', ref: primitiveElement }, slots) }, }) diff --git a/packages/radix-vue/src/Combobox/ComboboxItem.vue b/packages/radix-vue/src/Combobox/ComboboxItem.vue index f1935249c..f11bb8b07 100644 --- a/packages/radix-vue/src/Combobox/ComboboxItem.vue +++ b/packages/radix-vue/src/Combobox/ComboboxItem.vue @@ -103,7 +103,7 @@ provideComboboxItemContext({