@vkontakte/vkui 6.2.1 → 6.2.2

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 (109) hide show
  1. package/dist/cjs/components/Checkbox/Checkbox.d.ts.map +1 -1
  2. package/dist/cjs/components/Checkbox/Checkbox.js +10 -8
  3. package/dist/cjs/components/Checkbox/Checkbox.js.map +1 -1
  4. package/dist/cjs/components/ChipsInputBase/ChipsInputBase.d.ts.map +1 -1
  5. package/dist/cjs/components/ChipsInputBase/ChipsInputBase.js +1 -3
  6. package/dist/cjs/components/ChipsInputBase/ChipsInputBase.js.map +1 -1
  7. package/dist/cjs/components/FocusTrap/FocusTrap.d.ts.map +1 -1
  8. package/dist/cjs/components/FocusTrap/FocusTrap.js +10 -1
  9. package/dist/cjs/components/FocusTrap/FocusTrap.js.map +1 -1
  10. package/dist/cjs/components/PanelHeaderContext/PanelHeaderContext.d.ts.map +1 -1
  11. package/dist/cjs/components/PanelHeaderContext/PanelHeaderContext.js +1 -1
  12. package/dist/cjs/components/PanelHeaderContext/PanelHeaderContext.js.map +1 -1
  13. package/dist/cjs/components/Snackbar/Snackbar.d.ts +6 -0
  14. package/dist/cjs/components/Snackbar/Snackbar.d.ts.map +1 -1
  15. package/dist/cjs/components/Snackbar/Snackbar.js +3 -1
  16. package/dist/cjs/components/Snackbar/Snackbar.js.map +1 -1
  17. package/dist/cjs/components/Snackbar/types.d.ts +1 -0
  18. package/dist/cjs/components/Snackbar/types.d.ts.map +1 -1
  19. package/dist/cjs/components/Snackbar/utils.d.ts +4 -8
  20. package/dist/cjs/components/Snackbar/utils.d.ts.map +1 -1
  21. package/dist/cjs/components/Snackbar/utils.js +31 -41
  22. package/dist/cjs/components/Snackbar/utils.js.map +1 -1
  23. package/dist/cjs/helpers/array.d.ts +5 -0
  24. package/dist/cjs/helpers/array.d.ts.map +1 -0
  25. package/dist/cjs/helpers/array.js +20 -0
  26. package/dist/cjs/helpers/array.js.map +1 -0
  27. package/dist/cjs/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.d.ts.map +1 -1
  28. package/dist/cjs/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js +9 -5
  29. package/dist/cjs/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js.map +1 -1
  30. package/dist/components/Checkbox/Checkbox.d.ts.map +1 -1
  31. package/dist/components/Checkbox/Checkbox.js +10 -8
  32. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  33. package/dist/components/ChipsInputBase/ChipsInputBase.d.ts.map +1 -1
  34. package/dist/components/ChipsInputBase/ChipsInputBase.js +1 -3
  35. package/dist/components/ChipsInputBase/ChipsInputBase.js.map +1 -1
  36. package/dist/components/FocusTrap/FocusTrap.d.ts.map +1 -1
  37. package/dist/components/FocusTrap/FocusTrap.js +10 -1
  38. package/dist/components/FocusTrap/FocusTrap.js.map +1 -1
  39. package/dist/components/PanelHeaderContext/PanelHeaderContext.d.ts.map +1 -1
  40. package/dist/components/PanelHeaderContext/PanelHeaderContext.js +1 -1
  41. package/dist/components/PanelHeaderContext/PanelHeaderContext.js.map +1 -1
  42. package/dist/components/Snackbar/Snackbar.d.ts +6 -0
  43. package/dist/components/Snackbar/Snackbar.d.ts.map +1 -1
  44. package/dist/components/Snackbar/Snackbar.js +3 -1
  45. package/dist/components/Snackbar/Snackbar.js.map +1 -1
  46. package/dist/components/Snackbar/types.d.ts +1 -0
  47. package/dist/components/Snackbar/types.d.ts.map +1 -1
  48. package/dist/components/Snackbar/types.js.map +1 -1
  49. package/dist/components/Snackbar/utils.d.ts +4 -8
  50. package/dist/components/Snackbar/utils.d.ts.map +1 -1
  51. package/dist/components/Snackbar/utils.js +30 -41
  52. package/dist/components/Snackbar/utils.js.map +1 -1
  53. package/dist/components.css +2 -2
  54. package/dist/components.css.map +1 -1
  55. package/dist/components.js.tmp +101 -75
  56. package/dist/cssm/components/Checkbox/Checkbox.d.ts.map +1 -1
  57. package/dist/cssm/components/Checkbox/Checkbox.js +10 -8
  58. package/dist/cssm/components/Checkbox/Checkbox.js.map +1 -1
  59. package/dist/cssm/components/ChipsInputBase/ChipsInputBase.d.ts.map +1 -1
  60. package/dist/cssm/components/ChipsInputBase/ChipsInputBase.js +1 -3
  61. package/dist/cssm/components/ChipsInputBase/ChipsInputBase.js.map +1 -1
  62. package/dist/cssm/components/FocusTrap/FocusTrap.d.ts.map +1 -1
  63. package/dist/cssm/components/FocusTrap/FocusTrap.js +10 -1
  64. package/dist/cssm/components/FocusTrap/FocusTrap.js.map +1 -1
  65. package/dist/cssm/components/PanelHeaderContext/PanelHeaderContext.d.ts.map +1 -1
  66. package/dist/cssm/components/PanelHeaderContext/PanelHeaderContext.js +1 -1
  67. package/dist/cssm/components/PanelHeaderContext/PanelHeaderContext.js.map +1 -1
  68. package/dist/cssm/components/Search/Search.module.css +4 -5
  69. package/dist/cssm/components/Snackbar/Snackbar.d.ts +6 -0
  70. package/dist/cssm/components/Snackbar/Snackbar.d.ts.map +1 -1
  71. package/dist/cssm/components/Snackbar/Snackbar.js +3 -1
  72. package/dist/cssm/components/Snackbar/Snackbar.js.map +1 -1
  73. package/dist/cssm/components/Snackbar/Snackbar.module.css +47 -33
  74. package/dist/cssm/components/Snackbar/types.d.ts +1 -0
  75. package/dist/cssm/components/Snackbar/types.d.ts.map +1 -1
  76. package/dist/cssm/components/Snackbar/types.js.map +1 -1
  77. package/dist/cssm/components/Snackbar/utils.d.ts +4 -8
  78. package/dist/cssm/components/Snackbar/utils.d.ts.map +1 -1
  79. package/dist/cssm/components/Snackbar/utils.js +30 -41
  80. package/dist/cssm/components/Snackbar/utils.js.map +1 -1
  81. package/dist/cssm/helpers/array.d.ts +5 -0
  82. package/dist/cssm/helpers/array.d.ts.map +1 -0
  83. package/dist/cssm/helpers/array.js +10 -0
  84. package/dist/cssm/helpers/array.js.map +1 -0
  85. package/dist/cssm/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.d.ts.map +1 -1
  86. package/dist/cssm/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js +9 -5
  87. package/dist/cssm/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js.map +1 -1
  88. package/dist/helpers/array.d.ts +5 -0
  89. package/dist/helpers/array.d.ts.map +1 -0
  90. package/dist/helpers/array.js +10 -0
  91. package/dist/helpers/array.js.map +1 -0
  92. package/dist/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.d.ts.map +1 -1
  93. package/dist/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js +9 -5
  94. package/dist/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js.map +1 -1
  95. package/dist/vkui.css +2 -2
  96. package/dist/vkui.css.map +1 -1
  97. package/dist/vkui.js.tmp +101 -75
  98. package/package.json +1 -1
  99. package/src/components/Checkbox/Checkbox.tsx +11 -8
  100. package/src/components/ChipsInputBase/ChipsInputBase.tsx +1 -3
  101. package/src/components/FocusTrap/FocusTrap.tsx +10 -1
  102. package/src/components/PanelHeaderContext/PanelHeaderContext.tsx +2 -0
  103. package/src/components/Search/Search.module.css +4 -5
  104. package/src/components/Snackbar/Snackbar.module.css +47 -33
  105. package/src/components/Snackbar/Snackbar.tsx +9 -0
  106. package/src/components/Snackbar/types.ts +8 -1
  107. package/src/components/Snackbar/utils.ts +46 -42
  108. package/src/helpers/array.ts +9 -0
  109. package/src/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.ts +18 -10
package/dist/vkui.js.tmp CHANGED
@@ -4912,15 +4912,15 @@ function browser_computeBrowserInfo() {
4912
4912
  * Эмуляция функции `window.matchMedia` для SSR.
4913
4913
  *
4914
4914
  * ⚠️ Желательно избегать использование этой эмуляции в SSR.
4915
- */ function browser_mediaQueryNull(query) {
4915
+ */ function mediaQueryNull(query) {
4916
4916
  return {
4917
4917
  matches: false,
4918
4918
  media: query,
4919
- onchange: noop,
4920
- addListener: noop,
4921
- removeListener: noop,
4922
- addEventListener: noop,
4923
- removeEventListener: noop,
4919
+ onchange: functions_noop,
4920
+ addListener: functions_noop,
4921
+ removeListener: functions_noop,
4922
+ addEventListener: functions_noop,
4923
+ removeEventListener: functions_noop,
4924
4924
  dispatchEvent: function dispatchEvent() {
4925
4925
  return false;
4926
4926
  }
@@ -13127,22 +13127,26 @@ var whileElementsMounted = function() {
13127
13127
  blockMouseEnterRef.current = true;
13128
13128
  commitShownLocalState(false, 'click');
13129
13129
  });
13130
- var handleMouseEnterOnBoth = useStableCallback(function() {
13130
+ var handleMouseEnterOnBoth = useStableCallback(function(event) {
13131
+ if (willBeHide && event.currentTarget === refs.floating.current) {
13132
+ return;
13133
+ }
13131
13134
  showWithDelay.cancel();
13132
13135
  hideWithDelay.cancel();
13133
13136
  if (!blockMouseEnterRef.current && !shownLocalState.shown) {
13134
13137
  showWithDelay();
13135
13138
  }
13136
13139
  });
13137
- var handleMouseLeaveOnBothForHoverAndFocusStates = useStableCallback(function() {
13140
+ var handleMouseLeaveOnBothForHoverAndFocusStates = useStableCallback(function(event) {
13141
+ if (willBeHide && event.currentTarget === refs.floating.current) {
13142
+ return;
13143
+ }
13138
13144
  blockFocusRef.current = false;
13139
13145
  blockMouseEnterRef.current = false;
13140
13146
  if (triggerOnHover) {
13141
13147
  showWithDelay.cancel();
13142
13148
  hideWithDelay.cancel();
13143
- if (shownLocalState.reason !== 'focus' && shownLocalState.reason !== 'click') {
13144
- hideWithDelay();
13145
- }
13149
+ hideWithDelay();
13146
13150
  }
13147
13151
  });
13148
13152
  var handleFloatingAnimationStart = function() {
@@ -15021,7 +15025,7 @@ var PanelHeaderContext_sizeXClassNames = {
15021
15025
  var platform = usePlatform();
15022
15026
  var _useAdaptivity = useAdaptivity(), _useAdaptivity_sizeX = _useAdaptivity.sizeX, sizeX = _useAdaptivity_sizeX === void 0 ? 'none' : _useAdaptivity_sizeX;
15023
15027
  var elementRef = React.useRef(null);
15024
- var _useCSSKeyframesAnimationController = PanelHeaderContext_sliced_to_array(useCSSKeyframesAnimationController(opened ? 'enter' : 'exit'), 2), animationState = _useCSSKeyframesAnimationController[0], animationHandlers = _useCSSKeyframesAnimationController[1];
15028
+ var _useCSSKeyframesAnimationController = PanelHeaderContext_sliced_to_array(useCSSKeyframesAnimationController(opened ? 'enter' : 'exit', undefined, true), 2), animationState = _useCSSKeyframesAnimationController[0], animationHandlers = _useCSSKeyframesAnimationController[1];
15025
15029
  var visible = animationState !== 'exited';
15026
15030
  useScrollLock(platform !== 'vkcom' && visible);
15027
15031
  var handleGlobalOnClickOutside = React.useCallback(function(event) {
@@ -15436,20 +15440,20 @@ function SplitLayout_object_without_properties_loose(source, excluded) {
15436
15440
  var mediaQueriesCache = new WeakMap();
15437
15441
  function getMediaQueries(matchMedia) {
15438
15442
  return {
15439
- desktopPlus: matchMedia(MEDIA_QUERIES.DESKTOP_PLUS),
15440
- smallTabletPlus: matchMedia(MEDIA_QUERIES.SMALL_TABLET_PLUS),
15441
- tablet: matchMedia(MEDIA_QUERIES.TABLET),
15442
- smallTablet: matchMedia(MEDIA_QUERIES.SMALL_TABLET),
15443
- mobile: matchMedia(MEDIA_QUERIES.MOBILE),
15444
- mediumHeight: matchMedia(MEDIA_QUERIES.MEDIUM_HEIGHT),
15445
- mobileLandscapeHeight: matchMedia(MEDIA_QUERIES.MOBILE_LANDSCAPE_HEIGHT)
15443
+ desktopPlus: matchMedia(breakpoints.MEDIA_QUERIES.DESKTOP_PLUS),
15444
+ smallTabletPlus: matchMedia(breakpoints.MEDIA_QUERIES.SMALL_TABLET_PLUS),
15445
+ tablet: matchMedia(breakpoints.MEDIA_QUERIES.TABLET),
15446
+ smallTablet: matchMedia(breakpoints.MEDIA_QUERIES.SMALL_TABLET),
15447
+ mobile: matchMedia(breakpoints.MEDIA_QUERIES.MOBILE),
15448
+ mediumHeight: matchMedia(breakpoints.MEDIA_QUERIES.MEDIUM_HEIGHT),
15449
+ mobileLandscapeHeight: matchMedia(breakpoints.MEDIA_QUERIES.MOBILE_LANDSCAPE_HEIGHT)
15446
15450
  };
15447
15451
  }
15448
15452
  /**
15449
15453
  * Возвращает медиа выражения определенные дизайн-системой.
15450
15454
  */ var useMediaQueries_useMediaQueries = function() {
15451
- var window = useDOM().window;
15452
- return React.useMemo(function initializeStoreOrUpdateStoreIfWindowChanges() {
15455
+ var window = dom_useDOM().window;
15456
+ return react.useMemo(function initializeStoreOrUpdateStoreIfWindowChanges() {
15453
15457
  if (!window) {
15454
15458
  return getMediaQueries(mediaQueryNull);
15455
15459
  }
@@ -17343,6 +17347,18 @@ function useAdaptivityWithJSMediaQueries_unsupported_iterable_to_array(o, minLen
17343
17347
  return adaptivityProps;
17344
17348
  };
17345
17349
 
17350
+ ;// CONCATENATED MODULE: ./src/helpers/array.ts
17351
+ /**
17352
+ * Сравнивает два массива
17353
+ */ function arraysEquals(arrA, arrB) {
17354
+ if (arrA.length !== arrB.length) {
17355
+ return false;
17356
+ }
17357
+ return arrA.every(function(item, index) {
17358
+ return item === arrB[index];
17359
+ });
17360
+ }
17361
+
17346
17362
  ;// CONCATENATED MODULE: ./src/components/FocusTrap/FocusTrap.tsx
17347
17363
  function FocusTrap_array_like_to_array(arr, len) {
17348
17364
  if (len == null || len > arr.length) len = arr.length;
@@ -17352,6 +17368,9 @@ function FocusTrap_array_like_to_array(arr, len) {
17352
17368
  function FocusTrap_array_with_holes(arr) {
17353
17369
  if (Array.isArray(arr)) return arr;
17354
17370
  }
17371
+ function FocusTrap_array_without_holes(arr) {
17372
+ if (Array.isArray(arr)) return FocusTrap_array_like_to_array(arr);
17373
+ }
17355
17374
  function FocusTrap_define_property(obj, key, value) {
17356
17375
  if (key in obj) {
17357
17376
  Object.defineProperty(obj, key, {
@@ -17365,6 +17384,9 @@ function FocusTrap_define_property(obj, key, value) {
17365
17384
  }
17366
17385
  return obj;
17367
17386
  }
17387
+ function FocusTrap_iterable_to_array(iter) {
17388
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
17389
+ }
17368
17390
  function FocusTrap_iterable_to_array_limit(arr, i) {
17369
17391
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
17370
17392
  if (_i == null) return;
@@ -17392,6 +17414,9 @@ function FocusTrap_iterable_to_array_limit(arr, i) {
17392
17414
  function FocusTrap_non_iterable_rest() {
17393
17415
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
17394
17416
  }
17417
+ function FocusTrap_non_iterable_spread() {
17418
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
17419
+ }
17395
17420
  function FocusTrap_object_spread(target) {
17396
17421
  for(var i = 1; i < arguments.length; i++){
17397
17422
  var source = arguments[i] != null ? arguments[i] : {};
@@ -17437,6 +17462,9 @@ function FocusTrap_object_without_properties_loose(source, excluded) {
17437
17462
  function FocusTrap_sliced_to_array(arr, i) {
17438
17463
  return FocusTrap_array_with_holes(arr) || FocusTrap_iterable_to_array_limit(arr, i) || FocusTrap_unsupported_iterable_to_array(arr, i) || FocusTrap_non_iterable_rest();
17439
17464
  }
17465
+ function FocusTrap_to_consumable_array(arr) {
17466
+ return FocusTrap_array_without_holes(arr) || FocusTrap_iterable_to_array(arr) || FocusTrap_unsupported_iterable_to_array(arr) || FocusTrap_non_iterable_spread();
17467
+ }
17440
17468
  function FocusTrap_unsupported_iterable_to_array(o, minLen) {
17441
17469
  if (!o) return;
17442
17470
  if (typeof o === "string") return FocusTrap_array_like_to_array(o, minLen);
@@ -17450,6 +17478,7 @@ function FocusTrap_unsupported_iterable_to_array(o, minLen) {
17450
17478
 
17451
17479
 
17452
17480
 
17481
+
17453
17482
  var FOCUSABLE_ELEMENTS = FOCUSABLE_ELEMENTS_LIST.join();
17454
17483
  /**
17455
17484
  * @see https://vkcom.github.io/VKUI/#/FocusTrap
@@ -17472,7 +17501,9 @@ var FOCUSABLE_ELEMENTS = FOCUSABLE_ELEMENTS_LIST.join();
17472
17501
  var focusNodeByIndex = function(nodeIndex) {
17473
17502
  var element = focusableNodesRef.current[nodeIndex];
17474
17503
  if (element) {
17475
- element.focus();
17504
+ element.focus({
17505
+ preventScroll: true
17506
+ });
17476
17507
  }
17477
17508
  };
17478
17509
  var recalculateFocusableNodesRef = function(parentNode) {
@@ -17492,7 +17523,11 @@ var FOCUSABLE_ELEMENTS = FOCUSABLE_ELEMENTS_LIST.join();
17492
17523
  focusableNodesRef.current = nodes;
17493
17524
  };
17494
17525
  var onMutateParentHandler = function(parentNode) {
17526
+ var oldFocusableNodes = FocusTrap_to_consumable_array(focusableNodesRef.current);
17495
17527
  recalculateFocusableNodesRef(parentNode);
17528
+ if (arraysEquals(oldFocusableNodes, focusableNodesRef.current)) {
17529
+ return;
17530
+ }
17496
17531
  if (document) {
17497
17532
  var activeElement = document.activeElement;
17498
17533
  var currentElementIndex = Math.max(document.activeElement ? focusableNodesRef.current.indexOf(activeElement) : -1, 0);
@@ -19961,6 +19996,7 @@ function utils_object_spread_props(target, source) {
19961
19996
  return target;
19962
19997
  }
19963
19998
 
19999
+
19964
20000
  function resolveOffsetYCssStyle(placement, style, offsetY) {
19965
20001
  if (offsetY === undefined) {
19966
20002
  return style;
@@ -19980,9 +20016,10 @@ function resolveOffsetYCssStyle(placement, style, offsetY) {
19980
20016
  });
19981
20017
  }
19982
20018
  }
19983
- function getInitialShiftData(width, height) {
20019
+ function getInitialShiftData(width, height, mediaQueries) {
19984
20020
  return {
19985
20021
  shifted: false,
20022
+ isDesktop: mediaQueries.smallTabletPlus.matches,
19986
20023
  x: 0,
19987
20024
  y: 0,
19988
20025
  width: width,
@@ -19990,27 +20027,20 @@ function getInitialShiftData(width, height) {
19990
20027
  };
19991
20028
  }
19992
20029
  function getMovedShiftData(placement, shiftData, nextShift) {
19993
- switch(placement){
19994
- case 'top-start':
19995
- case 'bottom-start':
20030
+ /* istanbul ignore else: TODO чтобы протестировать кейс в блоке else, нужно мокать useMediaQueries(), чтобы перебивать mediaQueries.smallTabletPlus.matches */ if (shiftData.isDesktop) {
20031
+ if (placement.endsWith('start')) {
19996
20032
  shiftData.x = rubberbandIfOutOfBounds(nextShift.x, -shiftData.width, 0);
19997
- break;
19998
- case 'top-end':
19999
- case 'bottom-end':
20033
+ } else if (placement.endsWith('end')) {
20000
20034
  shiftData.x = rubberbandIfOutOfBounds(nextShift.x, 0, shiftData.width);
20001
- break;
20002
- }
20003
- switch(placement){
20004
- case 'top-start':
20005
- case 'top':
20006
- case 'top-end':
20007
- shiftData.y = rubberbandIfOutOfBounds(nextShift.y, -shiftData.height, 0);
20008
- break;
20009
- case 'bottom-start':
20010
- case 'bottom':
20011
- case 'bottom-end':
20035
+ }
20036
+ if (placement.startsWith('bottom')) {
20012
20037
  shiftData.y = rubberbandIfOutOfBounds(nextShift.y, 0, shiftData.height);
20013
- break;
20038
+ }
20039
+ } else if (placement.startsWith('bottom')) {
20040
+ shiftData.x = rubberbandIfOutOfBounds(nextShift.x, -shiftData.width, 0);
20041
+ }
20042
+ if (placement.startsWith('top')) {
20043
+ shiftData.y = rubberbandIfOutOfBounds(nextShift.y, -shiftData.height, 0);
20014
20044
  }
20015
20045
  shiftData.shifted = true;
20016
20046
  return shiftData;
@@ -20028,31 +20058,25 @@ function shouldBeClosedByShiftData(placement, shiftData, relativeClientRect, vel
20028
20058
  x: false,
20029
20059
  y: false
20030
20060
  };
20031
- switch(placement){
20032
- case 'top-start':
20033
- case 'bottom-start':
20061
+ /* istanbul ignore else: TODO чтобы протестировать кейс в блоке else, нужно мокать useMediaQueries(), чтобы перебивать mediaQueries.smallTabletPlus.matches */ if (shiftData.isDesktop) {
20062
+ if (placement.endsWith('start')) {
20034
20063
  shouldBeClosedThreshold.x = relativeClientRect.x < -relativeClientRect.width / 2;
20035
- shouldBeClosedByVelocity.x = velocity.x < -MINIMUM_PAN_GESTURE_FOR_TRIGGER_CLOSE;
20036
- break;
20037
- case 'top-end':
20038
- case 'bottom-end':
20064
+ shouldBeClosedByVelocity.x = relativeClientRect.x < 0 ? velocity.x < -MINIMUM_PAN_GESTURE_FOR_TRIGGER_CLOSE : false;
20065
+ } else if (placement.endsWith('end')) {
20039
20066
  shouldBeClosedThreshold.x = relativeClientRect.x > relativeClientRect.width / 2;
20040
- shouldBeClosedByVelocity.x = velocity.x > MINIMUM_PAN_GESTURE_FOR_TRIGGER_CLOSE;
20041
- break;
20042
- }
20043
- switch(placement){
20044
- case 'top-start':
20045
- case 'top':
20046
- case 'top-end':
20047
- shouldBeClosedThreshold.y = relativeClientRect.y < -relativeClientRect.height / 2;
20048
- shouldBeClosedByVelocity.y = velocity.y < -MINIMUM_PAN_GESTURE_FOR_TRIGGER_CLOSE;
20049
- break;
20050
- case 'bottom-start':
20051
- case 'bottom':
20052
- case 'bottom-end':
20067
+ shouldBeClosedByVelocity.x = relativeClientRect.x > 0 ? velocity.x > MINIMUM_PAN_GESTURE_FOR_TRIGGER_CLOSE : false;
20068
+ }
20069
+ if (placement.startsWith('bottom')) {
20053
20070
  shouldBeClosedThreshold.y = relativeClientRect.y > relativeClientRect.height / 2;
20054
- shouldBeClosedByVelocity.y = velocity.y > MINIMUM_PAN_GESTURE_FOR_TRIGGER_CLOSE;
20055
- break;
20071
+ shouldBeClosedByVelocity.y = relativeClientRect.y > 0 ? velocity.y > MINIMUM_PAN_GESTURE_FOR_TRIGGER_CLOSE : false;
20072
+ }
20073
+ } else if (placement.startsWith('bottom')) {
20074
+ shouldBeClosedThreshold.x = relativeClientRect.x < -relativeClientRect.width / 2;
20075
+ shouldBeClosedByVelocity.x = relativeClientRect.x < 0 ? velocity.x < -MINIMUM_PAN_GESTURE_FOR_TRIGGER_CLOSE : false;
20076
+ }
20077
+ if (placement.startsWith('top')) {
20078
+ shouldBeClosedThreshold.y = relativeClientRect.y < -relativeClientRect.height / 2;
20079
+ shouldBeClosedByVelocity.y = relativeClientRect.y < 0 ? velocity.y < -MINIMUM_PAN_GESTURE_FOR_TRIGGER_CLOSE : false;
20056
20080
  }
20057
20081
  return shouldBeClosedThreshold.x || shouldBeClosedByVelocity.x || shouldBeClosedThreshold.y || /* istanbul ignore next: подсвечивает жёлтым и пишет "branch not covered" */ shouldBeClosedByVelocity.y;
20058
20082
  }
@@ -20201,6 +20225,7 @@ function Snackbar_unsupported_iterable_to_array(o, minLen) {
20201
20225
 
20202
20226
 
20203
20227
 
20228
+
20204
20229
  var Snackbar_placementClassNames = {
20205
20230
  'top-start': "vkuiSnackbar--placement-top-start",
20206
20231
  'top': "vkuiSnackbar--placement-top",
@@ -20246,6 +20271,7 @@ var animationStateClassNames = {
20246
20271
  var shiftDataRef = react.useRef(null);
20247
20272
  var rafRef = react.useRef(null);
20248
20273
  var closeTimeoutIdRef = react.useRef();
20274
+ var mediaQueries = useMediaQueries_useMediaQueries();
20249
20275
  var _useCSSKeyframesAnimationController = Snackbar_sliced_to_array(useCSSKeyframesAnimationController_useCSSKeyframesAnimationController(open ? 'enter' : 'exit', {
20250
20276
  onExited: onClose
20251
20277
  }), 2), animationState = _useCSSKeyframesAnimationController[0], animationHandlers = _useCSSKeyframesAnimationController[1];
@@ -20277,7 +20303,7 @@ var animationStateClassNames = {
20277
20303
  var handleTouchStart = function(event) {
20278
20304
  panGestureRecognizer.current = new UIPanGestureRecognizer();
20279
20305
  panGestureRecognizer.current.setStartCoords(event.nativeEvent);
20280
- shiftDataRef.current = getInitialShiftData(rootRef.current.offsetWidth, rootRef.current.offsetHeight);
20306
+ shiftDataRef.current = getInitialShiftData(rootRef.current.offsetWidth, rootRef.current.offsetHeight, mediaQueries);
20281
20307
  setTouched(true);
20282
20308
  };
20283
20309
  var handleTouchMove = function(event) {
@@ -35655,9 +35681,7 @@ var ChipsInputBase_ChipsInputBase = function(_param) {
35655
35681
  if (contains(event.currentTarget, getActiveElementByAnotherElement(event.currentTarget))) {
35656
35682
  return;
35657
35683
  }
35658
- if (valueLength > 0 && listboxRef.current) {
35659
- moveFocusToChipOption(0, 'first', listboxRef.current);
35660
- } else if (inputRef.current) {
35684
+ if (inputRef.current) {
35661
35685
  inputRef.current.focus();
35662
35686
  }
35663
35687
  };
@@ -38992,6 +39016,9 @@ function Checkbox_object_without_properties_loose(source, excluded) {
38992
39016
 
38993
39017
 
38994
39018
 
39019
+ function setIndeterminate(el, indeterminate) {
39020
+ el.indeterminate = indeterminate;
39021
+ }
38995
39022
  var Checkbox_sizeYClassNames = Checkbox_define_property({
38996
39023
  none: "vkuiCheckbox--sizeY-none"
38997
39024
  }, 'compact', "vkuiCheckbox--sizeY-compact");
@@ -39021,9 +39048,9 @@ var Checkbox_warn = warnOnce('Checkbox');
39021
39048
  var _useAdaptivity = useAdaptivity(), _useAdaptivity_sizeY = _useAdaptivity.sizeY, sizeY = _useAdaptivity_sizeY === void 0 ? 'none' : _useAdaptivity_sizeY;
39022
39049
  var _useAdaptivityConditionalRender = useAdaptivityConditionalRender(), adaptiveSizeY = _useAdaptivityConditionalRender.sizeY;
39023
39050
  React.useEffect(function() {
39024
- var indeterminateValue = indeterminate === undefined ? defaultIndeterminate : indeterminate;
39051
+ var indeterminateValue = indeterminate !== null && indeterminate !== void 0 ? indeterminate : Boolean(defaultIndeterminate);
39025
39052
  if (inputRef.current) {
39026
- inputRef.current.indeterminate = Boolean(indeterminateValue);
39053
+ setIndeterminate(inputRef.current, indeterminateValue);
39027
39054
  }
39028
39055
  }, [
39029
39056
  defaultIndeterminate,
@@ -39031,19 +39058,18 @@ var Checkbox_warn = warnOnce('Checkbox');
39031
39058
  inputRef
39032
39059
  ]);
39033
39060
  var handleChange = React.useCallback(function(event) {
39034
- if (defaultIndeterminate !== undefined && indeterminate === undefined && restProps.checked === undefined && inputRef.current) {
39035
- inputRef.current.indeterminate = false;
39061
+ if (defaultIndeterminate !== undefined && indeterminate === undefined && restProps.checked === undefined) {
39062
+ event.currentTarget.indeterminate = false;
39036
39063
  }
39037
- if (indeterminate !== undefined && inputRef.current) {
39038
- inputRef.current.indeterminate = indeterminate;
39064
+ if (indeterminate !== undefined) {
39065
+ event.currentTarget.indeterminate = indeterminate;
39039
39066
  }
39040
39067
  onChange && onChange(event);
39041
39068
  }, [
39042
39069
  defaultIndeterminate,
39043
39070
  indeterminate,
39044
39071
  restProps.checked,
39045
- onChange,
39046
- inputRef
39072
+ onChange
39047
39073
  ]);
39048
39074
  if (false) {}
39049
39075
  return /*#__PURE__*/ React.createElement(Tappable, {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "6.2.1",
2
+ "version": "6.2.2",
3
3
  "name": "@vkontakte/vkui",
4
4
  "description": "VKUI library",
5
5
  "main": "dist/cjs/index.js",
@@ -20,6 +20,10 @@ import { Text } from '../Typography/Text/Text';
20
20
  import { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden';
21
21
  import styles from './Checkbox.module.css';
22
22
 
23
+ function setIndeterminate(el: HTMLInputElement, indeterminate: boolean) {
24
+ el.indeterminate = indeterminate;
25
+ }
26
+
23
27
  const sizeYClassNames = {
24
28
  none: styles['Checkbox--sizeY-none'],
25
29
  ['compact']: styles['Checkbox--sizeY-compact'],
@@ -68,10 +72,10 @@ export const Checkbox = ({
68
72
  const { sizeY: adaptiveSizeY } = useAdaptivityConditionalRender();
69
73
 
70
74
  React.useEffect(() => {
71
- const indeterminateValue = indeterminate === undefined ? defaultIndeterminate : indeterminate;
75
+ const indeterminateValue = indeterminate ?? Boolean(defaultIndeterminate);
72
76
 
73
77
  if (inputRef.current) {
74
- inputRef.current.indeterminate = Boolean(indeterminateValue);
78
+ setIndeterminate(inputRef.current, indeterminateValue);
75
79
  }
76
80
  }, [defaultIndeterminate, indeterminate, inputRef]);
77
81
 
@@ -80,17 +84,16 @@ export const Checkbox = ({
80
84
  if (
81
85
  defaultIndeterminate !== undefined &&
82
86
  indeterminate === undefined &&
83
- restProps.checked === undefined &&
84
- inputRef.current
87
+ restProps.checked === undefined
85
88
  ) {
86
- inputRef.current.indeterminate = false;
89
+ event.currentTarget.indeterminate = false;
87
90
  }
88
- if (indeterminate !== undefined && inputRef.current) {
89
- inputRef.current.indeterminate = indeterminate;
91
+ if (indeterminate !== undefined) {
92
+ event.currentTarget.indeterminate = indeterminate;
90
93
  }
91
94
  onChange && onChange(event);
92
95
  },
93
- [defaultIndeterminate, indeterminate, restProps.checked, onChange, inputRef],
96
+ [defaultIndeterminate, indeterminate, restProps.checked, onChange],
94
97
  );
95
98
 
96
99
  if (process.env.NODE_ENV === 'development') {
@@ -181,9 +181,7 @@ export const ChipsInputBase = <O extends ChipOption>({
181
181
  return;
182
182
  }
183
183
 
184
- if (valueLength > 0 && listboxRef.current) {
185
- moveFocusToChipOption(0, 'first', listboxRef.current);
186
- } else if (inputRef.current) {
184
+ if (inputRef.current) {
187
185
  inputRef.current.focus();
188
186
  }
189
187
  };
@@ -1,4 +1,5 @@
1
1
  import { AllHTMLAttributes, useCallback, useRef, useState } from 'react';
2
+ import { arraysEquals } from '../../helpers/array';
2
3
  import { useExternRef } from '../../hooks/useExternRef';
3
4
  import { FOCUSABLE_ELEMENTS_LIST, Keys, pressedKey } from '../../lib/accessibility';
4
5
  import {
@@ -53,7 +54,9 @@ export const FocusTrap = <T extends HTMLElement = HTMLElement>({
53
54
  const element = focusableNodesRef.current[nodeIndex];
54
55
 
55
56
  if (element) {
56
- element.focus();
57
+ element.focus({
58
+ preventScroll: true,
59
+ });
57
60
  }
58
61
  };
59
62
 
@@ -77,8 +80,14 @@ export const FocusTrap = <T extends HTMLElement = HTMLElement>({
77
80
  };
78
81
 
79
82
  const onMutateParentHandler = (parentNode: HTMLElement) => {
83
+ const oldFocusableNodes = [...focusableNodesRef.current];
84
+
80
85
  recalculateFocusableNodesRef(parentNode);
81
86
 
87
+ if (arraysEquals(oldFocusableNodes, focusableNodesRef.current)) {
88
+ return;
89
+ }
90
+
82
91
  if (document) {
83
92
  const activeElement = document.activeElement as HTMLElement;
84
93
  const currentElementIndex = Math.max(
@@ -35,6 +35,8 @@ export const PanelHeaderContext = ({
35
35
  const elementRef = React.useRef<HTMLDivElement>(null);
36
36
  const [animationState, animationHandlers] = useCSSKeyframesAnimationController(
37
37
  opened ? 'enter' : 'exit',
38
+ undefined,
39
+ true,
38
40
  );
39
41
  const visible = animationState !== 'exited';
40
42
 
@@ -159,21 +159,20 @@
159
159
 
160
160
  .Search__after {
161
161
  flex: 0;
162
- transform: translate(50%);
163
162
  transform-origin: left;
164
163
  min-inline-size: initial;
165
164
  max-inline-size: min-content;
166
165
  pointer-events: none;
167
- transition:
168
- flex 0.3s var(--vkui--animation_easing_platform),
169
- transform 0.3s var(--vkui--animation_easing_platform);
166
+ transition-timing-function: var(--vkui--animation_easing_platform);
167
+ transition-duration: 0.3s;
168
+ transition-property: flex, margin-inline;
170
169
  overflow: hidden;
170
+ margin-inline: 0;
171
171
  }
172
172
 
173
173
  .Search--focused .Search__after,
174
174
  .Search--has-value .Search__after {
175
175
  flex: 1;
176
- transform: translate(0);
177
176
  pointer-events: initial;
178
177
  margin-inline: 4px calc(4px - var(--vkui--size_base_padding_horizontal--regular));
179
178
  }
@@ -4,7 +4,7 @@
4
4
  --vkui_internal--snackbar_shift_x: 0;
5
5
  --vkui_internal--snackbar_shift_y: 0;
6
6
  --vkui_internal--snackbar_animation_from: translate3d(0, 0, 0);
7
- --vkui_internal--snackbar_animation_to: translate3d(0, var(--vkui_internal--snackbar_shift_y), 0);
7
+ --vkui_internal--snackbar_animation_to: translate3d(0, 0, 0);
8
8
  --vkui_internal--snackbar_animation_duration: 340ms;
9
9
 
10
10
  position: fixed;
@@ -22,6 +22,7 @@
22
22
  .Snackbar--placement-top,
23
23
  .Snackbar--placement-top-end {
24
24
  --vkui_internal--snackbar_animation_from: translate3d(0, -100%, 0);
25
+ --vkui_internal--snackbar_animation_to: translate3d(0, var(--vkui_internal--snackbar_shift_y), 0);
25
26
 
26
27
  inset-block-start: var(--vkui_internal--safe_area_inset_top);
27
28
  }
@@ -29,7 +30,8 @@
29
30
  .Snackbar--placement-bottom-start,
30
31
  .Snackbar--placement-bottom,
31
32
  .Snackbar--placement-bottom-end {
32
- --vkui_internal--snackbar_animation_from: translate3d(0, 100%, 0);
33
+ --vkui_internal--snackbar_animation_from: translate3d(-100%, 0, 0);
34
+ --vkui_internal--snackbar_animation_to: translate3d(var(--vkui_internal--snackbar_shift_x), 0, 0);
33
35
 
34
36
  inset-block-end: var(--vkui_internal--snackbar_safe_area_inset_bottom);
35
37
  }
@@ -42,23 +44,26 @@
42
44
 
43
45
  .Snackbar--placement-top,
44
46
  .Snackbar--placement-bottom {
45
- inset-inline: 0;
46
47
  margin-inline: auto;
47
48
  }
48
49
 
49
- .Snackbar--placement-top-start,
50
- .Snackbar--placement-top-end {
51
- inset-block-start: var(--vkui_internal--safe_area_inset_top);
52
- }
53
-
54
- .Snackbar--placement-bottom-start,
55
- .Snackbar--placement-bottom-end {
56
- inset-block-end: var(--vkui_internal--snackbar_safe_area_inset_bottom);
50
+ .Snackbar--placement-bottom {
51
+ --vkui_internal--snackbar_animation_from: translate3d(0, 100%, 0);
52
+ --vkui_internal--snackbar_animation_to: translate3d(
53
+ 0,
54
+ var(--vkui_internal--snackbar_shift_y),
55
+ 0
56
+ );
57
57
  }
58
58
 
59
59
  .Snackbar--placement-top-start,
60
60
  .Snackbar--placement-bottom-start {
61
61
  --vkui_internal--snackbar_animation_from: translate3d(-100%, 0, 0);
62
+ --vkui_internal--snackbar_animation_to: translate3d(
63
+ var(--vkui_internal--snackbar_shift_x),
64
+ 0,
65
+ 0
66
+ );
62
67
 
63
68
  inset-inline-start: var(--vkui_internal--safe_area_inset_left);
64
69
  inset-inline-end: auto;
@@ -67,20 +72,14 @@
67
72
  .Snackbar--placement-top-end,
68
73
  .Snackbar--placement-bottom-end {
69
74
  --vkui_internal--snackbar_animation_from: translate3d(100%, 0, 0);
70
-
71
- inset-inline-start: auto;
72
- inset-inline-end: var(--vkui_internal--safe_area_inset_right);
73
- }
74
-
75
- .Snackbar--placement-top-start,
76
- .Snackbar--placement-bottom-start,
77
- .Snackbar--placement-top-end,
78
- .Snackbar--placement-bottom-end {
79
75
  --vkui_internal--snackbar_animation_to: translate3d(
80
76
  var(--vkui_internal--snackbar_shift_x),
81
77
  0,
82
78
  0
83
79
  );
80
+
81
+ inset-inline-start: auto;
82
+ inset-inline-end: var(--vkui_internal--safe_area_inset_right);
84
83
  }
85
84
  }
86
85
 
@@ -89,9 +88,37 @@
89
88
  animation-duration: var(--vkui_internal--snackbar_animation_duration);
90
89
  animation-timing-function: var(--vkui--animation_easing_platform);
91
90
  animation-fill-mode: both;
91
+ }
92
+
93
+ .Snackbar--placement-top-start .Snackbar__in,
94
+ .Snackbar--placement-top .Snackbar__in,
95
+ .Snackbar--placement-top-end .Snackbar__in {
92
96
  transform: translate3d(0, var(--vkui_internal--snackbar_shift_y), 0);
93
97
  }
94
98
 
99
+ .Snackbar--placement-bottom-start .Snackbar__in,
100
+ .Snackbar--placement-bottom .Snackbar__in,
101
+ .Snackbar--placement-bottom-end .Snackbar__in {
102
+ transform: translate3d(var(--vkui_internal--snackbar_shift_x), 0, 0);
103
+ }
104
+
105
+ @media (--desktop) {
106
+ .Snackbar__in {
107
+ --vkui_internal--snackbar_in_padding: 12px;
108
+ }
109
+
110
+ .Snackbar--placement-top-start .Snackbar__in,
111
+ .Snackbar--placement-bottom-start .Snackbar__in,
112
+ .Snackbar--placement-top-end .Snackbar__in,
113
+ .Snackbar--placement-bottom-end .Snackbar__in {
114
+ transform: translate3d(var(--vkui_internal--snackbar_shift_x), 0, 0);
115
+ }
116
+
117
+ .Snackbar--placement-bottom .Snackbar__in {
118
+ transform: translate3d(0, var(--vkui_internal--snackbar_shift_y), 0);
119
+ }
120
+ }
121
+
95
122
  .Snackbar--state-enter .Snackbar__in,
96
123
  .Snackbar--state-entering .Snackbar__in {
97
124
  animation-name: animation-snackbar-slide-in;
@@ -126,19 +153,6 @@
126
153
  }
127
154
  } /* stylelint-disable-next-line at-rule-empty-line-before */
128
155
 
129
- @media (--desktop) {
130
- .Snackbar__in {
131
- --vkui_internal--snackbar_in_padding: 12px;
132
- }
133
-
134
- .Snackbar--placement-top-start .Snackbar__in,
135
- .Snackbar--placement-bottom-start .Snackbar__in,
136
- .Snackbar--placement-top-end .Snackbar__in,
137
- .Snackbar--placement-bottom-end .Snackbar__in {
138
- transform: translate3d(var(--vkui_internal--snackbar_shift_x), 0, 0);
139
- }
140
- }
141
-
142
156
  @keyframes animation-snackbar-slide-in {
143
157
  from {
144
158
  opacity: 0;