carbon-react 154.11.4 → 154.12.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.
@@ -11,6 +11,8 @@ export interface BadgeProps extends TagProps {
11
11
  color?: string;
12
12
  /** Callback fired when badge is clicked */
13
13
  onClick?: (ev: React.MouseEvent<HTMLElement>) => void;
14
+ /** Unique identifier for the component. */
15
+ id?: string;
14
16
  }
15
- export declare const Badge: ({ "aria-label": ariaLabel, children, counter, color, onClick, "data-element": dataElement, "data-role": dataRole, }: BadgeProps) => React.JSX.Element;
17
+ export declare const Badge: ({ "aria-label": ariaLabel, children, counter, color, onClick, id, "data-element": dataElement, "data-role": dataRole, }: BadgeProps) => React.JSX.Element;
16
18
  export default Badge;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as r}from"react";import{StyledBadgeWrapper as o,StyledBadge as n,StyledCrossIcon as c,StyledCounter as a}from"./badge.style.js";function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const i=({"aria-label":i,children:s,counter:u=0,color:b="--colorsActionMajor500",onClick:p,"data-element":d,"data-role":y})=>{const O=+u>0,f=+u>99?99:u,[m,j]=r(!1),[g,P]=r(!1);return e(o,{children:[s,O?e(n,(w=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){l(e,t,r[t])}))}return e}({"data-component":"badge","data-element":d,"data-role":y,color:b},p?{buttonType:"secondary",onClick:p}:{"aria-label":i}),h={onFocus:()=>{j(!0)},onBlur:()=>{j(!1)},onMouseEnter:()=>{P(!0)},onMouseLeave:()=>{P(!1)},isFocused:m,isHovered:g,children:[p&&t(c,{"data-element":"badge-cross-icon",type:"cross"}),t(a,{"data-element":"badge-counter",children:f})]},h=null!=h?h:{},Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(h)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(h)).forEach((function(e){Object.defineProperty(w,e,Object.getOwnPropertyDescriptor(h,e))})),w)):null]});var w,h};export{i as Badge,i as default};
1
+ import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useState as t,useRef as o}from"react";import{StyledBadgeWrapper as n,StyledBadge as c,StyledCrossIcon as a,StyledCounter as i}from"./badge.style.js";import l from"../../__internal__/utils/helpers/guid/index.js";function s(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}const u=({"aria-label":u,children:b,counter:p=0,color:d="--colorsActionMajor500",onClick:f,id:y,"data-element":O,"data-role":m})=>{const j=+p>0,g=+p>99?99:p,[P,h]=t(!1),[w,v]=t(!1),{current:k}=o(y||l());return e(n,{children:[b,j?e(c,(D=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(r){s(e,r,t[r])}))}return e}({"data-component":"badge","data-element":O,"data-role":m,color:d,id:k,"aria-label":u,onFocus:()=>{h(!0)},onBlur:()=>{h(!1)},onMouseEnter:()=>{v(!0)},onMouseLeave:()=>{v(!1)},isFocused:P,isHovered:w},f&&{buttonType:"secondary",onClick:f}),S={children:[f&&r(a,{"data-element":"badge-cross-icon",type:"cross"}),r(i,{"data-element":"badge-counter",children:g})]},S=null!=S?S:{},Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(S)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(S)).forEach((function(e){Object.defineProperty(D,e,Object.getOwnPropertyDescriptor(S,e))})),D)):null]});var D,S};export{u as Badge,u as default};
@@ -11,6 +11,8 @@ export interface BadgeProps extends TagProps {
11
11
  color?: string;
12
12
  /** Callback fired when badge is clicked */
13
13
  onClick?: (ev: React.MouseEvent<HTMLElement>) => void;
14
+ /** Unique identifier for the component. */
15
+ id?: string;
14
16
  }
15
- export declare const Badge: ({ "aria-label": ariaLabel, children, counter, color, onClick, "data-element": dataElement, "data-role": dataRole, }: BadgeProps) => React.JSX.Element;
17
+ export declare const Badge: ({ "aria-label": ariaLabel, children, counter, color, onClick, id, "data-element": dataElement, "data-role": dataRole, }: BadgeProps) => React.JSX.Element;
16
18
  export default Badge;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("./badge.style.js");function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const n=({"aria-label":n,children:c,counter:a=0,color:s="--colorsActionMajor500",onClick:l,"data-element":u,"data-role":i})=>{const d=+a>0,b=+a>99?99:a,[p,y]=t.useState(!1),[O,j]=t.useState(!1);return e.jsxs(r.StyledBadgeWrapper,{children:[c,(()=>{const t=l?{buttonType:"secondary",onClick:l}:{"aria-label":n};return d?e.jsxs(r.StyledBadge,(c=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){o(e,t,r[t])}))}return e}({"data-component":"badge","data-element":u,"data-role":i,color:s},t),a=null!=(a={onFocus:()=>{y(!0)},onBlur:()=>{y(!1)},onMouseEnter:()=>{j(!0)},onMouseLeave:()=>{j(!1)},isFocused:p,isHovered:O,children:[l&&e.jsx(r.StyledCrossIcon,{"data-element":"badge-cross-icon",type:"cross"}),e.jsx(r.StyledCounter,{"data-element":"badge-counter",children:b})]})?a:{},Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(a)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(a)).forEach((function(e){Object.defineProperty(c,e,Object.getOwnPropertyDescriptor(a,e))})),c)):null;var c,a})()]})};exports.Badge=n,exports.default=n;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("./badge.style.js"),n=require("../../__internal__/utils/helpers/guid/index.js");function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const c=({"aria-label":c,children:a,counter:s=0,color:l="--colorsActionMajor500",onClick:u,id:i,"data-element":d,"data-role":b})=>{const p=+s>0,y=+s>99?99:s,[j,O]=t.useState(!1),[f,g]=t.useState(!1),{current:m}=t.useRef(i||n.default());return e.jsxs(r.StyledBadgeWrapper,{children:[a,(()=>{const t={buttonType:"secondary",onClick:u};return p?e.jsxs(r.StyledBadge,(n=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){o(e,t,r[t])}))}return e}({"data-component":"badge","data-element":d,"data-role":b,color:l,id:m,"aria-label":c,onFocus:()=>{O(!0)},onBlur:()=>{O(!1)},onMouseEnter:()=>{g(!0)},onMouseLeave:()=>{g(!1)},isFocused:j,isHovered:f},u&&t),a=null!=(a={children:[u&&e.jsx(r.StyledCrossIcon,{"data-element":"badge-cross-icon",type:"cross"}),e.jsx(r.StyledCounter,{"data-element":"badge-counter",children:y})]})?a:{},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(a)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(a)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(a,e))})),n)):null;var n,a})()]})};exports.Badge=c,exports.default=c;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "154.11.4",
3
+ "version": "154.12.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",