akar 1.15.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 (125) 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-content-impl.js +47 -34
  6. package/dist/combobox/combobox-content-impl.js.map +1 -1
  7. package/dist/combobox/combobox-content.js +4 -0
  8. package/dist/combobox/combobox-content.js.map +1 -1
  9. package/dist/context-menu/context-menu-content.js +4 -0
  10. package/dist/context-menu/context-menu-content.js.map +1 -1
  11. package/dist/context-menu/context-menu-radio-group.js +1 -1
  12. package/dist/context-menu/context-menu-radio-item.js +1 -1
  13. package/dist/context-menu/context-menu-sub-content.js +4 -0
  14. package/dist/context-menu/context-menu-sub-content.js.map +1 -1
  15. package/dist/date/calendar.date.js.map +1 -1
  16. package/dist/date/parser.js +1 -0
  17. package/dist/date/parser.js.map +1 -1
  18. package/dist/date-picker/date-picker-content.js +4 -0
  19. package/dist/date-picker/date-picker-content.js.map +1 -1
  20. package/dist/date-range-picker/date-range-picker-content.js +4 -0
  21. package/dist/date-range-picker/date-range-picker-content.js.map +1 -1
  22. package/dist/dialog/dialog-content.js.map +1 -1
  23. package/dist/dropdown-menu/dropdown-menu-content.js +4 -0
  24. package/dist/dropdown-menu/dropdown-menu-content.js.map +1 -1
  25. package/dist/dropdown-menu/dropdown-menu-radio-group.js +1 -1
  26. package/dist/dropdown-menu/dropdown-menu-radio-item.js +1 -1
  27. package/dist/dropdown-menu/dropdown-menu-sub-content.js +4 -0
  28. package/dist/dropdown-menu/dropdown-menu-sub-content.js.map +1 -1
  29. package/dist/editable/editable-input.js +1 -1
  30. package/dist/editable/editable-input.js.map +1 -1
  31. package/dist/hover-card/hover-card-content-impl.js +4 -0
  32. package/dist/hover-card/hover-card-content-impl.js.map +1 -1
  33. package/dist/hover-card/hover-card-content.js +4 -0
  34. package/dist/hover-card/hover-card-content.js.map +1 -1
  35. package/dist/index.d.ts +712 -902
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +6 -5
  38. package/dist/index2.d.ts.map +1 -1
  39. package/dist/menu/menu-content-impl.js +4 -0
  40. package/dist/menu/menu-content-impl.js.map +1 -1
  41. package/dist/menu/menu-content.js +4 -0
  42. package/dist/menu/menu-content.js.map +1 -1
  43. package/dist/menu/menu-radio-group.js +1 -1
  44. package/dist/menu/menu-radio-group.js.map +1 -1
  45. package/dist/menu/menu-radio-item.js +1 -1
  46. package/dist/menu/menu-radio-item.js.map +1 -1
  47. package/dist/menu/menu-root-content-modal.js +4 -0
  48. package/dist/menu/menu-root-content-modal.js.map +1 -1
  49. package/dist/menu/menu-root-content-non-modal.js +4 -0
  50. package/dist/menu/menu-root-content-non-modal.js.map +1 -1
  51. package/dist/menu/menu-sub-content.js +4 -0
  52. package/dist/menu/menu-sub-content.js.map +1 -1
  53. package/dist/navigation-menu/navigation-menu-content-impl.js +1 -1
  54. package/dist/navigation-menu/navigation-menu-content.js +1 -1
  55. package/dist/navigation-menu/navigation-menu-item.js +1 -1
  56. package/dist/navigation-menu/navigation-menu-root.js +8 -6
  57. package/dist/navigation-menu/navigation-menu-root.js.map +1 -1
  58. package/dist/navigation-menu/navigation-menu-trigger.js +1 -1
  59. package/dist/navigation-menu/navigation-menu-viewport.js +1 -1
  60. package/dist/number-field/number-field-root.js +6 -1
  61. package/dist/number-field/number-field-root.js.map +1 -1
  62. package/dist/pin-input/pin-input-input.js +17 -11
  63. package/dist/pin-input/pin-input-input.js.map +1 -1
  64. package/dist/popover/popover-content-impl.js +4 -0
  65. package/dist/popover/popover-content-impl.js.map +1 -1
  66. package/dist/popover/popover-content-modal.js +4 -0
  67. package/dist/popover/popover-content-modal.js.map +1 -1
  68. package/dist/popover/popover-content-non-modal.js +4 -0
  69. package/dist/popover/popover-content-non-modal.js.map +1 -1
  70. package/dist/popover/popover-content.js +4 -0
  71. package/dist/popover/popover-content.js.map +1 -1
  72. package/dist/popper/popper-content.js +10 -2
  73. package/dist/popper/popper-content.js.map +1 -1
  74. package/dist/scroll-area/scroll-area-root.js.map +1 -1
  75. package/dist/scroll-area/scroll-area-scrollbar-auto.js +1 -1
  76. package/dist/scroll-area/scroll-area-scrollbar-glimpse.js +126 -0
  77. package/dist/scroll-area/scroll-area-scrollbar-glimpse.js.map +1 -0
  78. package/dist/scroll-area/scroll-area-scrollbar-impl.js +1 -1
  79. package/dist/scroll-area/scroll-area-scrollbar-scroll.js +1 -1
  80. package/dist/scroll-area/scroll-area-scrollbar-visible.js +1 -1
  81. package/dist/scroll-area/scroll-area-scrollbar.js +11 -4
  82. package/dist/scroll-area/scroll-area-scrollbar.js.map +1 -1
  83. package/dist/select/select-content-impl.js +4 -0
  84. package/dist/select/select-content-impl.js.map +1 -1
  85. package/dist/select/select-content.js +4 -0
  86. package/dist/select/select-content.js.map +1 -1
  87. package/dist/select/select-popper-position.js +4 -0
  88. package/dist/select/select-popper-position.js.map +1 -1
  89. package/dist/shared/use-date-formatter.js +1 -1
  90. package/dist/shared/use-date-formatter.js.map +1 -1
  91. package/dist/tabs/tabs-content.js +5 -1
  92. package/dist/tabs/tabs-content.js.map +1 -1
  93. package/dist/tabs/tabs-root.js +12 -2
  94. package/dist/tabs/tabs-root.js.map +1 -1
  95. package/dist/tabs/tabs-trigger.js +1 -1
  96. package/dist/tabs/tabs-trigger.js.map +1 -1
  97. package/package.json +12 -12
  98. package/src/avatar/avatar-image.vue +1 -0
  99. package/src/collection/collection.ts +3 -2
  100. package/src/combobox/combobox-content-impl.vue +46 -32
  101. package/src/date/calendar.date.ts +1 -0
  102. package/src/date-range-picker/date-range-picker-anchor.vue +2 -2
  103. package/src/date-range-picker/date-range-picker-arrow.vue +2 -2
  104. package/src/date-range-picker/date-range-picker-close.vue +2 -2
  105. package/src/date-range-picker/index.ts +4 -0
  106. package/src/editable/editable-input.vue +7 -1
  107. package/src/index.ts +1 -0
  108. package/src/menu/menu-radio-group.vue +5 -4
  109. package/src/menu/menu-radio-item.vue +2 -1
  110. package/src/navigation-menu/navigation-menu-item.vue +1 -1
  111. package/src/navigation-menu/navigation-menu-root.vue +14 -6
  112. package/src/number-field/number-field-root.vue +15 -7
  113. package/src/pin-input/pin-input-input.vue +26 -19
  114. package/src/popper/popper-content.vue +15 -5
  115. package/src/scroll-area/index.ts +4 -0
  116. package/src/scroll-area/scroll-area-root.vue +1 -0
  117. package/src/scroll-area/scroll-area-scrollbar-glimpse.vue +145 -0
  118. package/src/scroll-area/scroll-area-scrollbar.vue +9 -0
  119. package/src/scroll-area/types.ts +1 -1
  120. package/src/shared/date/parser.ts +9 -0
  121. package/src/shared/index.ts +1 -1
  122. package/src/shared/use-date-formatter.ts +2 -1
  123. package/src/tabs/tabs-content.vue +7 -1
  124. package/src/tabs/tabs-root.vue +14 -1
  125. package/src/tabs/tabs-trigger.vue +5 -2
@@ -3,7 +3,14 @@ import type { Ref } from 'vue';
3
3
  import type { DismissableLayerEmits, DismissableLayerProps } from '../dismissable-layer';
4
4
  import type { APopperContentProps } from '../popper';
5
5
 
6
- import { createContext, getActiveElement, useForwardExpose, useForwardProps, useHideOthers } from '../shared';
6
+ import {
7
+ createContext,
8
+ getActiveElement,
9
+ useFocusGuards,
10
+ useForwardExpose,
11
+ useForwardProps,
12
+ useHideOthers,
13
+ } from '../shared';
7
14
  import { useBodyScrollLock } from '../shared/use-body-scroll-lock';
8
15
 
9
16
  export type ComboboxContentImplEmits = DismissableLayerEmits;
@@ -30,6 +37,7 @@ export const [
30
37
  <script setup lang="ts">
31
38
  import { computed, onMounted, onUnmounted, ref, toRefs } from 'vue';
32
39
  import { DismissableLayer } from '../dismissable-layer';
40
+ import { AFocusScope } from '../focus-scope';
33
41
  import { AListboxContent } from '../listbox';
34
42
  import { APopperContent } from '../popper';
35
43
  import { APrimitive } from '../primitive';
@@ -45,6 +53,7 @@ const rootContext = injectAComboboxRootContext();
45
53
 
46
54
  const { forwardRef, currentElement } = useForwardExpose();
47
55
  useBodyScrollLock(props.bodyLock);
56
+ useFocusGuards();
48
57
  useHideOthers(rootContext.parentElement);
49
58
 
50
59
  const pickedProps = computed(() => {
@@ -93,40 +102,45 @@ onUnmounted(() => {
93
102
 
94
103
  <template>
95
104
  <AListboxContent as-child>
96
- <DismissableLayer
105
+ <AFocusScope
97
106
  as-child
98
- :disable-outside-pointer-events="disableOutsidePointerEvents"
99
- @dismiss="rootContext.onOpenChange(false)"
100
- @focus-outside="(event) => {
101
- // if clicking inside the combobox, prevent dismiss
102
- if (rootContext.parentElement.value?.contains(event.target as Node)) event.preventDefault()
103
- emits('focusOutside', event)
104
- }"
105
- @interact-outside="emits('interactOutside', $event)"
106
- @escape-key-down="emits('escapeKeyDown', $event)"
107
- @pointer-down-outside="(event) => {
108
- // if clicking inside the combobox, prevent dismiss
109
- if (rootContext.parentElement.value?.contains(event.target as Node)) event.preventDefault()
110
- emits('pointerDownOutside', event)
111
- }"
107
+ @mount-auto-focus.prevent
112
108
  >
113
- <component
114
- :is="position === 'popper' ? APopperContent : APrimitive"
115
- v-bind="{ ...$attrs, ...forwardedProps }"
116
- :id="rootContext.contentId"
117
- :ref="forwardRef"
118
- :data-state="rootContext.open.value ? 'open' : 'closed'"
119
- :style="{
120
- // flex layout so we can place the scroll buttons properly
121
- display: 'flex',
122
- flexDirection: 'column',
123
- // reset the outline by default as the content MAY get focused
124
- outline: 'none',
125
- ...(position === 'popper' ? popperStyle : {}),
109
+ <DismissableLayer
110
+ as-child
111
+ :disable-outside-pointer-events="disableOutsidePointerEvents"
112
+ @dismiss="rootContext.onOpenChange(false)"
113
+ @focus-outside="(event) => {
114
+ // if clicking inside the combobox, prevent dismiss
115
+ if (rootContext.parentElement.value?.contains(event.target as Node)) event.preventDefault()
116
+ emits('focusOutside', event)
117
+ }"
118
+ @interact-outside="emits('interactOutside', $event)"
119
+ @escape-key-down="emits('escapeKeyDown', $event)"
120
+ @pointer-down-outside="(event) => {
121
+ // if clicking inside the combobox, prevent dismiss
122
+ if (rootContext.parentElement.value?.contains(event.target as Node)) event.preventDefault()
123
+ emits('pointerDownOutside', event)
126
124
  }"
127
125
  >
128
- <slot />
129
- </component>
130
- </DismissableLayer>
126
+ <component
127
+ :is="position === 'popper' ? APopperContent : APrimitive"
128
+ v-bind="{ ...$attrs, ...forwardedProps }"
129
+ :id="rootContext.contentId"
130
+ :ref="forwardRef"
131
+ :data-state="rootContext.open.value ? 'open' : 'closed'"
132
+ :style="{
133
+ // flex layout so we can place the scroll buttons properly
134
+ display: 'flex',
135
+ flexDirection: 'column',
136
+ // reset the outline by default as the content MAY get focused
137
+ outline: 'none',
138
+ ...(position === 'popper' ? popperStyle : {}),
139
+ }"
140
+ >
141
+ <slot />
142
+ </component>
143
+ </DismissableLayer>
144
+ </AFocusScope>
131
145
  </AListboxContent>
132
146
  </template>
@@ -104,6 +104,7 @@ export function createMonth(props: CreateMonthProps): DateGrid<DateValue> {
104
104
 
105
105
  const allDays = lastMonthDays.concat(datesArray, nextMonthDays);
106
106
 
107
+ // @ts-expect-error FIXME: we need to investigate further for this type.
107
108
  const weeks = chunk(allDays, 7);
108
109
 
109
110
  return {
@@ -2,11 +2,11 @@
2
2
  import type { APopoverAnchorProps } from '..';
3
3
  import { APopoverAnchor } from '..';
4
4
 
5
- export interface DateRangePickerAnchorProps extends APopoverAnchorProps {}
5
+ export interface ADateRangePickerAnchorProps extends APopoverAnchorProps {}
6
6
  </script>
7
7
 
8
8
  <script setup lang="ts">
9
- const props = defineProps<DateRangePickerAnchorProps>();
9
+ const props = defineProps<ADateRangePickerAnchorProps>();
10
10
  </script>
11
11
 
12
12
  <template>
@@ -2,11 +2,11 @@
2
2
  import type { APopoverArrowProps } from '..';
3
3
  import { APopoverArrow } from '..';
4
4
 
5
- export interface DateRangePickerArrowProps extends APopoverArrowProps {}
5
+ export interface ADateRangePickerArrowProps extends APopoverArrowProps {}
6
6
  </script>
7
7
 
8
8
  <script setup lang="ts">
9
- const props = defineProps<DateRangePickerArrowProps>();
9
+ const props = defineProps<ADateRangePickerArrowProps>();
10
10
  </script>
11
11
 
12
12
  <template>
@@ -2,11 +2,11 @@
2
2
  import type { APopoverCloseProps } from '..';
3
3
  import { APopoverClose } from '..';
4
4
 
5
- export interface DateRangePickerCloseProps extends APopoverCloseProps {}
5
+ export interface ADateRangePickerCloseProps extends APopoverCloseProps {}
6
6
  </script>
7
7
 
8
8
  <script setup lang="ts">
9
- const props = defineProps<DateRangePickerCloseProps>();
9
+ const props = defineProps<ADateRangePickerCloseProps>();
10
10
  </script>
11
11
 
12
12
  <template>
@@ -1,9 +1,11 @@
1
1
  export {
2
2
  default as ADateRangePickerAnchor,
3
+ type ADateRangePickerAnchorProps,
3
4
  } from './date-range-picker-anchor.vue';
4
5
 
5
6
  export {
6
7
  default as ADateRangePickerArrow,
8
+ type ADateRangePickerArrowProps,
7
9
  } from './date-range-picker-arrow.vue';
8
10
  export {
9
11
  default as ADateRangePickerCalendar,
@@ -20,10 +22,12 @@ export {
20
22
  } from './date-range-picker-cell.vue';
21
23
  export {
22
24
  default as ADateRangePickerClose,
25
+ type ADateRangePickerCloseProps,
23
26
  } from './date-range-picker-close.vue';
24
27
 
25
28
  export {
26
29
  default as ADateRangePickerContent,
30
+ type ADateRangePickerContentEmits,
27
31
  type ADateRangePickerContentProps,
28
32
  } from './date-range-picker-content.vue';
29
33
  export {
@@ -45,7 +45,13 @@ watch(context.isEditing, (value) => {
45
45
  });
46
46
 
47
47
  function handleSubmitKeyDown(event: KeyboardEvent) {
48
- if ((context.submitMode.value === 'enter' || context.submitMode.value === 'both') && event.key === KEY_CODES.ENTER && !event.shiftKey && !event.metaKey) {
48
+ if (
49
+ (context.submitMode.value === 'enter' || context.submitMode.value === 'both')
50
+ && event.key === KEY_CODES.ENTER
51
+ && !event.shiftKey
52
+ && !event.metaKey
53
+ && !event.isComposing
54
+ ) {
49
55
  context.submit();
50
56
  }
51
57
  }
package/src/index.ts CHANGED
@@ -55,6 +55,7 @@ export {
55
55
  type DateRange,
56
56
  type DateValue,
57
57
  type SegmentPart,
58
+ type TimeValue,
58
59
  useBodyScrollLock,
59
60
  type UseDateFormatter,
60
61
  useDateFormatter,
@@ -1,21 +1,22 @@
1
1
  <script lang="ts">
2
2
  import type { Ref } from 'vue';
3
+ import type { AcceptableValue } from '../shared/types';
3
4
  import type { AMenuGroupProps } from './menu-group.vue';
4
5
  import { createContext } from '../shared';
5
6
 
6
7
  interface MenuRadioGroupContext {
7
- modelValue: Ref<string>;
8
- onValueChange: (payload: string) => void;
8
+ modelValue: Ref<AcceptableValue>;
9
+ onValueChange: (payload: AcceptableValue) => void;
9
10
  }
10
11
 
11
12
  export interface AMenuRadioGroupProps extends AMenuGroupProps {
12
13
  /** The value of the selected item in the group. */
13
- modelValue?: string;
14
+ modelValue?: AcceptableValue;
14
15
  }
15
16
 
16
17
  export type AMenuRadioGroupEmits = {
17
18
  /** Event handler called when the value changes. */
18
- 'update:modelValue': [payload: string];
19
+ 'update:modelValue': [payload: AcceptableValue];
19
20
  };
20
21
 
21
22
  export const [injectMenuRadioGroupContext, provideMenuRadioGroupContext]
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import type { AcceptableValue } from '../shared/types';
2
3
  import type {
3
4
  AMenuItemEmits,
4
5
  AMenuItemProps,
@@ -8,7 +9,7 @@ export type AMenuRadioItemEmits = AMenuItemEmits;
8
9
 
9
10
  export interface AMenuRadioItemProps extends AMenuItemProps {
10
11
  /** The unique value of the item. */
11
- value: string;
12
+ value: AcceptableValue;
12
13
  }
13
14
  </script>
14
15
 
@@ -8,7 +8,7 @@ export interface ANavigationMenuItemProps extends APrimitiveProps {
8
8
  /**
9
9
  * A unique value that associates the item with an active value when the navigation menu is controlled.
10
10
  *
11
- * This prop is managed automatically when uncontrolled.
11
+ * This prop is managed automatically when uncontrolled.
12
12
  */
13
13
  value?: string;
14
14
  }
@@ -94,7 +94,7 @@ export const [
94
94
 
95
95
  <script setup lang="ts">
96
96
  import { isString } from '@vinicunca/perkakas';
97
- import { refAutoReset, useDebounceFn, useVModel } from '@vueuse/core';
97
+ import { refAutoReset, useDebounceFn, useEventListener, useVModel } from '@vueuse/core';
98
98
  import {
99
99
  computed,
100
100
  ref,
@@ -106,6 +106,7 @@ import {
106
106
  APrimitive,
107
107
  } from '../primitive';
108
108
  import { useDirection, useForwardExpose, useId } from '../shared';
109
+ import { EVENT_ROOT_CONTENT_DISMISS } from './utils';
109
110
 
110
111
  const props = withDefaults(
111
112
  defineProps<ANavigationMenuRootProps>(),
@@ -185,6 +186,17 @@ watchEffect(() => {
185
186
  );
186
187
  });
187
188
 
189
+ function onItemDismiss() {
190
+ previousValue.value = modelValue.value;
191
+ modelValue.value = '';
192
+ }
193
+
194
+ useEventListener(
195
+ rootNavigationMenu,
196
+ EVENT_ROOT_CONTENT_DISMISS,
197
+ onItemDismiss,
198
+ );
199
+
188
200
  provideNavigationMenuContext({
189
201
  isRootMenu: true,
190
202
  modelValue,
@@ -225,10 +237,7 @@ provideNavigationMenuContext({
225
237
  previousValue.value = modelValue.value;
226
238
  modelValue.value = val;
227
239
  },
228
- onItemDismiss: () => {
229
- previousValue.value = modelValue.value;
230
- modelValue.value = '';
231
- },
240
+ onItemDismiss,
232
241
  });
233
242
  </script>
234
243
 
@@ -236,7 +245,6 @@ provideNavigationMenuContext({
236
245
  <ACollectionSlot>
237
246
  <APrimitive
238
247
  :ref="forwardRef"
239
- aria-label="Main"
240
248
  :as="as"
241
249
  :as-child="asChild"
242
250
  :data-orientation="orientation"
@@ -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
 
@@ -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>