@ebay/ui-core-react 5.8.0 → 5.9.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.
@@ -29,10 +29,13 @@ import '@ebay/skin/menu';
29
29
 
30
30
  ## EbayFakeMenuItem Props
31
31
 
32
- Name | Type | Required | Description
33
- --- | --- | --- | ---
34
- `href` | String | No | Redirection link on click
32
+ Name | Type | Required | Description
33
+ --- |---------| --- | ---
34
+ `href` | String | No | Redirection link on click
35
+ `type` | String | No | Set to `button` to render menu-item as a button instead of a link
35
36
  `current` | Boolean | No | Whether or not the href is the current href of the page
37
+ `badgeNumber` | Number | No | Used as a number to be placed inside the badge
38
+ `badgeAriaLabel` | Number | No | Only if `badgeNumber` provided, passed as the `aria-label` directly to the badge
36
39
 
37
40
  ## EbayFakeMenuSeparator
38
41
  Example:
@@ -1,4 +1,4 @@
1
1
  export { default as EbayFakeMenu } from './menu';
2
- export { default as EbayFakeMenuItem, EbayFakeMenuItemProps } from './menu-item';
2
+ export { default as EbayFakeMenuItem, EbayFakeMenuItemProps, EbayMenuItemType } from './menu-item';
3
3
  export { default as EbayFakeMenuSeparator } from './menu-item-separator';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ebay-fake-menu/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAChF,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,uBAAuB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ebay-fake-menu/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAClG,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,uBAAuB,CAAA"}
@@ -1,8 +1,12 @@
1
1
  import { ComponentProps, FC } from 'react';
2
- export type EbayFakeMenuItemProps = Omit<ComponentProps<'a'>, 'onKeyDown' | 'onMouseDown'> & {
2
+ export type EbayMenuItemType = 'button';
3
+ export type EbayFakeMenuItemProps = Omit<ComponentProps<'a'>, 'onKeyDown' | 'onMouseDown'> & Omit<ComponentProps<'button'>, 'onKeyDown' | 'onMouseDown'> & {
3
4
  current?: boolean;
4
5
  disabled?: boolean;
5
6
  autoFocus?: boolean;
7
+ type?: EbayMenuItemType;
8
+ badgeNumber?: number;
9
+ badgeAriaLabel?: string;
6
10
  };
7
11
  declare const EbayMenuItem: FC<EbayFakeMenuItemProps>;
8
12
  export default EbayMenuItem;
@@ -1 +1 @@
1
- {"version":3,"file":"menu-item.d.ts","sourceRoot":"","sources":["../../src/ebay-fake-menu/menu-item.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,cAAc,EAAE,EAAE,EAAqB,MAAM,OAAO,CAAA;AAIpE,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GAAG;IACzF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB,CAAA;AAED,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,qBAAqB,CA6B3C,CAAA;AAED,eAAe,YAAY,CAAA"}
1
+ {"version":3,"file":"menu-item.d.ts","sourceRoot":"","sources":["../../src/ebay-fake-menu/menu-item.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,cAAc,EAAE,EAAE,EAAqB,MAAM,OAAO,CAAA;AAKpE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAA;AACvC,MAAM,MAAM,qBAAqB,GAC7B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GACtD,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GAC3D;IACI,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAA;AAEL,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,qBAAqB,CA+D3C,CAAA;AAED,eAAe,YAAY,CAAA"}
@@ -51,17 +51,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
51
51
  var react_1 = __importStar(require("react"));
52
52
  var classnames_1 = __importDefault(require("classnames"));
53
53
  var ebay_icon_1 = require("../ebay-icon");
54
+ var ebay_badge_1 = require("../ebay-badge");
54
55
  var EbayMenuItem = function (_a) {
55
- var className = _a.className, current = _a.current, disabled = _a.disabled, autoFocus = _a.autoFocus, children = _a.children, rest = __rest(_a, ["className", "current", "disabled", "autoFocus", "children"]);
56
+ var className = _a.className, current = _a.current, disabled = _a.disabled, autoFocus = _a.autoFocus, type = _a.type, badgeNumber = _a.badgeNumber, badgeAriaLabel = _a.badgeAriaLabel, children = _a.children, rest = __rest(_a, ["className", "current", "disabled", "autoFocus", "type", "badgeNumber", "badgeAriaLabel", "children"]);
56
57
  var ref = (0, react_1.useRef)();
58
+ var hasBadge = badgeNumber !== undefined;
57
59
  (0, react_1.useEffect)(function () {
58
60
  var _a;
59
61
  if (autoFocus) {
60
62
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
61
63
  }
62
64
  });
63
- return (react_1.default.createElement("a", __assign({}, rest, { ref: ref, className: (0, classnames_1.default)(className, 'fake-menu__item'), "aria-disabled": disabled ? 'true' : undefined }),
64
- react_1.default.createElement("span", null, children),
65
- react_1.default.createElement(ebay_icon_1.EbayIcon, { name: "tick16" })));
65
+ var itemProps = __assign(__assign({}, rest), { ref: ref, className: (0, classnames_1.default)(className, 'fake-menu__item', hasBadge && 'menu__item--badged'), 'aria-label': badgeAriaLabel });
66
+ var tick = react_1.default.createElement(ebay_icon_1.EbayIcon, { name: "tick16" });
67
+ // todo: remove this workaround when Skin team fixes https://github.com/eBay/skin/issues/2208
68
+ var badgeStyleFix = {
69
+ marginLeft: 'var(--spacing-100)',
70
+ marginRight: 'var(--spacing-100)'
71
+ };
72
+ var badge = hasBadge && react_1.default.createElement(ebay_badge_1.EbayBadge, { type: "menu", number: badgeNumber, style: badgeStyleFix });
73
+ return type === 'button' ? (react_1.default.createElement("button", __assign({}, itemProps, { type: "button", disabled: disabled }),
74
+ react_1.default.createElement("span", null,
75
+ children,
76
+ badge),
77
+ tick)) : (react_1.default.createElement("a", __assign({}, itemProps, { "aria-disabled": disabled ? 'true' : undefined }),
78
+ react_1.default.createElement("span", null,
79
+ children,
80
+ badge),
81
+ tick));
66
82
  };
67
83
  exports.default = EbayMenuItem;
@@ -33,13 +33,13 @@ Name | Type | Required | Description
33
33
 
34
34
  ## EbayMenuItem Props
35
35
 
36
- Name | Type | Required | Description
37
- --- | --- | --- | ---
38
- `value` | String | No | for type `radio`, `checkbox`: the value to use with callbacks for `checkedValues[]`
39
- `checked` | Boolean | No | for type `radio`, `checkbox`: whether or not the item is checked
40
- `disabled` | Boolean | No | makes the menu item disabled
41
- `badgeNumber` | Number | No | used as the number to be placed in the badge
42
- `badgeAriaLabel` | String | If `badgeNumber` provided | passed as the `aria-label` directly to the badge
36
+ Name | Type | Required | Description
37
+ --- | --- |---------------------------------| ---
38
+ `value` | String | No | for type `radio`, `checkbox`: the value to use with callbacks for `checkedValues[]`
39
+ `checked` | Boolean | No | for type `radio`, `checkbox`: whether or not the item is checked
40
+ `disabled` | Boolean | No | makes the menu item disabled
41
+ `badgeNumber` | Number | No | used as the number to be placed in the badge
42
+ `badgeAriaLabel` | String | Only if `badgeNumber` provided, passed as the `aria-label` directly to the badge
43
43
 
44
44
  ## EbayMenuSeparator
45
45
  Example:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebay/ui-core-react",
3
- "version": "5.8.0",
3
+ "version": "5.9.0",
4
4
  "description": "Skin components build off React",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"