@ebay/ui-core-react 6.2.1 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/component-utils/array.polyfill.flat.js +11 -13
- package/common/component-utils/forwardRef.js +4 -17
- package/common/component-utils/usePrevious.js +3 -3
- package/common/component-utils/utils.js +13 -26
- package/common/debounce.js +3 -7
- package/common/event-utils/index.js +8 -11
- package/common/event-utils/use-key-press.js +10 -12
- package/common/event-utils/use-roving-index.js +13 -24
- package/common/floating-label-utils/hooks.js +43 -53
- package/common/notice-utils/notice-content.js +5 -6
- package/common/notice-utils/notice-cta.js +5 -16
- package/common/notice-utils/notice-footer.js +5 -16
- package/common/notice-utils/notice-title.js +6 -17
- package/common/random-id.js +1 -1
- package/common/range.js +1 -4
- package/common/tooltip-utils/tooltip-close-button.js +1 -1
- package/common/tooltip-utils/tooltip-content.js +16 -28
- package/common/tooltip-utils/tooltip-footer.js +3 -6
- package/common/tooltip-utils/tooltip-host.js +5 -16
- package/common/tooltip-utils/tooltip.d.ts +1 -1
- package/common/tooltip-utils/tooltip.js +14 -26
- package/common/tooltip-utils/use-tooltip.js +8 -9
- package/ebay-alert-dialog/alert-dialog.js +11 -22
- package/ebay-badge/badge.js +6 -17
- package/ebay-breadcrumbs/breadcrumb-item.js +7 -18
- package/ebay-breadcrumbs/breadcrumbs.js +19 -30
- package/ebay-button/button-cell.js +5 -16
- package/ebay-button/button-expand.d.ts +4 -2
- package/ebay-button/button-expand.d.ts.map +1 -1
- package/ebay-button/button-expand.js +7 -10
- package/ebay-button/button-loading.js +5 -5
- package/ebay-button/button-text.js +3 -6
- package/ebay-button/button.d.ts +1 -1
- package/ebay-button/button.js +31 -43
- package/ebay-calendar/calendar.js +94 -111
- package/ebay-calendar/date-utils.js +9 -18
- package/ebay-carousel/carousel-control-button.js +9 -10
- package/ebay-carousel/carousel-item.d.ts +1 -1
- package/ebay-carousel/carousel-item.js +14 -25
- package/ebay-carousel/carousel-list.js +21 -22
- package/ebay-carousel/carousel.js +32 -44
- package/ebay-carousel/helpers.js +35 -47
- package/ebay-carousel/scroll-to-transition.js +15 -15
- package/ebay-checkbox/checkbox.js +21 -32
- package/ebay-confirm-dialog/confirm-dialog.js +11 -22
- package/ebay-cta-button/cta-button.d.ts +1 -1
- package/ebay-cta-button/cta-button.js +9 -20
- package/ebay-date-textbox/date-textbox.js +37 -53
- package/ebay-dialog-base/components/animation.d.ts +0 -1
- package/ebay-dialog-base/components/animation.d.ts.map +1 -1
- package/ebay-dialog-base/components/animation.js +25 -28
- package/ebay-dialog-base/components/dialog-actions.js +2 -5
- package/ebay-dialog-base/components/dialog-close-button.d.ts +5 -2
- package/ebay-dialog-base/components/dialog-close-button.d.ts.map +1 -1
- package/ebay-dialog-base/components/dialog-close-button.js +2 -5
- package/ebay-dialog-base/components/dialog-footer.js +2 -5
- package/ebay-dialog-base/components/dialog-header.js +4 -15
- package/ebay-dialog-base/components/dialog-previous-button.js +6 -17
- package/ebay-dialog-base/components/dialogBase.js +40 -51
- package/ebay-dialog-base/dialog-base-with-state.js +22 -35
- package/ebay-drawer-dialog/components/drawer.js +27 -50
- package/ebay-eek/eek-rating.js +8 -10
- package/ebay-eek/eek-util.d.ts +1 -1
- package/ebay-eek/eek-util.d.ts.map +1 -1
- package/ebay-eek/eek-util.js +7 -6
- package/ebay-fake-menu/menu-item-separator.js +5 -16
- package/ebay-fake-menu/menu-item.js +15 -26
- package/ebay-fake-menu/menu.js +11 -22
- package/ebay-fake-menu-button/menu-button-item.js +2 -2
- package/ebay-fake-menu-button/menu-button-label.d.ts +4 -2
- package/ebay-fake-menu-button/menu-button-label.d.ts.map +1 -1
- package/ebay-fake-menu-button/menu-button-label.js +2 -5
- package/ebay-fake-menu-button/menu-button-separator.js +5 -16
- package/ebay-fake-menu-button/menu-button.js +32 -45
- package/ebay-fake-tabs/fake-tabs.js +10 -23
- package/ebay-fake-tabs/tab.js +5 -16
- package/ebay-field/description.js +7 -19
- package/ebay-field/field.js +4 -5
- package/ebay-field/label.js +7 -18
- package/ebay-fullscreen-dialog/fullscreen-dialog.js +7 -18
- package/ebay-icon/icon.d.ts +1 -1
- package/ebay-icon/icon.js +17 -29
- package/ebay-icon-button/icon-button.d.ts +1 -1
- package/ebay-icon-button/icon-button.js +15 -27
- package/ebay-infotip/ebay-infotip-content.js +2 -5
- package/ebay-infotip/ebay-infotip-heading.js +5 -16
- package/ebay-infotip/ebay-infotip-host.d.ts +2 -2
- package/ebay-infotip/ebay-infotip-host.d.ts.map +1 -1
- package/ebay-infotip/ebay-infotip-host.js +10 -24
- package/ebay-infotip/ebay-infotip.d.ts.map +1 -1
- package/ebay-infotip/ebay-infotip.js +23 -34
- package/ebay-inline-notice/inline-notice.js +15 -27
- package/ebay-lightbox-dialog/lightbox-dialog.js +9 -21
- package/ebay-listbox-button/listbox-button-option.js +7 -18
- package/ebay-listbox-button/listbox-button.d.ts.map +1 -1
- package/ebay-listbox-button/listbox-button.js +79 -100
- package/ebay-menu/menu-item-separator.js +5 -16
- package/ebay-menu/menu-item.js +12 -23
- package/ebay-menu/menu.d.ts +1 -1
- package/ebay-menu/menu.js +37 -64
- package/ebay-menu-button/README.md +1 -1
- package/ebay-menu-button/menu-button-item.js +1 -1
- package/ebay-menu-button/menu-button-label.d.ts +4 -2
- package/ebay-menu-button/menu-button-label.d.ts.map +1 -1
- package/ebay-menu-button/menu-button-label.js +2 -5
- package/ebay-menu-button/menu-button-separator.js +5 -16
- package/ebay-menu-button/menu-button.js +46 -60
- package/ebay-notice-base/components/ebay-notice-content/notice-content.js +1 -1
- package/ebay-notice-base/components/ebay-notice-title/notice-title.d.ts +5 -2
- package/ebay-notice-base/components/ebay-notice-title/notice-title.d.ts.map +1 -1
- package/ebay-notice-base/components/ebay-notice-title/notice-title.js +2 -5
- package/ebay-page-notice/page-notice-cta.js +3 -6
- package/ebay-page-notice/page-notice-footer.js +3 -6
- package/ebay-page-notice/page-notice-title.js +5 -16
- package/ebay-page-notice/page-notice.js +16 -27
- package/ebay-pagination/helpers.js +21 -24
- package/ebay-pagination/pagination-item.d.ts +1 -1
- package/ebay-pagination/pagination-item.js +16 -27
- package/ebay-pagination/pagination.js +52 -81
- package/ebay-panel-dialog/panel-dialog.js +9 -21
- package/ebay-progress-bar/progress-bar.js +5 -16
- package/ebay-progress-spinner/progress-spinner.js +7 -18
- package/ebay-progress-stepper/ebay-progress-step.js +14 -25
- package/ebay-progress-stepper/ebay-progress-stepper.js +10 -21
- package/ebay-progress-stepper/ebay-progress-title.js +2 -5
- package/ebay-radio/radio.js +18 -29
- package/ebay-section-notice/section-notice-footer.js +3 -6
- package/ebay-section-notice/section-notice-title.js +5 -16
- package/ebay-section-notice/section-notice.js +24 -39
- package/ebay-section-title/cta.js +5 -16
- package/ebay-section-title/info.js +5 -16
- package/ebay-section-title/overflow.js +5 -16
- package/ebay-section-title/section-title.js +13 -24
- package/ebay-section-title/subtitle.js +5 -16
- package/ebay-section-title/title.js +5 -16
- package/ebay-select/ebay-select-option.js +4 -15
- package/ebay-select/ebay-select.d.ts +1 -1
- package/ebay-select/ebay-select.js +34 -45
- package/ebay-signal/signal.js +6 -17
- package/ebay-snackbar-dialog/components/ebay-snackbar-dialog-action.js +5 -16
- package/ebay-snackbar-dialog/components/ebay-snackbar-dialog.js +27 -38
- package/ebay-split-button/split-button.js +10 -21
- package/ebay-star-rating/star-rating.js +8 -19
- package/ebay-star-rating-select/star-rating-select.js +20 -31
- package/ebay-svg/svg.js +3 -3
- package/ebay-switch/ebay-switch.js +10 -21
- package/ebay-tabs/tab-panel.js +5 -16
- package/ebay-tabs/tab.js +5 -16
- package/ebay-tabs/tabs.js +26 -40
- package/ebay-textbox/postfix-icon.js +7 -18
- package/ebay-textbox/prefix-icon.js +5 -16
- package/ebay-textbox/textbox.d.ts +1 -1
- package/ebay-textbox/textbox.js +42 -53
- package/ebay-toast-dialog/components/toast.js +6 -17
- package/ebay-tooltip/ebay-tooltip-content.js +1 -1
- package/ebay-tooltip/ebay-tooltip-host.js +1 -1
- package/ebay-tooltip/ebay-tooltip.js +21 -32
- package/ebay-tourtip/ebay-tourtip-content.js +1 -1
- package/ebay-tourtip/ebay-tourtip-footer.js +4 -7
- package/ebay-tourtip/ebay-tourtip-heading.js +6 -17
- package/ebay-tourtip/ebay-tourtip-host.js +1 -1
- package/ebay-tourtip/ebay-tourtip.js +22 -33
- package/ebay-video/controls.d.ts.map +1 -1
- package/ebay-video/controls.js +23 -46
- package/ebay-video/reportButton.d.ts +7 -2
- package/ebay-video/reportButton.d.ts.map +1 -1
- package/ebay-video/reportButton.js +5 -8
- package/ebay-video/source.js +3 -14
- package/ebay-video/video.d.ts.map +1 -1
- package/ebay-video/video.js +54 -80
- package/package.json +23 -18
package/ebay-menu/menu-item.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -48,28 +37,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
38
|
};
|
|
50
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
(0, react_1.useEffect)(
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
42
|
+
const ebay_badge_1 = require("../ebay-badge");
|
|
43
|
+
const ebay_icon_1 = require("../ebay-icon");
|
|
44
|
+
const EbayMenuItem = (_a) => {
|
|
45
|
+
var { className, checked, type, focused = false, tabIndex, disabled, badgeNumber, badgeAriaLabel, children } = _a, rest = __rest(_a, ["className", "checked", "type", "focused", "tabIndex", "disabled", "badgeNumber", "badgeAriaLabel", "children"]);
|
|
46
|
+
const ref = (0, react_1.useRef)(null);
|
|
47
|
+
const hasBadge = badgeNumber !== undefined;
|
|
48
|
+
(0, react_1.useEffect)(() => {
|
|
60
49
|
if (ref.current && focused) {
|
|
61
50
|
ref.current.focus();
|
|
62
51
|
}
|
|
63
52
|
}, [ref, focused]);
|
|
64
|
-
|
|
65
|
-
return (react_1.default.createElement("div",
|
|
53
|
+
const checkable = ['radio', 'checkbox'];
|
|
54
|
+
return (react_1.default.createElement("div", Object.assign({ "aria-label": badgeAriaLabel }, rest, { ref: ref, className: (0, classnames_1.default)(className, 'menu__item', hasBadge && 'menu__item--badged'), role: roleFromType(type), "aria-checked": checkable.includes(type) ? checked : undefined, "aria-disabled": disabled, tabIndex: focused ? 0 : tabIndex }),
|
|
66
55
|
react_1.default.createElement("span", { "aria-hidden": hasBadge },
|
|
67
56
|
children,
|
|
68
57
|
hasBadge && react_1.default.createElement(ebay_badge_1.EbayBadge, { type: "menu", number: badgeNumber })),
|
|
69
58
|
react_1.default.createElement(ebay_icon_1.EbayIcon, { name: "tick16" })));
|
|
70
59
|
};
|
|
71
60
|
function roleFromType(type) {
|
|
72
|
-
|
|
61
|
+
const roles = {
|
|
73
62
|
radio: 'menuitemradio',
|
|
74
63
|
checkbox: 'menuitemcheckbox'
|
|
75
64
|
};
|
package/ebay-menu/menu.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { EbayMenuProps } from './index';
|
|
3
|
-
declare const _default: React.ForwardRefExoticComponent<
|
|
3
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<EbayMenuProps, "ref"> & React.RefAttributes<React.FC<EbayMenuProps>>>;
|
|
4
4
|
export default _default;
|
|
5
5
|
//# sourceMappingURL=menu.d.ts.map
|
package/ebay-menu/menu.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -44,48 +33,32 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
44
33
|
}
|
|
45
34
|
return t;
|
|
46
35
|
};
|
|
47
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
48
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
49
|
-
if (ar || !(i in from)) {
|
|
50
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
51
|
-
ar[i] = from[i];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
55
|
-
};
|
|
56
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
57
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
58
38
|
};
|
|
59
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
76
|
-
var indexesFromChecked = function (indexes) {
|
|
77
|
-
return indexes.reduce(function (all, value, i) { return value ? __spreadArray(__spreadArray([], all, true), [i], false) : all; }, []);
|
|
78
|
-
};
|
|
79
|
-
var eventProps = function (index, indexes) { return ({
|
|
80
|
-
index: index,
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
42
|
+
const use_roving_index_1 = __importDefault(require("../common/event-utils/use-roving-index"));
|
|
43
|
+
const event_utils_1 = require("../common/event-utils");
|
|
44
|
+
const component_utils_1 = require("../common/component-utils");
|
|
45
|
+
const index_1 = require("./index");
|
|
46
|
+
const EbayMenu = (_a) => {
|
|
47
|
+
var { baseEl: Container = 'span', type, priority = 'secondary', checked, className, autofocus, onClick = () => { }, onKeyDown = () => { }, onChange = () => { }, onSelect = () => { }, forwardedRef, children } = _a, rest = __rest(_a, ["baseEl", "type", "priority", "checked", "className", "autofocus", "onClick", "onKeyDown", "onChange", "onSelect", "forwardedRef", "children"]);
|
|
48
|
+
const childrenArray = react_1.Children.toArray(children);
|
|
49
|
+
const [focusedIndex, setFocusedIndex] = (0, use_roving_index_1.default)(children, index_1.EbayMenuItem, autofocus === true ? 0 : undefined);
|
|
50
|
+
const [checkedIndexes, setCheckedIndexes] = (0, react_1.useState)(childrenArray.map(() => false));
|
|
51
|
+
const valuesFromChecked = (indexes) => childrenArray.reduce((values, item, i) => indexes[i] ? [...values, item.props.value] : values, []);
|
|
52
|
+
const indexesFromChecked = (indexes) => indexes.reduce((all, value, i) => value ? [...all, i] : all, []);
|
|
53
|
+
const eventProps = (index, indexes) => ({
|
|
54
|
+
index,
|
|
81
55
|
checked: indexesFromChecked(indexes)
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var defaultValue = resetOthers ? false : indexChecked;
|
|
56
|
+
});
|
|
57
|
+
const checkboxEventProps = (index, indexes) => (Object.assign(Object.assign({}, eventProps(index, indexes)), { indexes: indexesFromChecked(indexes), checkedValues: valuesFromChecked(indexes) }));
|
|
58
|
+
const updateIndex = (index, value, resetOthers = false) => {
|
|
59
|
+
let anyChanges = false;
|
|
60
|
+
const newValues = checkedIndexes.map((indexChecked, i) => {
|
|
61
|
+
const defaultValue = resetOthers ? false : indexChecked;
|
|
89
62
|
if (index === i) {
|
|
90
63
|
if (indexChecked !== value) {
|
|
91
64
|
anyChanges = true;
|
|
@@ -99,20 +72,20 @@ var EbayMenu = function (_a) {
|
|
|
99
72
|
return newValues;
|
|
100
73
|
}
|
|
101
74
|
};
|
|
102
|
-
|
|
75
|
+
const selectIndex = (index) => {
|
|
103
76
|
switch (type) {
|
|
104
77
|
case 'radio':
|
|
105
78
|
return updateIndex(index, true, true);
|
|
106
79
|
case 'checkbox':
|
|
107
80
|
return updateIndex(index, !checkedIndexes[index], false);
|
|
108
81
|
default:
|
|
109
|
-
return checkedIndexes.map(
|
|
82
|
+
return checkedIndexes.map((_, i) => i === index);
|
|
110
83
|
}
|
|
111
84
|
};
|
|
112
|
-
(0, react_1.useEffect)(
|
|
85
|
+
(0, react_1.useEffect)(() => {
|
|
113
86
|
if (type === 'radio') {
|
|
114
87
|
if (checked === undefined) {
|
|
115
|
-
|
|
88
|
+
const checkedIndex = childrenArray.findIndex(child => child.props.checked);
|
|
116
89
|
if (checkedIndex > -1) {
|
|
117
90
|
selectIndex(checkedIndex);
|
|
118
91
|
}
|
|
@@ -122,10 +95,10 @@ var EbayMenu = function (_a) {
|
|
|
122
95
|
}
|
|
123
96
|
}
|
|
124
97
|
else if (type === 'checkbox') {
|
|
125
|
-
setCheckedIndexes(childrenArray.map(
|
|
98
|
+
setCheckedIndexes(childrenArray.map(child => Boolean(child.props.checked)));
|
|
126
99
|
}
|
|
127
100
|
}, []);
|
|
128
|
-
|
|
101
|
+
const handleChange = (e, index, newValues) => {
|
|
129
102
|
switch (type) {
|
|
130
103
|
case 'radio':
|
|
131
104
|
case 'checkbox':
|
|
@@ -134,8 +107,8 @@ var EbayMenu = function (_a) {
|
|
|
134
107
|
return onSelect(e, eventProps(index, newValues));
|
|
135
108
|
}
|
|
136
109
|
};
|
|
137
|
-
|
|
138
|
-
|
|
110
|
+
const handleKeyDown = (e, index) => {
|
|
111
|
+
let newValues;
|
|
139
112
|
if ((0, event_utils_1.isActionKey)(e.key)) {
|
|
140
113
|
newValues = selectIndex(index);
|
|
141
114
|
if (newValues) {
|
|
@@ -150,24 +123,24 @@ var EbayMenu = function (_a) {
|
|
|
150
123
|
return onKeyDown(e, eventProps(index, newValues || checkedIndexes));
|
|
151
124
|
}
|
|
152
125
|
};
|
|
153
|
-
|
|
126
|
+
const handleClick = (e, index) => {
|
|
154
127
|
setFocusedIndex(index);
|
|
155
|
-
|
|
128
|
+
const newValues = selectIndex(index);
|
|
156
129
|
if (newValues) {
|
|
157
130
|
handleChange(e, index, newValues);
|
|
158
131
|
}
|
|
159
132
|
};
|
|
160
|
-
return (react_1.default.createElement(Container,
|
|
161
|
-
react_1.default.createElement("div", { className: "menu__items", role: "menu", ref: forwardedRef }, childrenArray.map(
|
|
162
|
-
|
|
163
|
-
return (0, react_1.cloneElement)(child,
|
|
133
|
+
return (react_1.default.createElement(Container, Object.assign({}, rest, { className: (0, classnames_1.default)(className, 'menu') }),
|
|
134
|
+
react_1.default.createElement("div", { className: "menu__items", role: "menu", ref: forwardedRef }, childrenArray.map((child, i) => {
|
|
135
|
+
const _a = child.props, { onClick: onItemClick = () => { }, onFocus: onItemFocus = () => { }, onKeyDown: onItemKeyDown = () => { } } = _a, itemRest = __rest(_a, ["onClick", "onFocus", "onKeyDown"]);
|
|
136
|
+
return (0, react_1.cloneElement)(child, Object.assign(Object.assign({}, itemRest), { type, focused: i === focusedIndex, tabIndex: focusedIndex === undefined ? 0 : -1, checked: checkedIndexes[i], onFocus: e => {
|
|
164
137
|
setFocusedIndex(i);
|
|
165
138
|
onItemFocus(e);
|
|
166
|
-
}, onClick:
|
|
139
|
+
}, onClick: e => {
|
|
167
140
|
handleClick(e, i);
|
|
168
141
|
onItemClick(e);
|
|
169
142
|
onClick(e);
|
|
170
|
-
}, onKeyDown:
|
|
143
|
+
}, onKeyDown: e => {
|
|
171
144
|
handleKeyDown(e, i);
|
|
172
145
|
onItemKeyDown(e);
|
|
173
146
|
} }));
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
declare const EbayMenuButtonLabel: FC
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
declare const EbayMenuButtonLabel: FC<{
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
}>;
|
|
3
5
|
export default EbayMenuButtonLabel;
|
|
4
6
|
//# sourceMappingURL=menu-button-label.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-button-label.d.ts","sourceRoot":"","sources":["../../src/ebay-menu-button/menu-button-label.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"menu-button-label.d.ts","sourceRoot":"","sources":["../../src/ebay-menu-button/menu-button-label.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAE5C,QAAA,MAAM,mBAAmB,EAAE,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,CAAqC,CAAA;AAE3F,eAAe,mBAAmB,CAAA"}
|
|
@@ -3,9 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var children = _a.children;
|
|
9
|
-
return react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
10
|
-
};
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const EbayMenuButtonLabel = ({ children }) => react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
11
8
|
exports.default = EbayMenuButtonLabel;
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
3
|
var t = {};
|
|
15
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -25,10 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
15
|
};
|
|
27
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var className = _a
|
|
32
|
-
return (react_1.default.createElement("hr",
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
19
|
+
const EbayMenuButtonSeparator = (_a) => {
|
|
20
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
21
|
+
return (react_1.default.createElement("hr", Object.assign({}, rest, { className: (0, classnames_1.default)(className, 'menu-button__separator'), role: "separator" })));
|
|
33
22
|
};
|
|
34
23
|
exports.default = EbayMenuButtonSeparator;
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -48,37 +37,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
38
|
};
|
|
50
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
42
|
+
const component_utils_1 = require("../common/component-utils");
|
|
43
|
+
const ebay_menu_1 = require("../ebay-menu");
|
|
44
|
+
const ebay_button_1 = require("../ebay-button");
|
|
45
|
+
const ebay_icon_button_1 = require("../ebay-icon-button");
|
|
46
|
+
const ebay_icon_1 = require("../ebay-icon");
|
|
47
|
+
const index_1 = require("./index");
|
|
48
|
+
const random_id_1 = require("../common/random-id");
|
|
49
|
+
const event_utils_1 = require("../common/event-utils");
|
|
50
|
+
const EbayMenuButton = (_a) => {
|
|
51
|
+
var { type, variant = 'button', className, text = '', fixWidth, reverse, expanded: defaultExpanded, noToggleIcon, checked, collapseOnSelect, a11yText, prefixId, prefixLabel, onClick = () => { }, onExpand = () => { }, onCollapse = () => { }, onChange = () => { }, onSelect = () => { }, children } = _a, rest = __rest(_a, ["type", "variant", "className", "text", "fixWidth", "reverse", "expanded", "noToggleIcon", "checked", "collapseOnSelect", "a11yText", "prefixId", "prefixLabel", "onClick", "onExpand", "onCollapse", "onChange", "onSelect", "children"]);
|
|
52
|
+
const [expanded, setExpanded] = (0, react_1.useState)(defaultExpanded);
|
|
53
|
+
const [menuId, setMenuId] = (0, react_1.useState)();
|
|
54
|
+
const buttonRef = (0, react_1.useRef)(null);
|
|
55
|
+
const menuRef = (0, react_1.useRef)();
|
|
56
|
+
const menuItems = (0, component_utils_1.filterByType)(children, [index_1.EbayMenuButtonItem, index_1.EbayMenuButtonSeparator]);
|
|
57
|
+
const defaultIndexes = menuItems.map((item) => Boolean(item.props.checked));
|
|
58
|
+
const [checkedIndexes, setCheckedIndexes] = (0, react_1.useState)(defaultIndexes);
|
|
59
|
+
const menuButtonLabel = (0, component_utils_1.findComponent)(children, index_1.EbayMenuButtonLabel);
|
|
60
|
+
const icon = (0, component_utils_1.findComponent)(children, ebay_icon_1.EbayIcon);
|
|
61
|
+
const label = labelWithPrefixAndIcon({ text, prefixId, prefixLabel, menuButtonLabel, icon });
|
|
62
|
+
const wrapperClasses = (0, classnames_1.default)('menu-button', className);
|
|
63
|
+
const menuClasses = (0, classnames_1.default)('menu-button__menu', {
|
|
75
64
|
'menu-button__menu--fix-width': fixWidth,
|
|
76
65
|
'menu-button__menu--reverse': reverse
|
|
77
66
|
});
|
|
78
|
-
(0, react_1.useEffect)(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
67
|
+
(0, react_1.useEffect)(() => {
|
|
68
|
+
const handleBackgroundClick = (e) => {
|
|
69
|
+
const menuEl = menuRef.current;
|
|
70
|
+
const menuClicked = menuEl && menuEl.contains(e.target);
|
|
82
71
|
if (collapseOnSelect || !menuClicked) {
|
|
83
72
|
setExpanded(false);
|
|
84
73
|
}
|
|
@@ -89,58 +78,55 @@ var EbayMenuButton = function (_a) {
|
|
|
89
78
|
// causing the event listener to be attached to the document at the same time that the dialog
|
|
90
79
|
// opens. Adding a timeout so the event is attached after the click event that opened the modal
|
|
91
80
|
// is finished.
|
|
92
|
-
setTimeout(
|
|
81
|
+
setTimeout(() => {
|
|
93
82
|
document.addEventListener('click', handleBackgroundClick, false);
|
|
94
83
|
});
|
|
95
84
|
}
|
|
96
85
|
else if (expanded === false) {
|
|
97
86
|
onCollapse();
|
|
98
87
|
}
|
|
99
|
-
return
|
|
88
|
+
return () => document.removeEventListener('click', handleBackgroundClick, false);
|
|
100
89
|
}, [expanded]);
|
|
101
|
-
(0, react_1.useEffect)(
|
|
90
|
+
(0, react_1.useEffect)(() => {
|
|
102
91
|
setMenuId((0, random_id_1.randomId)());
|
|
103
92
|
}, []);
|
|
104
|
-
|
|
105
|
-
(0, event_utils_1.handleEscapeKeydown)(e,
|
|
93
|
+
const handleMenuKeydown = (e) => {
|
|
94
|
+
(0, event_utils_1.handleEscapeKeydown)(e, () => {
|
|
106
95
|
var _a;
|
|
107
96
|
setExpanded(false);
|
|
108
97
|
(_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
109
98
|
});
|
|
110
99
|
};
|
|
111
|
-
|
|
100
|
+
const buttonProps = Object.assign({ ref: buttonRef, className: 'menu-button__button', 'aria-expanded': !!expanded, 'aria-haspopup': true, 'aria-label': a11yText, 'aria-controls': menuId, 'aria-labelledby': prefixId, onClick: e => {
|
|
112
101
|
setExpanded(!expanded);
|
|
113
102
|
onClick(e);
|
|
114
103
|
} }, rest);
|
|
115
|
-
|
|
104
|
+
const handleOnChange = (e, eventProps) => {
|
|
116
105
|
if (type === 'radio' || type === 'checkbox') {
|
|
117
|
-
|
|
106
|
+
const newCheckedIndexes = checkedIndexes.map((_, i) => eventProps.indexes.includes(i));
|
|
118
107
|
setCheckedIndexes(newCheckedIndexes);
|
|
119
108
|
}
|
|
120
109
|
onChange(e, eventProps);
|
|
121
110
|
};
|
|
122
|
-
|
|
123
|
-
|
|
111
|
+
const checkedIndex = () => {
|
|
112
|
+
const index = checkedIndexes.findIndex(Boolean);
|
|
124
113
|
return index > -1 ? index : checked;
|
|
125
114
|
};
|
|
126
115
|
return (react_1.default.createElement("span", { className: wrapperClasses },
|
|
127
116
|
variant === 'overflow' ?
|
|
128
|
-
react_1.default.createElement(ebay_icon_button_1.EbayIconButton,
|
|
129
|
-
react_1.default.createElement(ebay_button_1.EbayButton,
|
|
117
|
+
react_1.default.createElement(ebay_icon_button_1.EbayIconButton, Object.assign({ icon: "overflowVertical16" }, buttonProps)) :
|
|
118
|
+
react_1.default.createElement(ebay_button_1.EbayButton, Object.assign({ variant: variant === 'form' ? 'form' : undefined, bodyState: noToggleIcon ? undefined : 'expand' }, buttonProps), label),
|
|
130
119
|
expanded &&
|
|
131
|
-
react_1.default.createElement(ebay_menu_1.EbayMenu, { baseEl: "div", ref: menuRef, type: type, className: menuClasses, tabIndex: -1, id: menuId, autofocus: true, checked: checkedIndex(), onKeyDown: handleMenuKeydown, onChange: handleOnChange, onSelect: onSelect }, menuItems.map(
|
|
132
|
-
return (0, react_1.cloneElement)(item, __assign(__assign({}, item.props), { className: (0, classnames_1.default)(item.props.className, 'menu-button__item'), key: i, checked: checkedIndexes[i] }));
|
|
133
|
-
}))));
|
|
120
|
+
react_1.default.createElement(ebay_menu_1.EbayMenu, { baseEl: "div", ref: menuRef, type: type, className: menuClasses, tabIndex: -1, id: menuId, autofocus: true, checked: checkedIndex(), onKeyDown: handleMenuKeydown, onChange: handleOnChange, onSelect: onSelect }, menuItems.map((item, i) => (0, react_1.cloneElement)(item, Object.assign(Object.assign({}, item.props), { className: (0, classnames_1.default)(item.props.className, 'menu-button__item'), key: i, checked: checkedIndexes[i] }))))));
|
|
134
121
|
};
|
|
135
|
-
function labelWithPrefixAndIcon(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
var prefixLabelElement = !prefixId && prefixLabel && [
|
|
122
|
+
function labelWithPrefixAndIcon({ text, prefixId, prefixLabel, menuButtonLabel, icon }) {
|
|
123
|
+
const textLabelElement = text.length ? react_1.default.createElement("span", null, text) : null;
|
|
124
|
+
const prefixLabelElement = !prefixId && prefixLabel && [
|
|
139
125
|
react_1.default.createElement("span", { className: "menu-button-prefix-label" }, prefixLabel),
|
|
140
126
|
react_1.default.createElement(react_1.default.Fragment, null, "\u00A0")
|
|
141
127
|
];
|
|
142
|
-
|
|
143
|
-
|
|
128
|
+
const labelWithPrefix = [prefixLabelElement, menuButtonLabel || textLabelElement];
|
|
129
|
+
const labelArray = [icon, labelWithPrefix].flat().filter(Boolean);
|
|
144
130
|
return labelArray.length ? labelArray : null;
|
|
145
131
|
}
|
|
146
132
|
exports.default = EbayMenuButton;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
type EbayNoticeTitleProps = {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
};
|
|
5
|
+
declare const EbayNoticeTitle: ({ children }: EbayNoticeTitleProps) => ReactNode;
|
|
3
6
|
export default EbayNoticeTitle;
|
|
4
7
|
//# sourceMappingURL=notice-title.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notice-title.d.ts","sourceRoot":"","sources":["../../../../src/ebay-notice-base/components/ebay-notice-title/notice-title.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"notice-title.d.ts","sourceRoot":"","sources":["../../../../src/ebay-notice-base/components/ebay-notice-title/notice-title.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAExC,KAAK,oBAAoB,GAAG;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,CAAA;AAED,QAAA,MAAM,eAAe,iBAAkB,oBAAoB,KAAG,SAI7D,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -3,9 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var children = _a.children;
|
|
9
|
-
return (react_1.default.createElement("span", { className: "page-notice__title" }, children));
|
|
10
|
-
};
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const EbayNoticeTitle = ({ children }) => (react_1.default.createElement("span", { className: "page-notice__title" }, children));
|
|
11
8
|
exports.default = EbayNoticeTitle;
|
|
@@ -3,10 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var className = _a.className, children = _a.children;
|
|
10
|
-
return (react_1.default.createElement(notice_cta_1.default, { className: className, type: "page" }, children));
|
|
11
|
-
};
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const notice_cta_1 = __importDefault(require("../common/notice-utils/notice-cta"));
|
|
8
|
+
const EbayPageNoticeCTA = ({ className, children }) => (react_1.default.createElement(notice_cta_1.default, { className: className, type: "page" }, children));
|
|
12
9
|
exports.default = EbayPageNoticeCTA;
|
|
@@ -3,10 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var className = _a.className, children = _a.children;
|
|
10
|
-
return (react_1.default.createElement(notice_footer_1.default, { className: className, type: "page" }, children));
|
|
11
|
-
};
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const notice_footer_1 = __importDefault(require("../common/notice-utils/notice-footer"));
|
|
8
|
+
const EbayPageNoticeFooter = ({ className, children }) => (react_1.default.createElement(notice_footer_1.default, { className: className, type: "page" }, children));
|
|
12
9
|
exports.default = EbayPageNoticeFooter;
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
3
|
var t = {};
|
|
15
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -25,10 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
15
|
};
|
|
27
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
return (react_1.default.createElement(notice_title_1.default,
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const notice_title_1 = __importDefault(require("../common/notice-utils/notice-title"));
|
|
19
|
+
const EbayPageNoticeTitle = (_a) => {
|
|
20
|
+
var { className, as, children } = _a, rest = __rest(_a, ["className", "as", "children"]);
|
|
21
|
+
return (react_1.default.createElement(notice_title_1.default, Object.assign({}, rest, { className: className, as: as, type: "page" }), children));
|
|
33
22
|
};
|
|
34
23
|
exports.default = EbayPageNoticeTitle;
|