@prom-ui/core 0.0.22 → 0.0.30
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/Body/cjs/index.development.js +14 -0
- package/Body/cjs/index.production.js +1 -0
- package/Body/cjs/style.development.css +1 -0
- package/Body/cjs/style.production.css +1 -0
- package/Body/index.js +5 -12
- package/Body/package.json +1 -1
- package/Box/cjs/index.development.js +20 -0
- package/Box/cjs/index.production.js +1 -0
- package/Box/cjs/style.development.css +1 -0
- package/Box/cjs/style.production.css +1 -0
- package/Box/index.js +5 -18
- package/Box/package.json +1 -1
- package/Button/cjs/index.development.js +95 -0
- package/Button/cjs/index.production.js +1 -0
- package/Button/cjs/style.development.css +1 -0
- package/Button/cjs/style.production.css +1 -0
- package/Button/index.d.ts +5 -4
- package/Button/index.js +4 -81
- package/Button/package.json +1 -1
- package/ButtonPageUp/cjs/index.development.js +170 -0
- package/ButtonPageUp/cjs/index.production.js +1 -0
- package/ButtonPageUp/index.d.ts +12 -5
- package/ButtonPageUp/index.js +4 -169
- package/ButtonPageUp/package.json +1 -2
- package/Checkbox/cjs/index.development.js +111 -0
- package/Checkbox/cjs/index.production.js +1 -0
- package/Checkbox/cjs/style.development.css +1 -0
- package/Checkbox/cjs/style.production.css +1 -0
- package/Checkbox/index.d.ts +4 -4
- package/Checkbox/index.js +4 -96
- package/Checkbox/package.json +1 -1
- package/Flex/cjs/index.development.js +25 -0
- package/Flex/cjs/index.production.js +1 -0
- package/Flex/cjs/style.development.css +1 -0
- package/Flex/cjs/style.production.css +1 -0
- package/Flex/index.js +5 -23
- package/Flex/package.json +1 -1
- package/Grid/cjs/index.development.js +25 -0
- package/Grid/cjs/index.production.js +1 -0
- package/Grid/cjs/style.development.css +1 -0
- package/Grid/cjs/style.production.css +1 -0
- package/Grid/index.js +5 -23
- package/Grid/package.json +1 -1
- package/Icon/cjs/index.development.js +41 -0
- package/Icon/cjs/index.production.js +1 -0
- package/Icon/cjs/style.development.css +1 -0
- package/Icon/cjs/style.production.css +1 -0
- package/Icon/index.d.ts +7 -12
- package/Icon/index.js +4 -76
- package/Icon/package.json +1 -1
- package/Image/cjs/index.development.js +20 -0
- package/Image/cjs/index.production.js +1 -0
- package/Image/cjs/style.development.css +1 -0
- package/Image/cjs/style.production.css +1 -0
- package/Image/index.js +5 -18
- package/Image/package.json +1 -1
- package/ImageEmoji/cjs/index.development.js +90 -0
- package/ImageEmoji/cjs/index.production.js +1 -0
- package/ImageEmoji/index.d.ts +6 -4
- package/ImageEmoji/index.js +4 -86
- package/ImageEmoji/package.json +1 -1
- package/Input/cjs/index.development.js +39 -0
- package/Input/cjs/index.production.js +1 -0
- package/Input/cjs/style.development.css +1 -0
- package/Input/cjs/style.production.css +1 -0
- package/Input/index.d.ts +23 -23
- package/Input/index.js +4 -81
- package/Input/package.json +1 -1
- package/KeyPress/cjs/index.development.js +56 -0
- package/KeyPress/cjs/index.production.js +1 -0
- package/KeyPress/index.d.ts +8 -7
- package/KeyPress/index.js +5 -53
- package/KeyPress/package.json +2 -5
- package/Line/cjs/index.development.js +20 -0
- package/Line/cjs/index.production.js +1 -0
- package/Line/cjs/style.development.css +1 -0
- package/Line/cjs/style.production.css +1 -0
- package/Line/index.js +5 -18
- package/Line/package.json +1 -1
- package/Link/cjs/index.development.js +22 -0
- package/Link/cjs/index.production.js +1 -0
- package/Link/cjs/style.development.css +1 -0
- package/Link/cjs/style.production.css +1 -0
- package/Link/index.js +5 -20
- package/Link/package.json +1 -1
- package/List/cjs/index.development.js +25 -0
- package/List/cjs/index.production.js +1 -0
- package/List/cjs/style.development.css +1 -0
- package/List/cjs/style.production.css +1 -0
- package/List/index.js +5 -23
- package/List/package.json +1 -1
- package/Media/breakpoints.d.ts +17 -0
- package/Media/cjs/index.development.js +60 -0
- package/Media/cjs/index.production.js +1 -0
- package/Media/index.d.ts +11 -0
- package/Media/index.js +7 -0
- package/{Tooltip → Media}/package.json +3 -3
- package/Media/useMedia.d.ts +7 -0
- package/{Tooltip/Trigger/index.js → OutsideClick/cjs/index.development.js} +32 -24
- package/OutsideClick/cjs/index.production.js +1 -0
- package/OutsideClick/index.d.ts +6 -3
- package/OutsideClick/index.js +4 -74
- package/OutsideClick/package.json +2 -5
- package/Picture/cjs/index.development.js +25 -0
- package/Picture/cjs/index.production.js +1 -0
- package/Picture/cjs/style.development.css +1 -0
- package/Picture/cjs/style.production.css +1 -0
- package/Picture/index.js +5 -23
- package/Picture/package.json +1 -1
- package/PortableOverlay/cjs/index.development.js +111 -0
- package/PortableOverlay/cjs/index.production.js +1 -0
- package/PortableOverlay/cjs/style.development.css +1 -0
- package/PortableOverlay/cjs/style.production.css +1 -0
- package/PortableOverlay/index.d.ts +6 -4
- package/PortableOverlay/index.js +5 -112
- package/PortableOverlay/package.json +1 -2
- package/Portal/cjs/index.development.js +57 -0
- package/Portal/cjs/index.production.js +1 -0
- package/Portal/index.d.ts +6 -4
- package/Portal/index.js +5 -52
- package/Portal/package.json +2 -5
- package/Rating/cjs/index.development.js +105 -0
- package/Rating/cjs/index.production.js +1 -0
- package/Rating/cjs/style.development.css +1 -0
- package/Rating/cjs/style.production.css +1 -0
- package/Rating/index.d.ts +6 -5
- package/Rating/index.js +4 -98
- package/Rating/package.json +1 -1
- package/SafeQuery/cjs/index.development.js +181 -0
- package/SafeQuery/cjs/index.production.js +1 -0
- package/SafeQuery/cjs/style.development.css +1 -0
- package/SafeQuery/cjs/style.production.css +1 -0
- package/SafeQuery/components/Error.d.ts +7 -0
- package/SafeQuery/index.d.ts +10 -0
- package/SafeQuery/index.js +7 -0
- package/SafeQuery/package.json +12 -0
- package/Scroll/cjs/index.development.js +40 -0
- package/Scroll/cjs/index.production.js +1 -0
- package/Scroll/cjs/style.development.css +1 -0
- package/Scroll/cjs/style.production.css +1 -0
- package/Scroll/index.d.ts +18 -16
- package/Scroll/index.js +4 -76
- package/Scroll/package.json +1 -1
- package/ScrollControls/cjs/index.development.js +243 -0
- package/ScrollControls/cjs/index.production.js +1 -0
- package/ScrollControls/cjs/style.development.css +1 -0
- package/ScrollControls/cjs/style.production.css +1 -0
- package/ScrollControls/index.d.ts +16 -6
- package/ScrollControls/index.js +4 -244
- package/ScrollControls/package.json +1 -2
- package/SideOverlay/cjs/index.development.js +210 -0
- package/SideOverlay/cjs/index.production.js +1 -0
- package/SideOverlay/cjs/style.development.css +1 -0
- package/SideOverlay/cjs/style.production.css +1 -0
- package/SideOverlay/index.d.ts +28 -13
- package/SideOverlay/index.js +4 -251
- package/SideOverlay/package.json +1 -1
- package/SimpleSlider/cjs/index.development.js +433 -0
- package/SimpleSlider/cjs/index.production.js +1 -0
- package/SimpleSlider/cjs/style.development.css +1 -0
- package/SimpleSlider/cjs/style.production.css +1 -0
- package/SimpleSlider/index.d.ts +17 -3
- package/SimpleSlider/index.js +4 -477
- package/SimpleSlider/package.json +1 -1
- package/Skeleton/cjs/index.development.js +103 -0
- package/Skeleton/cjs/index.production.js +1 -0
- package/Skeleton/cjs/style.development.css +1 -0
- package/Skeleton/cjs/style.production.css +1 -0
- package/Skeleton/index.d.ts +9 -5
- package/Skeleton/index.js +4 -110
- package/Skeleton/package.json +1 -1
- package/Spinner/cjs/index.development.js +85 -0
- package/Spinner/cjs/index.production.js +1 -0
- package/Spinner/cjs/style.development.css +1 -0
- package/Spinner/cjs/style.production.css +1 -0
- package/Spinner/index.d.ts +7 -6
- package/Spinner/index.js +5 -76
- package/Spinner/package.json +1 -1
- package/Text/cjs/index.development.js +20 -0
- package/Text/cjs/index.production.js +1 -0
- package/Text/cjs/style.development.css +1 -0
- package/Text/cjs/style.production.css +1 -0
- package/Text/index.js +5 -18
- package/Text/package.json +1 -1
- package/TextEmoji/cjs/index.development.js +94 -0
- package/TextEmoji/cjs/index.production.js +1 -0
- package/TextEmoji/index.d.ts +4 -4
- package/TextEmoji/index.js +4 -84
- package/TextEmoji/package.json +1 -1
- package/Tumbler/cjs/index.development.js +110 -0
- package/Tumbler/cjs/index.production.js +1 -0
- package/Tumbler/cjs/style.development.css +1 -0
- package/Tumbler/cjs/style.production.css +1 -0
- package/Tumbler/index.d.ts +4 -4
- package/Tumbler/index.js +4 -95
- package/Tumbler/package.json +1 -1
- package/package.json +15 -9
- package/Body/style.css +0 -741
- package/Box/style.css +0 -9676
- package/Button/style.css +0 -3393
- package/Checkbox/style.css +0 -133
- package/Flex/style.css +0 -786
- package/Grid/style.css +0 -7350
- package/Icon/style.css +0 -46
- package/Image/style.css +0 -664
- package/Input/style.css +0 -345
- package/Line/style.css +0 -138
- package/Link/style.css +0 -259
- package/List/style.css +0 -312
- package/Picture/style.css +0 -1426
- package/PortableOverlay/style.css +0 -44
- package/Rating/style.css +0 -26
- package/Scroll/style.css +0 -169
- package/ScrollControls/style.css +0 -67
- package/SideOverlay/style.css +0 -208
- package/SimpleSlider/style.css +0 -134
- package/Skeleton/style.css +0 -145
- package/Spinner/style.css +0 -80
- package/Text/style.css +0 -840
- package/Tooltip/Popper/index.d.ts +0 -12
- package/Tooltip/Popper/index.js +0 -88
- package/Tooltip/Popper/package.json +0 -9
- package/Tooltip/Popper/style.css +0 -133
- package/Tooltip/Trigger/index.d.ts +0 -5
- package/Tooltip/Trigger/package.json +0 -9
- package/Tooltip/Trigger/style.css +0 -36
- package/Tooltip/index.d.ts +0 -24
- package/Tooltip/index.js +0 -284
- package/Tooltip/style.css +0 -170
- package/Tooltip/utils.d.ts +0 -1
- package/Tumbler/style.css +0 -118
package/Scroll/index.js
CHANGED
|
@@ -1,79 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var evokit = require('evokit');
|
|
8
|
-
|
|
9
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
-
|
|
11
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
12
|
-
|
|
13
|
-
/******************************************************************************
|
|
14
|
-
Copyright (c) Microsoft Corporation.
|
|
15
|
-
|
|
16
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
17
|
-
purpose with or without fee is hereby granted.
|
|
18
|
-
|
|
19
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
20
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
21
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
22
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
23
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
24
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
25
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
26
|
-
***************************************************************************** */
|
|
27
|
-
/* global Reflect, Promise */
|
|
28
|
-
|
|
29
|
-
var extendStatics = function(d, b) {
|
|
30
|
-
extendStatics = Object.setPrototypeOf ||
|
|
31
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
32
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
33
|
-
return extendStatics(d, b);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
function __extends(d, b) {
|
|
37
|
-
if (typeof b !== "function" && b !== null)
|
|
38
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
39
|
-
extendStatics(d, b);
|
|
40
|
-
function __() { this.constructor = d; }
|
|
41
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3
|
+
if (process.env.NODE_ENV === 'production') {
|
|
4
|
+
module.exports = require('./cjs/index.production.js');
|
|
5
|
+
} else {
|
|
6
|
+
module.exports = require('./cjs/index.development.js');
|
|
42
7
|
}
|
|
43
|
-
|
|
44
|
-
var css = {"ek-scroll":"Scroll__ek-scroll___m6Vr5","ek-scroll__item":"Scroll__ek-scroll__item___bfetG","ek-scroll__item_blackhole_width-fit-content":"Scroll__ek-scroll__item_blackhole_width-fit-content___k-fNo","ek-scroll__item_blackhole_width-max-content":"Scroll__ek-scroll__item_blackhole_width-max-content___s8gGl","ek-scroll_padding_xxs":"Scroll__ek-scroll_padding_xxs___9vZpV","ek-scroll_padding_xs":"Scroll__ek-scroll_padding_xs___L5kMA","ek-scroll_padding_s":"Scroll__ek-scroll_padding_s___Nr3Ig","ek-scroll_padding_m":"Scroll__ek-scroll_padding_m___hcRCz","ek-scroll_padding_l":"Scroll__ek-scroll_padding_l___SKeiS","ek-scroll_padding_xl":"Scroll__ek-scroll_padding_xl___MG4J-","ek-scroll_padding_xxl":"Scroll__ek-scroll_padding_xxl___m8ou2","ek-scroll_padding_3xl":"Scroll__ek-scroll_padding_3xl___xy72W","ek-scroll_padding_4xl":"Scroll__ek-scroll_padding_4xl___gzW-I","ek-scroll_padding_5xl":"Scroll__ek-scroll_padding_5xl___JErmt","ek-scroll_column_1":"Scroll__ek-scroll_column_1___n5mTi","ek-scroll_column_2":"Scroll__ek-scroll_column_2___GqdmF","ek-scroll_column_3":"Scroll__ek-scroll_column_3___DKZCp","ek-scroll_column_4":"Scroll__ek-scroll_column_4___-Nf-L","ek-scroll_column_5":"Scroll__ek-scroll_column_5___OxDq-","ek-scroll_column_6":"Scroll__ek-scroll_column_6___wP8Pu","ek-scroll_column_7":"Scroll__ek-scroll_column_7___-ZDSB","ek-scroll_column_8":"Scroll__ek-scroll_column_8___PnnsU","ek-scroll_column_9":"Scroll__ek-scroll_column_9___DDqgb","ek-scroll_column_10":"Scroll__ek-scroll_column_10___Hh-uZ","ek-scroll_gap_xxs":"Scroll__ek-scroll_gap_xxs___15vfK","ek-scroll_gap_xs":"Scroll__ek-scroll_gap_xs___Kvr2J","ek-scroll_gap_s":"Scroll__ek-scroll_gap_s___71-or","ek-scroll_gap_m":"Scroll__ek-scroll_gap_m___glUvB","ek-scroll_gap_l":"Scroll__ek-scroll_gap_l___pQC7Z","ek-scroll_gap_xl":"Scroll__ek-scroll_gap_xl___L1iAD","ek-scroll_gap_xxl":"Scroll__ek-scroll_gap_xxl___wVNm-","ek-scroll_gap_3xl":"Scroll__ek-scroll_gap_3xl___4tQXK","ek-scroll_gap_4xl":"Scroll__ek-scroll_gap_4xl___1-5dw","ek-scroll_gap_5xl":"Scroll__ek-scroll_gap_5xl___ym2qM","ek-scroll_bar_none":"Scroll__ek-scroll_bar_none___c1gVV","ek-scroll_bar_auto":"Scroll__ek-scroll_bar_auto___-TbaH","ek-scroll_align_normal":"Scroll__ek-scroll_align_normal___zoDjM","ek-scroll_align_start":"Scroll__ek-scroll_align_start___4mACC","ek-scroll_align_center":"Scroll__ek-scroll_align_center___3PWHW","ek-scroll_align_end":"Scroll__ek-scroll_align_end___AwLLA"};
|
|
45
|
-
|
|
46
|
-
var _a;
|
|
47
|
-
var Scroll = evokit.createBlock('ul', 'scroll', ['align', 'bar', 'column', 'gap', 'padding'], {
|
|
48
|
-
css: css
|
|
49
|
-
});
|
|
50
|
-
Scroll.Item = evokit.createBlock('li', 'scroll__item', [], {
|
|
51
|
-
css: css
|
|
52
|
-
}); // Only for StyleGuide
|
|
53
|
-
|
|
54
|
-
var StyleGuide =
|
|
55
|
-
/** @class */
|
|
56
|
-
function (_super) {
|
|
57
|
-
__extends(StyleGuide, _super);
|
|
58
|
-
|
|
59
|
-
function StyleGuide() {
|
|
60
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
StyleGuide.prototype.render = function () {
|
|
64
|
-
return null;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
StyleGuide.displayName = 'Scroll';
|
|
68
|
-
StyleGuide.propTypes = (_a = {},
|
|
69
|
-
/** Скрыть/показать полосу прокрутки */
|
|
70
|
-
_a['scroll-bar'] = PropTypes__default["default"].oneOf(['none', 'auto']),
|
|
71
|
-
/** Выравнивание ячеек по горизонтальной оси */
|
|
72
|
-
_a['scroll-align'] = PropTypes__default["default"].oneOf(['start', 'center', 'end', 'normal']), _a['scroll-column'] = PropTypes__default["default"].oneOf(['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']), _a['scroll-gap'] = PropTypes__default["default"].oneOf(['xxs', 'xs', 's', 'm', 'l', 'xl', 'xxl', '3xl', '4xl', '5xl']), _a['scroll-padding'] = PropTypes__default["default"].oneOf(['xxs', 'xs', 's', 'm', 'l', 'xl', 'xxl', '3xl', '4xl', '5xl']), _a);
|
|
73
|
-
return StyleGuide;
|
|
74
|
-
}(react.Component);
|
|
75
|
-
|
|
76
|
-
exports.Scroll = Scroll;
|
|
77
|
-
exports.StyleGuide = StyleGuide;
|
|
78
|
-
|
|
79
|
-
require('./style.css');
|
package/Scroll/package.json
CHANGED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var classNames = require('classnames');
|
|
7
|
+
var ttag = require('ttag');
|
|
8
|
+
var Button = require('@prom-ui/core/Button');
|
|
9
|
+
var Icon = require('@prom-ui/core/Icon');
|
|
10
|
+
var Left = require('@prom-ui/icons/Left');
|
|
11
|
+
var Right = require('@prom-ui/icons/Right');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
function _interopNamespace(e) {
|
|
16
|
+
if (e && e.__esModule) return e;
|
|
17
|
+
var n = Object.create(null);
|
|
18
|
+
if (e) {
|
|
19
|
+
Object.keys(e).forEach(function (k) {
|
|
20
|
+
if (k !== 'default') {
|
|
21
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return e[k]; }
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
n["default"] = e;
|
|
30
|
+
return Object.freeze(n);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
34
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
35
|
+
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
36
|
+
|
|
37
|
+
/******************************************************************************
|
|
38
|
+
Copyright (c) Microsoft Corporation.
|
|
39
|
+
|
|
40
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
41
|
+
purpose with or without fee is hereby granted.
|
|
42
|
+
|
|
43
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
44
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
45
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
46
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
47
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
48
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
49
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
50
|
+
***************************************************************************** */
|
|
51
|
+
|
|
52
|
+
var __assign = function() {
|
|
53
|
+
__assign = Object.assign || function __assign(t) {
|
|
54
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
55
|
+
s = arguments[i];
|
|
56
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
};
|
|
60
|
+
return __assign.apply(this, arguments);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
function __rest(s, e) {
|
|
64
|
+
var t = {};
|
|
65
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
66
|
+
t[p] = s[p];
|
|
67
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
68
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
69
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
70
|
+
t[p[i]] = s[p[i]];
|
|
71
|
+
}
|
|
72
|
+
return t;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function __makeTemplateObject(cooked, raw) {
|
|
76
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
77
|
+
return cooked;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
var css = {"root":"ScrollControls__root___mOlOq","buttonCommon":"ScrollControls__buttonCommon___rZcyK","prev":"ScrollControls__prev___cF2KB ScrollControls__buttonCommon___rZcyK","next":"ScrollControls__next___9B-9g ScrollControls__buttonCommon___rZcyK","icon":"ScrollControls__icon___lzBzL","showOnHover":"ScrollControls__showOnHover___StbVV","hideOnDisabled":"ScrollControls__hideOnDisabled___IONkE"};
|
|
81
|
+
|
|
82
|
+
var DIRECTION_NEXT = 1;
|
|
83
|
+
var DIRECTION_PREV = -1;
|
|
84
|
+
var CONTROLS_UPDATE_DELAY = 100;
|
|
85
|
+
var ScrollControlsButton = function (_a) {
|
|
86
|
+
var _b, _c;
|
|
87
|
+
|
|
88
|
+
var scrollRef = _a.scrollRef,
|
|
89
|
+
_d = _a.hideOnDisabled,
|
|
90
|
+
hideOnDisabled = _d === void 0 ? false : _d,
|
|
91
|
+
_e = _a.isActive,
|
|
92
|
+
isActive = _e === void 0 ? true : _e,
|
|
93
|
+
onClickNext = _a.onClickNext,
|
|
94
|
+
onClickPrev = _a.onClickPrev,
|
|
95
|
+
zIndex = _a.zIndex,
|
|
96
|
+
_f = _a.theme,
|
|
97
|
+
theme = _f === void 0 ? 'white' : _f,
|
|
98
|
+
children = _a.children;
|
|
99
|
+
var updateControlsTimer = React.useRef(null);
|
|
100
|
+
|
|
101
|
+
var _g = React.useState({
|
|
102
|
+
prev: false,
|
|
103
|
+
next: false
|
|
104
|
+
}),
|
|
105
|
+
controlsVisible = _g[0],
|
|
106
|
+
setControlsVisible = _g[1];
|
|
107
|
+
|
|
108
|
+
var updateControlsVisible = function (nextScrollLeft) {
|
|
109
|
+
var _a = scrollRef.current,
|
|
110
|
+
scrollLeft = _a.scrollLeft,
|
|
111
|
+
scrollWidth = _a.scrollWidth,
|
|
112
|
+
clientWidth = _a.clientWidth;
|
|
113
|
+
var currentScrollLeft = (Number.isInteger(nextScrollLeft) ? nextScrollLeft : scrollLeft) || 0;
|
|
114
|
+
setControlsVisible({
|
|
115
|
+
prev: currentScrollLeft > 1,
|
|
116
|
+
next: currentScrollLeft < scrollWidth - clientWidth
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var updateScrollLeft = function (direction) {
|
|
121
|
+
var _a = scrollRef.current,
|
|
122
|
+
scrollLeft = _a.scrollLeft,
|
|
123
|
+
clientWidth = _a.clientWidth;
|
|
124
|
+
var offset = clientWidth * direction;
|
|
125
|
+
updateControlsVisible(scrollLeft + offset);
|
|
126
|
+
requestAnimationFrame(function () {
|
|
127
|
+
if (scrollRef.current) {
|
|
128
|
+
scrollRef.current.scrollBy({
|
|
129
|
+
left: offset,
|
|
130
|
+
behavior: 'smooth'
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
var handleOnClickPrev = function () {
|
|
137
|
+
if (typeof onClickPrev === 'function') {
|
|
138
|
+
onClickPrev();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
updateScrollLeft(DIRECTION_PREV);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
var handleOnClickNext = function () {
|
|
145
|
+
if (typeof onClickNext === 'function') {
|
|
146
|
+
onClickNext();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
updateScrollLeft(DIRECTION_NEXT);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
var handleOnScroll = function () {
|
|
153
|
+
clearTimeout(updateControlsTimer.current || 0);
|
|
154
|
+
updateControlsTimer.current = setTimeout(updateControlsVisible, CONTROLS_UPDATE_DELAY);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
React.useEffect(function () {
|
|
158
|
+
if (scrollRef.current && isActive) {
|
|
159
|
+
updateControlsVisible();
|
|
160
|
+
scrollRef.current.addEventListener('scroll', handleOnScroll);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return function () {
|
|
164
|
+
if (scrollRef.current && isActive) {
|
|
165
|
+
scrollRef.current.removeEventListener('scroll', handleOnScroll);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}, [isActive, children]);
|
|
169
|
+
|
|
170
|
+
if (isActive && (controlsVisible.prev || controlsVisible.next)) {
|
|
171
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(Button.Button, {
|
|
172
|
+
"button-theme": theme,
|
|
173
|
+
"button-round": 'xs',
|
|
174
|
+
"button-weight": 'normal',
|
|
175
|
+
"button-padding": 'none xxs',
|
|
176
|
+
className: classNames__default["default"](css.prev, (_b = {}, _b[css.hideOnDisabled] = hideOnDisabled, _b)),
|
|
177
|
+
onClick: handleOnClickPrev,
|
|
178
|
+
style: {
|
|
179
|
+
zIndex: zIndex
|
|
180
|
+
},
|
|
181
|
+
disabled: !controlsVisible.prev,
|
|
182
|
+
title: ttag.t(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\u041D\u0430\u0437\u0430\u0434"], ["\u041D\u0430\u0437\u0430\u0434"])))
|
|
183
|
+
}, React__default["default"].createElement(Icon.Icon, {
|
|
184
|
+
className: css.icon,
|
|
185
|
+
"icon-as": Left.Left
|
|
186
|
+
})), React__default["default"].createElement(Button.Button, {
|
|
187
|
+
"button-theme": theme,
|
|
188
|
+
"button-round": 'xs',
|
|
189
|
+
"button-weight": 'normal',
|
|
190
|
+
"button-padding": 'none xxs',
|
|
191
|
+
className: classNames__default["default"](css.next, (_c = {}, _c[css.hideOnDisabled] = hideOnDisabled, _c)),
|
|
192
|
+
onClick: handleOnClickNext,
|
|
193
|
+
style: {
|
|
194
|
+
zIndex: zIndex
|
|
195
|
+
},
|
|
196
|
+
disabled: !controlsVisible.next,
|
|
197
|
+
title: ttag.t(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\u0414\u0430\u043B\u0435\u0435"], ["\u0414\u0430\u043B\u0435\u0435"])))
|
|
198
|
+
}, React__default["default"].createElement(Icon.Icon, {
|
|
199
|
+
className: css.icon,
|
|
200
|
+
"icon-as": Right.Right
|
|
201
|
+
})));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return null;
|
|
205
|
+
};
|
|
206
|
+
var templateObject_1, templateObject_2;
|
|
207
|
+
|
|
208
|
+
var ScrollControls = React__namespace.forwardRef(function (_a, ref) {
|
|
209
|
+
var _b;
|
|
210
|
+
|
|
211
|
+
var children = _a.children,
|
|
212
|
+
className = _a.className,
|
|
213
|
+
_c = _a.hideOnDisabled,
|
|
214
|
+
hideOnDisabled = _c === void 0 ? false : _c,
|
|
215
|
+
_d = _a.isActive,
|
|
216
|
+
isActive = _d === void 0 ? true : _d,
|
|
217
|
+
onClickNext = _a.onClickNext,
|
|
218
|
+
onClickPrev = _a.onClickPrev,
|
|
219
|
+
_e = _a.showOnHover,
|
|
220
|
+
showOnHover = _e === void 0 ? false : _e,
|
|
221
|
+
zIndex = _a.zIndex,
|
|
222
|
+
_f = _a.theme,
|
|
223
|
+
theme = _f === void 0 ? 'white' : _f,
|
|
224
|
+
props = __rest(_a, ["children", "className", "hideOnDisabled", "isActive", "onClickNext", "onClickPrev", "showOnHover", "zIndex", "theme"]);
|
|
225
|
+
|
|
226
|
+
var scrollRef = React__namespace.useRef(null);
|
|
227
|
+
return React__namespace.createElement("div", __assign({
|
|
228
|
+
ref: ref,
|
|
229
|
+
className: classNames__default["default"](css.root, className, (_b = {}, _b[css.showOnHover] = showOnHover, _b))
|
|
230
|
+
}, props), children(scrollRef), React__namespace.createElement(ScrollControlsButton, {
|
|
231
|
+
scrollRef: scrollRef,
|
|
232
|
+
hideOnDisabled: hideOnDisabled,
|
|
233
|
+
isActive: isActive,
|
|
234
|
+
onClickNext: onClickNext,
|
|
235
|
+
onClickPrev: onClickPrev,
|
|
236
|
+
zIndex: zIndex,
|
|
237
|
+
theme: theme
|
|
238
|
+
}, children));
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
exports.ScrollControls = ScrollControls;
|
|
242
|
+
|
|
243
|
+
require('./style.development.css');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("classnames"),r=require("ttag"),n=require("@prom-ui/core/Button"),o=require("@prom-ui/core/Icon"),i=require("@prom-ui/icons/Left"),c=require("@prom-ui/icons/Right");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(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 a=l(e),s=u(e),f=l(t),d=function(){return d=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},d.apply(this,arguments)};function v(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var m,p,b="mOlOq",h="cF2KB rZcyK",O="_9B-9g rZcyK",y="lzBzL",x="StbVV",g="IONkE",j=function(t){var l,u,s=t.scrollRef,d=t.hideOnDisabled,b=void 0!==d&&d,x=t.isActive,j=void 0===x||x,w=t.onClickNext,E=t.onClickPrev,N=t.zIndex,P=t.theme,k=void 0===P?"white":P,I=t.children,C=e.useRef(null),q=e.useState({prev:!1,next:!1}),z=q[0],B=q[1],L=function(e){var t=s.current,r=t.scrollLeft,n=t.scrollWidth,o=t.clientWidth,i=(Number.isInteger(e)?e:r)||0;B({prev:i>1,next:i<n-o})},R=function(e){var t=s.current,r=t.scrollLeft,n=t.clientWidth*e;L(r+n),requestAnimationFrame((function(){s.current&&s.current.scrollBy({left:n,behavior:"smooth"})}))},A=function(){clearTimeout(C.current||0),C.current=setTimeout(L,100)};return e.useEffect((function(){return s.current&&j&&(L(),s.current.addEventListener("scroll",A)),function(){s.current&&j&&s.current.removeEventListener("scroll",A)}}),[j,I]),j&&(z.prev||z.next)?a.default.createElement(a.default.Fragment,null,a.default.createElement(n.Button,{"button-theme":k,"button-round":"xs","button-weight":"normal","button-padding":"none xxs",className:f.default(h,(l={},l[g]=b,l)),onClick:function(){"function"==typeof E&&E(),R(-1)},style:{zIndex:N},disabled:!z.prev,title:r.t(m||(m=v(["Назад"],["Назад"])))},a.default.createElement(o.Icon,{className:y,"icon-as":i.Left})),a.default.createElement(n.Button,{"button-theme":k,"button-round":"xs","button-weight":"normal","button-padding":"none xxs",className:f.default(O,(u={},u[g]=b,u)),onClick:function(){"function"==typeof w&&w(),R(1)},style:{zIndex:N},disabled:!z.next,title:r.t(p||(p=v(["Далее"],["Далее"])))},a.default.createElement(o.Icon,{className:y,"icon-as":c.Right}))):null},w=s.forwardRef((function(e,t){var r,n=e.children,o=e.className,i=e.hideOnDisabled,c=void 0!==i&&i,l=e.isActive,u=void 0===l||l,a=e.onClickNext,v=e.onClickPrev,m=e.showOnHover,p=void 0!==m&&m,h=e.zIndex,O=e.theme,y=void 0===O?"white":O,g=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","className","hideOnDisabled","isActive","onClickNext","onClickPrev","showOnHover","zIndex","theme"]),w=s.useRef(null);return s.createElement("div",d({ref:t,className:f.default(b,o,(r={},r[x]=p,r))},g),n(w),s.createElement(j,{scrollRef:w,hideOnDisabled:c,isActive:u,onClickNext:a,onClickPrev:v,zIndex:h,theme:y},n))}));exports.ScrollControls=w,require("./style.production.css");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ScrollControls__root___mOlOq{position:relative;overflow:hidden}.ScrollControls__buttonCommon___rZcyK{position:absolute;top:50%;transform:translateY(-50%);border:0;box-shadow:0 0 10px rgba(0,0,0,.08);height:66px;max-width:30px;max-height:50%;min-height:24px}.ScrollControls__buttonCommon___rZcyK:disabled{opacity:.3;pointer-events:auto}.ScrollControls__buttonCommon___rZcyK:active{background:var(--black-200)}.ScrollControls__prev___cF2KB{left:0;margin-left:var(--pds-spacing-xs)}.ScrollControls__next___9B-9g{right:0;margin-right:var(--pds-spacing-xs)}.ScrollControls__icon___lzBzL{display:block;width:auto;height:24px;fill:currentColor;max-height:80%}.ScrollControls__showOnHover___StbVV .ScrollControls__next___9B-9g{right:-40px}.ScrollControls__showOnHover___StbVV .ScrollControls__prev___cF2KB{left:-40px}.ScrollControls__hideOnDisabled___IONkE:disabled{opacity:0;pointer-events:none;visibility:hidden}@media (hover:hover){.ScrollControls__showOnHover___StbVV:hover .ScrollControls__next___9B-9g{right:0}.ScrollControls__showOnHover___StbVV:hover .ScrollControls__prev___cF2KB{left:0}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.mOlOq{position:relative;overflow:hidden}.rZcyK{position:absolute;top:50%;transform:translateY(-50%);border:0;box-shadow:0 0 10px rgba(0,0,0,.08);height:66px;max-width:30px;max-height:50%;min-height:24px}.rZcyK:disabled{opacity:.3;pointer-events:auto}.rZcyK:active{background:var(--black-200)}.cF2KB{left:0;margin-left:var(--pds-spacing-xs)}._9B-9g{right:0;margin-right:var(--pds-spacing-xs)}.lzBzL{display:block;width:auto;height:24px;fill:currentColor;max-height:80%}.StbVV ._9B-9g{right:-40px}.StbVV .cF2KB{left:-40px}.IONkE:disabled{opacity:0;pointer-events:none;visibility:hidden}@media (hover:hover){.StbVV:hover ._9B-9g{right:0}.StbVV:hover .cF2KB{left:0}}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare type ScrollControlsProps = React.ComponentProps<"div"> & {
|
|
3
|
+
/** Принимает children как функцию, `(scrollRef) =>` */
|
|
4
|
+
children: (ref: React.RefObject<HTMLElement>) => any;
|
|
5
|
+
/** Показывать при наведении */
|
|
6
6
|
showOnHover?: boolean;
|
|
7
|
+
/** Скрыть если не активно */
|
|
8
|
+
hideOnDisabled?: boolean;
|
|
9
|
+
/** Если передать `false` компонент перестанет работать */
|
|
10
|
+
isActive?: boolean;
|
|
11
|
+
onClickNext?: () => void;
|
|
12
|
+
onClickPrev?: () => void;
|
|
13
|
+
/** Устанавливает цвет кнопок */
|
|
14
|
+
theme?: 'white' | 'gray';
|
|
15
|
+
/** Устанавливает z-index кнопкам */
|
|
16
|
+
zIndex?: number;
|
|
7
17
|
};
|
|
8
|
-
export declare const ScrollControls: React.
|
|
18
|
+
export declare const ScrollControls: React.ForwardRefExoticComponent<Pick<ScrollControlsProps, "hideOnDisabled" | "isActive" | "onClickNext" | "onClickPrev" | "showOnHover" | "zIndex" | "theme" | "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
|
package/ScrollControls/index.js
CHANGED
|
@@ -1,247 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var classNames = require('classnames');
|
|
8
|
-
var ttag = require('ttag');
|
|
9
|
-
var Button = require('@prom-ui/core/Button');
|
|
10
|
-
var Icon = require('@prom-ui/core/Icon');
|
|
11
|
-
var Left = require('@prom-ui/icons/Left');
|
|
12
|
-
var Right = require('@prom-ui/icons/Right');
|
|
13
|
-
|
|
14
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
-
|
|
16
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
18
|
-
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
19
|
-
|
|
20
|
-
/******************************************************************************
|
|
21
|
-
Copyright (c) Microsoft Corporation.
|
|
22
|
-
|
|
23
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
24
|
-
purpose with or without fee is hereby granted.
|
|
25
|
-
|
|
26
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
27
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
28
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
29
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
30
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
31
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
32
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
33
|
-
***************************************************************************** */
|
|
34
|
-
|
|
35
|
-
var __assign = function() {
|
|
36
|
-
__assign = Object.assign || function __assign(t) {
|
|
37
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
38
|
-
s = arguments[i];
|
|
39
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
40
|
-
}
|
|
41
|
-
return t;
|
|
42
|
-
};
|
|
43
|
-
return __assign.apply(this, arguments);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
function __rest(s, e) {
|
|
47
|
-
var t = {};
|
|
48
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
49
|
-
t[p] = s[p];
|
|
50
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
51
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
52
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
53
|
-
t[p[i]] = s[p[i]];
|
|
54
|
-
}
|
|
55
|
-
return t;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function __makeTemplateObject(cooked, raw) {
|
|
59
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
60
|
-
return cooked;
|
|
3
|
+
if (process.env.NODE_ENV === 'production') {
|
|
4
|
+
module.exports = require('./cjs/index.production.js');
|
|
5
|
+
} else {
|
|
6
|
+
module.exports = require('./cjs/index.development.js');
|
|
61
7
|
}
|
|
62
|
-
|
|
63
|
-
var css = {"root":"ScrollControls__root___mOlOq","buttonCommon":"ScrollControls__buttonCommon___rZcyK","prev":"ScrollControls__prev___cF2KB ScrollControls__buttonCommon___rZcyK","next":"ScrollControls__next___9B-9g ScrollControls__buttonCommon___rZcyK","icon":"ScrollControls__icon___lzBzL","showOnHover":"ScrollControls__showOnHover___StbVV","hideOnDisabled":"ScrollControls__hideOnDisabled___IONkE"};
|
|
64
|
-
|
|
65
|
-
var DIRECTION_NEXT = 1;
|
|
66
|
-
var DIRECTION_PREV = -1;
|
|
67
|
-
var CONTROLS_UPDATE_DELAY = 100;
|
|
68
|
-
var ScrollControlsButton = function (_a) {
|
|
69
|
-
var _b, _c;
|
|
70
|
-
|
|
71
|
-
var scrollRef = _a.scrollRef,
|
|
72
|
-
_d = _a.hideOnDisabled,
|
|
73
|
-
hideOnDisabled = _d === void 0 ? false : _d,
|
|
74
|
-
_e = _a.isActive,
|
|
75
|
-
isActive = _e === void 0 ? true : _e,
|
|
76
|
-
onClickNext = _a.onClickNext,
|
|
77
|
-
onClickPrev = _a.onClickPrev,
|
|
78
|
-
zIndex = _a.zIndex,
|
|
79
|
-
_f = _a.theme,
|
|
80
|
-
theme = _f === void 0 ? 'white' : _f,
|
|
81
|
-
children = _a.children;
|
|
82
|
-
var updateControlsTimer = React.useRef(null);
|
|
83
|
-
|
|
84
|
-
var _g = React.useState({
|
|
85
|
-
prev: false,
|
|
86
|
-
next: false
|
|
87
|
-
}),
|
|
88
|
-
controlsVisible = _g[0],
|
|
89
|
-
setControlsVisible = _g[1];
|
|
90
|
-
|
|
91
|
-
var updateControlsVisible = function (nextScrollLeft) {
|
|
92
|
-
var _a = scrollRef.current,
|
|
93
|
-
scrollLeft = _a.scrollLeft,
|
|
94
|
-
scrollWidth = _a.scrollWidth,
|
|
95
|
-
clientWidth = _a.clientWidth;
|
|
96
|
-
var currentScrollLeft = (Number.isInteger(nextScrollLeft) ? nextScrollLeft : scrollLeft) || 0;
|
|
97
|
-
setControlsVisible({
|
|
98
|
-
prev: currentScrollLeft > 1,
|
|
99
|
-
next: currentScrollLeft < scrollWidth - clientWidth
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
var updateScrollLeft = function (direction) {
|
|
104
|
-
var _a = scrollRef.current,
|
|
105
|
-
scrollLeft = _a.scrollLeft,
|
|
106
|
-
clientWidth = _a.clientWidth;
|
|
107
|
-
var offset = clientWidth * direction;
|
|
108
|
-
updateControlsVisible(scrollLeft + offset);
|
|
109
|
-
requestAnimationFrame(function () {
|
|
110
|
-
if (scrollRef.current) {
|
|
111
|
-
scrollRef.current.scrollBy({
|
|
112
|
-
left: offset,
|
|
113
|
-
behavior: 'smooth'
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
var handleOnClickPrev = function () {
|
|
120
|
-
if (typeof onClickPrev === 'function') {
|
|
121
|
-
onClickPrev();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
updateScrollLeft(DIRECTION_PREV);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
var handleOnClickNext = function () {
|
|
128
|
-
if (typeof onClickNext === 'function') {
|
|
129
|
-
onClickNext();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
updateScrollLeft(DIRECTION_NEXT);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
var handleOnScroll = function () {
|
|
136
|
-
clearTimeout(updateControlsTimer.current || 0);
|
|
137
|
-
updateControlsTimer.current = setTimeout(updateControlsVisible, CONTROLS_UPDATE_DELAY);
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
React.useEffect(function () {
|
|
141
|
-
if (scrollRef.current && isActive) {
|
|
142
|
-
updateControlsVisible();
|
|
143
|
-
scrollRef.current.addEventListener('scroll', handleOnScroll);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return function () {
|
|
147
|
-
if (scrollRef.current && isActive) {
|
|
148
|
-
scrollRef.current.removeEventListener('scroll', handleOnScroll);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
}, [isActive, children]);
|
|
152
|
-
|
|
153
|
-
if (isActive && (controlsVisible.prev || controlsVisible.next)) {
|
|
154
|
-
return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(Button.Button, {
|
|
155
|
-
"button-theme": theme,
|
|
156
|
-
"button-round": 'xs',
|
|
157
|
-
"button-weight": 'normal',
|
|
158
|
-
"button-padding": 'none xxs',
|
|
159
|
-
className: classNames__default["default"](css.prev, (_b = {}, _b[css.hideOnDisabled] = hideOnDisabled, _b)),
|
|
160
|
-
onClick: handleOnClickPrev,
|
|
161
|
-
style: {
|
|
162
|
-
zIndex: zIndex
|
|
163
|
-
},
|
|
164
|
-
disabled: !controlsVisible.prev,
|
|
165
|
-
title: ttag.t(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\u041D\u0430\u0437\u0430\u0434"], ["\u041D\u0430\u0437\u0430\u0434"])))
|
|
166
|
-
}, React__default["default"].createElement(Icon.Icon, {
|
|
167
|
-
className: css.icon,
|
|
168
|
-
"icon-as": Left.Left
|
|
169
|
-
})), React__default["default"].createElement(Button.Button, {
|
|
170
|
-
"button-theme": theme,
|
|
171
|
-
"button-round": 'xs',
|
|
172
|
-
"button-weight": 'normal',
|
|
173
|
-
"button-padding": 'none xxs',
|
|
174
|
-
className: classNames__default["default"](css.next, (_c = {}, _c[css.hideOnDisabled] = hideOnDisabled, _c)),
|
|
175
|
-
onClick: handleOnClickNext,
|
|
176
|
-
style: {
|
|
177
|
-
zIndex: zIndex
|
|
178
|
-
},
|
|
179
|
-
disabled: !controlsVisible.next,
|
|
180
|
-
title: ttag.t(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\u0414\u0430\u043B\u0435\u0435"], ["\u0414\u0430\u043B\u0435\u0435"])))
|
|
181
|
-
}, React__default["default"].createElement(Icon.Icon, {
|
|
182
|
-
className: css.icon,
|
|
183
|
-
"icon-as": Right.Right
|
|
184
|
-
})));
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return null;
|
|
188
|
-
};
|
|
189
|
-
var templateObject_1, templateObject_2;
|
|
190
|
-
|
|
191
|
-
var ScrollControls = React.forwardRef(function (_a, ref) {
|
|
192
|
-
var _b;
|
|
193
|
-
|
|
194
|
-
var children = _a.children,
|
|
195
|
-
className = _a.className,
|
|
196
|
-
_c = _a.hideOnDisabled,
|
|
197
|
-
hideOnDisabled = _c === void 0 ? false : _c,
|
|
198
|
-
_d = _a.isActive,
|
|
199
|
-
isActive = _d === void 0 ? true : _d,
|
|
200
|
-
onClickNext = _a.onClickNext,
|
|
201
|
-
onClickPrev = _a.onClickPrev,
|
|
202
|
-
_e = _a.showOnHover,
|
|
203
|
-
showOnHover = _e === void 0 ? false : _e,
|
|
204
|
-
zIndex = _a.zIndex,
|
|
205
|
-
_f = _a.theme,
|
|
206
|
-
theme = _f === void 0 ? 'white' : _f,
|
|
207
|
-
props = __rest(_a, ["children", "className", "hideOnDisabled", "isActive", "onClickNext", "onClickPrev", "showOnHover", "zIndex", "theme"]);
|
|
208
|
-
|
|
209
|
-
var scrollRef = React.useRef(null);
|
|
210
|
-
return React__default["default"].createElement("div", __assign({
|
|
211
|
-
ref: ref,
|
|
212
|
-
className: classNames__default["default"](css.root, className, (_b = {}, _b[css.showOnHover] = showOnHover, _b))
|
|
213
|
-
}, props), children(scrollRef), React__default["default"].createElement(ScrollControlsButton, {
|
|
214
|
-
scrollRef: scrollRef,
|
|
215
|
-
hideOnDisabled: hideOnDisabled,
|
|
216
|
-
isActive: isActive,
|
|
217
|
-
onClickNext: onClickNext,
|
|
218
|
-
onClickPrev: onClickPrev,
|
|
219
|
-
zIndex: zIndex,
|
|
220
|
-
theme: theme
|
|
221
|
-
}, children));
|
|
222
|
-
});
|
|
223
|
-
ScrollControls.propTypes = {
|
|
224
|
-
/** Принимает children как функцию, `(scrollRef) =>` */
|
|
225
|
-
// children: PropTypes.func.isRequired,
|
|
226
|
-
|
|
227
|
-
/** Если передать `false` компонент перестанет работать */
|
|
228
|
-
isActive: PropTypes__default["default"].bool,
|
|
229
|
-
onClickNext: PropTypes__default["default"].func,
|
|
230
|
-
onClickPrev: PropTypes__default["default"].func,
|
|
231
|
-
|
|
232
|
-
/** Показывать при наведении */
|
|
233
|
-
showOnHover: PropTypes__default["default"].bool,
|
|
234
|
-
|
|
235
|
-
/** Скрыть если не активно */
|
|
236
|
-
hideOnDisabled: PropTypes__default["default"].bool,
|
|
237
|
-
|
|
238
|
-
/** Устанавливает z-index кнопкам */
|
|
239
|
-
zIndex: PropTypes__default["default"].number,
|
|
240
|
-
|
|
241
|
-
/** Устанавливает цвет кнопок */
|
|
242
|
-
theme: PropTypes__default["default"].oneOf(['white', 'gray'])
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
exports.ScrollControls = ScrollControls;
|
|
246
|
-
|
|
247
|
-
require('./style.css');
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prom-ui/core/ScrollControls",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.30",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"*.css"
|
|
8
8
|
],
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@prom-ui/icons": "^0.0.5",
|
|
11
10
|
"classnames": "^2.3.1",
|
|
12
11
|
"ttag": "^1.7.24"
|
|
13
12
|
}
|