monday-ui-react-core
Version:
Official monday.com UI resources for application development in React.js
3 lines (2 loc) • 2.62 kB
JavaScript
import{slicedToArray as e,defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{camelCase as o}from"lodash-es";import{getStyle as i}from"../../helpers/typesciptCssModulesHelper.js";import{getTestId as r,ComponentDefaultTestId as a}from"../../tests/testIds.js";import s from"classnames";import n,{useState as d,useRef as l,useCallback as m,useEffect as c,useMemo as p}from"react";import{SwitchTransition as u,CSSTransition as f}from"react-transition-group";import v from"../../hooks/useEventListener/index.js";import E from"../../hooks/useAfterFirstRender/index.js";import{NOOP as b}from"../../utils/function-utils.js";import{backwardCompatibilityForProperties as j}from"../../helpers/backwardCompatibilityForProperties.js";import{CounterSize as x,CounterColor as A,CounterType as h,getActualSize as k}from"./CounterConstants.js";import{withStaticProps as C}from"../../types/withStaticProps.js";import N from"./Counter.module.scss.js";var y=C((function x(A){var h=A.counterClassName,C=A.count,y=void 0===C?0:C,L=A.size,w=void 0===L?x.sizes.LARGE:L,M=A.kind,R=void 0===M?x.kinds.FILL:M,g=A.color,P=void 0===g?x.colors.PRIMARY:g,z=A.maxDigits,D=void 0===z?3:z,F=A.ariaLabeledBy,I=void 0===F?"":F,T=A.ariaLabel,B=void 0===T?"":T,H=A.id,O=void 0===H?"":H,U=A.prefix,_=void 0===U?"":U,G=A.onMouseDown,S=void 0===G?b:G,Y=A.noAnimation,q=void 0!==Y&&Y,J=A["data-testid"],K=j([A.className,A.wrapperClassName],void 0),Q=d(!1),V=e(Q,2),W=V[0],X=V[1],Z=l(null),$=m((function(){X(!0)}),[X]),ee=m((function(){X(!1)}),[X]);v({eventName:"animationend",callback:ee,ref:Z});var te=E();c((function(){te.current&&$()}),[y,te,$]),c((function(){D>0||console.error("Max digits must be a positive number")}),[D]);var oe=p((function(){return s(N.counter,i(N,o("size-"+k(w))),i(N,o("kind-"+R)),i(N,o("color-"+P)),t({},N.withAnimation,W),h)}),[w,R,P,W,h]),ie="counter"+(O?"-".concat(O):""),re=(null==y?void 0:(""+y).length)>D?"".concat(Math.pow(10,D)-1,"+"):y+"",ae=n.createElement("span",{id:ie,"data-testid":J||r(a.COUNTER,O)},_+re);return n.createElement("span",{className:K,"aria-label":"".concat(B," ").concat(re),"aria-labelledby":I,onMouseDown:S},n.createElement("div",{className:oe,"aria-label":re,ref:Z},q?ae:n.createElement(u,{mode:"out-in"},n.createElement(f,{key:re,classNames:{enter:N.fadeEnter,enterActive:N.fadeEnterActive,exit:N.fadeExit,exitActive:N.fadeExitActive},addEndListener:function(e,t){e.addEventListener("transitionend",t,!1)}},n.createElement("span",{id:ie,"data-testid":J||r(a.COUNTER,O)},_+re)))))}),{sizes:x,colors:A,kinds:h});export{y as default};
//# sourceMappingURL=Counter.js.map