akar 1.15.0 → 1.18.0
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/avatar-image.js +4 -2
- package/dist/avatar/avatar-image.js.map +1 -1
- package/dist/calendar/calendar-root.js +6 -5
- package/dist/calendar/calendar-root.js.map +1 -1
- package/dist/collection/collection.js +6 -2
- package/dist/collection/collection.js.map +1 -1
- package/dist/combobox/combobox-content-impl.js +48 -34
- package/dist/combobox/combobox-content-impl.js.map +1 -1
- package/dist/combobox/combobox-content.js +4 -0
- package/dist/combobox/combobox-content.js.map +1 -1
- package/dist/context-menu/context-menu-content.js +4 -0
- package/dist/context-menu/context-menu-content.js.map +1 -1
- package/dist/context-menu/context-menu-radio-group.js +1 -1
- package/dist/context-menu/context-menu-radio-item.js +1 -1
- package/dist/context-menu/context-menu-sub-content.js +4 -0
- package/dist/context-menu/context-menu-sub-content.js.map +1 -1
- package/dist/date/calendar.date.js +25 -11
- package/dist/date/calendar.date.js.map +1 -1
- package/dist/date/comparators.date.js +10 -2
- package/dist/date/comparators.date.js.map +1 -1
- package/dist/date/parser.js +1 -0
- package/dist/date/parser.js.map +1 -1
- package/dist/date/use-date-field.js +59 -20
- package/dist/date/use-date-field.js.map +1 -1
- package/dist/date-picker/date-picker-content.js +4 -0
- package/dist/date-picker/date-picker-content.js.map +1 -1
- package/dist/date-picker/date-picker-root.js +10 -8
- package/dist/date-picker/date-picker-root.js.map +1 -1
- package/dist/date-range-picker/date-range-picker-content.js +4 -0
- package/dist/date-range-picker/date-range-picker-content.js.map +1 -1
- package/dist/date-range-picker/date-range-picker-root.js +11 -9
- package/dist/date-range-picker/date-range-picker-root.js.map +1 -1
- package/dist/date.d.ts +2 -2
- package/dist/date.js +2 -2
- package/dist/dialog/dialog-content.js.map +1 -1
- package/dist/dropdown-menu/dropdown-menu-content.js +4 -0
- package/dist/dropdown-menu/dropdown-menu-content.js.map +1 -1
- package/dist/dropdown-menu/dropdown-menu-radio-group.js +1 -1
- package/dist/dropdown-menu/dropdown-menu-radio-item.js +1 -1
- package/dist/dropdown-menu/dropdown-menu-sub-content.js +4 -0
- package/dist/dropdown-menu/dropdown-menu-sub-content.js.map +1 -1
- package/dist/editable/editable-input.js +1 -1
- package/dist/editable/editable-input.js.map +1 -1
- package/dist/focus-scope/focus-scope.js +2 -2
- package/dist/focus-scope/focus-scope.js.map +1 -1
- package/dist/focus-scope/stack.js +1 -4
- package/dist/focus-scope/stack.js.map +1 -1
- package/dist/hover-card/hover-card-content-impl.js +4 -0
- package/dist/hover-card/hover-card-content-impl.js.map +1 -1
- package/dist/hover-card/hover-card-content.js +4 -0
- package/dist/hover-card/hover-card-content.js.map +1 -1
- package/dist/index.d.ts +1185 -1376
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index2.d.ts +9 -2
- package/dist/index2.d.ts.map +1 -1
- package/dist/menu/menu-content-impl.js +4 -0
- package/dist/menu/menu-content-impl.js.map +1 -1
- package/dist/menu/menu-content.js +4 -0
- package/dist/menu/menu-content.js.map +1 -1
- package/dist/menu/menu-radio-group.js +1 -1
- package/dist/menu/menu-radio-group.js.map +1 -1
- package/dist/menu/menu-radio-item.js +1 -1
- package/dist/menu/menu-radio-item.js.map +1 -1
- package/dist/menu/menu-root-content-modal.js +4 -0
- package/dist/menu/menu-root-content-modal.js.map +1 -1
- package/dist/menu/menu-root-content-non-modal.js +4 -0
- package/dist/menu/menu-root-content-non-modal.js.map +1 -1
- package/dist/menu/menu-sub-content.js +4 -0
- package/dist/menu/menu-sub-content.js.map +1 -1
- package/dist/navigation-menu/navigation-menu-content-impl.js +1 -1
- package/dist/navigation-menu/navigation-menu-content.js +1 -1
- package/dist/navigation-menu/navigation-menu-item.js +1 -1
- package/dist/navigation-menu/navigation-menu-root.js +8 -6
- package/dist/navigation-menu/navigation-menu-root.js.map +1 -1
- package/dist/navigation-menu/navigation-menu-trigger.js +1 -1
- package/dist/navigation-menu/navigation-menu-viewport.js +1 -1
- package/dist/number-field/number-field-root.js +6 -1
- package/dist/number-field/number-field-root.js.map +1 -1
- package/dist/pin-input/pin-input-input.js +17 -11
- package/dist/pin-input/pin-input-input.js.map +1 -1
- package/dist/popover/popover-content-impl.js +4 -0
- package/dist/popover/popover-content-impl.js.map +1 -1
- package/dist/popover/popover-content-modal.js +4 -0
- package/dist/popover/popover-content-modal.js.map +1 -1
- package/dist/popover/popover-content-non-modal.js +4 -0
- package/dist/popover/popover-content-non-modal.js.map +1 -1
- package/dist/popover/popover-content.js +4 -0
- package/dist/popover/popover-content.js.map +1 -1
- package/dist/popper/popper-content.js +10 -2
- package/dist/popper/popper-content.js.map +1 -1
- package/dist/range-calendar/range-calendar-root.js +6 -5
- package/dist/range-calendar/range-calendar-root.js.map +1 -1
- package/dist/scroll-area/scroll-area-root.js.map +1 -1
- package/dist/scroll-area/scroll-area-scrollbar-auto.js +1 -1
- package/dist/scroll-area/scroll-area-scrollbar-glimpse.js +126 -0
- package/dist/scroll-area/scroll-area-scrollbar-glimpse.js.map +1 -0
- package/dist/scroll-area/scroll-area-scrollbar-impl.js +1 -1
- package/dist/scroll-area/scroll-area-scrollbar-scroll.js +1 -1
- package/dist/scroll-area/scroll-area-scrollbar-visible.js +1 -1
- package/dist/scroll-area/scroll-area-scrollbar.js +11 -4
- package/dist/scroll-area/scroll-area-scrollbar.js.map +1 -1
- package/dist/select/select-content-impl.js +4 -0
- package/dist/select/select-content-impl.js.map +1 -1
- package/dist/select/select-content.js +4 -0
- package/dist/select/select-content.js.map +1 -1
- package/dist/select/select-popper-position.js +4 -0
- package/dist/select/select-popper-position.js.map +1 -1
- package/dist/shared/use-date-formatter.js +1 -1
- package/dist/shared/use-date-formatter.js.map +1 -1
- package/dist/shared/use-grace-area.js +1 -1
- package/dist/shared/use-grace-area.js.map +1 -1
- package/dist/tabs/tabs-content.js +5 -1
- package/dist/tabs/tabs-content.js.map +1 -1
- package/dist/tabs/tabs-root.js +12 -2
- package/dist/tabs/tabs-root.js.map +1 -1
- package/dist/tabs/tabs-trigger.js +1 -1
- package/dist/tabs/tabs-trigger.js.map +1 -1
- package/dist/time-field/time-field-input.js +3 -1
- package/dist/time-field/time-field-input.js.map +1 -1
- package/dist/time-field/time-field-root.js +26 -2
- package/dist/time-field/time-field-root.js.map +1 -1
- package/package.json +17 -16
- package/src/avatar/avatar-image.vue +1 -0
- package/src/calendar/calendar-root.vue +12 -11
- package/src/calendar/use-calendar.ts +2 -2
- package/src/collection/collection.ts +3 -2
- package/src/combobox/combobox-content-impl.vue +47 -32
- package/src/combobox/combobox-root.vue +1 -1
- package/src/date/calendar.date.ts +42 -17
- package/src/date/comparators.date.ts +11 -3
- package/src/date-picker/date-picker-anchor.vue +2 -2
- package/src/date-picker/date-picker-arrow.vue +2 -2
- package/src/date-picker/date-picker-close.vue +2 -2
- package/src/date-picker/date-picker-root.vue +11 -11
- package/src/date-picker/index.ts +71 -27
- package/src/date-range-picker/date-range-picker-anchor.vue +2 -2
- package/src/date-range-picker/date-range-picker-arrow.vue +2 -2
- package/src/date-range-picker/date-range-picker-close.vue +2 -2
- package/src/date-range-picker/date-range-picker-root.vue +14 -15
- package/src/date-range-picker/index.ts +4 -0
- package/src/editable/editable-input.vue +7 -1
- package/src/focus-scope/focus-scope.vue +2 -2
- package/src/index.ts +2 -0
- package/src/listbox/listbox-filter.vue +1 -1
- package/src/listbox/listbox-root.vue +1 -1
- package/src/menu/menu-radio-group.vue +5 -4
- package/src/menu/menu-radio-item.vue +2 -1
- package/src/navigation-menu/navigation-menu-item.vue +1 -1
- package/src/navigation-menu/navigation-menu-root.vue +14 -6
- package/src/number-field/number-field-root.vue +15 -7
- package/src/pin-input/pin-input-input.vue +26 -19
- package/src/popper/popper-content.vue +15 -5
- package/src/range-calendar/range-calendar-root.vue +14 -14
- package/src/scroll-area/index.ts +4 -0
- package/src/scroll-area/scroll-area-root.vue +1 -0
- package/src/scroll-area/scroll-area-scrollbar-glimpse.vue +145 -0
- package/src/scroll-area/scroll-area-scrollbar.vue +9 -0
- package/src/scroll-area/types.ts +1 -1
- package/src/shared/date/parser.ts +9 -0
- package/src/shared/date/use-date-field.ts +104 -21
- package/src/shared/index.ts +1 -1
- package/src/shared/use-date-formatter.ts +2 -1
- package/src/shared/use-grace-area.ts +1 -1
- package/src/tabs/tabs-content.vue +7 -1
- package/src/tabs/tabs-root.vue +14 -1
- package/src/tabs/tabs-trigger.vue +5 -2
- package/src/time-field/time-field-input.vue +7 -2
- package/src/time-field/time-field-root.vue +42 -3
- package/src/tree/tree-root.vue +2 -2
|
@@ -20,6 +20,7 @@ export const APopperContentPropsDefaultValue = {
|
|
|
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 APopperContentProps extends APrimitiveProps {
|
|
|
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 APopperContentProps extends APrimitiveProps {
|
|
|
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
|
|
@@ -347,9 +356,10 @@ watchPostEffect(() => {
|
|
|
347
356
|
}
|
|
348
357
|
});
|
|
349
358
|
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
359
|
+
const shouldHideArrow = computed(() => {
|
|
360
|
+
const cannotCenterArrow = middlewareData.value.arrow?.centerOffset !== 0;
|
|
361
|
+
return props.hideShiftedArrow && cannotCenterArrow;
|
|
362
|
+
});
|
|
353
363
|
|
|
354
364
|
const contentZIndex = ref('');
|
|
355
365
|
watchEffect(() => {
|
|
@@ -368,7 +378,7 @@ providePopperContentContext({
|
|
|
368
378
|
},
|
|
369
379
|
arrowX,
|
|
370
380
|
arrowY,
|
|
371
|
-
shouldHideArrow
|
|
381
|
+
shouldHideArrow,
|
|
372
382
|
});
|
|
373
383
|
</script>
|
|
374
384
|
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { DateValue } from '@internationalized/date';
|
|
3
3
|
import type { Ref } from 'vue';
|
|
4
|
-
import type { DateGrid, DateMatcher, WeekDayFormat } from '../date';
|
|
4
|
+
import type { DateGrid, DateMatcher, WeekDayFormat, WeekStartsOn } from '../date';
|
|
5
5
|
import type { APrimitiveProps } from '../primitive';
|
|
6
6
|
import type { UseDateFormatter } from '../shared';
|
|
7
7
|
import type { DateRange } from '../shared/date';
|
|
8
8
|
import type { Direction } from '../shared/types';
|
|
9
|
-
import {
|
|
10
|
-
import { KEY_CODES } from '@vinicunca/perkakas';
|
|
11
|
-
import { useCalendar } from '../calendar/use-calendar';
|
|
12
|
-
import { isDateBefore } from '../date';
|
|
13
|
-
import { createContext, useDirection, useLocale } from '../shared';
|
|
14
|
-
import { getDefaultDate, handleCalendarInitialFocus } from '../shared/date';
|
|
15
|
-
import { useRangeCalendarState } from './use-range-calendar';
|
|
9
|
+
import { createContext } from '../shared';
|
|
16
10
|
|
|
17
11
|
type RangeCalendarRootContext = {
|
|
18
12
|
modelValue: Ref<DateRange>;
|
|
@@ -24,7 +18,7 @@ type RangeCalendarRootContext = {
|
|
|
24
18
|
preventDeselect: Ref<boolean>;
|
|
25
19
|
grid: Ref<Array<DateGrid<DateValue>>>;
|
|
26
20
|
weekDays: Ref<Array<string>>;
|
|
27
|
-
weekStartsOn: Ref<
|
|
21
|
+
weekStartsOn: Ref<WeekStartsOn>;
|
|
28
22
|
weekdayFormat: Ref<WeekDayFormat>;
|
|
29
23
|
fixedWeeks: Ref<boolean>;
|
|
30
24
|
numberOfMonths: Ref<number>;
|
|
@@ -84,7 +78,7 @@ export interface ARangeCalendarRootProps extends APrimitiveProps {
|
|
|
84
78
|
/** The maximum number of days that can be selected in a range */
|
|
85
79
|
maximumDays?: number;
|
|
86
80
|
/** The day of the week to start the calendar on */
|
|
87
|
-
weekStartsOn?:
|
|
81
|
+
weekStartsOn?: WeekStartsOn;
|
|
88
82
|
/** The format to use for the weekday strings provided via the weekdays slot prop */
|
|
89
83
|
weekdayFormat?: WeekDayFormat;
|
|
90
84
|
/** The accessible label for the calendar */
|
|
@@ -141,9 +135,16 @@ export const [
|
|
|
141
135
|
</script>
|
|
142
136
|
|
|
143
137
|
<script setup lang="ts">
|
|
138
|
+
import { isEqualDay } from '@internationalized/date';
|
|
139
|
+
import { KEY_CODES } from '@vinicunca/perkakas';
|
|
144
140
|
import { useEventListener, useVModel } from '@vueuse/core';
|
|
145
|
-
import { onMounted, ref, toRefs, watch } from 'vue';
|
|
141
|
+
import { computed, onMounted, ref, toRefs, watch } from 'vue';
|
|
142
|
+
import { useCalendar } from '../calendar/use-calendar';
|
|
143
|
+
import { getWeekStartsOn, isDateBefore } from '../date';
|
|
146
144
|
import { APrimitive, usePrimitiveElement } from '../primitive';
|
|
145
|
+
import { useDirection, useLocale } from '../shared';
|
|
146
|
+
import { getDefaultDate, handleCalendarInitialFocus } from '../shared/date';
|
|
147
|
+
import { useRangeCalendarState } from './use-range-calendar';
|
|
147
148
|
|
|
148
149
|
const props = withDefaults(
|
|
149
150
|
defineProps<ARangeCalendarRootProps>(),
|
|
@@ -152,7 +153,6 @@ const props = withDefaults(
|
|
|
152
153
|
as: 'div',
|
|
153
154
|
pagedNavigation: false,
|
|
154
155
|
preventDeselect: false,
|
|
155
|
-
weekStartsOn: 0,
|
|
156
156
|
weekdayFormat: 'narrow',
|
|
157
157
|
fixedWeeks: false,
|
|
158
158
|
numberOfMonths: 1,
|
|
@@ -179,7 +179,7 @@ defineSlots<{
|
|
|
179
179
|
/** The days of the week */
|
|
180
180
|
weekDays: Array<string>;
|
|
181
181
|
/** The start of the week */
|
|
182
|
-
weekStartsOn:
|
|
182
|
+
weekStartsOn: WeekStartsOn;
|
|
183
183
|
/** The calendar locale */
|
|
184
184
|
locale: string;
|
|
185
185
|
/** Whether or not to always display 6 weeks in the calendar */
|
|
@@ -194,7 +194,6 @@ const {
|
|
|
194
194
|
readonly,
|
|
195
195
|
initialFocus,
|
|
196
196
|
pagedNavigation,
|
|
197
|
-
weekStartsOn,
|
|
198
197
|
weekdayFormat,
|
|
199
198
|
fixedWeeks,
|
|
200
199
|
numberOfMonths,
|
|
@@ -221,6 +220,7 @@ const {
|
|
|
221
220
|
} = usePrimitiveElement();
|
|
222
221
|
const dir = useDirection(propDir);
|
|
223
222
|
const locale = useLocale(propLocale);
|
|
223
|
+
const weekStartsOn = computed(() => props.weekStartsOn ?? getWeekStartsOn(locale.value));
|
|
224
224
|
|
|
225
225
|
const lastPressedDateValue = ref() as Ref<DateValue | undefined>;
|
|
226
226
|
const focusedValue = ref() as Ref<DateValue | undefined>;
|
package/src/scroll-area/index.ts
CHANGED
|
@@ -7,6 +7,10 @@ export {
|
|
|
7
7
|
type AScrollAreaRootProps,
|
|
8
8
|
injectAScrollAreaRootContext,
|
|
9
9
|
} from './scroll-area-root.vue';
|
|
10
|
+
export {
|
|
11
|
+
default as AScrollAreaScrollbarGlimpse,
|
|
12
|
+
type AScrollAreaScrollbarGlimpseProps,
|
|
13
|
+
} from './scroll-area-scrollbar-glimpse.vue';
|
|
10
14
|
export {
|
|
11
15
|
default as AScrollAreaScrollbar,
|
|
12
16
|
type AScrollAreaScrollbarProps,
|
|
@@ -36,6 +36,7 @@ export interface AScrollAreaRootProps extends APrimitiveProps {
|
|
|
36
36
|
* `always` - means that scrollbars are always visible regardless of whether the content is overflowing.<br>
|
|
37
37
|
* `scroll` - means that scrollbars are visible when the user is scrolling along its corresponding orientation.<br>
|
|
38
38
|
* `hover` - when the user is scrolling along its corresponding orientation and when the user is hovering over the scroll area.
|
|
39
|
+
* `glimpse` - a hybrid approach that briefly shows scrollbars when the user enters the scroll area, then hides them until further interaction.
|
|
39
40
|
*/
|
|
40
41
|
type?: ScrollType;
|
|
41
42
|
/** The reading direction of the combobox when applicable. <br> If omitted, inherits globally from `AConfigProvider` or assumes LTR (left-to-right) reading mode. */
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ScrollAreaScrollbarAutoProps } from './scroll-area-scrollbar-auto.vue';
|
|
3
|
+
|
|
4
|
+
export interface AScrollAreaScrollbarGlimpseProps extends ScrollAreaScrollbarAutoProps {}
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { useDebounceFn } from '@vueuse/core';
|
|
9
|
+
import { computed, onMounted, onUnmounted, watchEffect } from 'vue';
|
|
10
|
+
import { APresence } from '../presence';
|
|
11
|
+
import { useForwardExpose } from '../shared';
|
|
12
|
+
import { useStateMachine } from '../shared/use-state-machine';
|
|
13
|
+
import { injectAScrollAreaRootContext } from './scroll-area-root.vue';
|
|
14
|
+
import ScrollAreaScrollbarAuto from './scroll-area-scrollbar-auto.vue';
|
|
15
|
+
import { injectAScrollAreaScrollbarContext } from './scroll-area-scrollbar.vue';
|
|
16
|
+
|
|
17
|
+
defineOptions({
|
|
18
|
+
inheritAttrs: false,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
defineProps<AScrollAreaScrollbarGlimpseProps>();
|
|
22
|
+
|
|
23
|
+
const rootContext = injectAScrollAreaRootContext();
|
|
24
|
+
const scrollbarContext = injectAScrollAreaScrollbarContext();
|
|
25
|
+
|
|
26
|
+
const { forwardRef } = useForwardExpose();
|
|
27
|
+
|
|
28
|
+
const { state, dispatch } = useStateMachine('hidden', {
|
|
29
|
+
hidden: {
|
|
30
|
+
POINTER_ENTER: 'glimpse',
|
|
31
|
+
SCROLL: 'scrolling',
|
|
32
|
+
},
|
|
33
|
+
glimpse: {
|
|
34
|
+
HIDE: 'hidden',
|
|
35
|
+
POINTER_LEAVE: 'hidden',
|
|
36
|
+
SCROLL: 'scrolling',
|
|
37
|
+
POINTER_ENTER: 'glimpse',
|
|
38
|
+
},
|
|
39
|
+
scrolling: {
|
|
40
|
+
SCROLL_END: 'idle',
|
|
41
|
+
POINTER_ENTER: 'interacting',
|
|
42
|
+
},
|
|
43
|
+
interacting: {
|
|
44
|
+
SCROLL: 'interacting',
|
|
45
|
+
POINTER_LEAVE: 'idle',
|
|
46
|
+
},
|
|
47
|
+
idle: {
|
|
48
|
+
HIDE: 'hidden',
|
|
49
|
+
SCROLL: 'scrolling',
|
|
50
|
+
POINTER_ENTER: 'interacting',
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const visible = computed(() => state.value !== 'hidden');
|
|
55
|
+
|
|
56
|
+
function handlePointerEnter() {
|
|
57
|
+
dispatch('POINTER_ENTER');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function handlePointerLeave() {
|
|
61
|
+
dispatch('POINTER_LEAVE');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const debounceScrollEnd = useDebounceFn(() => dispatch('SCROLL_END'), 100);
|
|
65
|
+
|
|
66
|
+
watchEffect((onCleanup) => {
|
|
67
|
+
if (state.value === 'glimpse') {
|
|
68
|
+
const timeId = window.setTimeout(
|
|
69
|
+
() => dispatch('HIDE'),
|
|
70
|
+
rootContext.scrollHideDelay.value,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
onCleanup(() => {
|
|
74
|
+
window.clearTimeout(timeId);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
watchEffect((onCleanup) => {
|
|
80
|
+
if (state.value === 'idle') {
|
|
81
|
+
const timeId = window.setTimeout(
|
|
82
|
+
() => dispatch('HIDE'),
|
|
83
|
+
rootContext.scrollHideDelay.value,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
onCleanup(() => {
|
|
87
|
+
window.clearTimeout(timeId);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
watchEffect((onCleanup) => {
|
|
93
|
+
const viewport = rootContext.viewport.value;
|
|
94
|
+
const scrollDirection = scrollbarContext.isHorizontal.value
|
|
95
|
+
? 'scrollLeft'
|
|
96
|
+
: 'scrollTop';
|
|
97
|
+
|
|
98
|
+
if (viewport) {
|
|
99
|
+
let prevScrollPos = viewport[scrollDirection];
|
|
100
|
+
const handleScroll = () => {
|
|
101
|
+
const scrollPos = viewport[scrollDirection];
|
|
102
|
+
const hasScrollInDirectionChanged = prevScrollPos !== scrollPos;
|
|
103
|
+
if (hasScrollInDirectionChanged) {
|
|
104
|
+
dispatch('SCROLL');
|
|
105
|
+
debounceScrollEnd();
|
|
106
|
+
}
|
|
107
|
+
prevScrollPos = scrollPos;
|
|
108
|
+
};
|
|
109
|
+
viewport.addEventListener('scroll', handleScroll);
|
|
110
|
+
|
|
111
|
+
onCleanup(() => {
|
|
112
|
+
viewport.removeEventListener('scroll', handleScroll);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
onMounted(() => {
|
|
118
|
+
const scrollArea = rootContext.scrollArea.value;
|
|
119
|
+
|
|
120
|
+
if (scrollArea) {
|
|
121
|
+
scrollArea.addEventListener('pointerenter', handlePointerEnter);
|
|
122
|
+
scrollArea.addEventListener('pointerleave', handlePointerLeave);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
onUnmounted(() => {
|
|
127
|
+
const scrollArea = rootContext.scrollArea.value;
|
|
128
|
+
if (scrollArea) {
|
|
129
|
+
scrollArea.removeEventListener('pointerenter', handlePointerEnter);
|
|
130
|
+
scrollArea.removeEventListener('pointerleave', handlePointerLeave);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<template>
|
|
136
|
+
<APresence :present="forceMount || visible">
|
|
137
|
+
<ScrollAreaScrollbarAuto
|
|
138
|
+
v-bind="$attrs"
|
|
139
|
+
:ref="forwardRef"
|
|
140
|
+
:data-state="visible ? 'visible' : 'hidden'"
|
|
141
|
+
>
|
|
142
|
+
<slot />
|
|
143
|
+
</ScrollAreaScrollbarAuto>
|
|
144
|
+
</APresence>
|
|
145
|
+
</template>
|
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
} from 'vue';
|
|
37
37
|
import { injectAScrollAreaRootContext } from './scroll-area-root.vue';
|
|
38
38
|
import ScrollAreaScrollbarAuto from './scroll-area-scrollbar-auto.vue';
|
|
39
|
+
import ScrollAreaScrollbarGlimpse from './scroll-area-scrollbar-glimpse.vue';
|
|
39
40
|
import ScrollAreaScrollbarHover from './scroll-area-scrollbar-hover.vue';
|
|
40
41
|
import ScrollAreaScrollbarScroll from './scroll-area-scrollbar-scroll.vue';
|
|
41
42
|
import ScrollAreaScrollbarVisible from './scroll-area-scrollbar-visible.vue';
|
|
@@ -98,6 +99,14 @@ provideScrollAreaScrollbarContext({
|
|
|
98
99
|
>
|
|
99
100
|
<slot />
|
|
100
101
|
</ScrollAreaScrollbarScroll>
|
|
102
|
+
<ScrollAreaScrollbarGlimpse
|
|
103
|
+
v-else-if="rootContext.type.value === 'glimpse'"
|
|
104
|
+
v-bind="$attrs"
|
|
105
|
+
:ref="forwardRef"
|
|
106
|
+
:force-mount="forceMount"
|
|
107
|
+
>
|
|
108
|
+
<slot />
|
|
109
|
+
</ScrollAreaScrollbarGlimpse>
|
|
101
110
|
<ScrollAreaScrollbarAuto
|
|
102
111
|
v-else-if="rootContext.type.value === 'auto'"
|
|
103
112
|
v-bind="$attrs"
|
package/src/scroll-area/types.ts
CHANGED
|
@@ -248,6 +248,15 @@ function createContentArr(props: CreateContentArrProps) {
|
|
|
248
248
|
return false;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
// In some locales (e.g., zh-TW), the time zone is represented with square brackets.
|
|
252
|
+
// We also filter out these literals that are just brackets.
|
|
253
|
+
if (
|
|
254
|
+
(!isZonedDateTime(props.dateRef) || hideTimeZone)
|
|
255
|
+
&& segment.part === 'literal' && ['[', ']'].includes(segment.value.trim())
|
|
256
|
+
) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
|
|
251
260
|
return true;
|
|
252
261
|
});
|
|
253
262
|
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import type { CalendarDateTime,
|
|
1
|
+
import type { CalendarDateTime, DateFields, DateValue, TimeFields } from '@internationalized/date';
|
|
2
2
|
import type { Ref } from 'vue';
|
|
3
3
|
import type { UseDateFormatter } from '../../shared';
|
|
4
4
|
import type { AnyExceptLiteral, DateStep, HourCycle, SegmentPart, SegmentValueObj } from './types';
|
|
5
|
+
import {
|
|
6
|
+
DateFormatter,
|
|
7
|
+
} from '@internationalized/date';
|
|
5
8
|
import { isIncludedIn, KEY_CODES } from '@vinicunca/perkakas';
|
|
6
9
|
import { computed } from 'vue';
|
|
7
10
|
import { getDaysInMonth, toDate } from '../../date';
|
|
11
|
+
import { snapValueToStep } from '../../shared';
|
|
8
12
|
import { isAcceptableSegmentKey, isNumberString, isSegmentNavigationKey } from './segment';
|
|
9
13
|
|
|
10
14
|
interface MinuteSecondIncrementProps {
|
|
@@ -19,7 +23,6 @@ interface DateTimeValueIncrementation {
|
|
|
19
23
|
part: keyof Omit<DateFields, 'era'> | keyof TimeFields;
|
|
20
24
|
dateRef: DateValue;
|
|
21
25
|
prevValue: null | number;
|
|
22
|
-
hourCycle?: HourCycle;
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
interface SegmentAttrProps {
|
|
@@ -299,6 +302,7 @@ export interface UseDateFieldProps {
|
|
|
299
302
|
placeholder: Ref<DateValue>;
|
|
300
303
|
hourCycle: HourCycle;
|
|
301
304
|
step: Ref<DateStep>;
|
|
305
|
+
stepSnapping?: Ref<boolean>;
|
|
302
306
|
formatter: UseDateFormatter;
|
|
303
307
|
segmentValues: Ref<SegmentValueObj>;
|
|
304
308
|
disabled: Ref<boolean>;
|
|
@@ -339,7 +343,7 @@ export function useDateField(props: UseDateFieldProps) {
|
|
|
339
343
|
return Number.parseInt(str.slice(0, -1));
|
|
340
344
|
}
|
|
341
345
|
|
|
342
|
-
function dateTimeValueIncrementation({ event, part, dateRef, prevValue
|
|
346
|
+
function dateTimeValueIncrementation({ event, part, dateRef, prevValue }: DateTimeValueIncrementation): number {
|
|
343
347
|
const step = props.step.value[part] ?? 1;
|
|
344
348
|
const sign = event.key === KEY_CODES.ARROW_UP ? step : -step;
|
|
345
349
|
|
|
@@ -348,7 +352,9 @@ export function useDateField(props: UseDateFieldProps) {
|
|
|
348
352
|
}
|
|
349
353
|
|
|
350
354
|
if (part === 'hour' && 'hour' in dateRef) {
|
|
351
|
-
|
|
355
|
+
// Don't pass hourCycle to cycle - internal representation is always 24-hour
|
|
356
|
+
// The hourCycle prop only affects display, not internal cycling
|
|
357
|
+
const cycleArgs: [keyof DateFields | keyof TimeFields, number] = [part, sign];
|
|
352
358
|
return dateRef.set({ [part as keyof DateValue]: prevValue }).cycle(...cycleArgs)[part];
|
|
353
359
|
}
|
|
354
360
|
|
|
@@ -528,8 +534,7 @@ export function useDateField(props: UseDateFieldProps) {
|
|
|
528
534
|
return { value: total, moveToNext };
|
|
529
535
|
}
|
|
530
536
|
|
|
531
|
-
function updateHour(num: number, prev: null | number) {
|
|
532
|
-
const max = 24;
|
|
537
|
+
function updateHour(max: number, num: number, prev: null | number) {
|
|
533
538
|
let moveToNext = false;
|
|
534
539
|
const maxStart = Math.floor(max / 10);
|
|
535
540
|
|
|
@@ -744,6 +749,11 @@ export function useDateField(props: UseDateFieldProps) {
|
|
|
744
749
|
}
|
|
745
750
|
}
|
|
746
751
|
|
|
752
|
+
function uses12HourFormat(locale: string): boolean {
|
|
753
|
+
const hourCycle = new DateFormatter(locale, { hour: 'numeric' }).resolvedOptions().hourCycle;
|
|
754
|
+
return hourCycle === 'h11' || hourCycle === 'h12';
|
|
755
|
+
}
|
|
756
|
+
|
|
747
757
|
function handleHourSegmentKeydown(event: KeyboardEvent) {
|
|
748
758
|
const dateRef = props.placeholder.value;
|
|
749
759
|
if (!isAcceptableSegmentKey(event.key) || isSegmentNavigationKey(event.key) || !('hour' in dateRef) || !('hour' in props.segmentValues.value)) {
|
|
@@ -752,17 +762,14 @@ export function useDateField(props: UseDateFieldProps) {
|
|
|
752
762
|
|
|
753
763
|
const prevValue = props.segmentValues.value.hour;
|
|
754
764
|
|
|
755
|
-
const hourCycle = props.hourCycle;
|
|
756
|
-
|
|
757
765
|
if (event.key === KEY_CODES.ARROW_UP || event.key === KEY_CODES.ARROW_DOWN) {
|
|
758
|
-
|
|
766
|
+
const newHour = dateTimeValueIncrementation({ event, part: 'hour', dateRef: props.placeholder.value, prevValue });
|
|
767
|
+
props.segmentValues.value.hour = newHour;
|
|
759
768
|
|
|
760
|
-
if ('dayPeriod' in props.segmentValues.value) {
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
props.segmentValues.value.dayPeriod = 'PM';
|
|
765
|
-
}
|
|
769
|
+
if ('dayPeriod' in props.segmentValues.value && newHour !== null) {
|
|
770
|
+
// Determine AM/PM based on internal 24-hour value
|
|
771
|
+
// Hour 0-11 = AM, Hour 12-23 = PM
|
|
772
|
+
props.segmentValues.value.dayPeriod = newHour >= 12 ? 'PM' : 'AM';
|
|
766
773
|
}
|
|
767
774
|
|
|
768
775
|
return;
|
|
@@ -770,15 +777,32 @@ export function useDateField(props: UseDateFieldProps) {
|
|
|
770
777
|
|
|
771
778
|
if (isNumberString(event.key)) {
|
|
772
779
|
const num = Number.parseInt(event.key);
|
|
773
|
-
const
|
|
780
|
+
const is12Hour = uses12HourFormat(props.formatter.getLocale());
|
|
781
|
+
const max = is12Hour ? 12 : 24;
|
|
782
|
+
|
|
783
|
+
let displayPrev = prevValue;
|
|
784
|
+
if (is12Hour && prevValue !== null) {
|
|
785
|
+
if (prevValue === 0) {
|
|
786
|
+
displayPrev = 12;
|
|
787
|
+
} else if (prevValue > 12) {
|
|
788
|
+
displayPrev = prevValue - 12;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
774
791
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
792
|
+
const { value, moveToNext } = updateHour(max, num, displayPrev);
|
|
793
|
+
|
|
794
|
+
// Convert display hour back to internal 24-hour format
|
|
795
|
+
let internalValue = value;
|
|
796
|
+
if (is12Hour && value !== null) {
|
|
797
|
+
const period = props.segmentValues.value.dayPeriod || 'AM';
|
|
798
|
+
if (value === 12) {
|
|
799
|
+
internalValue = period === 'AM' ? 0 : 12;
|
|
800
|
+
} else {
|
|
801
|
+
internalValue = period === 'PM' ? value + 12 : value;
|
|
802
|
+
}
|
|
779
803
|
}
|
|
780
804
|
|
|
781
|
-
props.segmentValues.value.hour =
|
|
805
|
+
props.segmentValues.value.hour = internalValue;
|
|
782
806
|
|
|
783
807
|
if (moveToNext) {
|
|
784
808
|
props.focusNext();
|
|
@@ -935,9 +959,68 @@ export function useDateField(props: UseDateFieldProps) {
|
|
|
935
959
|
}
|
|
936
960
|
}
|
|
937
961
|
|
|
962
|
+
function handleSegmentFocusOut() {
|
|
963
|
+
if (!props.stepSnapping?.value) {
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
if (
|
|
968
|
+
props.part === 'hour'
|
|
969
|
+
&& 'hour' in props.segmentValues.value
|
|
970
|
+
&& props.segmentValues.value.hour !== null
|
|
971
|
+
&& props.step.value.hour
|
|
972
|
+
&& props.step.value.hour > 1
|
|
973
|
+
) {
|
|
974
|
+
props.segmentValues.value.hour = snapValueToStep({
|
|
975
|
+
value: props.segmentValues.value.hour,
|
|
976
|
+
min: 0,
|
|
977
|
+
max: 23,
|
|
978
|
+
step: props.step.value.hour,
|
|
979
|
+
});
|
|
980
|
+
|
|
981
|
+
if ('dayPeriod' in props.segmentValues.value) {
|
|
982
|
+
if (props.segmentValues.value.hour < 12) {
|
|
983
|
+
props.segmentValues.value.dayPeriod = 'AM';
|
|
984
|
+
} else if (props.segmentValues.value.hour) {
|
|
985
|
+
props.segmentValues.value.dayPeriod = 'PM';
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
} else if (
|
|
989
|
+
props.part === 'minute'
|
|
990
|
+
&& 'minute' in props.segmentValues.value
|
|
991
|
+
&& props.segmentValues.value.minute !== null
|
|
992
|
+
&& props.step.value.minute
|
|
993
|
+
&& props.step.value.minute > 1) {
|
|
994
|
+
props.segmentValues.value.minute = snapValueToStep({
|
|
995
|
+
value: props.segmentValues.value.minute,
|
|
996
|
+
min: 0,
|
|
997
|
+
max: 59,
|
|
998
|
+
step: props.step.value.minute,
|
|
999
|
+
});
|
|
1000
|
+
} else if (
|
|
1001
|
+
props.part === 'second'
|
|
1002
|
+
&& 'second' in props.segmentValues.value
|
|
1003
|
+
&& props.segmentValues.value.second !== null
|
|
1004
|
+
&& props.step.value.second
|
|
1005
|
+
&& props.step.value.second > 1) {
|
|
1006
|
+
props.segmentValues.value.second = snapValueToStep({
|
|
1007
|
+
value: props.segmentValues.value.second,
|
|
1008
|
+
min: 0,
|
|
1009
|
+
max: 59,
|
|
1010
|
+
step: props.step.value.second,
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
if (Object.values(props.segmentValues.value).every((item) => item !== null)) {
|
|
1015
|
+
const dateRef = props.placeholder.value.set({ ...props.segmentValues.value as Record<AnyExceptLiteral, number> });
|
|
1016
|
+
props.modelValue.value = dateRef.copy();
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
|
|
938
1020
|
return {
|
|
939
1021
|
handleSegmentClick,
|
|
940
1022
|
handleSegmentKeydown,
|
|
1023
|
+
handleSegmentFocusOut,
|
|
941
1024
|
attributes,
|
|
942
1025
|
};
|
|
943
1026
|
}
|
package/src/shared/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './arrays';
|
|
2
2
|
export { createContext } from './create-context';
|
|
3
|
-
export { type DateRange, type DateStep, type DateValue, type SegmentPart } from './date';
|
|
3
|
+
export { type DateRange, type DateStep, type DateValue, type SegmentPart, type TimeValue } from './date';
|
|
4
4
|
export { getActiveElement } from './get-active-element';
|
|
5
5
|
export { handleAndDispatchCustomEvent } from './handle-and-dispatch-custom-event';
|
|
6
6
|
export { isValueEqualOrExist } from './is-value-equal-or-exist';
|
|
@@ -132,7 +132,8 @@ export function useDateFormatter(initialLocale: string): UseDateFormatter {
|
|
|
132
132
|
|
|
133
133
|
const value = parts.find((p) => p.type === 'dayPeriod')?.value;
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
// Day period can be "AM"/"PM" or "am"/"pm" or "a.m."/"p.m." in some locales
|
|
136
|
+
if (value === 'PM' || value === 'pm' || value === 'p.m.') {
|
|
136
137
|
return 'PM';
|
|
137
138
|
}
|
|
138
139
|
|
|
@@ -38,7 +38,7 @@ export function useGraceArea(
|
|
|
38
38
|
point: exitPoint,
|
|
39
39
|
rect: currentTarget.getBoundingClientRect(),
|
|
40
40
|
});
|
|
41
|
-
const paddedExitPoints = getPaddedExitPoints(exitPoint, exitSide);
|
|
41
|
+
const paddedExitPoints = getPaddedExitPoints(exitPoint, exitSide, 1);
|
|
42
42
|
const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());
|
|
43
43
|
const graceArea = getHull([...paddedExitPoints, ...hoverTargetPoints]);
|
|
44
44
|
pointerGraceArea.value = graceArea;
|
|
@@ -15,7 +15,7 @@ export interface ATabsContentProps extends APrimitiveProps {
|
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
17
|
<script setup lang="ts">
|
|
18
|
-
import { computed, onMounted, ref } from 'vue';
|
|
18
|
+
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
|
19
19
|
import { APresence } from '../presence';
|
|
20
20
|
import { APrimitive } from '../primitive';
|
|
21
21
|
import { injectATabsRootContext } from './tabs-root.vue';
|
|
@@ -33,10 +33,16 @@ const isSelected = computed(() => props.value === rootContext.modelValue.value);
|
|
|
33
33
|
const isMountAnimationPreventedRef = ref(isSelected.value);
|
|
34
34
|
|
|
35
35
|
onMounted(() => {
|
|
36
|
+
rootContext.registerContent(props.value);
|
|
37
|
+
|
|
36
38
|
requestAnimationFrame(() => {
|
|
37
39
|
isMountAnimationPreventedRef.value = false;
|
|
38
40
|
});
|
|
39
41
|
});
|
|
42
|
+
|
|
43
|
+
onBeforeUnmount(() => {
|
|
44
|
+
rootContext.unregisterContent(props.value);
|
|
45
|
+
});
|
|
40
46
|
</script>
|
|
41
47
|
|
|
42
48
|
<template>
|
package/src/tabs/tabs-root.vue
CHANGED
|
@@ -14,6 +14,9 @@ export interface TabsRootContext {
|
|
|
14
14
|
activationMode: 'automatic' | 'manual';
|
|
15
15
|
baseId: string;
|
|
16
16
|
tabsList: Ref<HTMLElement | undefined>;
|
|
17
|
+
contentIds: Ref<Set<StringOrNumber>>;
|
|
18
|
+
registerContent: (value: StringOrNumber) => void;
|
|
19
|
+
unregisterContent: (value: StringOrNumber) => void;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
export interface ATabsRootProps<T extends StringOrNumber = StringOrNumber> extends APrimitiveProps {
|
|
@@ -55,7 +58,7 @@ export const [injectATabsRootContext, provideTabsRootContext]
|
|
|
55
58
|
</script>
|
|
56
59
|
|
|
57
60
|
<script setup lang="ts" generic="T extends StringOrNumber = StringOrNumber">
|
|
58
|
-
import { ref, toRefs } from 'vue';
|
|
61
|
+
import { ref, shallowRef, toRefs } from 'vue';
|
|
59
62
|
import { APrimitive } from '../primitive';
|
|
60
63
|
|
|
61
64
|
const props = withDefaults(defineProps<ATabsRootProps<T>>(), {
|
|
@@ -82,6 +85,7 @@ const modelValue = useVModel<ATabsRootProps<T>, 'modelValue', 'update:modelValue
|
|
|
82
85
|
});
|
|
83
86
|
|
|
84
87
|
const tabsList = ref<HTMLElement>();
|
|
88
|
+
const contentIds = shallowRef<Set<StringOrNumber>>(new Set());
|
|
85
89
|
|
|
86
90
|
provideTabsRootContext({
|
|
87
91
|
modelValue,
|
|
@@ -94,6 +98,15 @@ provideTabsRootContext({
|
|
|
94
98
|
activationMode: props.activationMode,
|
|
95
99
|
baseId: useId(undefined, 'akar-tabs'),
|
|
96
100
|
tabsList,
|
|
101
|
+
contentIds,
|
|
102
|
+
registerContent: (value: StringOrNumber) => {
|
|
103
|
+
contentIds.value = new Set([...contentIds.value, value]);
|
|
104
|
+
},
|
|
105
|
+
unregisterContent: (value: StringOrNumber) => {
|
|
106
|
+
const newSet = new Set(contentIds.value);
|
|
107
|
+
newSet.delete(value);
|
|
108
|
+
contentIds.value = newSet;
|
|
109
|
+
},
|
|
97
110
|
});
|
|
98
111
|
</script>
|
|
99
112
|
|
|
@@ -27,8 +27,11 @@ const { forwardRef } = useForwardExpose();
|
|
|
27
27
|
const rootContext = injectATabsRootContext();
|
|
28
28
|
|
|
29
29
|
const triggerId = computed(() => makeTriggerId(rootContext.baseId, props.value));
|
|
30
|
-
const contentId = computed(() =>
|
|
31
|
-
|
|
30
|
+
const contentId = computed(() =>
|
|
31
|
+
rootContext.contentIds.value.has(props.value)
|
|
32
|
+
? makeContentId(rootContext.baseId, props.value)
|
|
33
|
+
: undefined,
|
|
34
|
+
);
|
|
32
35
|
const isSelected = computed(() => props.value === rootContext.modelValue.value);
|
|
33
36
|
|
|
34
37
|
function handleMouseDown(event: MouseEvent) {
|