akar 2.0.14 → 2.0.15

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 (129) hide show
  1. package/dist/Autocomplete/AutocompleteInput.cjs +4 -2
  2. package/dist/Autocomplete/AutocompleteInput.cjs.map +1 -1
  3. package/dist/Autocomplete/AutocompleteInput.js +4 -2
  4. package/dist/Autocomplete/AutocompleteInput.js.map +1 -1
  5. package/dist/Combobox/ComboboxInput.cjs +4 -2
  6. package/dist/Combobox/ComboboxInput.cjs.map +1 -1
  7. package/dist/Combobox/ComboboxInput.js +4 -2
  8. package/dist/Combobox/ComboboxInput.js.map +1 -1
  9. package/dist/DateField/DateFieldRoot.cjs +1 -1
  10. package/dist/DateField/DateFieldRoot.cjs.map +1 -1
  11. package/dist/DateField/DateFieldRoot.js +1 -1
  12. package/dist/DateField/DateFieldRoot.js.map +1 -1
  13. package/dist/DateRangeField/DateRangeFieldRoot.cjs +1 -1
  14. package/dist/DateRangeField/DateRangeFieldRoot.cjs.map +1 -1
  15. package/dist/DateRangeField/DateRangeFieldRoot.js +1 -1
  16. package/dist/DateRangeField/DateRangeFieldRoot.js.map +1 -1
  17. package/dist/DismissableLayer/DismissableLayer.cjs +12 -23
  18. package/dist/DismissableLayer/DismissableLayer.cjs.map +1 -1
  19. package/dist/DismissableLayer/DismissableLayer.js +3 -8
  20. package/dist/DismissableLayer/DismissableLayer.js.map +1 -1
  21. package/dist/DismissableLayer/DismissableLayerBranch.cjs +3 -3
  22. package/dist/DismissableLayer/DismissableLayerBranch.cjs.map +1 -1
  23. package/dist/DismissableLayer/DismissableLayerBranch.js +1 -1
  24. package/dist/DismissableLayer/context.cjs +19 -0
  25. package/dist/DismissableLayer/context.cjs.map +1 -0
  26. package/dist/DismissableLayer/context.js +13 -0
  27. package/dist/DismissableLayer/context.js.map +1 -0
  28. package/dist/DropdownMenu/DropdownMenuFilter.cjs +4 -2
  29. package/dist/DropdownMenu/DropdownMenuFilter.cjs.map +1 -1
  30. package/dist/DropdownMenu/DropdownMenuFilter.js +4 -2
  31. package/dist/DropdownMenu/DropdownMenuFilter.js.map +1 -1
  32. package/dist/Listbox/ListboxFilter.cjs +4 -2
  33. package/dist/Listbox/ListboxFilter.cjs.map +1 -1
  34. package/dist/Listbox/ListboxFilter.js +4 -2
  35. package/dist/Listbox/ListboxFilter.js.map +1 -1
  36. package/dist/NumberField/NumberFieldInput.cjs +1 -0
  37. package/dist/NumberField/NumberFieldInput.cjs.map +1 -1
  38. package/dist/NumberField/NumberFieldInput.js +1 -0
  39. package/dist/NumberField/NumberFieldInput.js.map +1 -1
  40. package/dist/Presence/usePresence.cjs +3 -2
  41. package/dist/Presence/usePresence.cjs.map +1 -1
  42. package/dist/Presence/usePresence.js +3 -2
  43. package/dist/Presence/usePresence.js.map +1 -1
  44. package/dist/Rating/RatingRoot.cjs +7 -1
  45. package/dist/Rating/RatingRoot.cjs.map +1 -1
  46. package/dist/Rating/RatingRoot.js +7 -1
  47. package/dist/Rating/RatingRoot.js.map +1 -1
  48. package/dist/Stepper/StepperIndicator.cjs +2 -1
  49. package/dist/Stepper/StepperIndicator.cjs.map +1 -1
  50. package/dist/Stepper/StepperIndicator.js +2 -1
  51. package/dist/Stepper/StepperIndicator.js.map +1 -1
  52. package/dist/Stepper/StepperTrigger.cjs +7 -2
  53. package/dist/Stepper/StepperTrigger.cjs.map +1 -1
  54. package/dist/Stepper/StepperTrigger.js +7 -2
  55. package/dist/Stepper/StepperTrigger.js.map +1 -1
  56. package/dist/TagsInput/TagsInputRoot.cjs +5 -3
  57. package/dist/TagsInput/TagsInputRoot.cjs.map +1 -1
  58. package/dist/TagsInput/TagsInputRoot.js +6 -4
  59. package/dist/TagsInput/TagsInputRoot.js.map +1 -1
  60. package/dist/TimeField/TimeFieldRoot.cjs +1 -1
  61. package/dist/TimeField/TimeFieldRoot.cjs.map +1 -1
  62. package/dist/TimeField/TimeFieldRoot.js +1 -1
  63. package/dist/TimeField/TimeFieldRoot.js.map +1 -1
  64. package/dist/TimeRangeField/TimeRangeFieldRoot.cjs +1 -1
  65. package/dist/TimeRangeField/TimeRangeFieldRoot.cjs.map +1 -1
  66. package/dist/TimeRangeField/TimeRangeFieldRoot.js +1 -1
  67. package/dist/TimeRangeField/TimeRangeFieldRoot.js.map +1 -1
  68. package/dist/Toast/ToastRootImpl.cjs +2 -2
  69. package/dist/Toast/ToastRootImpl.cjs.map +1 -1
  70. package/dist/Toast/ToastRootImpl.js +2 -2
  71. package/dist/Toast/ToastRootImpl.js.map +1 -1
  72. package/dist/composables/useSwipeDismiss.cjs +54 -18
  73. package/dist/composables/useSwipeDismiss.cjs.map +1 -1
  74. package/dist/composables/useSwipeDismiss.js +54 -18
  75. package/dist/composables/useSwipeDismiss.js.map +1 -1
  76. package/dist/constant.d.cts.map +1 -1
  77. package/dist/index.cjs +1 -0
  78. package/dist/index.js +1 -0
  79. package/dist/index2.d.ts.map +1 -1
  80. package/dist/index3.d.cts +17 -15
  81. package/dist/index3.d.cts.map +1 -1
  82. package/dist/index3.d.ts +17 -15
  83. package/dist/index3.d.ts.map +1 -1
  84. package/dist/index4.d.cts +655 -655
  85. package/dist/index4.d.cts.map +1 -1
  86. package/dist/index4.d.ts +651 -651
  87. package/dist/index4.d.ts.map +1 -1
  88. package/dist/internal.cjs +1 -0
  89. package/dist/internal.d.cts +2 -2
  90. package/dist/internal.d.cts.map +1 -1
  91. package/dist/internal.d.ts +2 -2
  92. package/dist/internal.js +1 -0
  93. package/dist/shared/useBodyScrollLock.cjs +6 -5
  94. package/dist/shared/useBodyScrollLock.cjs.map +1 -1
  95. package/dist/shared/useBodyScrollLock.js +6 -5
  96. package/dist/shared/useBodyScrollLock.js.map +1 -1
  97. package/dist/shared/useComposing.cjs +19 -0
  98. package/dist/shared/useComposing.cjs.map +1 -1
  99. package/dist/shared/useComposing.js +20 -1
  100. package/dist/shared/useComposing.js.map +1 -1
  101. package/dist/shared.cjs +1 -0
  102. package/dist/shared.js +1 -0
  103. package/dist/utils/validation.cjs +1 -0
  104. package/dist/utils/validation.cjs.map +1 -1
  105. package/dist/utils/validation.js +1 -0
  106. package/dist/utils/validation.js.map +1 -1
  107. package/package.json +6 -6
  108. package/src/Autocomplete/AutocompleteInput.vue +3 -2
  109. package/src/Combobox/ComboboxInput.vue +3 -2
  110. package/src/DateField/DateFieldRoot.vue +4 -1
  111. package/src/DateRangeField/DateRangeFieldRoot.vue +4 -1
  112. package/src/DismissableLayer/DismissableLayer.vue +2 -7
  113. package/src/DismissableLayer/DismissableLayerBranch.vue +1 -1
  114. package/src/DismissableLayer/context.ts +8 -0
  115. package/src/Drawer/composables/useSwipeDismiss.ts +94 -26
  116. package/src/DropdownMenu/DropdownMenuFilter.vue +3 -2
  117. package/src/Listbox/ListboxFilter.vue +3 -2
  118. package/src/NumberField/NumberFieldInput.vue +3 -0
  119. package/src/Presence/usePresence.ts +6 -2
  120. package/src/Rating/RatingRoot.vue +7 -0
  121. package/src/Splitter/utils/validation.ts +11 -7
  122. package/src/Stepper/StepperIndicator.vue +6 -1
  123. package/src/Stepper/StepperTrigger.vue +11 -2
  124. package/src/TagsInput/TagsInputRoot.vue +6 -4
  125. package/src/TimeField/TimeFieldRoot.vue +4 -1
  126. package/src/TimeRangeField/TimeRangeFieldRoot.vue +4 -1
  127. package/src/Toast/ToastRootImpl.vue +5 -2
  128. package/src/shared/useBodyScrollLock.ts +9 -1
  129. package/src/shared/useComposing.ts +53 -2
@@ -190,7 +190,12 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
190
190
  el.style.setProperty(movementCssVars.y, '0px');
191
191
  }
192
192
 
193
- function reset() {
193
+ /**
194
+ * Clears the per-gesture tracking state. Deliberately leaves the pointer
195
+ * identity and the touch scroll-guard flags alone, so it is safe to call at
196
+ * the start of a gesture as well as at the end of one.
197
+ */
198
+ function resetGestureState() {
194
199
  setSwiping(false);
195
200
  swipeDirection.value = undefined;
196
201
  dragOffset.value = { x: 0, y: 0 };
@@ -201,18 +206,27 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
201
206
  isFirstMove = false;
202
207
  pendingSwipe = false;
203
208
  pendingSwipeStartPos = null;
204
- swipeFromScrollable = false;
205
- scrollableAncestor = null;
206
209
  elementSize = { width: 0, height: 0 };
207
210
  swipeProgress = 0;
208
211
  lastDragSample = null;
209
212
  lastVelocity = { x: 0, y: 0 };
210
213
  lockedAxis = null;
214
+ }
215
+
216
+ function reset() {
217
+ resetGestureState();
218
+ swipeFromScrollable = false;
219
+ scrollableAncestor = null;
211
220
  activePointerId = null;
212
221
  pointerStarted = false;
213
222
  }
214
223
 
215
224
  function startSwipe(el: HTMLElement, pos: { x: number; y: number }) {
225
+ // Start from a clean slate (BaseUI parity: `startSwipeAtPosition` resets the
226
+ // gesture refs on every press). A previous gesture whose end we never saw
227
+ // would otherwise leak `isSwiping`, the intended direction and the velocity
228
+ // samples into this one.
229
+ resetGestureState();
216
230
  // Capture the element's current transform so we can account for it
217
231
  getElementTransform(el);
218
232
  dragStartPos = pos;
@@ -272,24 +286,19 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
272
286
  const dir: SwipeDirection | undefined = toValue(directions).find((d) => getDisplacement(d, dx, dy) > 0);
273
287
 
274
288
  if (pendingSwipe && pendingSwipeStartPos) {
275
- // Only promote to an active swipe when we've identified an allowed
276
- // direction. If the user is dragging against the dismiss direction
277
- // (dir === undefined), bail out so we don't steal scroll/drag from
278
- // one-direction drawers.
279
- if (!dir) {
280
- return;
281
- }
282
- const pending = getDisplacement(
283
- dir,
284
- pos.x - pendingSwipeStartPos.x,
285
- pos.y - pendingSwipeStartPos.y,
286
- );
287
- if (Math.abs(pending) < MIN_DRAG_THRESHOLD) {
289
+ // BaseUI parity (`useSwipeDismiss.ts:startSwipeAtPosition`): the drag is
290
+ // tracked from the first movement whatever its direction — the gesture
291
+ // does NOT need to point at a dismissable direction to begin. Movement
292
+ // along a non-dismissable direction still reaches
293
+ // `applyDirectionalDamping` below, which sqrt-damps it; that damped
294
+ // offset is the elastic "pull" feedback you get when dragging a bottom
295
+ // drawer upward. Bailing out on `!dir` instead would leave the drawer
296
+ // completely frozen until the user drags the dismissable way.
297
+ const pending = Math.max(Math.abs(dx), Math.abs(dy));
298
+ if (pending < MIN_DRAG_THRESHOLD) {
288
299
  return;
289
300
  }
290
301
  pendingSwipe = false;
291
- intendedDirection = dir;
292
- swipeDirection.value = dir;
293
302
  setSwiping(true);
294
303
  onSwipeStart?.();
295
304
  }
@@ -298,11 +307,21 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
298
307
  return;
299
308
  }
300
309
 
301
- const currentDir = intendedDirection ?? toValue(directions)[0];
302
- const displacement = getDisplacement(currentDir, dx, dy);
310
+ // The intended (dismissable) direction is adopted the first time the drag
311
+ // moves in one, which may be many moves after the swipe started — e.g. pull
312
+ // up, then push back down on a `down` drawer. Until then the gesture has no
313
+ // dismiss candidate and only rubber-bands.
314
+ if (!intendedDirection && dir) {
315
+ intendedDirection = dir;
316
+ swipeDirection.value = dir;
317
+ maxDisplacement = getDisplacement(dir, dx, dy);
318
+ }
319
+
320
+ const currentDir = intendedDirection;
303
321
 
304
322
  // Detect reversal (cancel swipe)
305
- if (!cancelledSwipe) {
323
+ if (currentDir && !cancelledSwipe) {
324
+ const displacement = getDisplacement(currentDir, dx, dy);
306
325
  maxDisplacement = Math.max(maxDisplacement, displacement);
307
326
  if (
308
327
  maxDisplacement > DEFAULT_SWIPE_THRESHOLD / 2
@@ -321,14 +340,18 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
321
340
  setCssVars(el, damped.x, damped.y);
322
341
  recordSample({ x: damped.x, y: damped.y }, time);
323
342
 
324
- // Progress: 0 = closed/start, 1 = fully dismissed
343
+ // Progress: 0 = closed/start, 1 = fully dismissed. Before a dismissable
344
+ // direction is adopted, measure against the primary one — a pull away from
345
+ // it yields a negative displacement, which clamps to 0 (BaseUI parity:
346
+ // `progressDirection = primaryDirection ?? intendedSwipeDirection`).
325
347
  const currentEl = elementRef.value;
326
- if (currentEl) {
327
- const dim = (currentDir === 'up' || currentDir === 'down')
348
+ const progressDir = currentDir ?? toValue(directions)[0];
349
+ if (currentEl && progressDir) {
350
+ const dim = (progressDir === 'up' || progressDir === 'down')
328
351
  ? elementSize.height || currentEl.offsetHeight
329
352
  : elementSize.width || currentEl.offsetWidth;
330
- const threshold = getThreshold(currentEl, currentDir);
331
- const p = Math.min(1, Math.max(0, displacement / (dim + threshold)));
353
+ const threshold = getThreshold(currentEl, progressDir);
354
+ const p = Math.min(1, Math.max(0, getDisplacement(progressDir, dx, dy) / (dim + threshold)));
332
355
  if (p !== swipeProgress) {
333
356
  swipeProgress = p;
334
357
  onProgress?.(p, { deltaX: damped.x, deltaY: damped.y, direction: currentDir });
@@ -428,6 +451,13 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
428
451
  return;
429
452
  }
430
453
  if ((e.buttons & 1) === 0) {
454
+ // The primary button is no longer held, but we never saw the release —
455
+ // it happened outside the window, over another application, or after the
456
+ // browser dropped pointer capture. Treat this move as the missing
457
+ // `pointerup`: without it the gesture stays wedged with `data-swiping`
458
+ // set (which pins the transition to 0ms), leaving the drawer frozen
459
+ // mid-pull and ignoring every subsequent drag.
460
+ finishSwipe(el);
431
461
  return;
432
462
  }
433
463
  processMove(el, { x: e.clientX, y: e.clientY }, e.timeStamp);
@@ -439,6 +469,25 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
439
469
  }
440
470
  const el = elementRef.value;
441
471
  if (!el) {
472
+ reset();
473
+ return;
474
+ }
475
+ finishSwipe(el);
476
+ }
477
+
478
+ /**
479
+ * Ends an in-flight pointer drag that can no longer be tracked — pointer
480
+ * capture was lost, or the window lost focus mid-drag (which is what happens
481
+ * when the release lands over another application). The drawer settles from
482
+ * wherever it was last dragged to.
483
+ */
484
+ function onPointerInterrupted() {
485
+ if (!pointerStarted) {
486
+ return;
487
+ }
488
+ const el = elementRef.value;
489
+ if (!el) {
490
+ reset();
442
491
  return;
443
492
  }
444
493
  finishSwipe(el);
@@ -556,16 +605,35 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
556
605
  return;
557
606
  }
558
607
 
608
+ // BaseUI hangs the gesture off `Drawer.Viewport`, a `position: fixed;
609
+ // inset: 0` element, so the pointer can never leave the element that is
610
+ // listening. Here the listeners live on the popup itself, which the
611
+ // pointer leaves as soon as the drag goes past the drawer's bounds.
612
+ // `setPointerCapture` covers that for an ordinary in-window drag, but a
613
+ // release the popup never sees — outside the window, over another app, or
614
+ // after capture is dropped — would otherwise leave the gesture wedged.
615
+ // Mirror the pointer end events on the document and window so the drag
616
+ // can always be finished.
617
+ const doc = el.ownerDocument;
618
+ const win = doc.defaultView;
619
+
559
620
  cleanups.push(
560
621
  useEventListener(el, 'pointerdown', onPointerDown as EventListener),
561
622
  useEventListener(el, 'pointermove', onPointerMove as EventListener),
562
623
  useEventListener(el, 'pointerup', onPointerUp as EventListener),
563
624
  useEventListener(el, 'pointercancel', onPointerUp as EventListener),
625
+ useEventListener(el, 'lostpointercapture', onPointerInterrupted as EventListener),
626
+ useEventListener(doc, 'pointerup', onPointerUp as EventListener),
627
+ useEventListener(doc, 'pointercancel', onPointerUp as EventListener),
564
628
  useEventListener(el, 'touchstart', onTouchStart as EventListener, { passive: true }),
565
629
  useEventListener(el, 'touchmove', onTouchMove as EventListener, { passive: false }),
566
630
  useEventListener(el, 'touchend', onTouchEnd as EventListener),
567
631
  useEventListener(el, 'touchcancel', onTouchEnd as EventListener),
568
632
  );
633
+
634
+ if (win) {
635
+ cleanups.push(useEventListener(win, 'blur', onPointerInterrupted));
636
+ }
569
637
  },
570
638
  { immediate: true },
571
639
  );
@@ -77,7 +77,7 @@ onUnmounted(() => {
77
77
  contentContext.searchRef.value = '';
78
78
  });
79
79
 
80
- const { isComposing, handleCompositionStart, handleCompositionEnd } = useComposing((event) => {
80
+ const { isComposing, shouldDeferInput, handleCompositionStart, handleCompositionUpdate, handleCompositionEnd } = useComposing((event) => {
81
81
  const el = event.target as HTMLInputElement;
82
82
  if (el) {
83
83
  modelValue.value = el.value;
@@ -90,7 +90,7 @@ function handleInput(event: InputEvent) {
90
90
  return;
91
91
  }
92
92
 
93
- if (isComposing.value) {
93
+ if (shouldDeferInput.value) {
94
94
  return;
95
95
  }
96
96
 
@@ -142,6 +142,7 @@ function handleKeyDown(event: KeyboardEvent) {
142
142
  @input="handleInput"
143
143
  @keydown="handleKeyDown"
144
144
  @compositionstart="handleCompositionStart"
145
+ @compositionupdate="handleCompositionUpdate"
145
146
  @compositionend="handleCompositionEnd"
146
147
  >
147
148
  <slot :model-value="modelValue" />
@@ -65,7 +65,7 @@ onUnmounted(() => {
65
65
  rootContext.focusable.value = true;
66
66
  });
67
67
 
68
- const { isComposing, handleCompositionStart, handleCompositionEnd } = useComposing((event) => {
68
+ const { isComposing, shouldDeferInput, handleCompositionStart, handleCompositionUpdate, handleCompositionEnd } = useComposing((event) => {
69
69
  modelValue.value = (event.target as HTMLInputElement).value;
70
70
  rootContext.onCompositionEnd();
71
71
  rootContext.highlightFirstItem();
@@ -77,7 +77,7 @@ function onCompositionStart() {
77
77
  }
78
78
 
79
79
  function handleInput(event: InputEvent) {
80
- if (isComposing.value) {
80
+ if (shouldDeferInput.value) {
81
81
  return;
82
82
  }
83
83
  modelValue.value = (event.target as HTMLInputElement).value;
@@ -117,6 +117,7 @@ function handleKeydownEnter(event: KeyboardEvent) {
117
117
  @keydown.enter="handleKeydownEnter"
118
118
  @input="handleInput"
119
119
  @compositionstart="onCompositionStart"
120
+ @compositionupdate="handleCompositionUpdate"
120
121
  @compositionend="handleCompositionEnd"
121
122
  >
122
123
  <slot :model-value="modelValue" />
@@ -126,6 +126,9 @@ function handleChange() {
126
126
  @wheel="handleWheelEvent"
127
127
  @beforeinput="(event: InputEvent) => {
128
128
  if (event.isComposing) return
129
+ // A collapsed deletion carries no data, so nextValue would repeat the current value; undo and redo read the same
130
+ // Every deletion is skipped so they stay consistent, and applyInputValue reformats on blur
131
+ if (event.inputType.startsWith('delete') || event.inputType.startsWith('history')) return
129
132
  const target = event.target as HTMLInputElement
130
133
  let nextValue
131
134
  = target.value.slice(0, target.selectionStart ?? undefined)
@@ -88,12 +88,16 @@ export function usePresence(
88
88
  * make sure we only trigger ANIMATION_END for the currently active animation.
89
89
  */
90
90
  const handleAnimationEnd = (event: AnimationEvent) => {
91
+ if (event.target !== node.value) {
92
+ return;
93
+ }
94
+
91
95
  const currentAnimationName = getAnimationName(node.value);
92
96
  const isCurrentAnimation = currentAnimationName.includes(
93
97
  CSS.escape(event.animationName),
94
98
  );
95
99
  const directionName = state.value === 'mounted' ? 'enter' : 'leave';
96
- if (event.target === node.value && isCurrentAnimation) {
100
+ if (isCurrentAnimation) {
97
101
  dispatchCustomEvent(`after-${directionName}`);
98
102
  dispatch('ANIMATION_END');
99
103
 
@@ -112,7 +116,7 @@ export function usePresence(
112
116
  }
113
117
  }
114
118
  // if no animation, immediately trigger 'ANIMATION_END'
115
- if (event.target === node.value && currentAnimationName === 'none') {
119
+ if (currentAnimationName === 'none') {
116
120
  dispatch('ANIMATION_END');
117
121
  }
118
122
  };
@@ -94,6 +94,12 @@ function changeHoveredRating(rating: number) {
94
94
  hoveredRating.value = rating;
95
95
  }
96
96
 
97
+ // Unconditional, so a preview left over from a `hoverable`/`disabled` toggle
98
+ // mid-hover still clears once the pointer leaves.
99
+ function resetHoveredRating() {
100
+ hoveredRating.value = 0;
101
+ }
102
+
97
103
  provideRatingRootContext({
98
104
  modelValue,
99
105
  items,
@@ -109,6 +115,7 @@ provideRatingRootContext({
109
115
  <RadioGroupRoot
110
116
  v-bind="reactiveOmit(props, 'length', 'clearable', 'hoverable', 'step')"
111
117
  :disabled="disabled"
118
+ @mouseleave="resetHoveredRating"
112
119
  >
113
120
  <slot
114
121
  :items="items"
@@ -12,6 +12,12 @@ export function validatePanelGroupLayout({
12
12
  panelConstraints: Array<PanelConstraints>;
13
13
  }): Array<number> {
14
14
  const nextLayout = [...prevLayout];
15
+
16
+ // An empty group has no sizes to total, so 0 !== 100 here is not a misconfiguration
17
+ if (nextLayout.length === 0 && panelConstraints.length === 0) {
18
+ return nextLayout;
19
+ }
20
+
15
21
  const nextLayoutTotalSize = nextLayout.reduce(
16
22
  (accumulated, current) => accumulated + current,
17
23
  0,
@@ -27,14 +33,12 @@ export function validatePanelGroupLayout({
27
33
  } else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100)) {
28
34
  // This is not ideal so we should warn about it, but it may be recoverable in some cases
29
35
  // (especially if the amount is small)
36
+ console.warn(
37
+ `WARNING: Invalid layout total size: ${nextLayout
38
+ .map((size) => `${size}%`)
39
+ .join(', ')}. Layout normalization will be applied.`,
40
+ );
30
41
 
31
- if (true) {
32
- console.warn(
33
- `WARNING: Invalid layout total size: ${nextLayout
34
- .map((size) => `${size}%`)
35
- .join(', ')}. Layout normalization will be applied.`,
36
- );
37
- }
38
42
  for (let index = 0; index < panelConstraints.length; index++) {
39
43
  const unsafeSize = nextLayout[index];
40
44
  assert(unsafeSize != null);
@@ -9,7 +9,12 @@ import { Primitive } from '@/Primitive';
9
9
 
10
10
  export interface StepperIndicatorProps extends PrimitiveProps { }
11
11
 
12
- const props = defineProps<StepperIndicatorProps>();
12
+ const props = withDefaults(
13
+ defineProps<StepperIndicatorProps>(),
14
+ {
15
+ as: 'span',
16
+ },
17
+ );
13
18
 
14
19
  defineSlots<{
15
20
  default?: (props: {
@@ -68,12 +68,21 @@ function handleKeyDown(event: KeyboardEvent) {
68
68
 
69
69
  const { forwardRef, currentElement } = useForwardExpose();
70
70
 
71
+ let registeredElement: HTMLElement | null = null;
72
+
71
73
  onMounted(() => {
72
- rootContext.totalStepperItems.value.add(currentElement.value);
74
+ registeredElement = currentElement.value;
75
+
76
+ if (registeredElement) {
77
+ rootContext.totalStepperItems.value.add(registeredElement);
78
+ }
73
79
  });
74
80
 
75
81
  onUnmounted(() => {
76
- rootContext.totalStepperItems.value.delete(currentElement.value);
82
+ if (registeredElement) {
83
+ rootContext.totalStepperItems.value.delete(registeredElement);
84
+ registeredElement = null;
85
+ }
77
86
  });
78
87
  </script>
79
88
 
@@ -69,7 +69,7 @@ export const [injectTagsInputRootContext, provideTagsInputRootContext]
69
69
  </script>
70
70
 
71
71
  <script setup lang="ts" generic="T extends AcceptableInputValue = string">
72
- import { isFunction } from '@vinicunca/perkakas';
72
+ import { isDeepEqual, isFunction } from '@vinicunca/perkakas';
73
73
  import { useFocusWithin, useVModel } from '@vueuse/core';
74
74
  import { useCollection } from '@/Collection';
75
75
  import { Primitive } from '@/Primitive';
@@ -112,9 +112,9 @@ const currentModelValue = computed(() => Array.isArray(modelValue.value) ? [...m
112
112
 
113
113
  function handleRemoveTag(index: number) {
114
114
  if (index !== -1) {
115
- const collection = getItems().filter((i) => i.ref.dataset.disabled !== '');
115
+ const removedValue = modelValue.value[index] as T;
116
116
  modelValue.value = modelValue.value.filter((_, i) => i !== index);
117
- emits('removeTag', collection[index].value);
117
+ emits('removeTag', removedValue);
118
118
  }
119
119
  }
120
120
 
@@ -176,7 +176,9 @@ provideTagsInputRootContext({
176
176
 
177
177
  if (selectedElement.value) {
178
178
  const index = collection.findIndex((i) => i === selectedElement.value);
179
- handleRemoveTag(index);
179
+ const selectedItem = getItems().find((i) => i.ref === selectedElement.value);
180
+ const modelIndex = selectedItem ? modelValue.value.findIndex((v) => isDeepEqual(v, selectedItem.value)) : -1;
181
+ handleRemoveTag(modelIndex);
180
182
  selectedElement.value = selectedElement.value === lastTag ? collection.at(index - 1) : collection.at(index + 1);
181
183
  event.preventDefault();
182
184
  } else if (event.key === 'Backspace') {
@@ -344,7 +344,10 @@ provideTimeFieldRootContext({
344
344
  elements: segmentElements,
345
345
  setFocusedElement,
346
346
  focusNext() {
347
- nextFocusableSegment.value?.focus();
347
+ // Auto-advance follows the segments' DOM order (the locale's format
348
+ // order) regardless of writing direction; only arrow-key navigation is
349
+ // direction-aware via nextFocusableSegment/prevFocusableSegment.
350
+ Array.from(segmentElements.value)[currentSegmentIndex.value + 1]?.focus();
348
351
  },
349
352
  });
350
353
 
@@ -453,7 +453,10 @@ provideTimeRangeFieldRootContext({
453
453
  elements: segmentElements,
454
454
  setFocusedElement,
455
455
  focusNext() {
456
- nextFocusableSegment.value?.focus();
456
+ // Auto-advance follows the segments' DOM order (the locale's format
457
+ // order) regardless of writing direction; only arrow-key navigation is
458
+ // direction-aware via nextFocusableSegment/prevFocusableSegment.
459
+ Array.from(segmentElements.value)[currentSegmentIndex.value + 1]?.focus();
457
460
  },
458
461
  });
459
462
 
@@ -136,6 +136,7 @@ watchEffect((cleanupFn) => {
136
136
  remainingRaf.resume();
137
137
  emits('resume');
138
138
  };
139
+
139
140
  const handlePause = () => {
140
141
  const elapsedTime = Date.now() - closeTimerStartTimeRef.value;
141
142
  closeTimerRemainingTimeRef.value = closeTimerRemainingTimeRef.value - elapsedTime;
@@ -143,12 +144,14 @@ watchEffect((cleanupFn) => {
143
144
  remainingRaf.pause();
144
145
  emits('pause');
145
146
  };
147
+
146
148
  viewport.addEventListener(VIEWPORT_PAUSE, handlePause);
147
149
  viewport.addEventListener(VIEWPORT_RESUME, handleResume);
148
- return () => {
150
+
151
+ cleanupFn(() => {
149
152
  viewport.removeEventListener(VIEWPORT_PAUSE, handlePause);
150
153
  viewport.removeEventListener(VIEWPORT_RESUME, handleResume);
151
- };
154
+ });
152
155
  }
153
156
  });
154
157
 
@@ -8,6 +8,7 @@ import { isClient, isIOS, tryOnBeforeUnmount } from '@vueuse/shared';
8
8
  import { defu } from 'defu';
9
9
  import { computed, nextTick, ref, watch } from 'vue';
10
10
  import { injectConfigProviderContext } from '@/ConfigProvider/ConfigProvider.vue';
11
+ import { context as dismissableLayerContext } from '@/DismissableLayer/context';
11
12
 
12
13
  const useBodyLockStackCount = createSharedComposable(() => {
13
14
  const map = ref<Map<string, boolean>>(new Map());
@@ -31,7 +32,14 @@ const useBodyLockStackCount = createSharedComposable(() => {
31
32
  const resetBodyStyle = () => {
32
33
  document.body.style.paddingRight = '';
33
34
  document.body.style.marginRight = '';
34
- document.body.style.pointerEvents = '';
35
+ // A mounted `DismissableLayer` with `disableOutsidePointerEvents` may
36
+ // still own the body pointer-events lock (e.g. a modal Dialog rendered
37
+ // without the Overlay that would hold a scroll lock). Clearing it here
38
+ // would make everything behind that layer clickable again; the
39
+ // layer restores it once its last disabling layer is gone.
40
+ if (dismissableLayerContext.layersWithOutsidePointerEventsDisabled.size === 0) {
41
+ document.body.style.pointerEvents = '';
42
+ }
35
43
  document.documentElement.style.removeProperty('--scrollbar-width');
36
44
  document.body.style.overflow = initialOverflow.value ?? '';
37
45
  isIOS && stopTouchMoveListener?.();
@@ -1,10 +1,61 @@
1
- import { nextTick, ref } from 'vue';
1
+ import { computed, nextTick, ref } from 'vue';
2
+
3
+ // Scripts typed through an IME with a candidate/conversion step (Chinese,
4
+ // Japanese, Korean, Bopomofo). When the composing text contains any of these,
5
+ // the value is incomplete until `compositionend` and must not be processed early.
6
+ const imeScriptRE = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Bopomofo}]/u;
7
+ const androidRE = /android/i;
8
+
9
+ function isAndroid() {
10
+ return typeof navigator !== 'undefined' && androidRE.test(navigator.userAgent);
11
+ }
2
12
 
3
13
  export function useComposing(onEnd?: (event: CompositionEvent) => void) {
4
14
  const isComposing = ref(false);
15
+ const isImeComposition = ref(true);
16
+ // Sticky for the whole composition session: once IME script has been seen, a
17
+ // later plain-text update cannot downgrade the session back to live.
18
+ const sawImeScript = ref(false);
19
+
20
+ // Whether `input` events should wait for `compositionend` before being
21
+ // processed. Android soft keyboards (Gboard, Samsung Keyboard, …) keep the
22
+ // current Latin word in composition for autocorrect and only commit it on
23
+ // space/Enter/suggestion tap, so deferring there would freeze live filtering
24
+ // until the word is committed. IME composition still defers so
25
+ // incomplete values never leak.
26
+ //
27
+ // Known limitation: on Android, the *leading* plain-text updates of a
28
+ // transliterating IME are indistinguishable from soft-keyboard autocorrect —
29
+ // romaji-mode Japanese ("ka" → "か"), Vietnamese Telex, Thai and Indic
30
+ // transliteration all emit Latin before any IME script appears — so those
31
+ // first keystrokes do filter live. Once IME script shows up the session
32
+ // becomes deferred and stays deferred, and the committed value is always
33
+ // correct; only the transient popup state is wrong.
34
+ const shouldDeferInput = computed(() => isComposing.value && isImeComposition.value);
5
35
 
6
36
  function handleCompositionStart() {
7
37
  isComposing.value = true;
38
+ isImeComposition.value = true;
39
+ sawImeScript.value = false;
40
+ }
41
+
42
+ function handleCompositionUpdate(event: CompositionEvent) {
43
+ // Empty data (e.g. backspacing the whole composed word) keeps the previous
44
+ // classification.
45
+ if (!event.data) {
46
+ return;
47
+ }
48
+ if (imeScriptRE.test(event.data)) {
49
+ isImeComposition.value = true;
50
+ sawImeScript.value = true;
51
+ } else if (isAndroid() && !sawImeScript.value) {
52
+ // Plain-text composition on Android is the soft keyboard buffering a
53
+ // word for autocorrect — process input live. Desktop IMEs also compose
54
+ // plain Latin before conversion (e.g. Pinyin preedit "xiang" for 香)
55
+ // so everywhere else deferring stays the
56
+ // safe default.
57
+ isImeComposition.value = false;
58
+ }
8
59
  }
9
60
 
10
61
  function handleCompositionEnd(event: CompositionEvent) {
@@ -14,5 +65,5 @@ export function useComposing(onEnd?: (event: CompositionEvent) => void) {
14
65
  });
15
66
  }
16
67
 
17
- return { isComposing, handleCompositionStart, handleCompositionEnd };
68
+ return { isComposing, shouldDeferInput, handleCompositionStart, handleCompositionUpdate, handleCompositionEnd };
18
69
  }