@megafon/ui-core 5.16.0 → 5.18.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 +31 -0
- package/dist/es/components/Banner/Banner.css +43 -32
- package/dist/es/components/Banner/Banner.d.ts +8 -3
- package/dist/es/components/Banner/Banner.js +62 -44
- package/dist/es/components/Banner/BannerDot.css +9 -16
- package/dist/es/components/Banner/BannerDot.d.ts +0 -7
- package/dist/es/components/Banner/BannerDot.js +5 -14
- package/dist/es/components/Banner/slidesSettings.d.ts +5 -0
- package/dist/es/components/Banner/slidesSettings.js +13 -0
- package/dist/es/components/Button/Button.css +3 -0
- package/dist/es/components/ContentView/ContentView.d.ts +1 -0
- package/dist/es/components/ContentView/ContentView.js +9 -3
- package/dist/es/components/ListData/ListData.css +162 -0
- package/dist/es/components/ListData/ListData.d.ts +94 -0
- package/dist/es/components/ListData/ListData.js +203 -0
- package/dist/es/components/ListData/ListDataGroup.css +15 -0
- package/dist/es/components/ListData/ListDataGroup.d.ts +46 -0
- package/dist/es/components/ListData/ListDataGroup.js +195 -0
- package/dist/es/components/ListData/components/ListDataSortable.css +79 -0
- package/dist/es/components/ListData/components/ListDataSortable.d.ts +34 -0
- package/dist/es/components/ListData/components/ListDataSortable.js +102 -0
- package/dist/es/components/ListData/doc/i/img.png +0 -0
- package/dist/es/components/ListData/helpers.d.ts +6 -0
- package/dist/es/components/ListData/helpers.js +40 -0
- package/dist/es/components/Search/Search.d.ts +1 -0
- package/dist/es/components/Search/Search.js +2 -2
- package/dist/es/components/Snackbar/SnackbarTimer/SnackbarTimer.css +1 -1
- package/dist/es/index.d.ts +4 -0
- package/dist/es/index.js +4 -0
- package/dist/lib/components/Banner/Banner.css +43 -32
- package/dist/lib/components/Banner/Banner.d.ts +8 -3
- package/dist/lib/components/Banner/Banner.js +63 -44
- package/dist/lib/components/Banner/BannerDot.css +9 -16
- package/dist/lib/components/Banner/BannerDot.d.ts +0 -7
- package/dist/lib/components/Banner/BannerDot.js +6 -17
- package/dist/lib/components/Banner/slidesSettings.d.ts +5 -0
- package/dist/lib/components/Banner/slidesSettings.js +24 -0
- package/dist/lib/components/Button/Button.css +3 -0
- package/dist/lib/components/ContentView/ContentView.d.ts +1 -0
- package/dist/lib/components/ContentView/ContentView.js +8 -2
- package/dist/lib/components/ListData/ListData.css +162 -0
- package/dist/lib/components/ListData/ListData.d.ts +94 -0
- package/dist/lib/components/ListData/ListData.js +229 -0
- package/dist/lib/components/ListData/ListDataGroup.css +15 -0
- package/dist/lib/components/ListData/ListDataGroup.d.ts +46 -0
- package/dist/lib/components/ListData/ListDataGroup.js +229 -0
- package/dist/lib/components/ListData/components/ListDataSortable.css +79 -0
- package/dist/lib/components/ListData/components/ListDataSortable.d.ts +34 -0
- package/dist/lib/components/ListData/components/ListDataSortable.js +129 -0
- package/dist/lib/components/ListData/doc/i/img.png +0 -0
- package/dist/lib/components/ListData/helpers.d.ts +6 -0
- package/dist/lib/components/ListData/helpers.js +58 -0
- package/dist/lib/components/Search/Search.d.ts +1 -0
- package/dist/lib/components/Search/Search.js +2 -2
- package/dist/lib/components/Snackbar/SnackbarTimer/SnackbarTimer.css +1 -1
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.js +32 -0
- package/package.json +5 -3
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import "core-js/modules/es.array.index-of.js";
|
|
4
|
+
import "core-js/modules/es.symbol.js";
|
|
5
|
+
import "core-js/modules/es.array.find-index.js";
|
|
6
|
+
import "core-js/modules/es.array.map.js";
|
|
7
|
+
import "core-js/modules/es.object.values.js";
|
|
8
|
+
|
|
9
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
10
|
+
var t = {};
|
|
11
|
+
|
|
12
|
+
for (var p in s) {
|
|
13
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
import React from 'react';
|
|
23
|
+
import { closestCenter, DndContext, DragOverlay, KeyboardSensor, MouseSensor, TouchSensor, useSensor, useSensors } from '@dnd-kit/core';
|
|
24
|
+
import { arrayMove, SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
25
|
+
import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
|
|
26
|
+
import * as PropTypes from 'prop-types';
|
|
27
|
+
import ListDataSortable, { ActivatorNodes, GapSizes } from "./components/ListDataSortable";
|
|
28
|
+
import { restrictToElement, restrictToVerticalAxis } from "./helpers";
|
|
29
|
+
import { ListDataPropType } from "./ListData";
|
|
30
|
+
import "./ListDataGroup.css";
|
|
31
|
+
var SCREEN_READER_INSTRUCTION = "\u0427\u0442\u043E\u0431\u044B \u0432\u044B\u0431\u0440\u0430\u0442\u044C \u043F\u0435\u0440\u0435\u0442\u0430\u0441\u043A\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u044D\u043B\u0435\u043C\u0435\u043D\u0442, \u043D\u0430\u0436\u043C\u0438\u0442\u0435 \u043F\u0440\u043E\u0431\u0435\u043B.\n \u041F\u0440\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0441\u043A\u0438\u0432\u0430\u043D\u0438\u0438 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 \u043A\u043B\u0430\u0432\u0438\u0448\u0438 \u0441\u043E \u0441\u0442\u0440\u0435\u043B\u043A\u0430\u043C\u0438 \u0434\u043B\u044F \u043F\u0435\u0440\u0435\u043C\u0435\u0449\u0435\u043D\u0438\u044F \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430.\n \u0421\u043D\u043E\u0432\u0430 \u043D\u0430\u0436\u043C\u0438\u0442\u0435 \u043F\u0440\u043E\u0431\u0435\u043B, \u0447\u0442\u043E\u0431\u044B \u043F\u0435\u0440\u0435\u043C\u0435\u0441\u0442\u0438\u0442\u044C \u044D\u043B\u0435\u043C\u0435\u043D\u0442 \u0432 \u0435\u0433\u043E \u043D\u043E\u0432\u043E\u0435 \u043F\u043E\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \u0438\u043B\u0438 \u043D\u0430\u0436\u043C\u0438\u0442\u0435 escape \u0434\u043B\u044F \u043E\u0442\u043C\u0435\u043D\u044B.";
|
|
32
|
+
var cn = cnCreate('mfui-list-data-group');
|
|
33
|
+
|
|
34
|
+
var ListDataGroup = function ListDataGroup(_ref) {
|
|
35
|
+
var items = _ref.items,
|
|
36
|
+
_ref$activatorNode = _ref.activatorNode,
|
|
37
|
+
activatorNode = _ref$activatorNode === void 0 ? ActivatorNodes.CONTROL : _ref$activatorNode,
|
|
38
|
+
_ref$gap = _ref.gap,
|
|
39
|
+
gap = _ref$gap === void 0 ? GapSizes.NONE : _ref$gap,
|
|
40
|
+
_ref$showDivider = _ref.showDivider,
|
|
41
|
+
showDivider = _ref$showDivider === void 0 ? false : _ref$showDivider,
|
|
42
|
+
onDragStart = _ref.onDragStart,
|
|
43
|
+
onDragEnd = _ref.onDragEnd,
|
|
44
|
+
_ref$disabled = _ref.disabled,
|
|
45
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
46
|
+
dragOverlayProps = _ref.dragOverlayProps,
|
|
47
|
+
className = _ref.className,
|
|
48
|
+
_ref$classes = _ref.classes,
|
|
49
|
+
classes = _ref$classes === void 0 ? {} : _ref$classes,
|
|
50
|
+
dataAttrs = _ref.dataAttrs;
|
|
51
|
+
|
|
52
|
+
var _React$useState = React.useState(items),
|
|
53
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
54
|
+
itemsList = _React$useState2[0],
|
|
55
|
+
setItemsList = _React$useState2[1];
|
|
56
|
+
|
|
57
|
+
var _React$useState3 = React.useState(null),
|
|
58
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
59
|
+
activeId = _React$useState4[0],
|
|
60
|
+
setActiveId = _React$useState4[1];
|
|
61
|
+
|
|
62
|
+
var _React$useState5 = React.useState(null),
|
|
63
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
64
|
+
dragEndEvent = _React$useState6[0],
|
|
65
|
+
setDragEndEvent = _React$useState6[1];
|
|
66
|
+
|
|
67
|
+
var boundaryRef = React.useRef(null);
|
|
68
|
+
var sensors = useSensors(useSensor(KeyboardSensor, {
|
|
69
|
+
coordinateGetter: sortableKeyboardCoordinates
|
|
70
|
+
}), useSensor(TouchSensor, {
|
|
71
|
+
activationConstraint: {
|
|
72
|
+
delay: 250,
|
|
73
|
+
tolerance: 5
|
|
74
|
+
}
|
|
75
|
+
}), useSensor(MouseSensor));
|
|
76
|
+
var handleDragStart = React.useCallback(function (event) {
|
|
77
|
+
var active = event.active;
|
|
78
|
+
setActiveId(active.id);
|
|
79
|
+
onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart(event);
|
|
80
|
+
}, [setActiveId, onDragStart]);
|
|
81
|
+
var handleDragCancel = React.useCallback(function () {
|
|
82
|
+
setActiveId(null);
|
|
83
|
+
}, [setActiveId]);
|
|
84
|
+
var handleDragEnd = React.useCallback(function (event) {
|
|
85
|
+
var active = event.active,
|
|
86
|
+
over = event.over;
|
|
87
|
+
|
|
88
|
+
if ((over === null || over === void 0 ? void 0 : over.id) && active.id !== over.id) {
|
|
89
|
+
setItemsList(function (prevItemsList) {
|
|
90
|
+
var oldIndex = prevItemsList.findIndex(function (item) {
|
|
91
|
+
return item.id === active.id;
|
|
92
|
+
});
|
|
93
|
+
var newIndex = prevItemsList.findIndex(function (item) {
|
|
94
|
+
return item.id === over.id;
|
|
95
|
+
});
|
|
96
|
+
return arrayMove(prevItemsList, oldIndex, newIndex);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
setActiveId(null);
|
|
101
|
+
setDragEndEvent(event);
|
|
102
|
+
}, []);
|
|
103
|
+
React.useEffect(function () {
|
|
104
|
+
if (dragEndEvent) {
|
|
105
|
+
onDragEnd === null || onDragEnd === void 0 ? void 0 : onDragEnd(itemsList, dragEndEvent);
|
|
106
|
+
setDragEndEvent(null);
|
|
107
|
+
}
|
|
108
|
+
}, [itemsList, onDragEnd, dragEndEvent]);
|
|
109
|
+
|
|
110
|
+
var renderSortableItem = function renderSortableItem(_a, index, isDragOverlay) {
|
|
111
|
+
var id = _a.id,
|
|
112
|
+
item = __rest(_a, ["id"]);
|
|
113
|
+
|
|
114
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
115
|
+
key: id,
|
|
116
|
+
className: cn('item', {
|
|
117
|
+
divider: showDivider
|
|
118
|
+
})
|
|
119
|
+
}, /*#__PURE__*/React.createElement(ListDataSortable, {
|
|
120
|
+
id: id,
|
|
121
|
+
item: item,
|
|
122
|
+
activatorNode: activatorNode,
|
|
123
|
+
gap: gap,
|
|
124
|
+
disabled: disabled || (item === null || item === void 0 ? void 0 : item.disabled),
|
|
125
|
+
isDragOverlay: isDragOverlay,
|
|
126
|
+
classes: {
|
|
127
|
+
root: classes.cell,
|
|
128
|
+
control: classes.control
|
|
129
|
+
},
|
|
130
|
+
dataAttrs: {
|
|
131
|
+
root: _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.cell, index + 1)),
|
|
132
|
+
control: _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.control, index + 1))
|
|
133
|
+
}
|
|
134
|
+
}));
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
var renderDragOverlay = function renderDragOverlay() {
|
|
138
|
+
var activeIndex = itemsList.findIndex(function (item) {
|
|
139
|
+
return item.id === activeId;
|
|
140
|
+
});
|
|
141
|
+
var activeItem = itemsList[activeIndex];
|
|
142
|
+
|
|
143
|
+
if (activeItem) {
|
|
144
|
+
return renderSortableItem(activeItem, activeIndex, true);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return null;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
return /*#__PURE__*/React.createElement(DndContext, {
|
|
151
|
+
sensors: sensors,
|
|
152
|
+
collisionDetection: closestCenter,
|
|
153
|
+
onDragStart: handleDragStart,
|
|
154
|
+
onDragEnd: handleDragEnd,
|
|
155
|
+
onDragCancel: handleDragCancel,
|
|
156
|
+
modifiers: [restrictToElement(boundaryRef), restrictToVerticalAxis],
|
|
157
|
+
accessibility: {
|
|
158
|
+
screenReaderInstructions: {
|
|
159
|
+
draggable: SCREEN_READER_INSTRUCTION
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}, /*#__PURE__*/React.createElement(SortableContext, {
|
|
163
|
+
items: itemsList,
|
|
164
|
+
strategy: verticalListSortingStrategy
|
|
165
|
+
}, /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
166
|
+
className: cn([className, classes.root]),
|
|
167
|
+
ref: boundaryRef
|
|
168
|
+
}), itemsList.map(function (item, index) {
|
|
169
|
+
return renderSortableItem(item, index);
|
|
170
|
+
}))), /*#__PURE__*/React.createElement(DragOverlay, dragOverlayProps, activeId ? renderDragOverlay() : null));
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
ListDataGroup.propTypes = {
|
|
174
|
+
items: PropTypes.arrayOf(PropTypes.shape(_extends({
|
|
175
|
+
id: PropTypes.string.isRequired
|
|
176
|
+
}, ListDataPropType)).isRequired).isRequired,
|
|
177
|
+
activatorNode: PropTypes.oneOf(Object.values(ActivatorNodes)),
|
|
178
|
+
gap: PropTypes.oneOf(Object.values(GapSizes)),
|
|
179
|
+
showDivider: PropTypes.bool,
|
|
180
|
+
onDragStart: PropTypes.func,
|
|
181
|
+
onDragEnd: PropTypes.func,
|
|
182
|
+
disabled: PropTypes.bool,
|
|
183
|
+
dragOverlayProps: PropTypes.shape({
|
|
184
|
+
className: PropTypes.string,
|
|
185
|
+
zIndex: PropTypes.number
|
|
186
|
+
}),
|
|
187
|
+
className: PropTypes.string,
|
|
188
|
+
classes: PropTypes.shape({
|
|
189
|
+
root: PropTypes.string,
|
|
190
|
+
cell: PropTypes.string,
|
|
191
|
+
control: PropTypes.string
|
|
192
|
+
}),
|
|
193
|
+
dataAttrs: PropTypes.objectOf(PropTypes.object)
|
|
194
|
+
};
|
|
195
|
+
export default ListDataGroup;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
.mfui-list-data-sortable {
|
|
2
|
+
-webkit-box-sizing: border-box;
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
-webkit-user-select: none;
|
|
5
|
+
-moz-user-select: none;
|
|
6
|
+
-ms-user-select: none;
|
|
7
|
+
user-select: none;
|
|
8
|
+
}
|
|
9
|
+
.mfui-list-data-sortable__wrapper {
|
|
10
|
+
display: -webkit-box;
|
|
11
|
+
display: -ms-flexbox;
|
|
12
|
+
display: flex;
|
|
13
|
+
-ms-flex-wrap: nowrap;
|
|
14
|
+
flex-wrap: nowrap;
|
|
15
|
+
-webkit-box-align: center;
|
|
16
|
+
-ms-flex-align: center;
|
|
17
|
+
align-items: center;
|
|
18
|
+
-webkit-box-pack: justify;
|
|
19
|
+
-ms-flex-pack: justify;
|
|
20
|
+
justify-content: space-between;
|
|
21
|
+
border-radius: 12px;
|
|
22
|
+
}
|
|
23
|
+
.mfui-list-data-sortable__item {
|
|
24
|
+
padding-right: 0;
|
|
25
|
+
}
|
|
26
|
+
.mfui-list-data-sortable__control {
|
|
27
|
+
display: -webkit-box;
|
|
28
|
+
display: -ms-flexbox;
|
|
29
|
+
display: flex;
|
|
30
|
+
-ms-flex-negative: 0;
|
|
31
|
+
flex-shrink: 0;
|
|
32
|
+
-webkit-box-align: center;
|
|
33
|
+
-ms-flex-align: center;
|
|
34
|
+
align-items: center;
|
|
35
|
+
-webkit-box-pack: center;
|
|
36
|
+
-ms-flex-pack: center;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
margin: 12px 16px 12px 8px;
|
|
39
|
+
}
|
|
40
|
+
.mfui-list-data-sortable__icon {
|
|
41
|
+
width: 32px;
|
|
42
|
+
height: 32px;
|
|
43
|
+
fill: var(--spbSky2);
|
|
44
|
+
}
|
|
45
|
+
.mfui-list-data-sortable_gap_small {
|
|
46
|
+
padding: 2px 0;
|
|
47
|
+
}
|
|
48
|
+
.mfui-list-data-sortable_gap_medium {
|
|
49
|
+
padding: 4px 0;
|
|
50
|
+
}
|
|
51
|
+
.mfui-list-data-sortable_gap_large {
|
|
52
|
+
padding: 6px 0;
|
|
53
|
+
}
|
|
54
|
+
.mfui-list-data-sortable_dragging {
|
|
55
|
+
opacity: 0;
|
|
56
|
+
}
|
|
57
|
+
.mfui-list-data-sortable_drag-overlay .mfui-list-data-sortable__wrapper {
|
|
58
|
+
background-color: var(--spbSky0);
|
|
59
|
+
-webkit-animation-duration: 0.3s;
|
|
60
|
+
animation-duration: 0.3s;
|
|
61
|
+
-webkit-animation-timing-function: ease-in-out;
|
|
62
|
+
animation-timing-function: ease-in-out;
|
|
63
|
+
}
|
|
64
|
+
.mfui-list-data-sortable_activator_cell:not(.mfui-list-data-sortable_disabled) {
|
|
65
|
+
cursor: -webkit-grab;
|
|
66
|
+
cursor: grab;
|
|
67
|
+
}
|
|
68
|
+
.mfui-list-data-sortable_activator_cell:not(.mfui-list-data-sortable_disabled).mfui-list-data-sortable_drag-overlay {
|
|
69
|
+
cursor: -webkit-grabbing;
|
|
70
|
+
cursor: grabbing;
|
|
71
|
+
}
|
|
72
|
+
.mfui-list-data-sortable_activator_control:not(.mfui-list-data-sortable_disabled) .mfui-list-data-sortable__control {
|
|
73
|
+
cursor: -webkit-grab;
|
|
74
|
+
cursor: grab;
|
|
75
|
+
}
|
|
76
|
+
.mfui-list-data-sortable_activator_control:not(.mfui-list-data-sortable_disabled).mfui-list-data-sortable_drag-overlay .mfui-list-data-sortable__control {
|
|
77
|
+
cursor: -webkit-grabbing;
|
|
78
|
+
cursor: grabbing;
|
|
79
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { UniqueIdentifier } from '@dnd-kit/core';
|
|
3
|
+
import { IListDataProps } from '../ListData';
|
|
4
|
+
import './ListDataSortable.less';
|
|
5
|
+
export declare const ActivatorNodes: {
|
|
6
|
+
readonly CELL: "cell";
|
|
7
|
+
readonly CONTROL: "control";
|
|
8
|
+
};
|
|
9
|
+
export declare type ActivatorNodesType = typeof ActivatorNodes[keyof typeof ActivatorNodes];
|
|
10
|
+
export declare const GapSizes: {
|
|
11
|
+
readonly NONE: "none";
|
|
12
|
+
readonly SMALL: "small";
|
|
13
|
+
readonly MEDIUM: "medium";
|
|
14
|
+
readonly LARGE: "large";
|
|
15
|
+
};
|
|
16
|
+
export declare type GapSizesType = typeof GapSizes[keyof typeof GapSizes];
|
|
17
|
+
export interface IListDataSortableProps {
|
|
18
|
+
id: UniqueIdentifier;
|
|
19
|
+
item: IListDataProps;
|
|
20
|
+
activatorNode: ActivatorNodesType;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
isDragOverlay?: boolean;
|
|
23
|
+
gap?: GapSizesType;
|
|
24
|
+
classes?: {
|
|
25
|
+
root?: string;
|
|
26
|
+
control?: string;
|
|
27
|
+
};
|
|
28
|
+
dataAttrs?: {
|
|
29
|
+
root?: Record<string, string>;
|
|
30
|
+
control?: Record<string, string>;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
declare const ListDataSortable: React.FC<IListDataSortableProps>;
|
|
34
|
+
export default ListDataSortable;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import "core-js/modules/es.date.to-string.js";
|
|
3
|
+
import "core-js/modules/es.object.to-string.js";
|
|
4
|
+
import "core-js/modules/es.regexp.to-string.js";
|
|
5
|
+
import "core-js/modules/es.object.values.js";
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { useSortable } from '@dnd-kit/sortable';
|
|
8
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
9
|
+
import { cnCreate } from '@megafon/ui-helpers';
|
|
10
|
+
import * as PropTypes from 'prop-types';
|
|
11
|
+
import ListData, { ListDataPropType } from "../ListData";
|
|
12
|
+
import "./ListDataSortable.css";
|
|
13
|
+
|
|
14
|
+
var DragIcon = function DragIcon(props) {
|
|
15
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
16
|
+
viewBox: "0 0 32 32"
|
|
17
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
18
|
+
fillRule: "evenodd",
|
|
19
|
+
clipRule: "evenodd",
|
|
20
|
+
d: "M24 14H8v-2h16v2zm0 6H8v-2h16v2z"
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export var ActivatorNodes = {
|
|
25
|
+
CELL: 'cell',
|
|
26
|
+
CONTROL: 'control'
|
|
27
|
+
};
|
|
28
|
+
export var GapSizes = {
|
|
29
|
+
NONE: 'none',
|
|
30
|
+
SMALL: 'small',
|
|
31
|
+
MEDIUM: 'medium',
|
|
32
|
+
LARGE: 'large'
|
|
33
|
+
};
|
|
34
|
+
var cn = cnCreate('mfui-list-data-sortable');
|
|
35
|
+
|
|
36
|
+
var ListDataSortable = function ListDataSortable(_ref) {
|
|
37
|
+
var id = _ref.id,
|
|
38
|
+
item = _ref.item,
|
|
39
|
+
activatorNode = _ref.activatorNode,
|
|
40
|
+
gap = _ref.gap,
|
|
41
|
+
_ref$disabled = _ref.disabled,
|
|
42
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
43
|
+
isDragOverlay = _ref.isDragOverlay,
|
|
44
|
+
_ref$classes = _ref.classes,
|
|
45
|
+
classes = _ref$classes === void 0 ? {} : _ref$classes,
|
|
46
|
+
dataAttrs = _ref.dataAttrs;
|
|
47
|
+
|
|
48
|
+
var _useSortable = useSortable({
|
|
49
|
+
id: id,
|
|
50
|
+
disabled: disabled
|
|
51
|
+
}),
|
|
52
|
+
attributes = _useSortable.attributes,
|
|
53
|
+
listeners = _useSortable.listeners,
|
|
54
|
+
setNodeRef = _useSortable.setNodeRef,
|
|
55
|
+
setActivatorNodeRef = _useSortable.setActivatorNodeRef,
|
|
56
|
+
transform = _useSortable.transform,
|
|
57
|
+
transition = _useSortable.transition,
|
|
58
|
+
isDragging = _useSortable.isDragging;
|
|
59
|
+
|
|
60
|
+
var isCellActivator = activatorNode === ActivatorNodes.CELL;
|
|
61
|
+
var isControlActivator = activatorNode === ActivatorNodes.CONTROL;
|
|
62
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
63
|
+
className: cn({
|
|
64
|
+
gap: gap,
|
|
65
|
+
disabled: disabled,
|
|
66
|
+
activator: activatorNode,
|
|
67
|
+
dragging: isDragging,
|
|
68
|
+
'drag-overlay': isDragOverlay
|
|
69
|
+
}, [classes.root])
|
|
70
|
+
}, dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root, isCellActivator ? listeners : null, isCellActivator ? attributes : null, {
|
|
71
|
+
style: {
|
|
72
|
+
transform: CSS.Transform.toString(transform),
|
|
73
|
+
transition: transition
|
|
74
|
+
},
|
|
75
|
+
ref: setNodeRef
|
|
76
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
className: cn('wrapper')
|
|
78
|
+
}, /*#__PURE__*/React.createElement(ListData, _extends({}, item, {
|
|
79
|
+
className: cn('item', [item === null || item === void 0 ? void 0 : item.className])
|
|
80
|
+
})), /*#__PURE__*/React.createElement("div", _extends({
|
|
81
|
+
className: cn('control', [classes.control])
|
|
82
|
+
}, dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.control, isControlActivator ? listeners : null, isControlActivator ? attributes : null, {
|
|
83
|
+
ref: isControlActivator ? setActivatorNodeRef : undefined
|
|
84
|
+
}), /*#__PURE__*/React.createElement(DragIcon, {
|
|
85
|
+
className: cn('icon')
|
|
86
|
+
}))));
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
ListDataSortable.propTypes = {
|
|
90
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
91
|
+
item: PropTypes.shape(ListDataPropType).isRequired,
|
|
92
|
+
activatorNode: PropTypes.oneOf(Object.values(ActivatorNodes)).isRequired,
|
|
93
|
+
disabled: PropTypes.bool,
|
|
94
|
+
isDragOverlay: PropTypes.bool,
|
|
95
|
+
gap: PropTypes.oneOf(Object.values(GapSizes)),
|
|
96
|
+
classes: PropTypes.shape({
|
|
97
|
+
root: PropTypes.string,
|
|
98
|
+
control: PropTypes.string
|
|
99
|
+
}),
|
|
100
|
+
dataAttrs: PropTypes.objectOf(PropTypes.object)
|
|
101
|
+
};
|
|
102
|
+
export default ListDataSortable;
|
|
Binary file
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ClientRect, Modifier } from '@dnd-kit/core';
|
|
3
|
+
import type { Transform } from '@dnd-kit/utilities';
|
|
4
|
+
export declare const restrictToBoundingRect: (transform: Transform, rect: ClientRect, boundingRect: ClientRect) => Transform;
|
|
5
|
+
export declare const restrictToVerticalAxis: Modifier;
|
|
6
|
+
export declare const restrictToElement: (boundaryRef: React.RefObject<HTMLDivElement>) => Modifier;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
export var restrictToBoundingRect = function restrictToBoundingRect(transform, rect, boundingRect) {
|
|
3
|
+
var value = _extends({}, transform);
|
|
4
|
+
|
|
5
|
+
if (rect.top + transform.y <= boundingRect.top) {
|
|
6
|
+
value.y = boundingRect.top - rect.top;
|
|
7
|
+
} else if (rect.bottom + transform.y >= boundingRect.top + boundingRect.height) {
|
|
8
|
+
value.y = boundingRect.top + boundingRect.height - rect.bottom;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (rect.left + transform.x <= boundingRect.left) {
|
|
12
|
+
value.x = boundingRect.left - rect.left;
|
|
13
|
+
} else if (rect.right + transform.x >= boundingRect.left + boundingRect.width) {
|
|
14
|
+
value.x = boundingRect.left + boundingRect.width - rect.right;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
export var restrictToVerticalAxis = function restrictToVerticalAxis(_ref) {
|
|
20
|
+
var transform = _ref.transform;
|
|
21
|
+
return _extends(_extends({}, transform), {
|
|
22
|
+
x: 0
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export var restrictToElement = function restrictToElement(boundaryRef) {
|
|
26
|
+
return function (_ref2) {
|
|
27
|
+
var transform = _ref2.transform,
|
|
28
|
+
draggingNodeRect = _ref2.draggingNodeRect;
|
|
29
|
+
|
|
30
|
+
var _a;
|
|
31
|
+
|
|
32
|
+
var boundaryRect = (_a = boundaryRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
33
|
+
|
|
34
|
+
if (!draggingNodeRect || !boundaryRect) {
|
|
35
|
+
return transform;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return restrictToBoundingRect(transform, draggingNodeRect, boundaryRect);
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -324,11 +324,11 @@ var Search = function Search(_ref) {
|
|
|
324
324
|
};
|
|
325
325
|
|
|
326
326
|
var renderClearButton = function renderClearButton() {
|
|
327
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
327
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.clearButton), {
|
|
328
328
|
onClick: handleClearClick,
|
|
329
329
|
type: "button",
|
|
330
330
|
className: cn('clear')
|
|
331
|
-
}, /*#__PURE__*/React.createElement(ClearIcon, {
|
|
331
|
+
}), /*#__PURE__*/React.createElement(ClearIcon, {
|
|
332
332
|
className: cn('clear-icon')
|
|
333
333
|
}));
|
|
334
334
|
};
|
|
@@ -7,6 +7,7 @@ h5 {
|
|
|
7
7
|
}
|
|
8
8
|
.mfui-snackbar-timer {
|
|
9
9
|
color: var(--base);
|
|
10
|
+
margin-right: 8px;
|
|
10
11
|
}
|
|
11
12
|
@-webkit-keyframes snackbar-progress-bar {
|
|
12
13
|
0% {
|
|
@@ -35,7 +36,6 @@ h5 {
|
|
|
35
36
|
-webkit-box-align: center;
|
|
36
37
|
-ms-flex-align: center;
|
|
37
38
|
align-items: center;
|
|
38
|
-
margin-right: 8px;
|
|
39
39
|
width: 24px;
|
|
40
40
|
height: 24px;
|
|
41
41
|
}
|
package/dist/es/index.d.ts
CHANGED
|
@@ -23,6 +23,9 @@ export { default as GridColumn } from './components/Grid/GridColumn';
|
|
|
23
23
|
export { default as Header } from './components/Header/Header';
|
|
24
24
|
export { default as Link } from './components/Link/Link';
|
|
25
25
|
export { default as List } from './components/List/List';
|
|
26
|
+
export { default as ListData } from './components/ListData/ListData';
|
|
27
|
+
export { default as ListDataGroup } from './components/ListData/ListDataGroup';
|
|
28
|
+
export { default as ListDataSortable } from './components/ListData/components/ListDataSortable';
|
|
26
29
|
export { default as ListItem } from './components/List/ListItem';
|
|
27
30
|
export { default as Logo } from './components/Logo/Logo';
|
|
28
31
|
export { default as Month } from './components/Calendar/components/Month/Month';
|
|
@@ -48,6 +51,7 @@ export { default as SliderDisplayValue } from './components/Sliders/components/S
|
|
|
48
51
|
export { default as SliderRange } from './components/Sliders/SliderRange/SliderRange';
|
|
49
52
|
export { default as SliderRatio } from './components/Sliders/SliderRatio/SliderRatio';
|
|
50
53
|
export { default as SliderScale } from './components/Sliders/components/SliderScale/SliderScale';
|
|
54
|
+
export { default as slidesSettings } from './components/Banner/slidesSettings';
|
|
51
55
|
export { default as Snackbar } from './components/Snackbar/Snackbar';
|
|
52
56
|
export { default as SnackbarTimer } from './components/Snackbar/SnackbarTimer/SnackbarTimer';
|
|
53
57
|
export { default as Switcher } from './components/Switcher/Switcher';
|
package/dist/es/index.js
CHANGED
|
@@ -23,6 +23,9 @@ export { default as GridColumn } from "./components/Grid/GridColumn";
|
|
|
23
23
|
export { default as Header } from "./components/Header/Header";
|
|
24
24
|
export { default as Link } from "./components/Link/Link";
|
|
25
25
|
export { default as List } from "./components/List/List";
|
|
26
|
+
export { default as ListData } from "./components/ListData/ListData";
|
|
27
|
+
export { default as ListDataGroup } from "./components/ListData/ListDataGroup";
|
|
28
|
+
export { default as ListDataSortable } from "./components/ListData/components/ListDataSortable";
|
|
26
29
|
export { default as ListItem } from "./components/List/ListItem";
|
|
27
30
|
export { default as Logo } from "./components/Logo/Logo";
|
|
28
31
|
export { default as Month } from "./components/Calendar/components/Month/Month";
|
|
@@ -48,6 +51,7 @@ export { default as SliderDisplayValue } from "./components/Sliders/components/S
|
|
|
48
51
|
export { default as SliderRange } from "./components/Sliders/SliderRange/SliderRange";
|
|
49
52
|
export { default as SliderRatio } from "./components/Sliders/SliderRatio/SliderRatio";
|
|
50
53
|
export { default as SliderScale } from "./components/Sliders/components/SliderScale/SliderScale";
|
|
54
|
+
export { default as slidesSettings } from "./components/Banner/slidesSettings";
|
|
51
55
|
export { default as Snackbar } from "./components/Snackbar/Snackbar";
|
|
52
56
|
export { default as SnackbarTimer } from "./components/Snackbar/SnackbarTimer/SnackbarTimer";
|
|
53
57
|
export { default as Switcher } from "./components/Switcher/Switcher";
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
display: -ms-flexbox;
|
|
7
7
|
display: flex;
|
|
8
8
|
}
|
|
9
|
+
.mfui-banner .mfui-banner__swiper-container {
|
|
10
|
+
position: relative;
|
|
11
|
+
}
|
|
9
12
|
.mfui-banner__swiper {
|
|
10
13
|
overflow: hidden;
|
|
11
14
|
}
|
|
@@ -24,16 +27,18 @@
|
|
|
24
27
|
height: 400px;
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
|
-
.mfui-
|
|
28
|
-
|
|
30
|
+
.mfui-banner__slide-content {
|
|
31
|
+
margin-right: -1px;
|
|
32
|
+
border-right: 1px solid transparent;
|
|
29
33
|
}
|
|
30
|
-
@media screen and (
|
|
31
|
-
.mfui-
|
|
32
|
-
|
|
33
|
-
-webkit-transition: opacity 0.4s;
|
|
34
|
-
transition: opacity 0.4s;
|
|
34
|
+
@media screen and (max-width: 1023px) {
|
|
35
|
+
.mfui-banner__slide-content {
|
|
36
|
+
height: 100%;
|
|
35
37
|
}
|
|
36
38
|
}
|
|
39
|
+
.mfui-banner_auto-height .mfui-banner__slide {
|
|
40
|
+
height: auto;
|
|
41
|
+
}
|
|
37
42
|
.mfui-banner__arrow {
|
|
38
43
|
position: absolute;
|
|
39
44
|
top: 50%;
|
|
@@ -107,32 +112,27 @@
|
|
|
107
112
|
scale: 1.125;
|
|
108
113
|
}
|
|
109
114
|
.mfui-banner__pagination {
|
|
110
|
-
position: absolute;
|
|
111
|
-
bottom: 24px;
|
|
112
115
|
left: 50%;
|
|
113
116
|
z-index: 10;
|
|
114
117
|
display: -webkit-box;
|
|
115
118
|
display: -ms-flexbox;
|
|
116
119
|
display: flex;
|
|
117
|
-
gap:
|
|
120
|
+
gap: 12px;
|
|
118
121
|
-webkit-box-align: center;
|
|
119
122
|
-ms-flex-align: center;
|
|
120
123
|
align-items: center;
|
|
121
124
|
-webkit-box-pack: center;
|
|
122
125
|
-ms-flex-pack: center;
|
|
123
126
|
justify-content: center;
|
|
124
|
-
|
|
125
|
-
border-radius: 12px;
|
|
126
|
-
-webkit-transform: translateX(-50%);
|
|
127
|
-
transform: translateX(-50%);
|
|
128
|
-
}
|
|
129
|
-
@media screen and (min-width: 1024px) {
|
|
130
|
-
.mfui-banner__pagination {
|
|
131
|
-
bottom: 16px;
|
|
132
|
-
}
|
|
127
|
+
margin-top: 32px;
|
|
133
128
|
}
|
|
134
129
|
.mfui-banner__pagination_bottom-offset {
|
|
130
|
+
position: absolute;
|
|
135
131
|
bottom: 60px;
|
|
132
|
+
left: 50%;
|
|
133
|
+
z-index: 10;
|
|
134
|
+
-webkit-transform: translateX(-50%);
|
|
135
|
+
transform: translateX(-50%);
|
|
136
136
|
}
|
|
137
137
|
@media screen and (min-width: 768px) and (max-width: 1023px) {
|
|
138
138
|
.mfui-banner__pagination_bottom-offset {
|
|
@@ -154,31 +154,42 @@
|
|
|
154
154
|
bottom: 72px;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
.mfui-
|
|
158
|
-
|
|
157
|
+
.mfui-banner_radius_rounded .mfui-banner__swiper {
|
|
158
|
+
border-radius: 24px;
|
|
159
159
|
}
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
@media screen and (max-width: 767px) {
|
|
161
|
+
.mfui-banner_show-next-slide .mfui-banner__swiper {
|
|
162
|
+
margin-right: -16px;
|
|
163
|
+
margin-left: -16px;
|
|
164
|
+
padding-right: 32px;
|
|
165
|
+
padding-left: 16px;
|
|
166
|
+
border-radius: 0;
|
|
167
|
+
}
|
|
162
168
|
}
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
@media screen and (max-width: 767px) {
|
|
170
|
+
.mfui-banner_show-next-slide .mfui-banner__slide-content {
|
|
171
|
+
margin-right: 0;
|
|
172
|
+
border-right: none;
|
|
173
|
+
}
|
|
165
174
|
}
|
|
166
|
-
|
|
167
|
-
|
|
175
|
+
@media screen and (max-width: 767px) {
|
|
176
|
+
.mfui-banner_show-next-slide.mfui-banner_radius_rounded .mfui-banner__slide-content {
|
|
177
|
+
border-radius: 24px;
|
|
178
|
+
}
|
|
168
179
|
}
|
|
169
|
-
.mfui-banner_background-color_green {
|
|
180
|
+
.mfui-banner_background-color_green .mfui-banner__swiper {
|
|
170
181
|
background-color: var(--brandGreen);
|
|
171
182
|
}
|
|
172
|
-
.mfui-banner_background-color_purple {
|
|
183
|
+
.mfui-banner_background-color_purple .mfui-banner__swiper {
|
|
173
184
|
background-color: var(--brandPurple);
|
|
174
185
|
}
|
|
175
|
-
.mfui-banner_background-color_gradient {
|
|
186
|
+
.mfui-banner_background-color_gradient .mfui-banner__swiper {
|
|
176
187
|
background: -webkit-gradient(linear, right top, left top, from(#ADA6BA), to(#F6F2F9));
|
|
177
188
|
background: linear-gradient(270deg, #ADA6BA 0%, #F6F2F9 100%);
|
|
178
189
|
}
|
|
179
|
-
.mfui-banner_background-color_light {
|
|
190
|
+
.mfui-banner_background-color_light .mfui-banner__swiper {
|
|
180
191
|
background-color: #F6F2F9;
|
|
181
192
|
}
|
|
182
|
-
.mfui-banner_background-color_spbSky0 {
|
|
193
|
+
.mfui-banner_background-color_spbSky0 .mfui-banner__swiper {
|
|
183
194
|
background-color: var(--spbSky0);
|
|
184
195
|
}
|