@rescui/tab-list 0.13.3 → 0.13.5
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/lib/_virtual/index.css.js +7 -7
- package/lib/_virtual/left.js +8 -9
- package/lib/_virtual/right.js +8 -9
- package/lib/index.css +81 -187
- package/lib/parts/deep-map.js +4 -7
- package/lib/parts/separator.p.module.css.js +3 -3
- package/lib/parts/tab-list-context.js +3 -5
- package/lib/parts/tab-list.p.module.css.js +15 -15
- package/lib/parts/tab-separator.js +6 -4
- package/lib/parts/tab.js +36 -50
- package/lib/parts/use-indicator.js +27 -44
- package/lib/parts/use-scrollable-list.js +115 -137
- package/lib/parts/with-scroll-arrows.js +37 -55
- package/lib/parts/with-scroll-arrows.p.module.css.js +11 -11
- package/lib/tab-list.js +24 -26
- package/package.json +9 -10
- package/lib/parts/use-resize-observer.d.ts +0 -2
- package/lib/parts/use-resize-observer.js +0 -46
|
@@ -1,53 +1,37 @@
|
|
|
1
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
|
2
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
3
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
4
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
5
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
6
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
7
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
8
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
9
|
-
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
10
|
-
var _excluded = ["child", "itemId", "childValue", "ref"],
|
|
11
|
-
_excluded2 = ["value", "onFocus"];
|
|
12
|
-
import "core-js/modules/es.object.to-string.js";
|
|
13
|
-
import "core-js/modules/es.promise.js";
|
|
14
|
-
|
|
15
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
-
|
|
17
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? Object.defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
-
|
|
19
1
|
import React, { useRef, useState, useCallback, useMemo, useEffect, cloneElement } from 'react';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
2
|
+
import { useResizeObserver } from '@rescui/use-resize-observer';
|
|
3
|
+
import { deepMap } from './deep-map.js'; // arrow (32) + shadow (10) + shadow blur (~8) + item focus outline (4)
|
|
22
4
|
|
|
23
|
-
|
|
5
|
+
const ARROW_AREA_WIDTH_IN_PX = 54;
|
|
24
6
|
|
|
25
7
|
function patchItemIfNeeded(_ref) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
8
|
+
let {
|
|
9
|
+
child,
|
|
10
|
+
itemId,
|
|
11
|
+
childValue,
|
|
12
|
+
ref,
|
|
13
|
+
...restProps
|
|
14
|
+
} = _ref;
|
|
15
|
+
return /*#__PURE__*/cloneElement(child, {
|
|
16
|
+
itemId,
|
|
34
17
|
value: childValue,
|
|
35
|
-
ref
|
|
36
|
-
|
|
18
|
+
ref,
|
|
19
|
+
...restProps
|
|
20
|
+
});
|
|
37
21
|
}
|
|
38
22
|
|
|
39
23
|
function calculateArrowsVisibility(scrollContainerEl) {
|
|
40
24
|
// doing this because scrollContainerEl.scrollWidth returns a rounded value
|
|
41
|
-
|
|
42
|
-
|
|
25
|
+
const scrollLeft = Math.round(scrollContainerEl.scrollLeft);
|
|
26
|
+
const shouldShowAnyArrow = scrollContainerEl.offsetWidth < scrollContainerEl.scrollWidth; // in some browsers, fully scrolled element has `scrollLeft + offsetWidth === scrollWidth - 1`
|
|
43
27
|
// so we take this measurement error into account
|
|
44
28
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
29
|
+
const delta = 1;
|
|
30
|
+
const showLeftArrow = shouldShowAnyArrow && scrollLeft > 0;
|
|
31
|
+
const showRightArrow = shouldShowAnyArrow && scrollLeft + scrollContainerEl.offsetWidth < scrollContainerEl.scrollWidth - delta;
|
|
48
32
|
return {
|
|
49
|
-
showLeftArrow
|
|
50
|
-
showRightArrow
|
|
33
|
+
showLeftArrow,
|
|
34
|
+
showRightArrow
|
|
51
35
|
};
|
|
52
36
|
}
|
|
53
37
|
|
|
@@ -76,30 +60,30 @@ function scrollElementLeft(element, to) {
|
|
|
76
60
|
}
|
|
77
61
|
|
|
78
62
|
function scrollIntoView(activeNode, parentNode) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
63
|
+
const childWidth = activeNode.offsetWidth;
|
|
64
|
+
const parentWidth = parentNode.offsetWidth;
|
|
65
|
+
const parentStyles = getComputedStyle(parentNode);
|
|
66
|
+
const parentMarginsOffset = parseInt(parentStyles.marginLeft, 10) + parseInt(parentStyles.marginRight, 10);
|
|
67
|
+
const parentScrollLeft = parentNode.scrollLeft;
|
|
68
|
+
const parentScrollWidth = parentNode.scrollWidth; // position of the left border in the container
|
|
85
69
|
|
|
86
|
-
|
|
70
|
+
const activeNodeLeft = parentNode.offsetLeft + activeNode.offsetLeft; // position of the right border in the container
|
|
87
71
|
|
|
88
|
-
|
|
72
|
+
const activeNodeRight = activeNodeLeft + childWidth; // position of the left border in relation to the viewport
|
|
89
73
|
|
|
90
|
-
|
|
74
|
+
const activeNodeLeftOffset = activeNodeLeft - parentScrollLeft; // position of the right border in relation to the viewport
|
|
91
75
|
|
|
92
|
-
|
|
76
|
+
const activeNodeRightOffset = parentWidth - (activeNodeLeftOffset + childWidth); // by default, don't scroll at all
|
|
93
77
|
|
|
94
|
-
|
|
78
|
+
let scrollTo = -1; // if before the element there is a space larger than arrow area
|
|
95
79
|
|
|
96
|
-
|
|
80
|
+
const isElHasWorkSpaceLeft = activeNodeLeft > ARROW_AREA_WIDTH_IN_PX; // if after the element there is a space larger than arrow area
|
|
97
81
|
|
|
98
|
-
|
|
82
|
+
const isElHasWorkSpaceRight = activeNodeRight < parentScrollWidth - ARROW_AREA_WIDTH_IN_PX;
|
|
99
83
|
|
|
100
84
|
if (activeNodeRightOffset <= ARROW_AREA_WIDTH_IN_PX) {
|
|
101
85
|
if (isElHasWorkSpaceRight) {
|
|
102
|
-
|
|
86
|
+
const sideOffset = parentWidth - childWidth + parentMarginsOffset;
|
|
103
87
|
scrollTo = activeNodeLeft + ARROW_AREA_WIDTH_IN_PX - sideOffset;
|
|
104
88
|
} else {
|
|
105
89
|
scrollTo = parentScrollWidth - parentWidth; // right edge
|
|
@@ -120,67 +104,60 @@ function scrollIntoView(activeNode, parentNode) {
|
|
|
120
104
|
}
|
|
121
105
|
}
|
|
122
106
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
107
|
+
const useScrollableList = _ref2 => {
|
|
108
|
+
let {
|
|
109
|
+
children,
|
|
110
|
+
compareValues,
|
|
111
|
+
value,
|
|
112
|
+
CompareItem
|
|
113
|
+
} = _ref2;
|
|
114
|
+
const activeNodeRef = useRef(null);
|
|
115
|
+
const scrollableRef = useRef(null);
|
|
116
|
+
const containerRef = useRef(null); // reset targeted element on scrolling by arrows
|
|
131
117
|
// so on window resize there wouldn't scroll to it
|
|
132
118
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
var _useState3 = useState({
|
|
119
|
+
const [targetedEl, setTargetedEl] = useState(null);
|
|
120
|
+
const [{
|
|
121
|
+
showLeftArrow,
|
|
122
|
+
showRightArrow
|
|
123
|
+
}, setShowArrows] = useState({
|
|
139
124
|
showLeftArrow: false,
|
|
140
125
|
showRightArrow: false
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
_useState4$ = _useState4[0],
|
|
144
|
-
showLeftArrow = _useState4$.showLeftArrow,
|
|
145
|
-
showRightArrow = _useState4$.showRightArrow,
|
|
146
|
-
setShowArrows = _useState4[1];
|
|
147
|
-
|
|
148
|
-
var _onFocus = useCallback(function (e) {
|
|
126
|
+
});
|
|
127
|
+
const onFocus = useCallback(e => {
|
|
149
128
|
setTargetedEl(e.target);
|
|
150
129
|
}, []);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
var items = deepMap(children, function (child) {
|
|
130
|
+
const [childrenWithValues, selectedId] = useMemo(() => {
|
|
131
|
+
let counter = 0;
|
|
132
|
+
let currentSelectedItemId = null;
|
|
133
|
+
const items = deepMap(children, child => {
|
|
156
134
|
if (child.type === CompareItem) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
var isSelectedItem = hasAlreadySelectedItem && compareValues(value, childValue);
|
|
135
|
+
const {
|
|
136
|
+
value: childValue = counter,
|
|
137
|
+
onFocus: onFocusFromProps,
|
|
138
|
+
...restProps
|
|
139
|
+
} = child.props;
|
|
140
|
+
const hasAlreadySelectedItem = currentSelectedItemId === null;
|
|
141
|
+
const isSelectedItem = hasAlreadySelectedItem && compareValues(value, childValue);
|
|
165
142
|
|
|
166
143
|
if (isSelectedItem) {
|
|
167
144
|
currentSelectedItemId = counter;
|
|
168
145
|
}
|
|
169
146
|
|
|
170
|
-
|
|
171
|
-
child
|
|
147
|
+
const patchedItem = patchItemIfNeeded({
|
|
148
|
+
child,
|
|
172
149
|
itemId: counter,
|
|
173
|
-
childValue
|
|
174
|
-
|
|
175
|
-
onFocus:
|
|
150
|
+
childValue,
|
|
151
|
+
...restProps,
|
|
152
|
+
onFocus: e => {
|
|
176
153
|
if (onFocusFromProps) {
|
|
177
154
|
onFocusFromProps(e);
|
|
178
155
|
}
|
|
179
156
|
|
|
180
|
-
|
|
157
|
+
onFocus(e);
|
|
181
158
|
},
|
|
182
159
|
ref: isSelectedItem ? activeNodeRef : null
|
|
183
|
-
})
|
|
160
|
+
});
|
|
184
161
|
counter += 1;
|
|
185
162
|
return patchedItem;
|
|
186
163
|
} else {
|
|
@@ -188,36 +165,47 @@ var useScrollableList = function useScrollableList(_ref2) {
|
|
|
188
165
|
}
|
|
189
166
|
});
|
|
190
167
|
return [React.Children.toArray(items), currentSelectedItemId];
|
|
191
|
-
}, [children, value, compareValues,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
setTargetedEl(null);
|
|
201
|
-
scrollElementBy(current, left);
|
|
202
|
-
};
|
|
168
|
+
}, [children, value, compareValues, onFocus, CompareItem]);
|
|
169
|
+
|
|
170
|
+
const prepareDirectionScroller = direction => () => {
|
|
171
|
+
const {
|
|
172
|
+
current
|
|
173
|
+
} = scrollableRef;
|
|
174
|
+
const left = Math.max(current.clientWidth - 2 * ARROW_AREA_WIDTH_IN_PX, 30) * (direction === 'right' ? 1 : -1);
|
|
175
|
+
setTargetedEl(null);
|
|
176
|
+
scrollElementBy(current, left);
|
|
203
177
|
};
|
|
204
178
|
|
|
205
|
-
useEffect(
|
|
179
|
+
useEffect(() => {
|
|
206
180
|
if (!activeNodeRef.current) {
|
|
207
181
|
return;
|
|
208
182
|
}
|
|
209
183
|
|
|
210
184
|
setTargetedEl(activeNodeRef.current);
|
|
211
185
|
}, [value, childrenWithValues]);
|
|
212
|
-
|
|
186
|
+
const setArrowsVisibility = useCallback(() => {
|
|
213
187
|
if (!scrollableRef.current) {
|
|
214
188
|
return;
|
|
215
189
|
}
|
|
216
190
|
|
|
217
191
|
setShowArrows(calculateArrowsVisibility(scrollableRef.current));
|
|
218
|
-
}, []);
|
|
219
|
-
|
|
220
|
-
|
|
192
|
+
}, []); // update arrows while smooth scrolling
|
|
193
|
+
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
const scrollContainer = scrollableRef.current;
|
|
196
|
+
|
|
197
|
+
if (!scrollContainer) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
scrollContainer.addEventListener('scroll', setArrowsVisibility, {
|
|
202
|
+
passive: true
|
|
203
|
+
});
|
|
204
|
+
return () => scrollContainer.removeEventListener('scroll', setArrowsVisibility);
|
|
205
|
+
}, [setArrowsVisibility]); // scrollIntoView active element when it changes or the component resizes
|
|
206
|
+
|
|
207
|
+
const updateScrollState = () => {
|
|
208
|
+
const scrollableEl = scrollableRef.current;
|
|
221
209
|
|
|
222
210
|
if (!scrollableEl) {
|
|
223
211
|
return;
|
|
@@ -228,35 +216,25 @@ var useScrollableList = function useScrollableList(_ref2) {
|
|
|
228
216
|
}
|
|
229
217
|
|
|
230
218
|
setArrowsVisibility();
|
|
231
|
-
}
|
|
219
|
+
}; // look at the containers resizes
|
|
232
220
|
|
|
233
|
-
useEffect(function () {
|
|
234
|
-
var scrollContainer = scrollableRef.current;
|
|
235
221
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return function () {
|
|
244
|
-
return scrollContainer.removeEventListener('scroll', setArrowsVisibility);
|
|
245
|
-
};
|
|
246
|
-
}, [setArrowsVisibility]); // look at the containers resizes
|
|
247
|
-
// onPartsResize will be called when its updates
|
|
248
|
-
|
|
249
|
-
useResizeObserver(containerRef, onPartsResize);
|
|
250
|
-
useResizeObserver(scrollableRef, onPartsResize);
|
|
222
|
+
useResizeObserver(containerRef, updateScrollState, {
|
|
223
|
+
ignoreFirstCall: true
|
|
224
|
+
});
|
|
225
|
+
useResizeObserver(scrollableRef, updateScrollState, {
|
|
226
|
+
ignoreFirstCall: true
|
|
227
|
+
});
|
|
228
|
+
useEffect(updateScrollState, [targetedEl, setArrowsVisibility]);
|
|
251
229
|
return {
|
|
252
|
-
selectedId
|
|
253
|
-
prepareDirectionScroller
|
|
254
|
-
activeNodeRef
|
|
255
|
-
scrollableRef
|
|
256
|
-
containerRef
|
|
257
|
-
childrenWithValues
|
|
258
|
-
showLeftArrow
|
|
259
|
-
showRightArrow
|
|
230
|
+
selectedId,
|
|
231
|
+
prepareDirectionScroller,
|
|
232
|
+
activeNodeRef,
|
|
233
|
+
scrollableRef,
|
|
234
|
+
containerRef,
|
|
235
|
+
childrenWithValues,
|
|
236
|
+
showLeftArrow,
|
|
237
|
+
showRightArrow
|
|
260
238
|
};
|
|
261
239
|
};
|
|
262
240
|
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
import "core-js/modules/es.object.to-string.js";
|
|
2
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
|
3
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
4
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
5
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
6
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
7
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
8
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
9
|
-
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
10
|
-
var _excluded = ["compareValues", "value", "onChange", "children", "theme", "data-e2e"];
|
|
11
|
-
import "core-js/modules/es.function.name.js";
|
|
12
|
-
|
|
13
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
-
|
|
15
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? Object.defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
-
|
|
17
1
|
import React from 'react';
|
|
18
2
|
import cn from 'classnames';
|
|
19
3
|
import { Button } from '@rescui/button';
|
|
@@ -23,41 +7,38 @@ import RightIcon from '../_virtual/right.js';
|
|
|
23
7
|
import { useScrollableList } from './use-scrollable-list.js';
|
|
24
8
|
import styles from './with-scroll-arrows.p.module.css.js';
|
|
25
9
|
|
|
26
|
-
|
|
27
|
-
return activeValue === tabValue;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
var withScrollArrows = function withScrollArrows(WrappedComponent, CompareItem) {
|
|
31
|
-
var arrowHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '100%';
|
|
32
|
-
|
|
33
|
-
var WithScrollArrowsComponent = function WithScrollArrowsComponent(_ref) {
|
|
34
|
-
var _ref$compareValues = _ref.compareValues,
|
|
35
|
-
compareValues = _ref$compareValues === void 0 ? compareTabsDefault : _ref$compareValues,
|
|
36
|
-
value = _ref.value,
|
|
37
|
-
onChange = _ref.onChange,
|
|
38
|
-
children = _ref.children,
|
|
39
|
-
themeFromProps = _ref.theme,
|
|
40
|
-
e2eId = _ref['data-e2e'],
|
|
41
|
-
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
10
|
+
const compareTabsDefault = (activeValue, tabValue) => activeValue === tabValue;
|
|
42
11
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var _useScrollableList = useScrollableList({
|
|
46
|
-
children: children,
|
|
47
|
-
compareValues: compareValues,
|
|
48
|
-
value: value,
|
|
49
|
-
CompareItem: CompareItem
|
|
50
|
-
}),
|
|
51
|
-
selectedId = _useScrollableList.selectedId,
|
|
52
|
-
prepareDirectionScroller = _useScrollableList.prepareDirectionScroller,
|
|
53
|
-
activeNodeRef = _useScrollableList.activeNodeRef,
|
|
54
|
-
scrollableRef = _useScrollableList.scrollableRef,
|
|
55
|
-
containerRef = _useScrollableList.containerRef,
|
|
56
|
-
childrenWithValues = _useScrollableList.childrenWithValues,
|
|
57
|
-
showLeftArrow = _useScrollableList.showLeftArrow,
|
|
58
|
-
showRightArrow = _useScrollableList.showRightArrow;
|
|
12
|
+
const withScrollArrows = function (WrappedComponent, CompareItem) {
|
|
13
|
+
let arrowHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '100%';
|
|
59
14
|
|
|
60
|
-
|
|
15
|
+
const WithScrollArrowsComponent = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
compareValues = compareTabsDefault,
|
|
18
|
+
value,
|
|
19
|
+
onChange,
|
|
20
|
+
children,
|
|
21
|
+
theme: themeFromProps,
|
|
22
|
+
['data-e2e']: e2eId,
|
|
23
|
+
...restProps
|
|
24
|
+
} = _ref;
|
|
25
|
+
const theme = useThemeWithUndefined(themeFromProps);
|
|
26
|
+
const {
|
|
27
|
+
selectedId,
|
|
28
|
+
prepareDirectionScroller,
|
|
29
|
+
activeNodeRef,
|
|
30
|
+
scrollableRef,
|
|
31
|
+
containerRef,
|
|
32
|
+
childrenWithValues,
|
|
33
|
+
showLeftArrow,
|
|
34
|
+
showRightArrow
|
|
35
|
+
} = useScrollableList({
|
|
36
|
+
children,
|
|
37
|
+
compareValues,
|
|
38
|
+
value,
|
|
39
|
+
CompareItem
|
|
40
|
+
});
|
|
41
|
+
const arrowStyles = {
|
|
61
42
|
height: arrowHeight
|
|
62
43
|
};
|
|
63
44
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -74,21 +55,22 @@ var withScrollArrows = function withScrollArrows(WrappedComponent, CompareItem)
|
|
|
74
55
|
onClick: prepareDirectionScroller('left'),
|
|
75
56
|
icon: /*#__PURE__*/React.createElement(LeftIcon, null),
|
|
76
57
|
size: "s",
|
|
77
|
-
"data-e2e": e2eId ?
|
|
58
|
+
"data-e2e": e2eId ? `${e2eId}__left-arrow` : null,
|
|
78
59
|
"data-test": 'scrollable-list-arrow-left'
|
|
79
60
|
})), /*#__PURE__*/React.createElement("div", {
|
|
80
61
|
className: cn(styles.scrollable, showLeftArrow && styles.withLeftArrow, showRightArrow && styles.withRightArrow),
|
|
81
62
|
ref: scrollableRef,
|
|
82
63
|
tabIndex: -1
|
|
83
|
-
}, /*#__PURE__*/React.createElement(WrappedComponent,
|
|
64
|
+
}, /*#__PURE__*/React.createElement(WrappedComponent, {
|
|
84
65
|
selectedId: selectedId,
|
|
85
66
|
activeNodeRef: activeNodeRef,
|
|
86
67
|
value: value,
|
|
87
68
|
onChange: onChange,
|
|
88
69
|
theme: theme,
|
|
89
70
|
"data-e2e": e2eId,
|
|
90
|
-
containerRef: containerRef
|
|
91
|
-
|
|
71
|
+
containerRef: containerRef,
|
|
72
|
+
...restProps
|
|
73
|
+
}, childrenWithValues)), /*#__PURE__*/React.createElement("div", {
|
|
92
74
|
className: cn(styles.arrow, styles.arrowRight, showRightArrow && styles.shown),
|
|
93
75
|
style: arrowStyles,
|
|
94
76
|
"data-test": 'scrollable-list-arrow-right-wrapper'
|
|
@@ -100,12 +82,12 @@ var withScrollArrows = function withScrollArrows(WrappedComponent, CompareItem)
|
|
|
100
82
|
icon: /*#__PURE__*/React.createElement(RightIcon, null),
|
|
101
83
|
className: styles.arrowButton,
|
|
102
84
|
size: "s",
|
|
103
|
-
"data-e2e": e2eId ?
|
|
85
|
+
"data-e2e": e2eId ? `${e2eId}__right-arrow` : null,
|
|
104
86
|
"data-test": 'scrollable-list-arrow-right'
|
|
105
87
|
})));
|
|
106
88
|
};
|
|
107
89
|
|
|
108
|
-
WithScrollArrowsComponent.displayName =
|
|
90
|
+
WithScrollArrowsComponent.displayName = `withScrollArrows(${WrappedComponent.displayName || WrappedComponent.name})`;
|
|
109
91
|
return WithScrollArrowsComponent;
|
|
110
92
|
};
|
|
111
93
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"light": "
|
|
3
|
-
"dark": "
|
|
4
|
-
"wrapper": "
|
|
5
|
-
"scrollable": "
|
|
6
|
-
"arrow": "
|
|
7
|
-
"shown": "
|
|
8
|
-
"arrowLeft": "
|
|
9
|
-
"arrowRight": "
|
|
10
|
-
"withLeftArrow": "
|
|
11
|
-
"withRightArrow": "
|
|
12
|
-
"arrowButton": "
|
|
2
|
+
"light": "_light_awzdsf_9",
|
|
3
|
+
"dark": "_dark_awzdsf_12",
|
|
4
|
+
"wrapper": "_wrapper_awzdsf_16",
|
|
5
|
+
"scrollable": "_scrollable_awzdsf_23",
|
|
6
|
+
"arrow": "_arrow_awzdsf_52",
|
|
7
|
+
"shown": "_shown_awzdsf_72",
|
|
8
|
+
"arrowLeft": "_arrowLeft_awzdsf_80",
|
|
9
|
+
"arrowRight": "_arrowRight_awzdsf_85",
|
|
10
|
+
"withLeftArrow": "_withLeftArrow_awzdsf_91",
|
|
11
|
+
"withRightArrow": "_withRightArrow_awzdsf_100",
|
|
12
|
+
"arrowButton": "_arrowButton_awzdsf_121"
|
|
13
13
|
};
|
|
14
14
|
export { styles as default };
|
package/lib/tab-list.js
CHANGED
|
@@ -6,42 +6,40 @@ import { TabListContext } from './parts/tab-list-context.js';
|
|
|
6
6
|
import { withScrollArrows } from './parts/with-scroll-arrows.js';
|
|
7
7
|
import { useIndicator } from './parts/use-indicator.js';
|
|
8
8
|
import styles from './parts/tab-list.p.module.css.js';
|
|
9
|
-
|
|
9
|
+
const STYLES_SIZES = {
|
|
10
10
|
m: styles.sizeM,
|
|
11
11
|
l: styles.sizeL
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
activeNodeRef: activeNodeRef,
|
|
34
|
-
containerRef: containerRef,
|
|
14
|
+
const InnerTabList = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
size = 'm',
|
|
17
|
+
sparse = false,
|
|
18
|
+
className,
|
|
19
|
+
mode = 'classic',
|
|
20
|
+
short = false,
|
|
21
|
+
theme,
|
|
22
|
+
value,
|
|
23
|
+
onChange,
|
|
24
|
+
children,
|
|
25
|
+
selectedId,
|
|
26
|
+
activeNodeRef,
|
|
27
|
+
containerRef,
|
|
28
|
+
['data-e2e']: e2eId
|
|
29
|
+
} = _ref;
|
|
30
|
+
const indicator = useIndicator({
|
|
31
|
+
activeNodeRef,
|
|
32
|
+
containerRef,
|
|
35
33
|
triggers: [value, children]
|
|
36
34
|
});
|
|
37
35
|
return /*#__PURE__*/React.createElement(TabListContext.Provider, {
|
|
38
36
|
value: {
|
|
39
|
-
onChange
|
|
40
|
-
selectedId
|
|
37
|
+
onChange,
|
|
38
|
+
selectedId
|
|
41
39
|
}
|
|
42
40
|
}, /*#__PURE__*/React.createElement("div", {
|
|
43
41
|
className: cn(styles.tabsContainer, styles[theme], styles[mode], STYLES_SIZES[size], sparse && styles.sparse, short && styles.short, className),
|
|
44
|
-
"data-e2e": e2eId ?
|
|
42
|
+
"data-e2e": e2eId ? `${e2eId}__tabs-container` : null,
|
|
45
43
|
"data-test": 'tab-list',
|
|
46
44
|
ref: containerRef
|
|
47
45
|
}, children, /*#__PURE__*/React.createElement("span", {
|
|
@@ -51,7 +49,7 @@ var InnerTabList = function InnerTabList(_ref) {
|
|
|
51
49
|
};
|
|
52
50
|
|
|
53
51
|
InnerTabList.displayName = 'TabList';
|
|
54
|
-
|
|
52
|
+
const TabList = withScrollArrows(InnerTabList, Tab); // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
55
53
|
// @ts-ignore
|
|
56
54
|
|
|
57
55
|
TabList.propTypes = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/tab-list",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
@@ -14,11 +14,10 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@babel/runtime-corejs3": "^7.
|
|
18
|
-
"@
|
|
19
|
-
"@rescui/
|
|
20
|
-
"classnames": "^2.2.6"
|
|
21
|
-
"core-js": "^3.9.1"
|
|
17
|
+
"@babel/runtime-corejs3": "^7.26.0",
|
|
18
|
+
"@rescui/button": "^0.18.1",
|
|
19
|
+
"@rescui/use-resize-observer": "^0.2.5",
|
|
20
|
+
"classnames": "^2.2.6"
|
|
22
21
|
},
|
|
23
22
|
"peerDependencies": {
|
|
24
23
|
"@rescui/ui-contexts": "^0.5.0",
|
|
@@ -26,10 +25,10 @@
|
|
|
26
25
|
"react": ">=16.8.0 <19"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
29
|
-
"@rescui/colors": "^0.2.
|
|
28
|
+
"@rescui/colors": "^0.2.6",
|
|
30
29
|
"@rescui/postcss-preset-library": "^0.2.2",
|
|
31
|
-
"@rescui/scripts": "^0.3.
|
|
32
|
-
"@rescui/typography": "^0.19.
|
|
30
|
+
"@rescui/scripts": "^0.3.5",
|
|
31
|
+
"@rescui/typography": "^0.19.1",
|
|
33
32
|
"@rescui/visual-regression": "^0.1.2"
|
|
34
33
|
},
|
|
35
34
|
"scripts": {
|
|
@@ -37,5 +36,5 @@
|
|
|
37
36
|
"build-pcss-api": "rescui-scripts build-pcss-api --file public-api.p.css"
|
|
38
37
|
},
|
|
39
38
|
"nx": {},
|
|
40
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "67627f69be3de4b4c6a21244fd7de36e841f01f0"
|
|
41
40
|
}
|