@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
|
@@ -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,37 +37,33 @@ 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
|
-
|
|
59
|
-
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}), secondSelected = _k[0], setSecondSelected = _k[1];
|
|
73
|
-
var _l = (0, react_1.useState)(false), isPopoverOpen = _l[0], setIsPopoverOpen = _l[1];
|
|
74
|
-
var _m = (0, react_1.useState)(1), numMonths = _m[0], setNumMonths = _m[1];
|
|
75
|
-
var openPopover = function () {
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const makeup_expander_1 = __importDefault(require("makeup-expander"));
|
|
42
|
+
const calendar_1 = __importDefault(require("../ebay-calendar/calendar"));
|
|
43
|
+
const ebay_textbox_1 = require("../ebay-textbox");
|
|
44
|
+
const date_utils_1 = require("../ebay-calendar/date-utils");
|
|
45
|
+
const textbox_1 = require("../ebay-textbox/textbox");
|
|
46
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
47
|
+
const MIN_WIDTH_FOR_DOUBLE_PANE = 600;
|
|
48
|
+
const EbayDateTextbox = (_a) => {
|
|
49
|
+
var { className, inputPlaceholderText = 'YYYY-MM-DD', a11yOpenPopoverText = 'open calendar', range, value: controlledValue, rangeEnd: controlledRangeEnd, defaultValue, defaultRangeEnd, collapseOnSelect, onChange = () => { }, onInputChange = () => { }, onInputRangeEndChange = () => { } } = _a, rest = __rest(_a, ["className", "inputPlaceholderText", "a11yOpenPopoverText", "range", "value", "rangeEnd", "defaultValue", "defaultRangeEnd", "collapseOnSelect", "onChange", "onInputChange", "onInputRangeEndChange"]);
|
|
50
|
+
const expander = (0, react_1.useRef)();
|
|
51
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
52
|
+
const [internalValue, setInternalValue] = (0, react_1.useState)(defaultValue || '');
|
|
53
|
+
const [internalRangeEnd, setInternalRangeEnd] = (0, react_1.useState)(defaultRangeEnd || '');
|
|
54
|
+
const valueToRender = (0, textbox_1.isControlled)(controlledValue) ? controlledValue : internalValue;
|
|
55
|
+
const rangeEndToRender = (0, textbox_1.isControlled)(controlledRangeEnd) ? controlledRangeEnd : internalRangeEnd;
|
|
56
|
+
const [firstSelected, setFirstSelected] = (0, react_1.useState)(() => (0, date_utils_1.dateArgToISO)(valueToRender));
|
|
57
|
+
const [secondSelected, setSecondSelected] = (0, react_1.useState)(() => (0, date_utils_1.dateArgToISO)(rangeEndToRender));
|
|
58
|
+
const [isPopoverOpen, setIsPopoverOpen] = (0, react_1.useState)(false);
|
|
59
|
+
const [numMonths, setNumMonths] = (0, react_1.useState)(1);
|
|
60
|
+
const openPopover = () => {
|
|
76
61
|
setIsPopoverOpen(true);
|
|
77
62
|
};
|
|
78
|
-
|
|
63
|
+
const closePopover = () => {
|
|
79
64
|
setIsPopoverOpen(false);
|
|
80
65
|
};
|
|
81
|
-
(0, react_1.useEffect)(
|
|
66
|
+
(0, react_1.useEffect)(() => {
|
|
82
67
|
if (!containerRef.current) {
|
|
83
68
|
return;
|
|
84
69
|
}
|
|
@@ -90,20 +75,20 @@ var EbayDateTextbox = function (_a) {
|
|
|
90
75
|
});
|
|
91
76
|
containerRef.current.addEventListener('expander-expand', openPopover);
|
|
92
77
|
containerRef.current.addEventListener('expander-collapse', closePopover);
|
|
93
|
-
|
|
78
|
+
const calculateNumMonths = () => {
|
|
94
79
|
setNumMonths(document.documentElement.clientWidth < MIN_WIDTH_FOR_DOUBLE_PANE ? 1 : 2);
|
|
95
80
|
};
|
|
96
81
|
calculateNumMonths();
|
|
97
82
|
window.addEventListener('resize', calculateNumMonths);
|
|
98
|
-
return
|
|
83
|
+
return () => {
|
|
99
84
|
var _a;
|
|
100
85
|
(_a = expander.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
101
86
|
window.removeEventListener('resize', calculateNumMonths);
|
|
102
87
|
};
|
|
103
88
|
}, []);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
89
|
+
const handleInputChange = (event, index) => {
|
|
90
|
+
const date = new Date(event.target.value);
|
|
91
|
+
const iso = isNaN(date.getTime()) ? null : (0, date_utils_1.toISO)(date);
|
|
107
92
|
if (index === 0) {
|
|
108
93
|
setFirstSelected(iso);
|
|
109
94
|
setInternalValue(iso || '');
|
|
@@ -124,13 +109,12 @@ var EbayDateTextbox = function (_a) {
|
|
|
124
109
|
});
|
|
125
110
|
}
|
|
126
111
|
};
|
|
127
|
-
|
|
128
|
-
var iso = _a.iso;
|
|
112
|
+
const handlePopoverSelect = (event, { iso }) => {
|
|
129
113
|
setFirstSelected(iso);
|
|
130
114
|
setInternalValue(iso);
|
|
131
115
|
if (range) {
|
|
132
|
-
|
|
133
|
-
|
|
116
|
+
const selected = firstSelected || secondSelected;
|
|
117
|
+
const eventData = {
|
|
134
118
|
rangeStart: iso,
|
|
135
119
|
rangeEnd: selected
|
|
136
120
|
};
|
|
@@ -170,7 +154,7 @@ var EbayDateTextbox = function (_a) {
|
|
|
170
154
|
expander.current.expanded = false;
|
|
171
155
|
}
|
|
172
156
|
};
|
|
173
|
-
|
|
157
|
+
const handleInternalChange = (event, index) => {
|
|
174
158
|
if (index === 0) {
|
|
175
159
|
setInternalValue(event.target.value);
|
|
176
160
|
onInputChange(event);
|
|
@@ -180,15 +164,15 @@ var EbayDateTextbox = function (_a) {
|
|
|
180
164
|
onInputRangeEndChange(event);
|
|
181
165
|
}
|
|
182
166
|
};
|
|
183
|
-
|
|
167
|
+
const [rangeStartPlaceholder, mainPlaceholder] = Array.isArray(inputPlaceholderText)
|
|
184
168
|
? inputPlaceholderText
|
|
185
|
-
: [inputPlaceholderText, inputPlaceholderText]
|
|
169
|
+
: [inputPlaceholderText, inputPlaceholderText];
|
|
186
170
|
return (react_1.default.createElement("span", { className: (0, classnames_1.default)('date-textbox', className), ref: containerRef },
|
|
187
|
-
range && (react_1.default.createElement(ebay_textbox_1.EbayTextbox, { value: valueToRender, placeholder: rangeStartPlaceholder, onInputChange:
|
|
188
|
-
react_1.default.createElement(ebay_textbox_1.EbayTextbox, { className: "ebay-date-textbox--main", placeholder: mainPlaceholder, value: range ? rangeEndToRender : valueToRender, onInputChange:
|
|
171
|
+
range && (react_1.default.createElement(ebay_textbox_1.EbayTextbox, { value: valueToRender, placeholder: rangeStartPlaceholder, onInputChange: (event) => handleInternalChange(event, 0), onBlur: (event) => handleInputChange(event, 0) })),
|
|
172
|
+
react_1.default.createElement(ebay_textbox_1.EbayTextbox, { className: "ebay-date-textbox--main", placeholder: mainPlaceholder, value: range ? rangeEndToRender : valueToRender, onInputChange: (event) => handleInternalChange(event, range ? 1 : 0), onBlur: (event) => handleInputChange(event, range ? 1 : 0) },
|
|
189
173
|
react_1.default.createElement(ebay_textbox_1.EbayTextboxPostfixIcon, { name: "calendar24", buttonAriaLabel: a11yOpenPopoverText })),
|
|
190
174
|
react_1.default.createElement("div", { hidden: !isPopoverOpen, className: "date-textbox__popover" },
|
|
191
|
-
react_1.default.createElement(calendar_1.default,
|
|
175
|
+
react_1.default.createElement(calendar_1.default, Object.assign({}, rest, { range: range, interactive: true, navigable: true, numMonths: numMonths, selected: firstSelected && secondSelected
|
|
192
176
|
? [firstSelected, secondSelected]
|
|
193
177
|
: firstSelected || secondSelected || undefined, onSelect: handlePopoverSelect })))));
|
|
194
178
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../../src/ebay-dialog-base/components/animation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../../src/ebay-dialog-base/components/animation.ts"],"names":[],"mappings":"AAWA,UAAU,wBAAwB;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,MAAM,IAAI,CAAA;CAC9B;AAED,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,MAAM,CAAC;AAElD,wBAAgB,kBAAkB,CAAC,EAC/B,IAAI,EACJ,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,OAAO,EACP,eAAe,EAClB,EAAE,wBAAwB,GAAG,IAAI,CA0CjC"}
|
|
@@ -1,40 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useDialogAnimation = void 0;
|
|
4
|
-
|
|
5
|
-
function useDialogAnimation(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
(0, react_1.useLayoutEffect)(function () {
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useDialogAnimation({ open, classPrefix, transitionElement, dialogRef, dialogWindowRef, enabled, onTransitionEnd }) {
|
|
6
|
+
const firstRender = (0, react_1.useRef)(true);
|
|
7
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
9
8
|
if (!enabled) {
|
|
10
9
|
return;
|
|
11
10
|
}
|
|
12
|
-
|
|
11
|
+
let transitionElements = [dialogWindowRef, dialogRef];
|
|
13
12
|
if (transitionElement === 'window') {
|
|
14
13
|
transitionElements = [dialogWindowRef];
|
|
15
14
|
}
|
|
16
15
|
else if (transitionElement === 'root') {
|
|
17
16
|
transitionElements = [dialogRef];
|
|
18
17
|
}
|
|
19
|
-
|
|
18
|
+
let cancelCurrentAnimation;
|
|
20
19
|
if (open) {
|
|
21
20
|
cancelCurrentAnimation = showAnimation({
|
|
22
21
|
dialog: dialogRef,
|
|
23
22
|
waitFor: transitionElements,
|
|
24
|
-
classPrefix
|
|
25
|
-
onTransitionEnd
|
|
23
|
+
classPrefix,
|
|
24
|
+
onTransitionEnd
|
|
26
25
|
});
|
|
27
26
|
}
|
|
28
27
|
else if (!firstRender.current) {
|
|
29
28
|
cancelCurrentAnimation = hideAnimation({
|
|
30
29
|
dialog: dialogRef,
|
|
31
30
|
waitFor: transitionElements,
|
|
32
|
-
classPrefix
|
|
33
|
-
onTransitionEnd
|
|
31
|
+
classPrefix,
|
|
32
|
+
onTransitionEnd
|
|
34
33
|
});
|
|
35
34
|
}
|
|
36
35
|
firstRender.current = false;
|
|
37
|
-
return
|
|
36
|
+
return () => {
|
|
38
37
|
if (cancelCurrentAnimation) {
|
|
39
38
|
cancelCurrentAnimation();
|
|
40
39
|
}
|
|
@@ -42,30 +41,28 @@ function useDialogAnimation(_a) {
|
|
|
42
41
|
}, [open, enabled]);
|
|
43
42
|
}
|
|
44
43
|
exports.useDialogAnimation = useDialogAnimation;
|
|
45
|
-
function showAnimation(
|
|
46
|
-
|
|
47
|
-
return transition(dialog, waitFor, "".concat(classPrefix, "--show"), onTransitionEnd);
|
|
44
|
+
function showAnimation({ dialog, waitFor, classPrefix, onTransitionEnd }) {
|
|
45
|
+
return transition(dialog, waitFor, `${classPrefix}--show`, onTransitionEnd);
|
|
48
46
|
}
|
|
49
|
-
function hideAnimation(
|
|
50
|
-
|
|
51
|
-
return transition(dialog, waitFor, "".concat(classPrefix, "--hide"), onTransitionEnd);
|
|
47
|
+
function hideAnimation({ dialog, waitFor, classPrefix, onTransitionEnd }) {
|
|
48
|
+
return transition(dialog, waitFor, `${classPrefix}--hide`, onTransitionEnd);
|
|
52
49
|
}
|
|
53
50
|
function transition(element, waitFor, className, onTransitionEnd) {
|
|
54
51
|
if (!element.current || !className) {
|
|
55
52
|
return;
|
|
56
53
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
let ran = 0;
|
|
55
|
+
const pending = waitFor ? waitFor.length : 0;
|
|
56
|
+
const initClass = `${className}-init`;
|
|
60
57
|
element.current.classList.add(initClass);
|
|
61
|
-
return nextFrame(
|
|
58
|
+
return nextFrame(() => {
|
|
62
59
|
if (!element.current) {
|
|
63
60
|
return;
|
|
64
61
|
}
|
|
65
62
|
element.current.classList.add(className);
|
|
66
63
|
element.current.classList.remove(initClass);
|
|
67
|
-
waitFor.forEach(
|
|
68
|
-
|
|
64
|
+
waitFor.forEach((ref) => {
|
|
65
|
+
const listener = () => {
|
|
69
66
|
var _a, _b;
|
|
70
67
|
if (++ran === pending) {
|
|
71
68
|
(_a = element.current) === null || _a === void 0 ? void 0 : _a.classList.remove(className);
|
|
@@ -78,10 +75,10 @@ function transition(element, waitFor, className, onTransitionEnd) {
|
|
|
78
75
|
});
|
|
79
76
|
}
|
|
80
77
|
function nextFrame(callback) {
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
let frame;
|
|
79
|
+
let cancelFrame;
|
|
83
80
|
if (window.requestAnimationFrame) {
|
|
84
|
-
frame = window.requestAnimationFrame(
|
|
81
|
+
frame = window.requestAnimationFrame(() => {
|
|
85
82
|
frame = window.requestAnimationFrame(callback);
|
|
86
83
|
});
|
|
87
84
|
cancelFrame = window.cancelAnimationFrame;
|
|
@@ -90,7 +87,7 @@ function nextFrame(callback) {
|
|
|
90
87
|
frame = window.setTimeout(callback, 26); // 16ms to simulate RAF, 10ms to ensure called after the frame.
|
|
91
88
|
cancelFrame = window.clearTimeout;
|
|
92
89
|
}
|
|
93
|
-
return
|
|
90
|
+
return () => {
|
|
94
91
|
if (frame) {
|
|
95
92
|
cancelFrame(frame);
|
|
96
93
|
frame = undefined;
|
|
@@ -3,9 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var children = _a.children;
|
|
9
|
-
return react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
10
|
-
};
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const EbayDialogActions = ({ children }) => react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
11
8
|
exports.default = EbayDialogActions;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
type EbayDialogCloseButtonProps = {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
};
|
|
5
|
+
declare const EbayDialogCloseButton: FC<EbayDialogCloseButtonProps>;
|
|
3
6
|
export default EbayDialogCloseButton;
|
|
4
7
|
//# sourceMappingURL=dialog-close-button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-close-button.d.ts","sourceRoot":"","sources":["../../../src/ebay-dialog-base/components/dialog-close-button.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"dialog-close-button.d.ts","sourceRoot":"","sources":["../../../src/ebay-dialog-base/components/dialog-close-button.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAE5C,KAAK,0BAA0B,GAAG;IAC9B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,CAAA;AAED,QAAA,MAAM,qBAAqB,EAAE,EAAE,CAAC,0BAA0B,CAAqC,CAAA;AAE/F,eAAe,qBAAqB,CAAA"}
|
|
@@ -3,9 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var children = _a.children;
|
|
9
|
-
return react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
10
|
-
};
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const EbayDialogCloseButton = ({ children }) => react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
11
8
|
exports.default = EbayDialogCloseButton;
|
|
@@ -3,9 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var children = _a.children;
|
|
9
|
-
return react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
10
|
-
};
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const EbayDialogFooter = ({ children }) => react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
11
8
|
exports.default = EbayDialogFooter;
|
|
@@ -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,9 +14,9 @@ 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
|
-
var children = _a
|
|
31
|
-
return react_1.default.createElement("h2",
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const EbayDialogHeader = (_a) => {
|
|
19
|
+
var { children } = _a, rest = __rest(_a, ["children"]);
|
|
20
|
+
return react_1.default.createElement("h2", Object.assign({}, rest), children);
|
|
32
21
|
};
|
|
33
22
|
exports.default = EbayDialogHeader;
|
|
@@ -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,11 +14,11 @@ 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
|
-
var
|
|
33
|
-
return (react_1.default.createElement(ebay_icon_button_1.EbayIconButton,
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
19
|
+
const ebay_icon_button_1 = require("../../ebay-icon-button");
|
|
20
|
+
const EbayDialogPreviousButton = (_a) => {
|
|
21
|
+
var { className, icon } = _a, rest = __rest(_a, ["className", "icon"]);
|
|
22
|
+
return (react_1.default.createElement(ebay_icon_button_1.EbayIconButton, Object.assign({}, rest, { icon: icon || 'chevronLeft16', className: (0, classnames_1.default)(className, 'lightbox-dialog__prev') })));
|
|
34
23
|
};
|
|
35
24
|
exports.default = EbayDialogPreviousButton;
|
|
@@ -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);
|
|
@@ -49,26 +38,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
49
38
|
};
|
|
50
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
40
|
exports.DialogBase = void 0;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
41
|
+
const react_1 = __importStar(require("react"));
|
|
42
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
43
|
+
const screenreaderTrap = __importStar(require("makeup-screenreader-trap"));
|
|
44
|
+
const keyboardTrap = __importStar(require("makeup-keyboard-trap"));
|
|
45
|
+
const ebay_icon_1 = require("../../ebay-icon");
|
|
46
|
+
const random_id_1 = require("../../common/random-id");
|
|
47
|
+
const animation_1 = require("./animation");
|
|
48
|
+
const DialogBase = (_a) => {
|
|
60
49
|
var _b;
|
|
61
|
-
var
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
(0, react_1.useEffect)(
|
|
50
|
+
var { baseEl: Container = 'div', classPrefix = 'drawer-dialog', windowClass, windowType, mainId, top, header, buttonPosition = 'right', children, ariaLabelledby, a11yCloseText, onCloseBtnClick = () => { }, footer, actions, onScroll, open = false, onOpen = () => { }, onBackgroundClick = () => { }, ignoreEscape, closeButton, previousButton, isModal, role = 'dialog', focus, transitionElement, animated, closeButtonClass } = _a, props = __rest(_a, ["baseEl", "classPrefix", "windowClass", "windowType", "mainId", "top", "header", "buttonPosition", "children", "ariaLabelledby", "a11yCloseText", "onCloseBtnClick", "footer", "actions", "onScroll", "open", "onOpen", "onBackgroundClick", "ignoreEscape", "closeButton", "previousButton", "isModal", "role", "focus", "transitionElement", "animated", "closeButtonClass"]);
|
|
51
|
+
const dialogRef = (0, react_1.useRef)(null);
|
|
52
|
+
const drawerBaseEl = (0, react_1.useRef)(null);
|
|
53
|
+
const closeButtonRef = (0, react_1.useRef)(null);
|
|
54
|
+
const [rId, setRandomId] = (0, react_1.useState)('');
|
|
55
|
+
(0, react_1.useEffect)(() => {
|
|
67
56
|
setRandomId((0, random_id_1.randomId)());
|
|
68
57
|
}, []);
|
|
69
|
-
(0, react_1.useEffect)(
|
|
70
|
-
|
|
71
|
-
|
|
58
|
+
(0, react_1.useEffect)(() => {
|
|
59
|
+
let timeout;
|
|
60
|
+
const handleBackgroundClick = (e) => {
|
|
72
61
|
if (drawerBaseEl.current && !drawerBaseEl.current.contains(e.target)) {
|
|
73
62
|
onBackgroundClick(e);
|
|
74
63
|
}
|
|
@@ -78,16 +67,16 @@ var DialogBase = function (_a) {
|
|
|
78
67
|
// causing the event listener to be attached to the document at the same time that the dialog
|
|
79
68
|
// opens. Adding a timeout so the event is attached after the click event that opened the modal
|
|
80
69
|
// is finished.
|
|
81
|
-
timeout = window.setTimeout(
|
|
70
|
+
timeout = window.setTimeout(() => {
|
|
82
71
|
document.addEventListener('click', handleBackgroundClick, false);
|
|
83
72
|
});
|
|
84
73
|
}
|
|
85
|
-
return
|
|
74
|
+
return () => {
|
|
86
75
|
clearTimeout(timeout);
|
|
87
76
|
document.removeEventListener('click', handleBackgroundClick, false);
|
|
88
77
|
};
|
|
89
78
|
}, [onBackgroundClick, open]);
|
|
90
|
-
(0, react_1.useEffect)(
|
|
79
|
+
(0, react_1.useEffect)(() => {
|
|
91
80
|
if (open && isModal) {
|
|
92
81
|
screenreaderTrap.trap(drawerBaseEl.current);
|
|
93
82
|
keyboardTrap.trap(drawerBaseEl.current);
|
|
@@ -96,27 +85,27 @@ var DialogBase = function (_a) {
|
|
|
96
85
|
screenreaderTrap.untrap();
|
|
97
86
|
keyboardTrap.untrap();
|
|
98
87
|
}
|
|
99
|
-
return
|
|
88
|
+
return () => {
|
|
100
89
|
screenreaderTrap.untrap();
|
|
101
90
|
keyboardTrap.untrap();
|
|
102
91
|
};
|
|
103
92
|
}, [open, isModal]);
|
|
104
93
|
(0, animation_1.useDialogAnimation)({
|
|
105
|
-
open
|
|
106
|
-
classPrefix
|
|
107
|
-
transitionElement
|
|
108
|
-
dialogRef
|
|
94
|
+
open,
|
|
95
|
+
classPrefix,
|
|
96
|
+
transitionElement,
|
|
97
|
+
dialogRef,
|
|
109
98
|
dialogWindowRef: drawerBaseEl,
|
|
110
99
|
enabled: animated,
|
|
111
|
-
onTransitionEnd:
|
|
100
|
+
onTransitionEnd: () => handleFocus(open)
|
|
112
101
|
});
|
|
113
|
-
|
|
102
|
+
const onKeyDown = (event) => {
|
|
114
103
|
if (!ignoreEscape && event.key === 'Escape') {
|
|
115
104
|
event.stopPropagation();
|
|
116
105
|
onCloseBtnClick(event);
|
|
117
106
|
}
|
|
118
107
|
};
|
|
119
|
-
(0, react_1.useEffect)(
|
|
108
|
+
(0, react_1.useEffect)(() => {
|
|
120
109
|
// For animated dialogs we handle the focus on transitionEnd event
|
|
121
110
|
if (!animated) {
|
|
122
111
|
handleFocus(open);
|
|
@@ -135,27 +124,27 @@ var DialogBase = function (_a) {
|
|
|
135
124
|
(_b = closeButtonRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
136
125
|
}
|
|
137
126
|
document.addEventListener('keydown', onKeyDown, false);
|
|
138
|
-
return
|
|
127
|
+
return () => document.removeEventListener('keydown', onKeyDown, false);
|
|
139
128
|
}
|
|
140
129
|
}
|
|
141
|
-
|
|
142
|
-
'icon-btn--transparent': classPrefix ===
|
|
130
|
+
const closeButtonContent = buttonPosition !== 'hidden' && (react_1.default.createElement("button", { ref: closeButtonRef, className: (0, classnames_1.default)(`icon-btn`, closeButtonClass, `${classPrefix}__close`, {
|
|
131
|
+
'icon-btn--transparent': classPrefix === `toast-dialog`
|
|
143
132
|
}), type: "button", "aria-label": a11yCloseText, onClick: onCloseBtnClick }, closeButton || react_1.default.createElement(ebay_icon_1.EbayIcon, { name: "close16" })));
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return (react_1.default.createElement(Container,
|
|
133
|
+
const windowClassName = windowType ? `${classPrefix}__${windowType}-window` : `${classPrefix}__window`;
|
|
134
|
+
const dialogTitleId = ((_b = header === null || header === void 0 ? void 0 : header.props) === null || _b === void 0 ? void 0 : _b.id) || `dialog-title-${rId}`;
|
|
135
|
+
const dialogLabelledBy = ariaLabelledby || dialogTitleId;
|
|
136
|
+
const dialogHeader = header ? (0, react_1.cloneElement)(header, Object.assign(Object.assign({}, header.props), { id: dialogTitleId })) : null;
|
|
137
|
+
return (react_1.default.createElement(Container, Object.assign({}, props, { "aria-labelledby": dialogLabelledBy, "aria-modal": "true", role: role, hidden: !open, className: (0, classnames_1.default)(classPrefix, props.className), "aria-live": !isModal ? 'polite' : undefined, ref: dialogRef, onKeyDown: onKeyDown }),
|
|
149
138
|
react_1.default.createElement("div", { className: (0, classnames_1.default)(windowClassName, windowClass), ref: drawerBaseEl },
|
|
150
139
|
top,
|
|
151
|
-
dialogHeader && (react_1.default.createElement("div", { className:
|
|
140
|
+
dialogHeader && (react_1.default.createElement("div", { className: `${classPrefix}__header` },
|
|
152
141
|
previousButton,
|
|
153
142
|
buttonPosition === 'right' && dialogHeader,
|
|
154
143
|
buttonPosition !== 'bottom' && closeButtonContent,
|
|
155
144
|
(buttonPosition === 'left' || buttonPosition === 'hidden') && dialogHeader)),
|
|
156
|
-
react_1.default.createElement("div", { id: mainId, className:
|
|
157
|
-
actions ? (react_1.default.createElement("div", { className:
|
|
158
|
-
footer || buttonPosition === 'bottom' ? (react_1.default.createElement("div", { className:
|
|
145
|
+
react_1.default.createElement("div", { id: mainId, className: `${classPrefix}__main`, onScroll: onScroll }, children),
|
|
146
|
+
actions ? (react_1.default.createElement("div", { className: `${classPrefix}__actions` }, actions)) : null,
|
|
147
|
+
footer || buttonPosition === 'bottom' ? (react_1.default.createElement("div", { className: `${classPrefix}__footer` },
|
|
159
148
|
footer,
|
|
160
149
|
buttonPosition === 'bottom' && closeButtonContent)) : null)));
|
|
161
150
|
};
|