@snack-uikit/carousel 0.6.13 → 0.6.14-preview-eff3bc02.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.
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
3
5
  var __rest = void 0 && (void 0).__rest || function (s, e) {
4
6
  var t = {};
5
7
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -29,29 +31,38 @@ const ItemProvider_1 = require("../ItemProvider");
29
31
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
30
32
  function Carousel(_a) {
31
33
  var _b;
32
- var {
33
- children: items,
34
- showItems = 1,
35
- scrollBy: scrollByProp,
36
- transition = 0.4,
37
- swipe = true,
38
- arrows = true,
39
- pagination = true,
40
- className,
41
- gap,
42
- state,
43
- infiniteScroll = false,
44
- swipeActivateLength = 48,
45
- autoSwipe,
46
- controlsVisibility = 'hover'
47
- } = _a,
34
+ var items = _a.children,
35
+ _a$showItems = _a.showItems,
36
+ showItems = _a$showItems === void 0 ? 1 : _a$showItems,
37
+ scrollByProp = _a.scrollBy,
38
+ _a$transition = _a.transition,
39
+ transition = _a$transition === void 0 ? 0.4 : _a$transition,
40
+ _a$swipe = _a.swipe,
41
+ swipe = _a$swipe === void 0 ? true : _a$swipe,
42
+ _a$arrows = _a.arrows,
43
+ arrows = _a$arrows === void 0 ? true : _a$arrows,
44
+ _a$pagination = _a.pagination,
45
+ pagination = _a$pagination === void 0 ? true : _a$pagination,
46
+ className = _a.className,
47
+ gap = _a.gap,
48
+ state = _a.state,
49
+ _a$infiniteScroll = _a.infiniteScroll,
50
+ infiniteScroll = _a$infiniteScroll === void 0 ? false : _a$infiniteScroll,
51
+ _a$swipeActivateLengt = _a.swipeActivateLength,
52
+ swipeActivateLength = _a$swipeActivateLengt === void 0 ? 48 : _a$swipeActivateLengt,
53
+ autoSwipe = _a.autoSwipe,
54
+ _a$controlsVisibility = _a.controlsVisibility,
55
+ controlsVisibility = _a$controlsVisibility === void 0 ? 'hover' : _a$controlsVisibility,
48
56
  rest = __rest(_a, ["children", "showItems", "scrollBy", "transition", "swipe", "arrows", "pagination", "className", "gap", "state", "infiniteScroll", "swipeActivateLength", "autoSwipe", "controlsVisibility"]);
49
57
  const timerRef = (0, react_1.useRef)();
50
58
  const scrollBy = (0, react_1.useMemo)(() => scrollByProp !== null && scrollByProp !== void 0 ? scrollByProp : Math.trunc(showItems), [showItems, scrollByProp]);
51
- const [page, setPage] = (0, uncontrollable_1.useUncontrolledProp)(state === null || state === void 0 ? void 0 : state.page, (_b = state === null || state === void 0 ? void 0 : state.page) !== null && _b !== void 0 ? _b : 0, newPage => {
52
- const result = typeof newPage === 'function' ? newPage(page) : newPage;
53
- state === null || state === void 0 ? void 0 : state.onChange(result);
54
- });
59
+ const _ref = (0, uncontrollable_1.useUncontrolledProp)(state === null || state === void 0 ? void 0 : state.page, (_b = state === null || state === void 0 ? void 0 : state.page) !== null && _b !== void 0 ? _b : 0, newPage => {
60
+ const result = typeof newPage === 'function' ? newPage(page) : newPage;
61
+ state === null || state === void 0 ? void 0 : state.onChange(result);
62
+ }),
63
+ _ref2 = (0, _slicedToArray2.default)(_ref, 2),
64
+ page = _ref2[0],
65
+ setPage = _ref2[1];
55
66
  const total = (0, react_1.useMemo)(() => {
56
67
  if (items.length <= showItems) {
57
68
  return 1;
@@ -24,11 +24,9 @@ const icons_1 = require("@snack-uikit/icons");
24
24
  const utils_1 = require("@snack-uikit/utils");
25
25
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
26
26
  exports.Control = (0, react_1.forwardRef)((_a, ref) => {
27
- var {
28
- onClick,
29
- variant,
30
- className
31
- } = _a,
27
+ var onClick = _a.onClick,
28
+ variant = _a.variant,
29
+ className = _a.className,
32
30
  rest = __rest(_a, ["onClick", "variant", "className"]);
33
31
  return (0, jsx_runtime_1.jsx)("button", Object.assign({
34
32
  ref: ref,
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
3
5
  var __rest = void 0 && (void 0).__rest || function (s, e) {
4
6
  var t = {};
5
7
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -25,22 +27,23 @@ const utils_1 = require("@snack-uikit/utils");
25
27
  const testIds_1 = require("../../testIds");
26
28
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
27
29
  function ItemProvider(_ref) {
28
- let {
29
- items,
30
- showItems,
31
- scrollBy,
32
- slideCallback,
33
- transition,
34
- swipe,
35
- swipeActivateLength,
36
- page,
37
- gap
38
- } = _ref;
30
+ let items = _ref.items,
31
+ showItems = _ref.showItems,
32
+ scrollBy = _ref.scrollBy,
33
+ slideCallback = _ref.slideCallback,
34
+ transition = _ref.transition,
35
+ swipe = _ref.swipe,
36
+ swipeActivateLength = _ref.swipeActivateLength,
37
+ page = _ref.page,
38
+ gap = _ref.gap;
39
39
  const containerRef = (0, react_1.useRef)(null);
40
- const [computedValues, setComputedValues] = (0, react_1.useState)({
41
- itemWidth: 0,
42
- gap: 0
43
- });
40
+ const _ref2 = (0, react_1.useState)({
41
+ itemWidth: 0,
42
+ gap: 0
43
+ }),
44
+ _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
45
+ computedValues = _ref3[0],
46
+ setComputedValues = _ref3[1];
44
47
  const recalculateItemsSize = (0, react_1.useCallback)(() => {
45
48
  const containerElement = containerRef.current;
46
49
  if (!containerElement) {
@@ -69,7 +72,7 @@ function ItemProvider(_ref) {
69
72
  const itemsTrackerRef = (0, react_1.useRef)(null);
70
73
  const hideNonVisibleItems = () => {
71
74
  var _a;
72
- (_a = itemsTrackerRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll(`[data-test-id=${testIds_1.TEST_IDS.trackItem}]`).forEach(slide => {
75
+ (_a = itemsTrackerRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll("[data-test-id=".concat(testIds_1.TEST_IDS.trackItem, "]")).forEach(slide => {
73
76
  slide.setAttribute('aria-hidden', '0');
74
77
  slide.querySelectorAll('a, button, select, input, textarea, [tabindex="0"]').forEach(focusableElement => {
75
78
  focusableElement.setAttribute('tabindex', '-5');
@@ -79,7 +82,7 @@ function ItemProvider(_ref) {
79
82
  };
80
83
  const showVisibleItems = (slide, page, show) => {
81
84
  var _a;
82
- (_a = itemsTrackerRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll(`[data-test-id=${testIds_1.TEST_IDS.trackItem}]`).forEach((item, i) => {
85
+ (_a = itemsTrackerRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll("[data-test-id=".concat(testIds_1.TEST_IDS.trackItem, "]")).forEach((item, i) => {
83
86
  if (i >= page * slide && i < page * slide + Math.trunc(show)) {
84
87
  item.removeAttribute('aria-hidden');
85
88
  item.querySelectorAll('a, button, select, input, textarea, [tabindex="-5"]').forEach(focusableElement => {
@@ -113,12 +116,15 @@ function ItemProvider(_ref) {
113
116
  return computedValues.itemWidth;
114
117
  }
115
118
  const fallbackWidth = Math.floor(100 / showItems);
116
- return `${fallbackWidth}%`;
119
+ return "".concat(fallbackWidth, "%");
117
120
  }, [computedValues.itemWidth, showItems]);
118
- const [drag, setDrag] = (0, react_1.useState)({
119
- drag: 0,
120
- pointers: true
121
- });
121
+ const _ref4 = (0, react_1.useState)({
122
+ drag: 0,
123
+ pointers: true
124
+ }),
125
+ _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
126
+ drag = _ref5[0],
127
+ setDrag = _ref5[1];
122
128
  const handleSwiping = eventData => {
123
129
  setDrag({
124
130
  drag: eventData.deltaX,
@@ -146,9 +152,7 @@ function ItemProvider(_ref) {
146
152
  enabled: swipe,
147
153
  availableDirections: ['Left', 'Right']
148
154
  }),
149
- {
150
- ref
151
- } = _a,
155
+ ref = _a.ref,
152
156
  swipeProps = __rest(_a, ["ref"]);
153
157
  return (0, jsx_runtime_1.jsx)("div", {
154
158
  ref: containerRef,
@@ -163,8 +167,8 @@ function ItemProvider(_ref) {
163
167
  className: styles_module_scss_1.default.itemTracker,
164
168
  "data-test-id": testIds_1.TEST_IDS.trackLine,
165
169
  style: {
166
- transform: `translateX(${transform + drag.drag}px)`,
167
- transition: `transform ${transition}s ease 0s`
170
+ transform: "translateX(".concat(transform + drag.drag, "px)"),
171
+ transition: "transform ".concat(transition, "s ease 0s")
168
172
  },
169
173
  ref: (0, merge_refs_1.default)(ref, itemsTrackerRef),
170
174
  children: items.map((item, i) =>
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.6.13",
7
+ "version": "0.6.14-preview-eff3bc02.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -36,13 +36,13 @@
36
36
  "license": "Apache-2.0",
37
37
  "scripts": {},
38
38
  "dependencies": {
39
- "@snack-uikit/icons": "0.27.7",
40
- "@snack-uikit/pagination": "0.10.26",
39
+ "@snack-uikit/icons": "0.27.8-preview-eff3bc02.0",
40
+ "@snack-uikit/pagination": "0.10.27-preview-eff3bc02.0",
41
41
  "@snack-uikit/utils": "4.0.2",
42
42
  "classnames": "2.5.1",
43
43
  "lodash.debounce": "4.0.8",
44
44
  "merge-refs": "1.3.0",
45
45
  "uncontrollable": "8.0.4"
46
46
  },
47
- "gitHead": "dfbff14ac89d87d7a86abd70d307e92bf11906cb"
47
+ "gitHead": "2ada20a05882c3ba2fa0e5a6ef967b504cfa6c31"
48
48
  }