akar 1.13.0 → 1.15.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 (47) hide show
  1. package/dist/accordion/accordion-item.js +3 -2
  2. package/dist/accordion/accordion-item.js.map +1 -1
  3. package/dist/combobox/combobox-cancel.js +1 -1
  4. package/dist/combobox/combobox-cancel.js.map +1 -1
  5. package/dist/combobox/combobox-content-impl.js +3 -1
  6. package/dist/combobox/combobox-content-impl.js.map +1 -1
  7. package/dist/date-picker/date-picker-root.js +0 -8
  8. package/dist/date-picker/date-picker-root.js.map +1 -1
  9. package/dist/date-range-picker/date-range-picker-root.js +0 -8
  10. package/dist/date-range-picker/date-range-picker-root.js.map +1 -1
  11. package/dist/dismissable-layer/dismissable-layer.js +4 -3
  12. package/dist/dismissable-layer/dismissable-layer.js.map +1 -1
  13. package/dist/index.d.ts +767 -763
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/range-calendar/range-calendar-cell-trigger.js +2 -2
  16. package/dist/range-calendar/range-calendar-cell-trigger.js.map +1 -1
  17. package/dist/range-calendar/range-calendar-root.js +10 -8
  18. package/dist/range-calendar/range-calendar-root.js.map +1 -1
  19. package/dist/select/select-arrow.js +1 -3
  20. package/dist/select/select-arrow.js.map +1 -1
  21. package/dist/select/select-content-impl.js +7 -2
  22. package/dist/select/select-content-impl.js.map +1 -1
  23. package/dist/select/select-content.js +4 -0
  24. package/dist/select/select-content.js.map +1 -1
  25. package/dist/shared/use-forward-expose.js +10 -1
  26. package/dist/shared/use-forward-expose.js.map +1 -1
  27. package/dist/shared/use-grace-area.js +4 -1
  28. package/dist/shared/use-grace-area.js.map +1 -1
  29. package/dist/tabs/tabs-indicator.js +18 -12
  30. package/dist/tabs/tabs-indicator.js.map +1 -1
  31. package/dist/tooltip/tooltip-content-impl.js +3 -19
  32. package/dist/tooltip/tooltip-content-impl.js.map +1 -1
  33. package/package.json +7 -7
  34. package/src/accordion/accordion-item.vue +7 -2
  35. package/src/combobox/combobox-cancel.vue +3 -3
  36. package/src/combobox/combobox-content-impl.vue +3 -2
  37. package/src/date-picker/date-picker-root.vue +1 -1
  38. package/src/date-range-picker/date-range-picker-root.vue +4 -4
  39. package/src/dismissable-layer/dismissable-layer.vue +5 -3
  40. package/src/range-calendar/range-calendar-cell-trigger.vue +1 -1
  41. package/src/range-calendar/range-calendar-root.vue +11 -25
  42. package/src/select/select-arrow.vue +1 -3
  43. package/src/select/select-content-impl.vue +6 -5
  44. package/src/shared/use-forward-expose.ts +16 -1
  45. package/src/shared/use-grace-area.ts +8 -1
  46. package/src/tabs/tabs-indicator.vue +29 -13
  47. package/src/tooltip/tooltip-content-impl.vue +3 -27
@@ -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,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 />
@@ -3,7 +3,7 @@ import type {
3
3
  ComponentPublicInstance,
4
4
  Ref,
5
5
  } from 'vue';
6
- import type { PointerDownOutsideEvent } from '../dismissable-layer';
6
+ import type { DismissableLayerProps, PointerDownOutsideEvent } from '../dismissable-layer';
7
7
  import type { APopperContentProps } from '../popper';
8
8
  import type { AcceptableValue } from '../shared/types';
9
9
  import { isIncludedIn, KEY_CODES } from '@vinicunca/perkakas';
@@ -25,14 +25,14 @@ export interface SelectContentContext {
25
25
  itemRefCallback: (
26
26
  node: HTMLElement | undefined,
27
27
  value: AcceptableValue,
28
- disabled: boolean
28
+ disabled: boolean,
29
29
  ) => void;
30
30
  selectedItem?: Ref<HTMLElement | undefined>;
31
31
  onItemLeave?: () => void;
32
32
  itemTextRefCallback: (
33
33
  node: HTMLElement | undefined,
34
34
  value: AcceptableValue,
35
- disabled: boolean
35
+ disabled: boolean,
36
36
  ) => void;
37
37
  focusSelectedItem?: () => void;
38
38
  selectedItemText?: Ref<HTMLElement | undefined>;
@@ -61,7 +61,7 @@ export type SelectContentImplEmits = {
61
61
  pointerDownOutside: [event: PointerDownOutsideEvent];
62
62
  };
63
63
 
64
- export interface SelectContentImplProps extends APopperContentProps {
64
+ export interface SelectContentImplProps extends APopperContentProps, DismissableLayerProps {
65
65
  /**
66
66
  * The positioning mode to use
67
67
  *
@@ -102,6 +102,7 @@ const props = withDefaults(defineProps<SelectContentImplProps>(), {
102
102
  align: 'start',
103
103
  position: 'item-aligned',
104
104
  bodyLock: true,
105
+ disableOutsidePointerEvents: true,
105
106
  });
106
107
  const emits = defineEmits<SelectContentImplEmits>();
107
108
 
@@ -296,7 +297,7 @@ provideSelectContentContext({
296
297
  >
297
298
  <DismissableLayer
298
299
  as-child
299
- disable-outside-pointer-events
300
+ :disable-outside-pointer-events="disableOutsidePointerEvents"
300
301
  @focus-outside.prevent
301
302
  @dismiss="rootContext.onOpenChange(false)"
302
303
  @escape-key-down="emits('escapeKeyDown', $event)"
@@ -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
 
@@ -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
  }
@@ -1,5 +1,4 @@
1
1
  <script lang="ts">
2
- import type { VNode } from 'vue';
3
2
  import type { APopperContentProps } from '../popper';
4
3
  import type { APrimitiveProps } from '../primitive';
5
4
 
@@ -40,9 +39,8 @@ export interface TooltipContentImplProps
40
39
  </script>
41
40
 
42
41
  <script setup lang="ts">
43
- import { isString } from '@vinicunca/perkakas';
44
42
  import { useEventListener } from '@vueuse/core';
45
- import { Comment, computed, onMounted, useSlots } from 'vue';
43
+ import { computed, onMounted } from 'vue';
46
44
  import { DismissableLayer } from '../dismissable-layer';
47
45
  import { APopperContent } from '../popper';
48
46
  import { useForwardExpose } from '../shared';
@@ -65,30 +63,8 @@ const emits = defineEmits<TooltipContentImplEmits>();
65
63
 
66
64
  const rootContext = injectATooltipRootContext();
67
65
 
68
- const { forwardRef } = useForwardExpose();
69
- const slot = useSlots();
70
- const defaultSlot = computed(() => slot.default?.({}));
71
- const ariaLabel = computed(() => {
72
- if (props.ariaLabel) {
73
- return props.ariaLabel;
74
- }
75
- let content = '';
76
-
77
- function recursiveTextSearch(node: VNode) {
78
- if (isString(node.children) && node.type !== Comment) {
79
- content += node.children;
80
- } else if (Array.isArray(node.children)) {
81
- node.children.forEach((child) => {
82
- recursiveTextSearch(child as VNode);
83
- });
84
- }
85
- }
86
-
87
- defaultSlot.value?.forEach((node: VNode) => {
88
- recursiveTextSearch(node);
89
- });
90
- return content;
91
- });
66
+ const { forwardRef, currentElement } = useForwardExpose();
67
+ const ariaLabel = computed(() => props.ariaLabel || currentElement.value?.textContent);
92
68
 
93
69
  const popperContentProps = computed(() => {
94
70
  const { ariaLabel: _, ...restProps } = props;