@ebay/ui-core-react 7.4.0-alpha.6 → 7.4.0-alpha.8
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/array.polyfill.flat-DyxysTxZ.js +21 -0
- package/badge-CR5t7-2L.js +8 -0
- package/button-B4bZIgwB.js +83 -0
- package/calendar-D-DWjrMU.js +333 -0
- package/common/component-utils/forwardRef/index.js +10 -1
- package/common/component-utils/index.js +9 -1
- package/common/component-utils/utils/index.js +25 -1
- package/common/event-utils/index.js +113 -1
- package/common/floating-label-utils/hooks/index.js +106 -1
- package/common/notice-utils/notice-cta/index.js +5 -1
- package/common/random-id/index.js +13 -1
- package/common/tooltip-utils/constants/index.js +97 -1
- package/common/tooltip-utils/index.js +11 -1
- package/debounce-v8bWAUnY.js +9 -0
- package/dialog-previous-button-EC_Y6KaT.js +370 -0
- package/drawer-DBDktEBZ.js +69 -0
- package/ebay-alert-dialog/index.js +26 -1
- package/ebay-badge/index.js +4 -1
- package/ebay-breadcrumbs/index.js +47 -1
- package/ebay-button/index.js +5 -1
- package/ebay-calendar/index.js +4 -1
- package/ebay-carousel/index.js +345 -1
- package/ebay-checkbox/index.js +52 -1
- package/ebay-confirm-dialog/index.js +28 -1
- package/ebay-cta-button/index.js +22 -1
- package/ebay-date-textbox/index.js +140 -1
- package/ebay-dialog-base/components/animation/index.js +92 -1
- package/ebay-dialog-base/components/dialog-footer/index.js +4 -1
- package/ebay-dialog-base/components/dialog-header/index.js +4 -1
- package/ebay-dialog-base/index.js +13 -1
- package/ebay-drawer-dialog/index.js +4 -1
- package/ebay-eek/index.js +54 -1
- package/ebay-fake-menu/index.js +10 -1
- package/ebay-fake-menu/menu-item/index.js +49 -1
- package/ebay-fake-menu-button/index.js +7 -1
- package/ebay-fake-menu-button/menu-button/index.js +12 -1
- package/ebay-fake-tabs/index.js +30 -1
- package/ebay-field/index.js +21 -1
- package/ebay-fullscreen-dialog/index.js +10 -1
- package/ebay-icon/index.js +4 -1
- package/ebay-icon-button/index.js +4 -1
- package/ebay-infotip/index.js +76 -1
- package/ebay-inline-notice/index.js +36 -1
- package/ebay-lightbox-dialog/index.js +12 -1
- package/ebay-listbox/index.js +6 -1
- package/ebay-listbox/listbox.d.ts.map +1 -1
- package/ebay-listbox-button/index.js +151 -1
- package/ebay-menu/index.js +9 -1
- package/ebay-menu-button/index.js +113 -1
- package/ebay-notice-base/index.js +7 -1
- package/ebay-page-notice/index.js +50 -1
- package/ebay-pagination/index.js +244 -1
- package/ebay-panel-dialog/index.js +12 -1
- package/ebay-progress-bar/index.js +6 -1
- package/ebay-progress-spinner/index.js +4 -1
- package/ebay-progress-stepper/index.js +72 -1
- package/ebay-radio/index.js +4 -1
- package/ebay-radio/radio/index.js +48 -1
- package/ebay-section-notice/index.js +69 -1
- package/ebay-section-title/index.js +38 -1
- package/ebay-segmented-buttons/index.js +46 -1
- package/ebay-select/index.js +98 -1
- package/ebay-signal/index.js +9 -1
- package/ebay-snackbar-dialog/index.js +81 -1
- package/ebay-split-button/index.js +22 -1
- package/ebay-star-rating/index.js +9 -1
- package/ebay-star-rating-select/index.js +55 -1
- package/ebay-svg/index.js +5189 -1
- package/ebay-switch/index.js +27 -1
- package/ebay-tabs/index.js +88 -1
- package/ebay-textbox/index.js +10 -1
- package/ebay-toast-dialog/index.js +9 -1
- package/ebay-tooltip/index.js +64 -1
- package/ebay-tourtip/index.js +54 -1
- package/ebay-video/index.js +229 -1
- package/events/index.js +18 -1
- package/icon-B17Di3YL.js +56 -0
- package/icon-button-BQWoMgX1.js +31 -0
- package/index-BXizW4ue.js +89 -0
- package/index-DcH7Tjjd.js +272 -0
- package/label-C0AS4fnO.js +19 -0
- package/listbox-DGbY99kq.js +674 -0
- package/menu-Bsy48CE1.js +163 -0
- package/menu-button-CKGsgg6G.js +89 -0
- package/menu-fCOy6wBS.js +29 -0
- package/notice-content-BTXVxttv.js +8 -0
- package/notice-content-BhUeK1pd.js +3 -0
- package/notice-footer-CIQ8SM6N.js +10 -0
- package/package.json +1 -1
- package/progress-spinner-DOFKRtuu.js +20 -0
- package/range-C5qzyhg4.js +3 -0
- package/textbox-J291yCpJ.js +136 -0
- package/use-roving-index-CEM_UsCH.js +58 -0
- package/use-tooltip-7JxcZHJn.js +92 -0
- package/utils/index.js +13 -1
- package/array.polyfill.flat-5BAolFdk.js +0 -1
- package/badge-CoHKfiPt.js +0 -1
- package/button-DGuEBUDJ.js +0 -1
- package/calendar-lAu6VfAb.js +0 -1
- package/debounce-BQsYxxOL.js +0 -1
- package/dialog-previous-button-5cTKpmJ-.js +0 -1
- package/drawer-xTtCoO3F.js +0 -1
- package/icon-TuxfQndO.js +0 -1
- package/icon-button-Cwaj-eT9.js +0 -1
- package/index-D3xZmuzJ.js +0 -1
- package/index-Dkz0UnlJ.js +0 -1
- package/label-CnrpYJ-g.js +0 -1
- package/listbox-Ck3BxDm4.js +0 -1
- package/menu-CV-INYLM.js +0 -1
- package/menu-_LzP6yje.js +0 -1
- package/menu-button-BZ66jxvI.js +0 -1
- package/notice-content-9iF4T8uB.js +0 -1
- package/notice-content-C0ZStfuX.js +0 -1
- package/notice-footer-Cw1DMzoB.js +0 -1
- package/progress-spinner-U2qOANON.js +0 -1
- package/range-DOsPN0h5.js +0 -1
- package/textbox-dUhinDwj.js +0 -1
- package/use-roving-index-DoAVBgsp.js +0 -1
- package/use-tooltip-CL3_zAeg.js +0 -1
|
@@ -1 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const classNames = require("classnames");
|
|
5
|
+
const dialogPreviousButton = require("../dialog-previous-button-EC_Y6KaT.js");
|
|
6
|
+
require("../icon-button-BQWoMgX1.js");
|
|
7
|
+
const classPrefix = "lightbox-dialog";
|
|
8
|
+
const EbayLightboxDialog = ({ open, mode, size, onClose = () => {
|
|
9
|
+
}, ...rest }) => React.createElement(dialogPreviousButton.DialogBaseWithState, { buttonPosition: "right", ...rest, classPrefix, onCloseBtnClick: onClose, onBackgroundClick: onClose, className: classNames(rest.className, `${classPrefix}--mask-fade`, size && `${classPrefix}--${size}`), windowClass: classNames("lightbox-dialog__window--fade", {
|
|
10
|
+
[`${classPrefix}__window--mini`]: mode === "mini"
|
|
11
|
+
}), open });
|
|
12
|
+
exports.EbayLightboxDialog = EbayLightboxDialog;
|
package/ebay-listbox/index.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const listbox = require("../listbox-DGbY99kq.js");
|
|
4
|
+
exports.EbayListbox = listbox.EbayListbox;
|
|
5
|
+
exports.EbayListboxOption = listbox.EbayListboxOption;
|
|
6
|
+
exports.EbayListboxOptionDescription = listbox.EbayListboxOptionDescription;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listbox.d.ts","sourceRoot":"","sources":["../../src/ebay-listbox/listbox.tsx"],"names":[],"mappings":"AAAA,OAAc,EAA6B,EAAE,EAA4B,MAAM,OAAO,CAAA;AAItF,OAAO,EAAE,cAAc,EAAE,SAAS,EAAoB,MAAM,OAAO,CAAA;AAInE,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAIlD,MAAM,MAAM,gBAAgB,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACvB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAClC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,sBAAsB,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;IACrE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACxB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"listbox.d.ts","sourceRoot":"","sources":["../../src/ebay-listbox/listbox.tsx"],"names":[],"mappings":"AAAA,OAAc,EAA6B,EAAE,EAA4B,MAAM,OAAO,CAAA;AAItF,OAAO,EAAE,cAAc,EAAE,SAAS,EAAoB,MAAM,OAAO,CAAA;AAInE,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAIlD,MAAM,MAAM,gBAAgB,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACvB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAClC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,sBAAsB,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;IACrE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACxB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAuM5C,CAAA"}
|
|
@@ -1 +1,151 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const index = require("../index-DcH7Tjjd.js");
|
|
5
|
+
const classNames = require("classnames");
|
|
6
|
+
const listbox = require("../listbox-DGbY99kq.js");
|
|
7
|
+
const common_componentUtils_utils = require("../common/component-utils/utils/index.js");
|
|
8
|
+
const icon = require("../icon-B17Di3YL.js");
|
|
9
|
+
function onKeyDown(e) {
|
|
10
|
+
if (e.keyCode >= 32 && e.keyCode <= 40) {
|
|
11
|
+
e.preventDefault();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function add(el) {
|
|
15
|
+
el.addEventListener("keydown", onKeyDown);
|
|
16
|
+
}
|
|
17
|
+
function remove(el) {
|
|
18
|
+
el.removeEventListener("keydown", onKeyDown);
|
|
19
|
+
}
|
|
20
|
+
const RenderText = ({ alwaysDisplay, icon: icon2, labelId, text, unselectedText, postfixLabel }) => {
|
|
21
|
+
if (icon2) {
|
|
22
|
+
return React.createElement("span", { id: labelId, className: "btn__text" }, icon2);
|
|
23
|
+
}
|
|
24
|
+
if (text || alwaysDisplay) {
|
|
25
|
+
const displayText = text || unselectedText;
|
|
26
|
+
return React.createElement(
|
|
27
|
+
"span",
|
|
28
|
+
{ id: labelId, className: "btn__text" },
|
|
29
|
+
displayText,
|
|
30
|
+
postfixLabel && React.createElement("span", { className: "btn__postfix-label" }, postfixLabel)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
function getSelectedValueIndex({ selected, value, options }) {
|
|
35
|
+
if (selected !== void 0) {
|
|
36
|
+
return selected;
|
|
37
|
+
}
|
|
38
|
+
if (value !== void 0) {
|
|
39
|
+
return options.findIndex((option) => option.props.value === value);
|
|
40
|
+
}
|
|
41
|
+
return options.findIndex((option) => option.props.selected);
|
|
42
|
+
}
|
|
43
|
+
const EbayListboxButtonOption = listbox.EbayListboxOption;
|
|
44
|
+
const EbayListboxButton = ({ "aria-invalid": invalid, a11yIconPrefixText, borderless, children, className, collapseOnSelect, disabled, floatingLabel, fluid, hasError, listSelection, maxHeight, name, postfixLabel, prefixId, prefixLabel, selected, split, truncate, unselectedText = "-", value, variant, onChange = () => {
|
|
45
|
+
}, onExpand = () => {
|
|
46
|
+
}, onCollapse = () => {
|
|
47
|
+
}, ...rest }) => {
|
|
48
|
+
const containerRef = React.useRef();
|
|
49
|
+
const buttonRef = React.useRef();
|
|
50
|
+
const expanderRef = React.useRef();
|
|
51
|
+
const options = common_componentUtils_utils.filterByType(children, listbox.EbayListboxOption);
|
|
52
|
+
const [selectedIndex, setSelectedIndex] = React.useState(getSelectedValueIndex({ selected, value, options }));
|
|
53
|
+
const selectedOption = options[selectedIndex];
|
|
54
|
+
const selectedText = selectedOption && (selectedOption.props.text || selectedOption.props.children);
|
|
55
|
+
const selectedIcon = selectedOption && selectedOption.props.icon;
|
|
56
|
+
const a11ySelectedIconText = selectedIcon && selectedText;
|
|
57
|
+
const labelId = prefixId && "expand-btn-text";
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
setSelectedIndex(getSelectedValueIndex({ selected, value, options }));
|
|
60
|
+
}, [value, selected]);
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
function handleExpand() {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
(_b = (_a = containerRef.current) == null ? void 0 : _a.querySelector(".listbox-button__listbox")) == null ? void 0 : _b.scroll();
|
|
65
|
+
onExpand();
|
|
66
|
+
}
|
|
67
|
+
function handleCollapse() {
|
|
68
|
+
requestAnimationFrame(() => {
|
|
69
|
+
var _a;
|
|
70
|
+
(_a = buttonRef.current) == null ? void 0 : _a.focus();
|
|
71
|
+
});
|
|
72
|
+
onCollapse();
|
|
73
|
+
}
|
|
74
|
+
if (options.length && !disabled) {
|
|
75
|
+
expanderRef.current = new index.src_default(containerRef.current, {
|
|
76
|
+
alwaysDoFocusManagement: true,
|
|
77
|
+
autoCollapse: true,
|
|
78
|
+
expandOnClick: true,
|
|
79
|
+
simulateSpacebarClick: true,
|
|
80
|
+
contentSelector: ".listbox-button__listbox",
|
|
81
|
+
hostSelector: ".listbox-button__control",
|
|
82
|
+
expandedClass: "listbox-button--expanded",
|
|
83
|
+
focusManagement: "content"
|
|
84
|
+
});
|
|
85
|
+
containerRef.current.addEventListener("expander-expand", handleExpand);
|
|
86
|
+
containerRef.current.addEventListener("expander-collapse", handleCollapse);
|
|
87
|
+
}
|
|
88
|
+
add(buttonRef.current);
|
|
89
|
+
return () => {
|
|
90
|
+
if (expanderRef.current) {
|
|
91
|
+
expanderRef.current.destroy();
|
|
92
|
+
expanderRef.current = void 0;
|
|
93
|
+
}
|
|
94
|
+
if (containerRef.current) {
|
|
95
|
+
containerRef.current.removeEventListener("expander-expand", handleExpand);
|
|
96
|
+
containerRef.current.removeEventListener("expander-collapse", handleCollapse);
|
|
97
|
+
}
|
|
98
|
+
if (buttonRef.current) {
|
|
99
|
+
remove(buttonRef.current);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}, [disabled]);
|
|
103
|
+
function handleListboxChange(event, data) {
|
|
104
|
+
if (collapseOnSelect !== false) {
|
|
105
|
+
expanderRef.current.expanded = false;
|
|
106
|
+
}
|
|
107
|
+
setSelectedIndex(data.index);
|
|
108
|
+
onChange(event, data);
|
|
109
|
+
}
|
|
110
|
+
function handleListboxEscape() {
|
|
111
|
+
expanderRef.current.expanded = false;
|
|
112
|
+
}
|
|
113
|
+
const Container = truncate && !fluid ? "div" : "span";
|
|
114
|
+
return React.createElement(
|
|
115
|
+
Container,
|
|
116
|
+
{ ref: containerRef, className: classNames("listbox-button", className, {
|
|
117
|
+
"listbox-button--fluid": fluid,
|
|
118
|
+
"listbox-button--form": variant === "form",
|
|
119
|
+
"listbox-button--error": invalid || hasError
|
|
120
|
+
}) },
|
|
121
|
+
React.createElement(
|
|
122
|
+
"button",
|
|
123
|
+
{ ...rest, disabled, ref: buttonRef, className: classNames("listbox-button__control", "btn", {
|
|
124
|
+
[`btn--split-${split}`]: split,
|
|
125
|
+
"btn--borderless": borderless,
|
|
126
|
+
"btn--form": !borderless,
|
|
127
|
+
"btn--truncated": truncate,
|
|
128
|
+
"btn--floating-label": floatingLabel
|
|
129
|
+
}), "aria-label": a11ySelectedIconText && `${a11yIconPrefixText}: ${a11ySelectedIconText}`, value: selectedText, type: "button", "aria-haspopup": "listbox", "aria-labelledby": labelId && `${prefixId} ${labelId}`, "aria-invalid": invalid || hasError },
|
|
130
|
+
React.createElement(
|
|
131
|
+
"span",
|
|
132
|
+
{ className: "btn__cell" },
|
|
133
|
+
floatingLabel ? React.createElement(
|
|
134
|
+
React.Fragment,
|
|
135
|
+
null,
|
|
136
|
+
React.createElement("span", { className: classNames("btn__floating-label", "btn__floating-label--animate", !selectedText && "btn__floating-label--inline") }, floatingLabel),
|
|
137
|
+
React.createElement(RenderText, { icon: selectedIcon, labelId, text: selectedText, unselectedText, postfixLabel })
|
|
138
|
+
) : React.createElement(
|
|
139
|
+
React.Fragment,
|
|
140
|
+
null,
|
|
141
|
+
prefixLabel ? React.createElement("span", { className: "btn__label" }, prefixLabel) : null,
|
|
142
|
+
React.createElement(RenderText, { alwaysDisplay: true, icon: selectedIcon, labelId, text: selectedText, unselectedText, postfixLabel })
|
|
143
|
+
),
|
|
144
|
+
React.createElement(icon.EbayIcon, { name: "chevronDown12" })
|
|
145
|
+
)
|
|
146
|
+
),
|
|
147
|
+
React.createElement(listbox.EbayListbox, { className: "listbox-button__listbox", selectClassName: "listbox-button__native", tabIndex: -1, listSelection, name, maxHeight, onChange: handleListboxChange, onEscape: handleListboxEscape }, options.map((option, index2) => React.createElement(listbox.EbayListboxOption, { key: option.props.value || index2, selected: index2 === selectedIndex, className: classNames("listbox-button__option", option.props.className), ...option.props })))
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
exports.EbayListboxButton = EbayListboxButton;
|
|
151
|
+
exports.EbayListboxButtonOption = EbayListboxButtonOption;
|
package/ebay-menu/index.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const menu = require("../menu-Bsy48CE1.js");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const classNames = require("classnames");
|
|
6
|
+
const EbayMenuItemSeparator = ({ className, ...rest }) => React.createElement("hr", { ...rest, className: classNames(className, "menu__separator"), role: "separator" });
|
|
7
|
+
exports.EbayMenu = menu.EbayMenu;
|
|
8
|
+
exports.EbayMenuItem = menu.EbayMenuItem;
|
|
9
|
+
exports.EbayMenuSeparator = EbayMenuItemSeparator;
|
|
@@ -1 +1,113 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const classNames = require("classnames");
|
|
5
|
+
const common_componentUtils_utils = require("../common/component-utils/utils/index.js");
|
|
6
|
+
const menu = require("../menu-Bsy48CE1.js");
|
|
7
|
+
const button = require("../button-B4bZIgwB.js");
|
|
8
|
+
const iconButton = require("../icon-button-BQWoMgX1.js");
|
|
9
|
+
const icon = require("../icon-B17Di3YL.js");
|
|
10
|
+
const common_randomId = require("../common/random-id/index.js");
|
|
11
|
+
const common_eventUtils = require("../common/event-utils/index.js");
|
|
12
|
+
const EbayMenuButton = ({ type, variant = "button", className, text = "", fixWidth, reverse, expanded: defaultExpanded, noToggleIcon, checked, collapseOnSelect, a11yText, prefixId, prefixLabel, onClick = () => {
|
|
13
|
+
}, onExpand = () => {
|
|
14
|
+
}, onCollapse = () => {
|
|
15
|
+
}, onChange = () => {
|
|
16
|
+
}, onSelect = () => {
|
|
17
|
+
}, children, ...rest }) => {
|
|
18
|
+
const [expanded, setExpanded] = React.useState(defaultExpanded);
|
|
19
|
+
const [menuId, setMenuId] = React.useState();
|
|
20
|
+
const buttonRef = React.useRef(null);
|
|
21
|
+
const menuRef = React.useRef();
|
|
22
|
+
const menuItems = common_componentUtils_utils.filterByType(children, [menu.EbayMenuItem, EbayMenuButtonSeparator]);
|
|
23
|
+
const defaultIndexes = menuItems.map((item) => Boolean(item.props.checked));
|
|
24
|
+
const [checkedIndexes, setCheckedIndexes] = React.useState(defaultIndexes);
|
|
25
|
+
const menuButtonLabel = common_componentUtils_utils.findComponent(children, EbayMenuButtonLabel);
|
|
26
|
+
const icon$1 = common_componentUtils_utils.findComponent(children, icon.EbayIcon);
|
|
27
|
+
const label = labelWithPrefixAndIcon({ text, prefixId, prefixLabel, menuButtonLabel, icon: icon$1 });
|
|
28
|
+
const wrapperClasses = classNames("menu-button", className);
|
|
29
|
+
const menuClasses = classNames("menu-button__menu", {
|
|
30
|
+
"menu-button__menu--fix-width": fixWidth,
|
|
31
|
+
"menu-button__menu--reverse": reverse
|
|
32
|
+
});
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
const handleBackgroundClick = (e) => {
|
|
35
|
+
const menuEl = menuRef.current;
|
|
36
|
+
const menuClicked = menuEl && menuEl.contains(e.target);
|
|
37
|
+
if (collapseOnSelect || !menuClicked) {
|
|
38
|
+
setExpanded(false);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
if (expanded) {
|
|
42
|
+
onExpand();
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
document.addEventListener("click", handleBackgroundClick, false);
|
|
45
|
+
});
|
|
46
|
+
} else if (expanded === false) {
|
|
47
|
+
onCollapse();
|
|
48
|
+
}
|
|
49
|
+
return () => document.removeEventListener("click", handleBackgroundClick, false);
|
|
50
|
+
}, [expanded]);
|
|
51
|
+
React.useEffect(() => {
|
|
52
|
+
setMenuId(common_randomId.randomId());
|
|
53
|
+
}, []);
|
|
54
|
+
const handleMenuKeydown = (e) => {
|
|
55
|
+
common_eventUtils.handleEscapeKeydown(e, () => {
|
|
56
|
+
var _a;
|
|
57
|
+
setExpanded(false);
|
|
58
|
+
(_a = buttonRef.current) == null ? void 0 : _a.focus();
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const buttonProps = {
|
|
62
|
+
ref: buttonRef,
|
|
63
|
+
className: "menu-button__button",
|
|
64
|
+
"aria-expanded": !!expanded,
|
|
65
|
+
"aria-haspopup": true,
|
|
66
|
+
"aria-label": a11yText,
|
|
67
|
+
"aria-controls": menuId,
|
|
68
|
+
"aria-labelledby": prefixId,
|
|
69
|
+
onClick: (e) => {
|
|
70
|
+
setExpanded(!expanded);
|
|
71
|
+
onClick(e);
|
|
72
|
+
},
|
|
73
|
+
...rest
|
|
74
|
+
};
|
|
75
|
+
const handleOnChange = (e, eventProps) => {
|
|
76
|
+
if (type === "radio" || type === "checkbox") {
|
|
77
|
+
const newCheckedIndexes = checkedIndexes.map((_, i) => eventProps.indexes.includes(i));
|
|
78
|
+
setCheckedIndexes(newCheckedIndexes);
|
|
79
|
+
}
|
|
80
|
+
onChange(e, eventProps);
|
|
81
|
+
};
|
|
82
|
+
const checkedIndex = () => {
|
|
83
|
+
const index = checkedIndexes.findIndex(Boolean);
|
|
84
|
+
return index > -1 ? index : checked;
|
|
85
|
+
};
|
|
86
|
+
return React.createElement(
|
|
87
|
+
"span",
|
|
88
|
+
{ className: wrapperClasses },
|
|
89
|
+
variant === "overflow" ? React.createElement(iconButton.EbayIconButton, { icon: "overflowVertical16", ...buttonProps }) : React.createElement(button.EbayButton, { variant: variant === "form" ? "form" : void 0, bodyState: noToggleIcon ? void 0 : "expand", ...buttonProps }, label),
|
|
90
|
+
expanded && React.createElement(menu.EbayMenu, { baseEl: "div", ref: menuRef, type, className: menuClasses, tabIndex: -1, id: menuId, autofocus: true, checked: checkedIndex(), onKeyDown: handleMenuKeydown, onChange: handleOnChange, onSelect }, menuItems.map((item, i) => React.cloneElement(item, {
|
|
91
|
+
...item.props,
|
|
92
|
+
className: classNames(item.props.className, "menu-button__item"),
|
|
93
|
+
key: i,
|
|
94
|
+
checked: checkedIndexes[i]
|
|
95
|
+
})))
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
function labelWithPrefixAndIcon({ text, prefixId, prefixLabel, menuButtonLabel, icon: icon2 }) {
|
|
99
|
+
const textLabelElement = text.length ? React.createElement("span", null, text) : null;
|
|
100
|
+
const prefixLabelElement = !prefixId && prefixLabel && [
|
|
101
|
+
React.createElement("span", { className: "menu-button-prefix-label" }, prefixLabel),
|
|
102
|
+
React.createElement(React.Fragment, null, " ")
|
|
103
|
+
];
|
|
104
|
+
const labelWithPrefix = [prefixLabelElement, menuButtonLabel || textLabelElement];
|
|
105
|
+
const labelArray = [icon2, labelWithPrefix].flat().filter(Boolean);
|
|
106
|
+
return labelArray.length ? labelArray : null;
|
|
107
|
+
}
|
|
108
|
+
const EbayMenuButtonSeparator = ({ className, ...rest }) => React.createElement("hr", { ...rest, className: classNames(className, "menu-button__separator"), role: "separator" });
|
|
109
|
+
const EbayMenuButtonLabel = ({ children }) => React.createElement(React.Fragment, null, children);
|
|
110
|
+
exports.EbayMenuButtonItem = menu.EbayMenuItem;
|
|
111
|
+
exports.EbayMenuButton = EbayMenuButton;
|
|
112
|
+
exports.EbayMenuButtonLabel = EbayMenuButtonLabel;
|
|
113
|
+
exports.EbayMenuButtonSeparator = EbayMenuButtonSeparator;
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const noticeContent = require("../notice-content-BhUeK1pd.js");
|
|
5
|
+
const EbayNoticeTitle = ({ children }) => React.createElement("span", { className: "page-notice__title" }, children);
|
|
6
|
+
exports.EbayNoticeContent = noticeContent.EbayNoticeContent;
|
|
7
|
+
exports.EbayNoticeTitle = EbayNoticeTitle;
|
|
@@ -1 +1,50 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const noticeContent$1 = require("../notice-content-BTXVxttv.js");
|
|
5
|
+
const noticeContent = require("../notice-content-BhUeK1pd.js");
|
|
6
|
+
const icon = require("../icon-B17Di3YL.js");
|
|
7
|
+
require("classnames");
|
|
8
|
+
const noticeFooter = require("../notice-footer-CIQ8SM6N.js");
|
|
9
|
+
const common_noticeUtils_noticeCta = require("../common/notice-utils/notice-cta/index.js");
|
|
10
|
+
const EbayPageNotice = ({ id, status = "general", children, a11yDismissText, "aria-label": ariaLabel, onDismiss = () => {
|
|
11
|
+
}, ...rest }) => {
|
|
12
|
+
const [dismissed, setDismissed] = React.useState(false);
|
|
13
|
+
const childrenArray = React.Children.toArray(children);
|
|
14
|
+
const content = childrenArray.find((child) => child.type === noticeContent.EbayNoticeContent);
|
|
15
|
+
if (!content) {
|
|
16
|
+
throw new Error(`EbayPageNotice: Please use a EbayNoticeContent that defines the content of the notice`);
|
|
17
|
+
}
|
|
18
|
+
const handleDismissed = (event) => {
|
|
19
|
+
setDismissed(true);
|
|
20
|
+
onDismiss(event);
|
|
21
|
+
};
|
|
22
|
+
return dismissed ? null : React.createElement(
|
|
23
|
+
"section",
|
|
24
|
+
{ ...rest, "aria-labelledby": id || `${status}-status`, className: `page-notice ${status !== `general` ? `page-notice--${status}` : ``}`, role: "region" },
|
|
25
|
+
status !== `general` ? React.createElement(
|
|
26
|
+
"div",
|
|
27
|
+
{ className: "page-notice__header", id: id || `${status}-status` },
|
|
28
|
+
React.createElement(icon.EbayIcon, { name: `${status}Filled16`, a11yText: ariaLabel, a11yVariant: "label" })
|
|
29
|
+
) : null,
|
|
30
|
+
React.createElement(noticeContent$1.NoticeContent, { ...content.props, type: "page" }),
|
|
31
|
+
children,
|
|
32
|
+
a11yDismissText && React.createElement(
|
|
33
|
+
EbayPageNoticeFooter,
|
|
34
|
+
null,
|
|
35
|
+
React.createElement(
|
|
36
|
+
"button",
|
|
37
|
+
{ "aria-label": a11yDismissText, className: "fake-link page-notice__dismiss", onClick: handleDismissed },
|
|
38
|
+
React.createElement(icon.EbayIcon, { name: "close16" })
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
const EbayPageNoticeTitle = ({ className, as, children, ...rest }) => React.createElement(noticeFooter.NoticeTitle, { ...rest, className, as, type: "page" }, children);
|
|
44
|
+
const EbayPageNoticeFooter = ({ className, children }) => React.createElement(noticeFooter.NoticeFooter, { className, type: "page" }, children);
|
|
45
|
+
const EbayPageNoticeCTA = ({ className, children }) => React.createElement(common_noticeUtils_noticeCta, { className, type: "page" }, children);
|
|
46
|
+
exports.EbayNoticeContent = noticeContent.EbayNoticeContent;
|
|
47
|
+
exports.EbayPageNotice = EbayPageNotice;
|
|
48
|
+
exports.EbayPageNoticeCTA = EbayPageNoticeCTA;
|
|
49
|
+
exports.EbayPageNoticeFooter = EbayPageNoticeFooter;
|
|
50
|
+
exports.EbayPageNoticeTitle = EbayPageNoticeTitle;
|
package/ebay-pagination/index.js
CHANGED
|
@@ -1 +1,244 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const ebayFakeMenuButton_menuButton = require("../menu-button-CKGsgg6G.js");
|
|
5
|
+
const classNames = require("classnames");
|
|
6
|
+
const debounce = require("../debounce-v8bWAUnY.js");
|
|
7
|
+
const common_componentUtils_utils = require("../common/component-utils/utils/index.js");
|
|
8
|
+
const icon = require("../icon-B17Di3YL.js");
|
|
9
|
+
const common_componentUtils_forwardRef = require("../common/component-utils/forwardRef/index.js");
|
|
10
|
+
require("../array.polyfill.flat-DyxysTxZ.js");
|
|
11
|
+
const MIN_PAGES = 1;
|
|
12
|
+
const MAX_PAGES = 9;
|
|
13
|
+
const MIN_VISIBLE_ITEMS = 4;
|
|
14
|
+
const LEADING_SPACE_WITH_DOT = 2;
|
|
15
|
+
const TRAILING_SPACE_WITH_DOT = MAX_PAGES - LEADING_SPACE_WITH_DOT;
|
|
16
|
+
function pageNumbersAround(totalPages, selectedPage, maxVisiblePages = totalPages, variant = null) {
|
|
17
|
+
const withDots = variant === "show-last" || variant === "overflow" && totalPages > MAX_PAGES;
|
|
18
|
+
const hasLeadingDots = variant === "overflow" && totalPages > MAX_PAGES;
|
|
19
|
+
const visibleItems = Math.min(maxVisiblePages, totalPages);
|
|
20
|
+
const startIndexWithoutDots = Math.max(0, selectedPage - Math.ceil((visibleItems - 1) / 2));
|
|
21
|
+
const startIndexWithDots = visibleItems < MIN_VISIBLE_ITEMS ? selectedPage : Math.max(0, selectedPage - Math.floor((visibleItems - 1) / 2));
|
|
22
|
+
const endIndex = (withDots ? startIndexWithDots : startIndexWithoutDots) + visibleItems;
|
|
23
|
+
const closeToEnd = endIndex >= totalPages;
|
|
24
|
+
const closeToFront = selectedPage <= MIN_VISIBLE_ITEMS;
|
|
25
|
+
const visibleRangeWithDots = (start, end) => {
|
|
26
|
+
const items = visibleRange(totalPages, start, end);
|
|
27
|
+
if (visibleItems > 2) {
|
|
28
|
+
items[end - 2] = "dots";
|
|
29
|
+
items[end - 1] = "hidden";
|
|
30
|
+
items[totalPages - 1] = "visible";
|
|
31
|
+
} else if (visibleItems > 1) {
|
|
32
|
+
items[end - 1] = "dots";
|
|
33
|
+
}
|
|
34
|
+
return items;
|
|
35
|
+
};
|
|
36
|
+
const visibleRangeWithOverflowDots = (start, end) => {
|
|
37
|
+
if (closeToFront) {
|
|
38
|
+
return visibleRangeWithDots(0, end);
|
|
39
|
+
} else if (closeToEnd) {
|
|
40
|
+
const items2 = visibleRange(totalPages, totalPages - TRAILING_SPACE_WITH_DOT, totalPages);
|
|
41
|
+
items2[0] = "visible";
|
|
42
|
+
items2[1] = "dots";
|
|
43
|
+
return items2;
|
|
44
|
+
}
|
|
45
|
+
const items = visibleRange(totalPages, selectedPage - LEADING_SPACE_WITH_DOT, selectedPage + LEADING_SPACE_WITH_DOT + 1);
|
|
46
|
+
items[0] = "visible";
|
|
47
|
+
items[1] = closeToFront ? "visible" : "dots";
|
|
48
|
+
items[totalPages - 2] = "dots";
|
|
49
|
+
items[totalPages - 1] = "visible";
|
|
50
|
+
return items;
|
|
51
|
+
};
|
|
52
|
+
if (closeToEnd && totalPages <= MAX_PAGES) {
|
|
53
|
+
return visibleRange(totalPages, totalPages - visibleItems);
|
|
54
|
+
}
|
|
55
|
+
if (withDots) {
|
|
56
|
+
return hasLeadingDots ? visibleRangeWithOverflowDots(startIndexWithDots, endIndex) : visibleRangeWithDots(startIndexWithDots, endIndex);
|
|
57
|
+
}
|
|
58
|
+
return visibleRange(totalPages, startIndexWithoutDots, endIndex);
|
|
59
|
+
}
|
|
60
|
+
function calcPageState(selectedPage, visiblePages, totalPages, variant = "show-range") {
|
|
61
|
+
if (selectedPage === -1) {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
const adjustedNumPages = variant === "overflow" ? MAX_PAGES : clamp(Math.min(totalPages, visiblePages), MIN_PAGES, MAX_PAGES);
|
|
65
|
+
return pageNumbersAround(totalPages, selectedPage - 1, adjustedNumPages, variant);
|
|
66
|
+
}
|
|
67
|
+
function clamp(n, min, max) {
|
|
68
|
+
return n <= min ? min : n >= max ? max : n;
|
|
69
|
+
}
|
|
70
|
+
function visibleRange(totalItems, start, end) {
|
|
71
|
+
return Array(totalItems).fill("hidden").fill("visible", start, end);
|
|
72
|
+
}
|
|
73
|
+
function getMaxWidth(el) {
|
|
74
|
+
if (!el) {
|
|
75
|
+
return 0;
|
|
76
|
+
}
|
|
77
|
+
el.style.width = "100vw";
|
|
78
|
+
const result = el.offsetWidth;
|
|
79
|
+
el.style.width = null;
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
const EbayPagination = ({ id = "ebay-pagination", className, a11yCurrentText = "Pagination - Current Page", a11yPreviousText = "Previous page", a11yNextText = "Next page", variant = "show-range", fluid = false, onPrevious = () => {
|
|
83
|
+
}, onNext = () => {
|
|
84
|
+
}, onSelect = () => {
|
|
85
|
+
}, children, ...rest }) => {
|
|
86
|
+
const paginationContainerRef = React.useRef(null);
|
|
87
|
+
const childPageRefs = React.useRef([]);
|
|
88
|
+
childPageRefs.current = React.Children.map(children, React.createRef);
|
|
89
|
+
const totalPages = common_componentUtils_utils.filterBy(children, ({ props }) => props.type === void 0 || props.type === "page").length;
|
|
90
|
+
const itemWidthRef = React.useRef(0);
|
|
91
|
+
const arrowWidthRef = React.useRef(0);
|
|
92
|
+
const getNumOfVisiblePageItems = () => {
|
|
93
|
+
var _a, _b, _c, _d;
|
|
94
|
+
const pageArrowWidth = arrowWidthRef.current || ((_b = (_a = childPageRefs.current[0]) == null ? void 0 : _a.current) == null ? void 0 : _b.offsetWidth);
|
|
95
|
+
arrowWidthRef.current = pageArrowWidth;
|
|
96
|
+
const pageItemWidth = itemWidthRef.current || ((_d = (_c = childPageRefs.current[1]) == null ? void 0 : _c.current) == null ? void 0 : _d.offsetWidth);
|
|
97
|
+
itemWidthRef.current = pageItemWidth;
|
|
98
|
+
return pageItemWidth ? Math.floor((getMaxWidth(paginationContainerRef.current) - pageArrowWidth * 2) / pageItemWidth) : 0;
|
|
99
|
+
};
|
|
100
|
+
const [page, setPage] = React.useState([]);
|
|
101
|
+
const [selectedIndex, setSelectedIndex] = React.useState(0);
|
|
102
|
+
const updatePages = (selectedPageIndexFromDotMenu) => {
|
|
103
|
+
const selectedPageIndex = selectedPageIndexFromDotMenu || childPageRefs.current.findIndex((pageRef) => {
|
|
104
|
+
var _a;
|
|
105
|
+
return ((_a = pageRef.current) == null ? void 0 : _a.getAttribute("aria-current")) === "page";
|
|
106
|
+
});
|
|
107
|
+
const visiblePageItems = getNumOfVisiblePageItems();
|
|
108
|
+
const pageState = calcPageState(selectedPageIndex, visiblePageItems, totalPages, variant);
|
|
109
|
+
setSelectedIndex(selectedPageIndex);
|
|
110
|
+
setPage(["hidden", ...pageState]);
|
|
111
|
+
};
|
|
112
|
+
React.useEffect(() => {
|
|
113
|
+
const debouncedUpdate = debounce.debounce(updatePages, 16);
|
|
114
|
+
updatePages();
|
|
115
|
+
window.addEventListener("resize", () => debouncedUpdate());
|
|
116
|
+
return () => {
|
|
117
|
+
window.removeEventListener("resize", () => debouncedUpdate());
|
|
118
|
+
};
|
|
119
|
+
}, [children]);
|
|
120
|
+
const createChildItems = (itemType) => {
|
|
121
|
+
let pageIndex = 0;
|
|
122
|
+
const firstDotItems = [];
|
|
123
|
+
const secondDotItems = [];
|
|
124
|
+
const allDotItems = [];
|
|
125
|
+
const firstDot = page.indexOf("dots");
|
|
126
|
+
const lastDot = page.lastIndexOf("dots");
|
|
127
|
+
return React.Children.map(children, (item, index) => {
|
|
128
|
+
const { type = "page", current, disabled, href, children: text } = item.props;
|
|
129
|
+
const isDot = page[index] === "dots";
|
|
130
|
+
const key = `${id}-item-${index}`;
|
|
131
|
+
const hide = page[index] === "hidden";
|
|
132
|
+
const isSeparator = isDot && type === "page";
|
|
133
|
+
const newProps = {
|
|
134
|
+
current,
|
|
135
|
+
disabled,
|
|
136
|
+
href,
|
|
137
|
+
type: isSeparator ? "separator" : type,
|
|
138
|
+
children: isDot ? React.createElement(icon.EbayIcon, { name: "overflowHorizontal24", focusable: false }) : text,
|
|
139
|
+
pageIndex: type === "page" ? pageIndex++ : void 0,
|
|
140
|
+
key,
|
|
141
|
+
hide,
|
|
142
|
+
onPrevious,
|
|
143
|
+
onNext,
|
|
144
|
+
onSelect,
|
|
145
|
+
a11yPreviousText,
|
|
146
|
+
a11yNextText,
|
|
147
|
+
ref: childPageRefs.current[index]
|
|
148
|
+
};
|
|
149
|
+
if ((hide || isDot) && type === "page") {
|
|
150
|
+
const itemComponent = React.createElement(ebayFakeMenuButton_menuButton.EbayFakeMenuButtonItem, { key, href, onClick: (event) => {
|
|
151
|
+
if (!href) {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
}
|
|
154
|
+
const currentTarget = event.currentTarget;
|
|
155
|
+
onSelect(event, { value: (currentTarget == null ? void 0 : currentTarget.innerText) || "", index: pageIndex });
|
|
156
|
+
updatePages(Number(currentTarget == null ? void 0 : currentTarget.innerText));
|
|
157
|
+
} }, text);
|
|
158
|
+
if (firstDot === lastDot) {
|
|
159
|
+
allDotItems.push(itemComponent);
|
|
160
|
+
}
|
|
161
|
+
if (selectedIndex - 2 > firstDot && index < selectedIndex) {
|
|
162
|
+
firstDotItems.push(itemComponent);
|
|
163
|
+
}
|
|
164
|
+
if (selectedIndex + 2 < lastDot && index > selectedIndex) {
|
|
165
|
+
secondDotItems.push(itemComponent);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (itemType === "page" && isDot && variant === "overflow") {
|
|
169
|
+
let childComponent = allDotItems;
|
|
170
|
+
if (firstDot !== lastDot) {
|
|
171
|
+
childComponent = index === 2 ? firstDotItems : secondDotItems;
|
|
172
|
+
}
|
|
173
|
+
return React.createElement(
|
|
174
|
+
"li",
|
|
175
|
+
{ key },
|
|
176
|
+
React.createElement(
|
|
177
|
+
"span",
|
|
178
|
+
{ className: "pagination__item", role: "separator" },
|
|
179
|
+
React.createElement(ebayFakeMenuButton_menuButton.EbayMenuButton, { a11yText: "Menu", borderless: true, variant: "overflow", noToggleIcon: true }, childComponent)
|
|
180
|
+
)
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
return itemType === type ? React.cloneElement(item, newProps) : null;
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
const headingId = `${id}-pagination-heading`;
|
|
187
|
+
return React.createElement(
|
|
188
|
+
"nav",
|
|
189
|
+
{ ...rest, role: "navigation", className: classNames(className, "pagination", { "pagination--fluid": fluid }), "aria-labelledby": headingId, ref: paginationContainerRef },
|
|
190
|
+
React.createElement(
|
|
191
|
+
"span",
|
|
192
|
+
{ "aria-live": "polite", role: "status" },
|
|
193
|
+
React.createElement("h2", { className: "clipped", id: headingId }, a11yCurrentText)
|
|
194
|
+
),
|
|
195
|
+
createChildItems("previous"),
|
|
196
|
+
React.createElement("ol", { className: "pagination__items" }, createChildItems("page")),
|
|
197
|
+
createChildItems("next")
|
|
198
|
+
);
|
|
199
|
+
};
|
|
200
|
+
const EbayPaginationItem = ({ pageIndex = 0, key, current, disabled, type = "page", href, hide, children, a11yPreviousText = "Previous page", a11yNextText = "Next page", onSelect, onNext, onPrevious, className, style, forwardedRef, ...rest }) => {
|
|
201
|
+
const handlePageNumber = (e) => {
|
|
202
|
+
var _a;
|
|
203
|
+
onSelect(e, { value: ((_a = e.currentTarget) == null ? void 0 : _a.innerText) || "", index: pageIndex });
|
|
204
|
+
};
|
|
205
|
+
const handleNextPage = (e) => {
|
|
206
|
+
if (!e.currentTarget.getAttribute("aria-disabled")) {
|
|
207
|
+
onNext(e);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const handlePreviousPage = (e) => {
|
|
211
|
+
if (!e.currentTarget.getAttribute("aria-disabled")) {
|
|
212
|
+
onPrevious(e);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
const isAnchor = !!href;
|
|
216
|
+
const ButtonOrAnchor = isAnchor ? "a" : "button";
|
|
217
|
+
const iconClassName = isAnchor ? "icon-link" : "icon-btn";
|
|
218
|
+
const arrowStyle = { ...style, minWidth: "40px" };
|
|
219
|
+
switch (type) {
|
|
220
|
+
case "previous":
|
|
221
|
+
return React.createElement(
|
|
222
|
+
ButtonOrAnchor,
|
|
223
|
+
{ ...rest, ref: forwardedRef, "aria-disabled": disabled ? "true" : void 0, "aria-label": a11yPreviousText, href: disabled ? void 0 : href, className: classNames(iconClassName, "pagination__previous"), style: arrowStyle, onClick: handlePreviousPage },
|
|
224
|
+
React.createElement(icon.EbayIcon, { name: "arrowLeft16" })
|
|
225
|
+
);
|
|
226
|
+
case "next":
|
|
227
|
+
return React.createElement(
|
|
228
|
+
ButtonOrAnchor,
|
|
229
|
+
{ ...rest, ref: forwardedRef, "aria-disabled": disabled ? "true" : void 0, "aria-label": a11yNextText, href: disabled ? void 0 : href, className: classNames(iconClassName, "pagination__next"), style: arrowStyle, onClick: handleNextPage },
|
|
230
|
+
React.createElement(icon.EbayIcon, { name: "arrowRight16" })
|
|
231
|
+
);
|
|
232
|
+
case "separator":
|
|
233
|
+
return React.createElement("span", { key, style, className: "pagination__item", ref: forwardedRef, role: "separator" }, children);
|
|
234
|
+
default:
|
|
235
|
+
return React.createElement(
|
|
236
|
+
"li",
|
|
237
|
+
{ ...rest, hidden: hide },
|
|
238
|
+
React.createElement(ButtonOrAnchor, { ref: forwardedRef, "aria-current": current ? "page" : void 0, href, className: "pagination__item", style, key, onClick: handlePageNumber }, children)
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
const paginationItem = common_componentUtils_forwardRef.withForwardRef(EbayPaginationItem);
|
|
243
|
+
exports.EbayPagination = EbayPagination;
|
|
244
|
+
exports.EbayPaginationItem = paginationItem;
|