@megafon/ui-core 3.0.1 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -1
- package/dist/es/components/Banner/Banner.css +16 -0
- package/dist/es/components/Banner/Banner.js +10 -3
- package/dist/es/components/Button/Button.css +8 -8
- package/dist/es/components/Calendar/Calendar.d.ts +8 -0
- package/dist/es/components/Calendar/Calendar.js +20 -4
- package/dist/es/components/Calendar/components/Day/Day.d.ts +3 -0
- package/dist/es/components/Calendar/components/Day/Day.js +9 -5
- package/dist/es/components/Calendar/components/Month/Month.d.ts +5 -0
- package/dist/es/components/Calendar/components/Month/Month.js +14 -8
- package/dist/es/components/Carousel/Carousel.js +31 -6
- package/dist/es/components/Checkbox/Checkbox.css +3 -0
- package/dist/es/components/Collapse/Collapse.js +55 -28
- package/dist/es/components/ContentArea/ContentArea.css +32 -22
- package/dist/es/components/ContentArea/ContentArea.d.ts +3 -2
- package/dist/es/components/ContentArea/ContentArea.js +11 -11
- package/dist/es/components/Counter/Counter.d.ts +7 -0
- package/dist/es/components/Counter/Counter.js +15 -8
- package/dist/es/components/Logo/Logo.js +8 -10
- package/dist/es/components/NavArrow/NavArrow.d.ts +3 -0
- package/dist/es/components/NavArrow/NavArrow.js +8 -4
- package/dist/es/components/Paragraph/Paragraph.js +1 -1
- package/dist/es/components/Search/Search.d.ts +7 -0
- package/dist/es/components/Search/Search.js +16 -9
- package/dist/es/components/Switcher/Switcher.d.ts +4 -0
- package/dist/es/components/Switcher/Switcher.js +22 -10
- package/dist/es/components/Tabs/Tabs.css +1 -1
- package/dist/es/components/TextLink/TextLink.js +6 -8
- package/dist/es/components/Tile/Tile.d.ts +2 -0
- package/dist/es/components/Tile/Tile.js +9 -3
- package/dist/lib/components/Banner/Banner.css +16 -0
- package/dist/lib/components/Banner/Banner.js +10 -3
- package/dist/lib/components/Button/Button.css +8 -8
- package/dist/lib/components/Calendar/Calendar.d.ts +8 -0
- package/dist/lib/components/Calendar/Calendar.js +19 -3
- package/dist/lib/components/Calendar/components/Day/Day.d.ts +3 -0
- package/dist/lib/components/Calendar/components/Day/Day.js +8 -4
- package/dist/lib/components/Calendar/components/Month/Month.d.ts +5 -0
- package/dist/lib/components/Calendar/components/Month/Month.js +13 -7
- package/dist/lib/components/Carousel/Carousel.js +31 -6
- package/dist/lib/components/Checkbox/Checkbox.css +3 -0
- package/dist/lib/components/Collapse/Collapse.js +54 -30
- package/dist/lib/components/ContentArea/ContentArea.css +32 -22
- package/dist/lib/components/ContentArea/ContentArea.d.ts +3 -2
- package/dist/lib/components/ContentArea/ContentArea.js +11 -11
- package/dist/lib/components/Counter/Counter.d.ts +7 -0
- package/dist/lib/components/Counter/Counter.js +14 -7
- package/dist/lib/components/Logo/Logo.js +8 -10
- package/dist/lib/components/NavArrow/NavArrow.d.ts +3 -0
- package/dist/lib/components/NavArrow/NavArrow.js +7 -3
- package/dist/lib/components/Paragraph/Paragraph.js +1 -1
- package/dist/lib/components/Search/Search.d.ts +7 -0
- package/dist/lib/components/Search/Search.js +15 -8
- package/dist/lib/components/Switcher/Switcher.d.ts +4 -0
- package/dist/lib/components/Switcher/Switcher.js +25 -9
- package/dist/lib/components/Tabs/Tabs.css +1 -1
- package/dist/lib/components/TextLink/TextLink.js +6 -8
- package/dist/lib/components/Tile/Tile.d.ts +2 -0
- package/dist/lib/components/Tile/Tile.js +9 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,56 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.2.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.1.0...@megafon/ui-core@3.2.0) (2022-02-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **checkbox:** delete outline focus effect ([ecd98e7](https://github.com/MegafonWebLab/megafon-ui/commit/ecd98e7129ddd305ce6e21c1c98cdacc3670ff92))
|
|
12
|
+
* **tile:** delete unnecessary symbol ([1f0ed90](https://github.com/MegafonWebLab/megafon-ui/commit/1f0ed9009ef2cb9e5562f257640a623eceae225e))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **carousel:** fix data-attribute passing for NavArrow ([af0d26e](https://github.com/MegafonWebLab/megafon-ui/commit/af0d26ef85a19cdb4fd863a45b2c2b2365d9c086))
|
|
18
|
+
* **tile:** add target props for link ([e49d040](https://github.com/MegafonWebLab/megafon-ui/commit/e49d0402725e88b9fd7d80fd418acd81bea321ba))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# [3.1.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.0.2...@megafon/ui-core@3.1.0) (2022-02-22)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
* **carousel:** add resize listener to nav display ([12abd93](https://github.com/MegafonWebLab/megafon-ui/commit/12abd93d226676d2c4f78968c9d5de032783ec8d))
|
|
30
|
+
* **colors:** fix colors usage ([f2f59a8](https://github.com/MegafonWebLab/megafon-ui/commit/f2f59a81644c157394817af1531dabb1c0b67b19))
|
|
31
|
+
* **components:** better view of default props values ([1817ed5](https://github.com/MegafonWebLab/megafon-ui/commit/1817ed5cd17fd78a0911a89020138f05d7af9833))
|
|
32
|
+
* **contentarea:** add 'black' color prop value; deprecate 'default' color prop value; more examples ([e0b0c72](https://github.com/MegafonWebLab/megafon-ui/commit/e0b0c723a37f0e42ccb1c0d30df8ae36e9c82920))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Features
|
|
36
|
+
|
|
37
|
+
* **banner:** add opacity for slides ([bb403a1](https://github.com/MegafonWebLab/megafon-ui/commit/bb403a1d38fd0c1efd3e1df3ed72ea4e5c772c40))
|
|
38
|
+
* **collapse:** changed collapse animation via setTimeout to requestAnimationFrame ([06d7b4f](https://github.com/MegafonWebLab/megafon-ui/commit/06d7b4ff0f3cdf3cc22fb1d45e8401e259636cf5))
|
|
39
|
+
* **ui-core:** add dataAttrs prop for interactive elements of components that did not have ([f495833](https://github.com/MegafonWebLab/megafon-ui/commit/f495833b33ac7823ae5992a3f7eb8b7cef82c036))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## [3.0.2](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.0.1...@megafon/ui-core@3.0.2) (2022-02-15)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Bug Fixes
|
|
49
|
+
|
|
50
|
+
* **tile:** fixed dataAttrs type in tile component ([d380289](https://github.com/MegafonWebLab/megafon-ui/commit/d3802896c57dc112543c73169c04262f58a29f58))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
6
56
|
## [3.0.1](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.0.0...@megafon/ui-core@3.0.1) (2022-02-11)
|
|
7
57
|
|
|
8
58
|
|
|
@@ -65,7 +115,7 @@ remove depreacted value 'freshAsphalt'
|
|
|
65
115
|
* **contentarea**, **paragraph**, **storebanner** and **breadcrumbs** components from no don't have
|
|
66
116
|
'freshAsphalt' and 'clearWhite' as values for colorizing props
|
|
67
117
|
* **paragraph:** remove from color prop values: 'spbSky0', 'spbSky1', 'spbSky2'
|
|
68
|
-
* **paragraph**: prop color change values from 'base' to 'white' and from '
|
|
118
|
+
* **paragraph**: prop color change values from 'base' to 'white' and from 'content' to 'default';
|
|
69
119
|
remove deprecared values 'freshAsphalt' and 'clearWhite'
|
|
70
120
|
* **storebanner**: prop theme change value from 'black' to 'default'; remove deprecated value 'clearWhite'
|
|
71
121
|
* **tooltip:** change onOpen, onClose types; AccessibilityEventTypeNative from @megafon/ui-helpers
|
|
@@ -17,6 +17,15 @@
|
|
|
17
17
|
height: 540px;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
+
@media screen and (min-width: 1024px) {
|
|
21
|
+
.mfui-banner__slide {
|
|
22
|
+
-webkit-backface-visibility: hidden;
|
|
23
|
+
backface-visibility: hidden;
|
|
24
|
+
opacity: 0;
|
|
25
|
+
-webkit-transition: opacity 0.2s;
|
|
26
|
+
transition: opacity 0.2s;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
20
29
|
@media screen and (min-width: 1024px) and (max-width: 1279px) {
|
|
21
30
|
.mfui-banner__slide {
|
|
22
31
|
height: 420px;
|
|
@@ -27,6 +36,13 @@
|
|
|
27
36
|
height: 400px;
|
|
28
37
|
}
|
|
29
38
|
}
|
|
39
|
+
@media screen and (min-width: 1024px) {
|
|
40
|
+
.mfui-banner .swiper-slide-visible {
|
|
41
|
+
opacity: 1;
|
|
42
|
+
-webkit-transition: opacity 0.4s;
|
|
43
|
+
transition: opacity 0.4s;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
30
46
|
.mfui-banner__arrow {
|
|
31
47
|
position: absolute;
|
|
32
48
|
top: 50%;
|
|
@@ -159,6 +159,7 @@ var Banner = function Banner(_ref) {
|
|
|
159
159
|
className: cn('swiper'),
|
|
160
160
|
loop: loop,
|
|
161
161
|
autoplay: autoPlay ? getAutoPlayConfig(autoPlayDelay) : false,
|
|
162
|
+
watchSlidesVisibility: true,
|
|
162
163
|
onSwiper: handleSwiper,
|
|
163
164
|
onReachBeginning: handleReachBeginning,
|
|
164
165
|
onReachEnd: handleReachEnd,
|
|
@@ -171,14 +172,20 @@ var Banner = function Banner(_ref) {
|
|
|
171
172
|
key: i,
|
|
172
173
|
className: cn('slide', classes === null || classes === void 0 ? void 0 : classes.slide)
|
|
173
174
|
}), child);
|
|
174
|
-
})), /*#__PURE__*/React.createElement(NavArrow,
|
|
175
|
+
})), /*#__PURE__*/React.createElement(NavArrow, {
|
|
176
|
+
dataAttrs: {
|
|
177
|
+
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.arrowPrev
|
|
178
|
+
},
|
|
175
179
|
className: cn('arrow', {
|
|
176
180
|
prev: true
|
|
177
181
|
}, [classes.arrow]),
|
|
178
182
|
onClick: handlePrevClick,
|
|
179
183
|
disabled: !loop && isBeginning,
|
|
180
184
|
theme: navArrowTheme
|
|
181
|
-
})
|
|
185
|
+
}), /*#__PURE__*/React.createElement(NavArrow, {
|
|
186
|
+
dataAttrs: {
|
|
187
|
+
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.arrowNext
|
|
188
|
+
},
|
|
182
189
|
className: cn('arrow', {
|
|
183
190
|
next: true
|
|
184
191
|
}, [classes.arrow]),
|
|
@@ -186,7 +193,7 @@ var Banner = function Banner(_ref) {
|
|
|
186
193
|
onClick: handleNextClick,
|
|
187
194
|
disabled: !loop && isEnd,
|
|
188
195
|
theme: navArrowTheme
|
|
189
|
-
})
|
|
196
|
+
}), /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.pagination), {
|
|
190
197
|
className: cn('pagination', {
|
|
191
198
|
theme: navTheme,
|
|
192
199
|
'bottom-offset': withPaginationBottomOffset
|
|
@@ -302,14 +302,14 @@
|
|
|
302
302
|
fill: var(--stcWhite);
|
|
303
303
|
}
|
|
304
304
|
.mfui-button_no-touch.mfui-button_type_outline.mfui-button_theme_white {
|
|
305
|
-
--
|
|
306
|
-
--
|
|
305
|
+
--stcWhite7: rgba(255, 255, 255, 0.07);
|
|
306
|
+
--stcWhite14: rgba(255, 255, 255, 0.14);
|
|
307
307
|
}
|
|
308
308
|
.mfui-button_no-touch.mfui-button_type_outline.mfui-button_theme_white:not(.mfui-button_loading):hover {
|
|
309
|
-
background-color: var(--
|
|
309
|
+
background-color: var(--stcWhite7);
|
|
310
310
|
}
|
|
311
311
|
.mfui-button_no-touch.mfui-button_type_outline.mfui-button_theme_white:not(.mfui-button_loading):active {
|
|
312
|
-
background-color: var(--
|
|
312
|
+
background-color: var(--stcWhite14);
|
|
313
313
|
}
|
|
314
314
|
.mfui-button_type_outline.mfui-button_theme_black {
|
|
315
315
|
color: var(--stcBlack);
|
|
@@ -321,14 +321,14 @@
|
|
|
321
321
|
fill: var(--stcBlack);
|
|
322
322
|
}
|
|
323
323
|
.mfui-button_no-touch.mfui-button_type_outline.mfui-button_theme_black {
|
|
324
|
-
--
|
|
325
|
-
--
|
|
324
|
+
--stcBlack7: rgba(51, 51, 51, 0.07);
|
|
325
|
+
--stcBlack14: rgba(51, 51, 51, 0.14);
|
|
326
326
|
}
|
|
327
327
|
.mfui-button_no-touch.mfui-button_type_outline.mfui-button_theme_black:not(.mfui-button_loading):hover {
|
|
328
|
-
background-color: var(--
|
|
328
|
+
background-color: var(--stcBlack7);
|
|
329
329
|
}
|
|
330
330
|
.mfui-button_no-touch.mfui-button_type_outline.mfui-button_theme_black:not(.mfui-button_loading):active {
|
|
331
|
-
background-color: var(--
|
|
331
|
+
background-color: var(--stcBlack14);
|
|
332
332
|
}
|
|
333
333
|
.mfui-button_full-width {
|
|
334
334
|
display: block;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './Calendar.less';
|
|
3
3
|
export interface ICalendarProps {
|
|
4
|
+
/** Дополнительные data атрибуты к внутренним элементам */
|
|
5
|
+
dataAttrs?: {
|
|
6
|
+
root?: Record<string, string>;
|
|
7
|
+
day?: Record<string, string>;
|
|
8
|
+
month?: Record<string, string>;
|
|
9
|
+
arrowLeft?: Record<string, string>;
|
|
10
|
+
arrowRight?: Record<string, string>;
|
|
11
|
+
};
|
|
4
12
|
/** Переключение календаря в режим выбора одной даты вместо периода */
|
|
5
13
|
isSingleDate?: boolean;
|
|
6
14
|
/** Классы для модификации компонента */
|
|
@@ -22,7 +22,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
22
22
|
|
|
23
23
|
import React, { useState, useEffect, useMemo } from 'react';
|
|
24
24
|
import { START_DATE, END_DATE, useDatepicker, useMonth } from '@datepicker-react/hooks';
|
|
25
|
-
import { cnCreate } from '@megafon/ui-helpers';
|
|
25
|
+
import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
|
|
26
26
|
import differenceInDays from 'date-fns/differenceInDays';
|
|
27
27
|
import format from 'date-fns/format';
|
|
28
28
|
import isAfter from 'date-fns/isAfter';
|
|
@@ -57,7 +57,8 @@ var monthLabelFormat = function monthLabelFormat(date) {
|
|
|
57
57
|
var cn = cnCreate('mfui-calendar');
|
|
58
58
|
|
|
59
59
|
var Calendar = function Calendar(_ref) {
|
|
60
|
-
var
|
|
60
|
+
var dataAttrs = _ref.dataAttrs,
|
|
61
|
+
_ref$isSingleDate = _ref.isSingleDate,
|
|
61
62
|
isSingleDate = _ref$isSingleDate === void 0 ? false : _ref$isSingleDate,
|
|
62
63
|
_ref$startDate = _ref.startDate,
|
|
63
64
|
startDate = _ref$startDate === void 0 ? null : _ref$startDate,
|
|
@@ -202,6 +203,9 @@ var Calendar = function Calendar(_ref) {
|
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
return /*#__PURE__*/React.createElement(Day, _extends({
|
|
206
|
+
dataAttrs: {
|
|
207
|
+
root: _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.day, index + 1))
|
|
208
|
+
},
|
|
205
209
|
date: date,
|
|
206
210
|
key: formatDate(date, 'dd-MM-yyyy'),
|
|
207
211
|
dayLabel: dayLabel
|
|
@@ -240,6 +244,11 @@ var Calendar = function Calendar(_ref) {
|
|
|
240
244
|
var isPrevMonthDisabled = !!minBookingDate && isSameMonth(new Date(year, month, 1), minBookingDate);
|
|
241
245
|
var isNextMonthDisabled = !!maxBookingDate && isSameMonth(new Date(year, month, 1), maxBookingDate);
|
|
242
246
|
return /*#__PURE__*/React.createElement(Month, {
|
|
247
|
+
dataAttrs: {
|
|
248
|
+
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.month,
|
|
249
|
+
arrowLeft: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.arrowLeft,
|
|
250
|
+
arrowRight: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.arrowRight
|
|
251
|
+
},
|
|
243
252
|
key: "".concat(year, "-").concat(month),
|
|
244
253
|
year: year,
|
|
245
254
|
weekdayLabels: weekdayLabels,
|
|
@@ -252,12 +261,19 @@ var Calendar = function Calendar(_ref) {
|
|
|
252
261
|
});
|
|
253
262
|
};
|
|
254
263
|
|
|
255
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
264
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
256
265
|
className: cn([className])
|
|
257
|
-
}, renderMonths());
|
|
266
|
+
}), renderMonths());
|
|
258
267
|
};
|
|
259
268
|
|
|
260
269
|
Calendar.propTypes = {
|
|
270
|
+
dataAttrs: PropTypes.shape({
|
|
271
|
+
root: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
272
|
+
day: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
273
|
+
month: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
274
|
+
arrowLeft: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
275
|
+
arrowRight: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
276
|
+
}),
|
|
261
277
|
isSingleDate: PropTypes.bool,
|
|
262
278
|
className: PropTypes.string,
|
|
263
279
|
startDate: PropTypes.instanceOf(Date),
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './Day.less';
|
|
3
3
|
export interface IDayPickerProps {
|
|
4
|
+
dataAttrs?: {
|
|
5
|
+
root?: Record<string, string>;
|
|
6
|
+
};
|
|
4
7
|
isDateSelected: (date: Date) => boolean;
|
|
5
8
|
isDateHovered: (date: Date) => boolean;
|
|
6
9
|
isFirstOrLastSelectedDate: (date: Date) => boolean;
|
|
@@ -18,7 +18,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
18
18
|
|
|
19
19
|
import React from 'react';
|
|
20
20
|
import { useDay } from '@datepicker-react/hooks';
|
|
21
|
-
import { cnCreate } from '@megafon/ui-helpers';
|
|
21
|
+
import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
|
|
22
22
|
import isFirstDayOfMonth from 'date-fns/isFirstDayOfMonth';
|
|
23
23
|
import isLastDayOfMonth from 'date-fns/isLastDayOfMonth';
|
|
24
24
|
import isMonday from 'date-fns/isMonday';
|
|
@@ -28,12 +28,13 @@ import "./Day.css";
|
|
|
28
28
|
var cn = cnCreate('mfui-day');
|
|
29
29
|
|
|
30
30
|
var Day = function Day(_a) {
|
|
31
|
-
var
|
|
31
|
+
var dataAttrs = _a.dataAttrs,
|
|
32
|
+
_a$isBetween = _a.isBetween,
|
|
32
33
|
isBetween = _a$isBetween === void 0 ? false : _a$isBetween,
|
|
33
34
|
dayLabel = _a.dayLabel,
|
|
34
35
|
date = _a.date,
|
|
35
36
|
onMouseLeave = _a.onMouseLeave,
|
|
36
|
-
pickerProps = __rest(_a, ["isBetween", "dayLabel", "date", "onMouseLeave"]);
|
|
37
|
+
pickerProps = __rest(_a, ["dataAttrs", "isBetween", "dayLabel", "date", "onMouseLeave"]);
|
|
37
38
|
|
|
38
39
|
var dayRef = React.useRef(null);
|
|
39
40
|
|
|
@@ -63,7 +64,7 @@ var Day = function Day(_a) {
|
|
|
63
64
|
onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave();
|
|
64
65
|
};
|
|
65
66
|
|
|
66
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
67
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
67
68
|
onClick: onClick,
|
|
68
69
|
onKeyDown: onKeyDown,
|
|
69
70
|
onMouseEnter: onMouseEnter,
|
|
@@ -72,12 +73,15 @@ var Day = function Day(_a) {
|
|
|
72
73
|
type: "button",
|
|
73
74
|
ref: dayRef,
|
|
74
75
|
className: cn(modClasses)
|
|
75
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
76
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
76
77
|
className: cn('label')
|
|
77
78
|
}, dayLabel));
|
|
78
79
|
};
|
|
79
80
|
|
|
80
81
|
Day.propTypes = {
|
|
82
|
+
dataAttrs: PropTypes.shape({
|
|
83
|
+
root: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
84
|
+
}),
|
|
81
85
|
dayLabel: PropTypes.string,
|
|
82
86
|
date: PropTypes.instanceOf(Date).isRequired,
|
|
83
87
|
focusedDate: PropTypes.instanceOf(Date),
|
|
@@ -8,6 +8,11 @@ export interface IMonthPickerProps {
|
|
|
8
8
|
goToNextMonths: () => void;
|
|
9
9
|
}
|
|
10
10
|
export interface IMonthProps {
|
|
11
|
+
dataAttrs?: {
|
|
12
|
+
root?: Record<string, string>;
|
|
13
|
+
arrowLeft?: Record<string, string>;
|
|
14
|
+
arrowRight?: Record<string, string>;
|
|
15
|
+
};
|
|
11
16
|
isPrevMonthDisabled: boolean;
|
|
12
17
|
isNextMonthDisabled: boolean;
|
|
13
18
|
year: number;
|
|
@@ -2,7 +2,7 @@ import "core-js/modules/es.array.concat";
|
|
|
2
2
|
import "core-js/modules/es.array.map";
|
|
3
3
|
import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import { checkEventIsClickOrEnterPress, cnCreate } from '@megafon/ui-helpers';
|
|
5
|
+
import { checkEventIsClickOrEnterPress, cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
|
|
6
6
|
import "./Month.css";
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
@@ -29,7 +29,8 @@ var ArrowRight = function ArrowRight(props) {
|
|
|
29
29
|
var cn = cnCreate('mfui-month');
|
|
30
30
|
|
|
31
31
|
var Month = function Month(_ref) {
|
|
32
|
-
var
|
|
32
|
+
var dataAttrs = _ref.dataAttrs,
|
|
33
|
+
isPrevMonthDisabled = _ref.isPrevMonthDisabled,
|
|
33
34
|
isNextMonthDisabled = _ref.isNextMonthDisabled,
|
|
34
35
|
year = _ref.year,
|
|
35
36
|
monthLabel = _ref.monthLabel,
|
|
@@ -56,11 +57,11 @@ var Month = function Month(_ref) {
|
|
|
56
57
|
return hasFocus ? tabIndexWithFocus : tabIndexWithoutFocus;
|
|
57
58
|
};
|
|
58
59
|
|
|
59
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
60
61
|
className: cn()
|
|
61
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
62
63
|
className: cn('header')
|
|
63
|
-
}, /*#__PURE__*/React.createElement(ArrowLeft, {
|
|
64
|
+
}, /*#__PURE__*/React.createElement(ArrowLeft, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.arrowLeft), {
|
|
64
65
|
role: "button",
|
|
65
66
|
tabIndex: getTabIndex(!isPrevMonthDisabled),
|
|
66
67
|
className: cn('arrow', {
|
|
@@ -68,9 +69,9 @@ var Month = function Month(_ref) {
|
|
|
68
69
|
}),
|
|
69
70
|
onKeyDown: handleArrowLeftClick,
|
|
70
71
|
onClick: handleArrowLeftClick
|
|
71
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
72
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
72
73
|
className: cn('title')
|
|
73
|
-
}, "".concat(monthLabel, " ").concat(year)), /*#__PURE__*/React.createElement(ArrowRight, {
|
|
74
|
+
}, "".concat(monthLabel, " ").concat(year)), /*#__PURE__*/React.createElement(ArrowRight, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.arrowRight), {
|
|
74
75
|
role: "button",
|
|
75
76
|
tabIndex: getTabIndex(!isNextMonthDisabled),
|
|
76
77
|
className: cn('arrow', {
|
|
@@ -78,7 +79,7 @@ var Month = function Month(_ref) {
|
|
|
78
79
|
}),
|
|
79
80
|
onKeyDown: handleArrowRightClick,
|
|
80
81
|
onClick: handleArrowRightClick
|
|
81
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
82
83
|
className: cn('weekday-labels')
|
|
83
84
|
}, weekdayLabels.map(function (dayLabel, index) {
|
|
84
85
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -91,6 +92,11 @@ var Month = function Month(_ref) {
|
|
|
91
92
|
};
|
|
92
93
|
|
|
93
94
|
Month.propTypes = {
|
|
95
|
+
dataAttrs: PropTypes.shape({
|
|
96
|
+
root: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
97
|
+
arrowLeft: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
98
|
+
arrowRight: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
99
|
+
}),
|
|
94
100
|
isPrevMonthDisabled: PropTypes.bool.isRequired,
|
|
95
101
|
isNextMonthDisabled: PropTypes.bool.isRequired,
|
|
96
102
|
year: PropTypes.number.isRequired,
|
|
@@ -180,14 +180,18 @@ var Carousel = function Carousel(_ref) {
|
|
|
180
180
|
if (isBullet && swiperInstance) {
|
|
181
181
|
increaseAutoplayDelay(swiperInstance);
|
|
182
182
|
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
var handleNavDisplay = function handleNavDisplay(swiper) {
|
|
186
|
+
setBeginning(swiper.isBeginning);
|
|
187
|
+
setEnd(swiper.isEnd);
|
|
188
|
+
setLocked(swiper.isBeginning && swiper.isEnd);
|
|
183
189
|
}; // https://github.com/nolimits4web/Swiper/issues/2346
|
|
184
190
|
|
|
185
191
|
|
|
186
192
|
var handleSwiperResize = React.useCallback(function () {
|
|
187
193
|
throttle(function (swiper) {
|
|
188
|
-
|
|
189
|
-
setEnd(swiper.isEnd);
|
|
190
|
-
setLocked(swiper.isBeginning && swiper.isEnd);
|
|
194
|
+
handleNavDisplay(swiper);
|
|
191
195
|
|
|
192
196
|
if (swiper.params.slidesPerView === SlidesPerView.AUTO) {
|
|
193
197
|
swiper.slides.css('width', '');
|
|
@@ -218,6 +222,21 @@ var Carousel = function Carousel(_ref) {
|
|
|
218
222
|
e.nativeEvent.preventDefault();
|
|
219
223
|
};
|
|
220
224
|
|
|
225
|
+
React.useEffect(function () {
|
|
226
|
+
if (!swiperInstance) {
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
var windowResizeHandler = function windowResizeHandler() {
|
|
231
|
+
return handleNavDisplay(swiperInstance);
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
var windowResizeHandlerThrottled = throttle(windowResizeHandler, throttleTime.resize);
|
|
235
|
+
window.addEventListener('resize', windowResizeHandlerThrottled);
|
|
236
|
+
return function () {
|
|
237
|
+
window.removeEventListener('resize', windowResizeHandlerThrottled);
|
|
238
|
+
};
|
|
239
|
+
}, [swiperInstance]);
|
|
221
240
|
return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
222
241
|
ref: rootRef,
|
|
223
242
|
className: cn({
|
|
@@ -262,7 +281,10 @@ var Carousel = function Carousel(_ref) {
|
|
|
262
281
|
onFocus: handleSlideFocus(i),
|
|
263
282
|
onMouseDown: disableFocusOnSlideClick
|
|
264
283
|
}), child);
|
|
265
|
-
})), /*#__PURE__*/React.createElement(NavArrow,
|
|
284
|
+
})), /*#__PURE__*/React.createElement(NavArrow, {
|
|
285
|
+
dataAttrs: {
|
|
286
|
+
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.prev
|
|
287
|
+
},
|
|
266
288
|
className: cn('arrow', {
|
|
267
289
|
prev: true,
|
|
268
290
|
locked: isLocked
|
|
@@ -270,7 +292,10 @@ var Carousel = function Carousel(_ref) {
|
|
|
270
292
|
onClick: handlePrevClick,
|
|
271
293
|
disabled: !loop && isBeginning,
|
|
272
294
|
theme: ArrowTheme.PURPLE
|
|
273
|
-
})
|
|
295
|
+
}), /*#__PURE__*/React.createElement(NavArrow, {
|
|
296
|
+
dataAttrs: {
|
|
297
|
+
root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.next
|
|
298
|
+
},
|
|
274
299
|
className: cn('arrow', {
|
|
275
300
|
next: true,
|
|
276
301
|
locked: isLocked
|
|
@@ -279,7 +304,7 @@ var Carousel = function Carousel(_ref) {
|
|
|
279
304
|
onClick: handleNextClick,
|
|
280
305
|
disabled: !loop && isEnd,
|
|
281
306
|
theme: ArrowTheme.PURPLE
|
|
282
|
-
}))
|
|
307
|
+
}));
|
|
283
308
|
};
|
|
284
309
|
|
|
285
310
|
Carousel.propTypes = {
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import "core-js/modules/web.timers";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
2
|
import * as React from 'react';
|
|
3
|
+
import { useCallback, useEffect } from 'react';
|
|
5
4
|
import { filterDataAttrs } from '@megafon/ui-helpers';
|
|
6
5
|
import * as PropTypes from 'prop-types';
|
|
7
|
-
var
|
|
6
|
+
var sin = Math.sin,
|
|
7
|
+
cos = Math.cos,
|
|
8
|
+
min = Math.min,
|
|
9
|
+
PI = Math.PI;
|
|
10
|
+
|
|
11
|
+
var easeOutSine = function easeOutSine(progress) {
|
|
12
|
+
return sin(progress * PI / 2);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
var easeInSine = function easeInSine(progress) {
|
|
16
|
+
return 1 - cos(progress * PI / 2);
|
|
17
|
+
};
|
|
8
18
|
|
|
9
19
|
var Collapse = function Collapse(props) {
|
|
10
20
|
var className = props.className,
|
|
@@ -16,58 +26,75 @@ var Collapse = function Collapse(props) {
|
|
|
16
26
|
children = props.children,
|
|
17
27
|
isOpened = props.isOpened,
|
|
18
28
|
dataAttrs = props.dataAttrs;
|
|
29
|
+
var duration = animation ? animationDuration : 0;
|
|
30
|
+
var animationStart = React.useRef(null);
|
|
31
|
+
var animationId = React.useRef(null);
|
|
19
32
|
var canUpdate = React.useRef(false);
|
|
20
|
-
var timer = React.useRef(undefined);
|
|
21
33
|
var rootNode = React.useRef(null);
|
|
34
|
+
useEffect(function () {
|
|
35
|
+
animationId.current && window.cancelAnimationFrame(animationId.current);
|
|
36
|
+
}, [isOpened]);
|
|
37
|
+
var animateSlide = useCallback(function (contentHeight, animationTime, timePassed) {
|
|
38
|
+
var isOpenAction = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
39
|
+
|
|
40
|
+
if (!rootNode.current) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
22
43
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
setHeight = _React$useState2[1];
|
|
44
|
+
if (!animationStart.current) {
|
|
45
|
+
animationStart.current = timePassed;
|
|
46
|
+
}
|
|
27
47
|
|
|
28
|
-
|
|
29
|
-
|
|
48
|
+
var runtime = timePassed - animationStart.current;
|
|
49
|
+
var progress = animationTime ? min(runtime / animationTime, 1) : 1;
|
|
50
|
+
var isAnimationInProgress = progress < 1;
|
|
51
|
+
var nextHeight = isOpenAction ? easeOutSine(progress) * contentHeight : contentHeight - easeInSine(progress) * contentHeight;
|
|
52
|
+
rootNode.current.style.height = "".concat(nextHeight, "px");
|
|
30
53
|
|
|
31
|
-
|
|
54
|
+
if (isAnimationInProgress) {
|
|
55
|
+
animationId.current = window.requestAnimationFrame(function (time) {
|
|
56
|
+
return animateSlide(contentHeight, animationTime, time, isOpenAction);
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
animationStart.current = null;
|
|
60
|
+
animationId.current = null;
|
|
61
|
+
}
|
|
62
|
+
}, []);
|
|
63
|
+
useEffect(function () {
|
|
32
64
|
if (!rootNode.current) {
|
|
33
65
|
return;
|
|
34
66
|
}
|
|
35
67
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
setHeight(finalHeight);
|
|
39
|
-
}, delay);
|
|
40
|
-
};
|
|
68
|
+
var _rootNode$current$scr = rootNode.current.scrollHeight,
|
|
69
|
+
scrollHeight = _rootNode$current$scr === void 0 ? 0 : _rootNode$current$scr;
|
|
41
70
|
|
|
42
|
-
React.useEffect(function () {
|
|
43
71
|
switch (true) {
|
|
44
72
|
case !canUpdate.current && isOpened:
|
|
45
|
-
|
|
73
|
+
rootNode.current.style.height = 'auto';
|
|
46
74
|
break;
|
|
47
75
|
|
|
48
76
|
case !canUpdate.current && !isOpened:
|
|
49
|
-
|
|
77
|
+
rootNode.current.style.height = '0px';
|
|
50
78
|
break;
|
|
51
79
|
|
|
52
80
|
case isOpened:
|
|
53
|
-
|
|
81
|
+
animationId.current = window.requestAnimationFrame(function (timePassed) {
|
|
82
|
+
return animateSlide(scrollHeight, duration, timePassed, true);
|
|
83
|
+
});
|
|
54
84
|
break;
|
|
55
85
|
|
|
56
86
|
default:
|
|
57
|
-
|
|
87
|
+
animationId.current = window.requestAnimationFrame(function (timePassed) {
|
|
88
|
+
return animateSlide(scrollHeight, duration, timePassed);
|
|
89
|
+
});
|
|
58
90
|
}
|
|
59
91
|
|
|
60
92
|
canUpdate.current = true;
|
|
61
|
-
|
|
62
|
-
return clearTimeout(timer.current);
|
|
63
|
-
};
|
|
64
|
-
}, [isOpened, duration]);
|
|
93
|
+
}, [isOpened, duration, animateSlide]);
|
|
65
94
|
return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
66
95
|
className: className,
|
|
67
96
|
style: {
|
|
68
|
-
overflow: 'hidden'
|
|
69
|
-
height: height,
|
|
70
|
-
transition: transition
|
|
97
|
+
overflow: 'hidden'
|
|
71
98
|
},
|
|
72
99
|
ref: rootNode
|
|
73
100
|
}), /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.inner), {
|