reka-ui 2.7.0 → 2.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Avatar/AvatarImage.cjs +4 -2
- package/dist/Avatar/AvatarImage.cjs.map +1 -1
- package/dist/Avatar/AvatarImage.js +4 -2
- package/dist/Avatar/AvatarImage.js.map +1 -1
- package/dist/Calendar/CalendarCellTrigger.cjs +4 -1
- package/dist/Calendar/CalendarCellTrigger.cjs.map +1 -1
- package/dist/Calendar/CalendarCellTrigger.js +4 -1
- package/dist/Calendar/CalendarCellTrigger.js.map +1 -1
- package/dist/Calendar/CalendarRoot.cjs +12 -7
- package/dist/Calendar/CalendarRoot.cjs.map +1 -1
- package/dist/Calendar/CalendarRoot.js +13 -8
- package/dist/Calendar/CalendarRoot.js.map +1 -1
- package/dist/Calendar/useCalendar.cjs +32 -2
- package/dist/Calendar/useCalendar.cjs.map +1 -1
- package/dist/Calendar/useCalendar.js +33 -3
- package/dist/Calendar/useCalendar.js.map +1 -1
- package/dist/Collection/Collection.cjs +6 -2
- package/dist/Collection/Collection.cjs.map +1 -1
- package/dist/Collection/Collection.js +6 -2
- package/dist/Collection/Collection.js.map +1 -1
- package/dist/Combobox/ComboboxContent.cjs +4 -0
- package/dist/Combobox/ComboboxContent.cjs.map +1 -1
- package/dist/Combobox/ComboboxContent.js +4 -0
- package/dist/Combobox/ComboboxContent.js.map +1 -1
- package/dist/Combobox/ComboboxContentImpl.cjs +47 -33
- package/dist/Combobox/ComboboxContentImpl.cjs.map +1 -1
- package/dist/Combobox/ComboboxContentImpl.js +48 -34
- package/dist/Combobox/ComboboxContentImpl.js.map +1 -1
- package/dist/ContextMenu/ContextMenuContent.cjs +4 -0
- package/dist/ContextMenu/ContextMenuContent.cjs.map +1 -1
- package/dist/ContextMenu/ContextMenuContent.js +4 -0
- package/dist/ContextMenu/ContextMenuContent.js.map +1 -1
- package/dist/ContextMenu/ContextMenuRadioGroup.cjs +1 -1
- package/dist/ContextMenu/ContextMenuRadioGroup.js +1 -1
- package/dist/ContextMenu/ContextMenuRadioItem.cjs +1 -1
- package/dist/ContextMenu/ContextMenuRadioItem.js +1 -1
- package/dist/ContextMenu/ContextMenuSubContent.cjs +4 -0
- package/dist/ContextMenu/ContextMenuSubContent.cjs.map +1 -1
- package/dist/ContextMenu/ContextMenuSubContent.js +4 -0
- package/dist/ContextMenu/ContextMenuSubContent.js.map +1 -1
- package/dist/DatePicker/DatePickerContent.cjs +4 -0
- package/dist/DatePicker/DatePickerContent.cjs.map +1 -1
- package/dist/DatePicker/DatePickerContent.js +4 -0
- package/dist/DatePicker/DatePickerContent.js.map +1 -1
- package/dist/DatePicker/DatePickerRoot.cjs +10 -8
- package/dist/DatePicker/DatePickerRoot.cjs.map +1 -1
- package/dist/DatePicker/DatePickerRoot.js +10 -8
- package/dist/DatePicker/DatePickerRoot.js.map +1 -1
- package/dist/DateRangePicker/DateRangePickerContent.cjs +4 -0
- package/dist/DateRangePicker/DateRangePickerContent.cjs.map +1 -1
- package/dist/DateRangePicker/DateRangePickerContent.js +4 -0
- package/dist/DateRangePicker/DateRangePickerContent.js.map +1 -1
- package/dist/DateRangePicker/DateRangePickerRoot.cjs +10 -8
- package/dist/DateRangePicker/DateRangePickerRoot.cjs.map +1 -1
- package/dist/DateRangePicker/DateRangePickerRoot.js +11 -9
- package/dist/DateRangePicker/DateRangePickerRoot.js.map +1 -1
- package/dist/DropdownMenu/DropdownMenuContent.cjs +4 -0
- package/dist/DropdownMenu/DropdownMenuContent.cjs.map +1 -1
- package/dist/DropdownMenu/DropdownMenuContent.js +4 -0
- package/dist/DropdownMenu/DropdownMenuContent.js.map +1 -1
- package/dist/DropdownMenu/DropdownMenuRadioGroup.cjs +1 -1
- package/dist/DropdownMenu/DropdownMenuRadioGroup.js +1 -1
- package/dist/DropdownMenu/DropdownMenuRadioItem.cjs +1 -1
- package/dist/DropdownMenu/DropdownMenuRadioItem.js +1 -1
- package/dist/DropdownMenu/DropdownMenuSubContent.cjs +4 -0
- package/dist/DropdownMenu/DropdownMenuSubContent.cjs.map +1 -1
- package/dist/DropdownMenu/DropdownMenuSubContent.js +4 -0
- package/dist/DropdownMenu/DropdownMenuSubContent.js.map +1 -1
- package/dist/Editable/EditableInput.cjs +1 -1
- package/dist/Editable/EditableInput.cjs.map +1 -1
- package/dist/Editable/EditableInput.js +1 -1
- package/dist/Editable/EditableInput.js.map +1 -1
- package/dist/FocusScope/FocusScope.cjs +1 -1
- package/dist/FocusScope/FocusScope.cjs.map +1 -1
- package/dist/FocusScope/FocusScope.js +2 -2
- package/dist/FocusScope/FocusScope.js.map +1 -1
- package/dist/FocusScope/stack.cjs +0 -9
- package/dist/FocusScope/stack.cjs.map +1 -1
- package/dist/FocusScope/stack.js +1 -4
- package/dist/FocusScope/stack.js.map +1 -1
- package/dist/HoverCard/HoverCardContent.cjs +4 -0
- package/dist/HoverCard/HoverCardContent.cjs.map +1 -1
- package/dist/HoverCard/HoverCardContent.js +4 -0
- package/dist/HoverCard/HoverCardContent.js.map +1 -1
- package/dist/HoverCard/HoverCardContentImpl.cjs +4 -0
- package/dist/HoverCard/HoverCardContentImpl.cjs.map +1 -1
- package/dist/HoverCard/HoverCardContentImpl.js +4 -0
- package/dist/HoverCard/HoverCardContentImpl.js.map +1 -1
- package/dist/Listbox/ListboxRoot.cjs.map +1 -1
- package/dist/Listbox/ListboxRoot.js.map +1 -1
- package/dist/Menu/MenuContent.cjs +4 -0
- package/dist/Menu/MenuContent.cjs.map +1 -1
- package/dist/Menu/MenuContent.js +4 -0
- package/dist/Menu/MenuContent.js.map +1 -1
- package/dist/Menu/MenuContentImpl.cjs +4 -0
- package/dist/Menu/MenuContentImpl.cjs.map +1 -1
- package/dist/Menu/MenuContentImpl.js +4 -0
- package/dist/Menu/MenuContentImpl.js.map +1 -1
- package/dist/Menu/MenuRadioGroup.cjs +1 -1
- package/dist/Menu/MenuRadioGroup.cjs.map +1 -1
- package/dist/Menu/MenuRadioGroup.js +1 -1
- package/dist/Menu/MenuRadioGroup.js.map +1 -1
- package/dist/Menu/MenuRadioItem.cjs +1 -1
- package/dist/Menu/MenuRadioItem.cjs.map +1 -1
- package/dist/Menu/MenuRadioItem.js +1 -1
- package/dist/Menu/MenuRadioItem.js.map +1 -1
- package/dist/Menu/MenuRootContentModal.cjs +4 -0
- package/dist/Menu/MenuRootContentModal.cjs.map +1 -1
- package/dist/Menu/MenuRootContentModal.js +4 -0
- package/dist/Menu/MenuRootContentModal.js.map +1 -1
- package/dist/Menu/MenuRootContentNonModal.cjs +4 -0
- package/dist/Menu/MenuRootContentNonModal.cjs.map +1 -1
- package/dist/Menu/MenuRootContentNonModal.js +4 -0
- package/dist/Menu/MenuRootContentNonModal.js.map +1 -1
- package/dist/Menu/MenuSubContent.cjs +4 -0
- package/dist/Menu/MenuSubContent.cjs.map +1 -1
- package/dist/Menu/MenuSubContent.js +4 -0
- package/dist/Menu/MenuSubContent.js.map +1 -1
- package/dist/Menubar/MenubarContent.cjs +4 -0
- package/dist/Menubar/MenubarContent.cjs.map +1 -1
- package/dist/Menubar/MenubarContent.js +4 -0
- package/dist/Menubar/MenubarContent.js.map +1 -1
- package/dist/Menubar/MenubarRadioGroup.cjs +1 -1
- package/dist/Menubar/MenubarRadioGroup.js +1 -1
- package/dist/Menubar/MenubarRadioItem.cjs +1 -1
- package/dist/Menubar/MenubarRadioItem.js +1 -1
- package/dist/Menubar/MenubarSubContent.cjs +4 -0
- package/dist/Menubar/MenubarSubContent.cjs.map +1 -1
- package/dist/Menubar/MenubarSubContent.js +4 -0
- package/dist/Menubar/MenubarSubContent.js.map +1 -1
- package/dist/NavigationMenu/NavigationMenuContent.cjs +1 -1
- package/dist/NavigationMenu/NavigationMenuContent.js +1 -1
- package/dist/NavigationMenu/NavigationMenuContentImpl.cjs +1 -1
- package/dist/NavigationMenu/NavigationMenuContentImpl.js +1 -1
- package/dist/NavigationMenu/NavigationMenuItem.cjs +1 -1
- package/dist/NavigationMenu/NavigationMenuItem.js +1 -1
- package/dist/NavigationMenu/NavigationMenuRoot.cjs +7 -5
- package/dist/NavigationMenu/NavigationMenuRoot.cjs.map +1 -1
- package/dist/NavigationMenu/NavigationMenuRoot.js +8 -6
- package/dist/NavigationMenu/NavigationMenuRoot.js.map +1 -1
- package/dist/NavigationMenu/NavigationMenuTrigger.cjs +1 -1
- package/dist/NavigationMenu/NavigationMenuTrigger.js +1 -1
- package/dist/NavigationMenu/NavigationMenuViewport.cjs +1 -1
- package/dist/NavigationMenu/NavigationMenuViewport.js +1 -1
- package/dist/NumberField/NumberFieldRoot.cjs +6 -1
- package/dist/NumberField/NumberFieldRoot.cjs.map +1 -1
- package/dist/NumberField/NumberFieldRoot.js +6 -1
- package/dist/NumberField/NumberFieldRoot.js.map +1 -1
- package/dist/PinInput/PinInputInput.cjs +15 -11
- package/dist/PinInput/PinInputInput.cjs.map +1 -1
- package/dist/PinInput/PinInputInput.js +15 -11
- package/dist/PinInput/PinInputInput.js.map +1 -1
- package/dist/Popover/PopoverContent.cjs +4 -0
- package/dist/Popover/PopoverContent.cjs.map +1 -1
- package/dist/Popover/PopoverContent.js +4 -0
- package/dist/Popover/PopoverContent.js.map +1 -1
- package/dist/Popover/PopoverContentImpl.cjs +4 -0
- package/dist/Popover/PopoverContentImpl.cjs.map +1 -1
- package/dist/Popover/PopoverContentImpl.js +4 -0
- package/dist/Popover/PopoverContentImpl.js.map +1 -1
- package/dist/Popover/PopoverContentModal.cjs +4 -0
- package/dist/Popover/PopoverContentModal.cjs.map +1 -1
- package/dist/Popover/PopoverContentModal.js +4 -0
- package/dist/Popover/PopoverContentModal.js.map +1 -1
- package/dist/Popover/PopoverContentNonModal.cjs +4 -0
- package/dist/Popover/PopoverContentNonModal.cjs.map +1 -1
- package/dist/Popover/PopoverContentNonModal.js +4 -0
- package/dist/Popover/PopoverContentNonModal.js.map +1 -1
- package/dist/Popper/PopperContent.cjs +10 -2
- package/dist/Popper/PopperContent.cjs.map +1 -1
- package/dist/Popper/PopperContent.js +10 -2
- package/dist/Popper/PopperContent.js.map +1 -1
- package/dist/RangeCalendar/RangeCalendarCellTrigger.cjs +8 -2
- package/dist/RangeCalendar/RangeCalendarCellTrigger.cjs.map +1 -1
- package/dist/RangeCalendar/RangeCalendarCellTrigger.js +8 -2
- package/dist/RangeCalendar/RangeCalendarCellTrigger.js.map +1 -1
- package/dist/RangeCalendar/RangeCalendarGrid.cjs +2 -1
- package/dist/RangeCalendar/RangeCalendarGrid.cjs.map +1 -1
- package/dist/RangeCalendar/RangeCalendarGrid.js +2 -1
- package/dist/RangeCalendar/RangeCalendarGrid.js.map +1 -1
- package/dist/RangeCalendar/RangeCalendarRoot.cjs +30 -16
- package/dist/RangeCalendar/RangeCalendarRoot.cjs.map +1 -1
- package/dist/RangeCalendar/RangeCalendarRoot.js +31 -17
- package/dist/RangeCalendar/RangeCalendarRoot.js.map +1 -1
- package/dist/RangeCalendar/useRangeCalendar.cjs +41 -8
- package/dist/RangeCalendar/useRangeCalendar.cjs.map +1 -1
- package/dist/RangeCalendar/useRangeCalendar.js +41 -8
- package/dist/RangeCalendar/useRangeCalendar.js.map +1 -1
- package/dist/ScrollArea/ScrollAreaRoot.cjs.map +1 -1
- package/dist/ScrollArea/ScrollAreaRoot.js.map +1 -1
- package/dist/ScrollArea/ScrollAreaScrollbar.cjs +9 -2
- package/dist/ScrollArea/ScrollAreaScrollbar.cjs.map +1 -1
- package/dist/ScrollArea/ScrollAreaScrollbar.js +9 -2
- package/dist/ScrollArea/ScrollAreaScrollbar.js.map +1 -1
- package/dist/ScrollArea/ScrollAreaScrollbarGlimpse.cjs +132 -0
- package/dist/ScrollArea/ScrollAreaScrollbarGlimpse.cjs.map +1 -0
- package/dist/ScrollArea/ScrollAreaScrollbarGlimpse.js +126 -0
- package/dist/ScrollArea/ScrollAreaScrollbarGlimpse.js.map +1 -0
- package/dist/Select/SelectContent.cjs +4 -0
- package/dist/Select/SelectContent.cjs.map +1 -1
- package/dist/Select/SelectContent.js +4 -0
- package/dist/Select/SelectContent.js.map +1 -1
- package/dist/Select/SelectContentImpl.cjs +4 -0
- package/dist/Select/SelectContentImpl.cjs.map +1 -1
- package/dist/Select/SelectContentImpl.js +4 -0
- package/dist/Select/SelectContentImpl.js.map +1 -1
- package/dist/Select/SelectPopperPosition.cjs +4 -0
- package/dist/Select/SelectPopperPosition.cjs.map +1 -1
- package/dist/Select/SelectPopperPosition.js +4 -0
- package/dist/Select/SelectPopperPosition.js.map +1 -1
- package/dist/Tabs/TabsContent.cjs +4 -0
- package/dist/Tabs/TabsContent.cjs.map +1 -1
- package/dist/Tabs/TabsContent.js +5 -1
- package/dist/Tabs/TabsContent.js.map +1 -1
- package/dist/Tabs/TabsRoot.cjs +11 -1
- package/dist/Tabs/TabsRoot.cjs.map +1 -1
- package/dist/Tabs/TabsRoot.js +12 -2
- package/dist/Tabs/TabsRoot.js.map +1 -1
- package/dist/Tabs/TabsTrigger.cjs +1 -1
- package/dist/Tabs/TabsTrigger.cjs.map +1 -1
- package/dist/Tabs/TabsTrigger.js +1 -1
- package/dist/Tabs/TabsTrigger.js.map +1 -1
- package/dist/TimeField/TimeFieldInput.cjs +3 -1
- package/dist/TimeField/TimeFieldInput.cjs.map +1 -1
- package/dist/TimeField/TimeFieldInput.js +3 -1
- package/dist/TimeField/TimeFieldInput.js.map +1 -1
- package/dist/TimeField/TimeFieldRoot.cjs +24 -2
- package/dist/TimeField/TimeFieldRoot.cjs.map +1 -1
- package/dist/TimeField/TimeFieldRoot.js +24 -2
- package/dist/TimeField/TimeFieldRoot.js.map +1 -1
- package/dist/date/calendar.cjs +29 -9
- package/dist/date/calendar.cjs.map +1 -1
- package/dist/date/calendar.js +25 -11
- package/dist/date/calendar.js.map +1 -1
- package/dist/date/comparators.cjs +14 -2
- package/dist/date/comparators.cjs.map +1 -1
- package/dist/date/comparators.js +14 -2
- package/dist/date/comparators.js.map +1 -1
- package/dist/date/parser.cjs +1 -0
- package/dist/date/parser.cjs.map +1 -1
- package/dist/date/parser.js +1 -0
- package/dist/date/parser.js.map +1 -1
- package/dist/date/useDateField.cjs +41 -20
- package/dist/date/useDateField.cjs.map +1 -1
- package/dist/date/useDateField.js +41 -20
- package/dist/date/useDateField.js.map +1 -1
- package/dist/date.cjs +1 -0
- package/dist/date.d.cts +2 -2
- package/dist/date.d.ts +2 -2
- package/dist/date.js +2 -2
- package/dist/index.cjs +3 -1
- package/dist/index.d.cts +1148 -1106
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +670 -628
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index2.d.cts +9 -2
- package/dist/index2.d.cts.map +1 -1
- package/dist/index2.d.ts +9 -2
- package/dist/index2.d.ts.map +1 -1
- package/dist/shared/useDateFormatter.cjs +1 -1
- package/dist/shared/useDateFormatter.cjs.map +1 -1
- package/dist/shared/useDateFormatter.js +1 -1
- package/dist/shared/useDateFormatter.js.map +1 -1
- package/dist/shared/useForwardExpose.cjs +1 -1
- package/dist/shared/useForwardExpose.cjs.map +1 -1
- package/dist/shared/useForwardExpose.js +1 -1
- package/dist/shared/useForwardExpose.js.map +1 -1
- package/dist/shared/useGraceArea.cjs +1 -1
- package/dist/shared/useGraceArea.cjs.map +1 -1
- package/dist/shared/useGraceArea.js +1 -1
- package/dist/shared/useGraceArea.js.map +1 -1
- package/package.json +20 -16
- package/src/Avatar/AvatarImage.vue +2 -1
- package/src/Calendar/CalendarCellTrigger.vue +8 -1
- package/src/Calendar/CalendarRoot.vue +19 -7
- package/src/Calendar/useCalendar.ts +43 -3
- package/src/Collection/Collection.ts +3 -2
- package/src/Combobox/ComboboxContentImpl.vue +40 -32
- package/src/Combobox/ComboboxRoot.vue +1 -1
- package/src/DatePicker/DatePickerRoot.vue +10 -10
- package/src/DatePicker/index.ts +4 -4
- package/src/DateRangePicker/DateRangePickerRoot.vue +11 -11
- package/src/DateRangePicker/index.ts +4 -4
- package/src/Editable/EditableInput.vue +1 -1
- package/src/FocusScope/FocusScope.vue +2 -2
- package/src/Listbox/ListboxFilter.vue +1 -1
- package/src/Listbox/ListboxRoot.vue +2 -1
- package/src/Menu/MenuRadioGroup.vue +5 -4
- package/src/Menu/MenuRadioItem.vue +2 -1
- package/src/NavigationMenu/NavigationMenuRoot.vue +10 -6
- package/src/NumberField/NumberFieldRoot.vue +6 -1
- package/src/PinInput/PinInputInput.vue +25 -18
- package/src/Popper/PopperContent.vue +15 -5
- package/src/RadioGroup/RadioGroupRoot.vue +1 -1
- package/src/RangeCalendar/RangeCalendarCellTrigger.vue +13 -3
- package/src/RangeCalendar/RangeCalendarGrid.vue +1 -0
- package/src/RangeCalendar/RangeCalendarRoot.vue +46 -30
- package/src/RangeCalendar/useRangeCalendar.ts +43 -15
- package/src/Rating/RatingItem.vue +52 -0
- package/src/Rating/RatingItemIndicator.vue +60 -0
- package/src/Rating/RatingRoot.vue +113 -0
- package/src/Rating/index.ts +3 -0
- package/src/ScrollArea/ScrollAreaRoot.vue +2 -1
- package/src/ScrollArea/ScrollAreaScrollbar.vue +9 -0
- package/src/ScrollArea/ScrollAreaScrollbarGlimpse.vue +145 -0
- package/src/ScrollArea/index.ts +4 -0
- package/src/ScrollArea/types.ts +1 -1
- package/src/Tabs/TabsContent.vue +6 -1
- package/src/Tabs/TabsRoot.vue +14 -1
- package/src/Tabs/TabsTrigger.vue +1 -1
- package/src/TimeField/TimeFieldInput.vue +6 -1
- package/src/TimeField/TimeFieldRoot.vue +25 -2
- package/src/Tree/TreeRoot.vue +2 -2
- package/src/date/calendar.ts +42 -18
- package/src/date/comparators.ts +15 -2
- package/src/index.ts +1 -0
- package/src/shared/date/parser.ts +10 -0
- package/src/shared/date/useDateField.ts +72 -21
- package/src/shared/index.ts +1 -1
- package/src/shared/useDateFormatter.ts +2 -2
- package/src/shared/useForwardExpose.ts +1 -1
- package/src/shared/useGraceArea.ts +1 -1
|
@@ -50,11 +50,18 @@ function handleInput(event: InputEvent) {
|
|
|
50
50
|
nextEl.focus()
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
function
|
|
54
|
-
const target = currentElement.value as HTMLInputElement
|
|
53
|
+
function updatePlaceholder() {
|
|
55
54
|
nextTick(() => {
|
|
56
|
-
|
|
55
|
+
const target = currentElement.value as HTMLInputElement
|
|
56
|
+
if (!target) {
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
if (!target.value && target === getActiveElement()) {
|
|
60
|
+
target.placeholder = ''
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
57
63
|
target.placeholder = context.placeholder.value
|
|
64
|
+
}
|
|
58
65
|
})
|
|
59
66
|
}
|
|
60
67
|
|
|
@@ -93,21 +100,25 @@ function handleDelete(event: KeyboardEvent) {
|
|
|
93
100
|
}
|
|
94
101
|
|
|
95
102
|
function handleFocus(event: FocusEvent) {
|
|
103
|
+
// In OTP mode, inputs should be filled one by one without skipping middle inputs
|
|
104
|
+
if (context.otp.value) {
|
|
105
|
+
const firstEmptyInputIdx = inputElements.value.findIndex((_, idx) =>
|
|
106
|
+
context.currentModelValue.value[idx] === ''
|
|
107
|
+
|| context.currentModelValue.value[idx] === undefined,
|
|
108
|
+
)
|
|
109
|
+
if (firstEmptyInputIdx !== -1 && firstEmptyInputIdx < props.index) {
|
|
110
|
+
inputElements.value[firstEmptyInputIdx].focus()
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
96
115
|
const target = event.target as HTMLInputElement
|
|
97
116
|
target.setSelectionRange(1, 1)
|
|
98
|
-
|
|
99
|
-
if (!target.value)
|
|
100
|
-
target.placeholder = ''
|
|
101
|
-
|
|
102
|
-
// #2266, check again after DOM flushes
|
|
103
|
-
setTimeout(() => {
|
|
104
|
-
if (!target.value)
|
|
105
|
-
target.placeholder = ''
|
|
106
|
-
})
|
|
117
|
+
updatePlaceholder()
|
|
107
118
|
}
|
|
108
119
|
|
|
109
120
|
function handleBlur(event: FocusEvent) {
|
|
110
|
-
|
|
121
|
+
updatePlaceholder()
|
|
111
122
|
}
|
|
112
123
|
|
|
113
124
|
function handlePaste(event: ClipboardEvent) {
|
|
@@ -168,11 +179,7 @@ function updateModelValueAt(index: number, value: string) {
|
|
|
168
179
|
context.modelValue.value = removeTrailingEmptyStrings(tempModelValue)
|
|
169
180
|
}
|
|
170
181
|
|
|
171
|
-
watch(currentValue,
|
|
172
|
-
if (!currentValue.value) {
|
|
173
|
-
resetPlaceholder()
|
|
174
|
-
}
|
|
175
|
-
})
|
|
182
|
+
watch(currentValue, updatePlaceholder)
|
|
176
183
|
|
|
177
184
|
onMounted(() => {
|
|
178
185
|
context.onInputElementChange(currentElement.value as HTMLInputElement)
|
|
@@ -20,6 +20,7 @@ export const PopperContentPropsDefaultValue = {
|
|
|
20
20
|
alignOffset: 0,
|
|
21
21
|
alignFlip: true,
|
|
22
22
|
arrowPadding: 0,
|
|
23
|
+
hideShiftedArrow: true,
|
|
23
24
|
avoidCollisions: true,
|
|
24
25
|
collisionBoundary: () => [],
|
|
25
26
|
collisionPadding: 0,
|
|
@@ -36,7 +37,7 @@ export interface PopperContentProps extends PrimitiveProps {
|
|
|
36
37
|
* Will be reversed when collisions occur and avoidCollisions
|
|
37
38
|
* is enabled.
|
|
38
39
|
*
|
|
39
|
-
* @defaultValue "
|
|
40
|
+
* @defaultValue "bottom"
|
|
40
41
|
*/
|
|
41
42
|
side?: Side
|
|
42
43
|
|
|
@@ -112,6 +113,14 @@ export interface PopperContentProps extends PrimitiveProps {
|
|
|
112
113
|
*/
|
|
113
114
|
arrowPadding?: number
|
|
114
115
|
|
|
116
|
+
/**
|
|
117
|
+
* When `true`, hides the arrow when it cannot be centered
|
|
118
|
+
* to the reference element.
|
|
119
|
+
*
|
|
120
|
+
* @defaultValue true
|
|
121
|
+
*/
|
|
122
|
+
hideShiftedArrow?: boolean
|
|
123
|
+
|
|
115
124
|
/**
|
|
116
125
|
* The sticky behavior on the align axis. `partial` will keep the
|
|
117
126
|
* content in the boundary as long as the trigger is at least partially
|
|
@@ -346,9 +355,10 @@ watchPostEffect(() => {
|
|
|
346
355
|
emits('placed')
|
|
347
356
|
})
|
|
348
357
|
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
|
|
358
|
+
const shouldHideArrow = computed(() => {
|
|
359
|
+
const cannotCenterArrow = middlewareData.value.arrow?.centerOffset !== 0
|
|
360
|
+
return props.hideShiftedArrow && cannotCenterArrow
|
|
361
|
+
})
|
|
352
362
|
|
|
353
363
|
const contentZIndex = ref('')
|
|
354
364
|
watchEffect(() => {
|
|
@@ -364,7 +374,7 @@ providePopperContentContext({
|
|
|
364
374
|
onArrowChange: element => arrow.value = element,
|
|
365
375
|
arrowX,
|
|
366
376
|
arrowY,
|
|
367
|
-
shouldHideArrow
|
|
377
|
+
shouldHideArrow,
|
|
368
378
|
})
|
|
369
379
|
</script>
|
|
370
380
|
|
|
@@ -24,7 +24,7 @@ export interface RadioGroupRootProps extends PrimitiveProps, FormFieldProps {
|
|
|
24
24
|
}
|
|
25
25
|
export type RadioGroupRootEmits = {
|
|
26
26
|
/** Event handler called when the radio group value changes */
|
|
27
|
-
'update:modelValue': [payload:
|
|
27
|
+
'update:modelValue': [payload: AcceptableValue]
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
interface RadioGroupRootContext {
|
|
@@ -94,7 +94,15 @@ const isDisabled = computed(() => rootContext.isDateDisabled(props.day) || (root
|
|
|
94
94
|
const dayValue = computed(() => props.day.day.toLocaleString(rootContext.locale.value))
|
|
95
95
|
|
|
96
96
|
const isFocusedDate = computed(() => {
|
|
97
|
-
|
|
97
|
+
if (isOutsideView.value || isDisabled.value)
|
|
98
|
+
return false
|
|
99
|
+
if (!rootContext.disabled.value && rootContext.isPlaceholderFocusable.value && isSameDay(props.day, rootContext.placeholder.value))
|
|
100
|
+
return true
|
|
101
|
+
if (!rootContext.disabled.value && rootContext.selectedFocusableDate.value && !rootContext.isPlaceholderFocusable.value)
|
|
102
|
+
return isSameDay(props.day, rootContext.selectedFocusableDate.value)
|
|
103
|
+
if (!rootContext.disabled.value && (!rootContext.hasSelectedDate.value || rootContext.isSelectedDisabled.value) && !rootContext.isPlaceholderFocusable.value)
|
|
104
|
+
return rootContext.firstFocusableDate.value && isSameDay(props.day, rootContext.firstFocusableDate.value)
|
|
105
|
+
return false
|
|
98
106
|
})
|
|
99
107
|
|
|
100
108
|
function changeDate(e: MouseEvent | KeyboardEvent, date: DateValue) {
|
|
@@ -103,22 +111,24 @@ function changeDate(e: MouseEvent | KeyboardEvent, date: DateValue) {
|
|
|
103
111
|
if (rootContext.isDateDisabled(date) || rootContext.isDateUnavailable?.(date))
|
|
104
112
|
return
|
|
105
113
|
|
|
106
|
-
rootContext.lastPressedDateValue.value = date.copy()
|
|
107
|
-
|
|
108
114
|
if (rootContext.startValue.value && rootContext.highlightedRange.value === null) {
|
|
109
115
|
if (isSameDay(date, rootContext.startValue.value) && !rootContext.preventDeselect.value && !rootContext.endValue.value) {
|
|
110
116
|
rootContext.startValue.value = undefined
|
|
111
117
|
rootContext.onPlaceholderChange(date)
|
|
118
|
+
rootContext.lastPressedDateValue.value = date.copy()
|
|
112
119
|
return
|
|
113
120
|
}
|
|
114
121
|
else if (!rootContext.endValue.value) {
|
|
115
122
|
e.preventDefault()
|
|
116
123
|
if (rootContext.lastPressedDateValue.value && isSameDay(rootContext.lastPressedDateValue.value, date))
|
|
117
124
|
rootContext.startValue.value = date.copy()
|
|
125
|
+
rootContext.lastPressedDateValue.value = date.copy()
|
|
118
126
|
return
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
129
|
|
|
130
|
+
rootContext.lastPressedDateValue.value = date.copy()
|
|
131
|
+
|
|
122
132
|
if (
|
|
123
133
|
rootContext.startValue.value
|
|
124
134
|
&& rootContext.endValue.value
|
|
@@ -26,6 +26,7 @@ const readonly = computed(() => rootContext.readonly.value ? true : undefined)
|
|
|
26
26
|
:aria-disabled="disabled"
|
|
27
27
|
:data-readonly="readonly && ''"
|
|
28
28
|
:data-disabled="disabled && ''"
|
|
29
|
+
@mouseleave="rootContext.focusedValue.value = undefined"
|
|
29
30
|
>
|
|
30
31
|
<slot />
|
|
31
32
|
</Primitive>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { DateValue } from '@internationalized/date'
|
|
3
3
|
import type { Ref } from 'vue'
|
|
4
|
-
import type { Grid, Matcher, WeekDayFormat } from '@/date'
|
|
4
|
+
import type { Grid, Matcher, WeekDayFormat, WeekStartsOn } from '@/date'
|
|
5
5
|
import type { PrimitiveProps } from '@/Primitive'
|
|
6
6
|
import type { Formatter } from '@/shared'
|
|
7
7
|
import type { DateRange } from '@/shared/date'
|
|
8
8
|
import type { Direction } from '@/shared/types'
|
|
9
9
|
import { isEqualDay } from '@internationalized/date'
|
|
10
10
|
import { useCalendar } from '@/Calendar/useCalendar'
|
|
11
|
-
import { isBefore } from '@/date'
|
|
11
|
+
import { getWeekStartsOn, isBefore } from '@/date'
|
|
12
12
|
import {
|
|
13
13
|
createContext,
|
|
14
14
|
useDirection,
|
|
@@ -28,7 +28,7 @@ type RangeCalendarRootContext = {
|
|
|
28
28
|
preventDeselect: Ref<boolean>
|
|
29
29
|
grid: Ref<Grid<DateValue>[]>
|
|
30
30
|
weekDays: Ref<string[]>
|
|
31
|
-
weekStartsOn: Ref<
|
|
31
|
+
weekStartsOn: Ref<WeekStartsOn>
|
|
32
32
|
weekdayFormat: Ref<WeekDayFormat>
|
|
33
33
|
fixedWeeks: Ref<boolean>
|
|
34
34
|
numberOfMonths: Ref<number>
|
|
@@ -68,6 +68,11 @@ type RangeCalendarRootContext = {
|
|
|
68
68
|
maximumDays: Ref<number | undefined>
|
|
69
69
|
minValue: Ref<DateValue | undefined>
|
|
70
70
|
maxValue: Ref<DateValue | undefined>
|
|
71
|
+
isPlaceholderFocusable: Ref<boolean>
|
|
72
|
+
firstFocusableDate: Ref<DateValue | undefined>
|
|
73
|
+
hasSelectedDate: Ref<boolean>
|
|
74
|
+
isSelectedDisabled: Ref<boolean>
|
|
75
|
+
selectedFocusableDate: Ref<DateValue | undefined>
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
export interface RangeCalendarRootProps extends PrimitiveProps {
|
|
@@ -88,7 +93,7 @@ export interface RangeCalendarRootProps extends PrimitiveProps {
|
|
|
88
93
|
/** The maximum number of days that can be selected in a range */
|
|
89
94
|
maximumDays?: number
|
|
90
95
|
/** The day of the week to start the calendar on */
|
|
91
|
-
weekStartsOn?:
|
|
96
|
+
weekStartsOn?: WeekStartsOn
|
|
92
97
|
/** The format to use for the weekday strings provided via the weekdays slot prop */
|
|
93
98
|
weekdayFormat?: WeekDayFormat
|
|
94
99
|
/** The accessible label for the calendar */
|
|
@@ -145,7 +150,7 @@ export const [injectRangeCalendarRootContext, provideRangeCalendarRootContext]
|
|
|
145
150
|
|
|
146
151
|
<script setup lang="ts">
|
|
147
152
|
import { useEventListener, useVModel } from '@vueuse/core'
|
|
148
|
-
import { onMounted, ref, toRefs, watch } from 'vue'
|
|
153
|
+
import { computed, onMounted, ref, toRefs, watch } from 'vue'
|
|
149
154
|
import { Primitive, usePrimitiveElement } from '@/Primitive'
|
|
150
155
|
|
|
151
156
|
const props = withDefaults(defineProps<RangeCalendarRootProps>(), {
|
|
@@ -153,7 +158,6 @@ const props = withDefaults(defineProps<RangeCalendarRootProps>(), {
|
|
|
153
158
|
as: 'div',
|
|
154
159
|
pagedNavigation: false,
|
|
155
160
|
preventDeselect: false,
|
|
156
|
-
weekStartsOn: 0,
|
|
157
161
|
weekdayFormat: 'narrow',
|
|
158
162
|
fixedWeeks: false,
|
|
159
163
|
numberOfMonths: 1,
|
|
@@ -167,6 +171,7 @@ const props = withDefaults(defineProps<RangeCalendarRootProps>(), {
|
|
|
167
171
|
allowNonContiguousRanges: false,
|
|
168
172
|
maximumDays: undefined,
|
|
169
173
|
disableDaysOutsideCurrentView: false,
|
|
174
|
+
|
|
170
175
|
})
|
|
171
176
|
const emits = defineEmits<RangeCalendarRootEmits>()
|
|
172
177
|
|
|
@@ -179,7 +184,7 @@ defineSlots<{
|
|
|
179
184
|
/** The days of the week */
|
|
180
185
|
weekDays: string[]
|
|
181
186
|
/** The start of the week */
|
|
182
|
-
weekStartsOn:
|
|
187
|
+
weekStartsOn: WeekStartsOn
|
|
183
188
|
/** The calendar locale */
|
|
184
189
|
locale: string
|
|
185
190
|
/** Whether or not to always display 6 weeks in the calendar */
|
|
@@ -194,7 +199,6 @@ const {
|
|
|
194
199
|
readonly,
|
|
195
200
|
initialFocus,
|
|
196
201
|
pagedNavigation,
|
|
197
|
-
weekStartsOn,
|
|
198
202
|
weekdayFormat,
|
|
199
203
|
fixedWeeks,
|
|
200
204
|
numberOfMonths,
|
|
@@ -219,6 +223,7 @@ const { primitiveElement, currentElement: parentElement }
|
|
|
219
223
|
= usePrimitiveElement()
|
|
220
224
|
const dir = useDirection(propDir)
|
|
221
225
|
const locale = useLocale(propLocale)
|
|
226
|
+
const weekStartsOn = computed(() => props.weekStartsOn ?? getWeekStartsOn(locale.value))
|
|
222
227
|
|
|
223
228
|
const lastPressedDateValue = ref() as Ref<DateValue | undefined>
|
|
224
229
|
const focusedValue = ref() as Ref<DateValue | undefined>
|
|
@@ -227,9 +232,12 @@ const isEditing = ref(false)
|
|
|
227
232
|
const modelValue = useVModel(props, 'modelValue', emits, {
|
|
228
233
|
defaultValue: props.defaultValue ?? { start: undefined, end: undefined },
|
|
229
234
|
passive: (props.modelValue === undefined) as false,
|
|
230
|
-
}) as Ref<DateRange>
|
|
235
|
+
}) as Ref<DateRange | null>
|
|
236
|
+
|
|
237
|
+
const normalizeRange = (value?: DateRange | null): DateRange => value ?? { start: undefined, end: undefined }
|
|
238
|
+
const normalizedModelValue = computed(() => normalizeRange(modelValue.value))
|
|
231
239
|
|
|
232
|
-
const validModelValue = ref(modelValue.value) as Ref<DateRange>
|
|
240
|
+
const validModelValue = ref(normalizeRange(modelValue.value)) as Ref<DateRange>
|
|
233
241
|
|
|
234
242
|
watch(validModelValue, (value) => {
|
|
235
243
|
emits('update:validModelValue', value)
|
|
@@ -237,14 +245,14 @@ watch(validModelValue, (value) => {
|
|
|
237
245
|
|
|
238
246
|
const defaultDate = getDefaultDate({
|
|
239
247
|
defaultPlaceholder: props.placeholder,
|
|
240
|
-
defaultValue: modelValue.value.start,
|
|
248
|
+
defaultValue: normalizeRange(modelValue.value).start,
|
|
241
249
|
locale: props.locale,
|
|
242
250
|
})
|
|
243
251
|
|
|
244
|
-
const startValue = ref(modelValue.value.start) as Ref<
|
|
252
|
+
const startValue = ref(normalizeRange(modelValue.value).start) as Ref<
|
|
245
253
|
DateValue | undefined
|
|
246
254
|
>
|
|
247
|
-
const endValue = ref(modelValue.value.end) as Ref<DateValue | undefined>
|
|
255
|
+
const endValue = ref(normalizeRange(modelValue.value).end) as Ref<DateValue | undefined>
|
|
248
256
|
|
|
249
257
|
const placeholder = useVModel(props, 'placeholder', emits, {
|
|
250
258
|
defaultValue: props.defaultPlaceholder ?? defaultDate.copy(),
|
|
@@ -268,6 +276,8 @@ const {
|
|
|
268
276
|
nextPage,
|
|
269
277
|
prevPage,
|
|
270
278
|
formatter,
|
|
279
|
+
isPlaceholderFocusable,
|
|
280
|
+
firstFocusableDate,
|
|
271
281
|
} = useCalendar({
|
|
272
282
|
locale,
|
|
273
283
|
placeholder,
|
|
@@ -296,6 +306,9 @@ const {
|
|
|
296
306
|
isHighlightedStart,
|
|
297
307
|
isHighlightedEnd,
|
|
298
308
|
isDateDisabled: rangeIsDateDisabled,
|
|
309
|
+
hasSelectedDate,
|
|
310
|
+
isSelectedDisabled,
|
|
311
|
+
selectedFocusableDate,
|
|
299
312
|
} = useRangeCalendarState({
|
|
300
313
|
start: startValue,
|
|
301
314
|
end: endValue,
|
|
@@ -308,23 +321,21 @@ const {
|
|
|
308
321
|
maximumDays,
|
|
309
322
|
})
|
|
310
323
|
|
|
311
|
-
watch(modelValue, (_modelValue
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
||
|
|
316
|
-
|
|
317
|
-
) {
|
|
318
|
-
startValue.value =
|
|
324
|
+
watch(modelValue, (_modelValue) => {
|
|
325
|
+
const next = normalizeRange(_modelValue)
|
|
326
|
+
|
|
327
|
+
const isStartSynced = (!next.start && !startValue.value)
|
|
328
|
+
|| (!!next.start && !!startValue.value && isEqualDay(next.start, startValue.value))
|
|
329
|
+
|
|
330
|
+
if (!isStartSynced) {
|
|
331
|
+
startValue.value = next.start?.copy?.()
|
|
319
332
|
}
|
|
320
333
|
|
|
321
|
-
|
|
322
|
-
(
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
) {
|
|
327
|
-
endValue.value = _modelValue?.end?.copy?.()
|
|
334
|
+
const isEndSynced = (!next.end && !endValue.value)
|
|
335
|
+
|| (!!next.end && !!endValue.value && isEqualDay(next.end, endValue.value))
|
|
336
|
+
|
|
337
|
+
if (!isEndSynced) {
|
|
338
|
+
endValue.value = next.end?.copy?.()
|
|
328
339
|
}
|
|
329
340
|
})
|
|
330
341
|
|
|
@@ -382,7 +393,7 @@ provideRangeCalendarRootContext({
|
|
|
382
393
|
startValue,
|
|
383
394
|
endValue,
|
|
384
395
|
formatter,
|
|
385
|
-
modelValue,
|
|
396
|
+
modelValue: normalizedModelValue,
|
|
386
397
|
placeholder,
|
|
387
398
|
disabled,
|
|
388
399
|
initialFocus,
|
|
@@ -422,6 +433,11 @@ provideRangeCalendarRootContext({
|
|
|
422
433
|
maximumDays,
|
|
423
434
|
minValue,
|
|
424
435
|
maxValue,
|
|
436
|
+
isPlaceholderFocusable,
|
|
437
|
+
firstFocusableDate,
|
|
438
|
+
hasSelectedDate,
|
|
439
|
+
isSelectedDisabled,
|
|
440
|
+
selectedFocusableDate,
|
|
425
441
|
})
|
|
426
442
|
|
|
427
443
|
onMounted(() => {
|
|
@@ -470,7 +486,7 @@ onMounted(() => {
|
|
|
470
486
|
:week-starts-on="weekStartsOn"
|
|
471
487
|
:locale="locale"
|
|
472
488
|
:fixed-weeks="fixedWeeks"
|
|
473
|
-
:model-value="
|
|
489
|
+
:model-value="normalizedModelValue"
|
|
474
490
|
/>
|
|
475
491
|
</Primitive>
|
|
476
492
|
</template>
|
|
@@ -41,7 +41,7 @@ export function useRangeCalendarState(props: UseRangeCalendarProps) {
|
|
|
41
41
|
const isInvalid = computed(
|
|
42
42
|
() => {
|
|
43
43
|
if (isStartInvalid.value || isEndInvalid.value)
|
|
44
|
-
return
|
|
44
|
+
return true
|
|
45
45
|
if (props.start.value && props.end.value && isBefore(props.end.value, props.start.value))
|
|
46
46
|
return true
|
|
47
47
|
return false
|
|
@@ -71,12 +71,10 @@ export function useRangeCalendarState(props: UseRangeCalendarProps) {
|
|
|
71
71
|
return false
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
// Check if a date exceeds maximum days limit from the start date
|
|
75
74
|
const rangeIsDateDisabled = (date: DateValue) => {
|
|
76
75
|
if (props.isDateDisabled(date))
|
|
77
76
|
return true
|
|
78
77
|
|
|
79
|
-
// Check if exceeds maximum days limit
|
|
80
78
|
if (props.maximumDays?.value) {
|
|
81
79
|
if (props.start.value && props.end.value) {
|
|
82
80
|
if (props.fixedDate.value) {
|
|
@@ -97,9 +95,6 @@ export function useRangeCalendarState(props: UseRangeCalendarProps) {
|
|
|
97
95
|
}
|
|
98
96
|
}
|
|
99
97
|
|
|
100
|
-
if (!props.start.value || props.end.value || isSameDay(props.start.value, date))
|
|
101
|
-
return false
|
|
102
|
-
|
|
103
98
|
return false
|
|
104
99
|
}
|
|
105
100
|
|
|
@@ -126,17 +121,17 @@ export function useRangeCalendarState(props: UseRangeCalendarProps) {
|
|
|
126
121
|
}
|
|
127
122
|
}
|
|
128
123
|
|
|
129
|
-
// If maximum days is set and the range exceeds it, limit the highlight
|
|
130
|
-
// We only apply this when we're in the middle of a selection (no end date yet)
|
|
131
124
|
if (props.maximumDays?.value && !props.end.value) {
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
? start.add({ days: props.maximumDays.value - 1 })
|
|
135
|
-
: start.subtract({ days: props.maximumDays.value })
|
|
125
|
+
const maximumDays = props.maximumDays.value
|
|
126
|
+
const anchor = props.start.value
|
|
136
127
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
end:
|
|
128
|
+
if (isStartBeforeFocused) {
|
|
129
|
+
const maxEnd = anchor.add({ days: maximumDays - 1 })
|
|
130
|
+
return { start: anchor, end: maxEnd }
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
const minStart = anchor.subtract({ days: maximumDays - 1 })
|
|
134
|
+
return { start: minStart, end: anchor }
|
|
140
135
|
}
|
|
141
136
|
}
|
|
142
137
|
|
|
@@ -162,6 +157,36 @@ export function useRangeCalendarState(props: UseRangeCalendarProps) {
|
|
|
162
157
|
return isSameDay(highlightedRange.value.end, date)
|
|
163
158
|
}
|
|
164
159
|
|
|
160
|
+
const hasSelectedDate = computed(() => {
|
|
161
|
+
return !!(props.start.value || props.end.value)
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
const isStartDateDisabled = computed(() => {
|
|
165
|
+
return !!(props.start.value && props.isDateDisabled(props.start.value))
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
const isEndDateDisabled = computed(() => {
|
|
169
|
+
return !!(props.end.value && props.isDateDisabled(props.end.value))
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
const isSelectedDisabled = computed(() => {
|
|
173
|
+
const hasStart = !!props.start.value
|
|
174
|
+
const hasEnd = !!props.end.value
|
|
175
|
+
if (!hasStart && !hasEnd)
|
|
176
|
+
return false
|
|
177
|
+
if (hasStart && hasEnd)
|
|
178
|
+
return isStartDateDisabled.value && isEndDateDisabled.value
|
|
179
|
+
return (hasStart && isStartDateDisabled.value) || (hasEnd && isEndDateDisabled.value)
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
const selectedFocusableDate = computed(() => {
|
|
183
|
+
if (props.start.value && !isStartDateDisabled.value)
|
|
184
|
+
return props.start.value
|
|
185
|
+
if (props.end.value && !isEndDateDisabled.value)
|
|
186
|
+
return props.end.value
|
|
187
|
+
return undefined
|
|
188
|
+
})
|
|
189
|
+
|
|
165
190
|
return {
|
|
166
191
|
isInvalid,
|
|
167
192
|
isSelected,
|
|
@@ -172,5 +197,8 @@ export function useRangeCalendarState(props: UseRangeCalendarProps) {
|
|
|
172
197
|
isHighlightedStart,
|
|
173
198
|
isHighlightedEnd,
|
|
174
199
|
isDateDisabled: rangeIsDateDisabled,
|
|
200
|
+
hasSelectedDate,
|
|
201
|
+
isSelectedDisabled,
|
|
202
|
+
selectedFocusableDate,
|
|
175
203
|
}
|
|
176
204
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComputedRef } from 'vue'
|
|
3
|
+
import type { PrimitiveProps } from '@/Primitive'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
import { Primitive } from '@/Primitive'
|
|
6
|
+
import { createContext } from '@/shared'
|
|
7
|
+
import { injectRatingRootContext } from './RatingRoot.vue'
|
|
8
|
+
|
|
9
|
+
interface RatingItemContext {
|
|
10
|
+
steps: ComputedRef<number[]>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface RatingItemProps extends PrimitiveProps {
|
|
14
|
+
item: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const [injectRatingItemContext, provideRatingItemContext]
|
|
18
|
+
= createContext<RatingItemContext>('RatingItem')
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
const props = withDefaults(defineProps<RatingItemProps>(), { as: 'label' })
|
|
23
|
+
defineSlots<{
|
|
24
|
+
default?: (props: {
|
|
25
|
+
steps: number[]
|
|
26
|
+
}) => any
|
|
27
|
+
}>()
|
|
28
|
+
|
|
29
|
+
const rootContext = injectRatingRootContext()
|
|
30
|
+
|
|
31
|
+
const steps = computed(() => {
|
|
32
|
+
const groupStartValue = (props.item - 1)
|
|
33
|
+
const groupEndValue = props.item
|
|
34
|
+
const stepSize = rootContext.step.value
|
|
35
|
+
|
|
36
|
+
const numberOfSteps = Math.ceil((groupEndValue - groupStartValue) / stepSize)
|
|
37
|
+
|
|
38
|
+
return Array.from({ length: numberOfSteps }, (_, index) =>
|
|
39
|
+
Number((groupStartValue + (index + 1) * stepSize).toFixed(2)))
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
provideRatingItemContext({ steps })
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<template>
|
|
46
|
+
<Primitive
|
|
47
|
+
:as="as"
|
|
48
|
+
:as-child="asChild"
|
|
49
|
+
>
|
|
50
|
+
<slot :steps="steps" />
|
|
51
|
+
</Primitive>
|
|
52
|
+
</template>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { PrimitiveProps } from '@/Primitive'
|
|
3
|
+
import { useActiveElement } from '@vueuse/core'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
import { RadioGroupIndicator, RadioGroupItem } from '@/RadioGroup'
|
|
6
|
+
import { useForwardExpose } from '@/shared'
|
|
7
|
+
import { injectRatingItemContext } from './RatingItem.vue'
|
|
8
|
+
import { injectRatingRootContext } from './RatingRoot.vue'
|
|
9
|
+
|
|
10
|
+
export interface RatingItemProps extends PrimitiveProps {
|
|
11
|
+
step: number
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
const props = defineProps<RatingItemProps>()
|
|
17
|
+
|
|
18
|
+
const rootContext = injectRatingRootContext()
|
|
19
|
+
const { currentElement, forwardRef } = useForwardExpose()
|
|
20
|
+
const activeElement = useActiveElement()
|
|
21
|
+
const itemContext = injectRatingItemContext()
|
|
22
|
+
|
|
23
|
+
const isActive = computed(() => {
|
|
24
|
+
return (rootContext.hoveredRating.value > 0 && props.step <= rootContext.hoveredRating.value) || (rootContext.hoveredRating.value === 0 && props.step <= rootContext.modelValue.value)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const isVisible = computed(() => {
|
|
28
|
+
return activeElement.value === currentElement.value || rootContext.step.value === 1 || props.step % 1 === 0 || props.step === rootContext.hoveredRating.value || props.step === rootContext.modelValue.value
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
function handleMouseEnter() {
|
|
32
|
+
rootContext.changeHoveredRating(props.step)
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<template>
|
|
37
|
+
<RadioGroupItem
|
|
38
|
+
:ref="forwardRef"
|
|
39
|
+
:as="as"
|
|
40
|
+
:as-child="asChild"
|
|
41
|
+
:style="{
|
|
42
|
+
['--reka-rating-item-step-width']: `${((step % 1 || 1) * 100)}%`,
|
|
43
|
+
['--reka-rating-item-step-opacity']: isVisible ? 1 : 0,
|
|
44
|
+
['--reka-rating-item-step-z-index']: itemContext.steps.value.length - itemContext.steps.value.indexOf(step),
|
|
45
|
+
|
|
46
|
+
}"
|
|
47
|
+
:value="step"
|
|
48
|
+
:data-state="isActive ? 'active' : undefined"
|
|
49
|
+
:disabled="rootContext.disabled.value"
|
|
50
|
+
@select="rootContext.changeModelValue(step)"
|
|
51
|
+
@mouseenter="handleMouseEnter"
|
|
52
|
+
>
|
|
53
|
+
<RadioGroupIndicator
|
|
54
|
+
force-mount
|
|
55
|
+
as-child
|
|
56
|
+
>
|
|
57
|
+
<slot />
|
|
58
|
+
</RadioGroupIndicator>
|
|
59
|
+
</RadioGroupItem>
|
|
60
|
+
</template>
|