@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.
Files changed (119) hide show
  1. package/array.polyfill.flat-DyxysTxZ.js +21 -0
  2. package/badge-CR5t7-2L.js +8 -0
  3. package/button-B4bZIgwB.js +83 -0
  4. package/calendar-D-DWjrMU.js +333 -0
  5. package/common/component-utils/forwardRef/index.js +10 -1
  6. package/common/component-utils/index.js +9 -1
  7. package/common/component-utils/utils/index.js +25 -1
  8. package/common/event-utils/index.js +113 -1
  9. package/common/floating-label-utils/hooks/index.js +106 -1
  10. package/common/notice-utils/notice-cta/index.js +5 -1
  11. package/common/random-id/index.js +13 -1
  12. package/common/tooltip-utils/constants/index.js +97 -1
  13. package/common/tooltip-utils/index.js +11 -1
  14. package/debounce-v8bWAUnY.js +9 -0
  15. package/dialog-previous-button-EC_Y6KaT.js +370 -0
  16. package/drawer-DBDktEBZ.js +69 -0
  17. package/ebay-alert-dialog/index.js +26 -1
  18. package/ebay-badge/index.js +4 -1
  19. package/ebay-breadcrumbs/index.js +47 -1
  20. package/ebay-button/index.js +5 -1
  21. package/ebay-calendar/index.js +4 -1
  22. package/ebay-carousel/index.js +345 -1
  23. package/ebay-checkbox/index.js +52 -1
  24. package/ebay-confirm-dialog/index.js +28 -1
  25. package/ebay-cta-button/index.js +22 -1
  26. package/ebay-date-textbox/index.js +140 -1
  27. package/ebay-dialog-base/components/animation/index.js +92 -1
  28. package/ebay-dialog-base/components/dialog-footer/index.js +4 -1
  29. package/ebay-dialog-base/components/dialog-header/index.js +4 -1
  30. package/ebay-dialog-base/index.js +13 -1
  31. package/ebay-drawer-dialog/index.js +4 -1
  32. package/ebay-eek/index.js +54 -1
  33. package/ebay-fake-menu/index.js +10 -1
  34. package/ebay-fake-menu/menu-item/index.js +49 -1
  35. package/ebay-fake-menu-button/index.js +7 -1
  36. package/ebay-fake-menu-button/menu-button/index.js +12 -1
  37. package/ebay-fake-tabs/index.js +30 -1
  38. package/ebay-field/index.js +21 -1
  39. package/ebay-fullscreen-dialog/index.js +10 -1
  40. package/ebay-icon/index.js +4 -1
  41. package/ebay-icon-button/index.js +4 -1
  42. package/ebay-infotip/index.js +76 -1
  43. package/ebay-inline-notice/index.js +36 -1
  44. package/ebay-lightbox-dialog/index.js +12 -1
  45. package/ebay-listbox/index.js +6 -1
  46. package/ebay-listbox/listbox.d.ts.map +1 -1
  47. package/ebay-listbox-button/index.js +151 -1
  48. package/ebay-menu/index.js +9 -1
  49. package/ebay-menu-button/index.js +113 -1
  50. package/ebay-notice-base/index.js +7 -1
  51. package/ebay-page-notice/index.js +50 -1
  52. package/ebay-pagination/index.js +244 -1
  53. package/ebay-panel-dialog/index.js +12 -1
  54. package/ebay-progress-bar/index.js +6 -1
  55. package/ebay-progress-spinner/index.js +4 -1
  56. package/ebay-progress-stepper/index.js +72 -1
  57. package/ebay-radio/index.js +4 -1
  58. package/ebay-radio/radio/index.js +48 -1
  59. package/ebay-section-notice/index.js +69 -1
  60. package/ebay-section-title/index.js +38 -1
  61. package/ebay-segmented-buttons/index.js +46 -1
  62. package/ebay-select/index.js +98 -1
  63. package/ebay-signal/index.js +9 -1
  64. package/ebay-snackbar-dialog/index.js +81 -1
  65. package/ebay-split-button/index.js +22 -1
  66. package/ebay-star-rating/index.js +9 -1
  67. package/ebay-star-rating-select/index.js +55 -1
  68. package/ebay-svg/index.js +5189 -1
  69. package/ebay-switch/index.js +27 -1
  70. package/ebay-tabs/index.js +88 -1
  71. package/ebay-textbox/index.js +10 -1
  72. package/ebay-toast-dialog/index.js +9 -1
  73. package/ebay-tooltip/index.js +64 -1
  74. package/ebay-tourtip/index.js +54 -1
  75. package/ebay-video/index.js +229 -1
  76. package/events/index.js +18 -1
  77. package/icon-B17Di3YL.js +56 -0
  78. package/icon-button-BQWoMgX1.js +31 -0
  79. package/index-BXizW4ue.js +89 -0
  80. package/index-DcH7Tjjd.js +272 -0
  81. package/label-C0AS4fnO.js +19 -0
  82. package/listbox-DGbY99kq.js +674 -0
  83. package/menu-Bsy48CE1.js +163 -0
  84. package/menu-button-CKGsgg6G.js +89 -0
  85. package/menu-fCOy6wBS.js +29 -0
  86. package/notice-content-BTXVxttv.js +8 -0
  87. package/notice-content-BhUeK1pd.js +3 -0
  88. package/notice-footer-CIQ8SM6N.js +10 -0
  89. package/package.json +1 -1
  90. package/progress-spinner-DOFKRtuu.js +20 -0
  91. package/range-C5qzyhg4.js +3 -0
  92. package/textbox-J291yCpJ.js +136 -0
  93. package/use-roving-index-CEM_UsCH.js +58 -0
  94. package/use-tooltip-7JxcZHJn.js +92 -0
  95. package/utils/index.js +13 -1
  96. package/array.polyfill.flat-5BAolFdk.js +0 -1
  97. package/badge-CoHKfiPt.js +0 -1
  98. package/button-DGuEBUDJ.js +0 -1
  99. package/calendar-lAu6VfAb.js +0 -1
  100. package/debounce-BQsYxxOL.js +0 -1
  101. package/dialog-previous-button-5cTKpmJ-.js +0 -1
  102. package/drawer-xTtCoO3F.js +0 -1
  103. package/icon-TuxfQndO.js +0 -1
  104. package/icon-button-Cwaj-eT9.js +0 -1
  105. package/index-D3xZmuzJ.js +0 -1
  106. package/index-Dkz0UnlJ.js +0 -1
  107. package/label-CnrpYJ-g.js +0 -1
  108. package/listbox-Ck3BxDm4.js +0 -1
  109. package/menu-CV-INYLM.js +0 -1
  110. package/menu-_LzP6yje.js +0 -1
  111. package/menu-button-BZ66jxvI.js +0 -1
  112. package/notice-content-9iF4T8uB.js +0 -1
  113. package/notice-content-C0ZStfuX.js +0 -1
  114. package/notice-footer-Cw1DMzoB.js +0 -1
  115. package/progress-spinner-U2qOANON.js +0 -1
  116. package/range-DOsPN0h5.js +0 -1
  117. package/textbox-dUhinDwj.js +0 -1
  118. package/use-roving-index-DoAVBgsp.js +0 -1
  119. package/use-tooltip-CL3_zAeg.js +0 -1
@@ -1 +1,12 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),a=require("classnames"),c=require("../dialog-previous-button-5cTKpmJ-.js");require("../icon-button-Cwaj-eT9.js");const i="lightbox-dialog",r=({open:s,mode:l,size:o,onClose:e=()=>{},...t})=>n.createElement(c.DialogBaseWithState,{buttonPosition:"right",...t,classPrefix:i,onCloseBtnClick:e,onBackgroundClick:e,className:a(t.className,`${i}--mask-fade`,o&&`${i}--${o}`),windowClass:a("lightbox-dialog__window--fade",{[`${i}__window--mini`]:l==="mini"}),open:s});exports.EbayLightboxDialog=r;
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;
@@ -1 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../listbox-Ck3BxDm4.js");exports.EbayListbox=t.EbayListbox;exports.EbayListboxOption=t.EbayListboxOption;exports.EbayListboxOptionDescription=t.EbayListboxOptionDescription;
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,CA0L5C,CAAA"}
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";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),W=require("../index-Dkz0UnlJ.js"),E=require("classnames"),_=require("../listbox-Ck3BxDm4.js"),X=require("../common/component-utils/utils/index.js"),Y=require("../icon-TuxfQndO.js");function M(t){t.keyCode>=32&&t.keyCode<=40&&t.preventDefault()}function Z(t){t.addEventListener("keydown",M)}function ee(t){t.removeEventListener("keydown",M)}const $=({alwaysDisplay:t,icon:c,labelId:n,text:o,unselectedText:y,postfixLabel:m})=>{if(c)return e.createElement("span",{id:n,className:"btn__text"},c);if(o||t){const i=o||y;return e.createElement("span",{id:n,className:"btn__text"},i,m&&e.createElement("span",{className:"btn__postfix-label"},m))}};function F({selected:t,value:c,options:n}){return t!==void 0?t:c!==void 0?n.findIndex(o=>o.props.value===c):n.findIndex(o=>o.props.selected)}const te=_.EbayListboxOption,ne=({"aria-invalid":t,a11yIconPrefixText:c,borderless:n,children:o,className:y,collapseOnSelect:m,disabled:i,floatingLabel:v,fluid:L,hasError:h,listSelection:j,maxHeight:A,name:K,postfixLabel:S,prefixId:q,prefixLabel:I,selected:N,split:O,truncate:R,unselectedText:k="-",value:g,variant:P,onChange:U=()=>{},onExpand:V=()=>{},onCollapse:z=()=>{},...G})=>{const a=e.useRef(),u=e.useRef(),l=e.useRef(),b=X.filterByType(o,_.EbayListboxOption),[w,B]=e.useState(F({selected:N,value:g,options:b})),d=b[w],p=d&&(d.props.text||d.props.children),C=d&&d.props.icon,D=C&&p,f=q&&"expand-btn-text";e.useEffect(()=>{B(F({selected:N,value:g,options:b}))},[g,N]),e.useEffect(()=>{function r(){var x,T;(T=(x=a.current)==null?void 0:x.querySelector(".listbox-button__listbox"))==null||T.scroll(),V()}function s(){requestAnimationFrame(()=>{var x;(x=u.current)==null||x.focus()}),z()}return b.length&&!i&&(l.current=new W.src_default(a.current,{alwaysDoFocusManagement:!0,autoCollapse:!0,expandOnClick:!0,simulateSpacebarClick:!0,contentSelector:".listbox-button__listbox",hostSelector:".listbox-button__control",expandedClass:"listbox-button--expanded",focusManagement:"content"}),a.current.addEventListener("expander-expand",r),a.current.addEventListener("expander-collapse",s)),Z(u.current),()=>{l.current&&(l.current.destroy(),l.current=void 0),a.current&&(a.current.removeEventListener("expander-expand",r),a.current.removeEventListener("expander-collapse",s)),u.current&&ee(u.current)}},[i]);function H(r,s){m!==!1&&(l.current.expanded=!1),B(s.index),U(r,s)}function J(){l.current.expanded=!1}const Q=R&&!L?"div":"span";return e.createElement(Q,{ref:a,className:E("listbox-button",y,{"listbox-button--fluid":L,"listbox-button--form":P==="form","listbox-button--error":t||h})},e.createElement("button",{...G,disabled:i,ref:u,className:E("listbox-button__control","btn",{[`btn--split-${O}`]:O,"btn--borderless":n,"btn--form":!n,"btn--truncated":R,"btn--floating-label":v}),"aria-label":D&&`${c}: ${D}`,value:p,type:"button","aria-haspopup":"listbox","aria-labelledby":f&&`${q} ${f}`,"aria-invalid":t||h},e.createElement("span",{className:"btn__cell"},v?e.createElement(e.Fragment,null,e.createElement("span",{className:E("btn__floating-label","btn__floating-label--animate",!p&&"btn__floating-label--inline")},v),e.createElement($,{icon:C,labelId:f,text:p,unselectedText:k,postfixLabel:S})):e.createElement(e.Fragment,null,I?e.createElement("span",{className:"btn__label"},I):null,e.createElement($,{alwaysDisplay:!0,icon:C,labelId:f,text:p,unselectedText:k,postfixLabel:S})),e.createElement(Y.EbayIcon,{name:"chevronDown12"}))),e.createElement(_.EbayListbox,{className:"listbox-button__listbox",selectClassName:"listbox-button__native",tabIndex:-1,listSelection:j,name:K,maxHeight:A,onChange:H,onEscape:J},b.map((r,s)=>e.createElement(_.EbayListboxOption,{key:r.props.value||s,selected:s===w,className:E("listbox-button__option",r.props.className),...r.props}))))};exports.EbayListboxButton=ne;exports.EbayListboxButtonOption=te;
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;
@@ -1 +1,9 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../menu-CV-INYLM.js"),t=require("react"),n=require("classnames"),u=({className:a,...r})=>t.createElement("hr",{...r,className:n(a,"menu__separator"),role:"separator"});exports.EbayMenu=e.EbayMenu;exports.EbayMenuItem=e.EbayMenuItem;exports.EbayMenuSeparator=u;
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";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),r=require("classnames"),y=require("../common/component-utils/utils/index.js"),h=require("../menu-CV-INYLM.js"),Q=require("../button-DGuEBUDJ.js"),X=require("../icon-button-Cwaj-eT9.js"),Y=require("../icon-TuxfQndO.js"),Z=require("../common/random-id/index.js"),ee=require("../common/event-utils/index.js"),ne=({type:t,variant:a="button",className:c,text:m="",fixWidth:d,reverse:i,expanded:x,noToggleIcon:b,checked:u,collapseOnSelect:w,a11yText:N,prefixId:I,prefixLabel:S,onClick:L=()=>{},onExpand:R=()=>{},onCollapse:K=()=>{},onChange:P=()=>{},onSelect:T=()=>{},children:f,...A})=>{const[s,E]=e.useState(x),[_,F]=e.useState(),B=e.useRef(null),k=e.useRef(),M=y.filterByType(f,[h.EbayMenuItem,v]),O=M.map(n=>!!n.props.checked),[p,U]=e.useState(O),W=y.findComponent(f,q),j=y.findComponent(f,Y.EbayIcon),D=te({text:m,prefixId:I,prefixLabel:S,menuButtonLabel:W,icon:j}),V=r("menu-button",c),$=r("menu-button__menu",{"menu-button__menu--fix-width":d,"menu-button__menu--reverse":i});e.useEffect(()=>{const n=o=>{const l=k.current,g=l&&l.contains(o.target);(w||!g)&&E(!1)};return s?(R(),setTimeout(()=>{document.addEventListener("click",n,!1)})):s===!1&&K(),()=>document.removeEventListener("click",n,!1)},[s]),e.useEffect(()=>{F(Z.randomId())},[]);const z=n=>{ee.handleEscapeKeydown(n,()=>{var o;E(!1),(o=B.current)==null||o.focus()})},C={ref:B,className:"menu-button__button","aria-expanded":!!s,"aria-haspopup":!0,"aria-label":N,"aria-controls":_,"aria-labelledby":I,onClick:n=>{E(!s),L(n)},...A},G=(n,o)=>{if(t==="radio"||t==="checkbox"){const l=p.map((g,J)=>o.indexes.includes(J));U(l)}P(n,o)},H=()=>{const n=p.findIndex(Boolean);return n>-1?n:u};return e.createElement("span",{className:V},a==="overflow"?e.createElement(X.EbayIconButton,{icon:"overflowVertical16",...C}):e.createElement(Q.EbayButton,{variant:a==="form"?"form":void 0,bodyState:b?void 0:"expand",...C},D),s&&e.createElement(h.EbayMenu,{baseEl:"div",ref:k,type:t,className:$,tabIndex:-1,id:_,autofocus:!0,checked:H(),onKeyDown:z,onChange:G,onSelect:T},M.map((n,o)=>e.cloneElement(n,{...n.props,className:r(n.props.className,"menu-button__item"),key:o,checked:p[o]}))))};function te({text:t,prefixId:a,prefixLabel:c,menuButtonLabel:m,icon:d}){const i=t.length?e.createElement("span",null,t):null,b=[!a&&c&&[e.createElement("span",{className:"menu-button-prefix-label"},c),e.createElement(e.Fragment,null," ")],m||i],u=[d,b].flat().filter(Boolean);return u.length?u:null}const v=({className:t,...a})=>e.createElement("hr",{...a,className:r(t,"menu-button__separator"),role:"separator"}),q=({children:t})=>e.createElement(e.Fragment,null,t);exports.EbayMenuButtonItem=h.EbayMenuItem;exports.EbayMenuButton=ne;exports.EbayMenuButtonLabel=q;exports.EbayMenuButtonSeparator=v;
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";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),o=require("../notice-content-C0ZStfuX.js"),n=({children:e})=>t.createElement("span",{className:"page-notice__title"},e);exports.EbayNoticeContent=o.EbayNoticeContent;exports.EbayNoticeTitle=n;
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";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),p=require("../notice-content-9iF4T8uB.js"),l=require("../notice-content-C0ZStfuX.js"),r=require("../icon-TuxfQndO.js");require("classnames");const s=require("../notice-footer-Cw1DMzoB.js"),u=require("../common/notice-utils/notice-cta/index.js"),C=({id:n,status:e="general",children:a,a11yDismissText:o,"aria-label":E,onDismiss:b=()=>{},...g})=>{const[m,N]=t.useState(!1),i=t.Children.toArray(a).find(c=>c.type===l.EbayNoticeContent);if(!i)throw new Error("EbayPageNotice: Please use a EbayNoticeContent that defines the content of the notice");const d=c=>{N(!0),b(c)};return m?null:t.createElement("section",{...g,"aria-labelledby":n||`${e}-status`,className:`page-notice ${e!=="general"?`page-notice--${e}`:""}`,role:"region"},e!=="general"?t.createElement("div",{className:"page-notice__header",id:n||`${e}-status`},t.createElement(r.EbayIcon,{name:`${e}Filled16`,a11yText:E,a11yVariant:"label"})):null,t.createElement(p.NoticeContent,{...i.props,type:"page"}),a,o&&t.createElement(y,null,t.createElement("button",{"aria-label":o,className:"fake-link page-notice__dismiss",onClick:d},t.createElement(r.EbayIcon,{name:"close16"}))))},P=({className:n,as:e,children:a,...o})=>t.createElement(s.NoticeTitle,{...o,className:n,as:e,type:"page"},a),y=({className:n,children:e})=>t.createElement(s.NoticeFooter,{className:n,type:"page"},e),h=({className:n,children:e})=>t.createElement(u,{className:n,type:"page"},e);exports.EbayNoticeContent=l.EbayNoticeContent;exports.EbayPageNotice=C;exports.EbayPageNoticeCTA=h;exports.EbayPageNoticeFooter=y;exports.EbayPageNoticeTitle=P;
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;
@@ -1 +1,244 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),J=require("../menu-button-BZ66jxvI.js"),H=require("classnames"),ee=require("../debounce-BQsYxxOL.js"),te=require("../common/component-utils/utils/index.js"),U=require("../icon-TuxfQndO.js"),ne=require("../common/component-utils/forwardRef/index.js");require("../array.polyfill.flat-5BAolFdk.js");const re=1,T=9,K=4,$=2,oe=T-$;function ie(e,n,a=e,s=null){const h=s==="show-last"||s==="overflow"&&e>T,l=s==="overflow"&&e>T,c=Math.min(a,e),v=Math.max(0,n-Math.ceil((c-1)/2)),E=c<K?n:Math.max(0,n-Math.floor((c-1)/2)),m=(h?E:v)+c,d=m>=e,D=n<=K,I=(b,i)=>{const r=k(e,b,i);return c>2?(r[i-2]="dots",r[i-1]="hidden",r[e-1]="visible"):c>1&&(r[i-1]="dots"),r},g=(b,i)=>{if(D)return I(0,i);if(d){const _=k(e,e-oe,e);return _[0]="visible",_[1]="dots",_}const r=k(e,n-$,n+$+1);return r[0]="visible",r[1]=D?"visible":"dots",r[e-2]="dots",r[e-1]="visible",r};return d&&e<=T?k(e,e-c):h?l?g(E,m):I(E,m):k(e,v,m)}function ae(e,n,a,s="show-range"){if(e===-1)return[];const h=s==="overflow"?T:se(Math.min(a,n),re,T);return ie(a,e-1,h,s)}function se(e,n,a){return e<=n?n:e>=a?a:e}function k(e,n,a){return Array(e).fill("hidden").fill("visible",n,a)}function ce(e){if(!e)return 0;e.style.width="100vw";const n=e.offsetWidth;return e.style.width=null,n}const ue=({id:e="ebay-pagination",className:n,a11yCurrentText:a="Pagination - Current Page",a11yPreviousText:s="Previous page",a11yNextText:h="Next page",variant:l="show-range",fluid:c=!1,onPrevious:v=()=>{},onNext:E=()=>{},onSelect:m=()=>{},children:d,...D})=>{const I=t.useRef(null),g=t.useRef([]);g.current=t.Children.map(d,t.createRef);const b=te.filterBy(d,({props:o})=>o.type===void 0||o.type==="page").length,i=t.useRef(0),r=t.useRef(0),_=()=>{var y,N,x,p;const o=r.current||((N=(y=g.current[0])==null?void 0:y.current)==null?void 0:N.offsetWidth);r.current=o;const f=i.current||((p=(x=g.current[1])==null?void 0:x.current)==null?void 0:p.offsetWidth);return i.current=f,f?Math.floor((ce(I.current)-o*2)/f):0},[A,L]=t.useState([]),[w,q]=t.useState(0),S=o=>{const f=o||g.current.findIndex(x=>{var p;return((p=x.current)==null?void 0:p.getAttribute("aria-current"))==="page"}),y=_(),N=ae(f,y,b,l);q(f),L(["hidden",...N])};t.useEffect(()=>{const o=ee.debounce(S,16);return S(),window.addEventListener("resize",()=>o()),()=>{window.removeEventListener("resize",()=>o())}},[d]);const W=o=>{let f=0;const y=[],N=[],x=[],p=A.indexOf("dots"),F=A.lastIndexOf("dots");return t.Children.map(d,(j,M)=>{const{type:O="page",current:Q,disabled:Y,href:G,children:V}=j.props,B=A[M]==="dots",P=`${e}-item-${M}`,X=A[M]==="hidden",Z={current:Q,disabled:Y,href:G,type:B&&O==="page"?"separator":O,children:B?t.createElement(U.EbayIcon,{name:"overflowHorizontal24",focusable:!1}):V,pageIndex:O==="page"?f++:void 0,key:P,hide:X,onPrevious:v,onNext:E,onSelect:m,a11yPreviousText:s,a11yNextText:h,ref:g.current[M]};if((X||B)&&O==="page"){const C=t.createElement(J.EbayFakeMenuButtonItem,{key:P,href:G,onClick:z=>{G||z.preventDefault();const R=z.currentTarget;m(z,{value:(R==null?void 0:R.innerText)||"",index:f}),S(Number(R==null?void 0:R.innerText))}},V);p===F&&x.push(C),w-2>p&&M<w&&y.push(C),w+2<F&&M>w&&N.push(C)}if(o==="page"&&B&&l==="overflow"){let C=x;return p!==F&&(C=M===2?y:N),t.createElement("li",{key:P},t.createElement("span",{className:"pagination__item",role:"separator"},t.createElement(J.EbayMenuButton,{a11yText:"Menu",borderless:!0,variant:"overflow",noToggleIcon:!0},C)))}return o===O?t.cloneElement(j,Z):null})},u=`${e}-pagination-heading`;return t.createElement("nav",{...D,role:"navigation",className:H(n,"pagination",{"pagination--fluid":c}),"aria-labelledby":u,ref:I},t.createElement("span",{"aria-live":"polite",role:"status"},t.createElement("h2",{className:"clipped",id:u},a)),W("previous"),t.createElement("ol",{className:"pagination__items"},W("page")),W("next"))},le=({pageIndex:e=0,key:n,current:a,disabled:s,type:h="page",href:l,hide:c,children:v,a11yPreviousText:E="Previous page",a11yNextText:m="Next page",onSelect:d,onNext:D,onPrevious:I,className:g,style:b,forwardedRef:i,...r})=>{const _=u=>{var o;d(u,{value:((o=u.currentTarget)==null?void 0:o.innerText)||"",index:e})},A=u=>{u.currentTarget.getAttribute("aria-disabled")||D(u)},L=u=>{u.currentTarget.getAttribute("aria-disabled")||I(u)},w=!!l,q=w?"a":"button",S=w?"icon-link":"icon-btn",W={...b,minWidth:"40px"};switch(h){case"previous":return t.createElement(q,{...r,ref:i,"aria-disabled":s?"true":void 0,"aria-label":E,href:s?void 0:l,className:H(S,"pagination__previous"),style:W,onClick:L},t.createElement(U.EbayIcon,{name:"arrowLeft16"}));case"next":return t.createElement(q,{...r,ref:i,"aria-disabled":s?"true":void 0,"aria-label":m,href:s?void 0:l,className:H(S,"pagination__next"),style:W,onClick:A},t.createElement(U.EbayIcon,{name:"arrowRight16"}));case"separator":return t.createElement("span",{key:n,style:b,className:"pagination__item",ref:i,role:"separator"},v);default:return t.createElement("li",{...r,hidden:c},t.createElement(q,{ref:i,"aria-current":a?"page":void 0,href:l,className:"pagination__item",style:b,key:n,onClick:_},v))}},me=ne.withForwardRef(le);exports.EbayPagination=ue;exports.EbayPaginationItem=me;
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;