@megafon/ui-core 9.2.2 → 9.4.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 (89) hide show
  1. package/dist/es/components/Badges/PromoBadge/PromoBadge.css +1 -1
  2. package/dist/es/components/Badges/PromoBadge/PromoBadge.d.ts +7 -0
  3. package/dist/es/components/Badges/PromoBadge/PromoBadge.js +44 -4
  4. package/dist/es/components/Chips/Chips/Chip.css +1 -1
  5. package/dist/es/components/Chips/Chips/Chip.d.ts +14 -3
  6. package/dist/es/components/Chips/Chips/Chip.js +31 -5
  7. package/dist/es/components/Chips/Chips/ChipBadge.css +1 -0
  8. package/dist/es/components/Chips/Chips/ChipBadge.d.ts +8 -0
  9. package/dist/es/components/Chips/Chips/ChipBadge.js +29 -0
  10. package/dist/es/components/Chips/Chips/Chips.css +1 -1
  11. package/dist/es/components/Chips/Chips/Chips.d.ts +6 -6
  12. package/dist/es/components/Chips/Chips/Chips.js +2 -2
  13. package/dist/es/components/Chips/Chips/components/ChipsDropdown/ChipsDropdown.css +1 -1
  14. package/dist/es/components/Chips/Chips/components/ChipsDropdown/ChipsDropdown.d.ts +6 -6
  15. package/dist/es/components/Chips/Chips/components/ChipsDropdown/ChipsDropdown.js +5 -9
  16. package/dist/es/components/Chips/Chips/components/ChipsScrollPanel/ChipsScrollPanel.css +1 -1
  17. package/dist/es/components/Chips/Chips/components/ChipsScrollPanel/ChipsScrollPanel.d.ts +6 -6
  18. package/dist/es/components/Chips/Chips/components/ChipsScrollPanel/ChipsScrollPanel.js +2 -2
  19. package/dist/es/components/Modal/Modal.css +1 -1
  20. package/dist/es/components/Modal/Modal.js +42 -10
  21. package/dist/es/components/Modal/_ModalMobile/ModalMobile.css +1 -1
  22. package/dist/es/components/Modal/_ModalMobile/ModalMobile.d.ts +1 -0
  23. package/dist/es/components/Modal/_ModalMobile/ModalMobile.js +9 -4
  24. package/dist/es/components/Modal/utils/usePreventScroll.d.ts +17 -0
  25. package/dist/es/components/Modal/utils/usePreventScroll.js +252 -0
  26. package/dist/es/components/Modal/utils/utils.d.ts +2 -1
  27. package/dist/es/components/Modal/utils/utils.js +8 -3
  28. package/dist/es/components/MultipleSelect/MultipleSelect.css +1 -0
  29. package/dist/es/components/MultipleSelect/MultipleSelect.d.ts +63 -0
  30. package/dist/es/components/MultipleSelect/MultipleSelect.js +235 -0
  31. package/dist/es/components/Tooltip/Tooltip.d.ts +6 -0
  32. package/dist/es/components/Tooltip/Tooltip.js +19 -6
  33. package/dist/es/hooks/useEvent.d.ts +3 -0
  34. package/dist/es/hooks/useEvent.js +11 -0
  35. package/dist/es/hooks/useLatest.d.ts +2 -0
  36. package/dist/es/hooks/useLatest.js +8 -0
  37. package/dist/es/hooks/useVisualViewport.d.ts +10 -0
  38. package/dist/es/hooks/useVisualViewport.js +55 -0
  39. package/dist/es/index.d.ts +3 -0
  40. package/dist/es/index.js +3 -0
  41. package/dist/es/utils/browser.d.ts +7 -0
  42. package/dist/es/utils/browser.js +30 -0
  43. package/dist/es/utils/is.d.ts +19 -0
  44. package/dist/es/utils/is.js +70 -0
  45. package/dist/lib/components/Badges/PromoBadge/PromoBadge.css +1 -1
  46. package/dist/lib/components/Badges/PromoBadge/PromoBadge.d.ts +7 -0
  47. package/dist/lib/components/Badges/PromoBadge/PromoBadge.js +45 -5
  48. package/dist/lib/components/Chips/Chips/Chip.css +1 -1
  49. package/dist/lib/components/Chips/Chips/Chip.d.ts +14 -3
  50. package/dist/lib/components/Chips/Chips/Chip.js +32 -6
  51. package/dist/lib/components/Chips/Chips/ChipBadge.css +1 -0
  52. package/dist/lib/components/Chips/Chips/ChipBadge.d.ts +8 -0
  53. package/dist/lib/components/Chips/Chips/ChipBadge.js +38 -0
  54. package/dist/lib/components/Chips/Chips/Chips.css +1 -1
  55. package/dist/lib/components/Chips/Chips/Chips.d.ts +6 -6
  56. package/dist/lib/components/Chips/Chips/Chips.js +2 -2
  57. package/dist/lib/components/Chips/Chips/components/ChipsDropdown/ChipsDropdown.css +1 -1
  58. package/dist/lib/components/Chips/Chips/components/ChipsDropdown/ChipsDropdown.d.ts +6 -6
  59. package/dist/lib/components/Chips/Chips/components/ChipsDropdown/ChipsDropdown.js +5 -9
  60. package/dist/lib/components/Chips/Chips/components/ChipsScrollPanel/ChipsScrollPanel.css +1 -1
  61. package/dist/lib/components/Chips/Chips/components/ChipsScrollPanel/ChipsScrollPanel.d.ts +6 -6
  62. package/dist/lib/components/Chips/Chips/components/ChipsScrollPanel/ChipsScrollPanel.js +2 -2
  63. package/dist/lib/components/Modal/Modal.css +1 -1
  64. package/dist/lib/components/Modal/Modal.js +41 -9
  65. package/dist/lib/components/Modal/_ModalMobile/ModalMobile.css +1 -1
  66. package/dist/lib/components/Modal/_ModalMobile/ModalMobile.d.ts +1 -0
  67. package/dist/lib/components/Modal/_ModalMobile/ModalMobile.js +9 -4
  68. package/dist/lib/components/Modal/utils/usePreventScroll.d.ts +17 -0
  69. package/dist/lib/components/Modal/utils/usePreventScroll.js +263 -0
  70. package/dist/lib/components/Modal/utils/utils.d.ts +2 -1
  71. package/dist/lib/components/Modal/utils/utils.js +9 -4
  72. package/dist/lib/components/MultipleSelect/MultipleSelect.css +1 -0
  73. package/dist/lib/components/MultipleSelect/MultipleSelect.d.ts +63 -0
  74. package/dist/lib/components/MultipleSelect/MultipleSelect.js +244 -0
  75. package/dist/lib/components/Tooltip/Tooltip.d.ts +6 -0
  76. package/dist/lib/components/Tooltip/Tooltip.js +19 -6
  77. package/dist/lib/hooks/useEvent.d.ts +3 -0
  78. package/dist/lib/hooks/useEvent.js +17 -0
  79. package/dist/lib/hooks/useLatest.d.ts +2 -0
  80. package/dist/lib/hooks/useLatest.js +14 -0
  81. package/dist/lib/hooks/useVisualViewport.d.ts +10 -0
  82. package/dist/lib/hooks/useVisualViewport.js +62 -0
  83. package/dist/lib/index.d.ts +3 -0
  84. package/dist/lib/index.js +21 -0
  85. package/dist/lib/utils/browser.d.ts +7 -0
  86. package/dist/lib/utils/browser.js +42 -0
  87. package/dist/lib/utils/is.d.ts +19 -0
  88. package/dist/lib/utils/is.js +92 -0
  89. package/package.json +2 -2
@@ -5,11 +5,15 @@ import { cnCreate, breakpoints } from '@megafon/ui-helpers';
5
5
  import throttle from 'lodash.throttle';
6
6
  import ReactModal from 'react-modal';
7
7
  import THROTTLE_TIME from "../../constants/throttleTime";
8
+ import { useEvent } from "../../hooks/useEvent";
8
9
  import usePrevious from "../../hooks/usePrevious";
9
10
  import useResolution from "../../hooks/useResolution";
11
+ import useVisualViewport from "../../hooks/useVisualViewport";
12
+ import { isIOS } from "../../utils/browser";
10
13
  import ModalDesktop from "./_ModalDesktop/ModalDesktop";
11
14
  import ModalMobile from "./_ModalMobile/ModalMobile";
12
- import { changeBodyPadding, getCorrectMaxHeight } from "./utils/utils";
15
+ import usePreventScroll from "./utils/usePreventScroll";
16
+ import { changeBodyStyles, getCorrectMaxHeight } from "./utils/utils";
13
17
  import "./Modal.css";
14
18
  var MOBILE_BIG_START = breakpoints.MOBILE_BIG_START;
15
19
  var HEIGHT_TRANSITION_PROPERTY = 'height';
@@ -29,7 +33,6 @@ export var MODAL_TRANSITIONS_STEPS_ENUM;
29
33
  MODAL_TRANSITIONS_STEPS_ENUM["MOVE_END_STEP"] = "move-end-step";
30
34
  MODAL_TRANSITIONS_STEPS_ENUM["END_STEP"] = "end-step";
31
35
  })(MODAL_TRANSITIONS_STEPS_ENUM || (MODAL_TRANSITIONS_STEPS_ENUM = {}));
32
- var bodyCn = cnCreate('mfui-9-modal-open-body');
33
36
  var cn = cnCreate('mfui-9-modal');
34
37
  var Modal = function Modal(_ref) {
35
38
  var className = _ref.className,
@@ -98,6 +101,18 @@ var Modal = function Modal(_ref) {
98
101
  var resizeObserver = React.useRef(null);
99
102
  var _useResolution = useResolution(),
100
103
  isMobile = _useResolution.isMobile;
104
+ var _useVisualViewport = useVisualViewport({
105
+ enabled: isOpened && isIOS(),
106
+ onChange: function onChange(metrics) {
107
+ document.documentElement.style.setProperty('--keyboard-offset', "".concat(metrics.keyboardOffset, "px"));
108
+ document.documentElement.style.setProperty('--viewport-height', "".concat(metrics.viewportHeight, "px"));
109
+ }
110
+ }),
111
+ isKeyboardOpen = _useVisualViewport.isKeyboardOpen,
112
+ viewportHeight = _useVisualViewport.viewportHeight;
113
+ usePreventScroll({
114
+ isDisabled: !isOpened
115
+ });
101
116
  var isFullScreenView = mobileView === 'fullScreen' && isMobile;
102
117
  var isBottomView = mobileView === 'bottom' && isMobile;
103
118
  var isBottomTransitionIn = transitionStep !== MODAL_TRANSITIONS_STEPS_ENUM.END_STEP && transitionStep !== MODAL_TRANSITIONS_STEPS_ENUM.MOVE_END_STEP;
@@ -122,7 +137,7 @@ var Modal = function Modal(_ref) {
122
137
  overlayRef.current = node;
123
138
  getModalOverlayRef === null || getModalOverlayRef === void 0 ? void 0 : getModalOverlayRef(node);
124
139
  };
125
- var handleSetScrollContentMaxHeight = React.useCallback(function () {
140
+ var handleSetScrollContentMaxHeight = useEvent(function () {
126
141
  var correctMaxHeight = getCorrectMaxHeight({
127
142
  refs: {
128
143
  overlayNode: overlayRef.current,
@@ -133,11 +148,12 @@ var Modal = function Modal(_ref) {
133
148
  props: {
134
149
  isStickyFooter: isStickyFooter,
135
150
  isBottomView: isBottomView,
136
- isStickyHeader: isStickyHeader
151
+ isStickyHeader: isStickyHeader,
152
+ availableHeight: isBottomView && isIOS() && viewportHeight ? viewportHeight : undefined
137
153
  }
138
154
  });
139
155
  setScrollMaxHeight(correctMaxHeight);
140
- }, [isStickyFooter, isBottomView, isStickyHeader]);
156
+ });
141
157
  var handleSetContainerWrapHeight = React.useCallback(function () {
142
158
  var containerInnerNode = containerInnerRef.current;
143
159
  if (!containerInnerNode) {
@@ -164,9 +180,13 @@ var Modal = function Modal(_ref) {
164
180
  handleSetScrollContentMaxHeight();
165
181
  }, [isEnabledNativeScroll, handleSetScrollContentMaxHeight]);
166
182
  var handleAfterOpen = function handleAfterOpen() {
183
+ changeBodyStyles(true);
167
184
  handleSetStyles();
168
185
  onAfterModalOpen === null || onAfterModalOpen === void 0 ? void 0 : onAfterModalOpen();
169
186
  };
187
+ var handleAfterClose = function handleAfterClose() {
188
+ changeBodyStyles(false);
189
+ };
170
190
  var handlePopupClose = function handlePopupClose() {
171
191
  setTransitionStep(MODAL_TRANSITIONS_STEPS_ENUM.END_STEP);
172
192
  };
@@ -183,7 +203,6 @@ var Modal = function Modal(_ref) {
183
203
  };
184
204
  React.useEffect(function () {
185
205
  setIsPopupOpened(isOpened);
186
- changeBodyPadding(isOpened);
187
206
  if (!isOpened) {
188
207
  setContainerWrapHeight(undefined);
189
208
  }
@@ -235,6 +254,12 @@ var Modal = function Modal(_ref) {
235
254
  }
236
255
  handleSetScrollContentMaxHeight();
237
256
  }, [isMobile, isChangeMobileView, handleSetScrollContentMaxHeight]);
257
+ React.useEffect(function () {
258
+ if (!isOpened || !isMobile || !isBottomView || !isIOS()) {
259
+ return;
260
+ }
261
+ handleSetScrollContentMaxHeight();
262
+ }, [isOpened, isMobile, isBottomView, viewportHeight, handleSetScrollContentMaxHeight]);
238
263
  React.useEffect(function () {
239
264
  if (isEnabledNativeScroll || !(isRecalculateHeight && (isHeaderPropsDiff || isFooterPropsDiff))) {
240
265
  return;
@@ -243,14 +268,19 @@ var Modal = function Modal(_ref) {
243
268
  }, [isEnabledNativeScroll, isFooterPropsDiff, isRecalculateHeight, isHeaderPropsDiff, handleSetScrollContentMaxHeight]);
244
269
  React.useEffect(function () {
245
270
  return function () {
246
- setIsPopupOpened(false);
247
- document.body.style.paddingRight = '';
248
271
  if (!containerInnerRef.current || !resizeObserver.current) {
249
272
  return;
250
273
  }
251
274
  resizeObserver.current.unobserve(containerInnerRef.current);
252
275
  };
253
276
  }, []);
277
+ React.useEffect(function () {
278
+ return function () {
279
+ if (isOpened) {
280
+ changeBodyStyles(false);
281
+ }
282
+ };
283
+ }, [isOpened]);
254
284
  var contextProps = {
255
285
  classes: classes,
256
286
  dataAttrs: dataAttrs,
@@ -290,6 +320,7 @@ var Modal = function Modal(_ref) {
290
320
  return /*#__PURE__*/React.createElement(ModalDesktop, contextProps, children);
291
321
  }
292
322
  return /*#__PURE__*/React.createElement(ModalMobile, _extends({}, contextProps, {
323
+ isKeyboardOpen: isKeyboardOpen,
293
324
  isSwipeDisabled: isSwipeDisabled,
294
325
  isFullView: isFullScreenView,
295
326
  onChangeTransitionStep: handleChangeTransitionStep,
@@ -305,7 +336,7 @@ var Modal = function Modal(_ref) {
305
336
  'native-scroll': isEnabledNativeScroll
306
337
  }, [className]),
307
338
  overlayClassName: cn('overlay', classes === null || classes === void 0 ? void 0 : classes.overlay),
308
- bodyOpenClassName: bodyCn('', classes === null || classes === void 0 ? void 0 : classes.bodyOpen),
339
+ bodyOpenClassName: classes === null || classes === void 0 ? void 0 : classes.bodyOpen,
309
340
  isOpen: isPopupOpened,
310
341
  ariaHideApp: hideAriaApp,
311
342
  contentLabel: contentLabel,
@@ -313,7 +344,8 @@ var Modal = function Modal(_ref) {
313
344
  contentRef: getModalContentRef,
314
345
  overlayRef: handleGetModalOverlayRef,
315
346
  onRequestClose: handlePopupClose,
316
- onAfterOpen: handleAfterOpen
347
+ onAfterOpen: handleAfterOpen,
348
+ onAfterClose: handleAfterClose
317
349
  }, renderContent());
318
350
  };
319
351
  export default Modal;
@@ -1 +1 @@
1
- h1,h2,h3,h4,h5{margin:0}.mfui-9-modal-mobile{width:100%}.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__container-wrap{display:block;height:calc(var(--vh)*100 - 72px);width:100%}.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__container-inner{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;height:100%}.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__container-body{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;overflow-y:auto}.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__children{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;height:100%}.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__children-content{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1}.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__scroll-content,.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__scroll-init,.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__scroll-root{height:100%}.mfui-9-modal-mobile__container-wrap{bottom:0;display:-webkit-box;display:-ms-flexbox;display:flex;position:fixed;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:end;-ms-flex-pack:end;-webkit-animation:show-popup-from-bottom .3s linear;animation:show-popup-from-bottom .3s linear;height:auto;justify-content:flex-end;max-height:100%;overflow:hidden;-webkit-transition:-webkit-transform .3s;transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s}.mfui-9-modal-mobile__container-wrap:before{content:"";display:block;-ms-flex-item-align:end;align-self:flex-end;background-color:var(--spbSky2);border-radius:10px;height:6px;margin:0 auto 8px;width:40px}.mfui-9-modal-mobile__container-wrap_move{-webkit-transition:none;transition:none}.mfui-9-modal-mobile__container-wrap_transition-end{-webkit-animation:hide-popup-to-bottom .2s linear forwards;animation:hide-popup-to-bottom .2s linear forwards}.mfui-9-modal-mobile__container-inner{-webkit-box-flex:0;-ms-flex-positive:0;border-top-left-radius:32px;border-top-right-radius:32px;flex-grow:0;height:auto;overflow:hidden}@-webkit-keyframes show-popup-from-bottom{0%{opacity:0;-webkit-transform:translateY(100%);transform:translateY(100%)}to{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes show-popup-from-bottom{0%{opacity:0;-webkit-transform:translateY(100%);transform:translateY(100%)}to{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@-webkit-keyframes hide-popup-to-bottom{0%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}to{opacity:0;-webkit-transform:translateY(100%);transform:translateY(100%)}}@keyframes hide-popup-to-bottom{0%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}to{opacity:0;-webkit-transform:translateY(100%);transform:translateY(100%)}}
1
+ h1,h2,h3,h4,h5{margin:0}.mfui-9-modal-mobile{--top-offset:72px;width:100%}.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__container-wrap{display:block;height:calc(var(--vh, 1vh)*100 - var(--top-offset));width:100%}.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__container-inner{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;height:100%}.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__container-body{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;overflow-y:auto}.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__children{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;height:100%}.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__children-content{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1}.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__scroll-content,.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__scroll-init,.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__scroll-root{height:100%}.mfui-9-modal-mobile__container-wrap{bottom:0;display:-webkit-box;display:-ms-flexbox;display:flex;position:fixed;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:end;-ms-flex-pack:end;-webkit-animation:show-popup-from-bottom .3s linear;animation:show-popup-from-bottom .3s linear;height:auto;justify-content:flex-end;max-height:100%;overflow:hidden;-webkit-transition:-webkit-transform .3s;transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s}.mfui-9-modal-mobile__container-wrap:before{content:"";display:block;-ms-flex-item-align:end;align-self:flex-end;background-color:var(--spbSky2);border-radius:10px;height:6px;margin:0 auto 8px;width:40px}.mfui-9-modal-mobile__container-wrap_move{-webkit-transition:none;transition:none}.mfui-9-modal-mobile__container-wrap_transition-end{-webkit-animation:hide-popup-to-bottom .2s linear forwards;animation:hide-popup-to-bottom .2s linear forwards}.mfui-9-modal-mobile__container-inner{-webkit-box-flex:0;-ms-flex-positive:0;border-top-left-radius:32px;border-top-right-radius:32px;flex-grow:0;height:auto;overflow:hidden}.mfui-9-modal-mobile_ios.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__container-wrap,.mfui-9-modal-mobile_ios.mfui-9-modal-mobile_keyboard-open .mfui-9-modal-mobile__container-wrap{bottom:var(--keyboard-offset,0);height:calc(var(--viewport-height) - var(--top-offset))}.mfui-9-modal-mobile_ios.mfui-9-modal-mobile_full-view .mfui-9-modal-mobile__container-wrap:after,.mfui-9-modal-mobile_ios.mfui-9-modal-mobile_keyboard-open .mfui-9-modal-mobile__container-wrap:after{background-color:var(--background);bottom:auto;content:"";display:block;height:200%;left:0;position:fixed;right:0;top:var(--viewport-height)}@-webkit-keyframes show-popup-from-bottom{0%{opacity:0;-webkit-transform:translateY(100%);transform:translateY(100%)}to{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes show-popup-from-bottom{0%{opacity:0;-webkit-transform:translateY(100%);transform:translateY(100%)}to{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@-webkit-keyframes hide-popup-to-bottom{0%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}to{opacity:0;-webkit-transform:translateY(100%);transform:translateY(100%)}}@keyframes hide-popup-to-bottom{0%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}to{opacity:0;-webkit-transform:translateY(100%);transform:translateY(100%)}}
@@ -8,6 +8,7 @@ export interface IModalMobileProps extends ModalContextPropsType {
8
8
  children?: React.ReactNode;
9
9
  onChangeTransitionStep: (value: MODAL_TRANSITIONS_STEPS_ENUM) => void;
10
10
  onChangeContainerWrapTransform: (value: string) => void;
11
+ isKeyboardOpen: boolean;
11
12
  }
12
13
  declare const ModalMobile: React.FC<IModalMobileProps>;
13
14
  export default ModalMobile;
@@ -12,6 +12,7 @@ var __rest = this && this.__rest || function (s, e) {
12
12
  };
13
13
  import * as React from 'react';
14
14
  import { cnCreate } from '@megafon/ui-helpers';
15
+ import { isIOS } from "../../../utils/browser";
15
16
  import ModalContent from "../_ModalContent/ModalContent";
16
17
  import { MODAL_TRANSITIONS_STEPS_ENUM } from "../Modal";
17
18
  import "./ModalMobile.css";
@@ -34,19 +35,21 @@ var ModalMobile = function ModalMobile(_a) {
34
35
  scrollContent = _f.scrollContent,
35
36
  restClassesScrollBar = __rest(_f, ["root", "init", "scrollContent"]),
36
37
  restScrollBarParams = __rest(_d, ["classes"]),
37
- isSwipeDisabled = _a.isSwipeDisabled,
38
38
  _a$isFullView = _a.isFullView,
39
39
  isFullView = _a$isFullView === void 0 ? true : _a$isFullView,
40
40
  children = _a.children,
41
41
  onChangeTransitionStep = _a.onChangeTransitionStep,
42
42
  onChangeContainerWrapTransform = _a.onChangeContainerWrapTransform,
43
- restProps = __rest(_a, ["classes", "scrollBarParams", "isSwipeDisabled", "isFullView", "children", "onChangeTransitionStep", "onChangeContainerWrapTransform"]);
43
+ isKeyboardOpen = _a.isKeyboardOpen,
44
+ restProps = __rest(_a, ["classes", "scrollBarParams", "isFullView", "children", "onChangeTransitionStep", "onChangeContainerWrapTransform", "isKeyboardOpen"]);
44
45
  var _restProps$refs = restProps.refs,
45
46
  containerWrapRef = _restProps$refs.containerWrapRef,
46
47
  containerInnerRef = _restProps$refs.containerInnerRef,
47
48
  scrollBarScrollableRef = _restProps$refs.scrollBarScrollableRef,
48
49
  isTransitionMoveStep = restProps.isTransitionMoveStep,
49
- isTransitionEndStep = restProps.isTransitionEndStep;
50
+ isTransitionEndStep = restProps.isTransitionEndStep,
51
+ isSwipeDisabledProps = restProps.isSwipeDisabled;
52
+ var isSwipeDisabled = isKeyboardOpen && isIOS() || isSwipeDisabledProps;
50
53
  var _React$useState = React.useState(null),
51
54
  _React$useState2 = _slicedToArray(_React$useState, 2),
52
55
  initialTouchPosition = _React$useState2[0],
@@ -118,7 +121,9 @@ var ModalMobile = function ModalMobile(_a) {
118
121
  }, [handleWindowTouchEnd, handleWindowTouchMove, isSwipeDisabled]);
119
122
  return /*#__PURE__*/React.createElement("div", {
120
123
  className: cn({
121
- 'full-view': isFullView
124
+ 'full-view': isFullView,
125
+ ios: isIOS(),
126
+ 'keyboard-open': isKeyboardOpen
122
127
  })
123
128
  }, /*#__PURE__*/React.createElement(ModalContent, _extends({}, restProps, {
124
129
  classes: _extends(_extends({}, restClasses), {
@@ -0,0 +1,17 @@
1
+ import { useEffect } from 'react';
2
+ export declare const useIsomorphicLayoutEffect: typeof useEffect;
3
+ interface PreventScrollOptions {
4
+ /** Whether the scroll lock is disabled. */
5
+ isDisabled?: boolean;
6
+ focusCallback?: () => void;
7
+ }
8
+ export declare function isScrollable(node: Element): boolean;
9
+ export declare function getScrollParent(node: Element): Element;
10
+ /**
11
+ * Prevents scrolling on the document body on mount, and
12
+ * restores it on unmount. Also ensures that content does not
13
+ * shift due to the scrollbars disappearing.
14
+ */
15
+ declare function usePreventScroll(options?: PreventScrollOptions): void;
16
+ export declare function isInput(target: Element): boolean;
17
+ export default usePreventScroll;
@@ -0,0 +1,252 @@
1
+ import "core-js/modules/es.array.iterator.js";
2
+ import "core-js/modules/es.object.to-string.js";
3
+ import "core-js/modules/es.regexp.exec.js";
4
+ import "core-js/modules/es.regexp.test.js";
5
+ import "core-js/modules/es.set.js";
6
+ import "core-js/modules/es.string.iterator.js";
7
+ import "core-js/modules/web.dom-collections.iterator.js";
8
+ // This code comes from https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/overlays/src/usePreventScroll.ts
9
+ /* eslint-disable */
10
+ import { useEffect, useLayoutEffect } from 'react';
11
+ import { isIOS } from "../../../utils/browser";
12
+ var KEYBOARD_BUFFER = 24;
13
+ export var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
14
+ function chain() {
15
+ for (var _len = arguments.length, callbacks = new Array(_len), _key = 0; _key < _len; _key++) {
16
+ callbacks[_key] = arguments[_key];
17
+ }
18
+ return function () {
19
+ for (var _i = 0, _callbacks = callbacks; _i < _callbacks.length; _i++) {
20
+ var callback = _callbacks[_i];
21
+ if (typeof callback === 'function') {
22
+ callback.apply(void 0, arguments);
23
+ }
24
+ }
25
+ };
26
+ }
27
+ // @ts-ignore
28
+ var visualViewport = typeof document !== 'undefined' && window.visualViewport;
29
+ export function isScrollable(node) {
30
+ var style = window.getComputedStyle(node);
31
+ return /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY);
32
+ }
33
+ export function getScrollParent(node) {
34
+ if (isScrollable(node)) {
35
+ node = node.parentElement;
36
+ }
37
+ while (node && !isScrollable(node)) {
38
+ node = node.parentElement;
39
+ }
40
+ return node || document.scrollingElement || document.documentElement;
41
+ }
42
+ // HTML input types that do not cause the software keyboard to appear.
43
+ var nonTextInputTypes = new Set(['checkbox', 'radio', 'range', 'color', 'file', 'image', 'button', 'submit', 'reset']);
44
+ // The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position
45
+ var preventScrollCount = 0;
46
+ var restore;
47
+ /**
48
+ * Prevents scrolling on the document body on mount, and
49
+ * restores it on unmount. Also ensures that content does not
50
+ * shift due to the scrollbars disappearing.
51
+ */
52
+ function usePreventScroll() {
53
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
54
+ var isDisabled = options.isDisabled;
55
+ useIsomorphicLayoutEffect(function () {
56
+ if (isDisabled) {
57
+ return;
58
+ }
59
+ preventScrollCount++;
60
+ if (preventScrollCount === 1) {
61
+ if (isIOS()) {
62
+ restore = preventScrollMobileSafari();
63
+ }
64
+ }
65
+ return function () {
66
+ preventScrollCount--;
67
+ if (preventScrollCount === 0) {
68
+ restore === null || restore === void 0 ? void 0 : restore();
69
+ }
70
+ };
71
+ }, [isDisabled]);
72
+ }
73
+ // Mobile Safari is a whole different beast. Even with overflow: hidden,
74
+ // it still scrolls the page in many situations:
75
+ //
76
+ // 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.
77
+ // 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of
78
+ // it, so it becomes scrollable.
79
+ // 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.
80
+ // This may cause even fixed position elements to scroll off the screen.
81
+ // 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always
82
+ // scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.
83
+ //
84
+ // In order to work around these cases, and prevent scrolling without jankiness, we do a few things:
85
+ //
86
+ // 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling
87
+ // on the window.
88
+ // 2. Prevent default on `touchmove` events inside a scrollable element when the scroll position is at the
89
+ // top or bottom. This avoids the whole page scrolling instead, but does prevent overscrolling.
90
+ // 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.
91
+ // 4. When focusing an input, apply a transform to trick Safari into thinking the input is at the top
92
+ // of the page, which prevents it from scrolling the page. After the input is focused, scroll the element
93
+ // into view ourselves, without scrolling the whole page.
94
+ // 5. Offset the body by the scroll position using a negative margin and scroll to the top. This should appear the
95
+ // same visually, but makes the actual scroll position always zero. This is required to make all of the
96
+ // above work or Safari will still try to scroll the page when focusing an input.
97
+ // 6. As a last resort, handle window scroll events, and scroll back to the top. This can happen when attempting
98
+ // to navigate to an input with the next/previous buttons that's outside a modal.
99
+ function preventScrollMobileSafari() {
100
+ var scrollable;
101
+ var lastY = 0;
102
+ var onTouchStart = function onTouchStart(e) {
103
+ // Store the nearest scrollable parent element from the element that the user touched.
104
+ scrollable = getScrollParent(e.target);
105
+ if (scrollable === document.documentElement && scrollable === document.body) {
106
+ return;
107
+ }
108
+ lastY = e.changedTouches[0].pageY;
109
+ };
110
+ var onTouchMove = function onTouchMove(e) {
111
+ // Prevent scrolling the window.
112
+ if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
113
+ e.preventDefault();
114
+ return;
115
+ }
116
+ // Prevent scrolling up when at the top and scrolling down when at the bottom
117
+ // of a nested scrollable area, otherwise mobile Safari will start scrolling
118
+ // the window instead. Unfortunately, this disables bounce scrolling when at
119
+ // the top but it's the best we can do.
120
+ var y = e.changedTouches[0].pageY;
121
+ var _scrollable = scrollable,
122
+ scrollTop = _scrollable.scrollTop;
123
+ var bottom = scrollable.scrollHeight - scrollable.clientHeight;
124
+ if (bottom === 0) {
125
+ return;
126
+ }
127
+ if (scrollTop <= 0 && y > lastY || scrollTop >= bottom && y < lastY) {
128
+ e.preventDefault();
129
+ }
130
+ lastY = y;
131
+ };
132
+ var onTouchEnd = function onTouchEnd(e) {
133
+ var target = e.target;
134
+ // Apply this change if we're not already focused on the target element
135
+ if (isInput(target) && target !== document.activeElement) {
136
+ e.preventDefault();
137
+ // Apply a transform to trick Safari into thinking the input is at the top of the page
138
+ // so it doesn't try to scroll it into view. When tapping on an input, this needs to
139
+ // be done before the "focus" event, so we have to focus the element ourselves.
140
+ target.style.transform = 'translateY(-2000px)';
141
+ target.focus();
142
+ requestAnimationFrame(function () {
143
+ target.style.transform = '';
144
+ });
145
+ }
146
+ };
147
+ var onFocus = function onFocus(e) {
148
+ var target = e.target;
149
+ if (isInput(target)) {
150
+ // Transform also needs to be applied in the focus event in cases where focus moves
151
+ // other than tapping on an input directly, e.g. the next/previous buttons in the
152
+ // software keyboard. In these cases, it seems applying the transform in the focus event
153
+ // is good enough, whereas when tapping an input, it must be done before the focus event. 🤷‍♂️
154
+ target.style.transform = 'translateY(-2000px)';
155
+ requestAnimationFrame(function () {
156
+ target.style.transform = '';
157
+ // This will have prevented the browser from scrolling the focused element into view,
158
+ // so we need to do this ourselves in a way that doesn't cause the whole page to scroll.
159
+ if (visualViewport) {
160
+ if (visualViewport.height < window.innerHeight) {
161
+ // If the keyboard is already visible, do this after one additional frame
162
+ // to wait for the transform to be removed.
163
+ requestAnimationFrame(function () {
164
+ scrollIntoView(target);
165
+ });
166
+ } else {
167
+ // Otherwise, wait for the visual viewport to resize before scrolling so we can
168
+ // measure the correct position to scroll to.
169
+ visualViewport.addEventListener('resize', function () {
170
+ return scrollIntoView(target);
171
+ }, {
172
+ once: true
173
+ });
174
+ }
175
+ }
176
+ });
177
+ }
178
+ };
179
+ var onWindowScroll = function onWindowScroll() {
180
+ // Last resort. If the window scrolled, scroll it back to the top.
181
+ // It should always be at the top because the body will have a negative margin (see below).
182
+ window.scrollTo(0, 0);
183
+ };
184
+ // Record the original scroll position so we can restore it.
185
+ // Then apply a negative margin to the body to offset it by the scroll position. This will
186
+ // enable us to scroll the window to the top, which is required for the rest of this to work.
187
+ var scrollX = window.pageXOffset;
188
+ var scrollY = window.pageYOffset;
189
+ var restoreStyles = chain(setStyle(document.documentElement, 'paddingRight', "".concat(window.innerWidth - document.documentElement.clientWidth, "px")));
190
+ // Scroll to the top. The negative margin on the body will make this appear the same.
191
+ window.scrollTo(0, 0);
192
+ var removeEvents = chain(addEvent(document, 'touchstart', onTouchStart, {
193
+ passive: false,
194
+ capture: true
195
+ }), addEvent(document, 'touchmove', onTouchMove, {
196
+ passive: false,
197
+ capture: true
198
+ }), addEvent(document, 'touchend', onTouchEnd, {
199
+ passive: false,
200
+ capture: true
201
+ }), addEvent(document, 'focus', onFocus, true), addEvent(window, 'scroll', onWindowScroll));
202
+ return function () {
203
+ // Restore styles and scroll the page back to where it was.
204
+ restoreStyles();
205
+ removeEvents();
206
+ window.scrollTo(scrollX, scrollY);
207
+ };
208
+ }
209
+ // Sets a CSS property on an element, and returns a function to revert it to the previous value.
210
+ function setStyle(element, style, value) {
211
+ // https://github.com/microsoft/TypeScript/issues/17827#issuecomment-391663310
212
+ // @ts-ignore
213
+ var cur = element.style[style];
214
+ // @ts-ignore
215
+ element.style[style] = value;
216
+ return function () {
217
+ // @ts-ignore
218
+ element.style[style] = cur;
219
+ };
220
+ }
221
+ // Adds an event listener to an element, and returns a function to remove it.
222
+ function addEvent(target, event, handler, options) {
223
+ // @ts-ignore
224
+ target.addEventListener(event, handler, options);
225
+ return function () {
226
+ // @ts-ignore
227
+ target.removeEventListener(event, handler, options);
228
+ };
229
+ }
230
+ function scrollIntoView(target) {
231
+ var root = document.scrollingElement || document.documentElement;
232
+ while (target && target !== root) {
233
+ // Find the parent scrollable element and adjust the scroll position if the target is not already in view.
234
+ var scrollable = getScrollParent(target);
235
+ if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== target) {
236
+ var scrollableTop = scrollable.getBoundingClientRect().top;
237
+ var targetTop = target.getBoundingClientRect().top;
238
+ var targetBottom = target.getBoundingClientRect().bottom;
239
+ // Buffer is needed for some edge cases
240
+ var keyboardHeight = scrollable.getBoundingClientRect().bottom + KEYBOARD_BUFFER;
241
+ if (targetBottom > keyboardHeight) {
242
+ scrollable.scrollTop += targetTop - scrollableTop;
243
+ }
244
+ }
245
+ // @ts-ignore
246
+ target = scrollable.parentElement;
247
+ }
248
+ }
249
+ export function isInput(target) {
250
+ return target instanceof HTMLInputElement && !nonTextInputTypes.has(target.type) || target instanceof HTMLTextAreaElement || target instanceof HTMLElement && target.isContentEditable;
251
+ }
252
+ export default usePreventScroll;
@@ -10,9 +10,10 @@ type CorrectMaxHeightArgsType = {
10
10
  isStickyFooter?: boolean;
11
11
  isBottomView?: boolean;
12
12
  isStickyHeader?: boolean;
13
+ availableHeight?: number;
13
14
  };
14
15
  };
15
16
  export declare const getCorrectMaxHeight: ({ refs, props }: CorrectMaxHeightArgsType) => number;
16
- export declare const changeBodyPadding: (isOpened: boolean) => void;
17
+ export declare const changeBodyStyles: (isOpened: boolean) => void;
17
18
  declare const _default: null;
18
19
  export default _default;
@@ -31,8 +31,9 @@ export var getCorrectMaxHeight = function getCorrectMaxHeight(_ref) {
31
31
  props = _ref.props;
32
32
  var isStickyFooter = props.isStickyFooter,
33
33
  isStickyHeader = props.isStickyHeader,
34
- isBottomView = props.isBottomView;
35
- var windowHeight = window.innerHeight;
34
+ isBottomView = props.isBottomView,
35
+ availableHeight = props.availableHeight;
36
+ var windowHeight = availableHeight !== null && availableHeight !== void 0 ? availableHeight : window.innerHeight;
36
37
  var windowWidth = window.innerWidth;
37
38
  var isMobile = windowWidth < breakpoints.MOBILE_BIG_START;
38
39
  var _getAdditionalSize = getAdditionalSize(refs),
@@ -48,15 +49,19 @@ export var getCorrectMaxHeight = function getCorrectMaxHeight(_ref) {
48
49
  var correctMaxHeight = isStickyFooter ? maxHeightResize - popupFooterHeight : maxHeightResize;
49
50
  return correctMaxHeight;
50
51
  };
51
- export var changeBodyPadding = function changeBodyPadding(isOpened) {
52
+ export var changeBodyStyles = function changeBodyStyles(isOpened) {
52
53
  var windowWidth = window.innerWidth;
53
54
  var documentClientWidth = document.documentElement.clientWidth;
54
55
  var scrollBarWidth = windowWidth - documentClientWidth;
55
56
  var bodyEl = document.body;
56
57
  if (!isOpened) {
57
58
  bodyEl.style.paddingRight = '';
59
+ bodyEl.style.height = '';
60
+ bodyEl.style.overflow = '';
58
61
  return;
59
62
  }
63
+ bodyEl.style.height = '100%';
64
+ bodyEl.style.overflow = 'hidden';
60
65
  if (scrollBarWidth === 0) {
61
66
  return;
62
67
  }
@@ -0,0 +1 @@
1
+ h1,h2,h3,h4,h5{margin:0}.mfui-9-multiple-select{-webkit-box-sizing:border-box;box-sizing:border-box;color:var(--content);font-family:inherit;font-size:15px;line-height:24px;position:relative;width:100%}.mfui-9-multiple-select__control{background-color:var(--base);border:1px solid var(--spbSky2);border-radius:16px;display:-webkit-box;display:-ms-flexbox;display:flex;gap:8px;height:auto;min-height:60px;outline:none;padding:13px 15px;position:relative;-webkit-transition:border-color .3s;transition:border-color .3s;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:100%}.mfui-9-multiple-select__control:hover{border-color:var(--content)}.mfui-9-multiple-select__input-container{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;gap:8px;overflow:hidden;width:100%}.mfui-9-multiple-select__arrow-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;border-radius:0;-webkit-box-sizing:border-box;box-sizing:border-box;color:inherit;cursor:pointer;font-family:inherit;font-size:inherit;line-height:inherit;margin:0;outline:none;padding:0;text-decoration:none;-webkit-tap-highlight-color:rgba(0,0,0,0);display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-negative:0;flex-shrink:0;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;border-radius:8px;justify-content:center;width:32px}.mfui-9-multiple-select__arrow-button:disabled{color:inherit;cursor:auto}.mfui-9-multiple-select__arrow-button:focus-visible{-webkit-animation:focus-outline-shrink .3s linear forwards;animation:focus-outline-shrink .3s linear forwards;outline-offset:2px}@-webkit-keyframes focus-outline-shrink{0%{outline:0 solid var(--137C)}to{outline:4px solid var(--137C)}}.mfui-9-multiple-select__arrow-button:focus{outline:none}.mfui-9-multiple-select__arrow-icon{height:auto;width:100%;fill:var(--spbSky2)}.mfui-9-multiple-select__control_active .mfui-9-multiple-select__arrow-icon{-webkit-transition-duration:.6s;transition-duration:.6s;-webkit-transition-property:color,-webkit-transform;transition-property:color,-webkit-transform;transition-property:transform,color;transition-property:transform,color,-webkit-transform;fill:var(--content)}.mfui-9-multiple-select__input{display:block;position:relative;z-index:1;-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;-ms-flex-negative:1;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;border-radius:0;-webkit-box-shadow:none;box-shadow:none;-webkit-box-sizing:border-box;box-sizing:border-box;caret-color:var(--brandGreen);color:var(--content);flex-shrink:1;font-family:inherit;font-size:100%;line-height:24px;opacity:1;outline:none;overflow:auto;padding:0;resize:none;width:100px}.mfui-9-multiple-select__input::-webkit-input-placeholder{color:var(--spbSky3)}.mfui-9-multiple-select__input::-moz-placeholder{color:var(--spbSky3)}.mfui-9-multiple-select__input:-ms-input-placeholder{color:var(--spbSky3)}.mfui-9-multiple-select__input::-ms-input-placeholder{color:var(--spbSky3)}.mfui-9-multiple-select__input::placeholder{color:var(--spbSky3)}.mfui-9-multiple-select__tag{display:-webkit-box;display:-ms-flexbox;display:flex;gap:2px;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-color:var(--spbSky0);border:none;border-radius:8px;height:32px;max-width:100%;padding:4px 6px 4px 12px}.mfui-9-multiple-select__tag-title{display:block;font-size:15px;font-weight:400;line-height:24px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mfui-9-multiple-select__tag-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;border-radius:0;-webkit-box-sizing:border-box;box-sizing:border-box;color:inherit;cursor:pointer;font-family:inherit;font-size:inherit;line-height:inherit;margin:0;outline:none;padding:0;text-decoration:none;-webkit-tap-highlight-color:rgba(0,0,0,0);border-radius:8px;height:20px;min-width:20px;width:20px}.mfui-9-multiple-select__tag-button:disabled{color:inherit;cursor:auto}.mfui-9-multiple-select__tag-button:focus-visible{-webkit-animation:focus-outline-shrink .3s linear forwards;animation:focus-outline-shrink .3s linear forwards;outline-offset:2px}@keyframes focus-outline-shrink{0%{outline:0 solid var(--137C)}to{outline:4px solid var(--137C)}}.mfui-9-multiple-select__tag-button:focus{outline:none}.mfui-9-multiple-select__tag-button-icon{-webkit-transition:fill .3s;transition:fill .3s;fill:var(--spbSky3)}.mfui-9-multiple-select__tag-button:hover .mfui-9-multiple-select__tag-button-icon{fill:var(--content)}.mfui-9-multiple-select__notice-text{color:var(--spbSky3);font-size:12px;font-weight:400;line-height:18px;margin-top:8px}.mfui-9-multiple-select_open .mfui-9-multiple-select__control{border-color:var(--content)}.mfui-9-multiple-select_open .mfui-9-multiple-select__arrow-icon{-webkit-transform:rotate(-180deg);transform:rotate(-180deg)}.mfui-9-multiple-select_disabled{pointer-events:none}.mfui-9-multiple-select_disabled .mfui-9-multiple-select__control{background-color:var(--spbSky0)}.mfui-9-multiple-select_disabled .mfui-9-multiple-select__input:not([placeholder]){width:0}.mfui-9-multiple-select_disabled .mfui-9-multiple-select__tag{background-color:var(--spbSky1)}.mfui-9-multiple-select_disabled .mfui-9-multiple-select__arrow-icon,.mfui-9-multiple-select_disabled .mfui-9-multiple-select__tag-button-icon{fill:var(--spbSky2)}
@@ -0,0 +1,63 @@
1
+ import * as React from 'react';
2
+ import './MultipleSelect.scss';
3
+ export type ItemValueType = number | string | undefined;
4
+ export type ItemType = {
5
+ /** Заголовок элемента */
6
+ title: string;
7
+ /** Уникальный идентификатор элемента */
8
+ value: ItemValueType;
9
+ };
10
+ export interface IMultipleSelectProps {
11
+ /** Дополнительный класс корневого элемента */
12
+ className?: string;
13
+ /** Элементы выпадающего списка */
14
+ items: ItemType[];
15
+ /** Список выбранных элементов */
16
+ selectedItems?: ItemType[];
17
+ /** Ограничение количества выбранных элементов */
18
+ selectLimit?: number;
19
+ /** Текст внутри поля по умолчанию */
20
+ placeholder?: string;
21
+ /** Максимальное вводимое количество символов */
22
+ maxLength?: number;
23
+ /** Текст при отсутствии результатов поиска */
24
+ notFoundText?: string;
25
+ /** Дополнительный текст под полем */
26
+ noticeText?: string;
27
+ /** Отключенное состояние */
28
+ disabled?: boolean;
29
+ /** Пользовательская функция поиска */
30
+ customSearchFilter?: (item: ItemType, searchQuery: string) => boolean;
31
+ /** Обработчик выбора элемента селекта */
32
+ onSelect?: (items: ItemType[]) => void;
33
+ /** Обработчик выхода из фокуса */
34
+ onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
35
+ /** Обработчик входа в фокус */
36
+ onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;
37
+ /** Обработчик изменения поля при поиске */
38
+ onSearch?: (query: string) => void;
39
+ /** Использование функции debounce для onSearch */
40
+ searchDelay?: number;
41
+ /** Переводит компонент в контролируемое состояние */
42
+ isControlled?: boolean;
43
+ /** Дополнительные классы для внутренних элементов */
44
+ classes?: {
45
+ root?: string;
46
+ input?: string;
47
+ list?: string;
48
+ listItem?: string;
49
+ tag?: string;
50
+ tagButton?: string;
51
+ };
52
+ /** Дополнительные data атрибуты к внутренним элементам */
53
+ dataAttrs?: {
54
+ root?: Record<string, string>;
55
+ input?: Record<string, string>;
56
+ list?: Record<string, string>;
57
+ listItem?: Record<string, string>;
58
+ tag?: Record<string, string>;
59
+ tagButton?: Record<string, string>;
60
+ };
61
+ }
62
+ declare const MultipleSelect: React.FC<IMultipleSelectProps>;
63
+ export default MultipleSelect;