@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.
- package/Avatar/package.json +1 -1
- package/Body/package.json +1 -1
- package/Box/package.json +1 -1
- package/Button/package.json +1 -1
- package/ButtonPageUp/package.json +1 -1
- package/Checkbox/package.json +1 -1
- package/Flex/package.json +1 -1
- package/Grid/package.json +1 -1
- package/Icon/package.json +1 -1
- package/Image/package.json +1 -1
- package/ImageEmoji/package.json +1 -1
- package/Input/package.json +1 -1
- package/KeyPress/package.json +1 -1
- package/Line/package.json +1 -1
- package/Link/package.json +1 -1
- package/List/package.json +1 -1
- package/Media/package.json +1 -1
- package/OutsideClick/package.json +1 -1
- package/Overlay/SwipeClose.d.ts +11 -0
- package/Overlay/TouchScrollable.d.ts +8 -0
- package/Overlay/cjs/index.development.js +207 -25
- package/Overlay/cjs/index.production.js +1 -1
- package/Overlay/index.d.ts +5 -3
- package/Overlay/package.json +2 -1
- package/Picture/package.json +1 -1
- package/PortableOverlay/package.json +1 -1
- package/Portal/package.json +1 -1
- package/QRCode/package.json +1 -1
- package/Rating/package.json +1 -1
- package/SafeQuery/package.json +1 -1
- package/Scroll/package.json +1 -1
- package/ScrollControls/package.json +1 -1
- package/SideOverlay/package.json +1 -1
- package/SimpleSlider/package.json +1 -1
- package/Skeleton/package.json +1 -1
- package/Spinner/package.json +1 -1
- package/Text/package.json +1 -1
- package/TextEmoji/package.json +1 -1
- package/Tooltip/package.json +1 -1
- package/Tumbler/package.json +1 -1
- package/package.json +2 -2
package/Avatar/package.json
CHANGED
package/Body/package.json
CHANGED
package/Box/package.json
CHANGED
package/Button/package.json
CHANGED
package/Checkbox/package.json
CHANGED
package/Flex/package.json
CHANGED
package/Grid/package.json
CHANGED
package/Icon/package.json
CHANGED
package/Image/package.json
CHANGED
package/ImageEmoji/package.json
CHANGED
package/Input/package.json
CHANGED
package/KeyPress/package.json
CHANGED
package/Line/package.json
CHANGED
package/Link/package.json
CHANGED
package/List/package.json
CHANGED
package/Media/package.json
CHANGED
|
@@ -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 {};
|
|
@@ -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.
|
|
198
|
-
|
|
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.
|
|
202
|
-
|
|
203
|
-
_h = _a.
|
|
204
|
-
|
|
205
|
-
_j = _a.
|
|
206
|
-
|
|
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
|
-
|
|
210
|
-
padding =
|
|
380
|
+
_l = _a.padding,
|
|
381
|
+
padding = _l === void 0 ? '20px 20px 20px 20px' : _l,
|
|
211
382
|
title = _a.title,
|
|
212
|
-
|
|
213
|
-
placement =
|
|
214
|
-
|
|
215
|
-
size =
|
|
216
|
-
|
|
217
|
-
maxSize =
|
|
218
|
-
|
|
219
|
-
zIndex =
|
|
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", "
|
|
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
|
|
225
|
-
var
|
|
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
|
|
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(
|
|
284
|
-
|
|
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"),
|
|
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");
|
package/Overlay/index.d.ts
CHANGED
|
@@ -32,10 +32,12 @@ export declare type OverlayProps = React.ComponentProps<"div"> & {
|
|
|
32
32
|
isShowPrevButton?: boolean;
|
|
33
33
|
/** Разрешает закрыть попап по клавише `Escape` */
|
|
34
34
|
isCloseOnEscape?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
|
|
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<
|
|
69
|
+
contentRef?: React.RefObject<HTMLDivElement>;
|
|
68
70
|
dataQaId?: string;
|
|
69
71
|
};
|
|
70
72
|
export declare const Overlay: React.FC<OverlayProps>;
|
package/Overlay/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prom-ui/core/Overlay",
|
|
3
|
-
"version": "0.0.
|
|
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"
|
package/Picture/package.json
CHANGED
package/Portal/package.json
CHANGED
package/QRCode/package.json
CHANGED
package/Rating/package.json
CHANGED
package/SafeQuery/package.json
CHANGED
package/Scroll/package.json
CHANGED
package/SideOverlay/package.json
CHANGED
package/Skeleton/package.json
CHANGED
package/Spinner/package.json
CHANGED
package/Text/package.json
CHANGED
package/TextEmoji/package.json
CHANGED
package/Tooltip/package.json
CHANGED
package/Tumbler/package.json
CHANGED
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.
|
|
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": "
|
|
66
|
+
"gitHead": "5959757fe7a53bacc54b5908765b53e4e67dcd65"
|
|
67
67
|
}
|