reka-ui 2.4.1 → 2.5.1
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/Calendar/CalendarCellTrigger.cjs +14 -0
- package/dist/Calendar/CalendarCellTrigger.cjs.map +1 -1
- package/dist/Calendar/CalendarCellTrigger.js +15 -1
- package/dist/Calendar/CalendarCellTrigger.js.map +1 -1
- package/dist/Calendar/CalendarRoot.cjs +3 -1
- package/dist/Calendar/CalendarRoot.cjs.map +1 -1
- package/dist/Calendar/CalendarRoot.js +3 -1
- package/dist/Calendar/CalendarRoot.js.map +1 -1
- package/dist/Combobox/ComboboxInput.cjs +1 -1
- package/dist/Combobox/ComboboxInput.cjs.map +1 -1
- package/dist/Combobox/ComboboxInput.js +1 -1
- package/dist/Combobox/ComboboxInput.js.map +1 -1
- package/dist/ContextMenu/ContextMenuRoot.cjs +8 -2
- package/dist/ContextMenu/ContextMenuRoot.cjs.map +1 -1
- package/dist/ContextMenu/ContextMenuRoot.js +8 -2
- package/dist/ContextMenu/ContextMenuRoot.js.map +1 -1
- package/dist/ContextMenu/ContextMenuTrigger.cjs +1 -1
- package/dist/ContextMenu/ContextMenuTrigger.cjs.map +1 -1
- package/dist/ContextMenu/ContextMenuTrigger.js +1 -1
- package/dist/ContextMenu/ContextMenuTrigger.js.map +1 -1
- package/dist/DatePicker/DatePickerRoot.cjs +9 -2
- package/dist/DatePicker/DatePickerRoot.cjs.map +1 -1
- package/dist/DatePicker/DatePickerRoot.js +9 -2
- package/dist/DatePicker/DatePickerRoot.js.map +1 -1
- package/dist/DateRangePicker/DateRangePickerRoot.cjs +11 -2
- package/dist/DateRangePicker/DateRangePickerRoot.cjs.map +1 -1
- package/dist/DateRangePicker/DateRangePickerRoot.js +11 -2
- package/dist/DateRangePicker/DateRangePickerRoot.js.map +1 -1
- package/dist/Listbox/ListboxContent.cjs +4 -2
- package/dist/Listbox/ListboxContent.cjs.map +1 -1
- package/dist/Listbox/ListboxContent.js +4 -2
- package/dist/Listbox/ListboxContent.js.map +1 -1
- package/dist/Menu/MenuCheckboxItem.cjs +4 -1
- package/dist/Menu/MenuCheckboxItem.cjs.map +1 -1
- package/dist/Menu/MenuCheckboxItem.js +5 -2
- package/dist/Menu/MenuCheckboxItem.js.map +1 -1
- package/dist/Menu/MenuRadioGroup.cjs +4 -1
- package/dist/Menu/MenuRadioGroup.cjs.map +1 -1
- package/dist/Menu/MenuRadioGroup.js +5 -2
- package/dist/Menu/MenuRadioGroup.js.map +1 -1
- package/dist/Menu/MenuRadioItem.cjs +5 -1
- package/dist/Menu/MenuRadioItem.cjs.map +1 -1
- package/dist/Menu/MenuRadioItem.js +5 -1
- package/dist/Menu/MenuRadioItem.js.map +1 -1
- package/dist/NavigationMenu/NavigationMenuViewport.cjs +7 -8
- package/dist/NavigationMenu/NavigationMenuViewport.cjs.map +1 -1
- package/dist/NavigationMenu/NavigationMenuViewport.js +8 -9
- package/dist/NavigationMenu/NavigationMenuViewport.js.map +1 -1
- package/dist/Presence/usePresence.cjs +1 -1
- package/dist/Presence/usePresence.cjs.map +1 -1
- package/dist/Presence/usePresence.js +1 -1
- package/dist/Presence/usePresence.js.map +1 -1
- package/dist/RangeCalendar/RangeCalendarCellTrigger.cjs +22 -5
- package/dist/RangeCalendar/RangeCalendarCellTrigger.cjs.map +1 -1
- package/dist/RangeCalendar/RangeCalendarCellTrigger.js +24 -7
- package/dist/RangeCalendar/RangeCalendarCellTrigger.js.map +1 -1
- package/dist/RangeCalendar/RangeCalendarNext.cjs +7 -3
- package/dist/RangeCalendar/RangeCalendarNext.cjs.map +1 -1
- package/dist/RangeCalendar/RangeCalendarNext.js +8 -4
- package/dist/RangeCalendar/RangeCalendarNext.js.map +1 -1
- package/dist/RangeCalendar/RangeCalendarPrev.cjs +7 -3
- package/dist/RangeCalendar/RangeCalendarPrev.cjs.map +1 -1
- package/dist/RangeCalendar/RangeCalendarPrev.js +8 -4
- package/dist/RangeCalendar/RangeCalendarPrev.js.map +1 -1
- package/dist/RangeCalendar/RangeCalendarRoot.cjs +28 -16
- package/dist/RangeCalendar/RangeCalendarRoot.cjs.map +1 -1
- package/dist/RangeCalendar/RangeCalendarRoot.js +29 -17
- package/dist/RangeCalendar/RangeCalendarRoot.js.map +1 -1
- package/dist/RovingFocus/RovingFocusGroup.cjs +2 -0
- package/dist/RovingFocus/RovingFocusGroup.cjs.map +1 -1
- package/dist/RovingFocus/RovingFocusGroup.js +2 -0
- package/dist/RovingFocus/RovingFocusGroup.js.map +1 -1
- package/dist/Select/SelectContentImpl.cjs +3 -1
- package/dist/Select/SelectContentImpl.cjs.map +1 -1
- package/dist/Select/SelectContentImpl.js +3 -1
- package/dist/Select/SelectContentImpl.js.map +1 -1
- package/dist/Select/SelectRoot.cjs +12 -2
- package/dist/Select/SelectRoot.cjs.map +1 -1
- package/dist/Select/SelectRoot.js +13 -3
- package/dist/Select/SelectRoot.js.map +1 -1
- package/dist/Splitter/SplitterPanel.cjs +4 -5
- package/dist/Splitter/SplitterPanel.cjs.map +1 -1
- package/dist/Splitter/SplitterPanel.js +4 -5
- package/dist/Splitter/SplitterPanel.js.map +1 -1
- package/dist/TagsInput/TagsInputInput.cjs +4 -0
- package/dist/TagsInput/TagsInputInput.cjs.map +1 -1
- package/dist/TagsInput/TagsInputInput.js +4 -0
- package/dist/TagsInput/TagsInputInput.js.map +1 -1
- package/dist/ToggleGroup/ToggleGroupItem.cjs +3 -4
- package/dist/ToggleGroup/ToggleGroupItem.cjs.map +1 -1
- package/dist/ToggleGroup/ToggleGroupItem.js +3 -4
- package/dist/ToggleGroup/ToggleGroupItem.js.map +1 -1
- package/dist/VisuallyHidden/VisuallyHidden.cjs +3 -1
- package/dist/VisuallyHidden/VisuallyHidden.cjs.map +1 -1
- package/dist/VisuallyHidden/VisuallyHidden.js +3 -1
- package/dist/VisuallyHidden/VisuallyHidden.js.map +1 -1
- package/dist/constant.d.cts.map +1 -1
- package/dist/index.d.cts +831 -801
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +870 -840
- package/dist/index.d.ts.map +1 -1
- 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/package.json +3 -3
- package/src/Calendar/CalendarCellTrigger.vue +19 -1
- package/src/Calendar/CalendarRoot.vue +4 -0
- package/src/Combobox/ComboboxInput.vue +3 -2
- package/src/ContextMenu/ContextMenuRoot.vue +12 -2
- package/src/ContextMenu/ContextMenuTrigger.vue +4 -1
- package/src/DatePicker/DatePickerRoot.vue +11 -1
- package/src/DateRangePicker/DateRangePickerRoot.vue +14 -1
- package/src/Listbox/ListboxContent.vue +17 -1
- package/src/Menu/MenuCheckboxItem.vue +6 -2
- package/src/Menu/MenuRadioGroup.vue +6 -3
- package/src/Menu/MenuRadioItem.vue +6 -1
- package/src/NavigationMenu/NavigationMenuViewport.vue +10 -8
- package/src/Presence/usePresence.ts +2 -2
- package/src/RadioGroup/index.ts +1 -0
- package/src/RangeCalendar/RangeCalendarCellTrigger.vue +19 -2
- package/src/RangeCalendar/RangeCalendarNext.vue +2 -1
- package/src/RangeCalendar/RangeCalendarPrev.vue +2 -1
- package/src/RangeCalendar/RangeCalendarRoot.vue +36 -23
- package/src/RovingFocus/RovingFocusGroup.vue +2 -1
- package/src/Select/SelectContentImpl.vue +6 -1
- package/src/Select/SelectRoot.vue +20 -3
- package/src/Splitter/SplitterPanel.vue +5 -5
- package/src/TagsInput/TagsInputInput.vue +5 -0
- package/src/ToggleGroup/ToggleGroupItem.vue +1 -2
- package/src/VisuallyHidden/VisuallyHidden.vue +6 -1
- package/src/shared/useDateFormatter.ts +2 -1
|
@@ -11,7 +11,6 @@ import { useCalendar } from '@/Calendar/useCalendar'
|
|
|
11
11
|
import { isBefore } from '@/date'
|
|
12
12
|
import {
|
|
13
13
|
createContext,
|
|
14
|
-
isNullish,
|
|
15
14
|
useDirection,
|
|
16
15
|
useKbd,
|
|
17
16
|
useLocale,
|
|
@@ -67,6 +66,8 @@ type RangeCalendarRootContext = {
|
|
|
67
66
|
disableDaysOutsideCurrentView: Ref<boolean>
|
|
68
67
|
fixedDate: Ref<'start' | 'end' | undefined>
|
|
69
68
|
maximumDays: Ref<number | undefined>
|
|
69
|
+
minValue: Ref<DateValue | undefined>
|
|
70
|
+
maxValue: Ref<DateValue | undefined>
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
export interface RangeCalendarRootProps extends PrimitiveProps {
|
|
@@ -130,6 +131,8 @@ export interface RangeCalendarRootProps extends PrimitiveProps {
|
|
|
130
131
|
export type RangeCalendarRootEmits = {
|
|
131
132
|
/** Event handler called whenever the model value changes */
|
|
132
133
|
'update:modelValue': [date: DateRange]
|
|
134
|
+
/** Event handler called whenever there is a new validModel */
|
|
135
|
+
'update:validModelValue': [date: DateRange]
|
|
133
136
|
/** Event handler called whenever the placeholder value changes */
|
|
134
137
|
'update:placeholder': [date: DateValue]
|
|
135
138
|
/** Event handler called whenever the start value changes */
|
|
@@ -142,7 +145,7 @@ export const [injectRangeCalendarRootContext, provideRangeCalendarRootContext]
|
|
|
142
145
|
|
|
143
146
|
<script setup lang="ts">
|
|
144
147
|
import { useEventListener, useVModel } from '@vueuse/core'
|
|
145
|
-
import {
|
|
148
|
+
import { onMounted, ref, toRefs, watch } from 'vue'
|
|
146
149
|
import { Primitive, usePrimitiveElement } from '@/Primitive'
|
|
147
150
|
|
|
148
151
|
const props = withDefaults(defineProps<RangeCalendarRootProps>(), {
|
|
@@ -226,22 +229,22 @@ const modelValue = useVModel(props, 'modelValue', emits, {
|
|
|
226
229
|
passive: (props.modelValue === undefined) as false,
|
|
227
230
|
}) as Ref<DateRange>
|
|
228
231
|
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
)
|
|
232
|
+
const validModelValue = ref(modelValue.value) as Ref<DateRange>
|
|
233
|
+
|
|
234
|
+
watch(validModelValue, (value) => {
|
|
235
|
+
emits('update:validModelValue', value)
|
|
236
|
+
})
|
|
234
237
|
|
|
235
238
|
const defaultDate = getDefaultDate({
|
|
236
239
|
defaultPlaceholder: props.placeholder,
|
|
237
|
-
defaultValue:
|
|
240
|
+
defaultValue: modelValue.value.start,
|
|
238
241
|
locale: props.locale,
|
|
239
242
|
})
|
|
240
243
|
|
|
241
|
-
const startValue = ref(
|
|
244
|
+
const startValue = ref(modelValue.value.start) as Ref<
|
|
242
245
|
DateValue | undefined
|
|
243
246
|
>
|
|
244
|
-
const endValue = ref(
|
|
247
|
+
const endValue = ref(modelValue.value.end) as Ref<DateValue | undefined>
|
|
245
248
|
|
|
246
249
|
const placeholder = useVModel(props, 'placeholder', emits, {
|
|
247
250
|
defaultValue: props.defaultPlaceholder ?? defaultDate.copy(),
|
|
@@ -333,7 +336,7 @@ watch(startValue, (_startValue) => {
|
|
|
333
336
|
})
|
|
334
337
|
|
|
335
338
|
watch([startValue, endValue], ([_startValue, _endValue]) => {
|
|
336
|
-
const value =
|
|
339
|
+
const value = modelValue.value
|
|
337
340
|
|
|
338
341
|
if (
|
|
339
342
|
value
|
|
@@ -348,16 +351,7 @@ watch([startValue, endValue], ([_startValue, _endValue]) => {
|
|
|
348
351
|
}
|
|
349
352
|
|
|
350
353
|
isEditing.value = true
|
|
351
|
-
if (
|
|
352
|
-
isEditing.value = false
|
|
353
|
-
if (
|
|
354
|
-
value.start
|
|
355
|
-
&& value.end
|
|
356
|
-
&& isEqualDay(value.start, _startValue)
|
|
357
|
-
&& isEqualDay(value.end, _endValue)
|
|
358
|
-
) {
|
|
359
|
-
return
|
|
360
|
-
}
|
|
354
|
+
if (_endValue && _startValue) {
|
|
361
355
|
if (isBefore(_endValue, _startValue)) {
|
|
362
356
|
modelValue.value = {
|
|
363
357
|
start: _endValue.copy(),
|
|
@@ -370,6 +364,23 @@ watch([startValue, endValue], ([_startValue, _endValue]) => {
|
|
|
370
364
|
end: _endValue.copy(),
|
|
371
365
|
}
|
|
372
366
|
}
|
|
367
|
+
|
|
368
|
+
isEditing.value = false
|
|
369
|
+
validModelValue.value = { start: modelValue.value.start?.copy(), end: modelValue.value.end?.copy() }
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
if (_startValue) {
|
|
373
|
+
modelValue.value = {
|
|
374
|
+
start: _startValue.copy(),
|
|
375
|
+
end: undefined,
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
modelValue.value = {
|
|
380
|
+
start: _endValue?.copy(),
|
|
381
|
+
end: undefined,
|
|
382
|
+
}
|
|
383
|
+
}
|
|
373
384
|
}
|
|
374
385
|
})
|
|
375
386
|
|
|
@@ -377,8 +388,8 @@ const kbd = useKbd()
|
|
|
377
388
|
useEventListener('keydown', (ev) => {
|
|
378
389
|
if (ev.key === kbd.ESCAPE && isEditing.value) {
|
|
379
390
|
// Abort start and end selection
|
|
380
|
-
startValue.value =
|
|
381
|
-
endValue.value =
|
|
391
|
+
startValue.value = validModelValue.value.start?.copy()
|
|
392
|
+
endValue.value = validModelValue.value.end?.copy()
|
|
382
393
|
}
|
|
383
394
|
})
|
|
384
395
|
|
|
@@ -426,6 +437,8 @@ provideRangeCalendarRootContext({
|
|
|
426
437
|
disableDaysOutsideCurrentView,
|
|
427
438
|
fixedDate,
|
|
428
439
|
maximumDays,
|
|
440
|
+
minValue,
|
|
441
|
+
maxValue,
|
|
429
442
|
})
|
|
430
443
|
|
|
431
444
|
onMounted(() => {
|
|
@@ -102,10 +102,11 @@ function handleFocus(event: FocusEvent) {
|
|
|
102
102
|
if (!entryFocusEvent.defaultPrevented) {
|
|
103
103
|
const items = getItems().map(i => i.ref).filter(i => i.dataset.disabled !== '')
|
|
104
104
|
const activeItem = items.find(item => item.getAttribute('data-active') === '')
|
|
105
|
+
const highlightedItem = items.find(item => item.getAttribute('data-highlighted') === '')
|
|
105
106
|
const currentItem = items.find(
|
|
106
107
|
item => item.id === currentTabStopId.value,
|
|
107
108
|
)
|
|
108
|
-
const candidateItems = [activeItem, currentItem, ...items].filter(
|
|
109
|
+
const candidateItems = [activeItem, highlightedItem, currentItem, ...items].filter(
|
|
109
110
|
Boolean,
|
|
110
111
|
) as typeof items
|
|
111
112
|
focusFirst(candidateItems, props.preventScrollOnEntryFocus)
|
|
@@ -301,7 +301,12 @@ provideSelectContentContext({
|
|
|
301
301
|
:id="rootContext.contentId"
|
|
302
302
|
:ref="
|
|
303
303
|
(vnode: ComponentPublicInstance) => {
|
|
304
|
-
|
|
304
|
+
const el = unrefElement(vnode) as HTMLElement | undefined
|
|
305
|
+
// special case for PopperContent
|
|
306
|
+
if (el?.hasAttribute('data-reka-popper-content-wrapper'))
|
|
307
|
+
content = el.firstElementChild as HTMLElement
|
|
308
|
+
else
|
|
309
|
+
content = el
|
|
305
310
|
return undefined
|
|
306
311
|
}
|
|
307
312
|
"
|
|
@@ -3,7 +3,7 @@ import type { Ref } from 'vue'
|
|
|
3
3
|
import type { AcceptableValue, Direction, FormFieldProps } from '@/shared/types'
|
|
4
4
|
import { useCollection } from '@/Collection'
|
|
5
5
|
import { createContext, isNullish, useDirection, useFormControl } from '@/shared'
|
|
6
|
-
import { compare } from './utils'
|
|
6
|
+
import { compare, valueComparator } from './utils'
|
|
7
7
|
|
|
8
8
|
export interface SelectRootProps<T = AcceptableValue> extends FormFieldProps {
|
|
9
9
|
/** The controlled open state of the Select. Can be bind as `v-model:open`. */
|
|
@@ -144,6 +144,11 @@ function handleValueChange(value: T) {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
function getOption(value: SelectOption['value']) {
|
|
148
|
+
return Array.from(optionsSet.value)
|
|
149
|
+
.find(option => valueComparator(value, option.value, props.by))
|
|
150
|
+
}
|
|
151
|
+
|
|
147
152
|
provideSelectRootContext({
|
|
148
153
|
triggerElement,
|
|
149
154
|
onTriggerChange: (node) => {
|
|
@@ -171,8 +176,20 @@ provideSelectRootContext({
|
|
|
171
176
|
isEmptyModelValue,
|
|
172
177
|
|
|
173
178
|
optionsSet,
|
|
174
|
-
onOptionAdd: option =>
|
|
175
|
-
|
|
179
|
+
onOptionAdd: (option) => {
|
|
180
|
+
const existingOption = getOption(option.value)
|
|
181
|
+
if (existingOption) {
|
|
182
|
+
optionsSet.value.delete(existingOption)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
optionsSet.value.add(option)
|
|
186
|
+
},
|
|
187
|
+
onOptionRemove: (option) => {
|
|
188
|
+
const existingOption = getOption(option.value)
|
|
189
|
+
if (existingOption) {
|
|
190
|
+
optionsSet.value.delete(existingOption)
|
|
191
|
+
}
|
|
192
|
+
},
|
|
176
193
|
})
|
|
177
194
|
</script>
|
|
178
195
|
|
|
@@ -127,11 +127,11 @@ watch(() => panelDataRef.value.constraints, (constraints, prevConstraints) => {
|
|
|
127
127
|
}, { deep: true })
|
|
128
128
|
|
|
129
129
|
onMounted(() => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
registerPanel(panelDataRef.value)
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
onUnmounted(() => {
|
|
134
|
+
unregisterPanel(panelDataRef.value)
|
|
135
135
|
})
|
|
136
136
|
|
|
137
137
|
const style = computed(() => getPanelStyle(panelDataRef.value, props.defaultSize))
|
|
@@ -86,6 +86,11 @@ function handleInput(event: InputEvent) {
|
|
|
86
86
|
const target = event.target as HTMLInputElement
|
|
87
87
|
target.value = target.value.replace(delimiter, '')
|
|
88
88
|
|
|
89
|
+
if (target.value.trim() === '') {
|
|
90
|
+
target.value = ''
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
|
|
89
94
|
const isAdded = context.onAddValue(target.value)
|
|
90
95
|
if (isAdded)
|
|
91
96
|
target.value = ''
|
|
@@ -33,8 +33,7 @@ const { forwardRef } = useForwardExpose()
|
|
|
33
33
|
<component
|
|
34
34
|
:is="rootContext.rovingFocus.value ? RovingFocusItem : Primitive"
|
|
35
35
|
as-child
|
|
36
|
-
|
|
37
|
-
:active="pressed"
|
|
36
|
+
v-bind="rootContext.rovingFocus.value ? { focusable: !disabled, active: pressed } : {}"
|
|
38
37
|
>
|
|
39
38
|
<Toggle
|
|
40
39
|
v-bind="props"
|
|
@@ -20,7 +20,7 @@ withDefaults(defineProps<VisuallyHiddenProps>(), { as: 'span', feature: 'focusab
|
|
|
20
20
|
:data-hidden="feature === 'fully-hidden' ? '' : undefined"
|
|
21
21
|
:tabindex="feature === 'fully-hidden' ? '-1' : undefined"
|
|
22
22
|
:style="{
|
|
23
|
-
// See: https://github.com/twbs/bootstrap/blob/
|
|
23
|
+
// See: https://github.com/twbs/bootstrap/blob/a360960b8dfdb4bf48f87539c2243458fa0366f7/scss/mixins/_visually-hidden.scss
|
|
24
24
|
position: 'absolute',
|
|
25
25
|
border: 0,
|
|
26
26
|
width: '1px',
|
|
@@ -32,6 +32,11 @@ withDefaults(defineProps<VisuallyHiddenProps>(), { as: 'span', feature: 'focusab
|
|
|
32
32
|
clipPath: 'inset(50%)',
|
|
33
33
|
whiteSpace: 'nowrap',
|
|
34
34
|
wordWrap: 'normal',
|
|
35
|
+
|
|
36
|
+
// Prevent causing unnecessary container scroll
|
|
37
|
+
// @see https://github.com/unovue/reka-ui/issues/2127
|
|
38
|
+
top: '-1px',
|
|
39
|
+
left: '-1px',
|
|
35
40
|
}"
|
|
36
41
|
>
|
|
37
42
|
<slot />
|
|
@@ -105,7 +105,8 @@ export function useDateFormatter(initialLocale: string, opts: DateFormatterOptio
|
|
|
105
105
|
minute: 'numeric',
|
|
106
106
|
}).formatToParts(date)
|
|
107
107
|
const value = parts.find(p => p.type === 'dayPeriod')?.value
|
|
108
|
-
|
|
108
|
+
// Day period can be "AM"/"PM" or "a.m."/"p.m." in some locales
|
|
109
|
+
if (value === 'PM' || value === 'p.m.')
|
|
109
110
|
return 'PM'
|
|
110
111
|
|
|
111
112
|
return 'AM'
|