@ebay/ui-core-react 6.2.1 → 6.3.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/common/component-utils/array.polyfill.flat.js +11 -13
- package/common/component-utils/forwardRef.js +4 -17
- package/common/component-utils/usePrevious.js +3 -3
- package/common/component-utils/utils.js +13 -26
- package/common/debounce.js +3 -7
- package/common/event-utils/index.js +8 -11
- package/common/event-utils/use-key-press.js +10 -12
- package/common/event-utils/use-roving-index.js +13 -24
- package/common/floating-label-utils/hooks.js +43 -53
- package/common/notice-utils/notice-content.js +5 -6
- package/common/notice-utils/notice-cta.js +5 -16
- package/common/notice-utils/notice-footer.js +5 -16
- package/common/notice-utils/notice-title.js +6 -17
- package/common/random-id.js +1 -1
- package/common/range.js +1 -4
- package/common/tooltip-utils/tooltip-close-button.js +1 -1
- package/common/tooltip-utils/tooltip-content.js +16 -28
- package/common/tooltip-utils/tooltip-footer.js +3 -6
- package/common/tooltip-utils/tooltip-host.js +5 -16
- package/common/tooltip-utils/tooltip.d.ts +1 -1
- package/common/tooltip-utils/tooltip.js +14 -26
- package/common/tooltip-utils/use-tooltip.js +8 -9
- package/ebay-alert-dialog/alert-dialog.js +11 -22
- package/ebay-badge/badge.js +6 -17
- package/ebay-breadcrumbs/breadcrumb-item.js +7 -18
- package/ebay-breadcrumbs/breadcrumbs.js +19 -30
- package/ebay-button/button-cell.js +5 -16
- package/ebay-button/button-expand.d.ts +4 -2
- package/ebay-button/button-expand.d.ts.map +1 -1
- package/ebay-button/button-expand.js +7 -10
- package/ebay-button/button-loading.js +5 -5
- package/ebay-button/button-text.js +3 -6
- package/ebay-button/button.d.ts +1 -1
- package/ebay-button/button.js +31 -43
- package/ebay-calendar/calendar.js +94 -111
- package/ebay-calendar/date-utils.js +9 -18
- package/ebay-carousel/carousel-control-button.js +9 -10
- package/ebay-carousel/carousel-item.d.ts +1 -1
- package/ebay-carousel/carousel-item.js +14 -25
- package/ebay-carousel/carousel-list.js +21 -22
- package/ebay-carousel/carousel.js +32 -44
- package/ebay-carousel/helpers.js +35 -47
- package/ebay-carousel/scroll-to-transition.js +15 -15
- package/ebay-checkbox/checkbox.js +21 -32
- package/ebay-confirm-dialog/confirm-dialog.js +11 -22
- package/ebay-cta-button/cta-button.d.ts +1 -1
- package/ebay-cta-button/cta-button.js +9 -20
- package/ebay-date-textbox/date-textbox.js +37 -53
- package/ebay-dialog-base/components/animation.d.ts +0 -1
- package/ebay-dialog-base/components/animation.d.ts.map +1 -1
- package/ebay-dialog-base/components/animation.js +25 -28
- package/ebay-dialog-base/components/dialog-actions.js +2 -5
- package/ebay-dialog-base/components/dialog-close-button.d.ts +5 -2
- package/ebay-dialog-base/components/dialog-close-button.d.ts.map +1 -1
- package/ebay-dialog-base/components/dialog-close-button.js +2 -5
- package/ebay-dialog-base/components/dialog-footer.js +2 -5
- package/ebay-dialog-base/components/dialog-header.js +4 -15
- package/ebay-dialog-base/components/dialog-previous-button.js +6 -17
- package/ebay-dialog-base/components/dialogBase.js +40 -51
- package/ebay-dialog-base/dialog-base-with-state.js +22 -35
- package/ebay-drawer-dialog/components/drawer.js +27 -50
- package/ebay-eek/eek-rating.js +8 -10
- package/ebay-eek/eek-util.d.ts +1 -1
- package/ebay-eek/eek-util.d.ts.map +1 -1
- package/ebay-eek/eek-util.js +7 -6
- package/ebay-fake-menu/menu-item-separator.js +5 -16
- package/ebay-fake-menu/menu-item.js +15 -26
- package/ebay-fake-menu/menu.js +11 -22
- package/ebay-fake-menu-button/menu-button-item.js +2 -2
- package/ebay-fake-menu-button/menu-button-label.d.ts +4 -2
- package/ebay-fake-menu-button/menu-button-label.d.ts.map +1 -1
- package/ebay-fake-menu-button/menu-button-label.js +2 -5
- package/ebay-fake-menu-button/menu-button-separator.js +5 -16
- package/ebay-fake-menu-button/menu-button.js +32 -45
- package/ebay-fake-tabs/fake-tabs.js +10 -23
- package/ebay-fake-tabs/tab.js +5 -16
- package/ebay-field/description.js +7 -19
- package/ebay-field/field.js +4 -5
- package/ebay-field/label.js +7 -18
- package/ebay-fullscreen-dialog/fullscreen-dialog.js +7 -18
- package/ebay-icon/icon.d.ts +1 -1
- package/ebay-icon/icon.js +17 -29
- package/ebay-icon-button/icon-button.d.ts +1 -1
- package/ebay-icon-button/icon-button.js +15 -27
- package/ebay-infotip/ebay-infotip-content.js +2 -5
- package/ebay-infotip/ebay-infotip-heading.js +5 -16
- package/ebay-infotip/ebay-infotip-host.d.ts +2 -2
- package/ebay-infotip/ebay-infotip-host.d.ts.map +1 -1
- package/ebay-infotip/ebay-infotip-host.js +10 -24
- package/ebay-infotip/ebay-infotip.d.ts.map +1 -1
- package/ebay-infotip/ebay-infotip.js +23 -34
- package/ebay-inline-notice/inline-notice.js +15 -27
- package/ebay-lightbox-dialog/lightbox-dialog.js +9 -21
- package/ebay-listbox-button/listbox-button-option.js +7 -18
- package/ebay-listbox-button/listbox-button.d.ts.map +1 -1
- package/ebay-listbox-button/listbox-button.js +79 -100
- package/ebay-menu/menu-item-separator.js +5 -16
- package/ebay-menu/menu-item.js +12 -23
- package/ebay-menu/menu.d.ts +1 -1
- package/ebay-menu/menu.js +37 -64
- package/ebay-menu-button/README.md +1 -1
- package/ebay-menu-button/menu-button-item.js +1 -1
- package/ebay-menu-button/menu-button-label.d.ts +4 -2
- package/ebay-menu-button/menu-button-label.d.ts.map +1 -1
- package/ebay-menu-button/menu-button-label.js +2 -5
- package/ebay-menu-button/menu-button-separator.js +5 -16
- package/ebay-menu-button/menu-button.js +46 -60
- package/ebay-notice-base/components/ebay-notice-content/notice-content.js +1 -1
- package/ebay-notice-base/components/ebay-notice-title/notice-title.d.ts +5 -2
- package/ebay-notice-base/components/ebay-notice-title/notice-title.d.ts.map +1 -1
- package/ebay-notice-base/components/ebay-notice-title/notice-title.js +2 -5
- package/ebay-page-notice/page-notice-cta.js +3 -6
- package/ebay-page-notice/page-notice-footer.js +3 -6
- package/ebay-page-notice/page-notice-title.js +5 -16
- package/ebay-page-notice/page-notice.js +16 -27
- package/ebay-pagination/helpers.js +21 -24
- package/ebay-pagination/pagination-item.d.ts +1 -1
- package/ebay-pagination/pagination-item.js +16 -27
- package/ebay-pagination/pagination.js +52 -81
- package/ebay-panel-dialog/panel-dialog.js +9 -21
- package/ebay-progress-bar/progress-bar.js +5 -16
- package/ebay-progress-spinner/progress-spinner.js +7 -18
- package/ebay-progress-stepper/ebay-progress-step.js +14 -25
- package/ebay-progress-stepper/ebay-progress-stepper.js +10 -21
- package/ebay-progress-stepper/ebay-progress-title.js +2 -5
- package/ebay-radio/radio.js +18 -29
- package/ebay-section-notice/section-notice-footer.js +3 -6
- package/ebay-section-notice/section-notice-title.js +5 -16
- package/ebay-section-notice/section-notice.js +24 -39
- package/ebay-section-title/cta.js +5 -16
- package/ebay-section-title/info.js +5 -16
- package/ebay-section-title/overflow.js +5 -16
- package/ebay-section-title/section-title.js +13 -24
- package/ebay-section-title/subtitle.js +5 -16
- package/ebay-section-title/title.js +5 -16
- package/ebay-select/ebay-select-option.js +4 -15
- package/ebay-select/ebay-select.d.ts +1 -1
- package/ebay-select/ebay-select.js +34 -45
- package/ebay-signal/signal.js +6 -17
- package/ebay-snackbar-dialog/components/ebay-snackbar-dialog-action.js +5 -16
- package/ebay-snackbar-dialog/components/ebay-snackbar-dialog.js +27 -38
- package/ebay-split-button/split-button.js +10 -21
- package/ebay-star-rating/star-rating.js +8 -19
- package/ebay-star-rating-select/star-rating-select.js +20 -31
- package/ebay-svg/svg.js +3 -3
- package/ebay-switch/ebay-switch.js +10 -21
- package/ebay-tabs/tab-panel.js +5 -16
- package/ebay-tabs/tab.js +5 -16
- package/ebay-tabs/tabs.js +26 -40
- package/ebay-textbox/postfix-icon.js +7 -18
- package/ebay-textbox/prefix-icon.js +5 -16
- package/ebay-textbox/textbox.d.ts +1 -1
- package/ebay-textbox/textbox.js +42 -53
- package/ebay-toast-dialog/components/toast.js +6 -17
- package/ebay-tooltip/ebay-tooltip-content.js +1 -1
- package/ebay-tooltip/ebay-tooltip-host.js +1 -1
- package/ebay-tooltip/ebay-tooltip.js +21 -32
- package/ebay-tourtip/ebay-tourtip-content.js +1 -1
- package/ebay-tourtip/ebay-tourtip-footer.js +4 -7
- package/ebay-tourtip/ebay-tourtip-heading.js +6 -17
- package/ebay-tourtip/ebay-tourtip-host.js +1 -1
- package/ebay-tourtip/ebay-tourtip.js +22 -33
- package/ebay-video/controls.d.ts.map +1 -1
- package/ebay-video/controls.js +23 -46
- package/ebay-video/reportButton.d.ts +7 -2
- package/ebay-video/reportButton.d.ts.map +1 -1
- package/ebay-video/reportButton.js +5 -8
- package/ebay-video/source.js +3 -14
- package/ebay-video/video.d.ts.map +1 -1
- package/ebay-video/video.js +54 -80
- package/package.json +23 -18
|
@@ -26,49 +26,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var size = react_1.Children.count(children);
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
31
|
+
const helpers_1 = require("./helpers");
|
|
32
|
+
const scroll_to_transition_1 = require("./scroll-to-transition");
|
|
33
|
+
const CarouselList = ({ gap = 16, itemsPerSlide, slideWidth, offset, activeIndex, nextControlDisabled, className, itemsRef, children, onSetActiveIndex, onScroll }) => {
|
|
34
|
+
const [translateLeft, setTranslateLeft] = (0, react_1.useState)(0);
|
|
35
|
+
const [skipScrolling, setSkipScrolling] = (0, react_1.useState)(false);
|
|
36
|
+
const [scrollTransitioning, setScrollTransitioning] = (0, react_1.useState)(false);
|
|
37
|
+
const listRef = (0, react_1.useRef)(null);
|
|
38
|
+
const scrollTimeout = (0, react_1.useRef)(null);
|
|
39
|
+
(0, react_1.useEffect)(() => {
|
|
40
|
+
const size = react_1.Children.count(children);
|
|
42
41
|
if (!size || !listRef.current)
|
|
43
42
|
return;
|
|
44
43
|
if (skipScrolling) {
|
|
45
44
|
setSkipScrolling(false);
|
|
46
45
|
return;
|
|
47
46
|
}
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const list = listRef.current;
|
|
48
|
+
const isNativeScroll = (0, helpers_1.isNativeScrolling)(list);
|
|
50
49
|
if (isNativeScroll) {
|
|
51
50
|
setScrollTransitioning(true);
|
|
52
|
-
(0, scroll_to_transition_1.scrollTransition)(list, offset,
|
|
51
|
+
(0, scroll_to_transition_1.scrollTransition)(list, offset, () => setScrollTransitioning(false));
|
|
53
52
|
}
|
|
54
53
|
else {
|
|
55
54
|
setTranslateLeft(offset);
|
|
56
55
|
}
|
|
57
56
|
}, [offset]);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const handleFinishScrolling = (0, react_1.useCallback)(() => {
|
|
58
|
+
const scrollLeft = listRef.current.scrollLeft;
|
|
59
|
+
const closest = (0, helpers_1.getClosestIndex)(scrollLeft, itemsRef.current, slideWidth, itemsPerSlide, gap);
|
|
61
60
|
if (closest !== activeIndex) {
|
|
62
61
|
setSkipScrolling(true);
|
|
63
62
|
onSetActiveIndex(closest);
|
|
64
63
|
onScroll({ index: closest });
|
|
65
64
|
}
|
|
66
65
|
}, [listRef.current, itemsRef.current, slideWidth, activeIndex, onSetActiveIndex]);
|
|
67
|
-
|
|
66
|
+
const handleScroll = () => {
|
|
68
67
|
if (scrollTimeout.current) {
|
|
69
68
|
clearTimeout(scrollTimeout.current);
|
|
70
69
|
}
|
|
71
|
-
scrollTimeout.current = setTimeout(
|
|
70
|
+
scrollTimeout.current = setTimeout(() => {
|
|
72
71
|
if (!scrollTransitioning) {
|
|
73
72
|
handleFinishScrolling();
|
|
74
73
|
}
|
|
@@ -77,6 +76,6 @@ var CarouselList = function (_a) {
|
|
|
77
76
|
return (react_1.default.createElement("div", { className: (0, classnames_1.default)('carousel__viewport', {
|
|
78
77
|
'carousel__viewport--mask': !nextControlDisabled
|
|
79
78
|
}, className) },
|
|
80
|
-
react_1.default.createElement("ul", { className: "carousel__list", ref: listRef, onScroll: handleScroll, style: { transform:
|
|
79
|
+
react_1.default.createElement("ul", { className: "carousel__list", ref: listRef, onScroll: handleScroll, style: { transform: `translate3d(${-translateLeft}px, 0, 0)` } }, (0, helpers_1.alterChildren)(children, itemsRef, itemsPerSlide, slideWidth, offset, gap))));
|
|
81
80
|
};
|
|
82
81
|
exports.default = CarouselList;
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -48,58 +37,57 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
38
|
};
|
|
50
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
42
|
+
const carousel_control_button_1 = __importDefault(require("./carousel-control-button"));
|
|
43
|
+
const carousel_list_1 = __importDefault(require("./carousel-list"));
|
|
44
|
+
const helpers_1 = require("./helpers");
|
|
45
|
+
const debounce_1 = require("../common/debounce");
|
|
57
46
|
// TO-DO:
|
|
58
47
|
// Image slides
|
|
59
48
|
// Auto play (+ onPlay/onPause callbacks)
|
|
60
|
-
|
|
61
|
-
var
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
49
|
+
const EbayCarousel = (_a) => {
|
|
50
|
+
var { gap = 16, index = 0, itemsPerSlide: _itemsPerSlide, a11yPreviousText, a11yNextText, onScroll = () => { }, onNext = () => { }, onPrevious = () => { }, onSlide = () => { }, className, children } = _a, rest = __rest(_a, ["gap", "index", "itemsPerSlide", "a11yPreviousText", "a11yNextText", "onScroll", "onNext", "onPrevious", "onSlide", "className", "children"]);
|
|
51
|
+
const [activeIndex, setActiveIndex] = (0, react_1.useState)(index);
|
|
52
|
+
const [slideWidth, setSlideWidth] = (0, react_1.useState)(0);
|
|
53
|
+
const [offset, setOffset] = (0, react_1.useState)(0);
|
|
54
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
55
|
+
const itemsRef = (0, react_1.useRef)([]);
|
|
56
|
+
const itemCount = react_1.Children.count(children);
|
|
57
|
+
const itemsPerSlide = Math.floor(_itemsPerSlide) || undefined;
|
|
58
|
+
const isSingleSlide = itemCount <= itemsPerSlide;
|
|
59
|
+
const prevControlDisabled = isSingleSlide || offset === 0;
|
|
60
|
+
const nextControlDisabled = isSingleSlide || (offset === (0, helpers_1.getMaxOffset)(itemsRef.current, slideWidth));
|
|
61
|
+
const handleResize = () => {
|
|
73
62
|
if (!containerRef.current)
|
|
74
63
|
return;
|
|
75
|
-
|
|
64
|
+
const { width: containerWidth } = containerRef.current.getBoundingClientRect();
|
|
76
65
|
setSlideWidth(containerWidth);
|
|
77
66
|
};
|
|
78
|
-
(0, react_1.useEffect)(
|
|
67
|
+
(0, react_1.useEffect)(() => {
|
|
79
68
|
window.addEventListener('resize', (0, debounce_1.debounce)(handleResize, 16));
|
|
80
|
-
return
|
|
69
|
+
return () => {
|
|
81
70
|
window.removeEventListener('resize', (0, debounce_1.debounce)(handleResize, 16));
|
|
82
71
|
};
|
|
83
72
|
}, []);
|
|
84
|
-
(0, react_1.useEffect)(
|
|
73
|
+
(0, react_1.useEffect)(() => {
|
|
85
74
|
setOffset((0, helpers_1.getOffset)(itemsRef.current, activeIndex, slideWidth));
|
|
86
75
|
}, [activeIndex, slideWidth]);
|
|
87
|
-
(0, react_1.useEffect)(
|
|
76
|
+
(0, react_1.useEffect)(() => {
|
|
88
77
|
if (index >= 0 && index <= itemCount - 1) {
|
|
89
78
|
setActiveIndex(index);
|
|
90
79
|
}
|
|
91
80
|
}, [index]);
|
|
92
|
-
(0, react_1.useEffect)(
|
|
81
|
+
(0, react_1.useEffect)(() => {
|
|
93
82
|
itemsRef.current = itemsRef.current.splice(0, itemCount);
|
|
94
83
|
}, [children]);
|
|
95
|
-
(0, react_1.useEffect)(
|
|
96
|
-
|
|
84
|
+
(0, react_1.useEffect)(() => {
|
|
85
|
+
const { width: containerWidth } = containerRef.current.getBoundingClientRect();
|
|
97
86
|
setSlideWidth(containerWidth);
|
|
98
87
|
}, [containerRef.current]);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
var slide = (0, helpers_1.getSlide)(activeIndex, itemsPerSlide, nextIndex);
|
|
88
|
+
const handleControlClick = (event, { direction }) => {
|
|
89
|
+
const nextIndex = (0, helpers_1.getNextIndex)(direction, activeIndex, itemsRef.current, slideWidth, itemsPerSlide);
|
|
90
|
+
const slide = (0, helpers_1.getSlide)(activeIndex, itemsPerSlide, nextIndex);
|
|
103
91
|
setActiveIndex(nextIndex);
|
|
104
92
|
if (direction === 'LEFT') {
|
|
105
93
|
onPrevious(event);
|
|
@@ -107,9 +95,9 @@ var EbayCarousel = function (_a) {
|
|
|
107
95
|
else {
|
|
108
96
|
onNext(event);
|
|
109
97
|
}
|
|
110
|
-
onSlide({ slide
|
|
98
|
+
onSlide({ slide });
|
|
111
99
|
};
|
|
112
|
-
return (react_1.default.createElement("div",
|
|
100
|
+
return (react_1.default.createElement("div", Object.assign({ className: (0, classnames_1.default)('carousel', className, {
|
|
113
101
|
'carousel--slides': itemsPerSlide,
|
|
114
102
|
'carousel--peek': itemsPerSlide % 1 === 0
|
|
115
103
|
}) }, rest),
|
package/ebay-carousel/helpers.js
CHANGED
|
@@ -1,66 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.getClosestIndex = exports.getNextIndex = exports.getSlide = exports.alterChildren = exports.getOffset = exports.getMaxOffset = exports.isNativeScrolling = exports.getRelativeRects = void 0;
|
|
15
|
-
|
|
4
|
+
const react_1 = require("react");
|
|
16
5
|
function getRelativeRects(el) {
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
const parent = el.parentElement;
|
|
7
|
+
const currentLeft = parent
|
|
19
8
|
? parent.firstElementChild.getBoundingClientRect().left
|
|
20
9
|
: 0;
|
|
21
|
-
|
|
10
|
+
const { left, right } = el.getBoundingClientRect();
|
|
22
11
|
return {
|
|
23
12
|
left: left - currentLeft,
|
|
24
13
|
right: right - currentLeft
|
|
25
14
|
};
|
|
26
15
|
}
|
|
27
16
|
exports.getRelativeRects = getRelativeRects;
|
|
28
|
-
|
|
17
|
+
const isNativeScrolling = (el) => getComputedStyle(el).overflowX !== 'visible';
|
|
29
18
|
exports.isNativeScrolling = isNativeScrolling;
|
|
30
|
-
|
|
19
|
+
const getMaxOffset = (items, slideWidth) => {
|
|
31
20
|
if (!items.length) {
|
|
32
21
|
return 0;
|
|
33
22
|
}
|
|
34
|
-
|
|
23
|
+
const lastEl = items[items.length - 1];
|
|
35
24
|
return Math.max(lastEl.right - slideWidth, 0) || 0;
|
|
36
25
|
};
|
|
37
26
|
exports.getMaxOffset = getMaxOffset;
|
|
38
|
-
|
|
27
|
+
const getOffset = (items, index, slideWidth) => {
|
|
39
28
|
if (!items.length) {
|
|
40
29
|
return 0;
|
|
41
30
|
}
|
|
42
31
|
return Math.min(items[index].left, (0, exports.getMaxOffset)(items, slideWidth)) || 0;
|
|
43
32
|
};
|
|
44
33
|
exports.getOffset = getOffset;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
const alterChildren = (children, itemsRef, itemsPerSlide, slideWidth, offset, gap) => react_1.Children.map(children, (item, index) => {
|
|
35
|
+
const { style = {} } = item.props;
|
|
36
|
+
let itemWidth;
|
|
48
37
|
if (itemsPerSlide) {
|
|
49
|
-
|
|
50
|
-
itemWidth =
|
|
38
|
+
const itemsInSlide = itemsPerSlide + (itemsPerSlide % 1);
|
|
39
|
+
itemWidth = `calc(${100 / itemsInSlide}% - ${((itemsInSlide - 1) * gap) / itemsInSlide}px)`;
|
|
51
40
|
}
|
|
52
|
-
|
|
53
|
-
return (0, react_1.cloneElement)(item,
|
|
41
|
+
const isStartOfSlide = itemsPerSlide ? index % itemsPerSlide === 0 : true;
|
|
42
|
+
return (0, react_1.cloneElement)(item, Object.assign(Object.assign({}, item.props), { slideWidth,
|
|
43
|
+
offset, ref: el => {
|
|
54
44
|
itemsRef.current[index] = el;
|
|
55
|
-
}, className: isStartOfSlide ? 'carousel__snap-point' : item.props.className, style:
|
|
56
|
-
});
|
|
45
|
+
}, className: isStartOfSlide ? 'carousel__snap-point' : item.props.className, style: Object.assign(Object.assign({}, style), { width: itemWidth || style.width, marginRight: gap && index !== react_1.Children.count(children) - 1 ? `${gap}px` : style.marginRight }) }));
|
|
46
|
+
});
|
|
57
47
|
exports.alterChildren = alterChildren;
|
|
58
48
|
/**
|
|
59
49
|
* Ensures that an index is valid.
|
|
60
50
|
*/
|
|
61
|
-
|
|
51
|
+
const normalizeIndex = (index, items, itemsPerSlide) => {
|
|
62
52
|
if (index > 0) {
|
|
63
|
-
|
|
53
|
+
let result = index;
|
|
64
54
|
result %= items.length || 1; // Ensure index is within bounds.
|
|
65
55
|
result -= result % (itemsPerSlide || 1); // Round index to the nearest valid slide index.
|
|
66
56
|
result = Math.abs(result); // Ensure positive value.
|
|
@@ -72,18 +62,17 @@ var normalizeIndex = function (index, items, itemsPerSlide) {
|
|
|
72
62
|
* Gets the slide for a given index.
|
|
73
63
|
* Defaults to the current index if none provided.
|
|
74
64
|
*/
|
|
75
|
-
|
|
76
|
-
if (nextIndex === void 0) { nextIndex = activeIndex; }
|
|
65
|
+
const getSlide = (activeIndex, itemsPerSlide, nextIndex = activeIndex) => {
|
|
77
66
|
if (!itemsPerSlide) {
|
|
78
67
|
return;
|
|
79
68
|
}
|
|
80
69
|
return Math.ceil(nextIndex / itemsPerSlide);
|
|
81
70
|
};
|
|
82
71
|
exports.getSlide = getSlide;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
const getDelta = (direction) => direction === 'LEFT' ? -1 : 1;
|
|
73
|
+
const getNextIndex = (direction, activeIndex, items, slideWidth, itemsPerSlide) => {
|
|
74
|
+
let i = activeIndex;
|
|
75
|
+
let item;
|
|
87
76
|
// If going backward from 0, we go to the end.
|
|
88
77
|
if (direction === 'LEFT' && i === 0) {
|
|
89
78
|
i = items.length - 1;
|
|
@@ -91,12 +80,12 @@ var getNextIndex = function (direction, activeIndex, items, slideWidth, itemsPer
|
|
|
91
80
|
else {
|
|
92
81
|
// Find the index of the next item that is not fully in view.
|
|
93
82
|
do {
|
|
94
|
-
|
|
83
|
+
const delta = getDelta(direction);
|
|
95
84
|
item = items[i += delta];
|
|
96
85
|
} while (item && item.fullyVisible);
|
|
97
86
|
if (direction === 'LEFT' && !itemsPerSlide) {
|
|
98
87
|
// If going left without items per slide, go as far left as possible while keeping this item fully in view.
|
|
99
|
-
|
|
88
|
+
const targetOffset = item.right - slideWidth;
|
|
100
89
|
do {
|
|
101
90
|
item = items[--i];
|
|
102
91
|
} while (item && item.left >= targetOffset);
|
|
@@ -106,19 +95,18 @@ var getNextIndex = function (direction, activeIndex, items, slideWidth, itemsPer
|
|
|
106
95
|
return normalizeIndex(i, items, itemsPerSlide);
|
|
107
96
|
};
|
|
108
97
|
exports.getNextIndex = getNextIndex;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
var closest;
|
|
98
|
+
const getClosestIndex = (scrollLeft, items, slideWidth, itemsPerSlide = 1, gap) => {
|
|
99
|
+
let closest;
|
|
112
100
|
if (scrollLeft >= (0, exports.getMaxOffset)(items, slideWidth) - gap) {
|
|
113
101
|
closest = items.length - 1;
|
|
114
102
|
}
|
|
115
103
|
else {
|
|
116
104
|
// Find the closest item using a binary search on each carousel slide.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
105
|
+
const totalItems = items.length;
|
|
106
|
+
let low = 0;
|
|
107
|
+
let high = Math.ceil(totalItems / itemsPerSlide) - 1;
|
|
120
108
|
while (high - low > 1) {
|
|
121
|
-
|
|
109
|
+
const mid = Math.floor((low + high) / 2);
|
|
122
110
|
if (scrollLeft > items[mid * itemsPerSlide].left) {
|
|
123
111
|
low = mid;
|
|
124
112
|
}
|
|
@@ -126,8 +114,8 @@ var getClosestIndex = function (scrollLeft, items, slideWidth, itemsPerSlide, ga
|
|
|
126
114
|
high = mid;
|
|
127
115
|
}
|
|
128
116
|
}
|
|
129
|
-
|
|
130
|
-
|
|
117
|
+
const deltaLow = Math.abs(scrollLeft - items[low * itemsPerSlide].left);
|
|
118
|
+
const deltaHigh = Math.abs(scrollLeft - items[high * itemsPerSlide].left);
|
|
131
119
|
closest = normalizeIndex((deltaLow > deltaHigh ? high : low) * itemsPerSlide, items, itemsPerSlide);
|
|
132
120
|
}
|
|
133
121
|
return closest;
|
|
@@ -3,27 +3,27 @@
|
|
|
3
3
|
// todo: replace with ebayui-core-react/ebay-carousel when it's ready
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.scrollTransition = void 0;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const onScrollEnd = (el, fn) => {
|
|
7
|
+
let timeout;
|
|
8
|
+
let frame;
|
|
9
|
+
let lastPos;
|
|
10
10
|
(function checkMoved() {
|
|
11
|
-
|
|
11
|
+
const { scrollLeft } = el;
|
|
12
12
|
if (lastPos !== scrollLeft) {
|
|
13
13
|
lastPos = scrollLeft;
|
|
14
|
-
timeout = setTimeout(
|
|
14
|
+
timeout = setTimeout(() => {
|
|
15
15
|
frame = requestAnimationFrame(checkMoved);
|
|
16
16
|
}, 90);
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
fn(lastPos);
|
|
20
20
|
}());
|
|
21
|
-
return
|
|
21
|
+
return () => {
|
|
22
22
|
clearTimeout(timeout);
|
|
23
23
|
cancelAnimationFrame(frame);
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
const supportsScrollBehavior = typeof window !== 'undefined' && 'scrollBehavior' in document.body.style;
|
|
27
27
|
/**
|
|
28
28
|
* Utility to animate scroll position of an element using an `ease-out` curve over 250ms.
|
|
29
29
|
* Cancels the animation if the user touches back down.
|
|
@@ -38,14 +38,14 @@ function scrollTransition(el, to, fn) {
|
|
|
38
38
|
el.scrollTo({ left: to });
|
|
39
39
|
return onScrollEnd(el, fn);
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
let lastPosition;
|
|
42
|
+
let cancelInterruptTransition;
|
|
43
|
+
let frame = requestAnimationFrame(startTime => {
|
|
44
|
+
const { scrollLeft } = el;
|
|
45
|
+
const distance = to - scrollLeft;
|
|
46
|
+
const duration = 450;
|
|
47
47
|
(function animate(curTime) {
|
|
48
|
-
|
|
48
|
+
const delta = curTime - startTime;
|
|
49
49
|
if (delta > duration) {
|
|
50
50
|
el.scrollLeft = to;
|
|
51
51
|
cancel();
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -48,41 +37,41 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
38
|
};
|
|
50
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
42
|
+
const ebay_icon_1 = require("../ebay-icon");
|
|
43
|
+
const ebay_field_1 = require("../ebay-field");
|
|
44
|
+
const component_utils_1 = require("../common/component-utils");
|
|
45
|
+
const isControlled = checked => typeof checked !== 'undefined';
|
|
46
|
+
const EbayCheckbox = (_a) => {
|
|
47
|
+
var { id, size = 'default', className, style, checked, defaultChecked = false, onChange = () => { }, onFocus = () => { }, onKeyDown = () => { }, children, inputRef } = _a, rest = __rest(_a, ["id", "size", "className", "style", "checked", "defaultChecked", "onChange", "onFocus", "onKeyDown", "children", "inputRef"]);
|
|
48
|
+
const [isChecked, setChecked] = (0, react_1.useState)(defaultChecked);
|
|
49
|
+
const handleChange = (e) => {
|
|
50
|
+
const input = e.target;
|
|
62
51
|
onChange(e, { value: input === null || input === void 0 ? void 0 : input.value, checked: Boolean(input === null || input === void 0 ? void 0 : input.checked) });
|
|
63
52
|
setChecked(input === null || input === void 0 ? void 0 : input.checked);
|
|
64
53
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
const handleFocus = (e) => { var _a, _b; return onFocus(e, { value: (_a = e.target) === null || _a === void 0 ? void 0 : _a.value, checked: Boolean((_b = e.target) === null || _b === void 0 ? void 0 : _b.checked) }); };
|
|
55
|
+
const handleKeyDown = (e) => {
|
|
56
|
+
const input = e.target;
|
|
68
57
|
onKeyDown(e, { value: input.value, checked: Boolean(input.checked) });
|
|
69
58
|
};
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
const containerClass = (0, classnames_1.default)('checkbox', className, { 'checkbox--large': size === 'large' });
|
|
60
|
+
const iconChecked = size === 'large' ?
|
|
72
61
|
react_1.default.createElement(ebay_icon_1.EbayIcon, { name: "checkboxChecked24", className: "checkbox__checked" }) :
|
|
73
62
|
react_1.default.createElement(ebay_icon_1.EbayIcon, { name: "checkboxChecked18", className: "checkbox__checked" });
|
|
74
|
-
|
|
63
|
+
const iconUnChecked = size === 'large' ?
|
|
75
64
|
react_1.default.createElement(ebay_icon_1.EbayIcon, { name: "checkboxUnchecked24", className: "checkbox__unchecked" }) :
|
|
76
65
|
react_1.default.createElement(ebay_icon_1.EbayIcon, { name: "checkboxUnchecked18", className: "checkbox__unchecked" });
|
|
77
|
-
|
|
66
|
+
const ebayLabel = (0, component_utils_1.findComponent)(children, ebay_field_1.EbayLabel);
|
|
78
67
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
79
|
-
react_1.default.createElement("span", { className: containerClass, style:
|
|
80
|
-
react_1.default.createElement("input",
|
|
68
|
+
react_1.default.createElement("span", { className: containerClass, style: Object.assign(Object.assign({}, style), { alignItems: 'center' }) },
|
|
69
|
+
react_1.default.createElement("input", Object.assign({}, rest, { id: id, className: "checkbox__control", type: "checkbox", checked: isControlled(checked) ? checked : isChecked, onChange: handleChange, onFocus: handleFocus, onKeyDown: handleKeyDown, ref: inputRef })),
|
|
81
70
|
react_1.default.createElement("span", { className: "checkbox__icon", hidden: true },
|
|
82
71
|
iconChecked,
|
|
83
72
|
iconUnChecked)),
|
|
84
73
|
ebayLabel ?
|
|
85
|
-
(0, react_1.cloneElement)(ebayLabel,
|
|
74
|
+
(0, react_1.cloneElement)(ebayLabel, Object.assign(Object.assign({}, ebayLabel.props), { position: 'end', htmlFor: id })) :
|
|
86
75
|
children));
|
|
87
76
|
};
|
|
88
77
|
exports.default = EbayCheckbox;
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -48,17 +37,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
38
|
};
|
|
50
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return (react_1.default.createElement(ebay_dialog_base_1.DialogBaseWithState,
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
42
|
+
const ebay_dialog_base_1 = require("../ebay-dialog-base");
|
|
43
|
+
const ebay_button_1 = require("../ebay-button");
|
|
44
|
+
const classPrefix = 'confirm-dialog';
|
|
45
|
+
const EbayConfirmDialog = (_a) => {
|
|
46
|
+
var { a11yCloseText = 'Close Dialog', confirmText, rejectText, onReject = () => { }, onConfirm = () => { } } = _a, rest = __rest(_a, ["a11yCloseText", "confirmText", "rejectText", "onReject", "onConfirm"]);
|
|
47
|
+
const confirmBtnRef = (0, react_1.useRef)(null);
|
|
48
|
+
const confirmId = 'confirm-dialog-confirm';
|
|
49
|
+
const mainId = 'confirm-dialog-main';
|
|
50
|
+
return (react_1.default.createElement(ebay_dialog_base_1.DialogBaseWithState, Object.assign({ focus: confirmBtnRef }, rest, { a11yCloseText: a11yCloseText, role: "dialog", mainId: mainId, classPrefix: classPrefix, className: (0, classnames_1.default)(rest.className, `${classPrefix}--mask-fade`), windowClass: `${classPrefix}__window ${classPrefix}__window--fade`, buttonPosition: "hidden", onCloseBtnClick: onReject }),
|
|
62
51
|
rest.children,
|
|
63
52
|
react_1.default.createElement(ebay_dialog_base_1.EbayDialogFooter, null,
|
|
64
53
|
react_1.default.createElement(ebay_button_1.EbayButton, { onClick: onReject, className: "confirm-dialog__reject" }, rejectText),
|
|
@@ -7,6 +7,6 @@ type Props = HTMLAnchorProps & {
|
|
|
7
7
|
size?: Size;
|
|
8
8
|
forwardedRef?: RefObject<HTMLAnchorElement>;
|
|
9
9
|
};
|
|
10
|
-
declare const _default: React.ForwardRefExoticComponent<
|
|
10
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<React.FC<Props>>>;
|
|
11
11
|
export default _default;
|
|
12
12
|
//# sourceMappingURL=cta-button.d.ts.map
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
3
|
var t = {};
|
|
15
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -25,15 +14,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
15
|
};
|
|
27
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
return (react_1.default.createElement("a",
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
19
|
+
const forwardRef_1 = require("../common/component-utils/forwardRef");
|
|
20
|
+
const ebay_icon_1 = require("../ebay-icon");
|
|
21
|
+
const ebay_button_1 = require("../ebay-button");
|
|
22
|
+
const EbayCtaButton = (_a) => {
|
|
23
|
+
var { size, children, fluid, truncate, forwardedRef, className: extraClasses } = _a, rest = __rest(_a, ["size", "children", "fluid", "truncate", "forwardedRef", "className"]);
|
|
24
|
+
const className = (0, classnames_1.default)(extraClasses, 'cta-btn', { 'cta-btn--large': size === 'large' }, { 'cta-btn--fluid': fluid }, { 'cta-btn--truncated': truncate });
|
|
25
|
+
return (react_1.default.createElement("a", Object.assign({}, rest, { className: className, ref: forwardedRef }),
|
|
37
26
|
react_1.default.createElement(ebay_button_1.EbayButtonCell, { type: "cta" },
|
|
38
27
|
react_1.default.createElement("span", null, children),
|
|
39
28
|
react_1.default.createElement(ebay_icon_1.EbayIcon, { name: "arrowRight24" }))));
|