@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
@@ -12,10 +12,14 @@ var _uiHelpers = require("@megafon/ui-helpers");
12
12
  var _lodash = _interopRequireDefault(require("lodash.throttle"));
13
13
  var _reactModal = _interopRequireDefault(require("react-modal"));
14
14
  var _throttleTime = _interopRequireDefault(require("../../constants/throttleTime"));
15
+ var _useEvent = require("../../hooks/useEvent");
15
16
  var _usePrevious = _interopRequireDefault(require("../../hooks/usePrevious"));
16
17
  var _useResolution2 = _interopRequireDefault(require("../../hooks/useResolution"));
18
+ var _useVisualViewport2 = _interopRequireDefault(require("../../hooks/useVisualViewport"));
19
+ var _browser = require("../../utils/browser");
17
20
  var _ModalDesktop = _interopRequireDefault(require("./_ModalDesktop/ModalDesktop"));
18
21
  var _ModalMobile = _interopRequireDefault(require("./_ModalMobile/ModalMobile"));
22
+ var _usePreventScroll = _interopRequireDefault(require("./utils/usePreventScroll"));
19
23
  var _utils = require("./utils/utils");
20
24
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
21
25
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
@@ -38,7 +42,6 @@ var MODAL_TRANSITIONS_STEPS_ENUM;
38
42
  MODAL_TRANSITIONS_STEPS_ENUM["MOVE_END_STEP"] = "move-end-step";
39
43
  MODAL_TRANSITIONS_STEPS_ENUM["END_STEP"] = "end-step";
40
44
  })(MODAL_TRANSITIONS_STEPS_ENUM || (exports.MODAL_TRANSITIONS_STEPS_ENUM = MODAL_TRANSITIONS_STEPS_ENUM = {}));
41
- var bodyCn = (0, _uiHelpers.cnCreate)('mfui-9-modal-open-body');
42
45
  var cn = (0, _uiHelpers.cnCreate)('mfui-9-modal');
43
46
  var Modal = function Modal(_ref) {
44
47
  var className = _ref.className,
@@ -107,6 +110,18 @@ var Modal = function Modal(_ref) {
107
110
  var resizeObserver = React.useRef(null);
108
111
  var _useResolution = (0, _useResolution2["default"])(),
109
112
  isMobile = _useResolution.isMobile;
113
+ var _useVisualViewport = (0, _useVisualViewport2["default"])({
114
+ enabled: isOpened && (0, _browser.isIOS)(),
115
+ onChange: function onChange(metrics) {
116
+ document.documentElement.style.setProperty('--keyboard-offset', "".concat(metrics.keyboardOffset, "px"));
117
+ document.documentElement.style.setProperty('--viewport-height', "".concat(metrics.viewportHeight, "px"));
118
+ }
119
+ }),
120
+ isKeyboardOpen = _useVisualViewport.isKeyboardOpen,
121
+ viewportHeight = _useVisualViewport.viewportHeight;
122
+ (0, _usePreventScroll["default"])({
123
+ isDisabled: !isOpened
124
+ });
110
125
  var isFullScreenView = mobileView === 'fullScreen' && isMobile;
111
126
  var isBottomView = mobileView === 'bottom' && isMobile;
112
127
  var isBottomTransitionIn = transitionStep !== MODAL_TRANSITIONS_STEPS_ENUM.END_STEP && transitionStep !== MODAL_TRANSITIONS_STEPS_ENUM.MOVE_END_STEP;
@@ -131,7 +146,7 @@ var Modal = function Modal(_ref) {
131
146
  overlayRef.current = node;
132
147
  getModalOverlayRef === null || getModalOverlayRef === void 0 ? void 0 : getModalOverlayRef(node);
133
148
  };
134
- var handleSetScrollContentMaxHeight = React.useCallback(function () {
149
+ var handleSetScrollContentMaxHeight = (0, _useEvent.useEvent)(function () {
135
150
  var correctMaxHeight = (0, _utils.getCorrectMaxHeight)({
136
151
  refs: {
137
152
  overlayNode: overlayRef.current,
@@ -142,11 +157,12 @@ var Modal = function Modal(_ref) {
142
157
  props: {
143
158
  isStickyFooter: isStickyFooter,
144
159
  isBottomView: isBottomView,
145
- isStickyHeader: isStickyHeader
160
+ isStickyHeader: isStickyHeader,
161
+ availableHeight: isBottomView && (0, _browser.isIOS)() && viewportHeight ? viewportHeight : undefined
146
162
  }
147
163
  });
148
164
  setScrollMaxHeight(correctMaxHeight);
149
- }, [isStickyFooter, isBottomView, isStickyHeader]);
165
+ });
150
166
  var handleSetContainerWrapHeight = React.useCallback(function () {
151
167
  var containerInnerNode = containerInnerRef.current;
152
168
  if (!containerInnerNode) {
@@ -173,9 +189,13 @@ var Modal = function Modal(_ref) {
173
189
  handleSetScrollContentMaxHeight();
174
190
  }, [isEnabledNativeScroll, handleSetScrollContentMaxHeight]);
175
191
  var handleAfterOpen = function handleAfterOpen() {
192
+ (0, _utils.changeBodyStyles)(true);
176
193
  handleSetStyles();
177
194
  onAfterModalOpen === null || onAfterModalOpen === void 0 ? void 0 : onAfterModalOpen();
178
195
  };
196
+ var handleAfterClose = function handleAfterClose() {
197
+ (0, _utils.changeBodyStyles)(false);
198
+ };
179
199
  var handlePopupClose = function handlePopupClose() {
180
200
  setTransitionStep(MODAL_TRANSITIONS_STEPS_ENUM.END_STEP);
181
201
  };
@@ -192,7 +212,6 @@ var Modal = function Modal(_ref) {
192
212
  };
193
213
  React.useEffect(function () {
194
214
  setIsPopupOpened(isOpened);
195
- (0, _utils.changeBodyPadding)(isOpened);
196
215
  if (!isOpened) {
197
216
  setContainerWrapHeight(undefined);
198
217
  }
@@ -244,6 +263,12 @@ var Modal = function Modal(_ref) {
244
263
  }
245
264
  handleSetScrollContentMaxHeight();
246
265
  }, [isMobile, isChangeMobileView, handleSetScrollContentMaxHeight]);
266
+ React.useEffect(function () {
267
+ if (!isOpened || !isMobile || !isBottomView || !(0, _browser.isIOS)()) {
268
+ return;
269
+ }
270
+ handleSetScrollContentMaxHeight();
271
+ }, [isOpened, isMobile, isBottomView, viewportHeight, handleSetScrollContentMaxHeight]);
247
272
  React.useEffect(function () {
248
273
  if (isEnabledNativeScroll || !(isRecalculateHeight && (isHeaderPropsDiff || isFooterPropsDiff))) {
249
274
  return;
@@ -252,14 +277,19 @@ var Modal = function Modal(_ref) {
252
277
  }, [isEnabledNativeScroll, isFooterPropsDiff, isRecalculateHeight, isHeaderPropsDiff, handleSetScrollContentMaxHeight]);
253
278
  React.useEffect(function () {
254
279
  return function () {
255
- setIsPopupOpened(false);
256
- document.body.style.paddingRight = '';
257
280
  if (!containerInnerRef.current || !resizeObserver.current) {
258
281
  return;
259
282
  }
260
283
  resizeObserver.current.unobserve(containerInnerRef.current);
261
284
  };
262
285
  }, []);
286
+ React.useEffect(function () {
287
+ return function () {
288
+ if (isOpened) {
289
+ (0, _utils.changeBodyStyles)(false);
290
+ }
291
+ };
292
+ }, [isOpened]);
263
293
  var contextProps = {
264
294
  classes: classes,
265
295
  dataAttrs: dataAttrs,
@@ -299,6 +329,7 @@ var Modal = function Modal(_ref) {
299
329
  return /*#__PURE__*/React.createElement(_ModalDesktop["default"], contextProps, children);
300
330
  }
301
331
  return /*#__PURE__*/React.createElement(_ModalMobile["default"], (0, _extends2["default"])({}, contextProps, {
332
+ isKeyboardOpen: isKeyboardOpen,
302
333
  isSwipeDisabled: isSwipeDisabled,
303
334
  isFullView: isFullScreenView,
304
335
  onChangeTransitionStep: handleChangeTransitionStep,
@@ -314,7 +345,7 @@ var Modal = function Modal(_ref) {
314
345
  'native-scroll': isEnabledNativeScroll
315
346
  }, [className]),
316
347
  overlayClassName: cn('overlay', classes === null || classes === void 0 ? void 0 : classes.overlay),
317
- bodyOpenClassName: bodyCn('', classes === null || classes === void 0 ? void 0 : classes.bodyOpen),
348
+ bodyOpenClassName: classes === null || classes === void 0 ? void 0 : classes.bodyOpen,
318
349
  isOpen: isPopupOpened,
319
350
  ariaHideApp: hideAriaApp,
320
351
  contentLabel: contentLabel,
@@ -322,7 +353,8 @@ var Modal = function Modal(_ref) {
322
353
  contentRef: getModalContentRef,
323
354
  overlayRef: handleGetModalOverlayRef,
324
355
  onRequestClose: handlePopupClose,
325
- onAfterOpen: handleAfterOpen
356
+ onAfterOpen: handleAfterOpen,
357
+ onAfterClose: handleAfterClose
326
358
  }, renderContent());
327
359
  };
328
360
  var _default = exports["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;
@@ -11,6 +11,7 @@ require("core-js/modules/es.symbol.js");
11
11
  require("core-js/modules/es.array.index-of.js");
12
12
  var React = _interopRequireWildcard(require("react"));
13
13
  var _uiHelpers = require("@megafon/ui-helpers");
14
+ var _browser = require("../../../utils/browser");
14
15
  var _ModalContent = _interopRequireDefault(require("../_ModalContent/ModalContent"));
15
16
  var _Modal = require("../Modal");
16
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -43,19 +44,21 @@ var ModalMobile = function ModalMobile(_a) {
43
44
  scrollContent = _f.scrollContent,
44
45
  restClassesScrollBar = __rest(_f, ["root", "init", "scrollContent"]),
45
46
  restScrollBarParams = __rest(_d, ["classes"]),
46
- isSwipeDisabled = _a.isSwipeDisabled,
47
47
  _a$isFullView = _a.isFullView,
48
48
  isFullView = _a$isFullView === void 0 ? true : _a$isFullView,
49
49
  children = _a.children,
50
50
  onChangeTransitionStep = _a.onChangeTransitionStep,
51
51
  onChangeContainerWrapTransform = _a.onChangeContainerWrapTransform,
52
- restProps = __rest(_a, ["classes", "scrollBarParams", "isSwipeDisabled", "isFullView", "children", "onChangeTransitionStep", "onChangeContainerWrapTransform"]);
52
+ isKeyboardOpen = _a.isKeyboardOpen,
53
+ restProps = __rest(_a, ["classes", "scrollBarParams", "isFullView", "children", "onChangeTransitionStep", "onChangeContainerWrapTransform", "isKeyboardOpen"]);
53
54
  var _restProps$refs = restProps.refs,
54
55
  containerWrapRef = _restProps$refs.containerWrapRef,
55
56
  containerInnerRef = _restProps$refs.containerInnerRef,
56
57
  scrollBarScrollableRef = _restProps$refs.scrollBarScrollableRef,
57
58
  isTransitionMoveStep = restProps.isTransitionMoveStep,
58
- isTransitionEndStep = restProps.isTransitionEndStep;
59
+ isTransitionEndStep = restProps.isTransitionEndStep,
60
+ isSwipeDisabledProps = restProps.isSwipeDisabled;
61
+ var isSwipeDisabled = isKeyboardOpen && (0, _browser.isIOS)() || isSwipeDisabledProps;
59
62
  var _React$useState = React.useState(null),
60
63
  _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
61
64
  initialTouchPosition = _React$useState2[0],
@@ -127,7 +130,9 @@ var ModalMobile = function ModalMobile(_a) {
127
130
  }, [handleWindowTouchEnd, handleWindowTouchMove, isSwipeDisabled]);
128
131
  return /*#__PURE__*/React.createElement("div", {
129
132
  className: cn({
130
- 'full-view': isFullView
133
+ 'full-view': isFullView,
134
+ ios: (0, _browser.isIOS)(),
135
+ 'keyboard-open': isKeyboardOpen
131
136
  })
132
137
  }, /*#__PURE__*/React.createElement(_ModalContent["default"], (0, _extends2["default"])({}, restProps, {
133
138
  classes: (0, _extends2["default"])((0, _extends2["default"])({}, 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,263 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ exports.getScrollParent = getScrollParent;
8
+ exports.isInput = isInput;
9
+ exports.isScrollable = isScrollable;
10
+ exports.useIsomorphicLayoutEffect = void 0;
11
+ require("core-js/modules/es.array.iterator.js");
12
+ require("core-js/modules/es.object.to-string.js");
13
+ require("core-js/modules/es.regexp.exec.js");
14
+ require("core-js/modules/es.regexp.test.js");
15
+ require("core-js/modules/es.set.js");
16
+ require("core-js/modules/es.string.iterator.js");
17
+ require("core-js/modules/web.dom-collections.iterator.js");
18
+ var _react = require("react");
19
+ var _browser = require("../../../utils/browser");
20
+ // This code comes from https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/overlays/src/usePreventScroll.ts
21
+ /* eslint-disable */
22
+
23
+ var KEYBOARD_BUFFER = 24;
24
+ var useIsomorphicLayoutEffect = exports.useIsomorphicLayoutEffect = typeof window !== 'undefined' ? _react.useLayoutEffect : _react.useEffect;
25
+ function chain() {
26
+ for (var _len = arguments.length, callbacks = new Array(_len), _key = 0; _key < _len; _key++) {
27
+ callbacks[_key] = arguments[_key];
28
+ }
29
+ return function () {
30
+ for (var _i = 0, _callbacks = callbacks; _i < _callbacks.length; _i++) {
31
+ var callback = _callbacks[_i];
32
+ if (typeof callback === 'function') {
33
+ callback.apply(void 0, arguments);
34
+ }
35
+ }
36
+ };
37
+ }
38
+ // @ts-ignore
39
+ var visualViewport = typeof document !== 'undefined' && window.visualViewport;
40
+ function isScrollable(node) {
41
+ var style = window.getComputedStyle(node);
42
+ return /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY);
43
+ }
44
+ function getScrollParent(node) {
45
+ if (isScrollable(node)) {
46
+ node = node.parentElement;
47
+ }
48
+ while (node && !isScrollable(node)) {
49
+ node = node.parentElement;
50
+ }
51
+ return node || document.scrollingElement || document.documentElement;
52
+ }
53
+ // HTML input types that do not cause the software keyboard to appear.
54
+ var nonTextInputTypes = new Set(['checkbox', 'radio', 'range', 'color', 'file', 'image', 'button', 'submit', 'reset']);
55
+ // The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position
56
+ var preventScrollCount = 0;
57
+ var restore;
58
+ /**
59
+ * Prevents scrolling on the document body on mount, and
60
+ * restores it on unmount. Also ensures that content does not
61
+ * shift due to the scrollbars disappearing.
62
+ */
63
+ function usePreventScroll() {
64
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
65
+ var isDisabled = options.isDisabled;
66
+ useIsomorphicLayoutEffect(function () {
67
+ if (isDisabled) {
68
+ return;
69
+ }
70
+ preventScrollCount++;
71
+ if (preventScrollCount === 1) {
72
+ if ((0, _browser.isIOS)()) {
73
+ restore = preventScrollMobileSafari();
74
+ }
75
+ }
76
+ return function () {
77
+ preventScrollCount--;
78
+ if (preventScrollCount === 0) {
79
+ restore === null || restore === void 0 ? void 0 : restore();
80
+ }
81
+ };
82
+ }, [isDisabled]);
83
+ }
84
+ // Mobile Safari is a whole different beast. Even with overflow: hidden,
85
+ // it still scrolls the page in many situations:
86
+ //
87
+ // 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.
88
+ // 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of
89
+ // it, so it becomes scrollable.
90
+ // 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.
91
+ // This may cause even fixed position elements to scroll off the screen.
92
+ // 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always
93
+ // scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.
94
+ //
95
+ // In order to work around these cases, and prevent scrolling without jankiness, we do a few things:
96
+ //
97
+ // 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling
98
+ // on the window.
99
+ // 2. Prevent default on `touchmove` events inside a scrollable element when the scroll position is at the
100
+ // top or bottom. This avoids the whole page scrolling instead, but does prevent overscrolling.
101
+ // 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.
102
+ // 4. When focusing an input, apply a transform to trick Safari into thinking the input is at the top
103
+ // of the page, which prevents it from scrolling the page. After the input is focused, scroll the element
104
+ // into view ourselves, without scrolling the whole page.
105
+ // 5. Offset the body by the scroll position using a negative margin and scroll to the top. This should appear the
106
+ // same visually, but makes the actual scroll position always zero. This is required to make all of the
107
+ // above work or Safari will still try to scroll the page when focusing an input.
108
+ // 6. As a last resort, handle window scroll events, and scroll back to the top. This can happen when attempting
109
+ // to navigate to an input with the next/previous buttons that's outside a modal.
110
+ function preventScrollMobileSafari() {
111
+ var scrollable;
112
+ var lastY = 0;
113
+ var onTouchStart = function onTouchStart(e) {
114
+ // Store the nearest scrollable parent element from the element that the user touched.
115
+ scrollable = getScrollParent(e.target);
116
+ if (scrollable === document.documentElement && scrollable === document.body) {
117
+ return;
118
+ }
119
+ lastY = e.changedTouches[0].pageY;
120
+ };
121
+ var onTouchMove = function onTouchMove(e) {
122
+ // Prevent scrolling the window.
123
+ if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
124
+ e.preventDefault();
125
+ return;
126
+ }
127
+ // Prevent scrolling up when at the top and scrolling down when at the bottom
128
+ // of a nested scrollable area, otherwise mobile Safari will start scrolling
129
+ // the window instead. Unfortunately, this disables bounce scrolling when at
130
+ // the top but it's the best we can do.
131
+ var y = e.changedTouches[0].pageY;
132
+ var _scrollable = scrollable,
133
+ scrollTop = _scrollable.scrollTop;
134
+ var bottom = scrollable.scrollHeight - scrollable.clientHeight;
135
+ if (bottom === 0) {
136
+ return;
137
+ }
138
+ if (scrollTop <= 0 && y > lastY || scrollTop >= bottom && y < lastY) {
139
+ e.preventDefault();
140
+ }
141
+ lastY = y;
142
+ };
143
+ var onTouchEnd = function onTouchEnd(e) {
144
+ var target = e.target;
145
+ // Apply this change if we're not already focused on the target element
146
+ if (isInput(target) && target !== document.activeElement) {
147
+ e.preventDefault();
148
+ // Apply a transform to trick Safari into thinking the input is at the top of the page
149
+ // so it doesn't try to scroll it into view. When tapping on an input, this needs to
150
+ // be done before the "focus" event, so we have to focus the element ourselves.
151
+ target.style.transform = 'translateY(-2000px)';
152
+ target.focus();
153
+ requestAnimationFrame(function () {
154
+ target.style.transform = '';
155
+ });
156
+ }
157
+ };
158
+ var onFocus = function onFocus(e) {
159
+ var target = e.target;
160
+ if (isInput(target)) {
161
+ // Transform also needs to be applied in the focus event in cases where focus moves
162
+ // other than tapping on an input directly, e.g. the next/previous buttons in the
163
+ // software keyboard. In these cases, it seems applying the transform in the focus event
164
+ // is good enough, whereas when tapping an input, it must be done before the focus event. 🤷‍♂️
165
+ target.style.transform = 'translateY(-2000px)';
166
+ requestAnimationFrame(function () {
167
+ target.style.transform = '';
168
+ // This will have prevented the browser from scrolling the focused element into view,
169
+ // so we need to do this ourselves in a way that doesn't cause the whole page to scroll.
170
+ if (visualViewport) {
171
+ if (visualViewport.height < window.innerHeight) {
172
+ // If the keyboard is already visible, do this after one additional frame
173
+ // to wait for the transform to be removed.
174
+ requestAnimationFrame(function () {
175
+ scrollIntoView(target);
176
+ });
177
+ } else {
178
+ // Otherwise, wait for the visual viewport to resize before scrolling so we can
179
+ // measure the correct position to scroll to.
180
+ visualViewport.addEventListener('resize', function () {
181
+ return scrollIntoView(target);
182
+ }, {
183
+ once: true
184
+ });
185
+ }
186
+ }
187
+ });
188
+ }
189
+ };
190
+ var onWindowScroll = function onWindowScroll() {
191
+ // Last resort. If the window scrolled, scroll it back to the top.
192
+ // It should always be at the top because the body will have a negative margin (see below).
193
+ window.scrollTo(0, 0);
194
+ };
195
+ // Record the original scroll position so we can restore it.
196
+ // Then apply a negative margin to the body to offset it by the scroll position. This will
197
+ // enable us to scroll the window to the top, which is required for the rest of this to work.
198
+ var scrollX = window.pageXOffset;
199
+ var scrollY = window.pageYOffset;
200
+ var restoreStyles = chain(setStyle(document.documentElement, 'paddingRight', "".concat(window.innerWidth - document.documentElement.clientWidth, "px")));
201
+ // Scroll to the top. The negative margin on the body will make this appear the same.
202
+ window.scrollTo(0, 0);
203
+ var removeEvents = chain(addEvent(document, 'touchstart', onTouchStart, {
204
+ passive: false,
205
+ capture: true
206
+ }), addEvent(document, 'touchmove', onTouchMove, {
207
+ passive: false,
208
+ capture: true
209
+ }), addEvent(document, 'touchend', onTouchEnd, {
210
+ passive: false,
211
+ capture: true
212
+ }), addEvent(document, 'focus', onFocus, true), addEvent(window, 'scroll', onWindowScroll));
213
+ return function () {
214
+ // Restore styles and scroll the page back to where it was.
215
+ restoreStyles();
216
+ removeEvents();
217
+ window.scrollTo(scrollX, scrollY);
218
+ };
219
+ }
220
+ // Sets a CSS property on an element, and returns a function to revert it to the previous value.
221
+ function setStyle(element, style, value) {
222
+ // https://github.com/microsoft/TypeScript/issues/17827#issuecomment-391663310
223
+ // @ts-ignore
224
+ var cur = element.style[style];
225
+ // @ts-ignore
226
+ element.style[style] = value;
227
+ return function () {
228
+ // @ts-ignore
229
+ element.style[style] = cur;
230
+ };
231
+ }
232
+ // Adds an event listener to an element, and returns a function to remove it.
233
+ function addEvent(target, event, handler, options) {
234
+ // @ts-ignore
235
+ target.addEventListener(event, handler, options);
236
+ return function () {
237
+ // @ts-ignore
238
+ target.removeEventListener(event, handler, options);
239
+ };
240
+ }
241
+ function scrollIntoView(target) {
242
+ var root = document.scrollingElement || document.documentElement;
243
+ while (target && target !== root) {
244
+ // Find the parent scrollable element and adjust the scroll position if the target is not already in view.
245
+ var scrollable = getScrollParent(target);
246
+ if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== target) {
247
+ var scrollableTop = scrollable.getBoundingClientRect().top;
248
+ var targetTop = target.getBoundingClientRect().top;
249
+ var targetBottom = target.getBoundingClientRect().bottom;
250
+ // Buffer is needed for some edge cases
251
+ var keyboardHeight = scrollable.getBoundingClientRect().bottom + KEYBOARD_BUFFER;
252
+ if (targetBottom > keyboardHeight) {
253
+ scrollable.scrollTop += targetTop - scrollableTop;
254
+ }
255
+ }
256
+ // @ts-ignore
257
+ target = scrollable.parentElement;
258
+ }
259
+ }
260
+ function isInput(target) {
261
+ return target instanceof HTMLInputElement && !nonTextInputTypes.has(target.type) || target instanceof HTMLTextAreaElement || target instanceof HTMLElement && target.isContentEditable;
262
+ }
263
+ var _default = exports["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;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getCorrectMaxHeight = exports["default"] = exports.changeBodyPadding = void 0;
6
+ exports.getCorrectMaxHeight = exports["default"] = exports.changeBodyStyles = void 0;
7
7
  require("core-js/modules/es.parse-int.js");
8
8
  var _uiHelpers = require("@megafon/ui-helpers");
9
9
  var getAdditionalSize = function getAdditionalSize(refs) {
@@ -37,8 +37,9 @@ var getCorrectMaxHeight = exports.getCorrectMaxHeight = function getCorrectMaxHe
37
37
  props = _ref.props;
38
38
  var isStickyFooter = props.isStickyFooter,
39
39
  isStickyHeader = props.isStickyHeader,
40
- isBottomView = props.isBottomView;
41
- var windowHeight = window.innerHeight;
40
+ isBottomView = props.isBottomView,
41
+ availableHeight = props.availableHeight;
42
+ var windowHeight = availableHeight !== null && availableHeight !== void 0 ? availableHeight : window.innerHeight;
42
43
  var windowWidth = window.innerWidth;
43
44
  var isMobile = windowWidth < _uiHelpers.breakpoints.MOBILE_BIG_START;
44
45
  var _getAdditionalSize = getAdditionalSize(refs),
@@ -54,15 +55,19 @@ var getCorrectMaxHeight = exports.getCorrectMaxHeight = function getCorrectMaxHe
54
55
  var correctMaxHeight = isStickyFooter ? maxHeightResize - popupFooterHeight : maxHeightResize;
55
56
  return correctMaxHeight;
56
57
  };
57
- var changeBodyPadding = exports.changeBodyPadding = function changeBodyPadding(isOpened) {
58
+ var changeBodyStyles = exports.changeBodyStyles = function changeBodyStyles(isOpened) {
58
59
  var windowWidth = window.innerWidth;
59
60
  var documentClientWidth = document.documentElement.clientWidth;
60
61
  var scrollBarWidth = windowWidth - documentClientWidth;
61
62
  var bodyEl = document.body;
62
63
  if (!isOpened) {
63
64
  bodyEl.style.paddingRight = '';
65
+ bodyEl.style.height = '';
66
+ bodyEl.style.overflow = '';
64
67
  return;
65
68
  }
69
+ bodyEl.style.height = '100%';
70
+ bodyEl.style.overflow = 'hidden';
66
71
  if (scrollBarWidth === 0) {
67
72
  return;
68
73
  }
@@ -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;