@snack-uikit/carousel 0.4.0 → 0.4.2-preview-1becd961.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
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
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
|
+
## 0.4.1 (2024-10-31)
|
|
7
|
+
|
|
8
|
+
### Only dependencies have been changed
|
|
9
|
+
* [@snack-uikit/pagination@0.9.1](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/pagination/CHANGELOG.md)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
# 0.4.0 (2024-10-28)
|
|
7
16
|
|
|
8
17
|
|
|
@@ -29,7 +29,7 @@ function ItemProvider(_ref) {
|
|
|
29
29
|
} = _ref;
|
|
30
30
|
const containerRef = (0, react_1.useRef)(null);
|
|
31
31
|
const [computedValues, setComputedValues] = (0, react_1.useState)({
|
|
32
|
-
itemWidth:
|
|
32
|
+
itemWidth: 0,
|
|
33
33
|
gap: 0
|
|
34
34
|
});
|
|
35
35
|
const recalculateItemsSize = (0, react_1.useCallback)(() => {
|
|
@@ -158,6 +158,13 @@ function ItemProvider(_ref) {
|
|
|
158
158
|
slideCallback(slidePositionDelta);
|
|
159
159
|
}
|
|
160
160
|
}, [slideCallback]);
|
|
161
|
+
const itemWidth = (0, react_1.useMemo)(() => {
|
|
162
|
+
if (computedValues.itemWidth > 0) {
|
|
163
|
+
return computedValues.itemWidth;
|
|
164
|
+
}
|
|
165
|
+
const fallbackWidth = Math.floor(100 / showItems);
|
|
166
|
+
return `${fallbackWidth}%`;
|
|
167
|
+
}, [computedValues.itemWidth, showItems]);
|
|
161
168
|
return (0, jsx_runtime_1.jsx)("div", {
|
|
162
169
|
ref: containerRef,
|
|
163
170
|
className: styles_module_scss_1.default.itemProvider,
|
|
@@ -179,7 +186,7 @@ function ItemProvider(_ref) {
|
|
|
179
186
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
180
187
|
(0, jsx_runtime_1.jsx)("div", {
|
|
181
188
|
style: {
|
|
182
|
-
width:
|
|
189
|
+
width: itemWidth
|
|
183
190
|
},
|
|
184
191
|
className: styles_module_scss_1.default.itemContainer,
|
|
185
192
|
role: 'group',
|
|
@@ -7,7 +7,7 @@ import styles from './styles.module.css';
|
|
|
7
7
|
export function ItemProvider({ items, showItems, scrollBy, slideCallback, transition, swipe, swipeActivateLength, page, gap, }) {
|
|
8
8
|
const containerRef = useRef(null);
|
|
9
9
|
const [computedValues, setComputedValues] = useState({
|
|
10
|
-
itemWidth:
|
|
10
|
+
itemWidth: 0,
|
|
11
11
|
gap: 0,
|
|
12
12
|
});
|
|
13
13
|
const recalculateItemsSize = useCallback(() => {
|
|
@@ -126,10 +126,17 @@ export function ItemProvider({ items, showItems, scrollBy, slideCallback, transi
|
|
|
126
126
|
slideCallback(slidePositionDelta);
|
|
127
127
|
}
|
|
128
128
|
}, [slideCallback]);
|
|
129
|
+
const itemWidth = useMemo(() => {
|
|
130
|
+
if (computedValues.itemWidth > 0) {
|
|
131
|
+
return computedValues.itemWidth;
|
|
132
|
+
}
|
|
133
|
+
const fallbackWidth = Math.floor(100 / showItems);
|
|
134
|
+
return `${fallbackWidth}%`;
|
|
135
|
+
}, [computedValues.itemWidth, showItems]);
|
|
129
136
|
return (_jsx("div", { ref: containerRef, className: styles.itemProvider, "data-pointers": !drag.pointers || undefined, "data-swipe": swipe || undefined, "data-gap": gap, style: Object.assign({}, (Boolean(gap) ? { '--gap': gap } : {})), children: _jsx("div", Object.assign({}, swipeProps, { className: styles.itemTracker, "data-test-id": TEST_IDS.trackLine, style: {
|
|
130
137
|
transform: `translateX(${transform - drag.drag}px)`,
|
|
131
138
|
transition: `transform ${transition}s ease 0s`,
|
|
132
139
|
}, ref: itemsTrackerRef, children: items.map((item, i) => (
|
|
133
140
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
134
|
-
_jsx("div", { style: { width:
|
|
141
|
+
_jsx("div", { style: { width: itemWidth }, className: styles.itemContainer, role: 'group', "data-test-id": TEST_IDS.trackItem, onClick: handleSlideClick, children: item }, i))) })) }));
|
|
135
142
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.4.0",
|
|
7
|
+
"version": "0.4.2-preview-1becd961.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@snack-uikit/icons": "0.24.0",
|
|
40
|
-
"@snack-uikit/pagination": "0.9.
|
|
40
|
+
"@snack-uikit/pagination": "0.9.1",
|
|
41
41
|
"@snack-uikit/utils": "3.5.0",
|
|
42
42
|
"classnames": "2.3.2",
|
|
43
43
|
"lodash.debounce": "4.0.8",
|
|
44
44
|
"uncontrollable": "8.0.4"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "09e245c9e38c2e661fc37bdb9bed5c13e23b4844"
|
|
47
47
|
}
|
|
@@ -41,7 +41,7 @@ export function ItemProvider({
|
|
|
41
41
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
42
42
|
|
|
43
43
|
const [computedValues, setComputedValues] = useState({
|
|
44
|
-
itemWidth:
|
|
44
|
+
itemWidth: 0,
|
|
45
45
|
gap: 0,
|
|
46
46
|
});
|
|
47
47
|
|
|
@@ -203,6 +203,15 @@ export function ItemProvider({
|
|
|
203
203
|
[slideCallback],
|
|
204
204
|
);
|
|
205
205
|
|
|
206
|
+
const itemWidth = useMemo(() => {
|
|
207
|
+
if (computedValues.itemWidth > 0) {
|
|
208
|
+
return computedValues.itemWidth;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const fallbackWidth = Math.floor(100 / showItems);
|
|
212
|
+
return `${fallbackWidth}%`;
|
|
213
|
+
}, [computedValues.itemWidth, showItems]);
|
|
214
|
+
|
|
206
215
|
return (
|
|
207
216
|
<div
|
|
208
217
|
ref={containerRef}
|
|
@@ -228,7 +237,7 @@ export function ItemProvider({
|
|
|
228
237
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
229
238
|
<div
|
|
230
239
|
key={i}
|
|
231
|
-
style={{ width:
|
|
240
|
+
style={{ width: itemWidth }}
|
|
232
241
|
className={styles.itemContainer}
|
|
233
242
|
role='group'
|
|
234
243
|
data-test-id={TEST_IDS.trackItem}
|