akar 1.14.0 → 1.16.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.
Files changed (151) hide show
  1. package/dist/avatar/avatar-image.js +4 -2
  2. package/dist/avatar/avatar-image.js.map +1 -1
  3. package/dist/collection/collection.js +6 -2
  4. package/dist/collection/collection.js.map +1 -1
  5. package/dist/combobox/combobox-cancel.js +1 -1
  6. package/dist/combobox/combobox-cancel.js.map +1 -1
  7. package/dist/combobox/combobox-content-impl.js +50 -35
  8. package/dist/combobox/combobox-content-impl.js.map +1 -1
  9. package/dist/combobox/combobox-content.js +4 -0
  10. package/dist/combobox/combobox-content.js.map +1 -1
  11. package/dist/context-menu/context-menu-content.js +4 -0
  12. package/dist/context-menu/context-menu-content.js.map +1 -1
  13. package/dist/context-menu/context-menu-radio-group.js +1 -1
  14. package/dist/context-menu/context-menu-radio-item.js +1 -1
  15. package/dist/context-menu/context-menu-sub-content.js +4 -0
  16. package/dist/context-menu/context-menu-sub-content.js.map +1 -1
  17. package/dist/date/calendar.date.js.map +1 -1
  18. package/dist/date/parser.js +1 -0
  19. package/dist/date/parser.js.map +1 -1
  20. package/dist/date-picker/date-picker-content.js +4 -0
  21. package/dist/date-picker/date-picker-content.js.map +1 -1
  22. package/dist/date-picker/date-picker-root.js +0 -8
  23. package/dist/date-picker/date-picker-root.js.map +1 -1
  24. package/dist/date-range-picker/date-range-picker-content.js +4 -0
  25. package/dist/date-range-picker/date-range-picker-content.js.map +1 -1
  26. package/dist/date-range-picker/date-range-picker-root.js +0 -8
  27. package/dist/date-range-picker/date-range-picker-root.js.map +1 -1
  28. package/dist/dismissable-layer/dismissable-layer.js +4 -3
  29. package/dist/dismissable-layer/dismissable-layer.js.map +1 -1
  30. package/dist/dropdown-menu/dropdown-menu-content.js +4 -0
  31. package/dist/dropdown-menu/dropdown-menu-content.js.map +1 -1
  32. package/dist/dropdown-menu/dropdown-menu-radio-group.js +1 -1
  33. package/dist/dropdown-menu/dropdown-menu-radio-item.js +1 -1
  34. package/dist/dropdown-menu/dropdown-menu-sub-content.js +4 -0
  35. package/dist/dropdown-menu/dropdown-menu-sub-content.js.map +1 -1
  36. package/dist/editable/editable-input.js +1 -1
  37. package/dist/editable/editable-input.js.map +1 -1
  38. package/dist/hover-card/hover-card-content-impl.js +4 -0
  39. package/dist/hover-card/hover-card-content-impl.js.map +1 -1
  40. package/dist/hover-card/hover-card-content.js +4 -0
  41. package/dist/hover-card/hover-card-content.js.map +1 -1
  42. package/dist/index.d.ts +1173 -1361
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +6 -5
  45. package/dist/index2.d.ts.map +1 -1
  46. package/dist/menu/menu-content-impl.js +4 -0
  47. package/dist/menu/menu-content-impl.js.map +1 -1
  48. package/dist/menu/menu-content.js +4 -0
  49. package/dist/menu/menu-content.js.map +1 -1
  50. package/dist/menu/menu-radio-group.js +1 -1
  51. package/dist/menu/menu-radio-group.js.map +1 -1
  52. package/dist/menu/menu-radio-item.js +1 -1
  53. package/dist/menu/menu-radio-item.js.map +1 -1
  54. package/dist/menu/menu-root-content-modal.js +4 -0
  55. package/dist/menu/menu-root-content-modal.js.map +1 -1
  56. package/dist/menu/menu-root-content-non-modal.js +4 -0
  57. package/dist/menu/menu-root-content-non-modal.js.map +1 -1
  58. package/dist/menu/menu-sub-content.js +4 -0
  59. package/dist/menu/menu-sub-content.js.map +1 -1
  60. package/dist/navigation-menu/navigation-menu-content-impl.js +1 -1
  61. package/dist/navigation-menu/navigation-menu-content.js +1 -1
  62. package/dist/navigation-menu/navigation-menu-item.js +1 -1
  63. package/dist/navigation-menu/navigation-menu-root.js +8 -6
  64. package/dist/navigation-menu/navigation-menu-root.js.map +1 -1
  65. package/dist/navigation-menu/navigation-menu-trigger.js +1 -1
  66. package/dist/navigation-menu/navigation-menu-viewport.js +1 -1
  67. package/dist/number-field/number-field-root.js +6 -1
  68. package/dist/number-field/number-field-root.js.map +1 -1
  69. package/dist/pin-input/pin-input-input.js +17 -11
  70. package/dist/pin-input/pin-input-input.js.map +1 -1
  71. package/dist/popover/popover-content-impl.js +4 -0
  72. package/dist/popover/popover-content-impl.js.map +1 -1
  73. package/dist/popover/popover-content-modal.js +4 -0
  74. package/dist/popover/popover-content-modal.js.map +1 -1
  75. package/dist/popover/popover-content-non-modal.js +4 -0
  76. package/dist/popover/popover-content-non-modal.js.map +1 -1
  77. package/dist/popover/popover-content.js +4 -0
  78. package/dist/popover/popover-content.js.map +1 -1
  79. package/dist/popper/popper-content.js +10 -2
  80. package/dist/popper/popper-content.js.map +1 -1
  81. package/dist/range-calendar/range-calendar-root.js +10 -8
  82. package/dist/range-calendar/range-calendar-root.js.map +1 -1
  83. package/dist/scroll-area/scroll-area-root.js.map +1 -1
  84. package/dist/scroll-area/scroll-area-scrollbar-auto.js +1 -1
  85. package/dist/scroll-area/scroll-area-scrollbar-glimpse.js +126 -0
  86. package/dist/scroll-area/scroll-area-scrollbar-glimpse.js.map +1 -0
  87. package/dist/scroll-area/scroll-area-scrollbar-impl.js +1 -1
  88. package/dist/scroll-area/scroll-area-scrollbar-scroll.js +1 -1
  89. package/dist/scroll-area/scroll-area-scrollbar-visible.js +1 -1
  90. package/dist/scroll-area/scroll-area-scrollbar.js +11 -4
  91. package/dist/scroll-area/scroll-area-scrollbar.js.map +1 -1
  92. package/dist/select/select-arrow.js +1 -3
  93. package/dist/select/select-arrow.js.map +1 -1
  94. package/dist/select/select-content-impl.js +4 -0
  95. package/dist/select/select-content-impl.js.map +1 -1
  96. package/dist/select/select-content.js +4 -0
  97. package/dist/select/select-content.js.map +1 -1
  98. package/dist/select/select-popper-position.js +4 -0
  99. package/dist/select/select-popper-position.js.map +1 -1
  100. package/dist/shared/use-date-formatter.js +1 -1
  101. package/dist/shared/use-date-formatter.js.map +1 -1
  102. package/dist/shared/use-forward-expose.js +10 -1
  103. package/dist/shared/use-forward-expose.js.map +1 -1
  104. package/dist/shared/use-grace-area.js +4 -1
  105. package/dist/shared/use-grace-area.js.map +1 -1
  106. package/dist/tabs/tabs-content.js +5 -1
  107. package/dist/tabs/tabs-content.js.map +1 -1
  108. package/dist/tabs/tabs-indicator.js +18 -12
  109. package/dist/tabs/tabs-indicator.js.map +1 -1
  110. package/dist/tabs/tabs-root.js +12 -2
  111. package/dist/tabs/tabs-root.js.map +1 -1
  112. package/dist/tabs/tabs-trigger.js +1 -1
  113. package/dist/tabs/tabs-trigger.js.map +1 -1
  114. package/package.json +13 -13
  115. package/src/avatar/avatar-image.vue +1 -0
  116. package/src/collection/collection.ts +3 -2
  117. package/src/combobox/combobox-cancel.vue +3 -3
  118. package/src/combobox/combobox-content-impl.vue +48 -33
  119. package/src/date/calendar.date.ts +1 -0
  120. package/src/date-picker/date-picker-root.vue +1 -1
  121. package/src/date-range-picker/date-range-picker-anchor.vue +2 -2
  122. package/src/date-range-picker/date-range-picker-arrow.vue +2 -2
  123. package/src/date-range-picker/date-range-picker-close.vue +2 -2
  124. package/src/date-range-picker/date-range-picker-root.vue +4 -4
  125. package/src/date-range-picker/index.ts +4 -0
  126. package/src/dismissable-layer/dismissable-layer.vue +5 -3
  127. package/src/editable/editable-input.vue +7 -1
  128. package/src/index.ts +1 -0
  129. package/src/menu/menu-radio-group.vue +5 -4
  130. package/src/menu/menu-radio-item.vue +2 -1
  131. package/src/navigation-menu/navigation-menu-item.vue +1 -1
  132. package/src/navigation-menu/navigation-menu-root.vue +14 -6
  133. package/src/number-field/number-field-root.vue +15 -7
  134. package/src/pin-input/pin-input-input.vue +26 -19
  135. package/src/popper/popper-content.vue +15 -5
  136. package/src/range-calendar/range-calendar-root.vue +11 -25
  137. package/src/scroll-area/index.ts +4 -0
  138. package/src/scroll-area/scroll-area-root.vue +1 -0
  139. package/src/scroll-area/scroll-area-scrollbar-glimpse.vue +145 -0
  140. package/src/scroll-area/scroll-area-scrollbar.vue +9 -0
  141. package/src/scroll-area/types.ts +1 -1
  142. package/src/select/select-arrow.vue +1 -3
  143. package/src/shared/date/parser.ts +9 -0
  144. package/src/shared/index.ts +1 -1
  145. package/src/shared/use-date-formatter.ts +2 -1
  146. package/src/shared/use-forward-expose.ts +16 -1
  147. package/src/shared/use-grace-area.ts +8 -1
  148. package/src/tabs/tabs-content.vue +7 -1
  149. package/src/tabs/tabs-indicator.vue +29 -13
  150. package/src/tabs/tabs-root.vue +14 -1
  151. package/src/tabs/tabs-trigger.vue +5 -2
@@ -17,6 +17,8 @@ export interface ANumberFieldRootProps extends APrimitiveProps, FormFieldProps {
17
17
  step?: number;
18
18
  /** When `false`, prevents the value from snapping to the nearest increment of the step value */
19
19
  stepSnapping?: boolean;
20
+ /** When `true`, the input will be focused when the value changes. */
21
+ focusOnChange?: boolean;
20
22
  /** Formatting options for the value displayed in the number field. This also affects what characters are allowed to be typed by the user. */
21
23
  formatOptions?: Intl.NumberFormatOptions;
22
24
  /** The locale to use for formatting dates */
@@ -75,12 +77,16 @@ defineOptions({
75
77
  inheritAttrs: false,
76
78
  });
77
79
 
78
- const props = withDefaults(defineProps<ANumberFieldRootProps>(), {
79
- as: 'div',
80
- defaultValue: undefined,
81
- step: 1,
82
- stepSnapping: true,
83
- });
80
+ const props = withDefaults(
81
+ defineProps<ANumberFieldRootProps>(),
82
+ {
83
+ as: 'div',
84
+ defaultValue: undefined,
85
+ step: 1,
86
+ stepSnapping: true,
87
+ focusOnChange: true,
88
+ },
89
+ );
84
90
  const emits = defineEmits<ANumberFieldRootEmits>();
85
91
  const {
86
92
  disabled,
@@ -143,7 +149,9 @@ const isIncreaseDisabled = computed(() => {
143
149
  );
144
150
 
145
151
  function handleChangingValue(type: 'decrease' | 'increase', multiplier = 1) {
146
- inputEl.value?.focus();
152
+ if (props.focusOnChange) {
153
+ inputEl.value?.focus();
154
+ }
147
155
 
148
156
  if (props.disabled || props.readonly) {
149
157
  return;
@@ -61,10 +61,16 @@ function handleInput(event: InputEvent) {
61
61
  }
62
62
  }
63
63
 
64
- function resetPlaceholder() {
65
- const target = currentElement.value as HTMLInputElement;
64
+ function updatePlaceholder() {
66
65
  nextTick(() => {
67
- if (target && !target.value) {
66
+ const target = currentElement.value as HTMLInputElement;
67
+ if (!target) {
68
+ return;
69
+ }
70
+
71
+ if (!target.value && target === getActiveElement()) {
72
+ target.placeholder = '';
73
+ } else {
68
74
  target.placeholder = context.placeholder.value;
69
75
  }
70
76
  });
@@ -117,23 +123,28 @@ function handleDelete(event: KeyboardEvent) {
117
123
  }
118
124
 
119
125
  function handleFocus(event: FocusEvent) {
120
- const target = event.target as HTMLInputElement;
121
- target.setSelectionRange(1, 1);
126
+ // In OTP mode, inputs should be filled one by one without skipping middle inputs
122
127
 
123
- if (!target.value) {
124
- target.placeholder = '';
125
- }
128
+ if (context.otp.value) {
129
+ const firstEmptyIndex = inputElements.value.findIndex((_, idx) => {
130
+ return context.currentModelValue.value[idx] === ''
131
+ || context.currentModelValue.value[idx] === undefined;
132
+ });
126
133
 
127
- // check again after DOM flushes
128
- setTimeout(() => {
129
- if (!target.value) {
130
- target.placeholder = '';
134
+ if (firstEmptyIndex !== -1 && firstEmptyIndex < props.index) {
135
+ inputElements.value[firstEmptyIndex].focus();
136
+ return;
131
137
  }
132
- });
138
+ }
139
+
140
+ const target = event.target as HTMLInputElement;
141
+ target.setSelectionRange(1, 1);
142
+
143
+ updatePlaceholder();
133
144
  }
134
145
 
135
146
  function handleBlur() {
136
- resetPlaceholder();
147
+ updatePlaceholder();
137
148
  }
138
149
 
139
150
  function handlePaste(event: ClipboardEvent) {
@@ -200,11 +211,7 @@ function updateModelValueAt(
200
211
 
201
212
  watch(
202
213
  currentValue,
203
- () => {
204
- if (!currentValue.value) {
205
- resetPlaceholder();
206
- }
207
- },
214
+ updatePlaceholder,
208
215
  );
209
216
 
210
217
  onMounted(() => {
@@ -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 "top"
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 cannotCenterArrow = computed(
351
- () => middlewareData.value.arrow?.centerOffset !== 0,
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: cannotCenterArrow,
381
+ shouldHideArrow,
372
382
  });
373
383
  </script>
374
384
 
@@ -52,10 +52,10 @@ type RangeCalendarRootContext = {
52
52
  prevPage: (prevPageFunc?: (date: DateValue) => DateValue) => void;
53
53
  nextPage: (nextPageFunc?: (date: DateValue) => DateValue) => void;
54
54
  isNextButtonDisabled: (
55
- nextPageFunc?: (date: DateValue) => DateValue
55
+ nextPageFunc?: (date: DateValue) => DateValue,
56
56
  ) => boolean;
57
57
  isPrevButtonDisabled: (
58
- prevPageFunc?: (date: DateValue) => DateValue
58
+ prevPageFunc?: (date: DateValue) => DateValue,
59
59
  ) => boolean;
60
60
  formatter: UseDateFormatter;
61
61
  dir: Ref<Direction>;
@@ -362,32 +362,18 @@ watch(
362
362
  isEditing.value = true;
363
363
 
364
364
  if (_endValue && _startValue) {
365
- if (isDateBefore(_endValue, _startValue)) {
366
- modelValue.value = {
367
- start: _endValue.copy(),
368
- end: _startValue.copy(),
369
- };
370
- } else {
371
- modelValue.value = {
372
- start: _startValue.copy(),
373
- end: _endValue.copy(),
374
- };
375
- }
365
+ const nextValue = isDateBefore(_endValue, _startValue)
366
+ ? { start: _endValue.copy(), end: _startValue.copy() }
367
+ : { start: _startValue.copy(), end: _endValue.copy() };
368
+
369
+ modelValue.value = { start: nextValue.start, end: nextValue.end };
376
370
 
377
371
  isEditing.value = false;
378
- validModelValue.value = { start: modelValue.value.start?.copy(), end: modelValue.value.end?.copy() };
372
+ validModelValue.value = { start: nextValue.start.copy(), end: nextValue.end.copy() };
379
373
  } else {
380
- if (_startValue) {
381
- modelValue.value = {
382
- start: _startValue.copy(),
383
- end: undefined,
384
- };
385
- } else {
386
- modelValue.value = {
387
- start: _endValue?.copy(),
388
- end: undefined,
389
- };
390
- }
374
+ modelValue.value = _startValue
375
+ ? { start: _startValue.copy(), end: undefined }
376
+ : { start: _endValue?.copy(), end: undefined };
391
377
  }
392
378
  },
393
379
  );
@@ -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"
@@ -9,4 +9,4 @@ export interface Sizes {
9
9
  };
10
10
  }
11
11
 
12
- export type ScrollType = 'always' | 'auto' | 'hover' | 'scroll';
12
+ export type ScrollType = 'always' | 'auto' | 'hover' | 'scroll' | 'glimpse';
@@ -7,20 +7,18 @@ export interface ASelectArrowProps extends APopperArrowProps {}
7
7
  <script setup lang="ts">
8
8
  import { APopperArrow } from '../popper';
9
9
  import { injectSelectContentContext, SelectContentDefaultContextValue } from './select-content-impl.vue';
10
- import { injectASelectRootContext } from './select-root.vue';
11
10
 
12
11
  const props = withDefaults(defineProps<ASelectArrowProps>(), {
13
12
  width: 10,
14
13
  height: 5,
15
14
  as: 'svg',
16
15
  });
17
- const rootContext = injectASelectRootContext();
18
16
  const contentContext = injectSelectContentContext(SelectContentDefaultContextValue);
19
17
  </script>
20
18
 
21
19
  <template>
22
20
  <APopperArrow
23
- v-if="rootContext.open.value && contentContext.position === 'popper'"
21
+ v-if="contentContext.position === 'popper'"
24
22
  v-bind="props"
25
23
  >
26
24
  <slot />
@@ -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,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
- if (value === 'PM' || value === 'p.m.') {
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
 
@@ -69,7 +69,22 @@ export function useForwardExpose<T extends ComponentPublicInstance>() {
69
69
  get: () => (ref instanceof Element ? ref : ref.$el),
70
70
  });
71
71
 
72
- instance.exposed = ret;
72
+ // ref not is Element and `useForwardExpose.test.ts > useForwardRef > should forward plain DOM element ref - 2` Passing in `$el`
73
+ if (!(ref instanceof Element) && !Object.hasOwn(ref, '$el')) {
74
+ // Retrieves the `exposed` data that has not been unwrapped by `vue` from `$.exposed`.
75
+ const childExposed = ref.$.exposed;
76
+ const merged = Object.assign({}, ret);
77
+
78
+ for (const key in childExposed) {
79
+ Object.defineProperty(merged, key, {
80
+ enumerable: true,
81
+ configurable: true,
82
+ get: () => childExposed[key],
83
+ });
84
+ }
85
+
86
+ instance.exposed = merged;
87
+ }
73
88
  }
74
89
 
75
90
  return { forwardRef, currentRef, currentElement };
@@ -1,6 +1,6 @@
1
1
  import type { Ref } from 'vue';
2
2
  import type { Side } from '../popper/utils';
3
- import { createEventHook, refAutoReset } from '@vueuse/shared';
3
+ import { createEventHook, refAutoReset, tryOnScopeDispose } from '@vueuse/shared';
4
4
  import { ref, watchEffect } from 'vue';
5
5
 
6
6
  export function useGraceArea(
@@ -13,6 +13,13 @@ export function useGraceArea(
13
13
  // Reset the inTransit state if idle/scrolled.
14
14
  const isPointerInTransit = refAutoReset(false, 300);
15
15
 
16
+ // `refAutoReset` will clear timeout-based resets on scope dispose (e.g., component unmount),
17
+ // thus leaving the state as-is without resetting it.
18
+ // So we need to manually reset it in such cases.
19
+ tryOnScopeDispose(() => {
20
+ isPointerInTransit.value = false;
21
+ });
22
+
16
23
  const pointerGraceArea = ref<null | Polygon>(null);
17
24
  const pointerExit = createEventHook<void>();
18
25
 
@@ -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>
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { APrimitiveProps } from '../primitive';
3
- import { nextTick, ref, watch } from 'vue';
3
+ import { computed, ref, watch, watchPostEffect } from 'vue';
4
4
  import { useForwardExpose } from '../shared';
5
5
  import { injectATabsRootContext } from './tabs-root.vue';
6
6
 
@@ -13,41 +13,57 @@ import { APrimitive } from '../primitive';
13
13
 
14
14
  const props = defineProps<ATabsIndicatorProps>();
15
15
  const context = injectATabsRootContext();
16
+
17
+ defineExpose({
18
+ updateIndicatorStyle,
19
+ });
20
+
16
21
  useForwardExpose();
17
22
 
18
23
  interface IndicatorStyle {
19
24
  size: null | number;
20
25
  position: null | number;
21
26
  }
22
- const activeTab = ref<HTMLElement | null>();
27
+
23
28
  const indicatorStyle = ref<IndicatorStyle>({
24
29
  size: null,
25
30
  position: null,
26
31
  });
32
+ const tabs = ref<Array<HTMLElement>>([]);
33
+
34
+ watch(
35
+ () => [context.modelValue.value, context?.dir.value],
36
+ async () => {
37
+ updateIndicatorStyle();
38
+ },
39
+ { immediate: true, flush: 'post' },
40
+ );
27
41
 
28
- watch(() => [context.modelValue.value, context?.dir.value], async () => {
29
- await nextTick();
30
- updateIndicatorStyle();
31
- }, { immediate: true });
42
+ watchPostEffect(() => {
43
+ tabs.value = Array.from(context.tabsList.value?.querySelectorAll<HTMLElement>('[role="tab"]') || []);
44
+ });
32
45
 
33
- useResizeObserver([context.tabsList, activeTab], updateIndicatorStyle);
46
+ useResizeObserver(
47
+ computed(() => [context.tabsList.value, ...tabs.value]),
48
+ updateIndicatorStyle,
49
+ );
34
50
 
35
51
  function updateIndicatorStyle() {
36
- activeTab.value = context.tabsList.value?.querySelector<HTMLButtonElement>('[role="tab"][data-state="active"]');
52
+ const activeTab = context.tabsList.value?.querySelector<HTMLButtonElement>('[role="tab"][data-state="active"]');
37
53
 
38
- if (!activeTab.value) {
54
+ if (!activeTab) {
39
55
  return;
40
56
  }
41
57
 
42
58
  if (context.orientation.value === 'horizontal') {
43
59
  indicatorStyle.value = {
44
- size: activeTab.value.offsetWidth,
45
- position: activeTab.value.offsetLeft,
60
+ size: activeTab.offsetWidth,
61
+ position: activeTab.offsetLeft,
46
62
  };
47
63
  } else {
48
64
  indicatorStyle.value = {
49
- size: activeTab.value.offsetHeight,
50
- position: activeTab.value.offsetTop,
65
+ size: activeTab.offsetHeight,
66
+ position: activeTab.offsetTop,
51
67
  };
52
68
  }
53
69
  }
@@ -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