@prom-ui/core 0.0.90 → 0.0.100

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Avatar",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
package/Body/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Body",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
package/Box/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Box",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Button",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/ButtonPageUp",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Checkbox",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
package/Flex/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Flex",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
package/Grid/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Grid",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
package/Icon/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Icon",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Image",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/ImageEmoji",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Input",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/KeyPress",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
package/Line/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Line",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
package/Link/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Link",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
package/List/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/List",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Media",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/OutsideClick",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ declare type SwipeCloseProps = {
3
+ isActive?: boolean;
4
+ children: React.ReactNode;
5
+ rootRef: React.RefObject<HTMLDivElement>;
6
+ contentRef: React.RefObject<HTMLDivElement>;
7
+ onClose: (e: any) => void;
8
+ placement: 'adaptive' | 'top' | 'right' | 'bottom' | 'left';
9
+ };
10
+ export declare const SwipeClose: React.FC<SwipeCloseProps>;
11
+ export {};
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ declare type TouchScrollableProps = {
3
+ isActive?: boolean;
4
+ scrollRef: React.RefObject<HTMLDivElement>;
5
+ children: React.ReactNode;
6
+ };
7
+ export declare const TouchScrollable: React.FC<TouchScrollableProps>;
8
+ export {};
@@ -15,6 +15,8 @@ var Button = require('@prom-ui/core/Button');
15
15
  var Icon = require('@prom-ui/core/Icon');
16
16
  var Close = require('@prom-ui/icons/Close');
17
17
  var ArrowBack = require('@prom-ui/icons/ArrowBack');
18
+ var utils = require('react-scrolllock/dist/utils');
19
+ var Swipe = require('react-easy-swipe');
18
20
 
19
21
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
22
 
@@ -39,6 +41,7 @@ function _interopNamespace(e) {
39
41
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
40
42
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
41
43
  var ScrollLock__default = /*#__PURE__*/_interopDefaultLegacy(ScrollLock);
44
+ var Swipe__default = /*#__PURE__*/_interopDefaultLegacy(Swipe);
42
45
 
43
46
  /******************************************************************************
44
47
  Copyright (c) Microsoft Corporation.
@@ -179,6 +182,172 @@ var getPopupStyle = function (placement, size, maxSize) {
179
182
  };
180
183
  };
181
184
 
185
+ // FORK FROM https://github.com/jossmac/react-scrolllock/blob/master/src/TouchScrollable.js
186
+ var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
187
+ /* @ts-ignore */
188
+
189
+ var canUseEventListeners = canUseDOM && !!(window.addEventListener || window.attachEvent);
190
+ var TouchScrollable = function (_a) {
191
+ var _b = _a.isActive,
192
+ isActive = _b === void 0 ? false : _b,
193
+ scrollRef = _a.scrollRef,
194
+ children = _a.children;
195
+ React__namespace.useEffect(function () {
196
+ if (!isActive || !canUseEventListeners || !(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) return;
197
+ scrollRef.current.addEventListener('touchstart', utils.preventInertiaScroll, utils.listenerOptions);
198
+ scrollRef.current.addEventListener('touchmove', utils.allowTouchMove, utils.listenerOptions);
199
+ return function () {
200
+ if (!isActive || !canUseEventListeners || !(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) return;
201
+ scrollRef.current.removeEventListener('touchstart', utils.preventInertiaScroll, utils.listenerOptions);
202
+ scrollRef.current.removeEventListener('touchmove', utils.allowTouchMove, utils.listenerOptions);
203
+ };
204
+ });
205
+ return React__namespace.createElement(React__namespace.Fragment, null, children);
206
+ };
207
+
208
+ var VENDOR_PREFIX = ['-webkit', '-moz', '-ms', '-o'];
209
+ var PROPERTYES_VENDOR_PREFIX = ['transform', 'transition'];
210
+
211
+ var setStyle = function (element, style) {
212
+ if (!element) return;
213
+
214
+ for (var property in style) {
215
+ var isVendorPrefix = PROPERTYES_VENDOR_PREFIX.indexOf(property) !== -1;
216
+
217
+ if (!!!style[property]) {
218
+ element.style.removeProperty(property);
219
+
220
+ if (isVendorPrefix) {
221
+ for (var _i = 0, VENDOR_PREFIX_1 = VENDOR_PREFIX; _i < VENDOR_PREFIX_1.length; _i++) {
222
+ var vendor = VENDOR_PREFIX_1[_i];
223
+ element.style.removeProperty("".concat(vendor, "-").concat(property));
224
+ }
225
+ }
226
+ } else {
227
+ element.style.setProperty(property, style[property]);
228
+
229
+ if (isVendorPrefix) {
230
+ for (var _a = 0, VENDOR_PREFIX_2 = VENDOR_PREFIX; _a < VENDOR_PREFIX_2.length; _a++) {
231
+ var vendor = VENDOR_PREFIX_2[_a];
232
+ element.style.setProperty("".concat(vendor, "-").concat(property), style[property]);
233
+ }
234
+ }
235
+ }
236
+ }
237
+ };
238
+
239
+ var SWIPE_TIME_RATE = 250;
240
+ var SWIPE_MIN_POS = 70;
241
+ var SWIPE_TRANSITION_DURATION = 225;
242
+ var SwipeClose = function (_a) {
243
+ var _b = _a.isActive,
244
+ isActive = _b === void 0 ? true : _b,
245
+ children = _a.children,
246
+ onClose = _a.onClose,
247
+ placement = _a.placement,
248
+ rootRef = _a.rootRef,
249
+ contentRef = _a.contentRef;
250
+ var isAllowSwipe = React__namespace.useRef(null);
251
+ var isAllowClose = React__namespace.useRef(false);
252
+ var startTime = React__namespace.useRef(0);
253
+
254
+ if (!isActive) {
255
+ return React__namespace.createElement(React__namespace.Fragment, null, children);
256
+ }
257
+
258
+ var onSwipeMove = function (_a) {
259
+ var _b, _c, _d;
260
+
261
+ var x = _a.x,
262
+ y = _a.y;
263
+ var contentsScrollHeight = ((_b = contentRef.current) === null || _b === void 0 ? void 0 : _b.scrollHeight) || 0;
264
+ var contentOffsetHeight = ((_c = contentRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) || 0;
265
+ var contentScrollTop = ((_d = contentRef.current) === null || _d === void 0 ? void 0 : _d.scrollTop) || 0;
266
+ var contentScrollBottom = contentsScrollHeight - (contentScrollTop + contentOffsetHeight);
267
+ var transform = null;
268
+ var isAllowSwipeCords = false;
269
+ var isAllowCloseCords = false;
270
+ var xAbs = Math.abs(x);
271
+ var yAbs = Math.abs(y);
272
+
273
+ if (placement === 'top') {
274
+ transform = "translateY(".concat(y >= 0 ? 0 : y, "px)");
275
+ isAllowSwipeCords = contentScrollBottom <= 1 && y <= 0 && yAbs > xAbs;
276
+ isAllowCloseCords = yAbs > SWIPE_MIN_POS;
277
+ } else if (placement === 'bottom') {
278
+ transform = "translateY(".concat(y <= 0 ? 0 : y, "px)");
279
+ isAllowSwipeCords = contentScrollTop <= 1 && y >= 0 && yAbs > xAbs;
280
+ isAllowCloseCords = yAbs > SWIPE_MIN_POS;
281
+ } else if (placement === 'left') {
282
+ transform = "translateX(".concat(x >= 0 ? 0 : x, "px)");
283
+ isAllowSwipeCords = x <= 0 && xAbs > yAbs;
284
+ isAllowCloseCords = xAbs > SWIPE_MIN_POS;
285
+ } else if (placement === 'right') {
286
+ transform = "translateX(".concat(x <= 0 ? 0 : x, "px)");
287
+ isAllowSwipeCords = x >= 0 && xAbs > yAbs;
288
+ isAllowCloseCords = xAbs > SWIPE_MIN_POS;
289
+ }
290
+
291
+ if (isAllowSwipe.current === null) {
292
+ if (isAllowSwipeCords) {
293
+ isAllowSwipe.current = true;
294
+ } else {
295
+ isAllowSwipe.current = false;
296
+ }
297
+ }
298
+
299
+ if (isAllowSwipe.current) {
300
+ if (!startTime.current) {
301
+ startTime.current = new Date().getTime();
302
+ }
303
+
304
+ if (!isAllowClose.current && isAllowCloseCords) {
305
+ isAllowClose.current = true;
306
+ }
307
+
308
+ setStyle(rootRef.current, {
309
+ transform: transform
310
+ });
311
+ setStyle(contentRef.current, {
312
+ 'pointer-events': "none",
313
+ 'overflow': 'hidden'
314
+ });
315
+ }
316
+ };
317
+
318
+ var onSwipeEnd = function () {
319
+ if (isAllowSwipe.current) {
320
+ setStyle(rootRef.current, {
321
+ transition: "transform ".concat(SWIPE_TRANSITION_DURATION, "ms cubic-bezier(0, 0, 0.2, 1) 0ms"),
322
+ transform: null
323
+ });
324
+ setStyle(contentRef.current, {
325
+ 'pointer-events': null,
326
+ 'overflow': null
327
+ });
328
+ setTimeout(function () {
329
+ setStyle(rootRef.current, {
330
+ transition: null
331
+ });
332
+ }, SWIPE_TRANSITION_DURATION);
333
+ var timeRate = new Date().getTime() - startTime.current;
334
+
335
+ if (isAllowClose.current && timeRate < SWIPE_TIME_RATE && onClose) {
336
+ onClose({});
337
+ }
338
+ }
339
+
340
+ startTime.current = 0;
341
+ isAllowSwipe.current = null;
342
+ isAllowClose.current = false;
343
+ };
344
+
345
+ return React__namespace.createElement(Swipe__default["default"], {
346
+ onSwipeMove: onSwipeMove,
347
+ onSwipeEnd: onSwipeEnd
348
+ }, children);
349
+ };
350
+
182
351
  var DEFAULT_SIZE = 400;
183
352
  var Overlay = function (_a) {
184
353
  var children = _a.children,
@@ -194,39 +363,42 @@ var Overlay = function (_a) {
194
363
  isShowPrevButton = _c === void 0 ? false : _c,
195
364
  _d = _a.isCloseOnEscape,
196
365
  isCloseOnEscape = _d === void 0 ? true : _d,
197
- _e = _a.isAnimated,
198
- isAnimated = _e === void 0 ? true : _e,
366
+ _e = _a.isCloseOnSwipe,
367
+ isCloseOnSwipe = _e === void 0 ? true : _e,
199
368
  _f = _a.isCloseOutsideClick,
200
369
  isCloseOutsideClick = _f === void 0 ? true : _f,
201
- _g = _a.isRenderPortal,
202
- isRenderPortal = _g === void 0 ? true : _g,
203
- _h = _a.isScrollLock,
204
- isScrollLock = _h === void 0 ? true : _h,
205
- _j = _a.isScrollLockTouch,
206
- isScrollLockTouch = _j === void 0 ? true : _j,
370
+ _g = _a.isAnimated,
371
+ isAnimated = _g === void 0 ? true : _g,
372
+ _h = _a.isRenderPortal,
373
+ isRenderPortal = _h === void 0 ? true : _h,
374
+ _j = _a.isScrollLock,
375
+ isScrollLock = _j === void 0 ? true : _j,
376
+ _k = _a.isScrollLockTouch,
377
+ isScrollLockTouch = _k === void 0 ? true : _k,
207
378
  header = _a.header,
208
379
  footer = _a.footer,
209
- _k = _a.padding,
210
- padding = _k === void 0 ? '20px 20px 20px 20px' : _k,
380
+ _l = _a.padding,
381
+ padding = _l === void 0 ? '20px 20px 20px 20px' : _l,
211
382
  title = _a.title,
212
- _l = _a.placement,
213
- placement = _l === void 0 ? 'adaptive' : _l,
214
- _m = _a.size,
215
- size = _m === void 0 ? 'adaptive' : _m,
216
- _o = _a.maxSize,
217
- maxSize = _o === void 0 ? '90%' : _o,
218
- _p = _a.zIndex,
219
- zIndex = _p === void 0 ? 5000 : _p,
383
+ _m = _a.placement,
384
+ placement = _m === void 0 ? 'adaptive' : _m,
385
+ _o = _a.size,
386
+ size = _o === void 0 ? 'adaptive' : _o,
387
+ _p = _a.maxSize,
388
+ maxSize = _p === void 0 ? '90%' : _p,
389
+ _q = _a.zIndex,
390
+ zIndex = _q === void 0 ? 5000 : _q,
220
391
  contentRef = _a.contentRef,
221
392
  dataQaId = _a.dataQaId,
222
- props = __rest(_a, ["children", "onClose", "onOpen", "onPrev", "onOpened", "onClosed", "isOpen", "isShowCloseButton", "isShowPrevButton", "isCloseOnEscape", "isAnimated", "isCloseOutsideClick", "isRenderPortal", "isScrollLock", "isScrollLockTouch", "header", "footer", "padding", "title", "placement", "size", "maxSize", "zIndex", "contentRef", "dataQaId"]);
393
+ props = __rest(_a, ["children", "onClose", "onOpen", "onPrev", "onOpened", "onClosed", "isOpen", "isShowCloseButton", "isShowPrevButton", "isCloseOnEscape", "isCloseOnSwipe", "isCloseOutsideClick", "isAnimated", "isRenderPortal", "isScrollLock", "isScrollLockTouch", "header", "footer", "padding", "title", "placement", "size", "maxSize", "zIndex", "contentRef", "dataQaId"]);
223
394
 
224
- var currentPlacement = placement;
225
- var currentSize = size;
395
+ var popupRef = React__namespace.useRef(null);
396
+ var currentContentRef = contentRef || React__namespace.useRef(null);
226
397
  var isMinWidthMedium = Media.useMedia({
227
398
  minWidth: 'medium'
228
399
  });
229
- var ScrollableWrapper = isScrollLockTouch ? ScrollLock.TouchScrollable : React__namespace.Fragment;
400
+ var currentPlacement = placement;
401
+ var currentSize = size;
230
402
 
231
403
  if (size === 'adaptive') {
232
404
  if (placement === 'top' || placement === 'bottom') {
@@ -250,6 +422,12 @@ var Overlay = function (_a) {
250
422
  enabled: isAnimated
251
423
  }, React__namespace.createElement(Portal.Portal, {
252
424
  isActive: isRenderPortal
425
+ }, React__namespace.createElement(SwipeClose, {
426
+ isActive: isScrollLock && isCloseOnSwipe,
427
+ rootRef: popupRef,
428
+ contentRef: currentContentRef,
429
+ placement: currentPlacement,
430
+ onClose: onClose
253
431
  }, React__namespace.createElement(Root, __assign({
254
432
  role: 'presentation',
255
433
  style: {
@@ -269,6 +447,7 @@ var Overlay = function (_a) {
269
447
  }
270
448
  }
271
449
  }), React__namespace.createElement(Popup, {
450
+ ref: popupRef,
272
451
  "popup-placement": currentPlacement,
273
452
  "aria-modal": true,
274
453
  role: 'dialog',
@@ -280,12 +459,15 @@ var Overlay = function (_a) {
280
459
  onClose: onClose,
281
460
  onPrev: onPrev,
282
461
  title: title
283
- }, header), React__namespace.createElement(OverlayFooter, null, footer), React__namespace.createElement(ScrollableWrapper, null, React__namespace.createElement(OverlayContent, {
284
- ref: contentRef,
462
+ }, header), React__namespace.createElement(OverlayFooter, null, footer), React__namespace.createElement(TouchScrollable, {
463
+ isActive: isScrollLockTouch,
464
+ scrollRef: currentContentRef
465
+ }, React__namespace.createElement(OverlayContent, {
466
+ ref: currentContentRef,
285
467
  style: {
286
468
  padding: padding
287
469
  }
288
- }, children))))));
470
+ }, children)))))));
289
471
  };
290
472
 
291
473
  exports.Overlay = Overlay;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("react-scrolllock"),o=require("@prom-ui/core/KeyPress"),r=require("@prom-ui/core/Portal"),n=require("@prom-ui/core/Media"),a=require("ttag"),i=require("evokit"),c=require("react-transition-group"),l=require("@prom-ui/core/Text"),d=require("@prom-ui/core/Button"),u=require("@prom-ui/core/Icon"),s=require("@prom-ui/icons/Close"),p=require("@prom-ui/icons/ArrowBack");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function v(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var f=m(e),h=v(e),_=m(t),b=function(){return b=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},b.apply(this,arguments)};function E(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var O,y,x={root:"v0oYp",backdrop:"RvRWz",popup:"elIqJ",popup_placement_top:"Llv4b",popup_placement_bottom:"DJyNc",popup_placement_right:"_4DX3c",popup_placement_left:"OwkR7",content:"_5qQ0k",header:"LIk9z",header__grid:"SShy4",header__item:"_9fUzS",header__title:"Vuilz _9fUzS",header__action:"c-A8d _9fUzS",header__actionButton:"yYG24",header__actionIcon:"La2ok",footer:"_3Ca-G",enter:"OjeZp",exit:"HiHMU",enterActive:"Ne-Vn",exitActive:"_6f7f1"},k={css:x,b:""},g=i.createBlock("div","root",[],k),S=i.createBlock("div","backdrop",[],k),C=i.createBlock("div","popup",["placement"],k),P=i.createBlock("div","content",[],k),w=function(e){var t=e.open,o=void 0!==t&&t,r=e.children,n=e.enabled,a=void 0===n||n,i=e.onEnter,l=e.onEntered,d=e.onExited;return f.default.createElement(c.CSSTransition,{in:o,timeout:a?225:0,classNames:x,unmountOnExit:!0,onEnter:i,onEntered:l,onExited:d},r)},q=function(e){var t=e.isShowPrevButton,o=e.isShowCloseButton,r=e.children,n=e.title,i=e.onClose,c=e.onPrev;return f.default.createElement("div",{className:x.header},void 0!==r?r:f.default.createElement("div",{className:x.header__grid},f.default.createElement("div",{className:x.header__action},t&&f.default.createElement(d.Button,{className:x.header__actionButton,"button-theme":"black-inherit",type:"button",onClick:c,"aria-label":a.t(O||(O=E(["Назад"],["Назад"]))),"data-qaid":"prev"},f.default.createElement(u.Icon,{"icon-as":p.ArrowBack,className:x.header__actionIcon}))),f.default.createElement("div",{className:x.header__title},"string"==typeof n?f.default.createElement(l.Text,{"text-align":"center","text-size":"h4","text-wrap":"ellipsis","text-weight":"bold","data-qaid":"title"},n):n),f.default.createElement("div",{className:x.header__action},o&&i&&f.default.createElement(d.Button,{className:x.header__actionButton,"button-theme":"black-inherit",type:"button",onClick:i,"aria-label":a.t(y||(y=E(["Закрыть"],["Закрыть"]))),"data-qaid":"close"},f.default.createElement(u.Icon,{"icon-as":s.Close,className:x.header__actionIcon})))))},B=function(e){var t=e.children;return f.default.createElement("div",{className:x.footer},t)},j=function(e,t,o){return["top","bottom"].includes(e)?{height:t,maxHeight:o}:{width:t,maxWidth:o}};exports.Overlay=function(e){var a=e.children,i=e.onClose,c=e.onOpen,l=e.onPrev,d=e.onOpened,u=e.onClosed,s=e.isOpen,p=e.isShowCloseButton,m=void 0===p||p,v=e.isShowPrevButton,f=void 0!==v&&v,E=e.isCloseOnEscape,O=void 0===E||E,y=e.isAnimated,x=void 0===y||y,k=e.isCloseOutsideClick,z=void 0===k||k,I=e.isRenderPortal,N=void 0===I||I,A=e.isScrollLock,L=void 0===A||A,R=e.isScrollLockTouch,T=void 0===R||R,M=e.header,D=e.footer,U=e.padding,H=void 0===U?"20px 20px 20px 20px":U,K=e.title,Q=e.placement,W=void 0===Q?"adaptive":Q,G=e.size,J=void 0===G?"adaptive":G,V=e.maxSize,Y=void 0===V?"90%":V,F=e.zIndex,X=void 0===F?5e3:F,Z=e.contentRef,$=e.dataQaId,ee=function(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(o[r[n]]=e[r[n]])}return o}(e,["children","onClose","onOpen","onPrev","onOpened","onClosed","isOpen","isShowCloseButton","isShowPrevButton","isCloseOnEscape","isAnimated","isCloseOutsideClick","isRenderPortal","isScrollLock","isScrollLockTouch","header","footer","padding","title","placement","size","maxSize","zIndex","contentRef","dataQaId"]),te=W,oe=J,re=n.useMedia({minWidth:"medium"}),ne=T?t.TouchScrollable:h.Fragment;return"adaptive"===J&&(oe="top"===W||"bottom"===W?"auto":"adaptive"===W?re?400:"auto":400),"adaptive"===W&&(te=re?"right":"bottom"),h.createElement(w,{open:s,onEnter:c,onEntered:d,onExited:u,enabled:x},h.createElement(r.Portal,{isActive:N},h.createElement(g,b({role:"presentation",style:{zIndex:X}},ee),h.createElement(_.default,{isActive:L}),h.createElement(o.KeyPress,{isActive:O,code:"Escape",onKeyDown:i}),h.createElement(S,{"aria-hidden":!0,onClick:function(e){z&&i&&i(e)}}),h.createElement(C,{"popup-placement":te,"aria-modal":!0,role:"dialog",style:j(te,oe,Y),"data-qaid":$},h.createElement(q,{isShowCloseButton:m,isShowPrevButton:f,onClose:i,onPrev:l,title:K},M),h.createElement(B,null,D),h.createElement(ne,null,h.createElement(P,{ref:Z,style:{padding:H}},a))))))},require("./style.production.css");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("react-scrolllock"),r=require("@prom-ui/core/KeyPress"),n=require("@prom-ui/core/Portal"),o=require("@prom-ui/core/Media"),i=require("ttag"),a=require("evokit"),c=require("react-transition-group"),l=require("@prom-ui/core/Text"),u=require("@prom-ui/core/Button"),s=require("@prom-ui/core/Icon"),d=require("@prom-ui/icons/Close"),p=require("@prom-ui/icons/ArrowBack"),v=require("react-scrolllock/dist/utils"),f=require("react-easy-swipe");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function h(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var E=m(e),_=h(e),b=m(t),w=m(f),y=function(){return y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},y.apply(this,arguments)};function O(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var x,g,S={root:"v0oYp",backdrop:"RvRWz",popup:"elIqJ",popup_placement_top:"Llv4b",popup_placement_bottom:"DJyNc",popup_placement_right:"_4DX3c",popup_placement_left:"OwkR7",content:"_5qQ0k",header:"LIk9z",header__grid:"SShy4",header__item:"_9fUzS",header__title:"Vuilz _9fUzS",header__action:"c-A8d _9fUzS",header__actionButton:"yYG24",header__actionIcon:"La2ok",footer:"_3Ca-G",enter:"OjeZp",exit:"HiHMU",enterActive:"Ne-Vn",exitActive:"_6f7f1"},k={css:S,b:""},C=a.createBlock("div","root",[],k),P=a.createBlock("div","backdrop",[],k),q=a.createBlock("div","popup",["placement"],k),B=a.createBlock("div","content",[],k),R=function(e){var t=e.open,r=void 0!==t&&t,n=e.children,o=e.enabled,i=void 0===o||o,a=e.onEnter,l=e.onEntered,u=e.onExited;return E.default.createElement(c.CSSTransition,{in:r,timeout:i?225:0,classNames:S,unmountOnExit:!0,onEnter:a,onEntered:l,onExited:u},n)},z=function(e){var t=e.isShowPrevButton,r=e.isShowCloseButton,n=e.children,o=e.title,a=e.onClose,c=e.onPrev;return E.default.createElement("div",{className:S.header},void 0!==n?n:E.default.createElement("div",{className:S.header__grid},E.default.createElement("div",{className:S.header__action},t&&E.default.createElement(u.Button,{className:S.header__actionButton,"button-theme":"black-inherit",type:"button",onClick:c,"aria-label":i.t(x||(x=O(["Назад"],["Назад"]))),"data-qaid":"prev"},E.default.createElement(s.Icon,{"icon-as":p.ArrowBack,className:S.header__actionIcon}))),E.default.createElement("div",{className:S.header__title},"string"==typeof o?E.default.createElement(l.Text,{"text-align":"center","text-size":"h4","text-wrap":"ellipsis","text-weight":"bold","data-qaid":"title"},o):o),E.default.createElement("div",{className:S.header__action},r&&a&&E.default.createElement(u.Button,{className:S.header__actionButton,"button-theme":"black-inherit",type:"button",onClick:a,"aria-label":i.t(g||(g=O(["Закрыть"],["Закрыть"]))),"data-qaid":"close"},E.default.createElement(s.Icon,{"icon-as":d.Close,className:S.header__actionIcon})))))},j=function(e){var t=e.children;return E.default.createElement("div",{className:S.footer},t)},I=function(e,t,r){return["top","bottom"].includes(e)?{height:t,maxHeight:r}:{width:t,maxWidth:r}},A=!("undefined"==typeof window||!window.document||!window.document.createElement)&&!(!window.addEventListener&&!window.attachEvent),N=function(e){var t=e.isActive,r=void 0!==t&&t,n=e.scrollRef,o=e.children;return _.useEffect((function(){if(r&&A&&(null==n?void 0:n.current))return n.current.addEventListener("touchstart",v.preventInertiaScroll,v.listenerOptions),n.current.addEventListener("touchmove",v.allowTouchMove,v.listenerOptions),function(){r&&A&&(null==n?void 0:n.current)&&(n.current.removeEventListener("touchstart",v.preventInertiaScroll,v.listenerOptions),n.current.removeEventListener("touchmove",v.allowTouchMove,v.listenerOptions))}})),_.createElement(_.Fragment,null,o)},L=["-webkit","-moz","-ms","-o"],T=["transform","transition"],M=function(e,t){if(e)for(var r in t){var n=-1!==T.indexOf(r);if(t[r]){if(e.style.setProperty(r,t[r]),n)for(var o=0,i=L;o<i.length;o++){l=i[o];e.style.setProperty("".concat(l,"-").concat(r),t[r])}}else if(e.style.removeProperty(r),n)for(var a=0,c=L;a<c.length;a++){var l=c[a];e.style.removeProperty("".concat(l,"-").concat(r))}}},D=function(e){var t=e.isActive,r=void 0===t||t,n=e.children,o=e.onClose,i=e.placement,a=e.rootRef,c=e.contentRef,l=_.useRef(null),u=_.useRef(!1),s=_.useRef(0);if(!r)return _.createElement(_.Fragment,null,n);return _.createElement(w.default,{onSwipeMove:function(e){var t,r,n,o=e.x,d=e.y,p=(null===(t=c.current)||void 0===t?void 0:t.scrollHeight)||0,v=(null===(r=c.current)||void 0===r?void 0:r.offsetHeight)||0,f=(null===(n=c.current)||void 0===n?void 0:n.scrollTop)||0,m=p-(f+v),h=null,E=!1,_=!1,b=Math.abs(o),w=Math.abs(d);"top"===i?(h="translateY(".concat(d>=0?0:d,"px)"),E=m<=1&&d<=0&&w>b,_=w>70):"bottom"===i?(h="translateY(".concat(d<=0?0:d,"px)"),E=f<=1&&d>=0&&w>b,_=w>70):"left"===i?(h="translateX(".concat(o>=0?0:o,"px)"),E=o<=0&&b>w,_=b>70):"right"===i&&(h="translateX(".concat(o<=0?0:o,"px)"),E=o>=0&&b>w,_=b>70),null===l.current&&(l.current=!!E),l.current&&(s.current||(s.current=(new Date).getTime()),!u.current&&_&&(u.current=!0),M(a.current,{transform:h}),M(c.current,{"pointer-events":"none",overflow:"hidden"}))},onSwipeEnd:function(){if(l.current){M(a.current,{transition:"transform ".concat(225,"ms cubic-bezier(0, 0, 0.2, 1) 0ms"),transform:null}),M(c.current,{"pointer-events":null,overflow:null}),setTimeout((function(){M(a.current,{transition:null})}),225);var e=(new Date).getTime()-s.current;u.current&&e<250&&o&&o({})}s.current=0,l.current=null,u.current=!1}},n)};exports.Overlay=function(e){var t=e.children,i=e.onClose,a=e.onOpen,c=e.onPrev,l=e.onOpened,u=e.onClosed,s=e.isOpen,d=e.isShowCloseButton,p=void 0===d||d,v=e.isShowPrevButton,f=void 0!==v&&v,m=e.isCloseOnEscape,h=void 0===m||m,E=e.isCloseOnSwipe,w=void 0===E||E,O=e.isCloseOutsideClick,x=void 0===O||O,g=e.isAnimated,S=void 0===g||g,k=e.isRenderPortal,A=void 0===k||k,L=e.isScrollLock,T=void 0===L||L,M=e.isScrollLockTouch,H=void 0===M||M,U=e.header,Y=e.footer,K=e.padding,Q=void 0===K?"20px 20px 20px 20px":K,W=e.title,X=e.placement,F=void 0===X?"adaptive":X,G=e.size,J=void 0===G?"adaptive":G,V=e.maxSize,Z=void 0===V?"90%":V,$=e.zIndex,ee=void 0===$?5e3:$,te=e.contentRef,re=e.dataQaId,ne=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["children","onClose","onOpen","onPrev","onOpened","onClosed","isOpen","isShowCloseButton","isShowPrevButton","isCloseOnEscape","isCloseOnSwipe","isCloseOutsideClick","isAnimated","isRenderPortal","isScrollLock","isScrollLockTouch","header","footer","padding","title","placement","size","maxSize","zIndex","contentRef","dataQaId"]),oe=_.useRef(null),ie=te||_.useRef(null),ae=o.useMedia({minWidth:"medium"}),ce=F,le=J;return"adaptive"===J&&(le="top"===F||"bottom"===F?"auto":"adaptive"===F?ae?400:"auto":400),"adaptive"===F&&(ce=ae?"right":"bottom"),_.createElement(R,{open:s,onEnter:a,onEntered:l,onExited:u,enabled:S},_.createElement(n.Portal,{isActive:A},_.createElement(D,{isActive:T&&w,rootRef:oe,contentRef:ie,placement:ce,onClose:i},_.createElement(C,y({role:"presentation",style:{zIndex:ee}},ne),_.createElement(b.default,{isActive:T}),_.createElement(r.KeyPress,{isActive:h,code:"Escape",onKeyDown:i}),_.createElement(P,{"aria-hidden":!0,onClick:function(e){x&&i&&i(e)}}),_.createElement(q,{ref:oe,"popup-placement":ce,"aria-modal":!0,role:"dialog",style:I(ce,le,Z),"data-qaid":re},_.createElement(z,{isShowCloseButton:p,isShowPrevButton:f,onClose:i,onPrev:c,title:W},U),_.createElement(j,null,Y),_.createElement(N,{isActive:H,scrollRef:ie},_.createElement(B,{ref:ie,style:{padding:Q}},t)))))))},require("./style.production.css");
@@ -32,10 +32,12 @@ export declare type OverlayProps = React.ComponentProps<"div"> & {
32
32
  isShowPrevButton?: boolean;
33
33
  /** Разрешает закрыть попап по клавише `Escape` */
34
34
  isCloseOnEscape?: boolean;
35
- /** Рендер в конец `<body>` */
36
- isRenderPortal?: boolean;
35
+ /** Разрешает закрыть попап по свайпу, работает если `isScrollLock={true}` */
36
+ isCloseOnSwipe?: boolean;
37
37
  /** Разрешает закрытие при клике на свободное пространство (затемнение документа) */
38
38
  isCloseOutsideClick?: boolean;
39
+ /** Рендер в конец `<body>` */
40
+ isRenderPortal?: boolean;
39
41
  /** Включает/отключает анимацию открытия/скрытия шторки */
40
42
  isAnimated?: boolean;
41
43
  /** Запрещает прокрутку `<body>` */
@@ -64,7 +66,7 @@ export declare type OverlayProps = React.ComponentProps<"div"> & {
64
66
  zIndex?: string | number;
65
67
  /** HTML Атрибут `data-qaid` для автотестов */
66
68
  /** `ref` для блока с контентом */
67
- contentRef?: React.RefObject<HTMLElement>;
69
+ contentRef?: React.RefObject<HTMLDivElement>;
68
70
  dataQaId?: string;
69
71
  };
70
72
  export declare const Overlay: React.FC<OverlayProps>;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Overlay",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -8,6 +8,7 @@
8
8
  ],
9
9
  "dependencies": {
10
10
  "evokit": "^3.2.3",
11
+ "react-easy-swipe": "^0.0.22",
11
12
  "react-scrolllock": "^5.0.1",
12
13
  "react-transition-group": "^4.4.2",
13
14
  "ttag": "^1.7.24"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Picture",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/PortableOverlay",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Portal",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/QRCode",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Rating",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/SafeQuery",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Scroll",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/ScrollControls",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/SideOverlay",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/SimpleSlider",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Skeleton",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Spinner",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
package/Text/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Text",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/TextEmoji",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Tooltip",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prom-ui/core/Tumbler",
3
- "version": "0.0.90",
3
+ "version": "0.0.100",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prom-ui/core",
3
3
  "author": "e.marchenko",
4
- "version": "0.0.90",
4
+ "version": "0.0.100",
5
5
  "description": "core ui blocks",
6
6
  "scripts": {
7
7
  "test": "jest",
@@ -63,5 +63,5 @@
63
63
  "optional": true
64
64
  }
65
65
  },
66
- "gitHead": "81c9b332895c578aa45747c42ef7febb0bac6380"
66
+ "gitHead": "5959757fe7a53bacc54b5908765b53e4e67dcd65"
67
67
  }