@razorpay/blade 11.12.0 → 11.13.1
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/build/lib/native/components/ProgressBar/CircularProgressBar.native.js +31 -0
- package/build/lib/native/components/ProgressBar/CircularProgressBar.native.js.map +1 -0
- package/build/lib/native/components/ProgressBar/CircularProgressLabel.js +17 -0
- package/build/lib/native/components/ProgressBar/CircularProgressLabel.js.map +1 -0
- package/build/lib/native/components/ProgressBar/ProgressBar.js +2 -1
- package/build/lib/native/components/ProgressBar/ProgressBar.js.map +1 -1
- package/build/lib/native/components/ProgressBar/ProgressBarFilled.native.js +1 -1
- package/build/lib/native/components/ProgressBar/ProgressBarFilled.native.js.map +1 -1
- package/build/lib/native/components/ProgressBar/progressBarTokens.js +6 -2
- package/build/lib/native/components/ProgressBar/progressBarTokens.js.map +1 -1
- package/build/lib/native/tokens/global/size.js +1 -1
- package/build/lib/native/tokens/global/size.js.map +1 -1
- package/build/lib/web/development/components/Input/PhoneNumberInput/CountrySelector.web.js +9 -1
- package/build/lib/web/development/components/Input/PhoneNumberInput/CountrySelector.web.js.map +1 -1
- package/build/lib/web/development/components/ProgressBar/CircularProgressBar.web.js +140 -0
- package/build/lib/web/development/components/ProgressBar/CircularProgressBar.web.js.map +1 -0
- package/build/lib/web/development/components/ProgressBar/CircularProgressLabel.js +38 -0
- package/build/lib/web/development/components/ProgressBar/CircularProgressLabel.js.map +1 -0
- package/build/lib/web/development/components/ProgressBar/ProgressBar.js +47 -10
- package/build/lib/web/development/components/ProgressBar/ProgressBar.js.map +1 -1
- package/build/lib/web/development/components/ProgressBar/ProgressBarFilled.web.js +6 -6
- package/build/lib/web/development/components/ProgressBar/ProgressBarFilled.web.js.map +1 -1
- package/build/lib/web/development/components/ProgressBar/progressBarTokens.js +45 -1
- package/build/lib/web/development/components/ProgressBar/progressBarTokens.js.map +1 -1
- package/build/lib/web/development/tokens/global/size.js +4 -0
- package/build/lib/web/development/tokens/global/size.js.map +1 -1
- package/build/lib/web/production/components/Input/PhoneNumberInput/CountrySelector.web.js +9 -1
- package/build/lib/web/production/components/Input/PhoneNumberInput/CountrySelector.web.js.map +1 -1
- package/build/lib/web/production/components/ProgressBar/CircularProgressBar.web.js +140 -0
- package/build/lib/web/production/components/ProgressBar/CircularProgressBar.web.js.map +1 -0
- package/build/lib/web/production/components/ProgressBar/CircularProgressLabel.js +38 -0
- package/build/lib/web/production/components/ProgressBar/CircularProgressLabel.js.map +1 -0
- package/build/lib/web/production/components/ProgressBar/ProgressBar.js +47 -10
- package/build/lib/web/production/components/ProgressBar/ProgressBar.js.map +1 -1
- package/build/lib/web/production/components/ProgressBar/ProgressBarFilled.web.js +6 -6
- package/build/lib/web/production/components/ProgressBar/ProgressBarFilled.web.js.map +1 -1
- package/build/lib/web/production/components/ProgressBar/progressBarTokens.js +45 -1
- package/build/lib/web/production/components/ProgressBar/progressBarTokens.js.map +1 -1
- package/build/lib/web/production/tokens/global/size.js +4 -0
- package/build/lib/web/production/tokens/global/size.js.map +1 -1
- package/build/types/components/index.d.ts +11 -5
- package/build/types/components/index.native.d.ts +11 -5
- package/build/types/tokens/index.d.ts +4 -0
- package/build/types/tokens/index.native.d.ts +4 -0
- package/codemods/migrate-progressbar/transformers/__test__/migrate-progressbar.test.ts +28 -0
- package/codemods/migrate-progressbar/transformers/index.ts +89 -0
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import styled from 'styled-components/native';
|
|
3
|
+
import Animated, { useSharedValue, withTiming, cancelAnimation, withDelay, withRepeat, withSequence, useAnimatedStyle } from 'react-native-reanimated';
|
|
4
|
+
import { Text, Circle } from 'react-native-svg';
|
|
5
|
+
import { getCircularProgressSVGTokens, circularProgressSizeTokens } from './progressBarTokens.js';
|
|
6
|
+
import { CircularProgressLabel } from './CircularProgressLabel.js';
|
|
7
|
+
import getIn from '../../utils/lodashButBetter/get.js';
|
|
8
|
+
import { BaseBox } from '../Box/BaseBox/BaseBox.native.js';
|
|
9
|
+
import { makeMotionTime } from '../../utils/makeMotionTime/makeMotionTime.native.js';
|
|
10
|
+
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
11
|
+
import '../Typography/BaseText/BaseText.native.js';
|
|
12
|
+
import '@babel/runtime/helpers/slicedToArray';
|
|
13
|
+
import 'react-native';
|
|
14
|
+
import '../../tokens/global/typography.js';
|
|
15
|
+
import '../../tokens/global/motion.js';
|
|
16
|
+
import { castNativeType } from '../../utils/platform/castUtils.js';
|
|
17
|
+
import useTheme from '../BladeProvider/useTheme.js';
|
|
18
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
19
|
+
import { getTextProps } from '../Typography/Text/Text.js';
|
|
20
|
+
import '../Typography/Code/Code.js';
|
|
21
|
+
import '@gorhom/portal';
|
|
22
|
+
import 'react-native-gesture-handler';
|
|
23
|
+
import '../BottomSheet/BottomSheetStack.js';
|
|
24
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
25
|
+
import Svg from '../Icons/_Svg/Svg/Svg.native.js';
|
|
26
|
+
import getBaseTextStyles from '../Typography/BaseText/getBaseTextStyles.js';
|
|
27
|
+
|
|
28
|
+
var pulseAnimation={opacityInitial:1,opacityMid:0.65,opacityFinal:1};var StyledSVGText=styled(Text)(function(_ref){var theme=_ref.theme,size=_ref.size,weight=_ref.weight;var textProps=getTextProps({variant:'body',size:size,weight:weight});return Object.assign({},getBaseTextStyles(Object.assign({theme:theme},textProps)),{strokeWidth:0,fill:getIn(theme.colors,textProps.color)});});var CircularProgressBarFilled=function CircularProgressBarFilled(_ref2){var progressPercent=_ref2.progressPercent,fillColor=_ref2.fillColor,backgroundColor=_ref2.backgroundColor,_ref2$size=_ref2.size,size=_ref2$size===void 0?'small':_ref2$size,label=_ref2.label,_ref2$showPercentage=_ref2.showPercentage,showPercentage=_ref2$showPercentage===void 0?true:_ref2$showPercentage,isMeter=_ref2.isMeter,motionEasing=_ref2.motionEasing,pulseMotionDuration=_ref2.pulseMotionDuration,pulseMotionDelay=_ref2.pulseMotionDelay,fillMotionDuration=_ref2.fillMotionDuration;var _getCircularProgressS=getCircularProgressSVGTokens({size:size,progressPercent:progressPercent}),sqSize=_getCircularProgressS.sqSize,strokeWidth=_getCircularProgressS.strokeWidth,radius=_getCircularProgressS.radius,viewBox=_getCircularProgressS.viewBox,dashArray=_getCircularProgressS.dashArray,dashOffset=_getCircularProgressS.dashOffset;var AnimatedCircle=Animated.createAnimatedComponent(Circle);var animatedOpacity=useSharedValue(pulseAnimation.opacityInitial);var animatedStrokeDashoffset=useSharedValue(dashOffset);var _useTheme=useTheme(),theme=_useTheme.theme;var fillAndPulseEasing=getIn(theme.motion,motionEasing);var pulseDuration=castNativeType(makeMotionTime(getIn(theme.motion,pulseMotionDuration)))/2;useEffect(function(){var fillDuration=castNativeType(makeMotionTime(getIn(theme.motion,fillMotionDuration)));animatedStrokeDashoffset.value=withTiming(dashOffset,{duration:fillDuration,easing:fillAndPulseEasing});return function(){cancelAnimation(animatedStrokeDashoffset);};},[dashOffset,animatedStrokeDashoffset,fillMotionDuration,theme,fillAndPulseEasing]);useEffect(function(){var pulsatingAnimationTimingConfig={duration:pulseDuration,easing:fillAndPulseEasing};if(!isMeter){animatedOpacity.value=withDelay(castNativeType(makeMotionTime(getIn(theme.motion,pulseMotionDelay))),withRepeat(withSequence(withTiming(pulseAnimation.opacityMid,pulsatingAnimationTimingConfig),withTiming(pulseAnimation.opacityFinal,pulsatingAnimationTimingConfig)),-1));}return function(){cancelAnimation(animatedOpacity);};},[animatedOpacity,fillAndPulseEasing,pulseDuration,pulseMotionDelay,theme,isMeter]);var firstIndicatorStyles=useAnimatedStyle(function(){return {strokeDashoffset:animatedStrokeDashoffset.value,opacity:progressPercent<100?animatedOpacity.value:1};});return jsxs(BaseBox,{display:"flex",width:"fit-content",alignItems:"center",children:[jsxs(Svg,{width:String(sqSize),height:String(sqSize),viewBox:viewBox,children:[jsx(Circle,{fill:"none",stroke:backgroundColor,cx:String(sqSize/2),cy:String(sqSize/2),r:String(radius),strokeWidth:`${strokeWidth}px`}),jsx(AnimatedCircle,{fill:"none",stroke:fillColor,cx:sqSize/2,cy:sqSize/2,r:radius,strokeWidth:`${strokeWidth}px`,transform:`rotate(-90 ${sqSize/2} ${sqSize/2})`,strokeDasharray:dashArray,strokeDashoffset:dashOffset,style:firstIndicatorStyles}),showPercentage&&size!=='small'&&jsx(StyledSVGText,{size:circularProgressSizeTokens[size].percentTextSize,weight:"semibold",x:"50%",y:"50%",textAnchor:"middle",dy:".5em",children:`${progressPercent}%`})]}),jsx(CircularProgressLabel,{progressPercent:progressPercent,size:size,label:label,showPercentage:showPercentage})]});};
|
|
29
|
+
|
|
30
|
+
export { CircularProgressBarFilled };
|
|
31
|
+
//# sourceMappingURL=CircularProgressBar.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircularProgressBar.native.js","sources":["../../../../../src/components/ProgressBar/CircularProgressBar.native.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport styled from 'styled-components/native';\nimport Animated, {\n cancelAnimation,\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withRepeat,\n withSequence,\n withTiming,\n} from 'react-native-reanimated';\nimport { Text as SVGText, Circle } from 'react-native-svg';\nimport type { CircularProgressBarFilledProps } from './types';\nimport { circularProgressSizeTokens, getCircularProgressSVGTokens } from './progressBarTokens';\nimport { CircularProgressLabel } from './CircularProgressLabel';\nimport getIn from '~utils/lodashButBetter/get';\nimport BaseBox from '~components/Box/BaseBox';\nimport { makeMotionTime } from '~utils/makeMotionTime';\nimport type { TextProps } from '~components/Typography';\nimport { getTextProps } from '~components/Typography';\nimport { useTheme } from '~components/BladeProvider';\nimport { castNativeType } from '~utils';\nimport { Svg } from '~components/Icons/_Svg';\nimport getBaseTextStyles from '~components/Typography/BaseText/getBaseTextStyles';\n\nconst pulseAnimation = {\n opacityInitial: 1,\n opacityMid: 0.65,\n opacityFinal: 1,\n};\n\nconst StyledSVGText = styled(SVGText)<Pick<TextProps<{ variant: 'body' }>, 'size' | 'weight'>>(\n ({ theme, size, weight }) => {\n const textProps = getTextProps({ variant: 'body', size, weight });\n\n return {\n ...getBaseTextStyles({ theme, ...textProps }),\n strokeWidth: 0,\n fill: getIn(theme.colors, textProps.color!),\n };\n },\n);\n\nconst CircularProgressBarFilled = ({\n progressPercent,\n fillColor,\n backgroundColor,\n size = 'small',\n label,\n showPercentage = true,\n isMeter,\n motionEasing,\n pulseMotionDuration,\n pulseMotionDelay,\n fillMotionDuration,\n}: CircularProgressBarFilledProps): React.ReactElement => {\n const {\n sqSize,\n strokeWidth,\n radius,\n viewBox,\n dashArray,\n dashOffset,\n } = getCircularProgressSVGTokens({ size, progressPercent });\n\n const AnimatedCircle = Animated.createAnimatedComponent(Circle);\n const animatedOpacity = useSharedValue(pulseAnimation.opacityInitial);\n const animatedStrokeDashoffset = useSharedValue(dashOffset);\n const { theme } = useTheme();\n const fillAndPulseEasing = getIn(theme.motion, motionEasing);\n const pulseDuration =\n castNativeType(makeMotionTime(getIn(theme.motion, pulseMotionDuration))) / 2;\n\n // Trigger animation for progress fill\n useEffect(() => {\n const fillDuration = castNativeType(makeMotionTime(getIn(theme.motion, fillMotionDuration)));\n animatedStrokeDashoffset.value = withTiming(dashOffset, {\n duration: fillDuration,\n easing: fillAndPulseEasing,\n });\n return () => {\n cancelAnimation(animatedStrokeDashoffset);\n };\n }, [dashOffset, animatedStrokeDashoffset, fillMotionDuration, theme, fillAndPulseEasing]);\n\n // Trigger pulsating animation\n useEffect(() => {\n const pulsatingAnimationTimingConfig = {\n duration: pulseDuration,\n easing: fillAndPulseEasing,\n };\n if (!isMeter) {\n animatedOpacity.value = withDelay(\n castNativeType(makeMotionTime(getIn(theme.motion, pulseMotionDelay))),\n withRepeat(\n withSequence(\n withTiming(pulseAnimation.opacityMid, pulsatingAnimationTimingConfig),\n withTiming(pulseAnimation.opacityFinal, pulsatingAnimationTimingConfig),\n ),\n -1,\n ),\n );\n }\n\n return () => {\n cancelAnimation(animatedOpacity);\n };\n }, [animatedOpacity, fillAndPulseEasing, pulseDuration, pulseMotionDelay, theme, isMeter]);\n\n const firstIndicatorStyles = useAnimatedStyle(() => {\n return {\n strokeDashoffset: animatedStrokeDashoffset.value,\n opacity: progressPercent < 100 ? animatedOpacity.value : 1,\n };\n });\n\n return (\n <BaseBox display=\"flex\" width=\"fit-content\" alignItems=\"center\">\n <Svg width={String(sqSize)} height={String(sqSize)} viewBox={viewBox}>\n <Circle\n fill=\"none\"\n stroke={backgroundColor}\n cx={String(sqSize / 2)}\n cy={String(sqSize / 2)}\n r={String(radius)}\n strokeWidth={`${strokeWidth}px`}\n />\n\n <AnimatedCircle\n fill=\"none\"\n stroke={fillColor}\n cx={sqSize / 2}\n cy={sqSize / 2}\n r={radius}\n strokeWidth={`${strokeWidth}px`}\n // Start progress marker at 12 O'Clock\n transform={`rotate(-90 ${sqSize / 2} ${sqSize / 2})`}\n strokeDasharray={dashArray}\n strokeDashoffset={dashOffset}\n style={firstIndicatorStyles}\n />\n\n {showPercentage && size !== 'small' && (\n <StyledSVGText\n size={circularProgressSizeTokens[size].percentTextSize}\n weight=\"semibold\"\n x=\"50%\"\n y=\"50%\"\n textAnchor=\"middle\"\n dy=\".5em\"\n >\n {`${progressPercent}%`}\n </StyledSVGText>\n )}\n </Svg>\n\n <CircularProgressLabel\n progressPercent={progressPercent}\n size={size}\n label={label}\n showPercentage={showPercentage}\n />\n </BaseBox>\n );\n};\n\nexport { CircularProgressBarFilled };\n"],"names":["pulseAnimation","opacityInitial","opacityMid","opacityFinal","StyledSVGText","styled","SVGText","_ref","theme","size","weight","textProps","getTextProps","variant","Object","assign","getBaseTextStyles","strokeWidth","fill","getIn","colors","color","CircularProgressBarFilled","_ref2","progressPercent","fillColor","backgroundColor","_ref2$size","label","_ref2$showPercentage","showPercentage","isMeter","motionEasing","pulseMotionDuration","pulseMotionDelay","fillMotionDuration","_getCircularProgressS","getCircularProgressSVGTokens","sqSize","radius","viewBox","dashArray","dashOffset","AnimatedCircle","Animated","createAnimatedComponent","Circle","animatedOpacity","useSharedValue","animatedStrokeDashoffset","_useTheme","useTheme","fillAndPulseEasing","motion","pulseDuration","castNativeType","makeMotionTime","useEffect","fillDuration","value","withTiming","duration","easing","cancelAnimation","pulsatingAnimationTimingConfig","withDelay","withRepeat","withSequence","firstIndicatorStyles","useAnimatedStyle","strokeDashoffset","opacity","_jsxs","BaseBox","display","width","alignItems","children","Svg","String","height","_jsx","stroke","cx","cy","r","transform","strokeDasharray","style","circularProgressSizeTokens","percentTextSize","x","y","textAnchor","dy","CircularProgressLabel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAMA,cAAc,CAAG,CACrBC,cAAc,CAAE,CAAC,CACjBC,UAAU,CAAE,IAAI,CAChBC,YAAY,CAAE,CAChB,CAAC,CAED,IAAMC,aAAa,CAAGC,MAAM,CAACC,IAAO,CAAC,CACnC,SAAAC,IAAA,CAA6B,KAA1BC,KAAK,CAAAD,IAAA,CAALC,KAAK,CAAEC,IAAI,CAAAF,IAAA,CAAJE,IAAI,CAAEC,MAAM,CAAAH,IAAA,CAANG,MAAM,CACpB,IAAMC,SAAS,CAAGC,YAAY,CAAC,CAAEC,OAAO,CAAE,MAAM,CAAEJ,IAAI,CAAJA,IAAI,CAAEC,MAAM,CAANA,MAAO,CAAC,CAAC,CAEjE,OAAAI,MAAA,CAAAC,MAAA,CAAA,EAAA,CACKC,iBAAiB,CAAAF,MAAA,CAAAC,MAAA,CAAGP,CAAAA,KAAK,CAALA,KAAK,CAAA,CAAKG,SAAS,CAAE,CAAC,EAC7CM,WAAW,CAAE,CAAC,CACdC,IAAI,CAAEC,KAAK,CAACX,KAAK,CAACY,MAAM,CAAET,SAAS,CAACU,KAAM,CAAC,CAAA,CAAA,CAE/C,CACF,CAAC,CAEK,IAAAC,yBAAyB,CAAG,SAA5BA,yBAAyBA,CAAAC,KAAA,CAY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AU,CAC3B6B,gBAAgB,CAAE5B,UAAW,CAC7B8C,KAAK,CAAEpB,oBAAqB,CAC7B,CAAC,CAEDtC,cAAc,EAAIrB,IAAI,GAAK,OAAO,EACjCwE,GAAA,CAAC7E,aAAa,CAAA,CACZK,IAAI,CAAEgF,0BAA0B,CAAChF,IAAI,CAAC,CAACiF,eAAgB,CACvDhF,MAAM,CAAC,UAAU,CACjBiF,CAAC,CAAC,KAAK,CACPC,CAAC,CAAC,KAAK,CACPC,UAAU,CAAC,QAAQ,CACnBC,EAAE,CAAC,MAAM,CAAAjB,QAAA,CAEP,CAAA,EAAErD,eAAgB,CAAA,CAAA,CAAE,CACT,CAChB,CAAA,CACE,CAAC,CAENyD,GAAA,CAACc,qBAAqB,CACpBvE,CAAAA,eAAe,CAAEA,eAAgB,CACjCf,IAAI,CAAEA,IAAK,CACXmB,KAAK,CAAEA,KAAM,CACbE,cAAc,CAAEA,cAAe,CAChC,CAAC,CAAA,CACK,CAAC,CAEd;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import 'react';
|
|
2
|
+
import { BaseBox } from '../Box/BaseBox/BaseBox.native.js';
|
|
3
|
+
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
|
+
import '../Typography/BaseText/BaseText.native.js';
|
|
5
|
+
import '@babel/runtime/helpers/slicedToArray';
|
|
6
|
+
import 'react-native';
|
|
7
|
+
import '../../tokens/global/typography.js';
|
|
8
|
+
import '../../tokens/global/motion.js';
|
|
9
|
+
import '../BladeProvider/useTheme.js';
|
|
10
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
11
|
+
import { Text } from '../Typography/Text/Text.js';
|
|
12
|
+
import '../Typography/Code/Code.js';
|
|
13
|
+
|
|
14
|
+
var CircularProgressLabel=function CircularProgressLabel(_ref){var _label$trim;var progressPercent=_ref.progressPercent,_ref$size=_ref.size,size=_ref$size===void 0?'small':_ref$size,label=_ref.label,_ref$showPercentage=_ref.showPercentage,showPercentage=_ref$showPercentage===void 0?true:_ref$showPercentage;var hasLabel=label&&((_label$trim=label.trim())==null?void 0:_label$trim.length)>0;return jsxs(BaseBox,{display:"flex",flexDirection:"column",alignItems:"center",children:[hasLabel&&jsx(Text,{marginTop:"spacing.3",variant:"body",weight:"regular",size:"small",children:label}),showPercentage&&size==='small'&&jsxs(Text,{marginTop:hasLabel?'spacing.0':'spacing.3',variant:"body",weight:"semibold",size:"small",children:[progressPercent,"%"]})]});};
|
|
15
|
+
|
|
16
|
+
export { CircularProgressLabel };
|
|
17
|
+
//# sourceMappingURL=CircularProgressLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircularProgressLabel.js","sources":["../../../../../src/components/ProgressBar/CircularProgressLabel.tsx"],"sourcesContent":["import React from 'react';\nimport type { CircularProgressBarFilledProps } from './types';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Text } from '~components/Typography';\n\nconst CircularProgressLabel = ({\n progressPercent,\n size = 'small',\n label,\n showPercentage = true,\n}: Pick<\n CircularProgressBarFilledProps,\n 'progressPercent' | 'size' | 'label' | 'showPercentage'\n>): React.ReactElement => {\n const hasLabel = label && label.trim()?.length > 0;\n\n return (\n <BaseBox display=\"flex\" flexDirection=\"column\" alignItems=\"center\">\n {hasLabel && (\n <Text marginTop=\"spacing.3\" variant=\"body\" weight=\"regular\" size=\"small\">\n {label}\n </Text>\n )}\n\n {showPercentage && size === 'small' && (\n <Text\n marginTop={hasLabel ? 'spacing.0' : 'spacing.3'}\n variant=\"body\"\n weight=\"semibold\"\n size=\"small\"\n >\n {progressPercent}%\n </Text>\n )}\n </BaseBox>\n );\n};\n\nexport { CircularProgressLabel };\n"],"names":["CircularProgressLabel","_ref","_label$trim","progressPercent","_ref$size","size","label","_ref$showPercentage","showPercentage","hasLabel","trim","length","_jsxs","BaseBox","display","flexDirection","alignItems","children","_jsx","Text","marginTop","variant","weight"],"mappings":";;;;;;;;;;;;;AAKM,IAAAA,qBAAqB,CAAG,SAAxBA,qBAAqBA,CAAAC,IAAA,CAQD,CAAAC,IAAAA,WAAA,KAPxBC,eAAe,CAAAF,IAAA,CAAfE,eAAe,CAAAC,SAAA,CAAAH,IAAA,CACfI,IAAI,CAAJA,IAAI,CAAAD,SAAA,GAAA,KAAA,CAAA,CAAG,OAAO,CAAAA,SAAA,CACdE,KAAK,CAAAL,IAAA,CAALK,KAAK,CAAAC,mBAAA,CAAAN,IAAA,CACLO,cAAc,CAAdA,cAAc,CAAAD,mBAAA,GAAG,KAAA,CAAA,CAAA,IAAI,CAAAA,mBAAA,CAKrB,IAAME,QAAQ,CAAGH,KAAK,EAAI,EAAAJ,WAAA,CAAAI,KAAK,CAACI,IAAI,EAAE,GAAA,IAAA,CAAA,KAAA,CAAA,CAAZR,WAAA,CAAcS,MAAM,EAAG,CAAC,CAElD,OACEC,IAAA,CAACC,OAAO,CAAA,CAACC,OAAO,CAAC,MAAM,CAACC,aAAa,CAAC,QAAQ,CAACC,UAAU,CAAC,QAAQ,CAAAC,QAAA,CAC/DR,CAAAA,QAAQ,EACPS,GAAA,CAACC,IAAI,CAACC,CAAAA,SAAS,CAAC,WAAW,CAACC,OAAO,CAAC,MAAM,CAACC,MAAM,CAAC,SAAS,CAACjB,IAAI,CAAC,OAAO,CAAAY,QAAA,CACrEX,KAAK,CACF,CACP,CAEAE,cAAc,EAAIH,IAAI,GAAK,OAAO,EACjCO,IAAA,CAACO,IAAI,EACHC,SAAS,CAAEX,QAAQ,CAAG,WAAW,CAAG,WAAY,CAChDY,OAAO,CAAC,MAAM,CACdC,MAAM,CAAC,UAAU,CACjBjB,IAAI,CAAC,OAAO,CAAAY,QAAA,CAEXd,CAAAA,eAAe,CAAC,GACnB,CAAA,CAAM,CACP,CACM,CAAA,CAAC,CAEd;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
2
2
|
import { ProgressBarFilled } from './ProgressBarFilled.native.js';
|
|
3
|
+
import { CircularProgressBarFilled } from './CircularProgressBar.native.js';
|
|
3
4
|
import clamp from '../../utils/lodashButBetter/clamp.js';
|
|
4
5
|
import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.native.js';
|
|
5
6
|
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
|
|
@@ -23,7 +24,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
23
24
|
import { BaseBox } from '../Box/BaseBox/BaseBox.native.js';
|
|
24
25
|
import { makeAccessible } from '../../utils/makeAccessible/makeAccessible.native.js';
|
|
25
26
|
|
|
26
|
-
var _excluded=["accessibilityLabel","color","isIndeterminate","label","showPercentage","size","value","variant","min","max","testID"];var progressBarHeight={small:size[2],medium:size[4]};var ProgressBar=function ProgressBar(_ref){var _label$trim;var accessibilityLabel=_ref.accessibilityLabel,color=_ref.color,_ref$isIndeterminate=_ref.isIndeterminate,isIndeterminate=_ref$isIndeterminate===void 0?false:_ref$isIndeterminate,label=_ref.label,_ref$showPercentage=_ref.showPercentage,showPercentage=_ref$showPercentage===void 0?true:_ref$showPercentage,_ref$size=_ref.size,size=_ref$size===void 0?'small':_ref$size,_ref$value=_ref.value,value=_ref$value===void 0?0:_ref$value,_ref$variant=_ref.variant,variant=_ref$variant===void 0?'progress':_ref$variant,_ref$min=_ref.min,min=_ref$min===void 0?0:_ref$min,_ref$max=_ref.max,max=_ref$max===void 0?100:_ref$max,testID=_ref.testID,styledProps=_objectWithoutProperties(_ref,_excluded);var _useTheme=useTheme(),theme=_useTheme.theme;var id=useId(
|
|
27
|
+
var _excluded=["accessibilityLabel","color","type","isIndeterminate","label","showPercentage","size","value","variant","min","max","testID"];var progressBarHeight={small:size[2],medium:size[4],large:size[0]};var ProgressBar=function ProgressBar(_ref){var _label$trim;var accessibilityLabel=_ref.accessibilityLabel,color=_ref.color,type=_ref.type,_ref$isIndeterminate=_ref.isIndeterminate,isIndeterminate=_ref$isIndeterminate===void 0?false:_ref$isIndeterminate,label=_ref.label,_ref$showPercentage=_ref.showPercentage,showPercentage=_ref$showPercentage===void 0?true:_ref$showPercentage,_ref$size=_ref.size,size=_ref$size===void 0?'small':_ref$size,_ref$value=_ref.value,value=_ref$value===void 0?0:_ref$value,_ref$variant=_ref.variant,variant=_ref$variant===void 0?'progress':_ref$variant,_ref$min=_ref.min,min=_ref$min===void 0?0:_ref$min,_ref$max=_ref.max,max=_ref$max===void 0?100:_ref$max,testID=_ref.testID,styledProps=_objectWithoutProperties(_ref,_excluded);var _useTheme=useTheme(),theme=_useTheme.theme;var progressType=!type&&(variant==='meter'||variant==='progress')?variant:type;var progressVariant=variant==='meter'||variant==='progress'?'linear':variant;var id=useId(`${progressType}-${progressVariant}`);if(__DEV__){if(progressType==='meter'&&isIndeterminate){throwBladeError({moduleName:'ProgressBar',message:`Cannot set 'isIndeterminate' when 'type' or 'variant' is 'meter'.`});}if(progressVariant==='circular'&&isIndeterminate){throwBladeError({moduleName:'ProgressBar',message:`Cannot set 'isIndeterminate' when 'variant' is 'circular'.`});}if(progressVariant==='linear'&&size==='large'){throwBladeError({moduleName:'ProgressBar',message:`Large size isn't available when 'variant' is 'linear'.`});}if(type&&(variant==='progress'||variant==='meter')){throwBladeError({moduleName:'ProgressBar',message:`variant can only be 'linear' or 'circular' when 'type=${type}'.`});}}var unfilledBackgroundColor=theme.colors.feedback.background.neutral.subtle;var filledBackgroundColor=color?theme.colors.feedback.background[color].intense:theme.colors.surface.background.primary.intense;var hasLabel=label&&((_label$trim=label.trim())==null?void 0:_label$trim.length)>0;var isMeter=progressType==='meter';var isCircular=progressVariant==='circular';var progressValue=clamp(value,min,max);var percentageProgressValue=Math.floor((progressValue-min)*100/(max-min));var shouldShowPercentage=showPercentage&&!isMeter&&!isIndeterminate;var accessibilityProps={role:'progressbar',label:accessibilityLabel!=null?accessibilityLabel:label,valueNow:percentageProgressValue,valueText:`${percentageProgressValue}%`,valueMin:min,valueMax:max};if(isMeter){accessibilityProps.role='meter';accessibilityProps.valueNow=progressValue;accessibilityProps.valueText=`${progressValue}`;}if(isIndeterminate){accessibilityProps.valueNow=undefined;accessibilityProps.valueMin=undefined;accessibilityProps.valueMax=undefined;accessibilityProps.valueText=undefined;}return jsx(BaseBox,Object.assign({},getStyledProps(styledProps),metaAttribute({name:MetaConstants.ProgressBar,testID:testID}),{children:jsxs(BaseBox,{display:"flex",flexDirection:"column",width:"100%",children:[!isCircular?jsxs(BaseBox,{display:"flex",flexDirection:"row",justifyContent:hasLabel?'space-between':'flex-end',children:[hasLabel?jsx(Text,{as:"label",variant:"body",size:"small",color:"surface.text.gray.subtle",children:label}):null,shouldShowPercentage?jsx(BaseBox,{marginBottom:"spacing.2",children:jsx(Text,{variant:"body",size:"small",color:"surface.text.gray.subtle",children:`${percentageProgressValue}%`})}):null]}):null,jsx(BaseBox,Object.assign({id:id},makeAccessible({role:accessibilityProps.role,label:accessibilityProps.label,valueNow:accessibilityProps.valueNow,valueText:accessibilityProps.valueText,valueMin:accessibilityProps.valueMin,valueMax:accessibilityProps.valueMax}),{children:isCircular?jsx(CircularProgressBarFilled,{size:size,label:label,progressPercent:percentageProgressValue,isMeter:isMeter,showPercentage:shouldShowPercentage,backgroundColor:unfilledBackgroundColor,fillColor:filledBackgroundColor,pulseMotionDuration:"duration.2xgentle",fillMotionDuration:"duration.2xgentle",pulseMotionDelay:"delay.long",motionEasing:"easing.standard.revealing"}):jsx(BaseBox,{backgroundColor:unfilledBackgroundColor,height:makeSize(progressBarHeight[size]),overflow:"hidden",position:"relative",children:jsx(ProgressBarFilled,{backgroundColor:filledBackgroundColor,progress:percentageProgressValue,fillMotionDuration:"duration.2xgentle",pulseMotionDuration:"duration.2xgentle",indeterminateMotionDuration:"duration.2xgentle",pulseMotionDelay:"delay.long",motionEasing:"easing.standard.revealing",type:progressType,isIndeterminate:isIndeterminate})})}))]})}));};
|
|
27
28
|
|
|
28
29
|
export { ProgressBar };
|
|
29
30
|
//# sourceMappingURL=ProgressBar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.js","sources":["../../../../../src/components/ProgressBar/ProgressBar.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport { ProgressBarFilled } from './ProgressBarFilled';\nimport clamp from '~utils/lodashButBetter/clamp';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { Text } from '~components/Typography/Text';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { useId } from '~utils/useId';\nimport { useTheme } from '~components/BladeProvider';\nimport type { BaseBoxProps } from '~components/Box/BaseBox';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { FeedbackColors } from '~tokens/theme/theme';\nimport { size } from '~tokens/global';\nimport type { TestID } from '~utils/types';\nimport { makeSize } from '~utils/makeSize';\nimport type { AccessibilityProps } from '~utils/makeAccessible';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { throwBladeError } from '~utils/logger';\n\ntype ProgressBarCommonProps = {\n /**\n * Sets aria-label to help users know what the progress bar is for. Default value is the same as the `label` passed.\n */\n accessibilityLabel?: string;\n /**\n * Sets the color of the progress bar which changes the feedback color.\n */\n color?: FeedbackColors;\n /**\n * Sets the label to be rendered for the progress bar. This value will also be used as default for `accessibilityLabel`.\n */\n label?: string;\n /**\n * Sets the size of the progress bar.\n * @default 'small'\n */\n size?: 'small' | 'medium';\n /**\n * Sets the progress value of the progress bar.\n * @default 'small'\n */\n value?: number;\n /**\n * Sets the minimum value for the progress bar.\n * @default 0\n */\n min?: number;\n /**\n * Sets the maximum value for the progress bar.\n * @default 100\n */\n max?: number;\n} & TestID &\n StyledPropsBlade;\n\ntype ProgressBarVariant = 'progress' | 'meter';\n\ntype ProgressBarProgressProps = ProgressBarCommonProps & {\n /**\n * Sets the variant to be rendered for the progress bar.\n * @default 'progress'\n */\n variant?: Extract<ProgressBarVariant, 'progress'>;\n /**\n * Sets whether the progress bar is in an indeterminate state.\n * @default false\n */\n isIndeterminate?: boolean;\n /**\n * Sets whether or not to show the progress percentage for the progress bar. Percentage is hidden by default for the `meter` variant.\n * @default true\n */\n showPercentage?: boolean;\n};\n\ntype ProgressBarMeterProps = ProgressBarCommonProps & {\n /**\n * Sets the variant to be rendered for thr progress bar.\n * @default 'progress'\n */\n variant?: Extract<ProgressBarVariant, 'meter'>;\n /**\n * Sets whether the progress bar is in an indeterminate state.\n * @default false\n */\n isIndeterminate?: undefined;\n /**\n * Sets whether or not to show the progress percentage for the progress bar. Percentage is hidden by default for the `meter` variant.\n * @default false\n */\n showPercentage?: undefined;\n};\n\ntype ProgressBarProps = ProgressBarProgressProps | ProgressBarMeterProps;\n\nconst progressBarHeight: Record<NonNullable<ProgressBarCommonProps['size']>, 2 | 4> = {\n small: size[2],\n medium: size[4],\n};\n\nconst ProgressBar = ({\n accessibilityLabel,\n color,\n isIndeterminate = false,\n label,\n showPercentage = true,\n size = 'small',\n value = 0,\n variant = 'progress',\n min = 0,\n max = 100,\n testID,\n ...styledProps\n}: ProgressBarProps): ReactElement => {\n const { theme } = useTheme();\n const id = useId(variant);\n\n if (__DEV__) {\n if (variant === 'meter' && isIndeterminate) {\n throwBladeError({\n moduleName: 'ProgressBar',\n message: `Cannot set 'isIndeterminate' when 'variant' is 'meter'.`,\n });\n }\n }\n\n const unfilledBackgroundColor = theme.colors.feedback.background.neutral\n .subtle as BaseBoxProps['backgroundColor'];\n const filledBackgroundColor = color\n ? theme.colors.feedback.background[color].intense\n : theme.colors.surface.background.primary.intense;\n const hasLabel = label && label.trim()?.length > 0;\n const isMeter = variant === 'meter';\n const progressValue = clamp(value, min, max);\n const percentageProgressValue = Math.floor(((progressValue - min) * 100) / (max - min));\n const shouldShowPercentage = showPercentage && !isMeter && !isIndeterminate;\n const accessibilityProps: Pick<\n AccessibilityProps,\n 'role' | 'label' | 'valueMax' | 'valueNow' | 'valueMin' | 'valueText'\n > = {\n role: 'progressbar',\n label: accessibilityLabel ?? label,\n valueNow: percentageProgressValue,\n valueText: `${percentageProgressValue}%`,\n valueMin: min,\n valueMax: max,\n };\n\n if (isMeter) {\n accessibilityProps.role = 'meter';\n accessibilityProps.valueNow = progressValue;\n accessibilityProps.valueText = `${progressValue}`;\n }\n\n if (isIndeterminate) {\n accessibilityProps.valueNow = undefined;\n accessibilityProps.valueMin = undefined;\n accessibilityProps.valueMax = undefined;\n accessibilityProps.valueText = undefined;\n }\n\n return (\n <BaseBox\n {...getStyledProps(styledProps)}\n {...metaAttribute({ name: MetaConstants.ProgressBar, testID })}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\" width=\"100%\">\n <BaseBox\n display=\"flex\"\n flexDirection=\"row\"\n justifyContent={hasLabel ? 'space-between' : 'flex-end'}\n >\n {hasLabel ? (\n <Text as=\"label\" variant=\"body\" size=\"small\" color=\"surface.text.gray.subtle\">\n {label}\n </Text>\n ) : null}\n {shouldShowPercentage ? (\n <BaseBox marginBottom=\"spacing.2\">\n <Text\n variant=\"body\"\n size=\"small\"\n color=\"surface.text.gray.subtle\"\n >{`${percentageProgressValue}%`}</Text>\n </BaseBox>\n ) : null}\n </BaseBox>\n <BaseBox\n id={id}\n {...makeAccessible({\n role: accessibilityProps.role,\n label: accessibilityProps.label,\n valueNow: accessibilityProps.valueNow,\n valueText: accessibilityProps.valueText,\n valueMin: accessibilityProps.valueMin,\n valueMax: accessibilityProps.valueMax,\n })}\n >\n <BaseBox\n backgroundColor={unfilledBackgroundColor}\n height={makeSize(progressBarHeight[size])}\n overflow=\"hidden\"\n position=\"relative\"\n >\n <ProgressBarFilled\n backgroundColor={filledBackgroundColor}\n progress={percentageProgressValue}\n fillMotionDuration=\"duration.2xgentle\"\n pulseMotionDuration=\"duration.2xgentle\"\n indeterminateMotionDuration=\"duration.2xgentle\"\n pulseMotionDelay=\"delay.long\"\n motionEasing=\"easing.standard.revealing\"\n variant={variant}\n isIndeterminate={isIndeterminate}\n />\n </BaseBox>\n </BaseBox>\n </BaseBox>\n </BaseBox>\n );\n};\n\nexport type { ProgressBarProps, ProgressBarVariant };\nexport { ProgressBar };\n"],"names":["progressBarHeight","small","size","medium","ProgressBar","_ref","_label$trim","accessibilityLabel","color","_ref$isIndeterminate","isIndeterminate","label","_ref$showPercentage","showPercentage","_ref$size","_ref$value","value","_ref$variant","variant","_ref$min","min","_ref$max","max","testID","styledProps","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","id","useId","__DEV__","throwBladeError","moduleName","message","unfilledBackgroundColor","colors","feedback","background","neutral","subtle","filledBackgroundColor","intense","surface","primary","hasLabel","trim","length","isMeter","progressValue","clamp","percentageProgressValue","Math","floor","shouldShowPercentage","accessibilityProps","role","valueNow","valueText","valueMin","valueMax","undefined","_jsx","BaseBox","Object","assign","getStyledProps","metaAttribute","name","MetaConstants","children","_jsxs","display","flexDirection","width","justifyContent","Text","as","marginBottom","makeAccessible","backgroundColor","height","makeSize","overflow","position","ProgressBarFilled","progress","fillMotionDuration","pulseMotionDuration","indeterminateMotionDuration","pulseMotionDelay","motionEasing"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAA,SAAA,CAAA,CAAA,oBAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,MAAA,CAAA,OAAA,CAAA,SAAA,CAAA,KAAA,CAAA,KAAA,CAAA,QAAA,CAAA,CA8FA,IAAMA,iBAA6E,CAAG,CACpFC,KAAK,CAAEC,IAAI,CAAC,CAAC,CAAC,CACdC,MAAM,CAAED,IAAI,CAAC,CAAC,CAChB,CAAC,CAEK,IAAAE,WAAW,CAAG,SAAdA,WAAWA,CAAAC,IAAA,CAaqB,CAAAC,IAAAA,WAAA,KAZpCC,kBAAkB,CAAAF,IAAA,CAAlBE,kBAAkB,CAClBC,KAAK,CAAAH,IAAA,CAALG,KAAK,CAAAC,oBAAA,CAAAJ,IAAA,CACLK,eAAe,CAAfA,eAAe,CAAAD,oBAAA,UAAG,KAAK,CAAAA,oBAAA,CACvBE,KAAK,CAAAN,IAAA,CAALM,KAAK,CAAAC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AS,CAAEH,kBAAkB,CAACG,SAAS,CACvCC,QAAQ,CAAEJ,kBAAkB,CAACI,QAAQ,CACrCC,QAAQ,CAAEL,kBAAkB,CAACK,QAC/B,CAAC,CAAC,CAAAU,CAAAA,QAAA,CAEFR,GAAA,CAACC,OAAO,CACNiB,CAAAA,eAAe,CAAE7C,uBAAwB,CACzC8C,MAAM,CAAEC,QAAQ,CAACnF,iBAAiB,CAACE,IAAI,CAAC,CAAE,CAC1CkF,QAAQ,CAAC,QAAQ,CACjBC,QAAQ,CAAC,UAAU,CAAAd,QAAA,CAEnBR,GAAA,CAACuB,iBAAiB,CAAA,CAChBL,eAAe,CAAEvC,qBAAsB,CACvC6C,QAAQ,CAAEnC,uBAAwB,CAClCoC,kBAAkB,CAAC,mBAAmB,CACtCC,mBAAmB,CAAC,mBAAmB,CACvCC,2BAA2B,CAAC,mBAAmB,CAC/CC,gBAAgB,CAAC,YAAY,CAC7BC,YAAY,CAAC,2BAA2B,CACxC1E,OAAO,CAAEA,OAAQ,CACjBR,eAAe,CAAEA,eAAgB,CAClC,CAAC,CACK,CAAC,EACH,CAAC,CAAA,CACH,CAAC,CACH,CAAA,CAAC,CAEd;;;;"}
|
|
1
|
+
{"version":3,"file":"ProgressBar.js","sources":["../../../../../src/components/ProgressBar/ProgressBar.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport { ProgressBarFilled } from './ProgressBarFilled';\nimport { CircularProgressBarFilled } from './CircularProgressBar';\nimport clamp from '~utils/lodashButBetter/clamp';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { Text } from '~components/Typography/Text';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { useId } from '~utils/useId';\nimport { useTheme } from '~components/BladeProvider';\nimport type { BaseBoxProps } from '~components/Box/BaseBox';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { FeedbackColors } from '~tokens/theme/theme';\nimport { size } from '~tokens/global';\nimport type { TestID } from '~utils/types';\nimport { makeSize } from '~utils/makeSize';\nimport type { AccessibilityProps } from '~utils/makeAccessible';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { throwBladeError } from '~utils/logger';\n\ntype ProgressBarCommonProps = {\n /**\n * Sets aria-label to help users know what the progress bar is for. Default value is the same as the `label` passed.\n */\n accessibilityLabel?: string;\n /**\n * Sets the color of the progress bar which changes the feedback color.\n */\n color?: FeedbackColors;\n /**\n * Sets the type of the progress bar.\n * @default 'progress'\n */\n type?: 'meter' | 'progress';\n /**\n * Sets the label to be rendered for the progress bar. This value will also be used as default for `accessibilityLabel`.\n */\n label?: string;\n /**\n * Sets the size of the progress bar.\n * Note: 'large' size isn't available when the variant is 'linear'.\n * @default 'small'\n */\n size?: 'small' | 'medium' | 'large';\n /**\n * Sets the progress value of the progress bar.\n * @default 'small'\n */\n value?: number;\n /**\n * Sets the minimum value for the progress bar.\n * @default 0\n */\n min?: number;\n /**\n * Sets the maximum value for the progress bar.\n * @default 100\n */\n max?: number;\n} & TestID &\n StyledPropsBlade;\n\ntype ProgressBarVariant = 'progress' | 'meter' | 'linear' | 'circular';\n\ntype ProgressBarProgressProps = ProgressBarCommonProps & {\n /**\n * Sets the variant to be rendered for the progress bar.\n * @default 'progress'\n */\n variant?: Extract<ProgressBarVariant, 'progress' | 'linear' | 'circular'>;\n /**\n * Sets whether the progress bar is in an indeterminate state.\n * @default false\n */\n isIndeterminate?: boolean;\n /**\n * Sets whether or not to show the progress percentage for the progress bar. Percentage is hidden by default for the `meter` variant.\n * @default true\n */\n showPercentage?: boolean;\n};\n\ntype ProgressBarMeterProps = ProgressBarCommonProps & {\n /**\n * Sets the variant to be rendered for thr progress bar.\n * @default 'progress'\n */\n variant?: Extract<ProgressBarVariant, 'meter' | 'linear' | 'circular'>;\n /**\n * Sets whether the progress bar is in an indeterminate state.\n * @default false\n */\n isIndeterminate?: undefined;\n /**\n * Sets whether or not to show the progress percentage for the progress bar. Percentage is hidden by default for the `meter` variant.\n * @default false\n */\n showPercentage?: undefined;\n};\n\ntype ProgressBarProps = ProgressBarProgressProps | ProgressBarMeterProps;\n\nconst progressBarHeight: Record<NonNullable<ProgressBarProps['size']>, 2 | 4 | 0> = {\n small: size[2],\n medium: size[4],\n // Large size isn't available when variant is 'linear'\n large: size[0],\n};\n\nconst ProgressBar = ({\n accessibilityLabel,\n color,\n type,\n isIndeterminate = false,\n label,\n showPercentage = true,\n size = 'small',\n value = 0,\n variant = 'progress',\n min = 0,\n max = 100,\n testID,\n ...styledProps\n}: ProgressBarProps): ReactElement => {\n const { theme } = useTheme();\n const progressType = !type && (variant === 'meter' || variant === 'progress') ? variant : type;\n const progressVariant = variant === 'meter' || variant === 'progress' ? 'linear' : variant;\n const id = useId(`${progressType}-${progressVariant}`);\n\n if (__DEV__) {\n if (progressType === 'meter' && isIndeterminate) {\n throwBladeError({\n moduleName: 'ProgressBar',\n message: `Cannot set 'isIndeterminate' when 'type' or 'variant' is 'meter'.`,\n });\n }\n\n if (progressVariant === 'circular' && isIndeterminate) {\n throwBladeError({\n moduleName: 'ProgressBar',\n message: `Cannot set 'isIndeterminate' when 'variant' is 'circular'.`,\n });\n }\n\n if (progressVariant === 'linear' && size === 'large') {\n throwBladeError({\n moduleName: 'ProgressBar',\n message: `Large size isn't available when 'variant' is 'linear'.`,\n });\n }\n\n if (type && (variant === 'progress' || variant === 'meter')) {\n throwBladeError({\n moduleName: 'ProgressBar',\n message: `variant can only be 'linear' or 'circular' when 'type=${type}'.`,\n });\n }\n }\n\n const unfilledBackgroundColor = theme.colors.feedback.background.neutral\n .subtle as BaseBoxProps['backgroundColor'];\n const filledBackgroundColor = color\n ? theme.colors.feedback.background[color].intense\n : theme.colors.surface.background.primary.intense;\n const hasLabel = label && label.trim()?.length > 0;\n const isMeter = progressType === 'meter';\n const isCircular = progressVariant === 'circular';\n const progressValue = clamp(value, min, max);\n const percentageProgressValue = Math.floor(((progressValue - min) * 100) / (max - min));\n const shouldShowPercentage = showPercentage && !isMeter && !isIndeterminate;\n const accessibilityProps: Pick<\n AccessibilityProps,\n 'role' | 'label' | 'valueMax' | 'valueNow' | 'valueMin' | 'valueText'\n > = {\n role: 'progressbar',\n label: accessibilityLabel ?? label,\n valueNow: percentageProgressValue,\n valueText: `${percentageProgressValue}%`,\n valueMin: min,\n valueMax: max,\n };\n\n if (isMeter) {\n accessibilityProps.role = 'meter';\n accessibilityProps.valueNow = progressValue;\n accessibilityProps.valueText = `${progressValue}`;\n }\n\n if (isIndeterminate) {\n accessibilityProps.valueNow = undefined;\n accessibilityProps.valueMin = undefined;\n accessibilityProps.valueMax = undefined;\n accessibilityProps.valueText = undefined;\n }\n\n return (\n <BaseBox\n {...getStyledProps(styledProps)}\n {...metaAttribute({ name: MetaConstants.ProgressBar, testID })}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\" width=\"100%\">\n {!isCircular ? (\n <BaseBox\n display=\"flex\"\n flexDirection=\"row\"\n justifyContent={hasLabel ? 'space-between' : 'flex-end'}\n >\n {hasLabel ? (\n <Text as=\"label\" variant=\"body\" size=\"small\" color=\"surface.text.gray.subtle\">\n {label}\n </Text>\n ) : null}\n {shouldShowPercentage ? (\n <BaseBox marginBottom=\"spacing.2\">\n <Text\n variant=\"body\"\n size=\"small\"\n color=\"surface.text.gray.subtle\"\n >{`${percentageProgressValue}%`}</Text>\n </BaseBox>\n ) : null}\n </BaseBox>\n ) : null}\n\n <BaseBox\n id={id}\n {...makeAccessible({\n role: accessibilityProps.role,\n label: accessibilityProps.label,\n valueNow: accessibilityProps.valueNow,\n valueText: accessibilityProps.valueText,\n valueMin: accessibilityProps.valueMin,\n valueMax: accessibilityProps.valueMax,\n })}\n >\n {isCircular ? (\n <CircularProgressBarFilled\n size={size}\n label={label}\n progressPercent={percentageProgressValue}\n isMeter={isMeter}\n showPercentage={shouldShowPercentage}\n backgroundColor={unfilledBackgroundColor as string}\n fillColor={filledBackgroundColor}\n pulseMotionDuration=\"duration.2xgentle\"\n fillMotionDuration=\"duration.2xgentle\"\n pulseMotionDelay=\"delay.long\"\n motionEasing=\"easing.standard.revealing\"\n />\n ) : (\n <BaseBox\n backgroundColor={unfilledBackgroundColor}\n height={makeSize(progressBarHeight[size])}\n overflow=\"hidden\"\n position=\"relative\"\n >\n <ProgressBarFilled\n backgroundColor={filledBackgroundColor}\n progress={percentageProgressValue}\n fillMotionDuration=\"duration.2xgentle\"\n pulseMotionDuration=\"duration.2xgentle\"\n indeterminateMotionDuration=\"duration.2xgentle\"\n pulseMotionDelay=\"delay.long\"\n motionEasing=\"easing.standard.revealing\"\n type={progressType}\n isIndeterminate={isIndeterminate}\n />\n </BaseBox>\n )}\n </BaseBox>\n </BaseBox>\n </BaseBox>\n );\n};\n\nexport type { ProgressBarProps, ProgressBarVariant };\nexport { ProgressBar };\n"],"names":["progressBarHeight","small","size","medium","large","ProgressBar","_ref","_label$trim","accessibilityLabel","color","type","_ref$isIndeterminate","isIndeterminate","label","_ref$showPercentage","showPercentage","_ref$size","_ref$value","value","_ref$variant","variant","_ref$min","min","_ref$max","max","testID","styledProps","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","progressType","progressVariant","id","useId","__DEV__","throwBladeError","moduleName","message","unfilledBackgroundColor","colors","feedback","background","neutral","subtle","filledBackgroundColor","intense","surface","primary","hasLabel","trim","length","isMeter","isCircular","progressValue","clamp","percentageProgressValue","Math","floor","shouldShowPercentage","accessibilityProps","role","valueNow","valueText","valueMin","valueMax","undefined","_jsx","BaseBox","Object","assign","getStyledProps","metaAttribute","name","MetaConstants","children","_jsxs","display","flexDirection","width","justifyContent","Text","as","marginBottom","makeAccessible","CircularProgressBarFilled","progressPercent","backgroundColor","fillColor","pulseMotionDuration","fillMotionDuration","pulseMotionDelay","motionEasing","height","makeSize","overflow","position","ProgressBarFilled","progress","indeterminateMotionDuration"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;6IAsGA,IAAMA,iBAA2E,CAAG,CAClFC,KAAK,CAAEC,IAAI,CAAC,CAAC,CAAC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eAAgB,CAClC,CAAC,CACK,CACV,CACM,CAAA,CAAC,CACH,CAAA,CAAC,CACH,CAAA,CAAC,CAEd;;;;"}
|
|
@@ -13,7 +13,7 @@ import { makeMotionTime } from '../../utils/makeMotionTime/makeMotionTime.native
|
|
|
13
13
|
import '../BottomSheet/BottomSheetStack.js';
|
|
14
14
|
import { jsx } from 'react/jsx-runtime';
|
|
15
15
|
|
|
16
|
-
var ProgressBarIndeterminateFilledContainer=styled(Animated.View)(function(_ref){var backgroundColor=_ref.backgroundColor;return {backgroundColor:backgroundColor,height:'100%',width:indeterminateAnimation.fillWidth,position:'absolute'};});var ProgressBarDeterminateFilledContainer=styled(Animated.View)(function(_ref2){var backgroundColor=_ref2.backgroundColor,progress=_ref2.progress;return {backgroundColor:backgroundColor,height:'100%',width:`${progress}%`};});var ProgressBarPulseAnimation=styled(Animated.View)({backgroundColor:pulseAnimation.backgroundColor,opacity:pulseAnimation.opacityInitial,width:'100%',height:'100%'});var ProgressBarFilled=function ProgressBarFilled(_ref3){var backgroundColor=_ref3.backgroundColor,progress=_ref3.progress,fillMotionDuration=_ref3.fillMotionDuration,motionEasing=_ref3.motionEasing,pulseMotionDuration=_ref3.pulseMotionDuration,pulseMotionDelay=_ref3.pulseMotionDelay,
|
|
16
|
+
var ProgressBarIndeterminateFilledContainer=styled(Animated.View)(function(_ref){var backgroundColor=_ref.backgroundColor;return {backgroundColor:backgroundColor,height:'100%',width:indeterminateAnimation.fillWidth,position:'absolute'};});var ProgressBarDeterminateFilledContainer=styled(Animated.View)(function(_ref2){var backgroundColor=_ref2.backgroundColor,progress=_ref2.progress;return {backgroundColor:backgroundColor,height:'100%',width:`${progress}%`};});var ProgressBarPulseAnimation=styled(Animated.View)({backgroundColor:pulseAnimation.backgroundColor,opacity:pulseAnimation.opacityInitial,width:'100%',height:'100%'});var ProgressBarFilled=function ProgressBarFilled(_ref3){var backgroundColor=_ref3.backgroundColor,progress=_ref3.progress,fillMotionDuration=_ref3.fillMotionDuration,motionEasing=_ref3.motionEasing,pulseMotionDuration=_ref3.pulseMotionDuration,pulseMotionDelay=_ref3.pulseMotionDelay,type=_ref3.type,isIndeterminate=_ref3.isIndeterminate,indeterminateMotionDuration=_ref3.indeterminateMotionDuration;var animatedWidth=useSharedValue(progress);var animatedOpacity=useSharedValue(pulseAnimation.opacityInitial);var animatedScaleX=useSharedValue(indeterminateAnimation.scaleXInitial);var animatedLeft=useSharedValue(indeterminateAnimation.leftInitial);var _useTheme=useTheme(),theme=_useTheme.theme;var fillAndPulseEasing=getIn(theme.motion,motionEasing);var pulseDuration=castNativeType(makeMotionTime(getIn(theme.motion,pulseMotionDuration)))/2;useEffect(function(){var fillDuration=castNativeType(makeMotionTime(getIn(theme.motion,fillMotionDuration)));animatedWidth.value=withTiming(progress,{duration:fillDuration,easing:fillAndPulseEasing});return function(){cancelAnimation(animatedWidth);};},[progress,animatedWidth,fillMotionDuration,theme,fillAndPulseEasing]);var progressFillAnimatedStyle=useAnimatedStyle(function(){return {width:`${animatedWidth.value}%`};});useEffect(function(){if(type==='progress'&&isIndeterminate){var indeterminateDuration=castNativeType(makeMotionTime(getIn(theme.motion,indeterminateMotionDuration)));var indeterminateEasing=Easing.linear;animatedLeft.value=withRepeat(withTiming(indeterminateAnimation.leftFinal,{duration:indeterminateDuration,easing:indeterminateEasing}),-1);animatedScaleX.value=withRepeat(withSequence(withTiming(indeterminateAnimation.scaleXMid,{duration:indeterminateDuration/2,easing:indeterminateEasing}),withTiming(indeterminateAnimation.scaleXFinal,{duration:indeterminateDuration/2,easing:indeterminateEasing})),-1);}return function(){cancelAnimation(animatedLeft);cancelAnimation(animatedScaleX);};},[animatedLeft,animatedScaleX,indeterminateMotionDuration,isIndeterminate,theme,type]);var indeterminateAnimatedStyle=useAnimatedStyle(function(){return {left:animatedLeft.value,transform:[{scaleX:animatedScaleX.value}]};});useEffect(function(){var pulsatingAnimationTimingConfig={duration:pulseDuration,easing:fillAndPulseEasing};if(type==='progress'){animatedOpacity.value=withDelay(castNativeType(makeMotionTime(getIn(theme.motion,pulseMotionDelay))),withRepeat(withSequence(withTiming(pulseAnimation.opacityMid,pulsatingAnimationTimingConfig),withTiming(pulseAnimation.opacityFinal,pulsatingAnimationTimingConfig)),-1));}return function(){cancelAnimation(animatedOpacity);};},[animatedOpacity,fillAndPulseEasing,pulseDuration,pulseMotionDelay,theme,type]);var pulseAnimatedStyle=useAnimatedStyle(function(){return {opacity:animatedOpacity.value};});var ProgressBarFilledContainer=isIndeterminate?ProgressBarIndeterminateFilledContainer:ProgressBarDeterminateFilledContainer;return jsx(ProgressBarFilledContainer,{style:isIndeterminate?indeterminateAnimatedStyle:progressFillAnimatedStyle,backgroundColor:backgroundColor,progress:progress,children:jsx(ProgressBarPulseAnimation,{style:pulseAnimatedStyle})});};
|
|
17
17
|
|
|
18
18
|
export { ProgressBarFilled };
|
|
19
19
|
//# sourceMappingURL=ProgressBarFilled.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBarFilled.native.js","sources":["../../../../../src/components/ProgressBar/ProgressBarFilled.native.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport styled from 'styled-components';\nimport Animated, {\n cancelAnimation,\n Easing,\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withRepeat,\n withSequence,\n withTiming,\n} from 'react-native-reanimated';\nimport type { ProgressBarFilledProps } from './types';\nimport { indeterminateAnimation, pulseAnimation } from './progressBarTokens';\nimport getIn from '~utils/lodashButBetter/get';\nimport { useTheme } from '~components/BladeProvider';\nimport { castNativeType } from '~utils';\nimport { makeMotionTime } from '~utils/makeMotionTime';\n\nconst ProgressBarIndeterminateFilledContainer = styled(Animated.View)<\n Pick<ProgressBarFilledProps, 'backgroundColor' | 'progress'>\n>(({ backgroundColor }) => ({\n backgroundColor,\n height: '100%',\n width: indeterminateAnimation.fillWidth,\n position: 'absolute',\n}));\n\nconst ProgressBarDeterminateFilledContainer = styled(Animated.View)<\n Pick<ProgressBarFilledProps, 'backgroundColor' | 'progress'>\n>(({ backgroundColor, progress }) => ({\n backgroundColor,\n height: '100%',\n width: `${progress}%`,\n}));\n\nconst ProgressBarPulseAnimation = styled(Animated.View)({\n backgroundColor: pulseAnimation.backgroundColor,\n opacity: pulseAnimation.opacityInitial,\n width: '100%',\n height: '100%',\n});\n\nconst ProgressBarFilled = ({\n backgroundColor,\n progress,\n fillMotionDuration,\n motionEasing,\n pulseMotionDuration,\n pulseMotionDelay,\n variant,\n isIndeterminate,\n indeterminateMotionDuration,\n}: ProgressBarFilledProps): React.ReactElement => {\n const animatedWidth = useSharedValue(progress); // for progress fill animation\n const animatedOpacity = useSharedValue(pulseAnimation.opacityInitial); // for pulse animation\n const animatedScaleX = useSharedValue(indeterminateAnimation.scaleXInitial); // for indeterminate scale animation\n const animatedLeft = useSharedValue(indeterminateAnimation.leftInitial); // for indeterminate slide animation\n\n const { theme } = useTheme();\n const fillAndPulseEasing = getIn(theme.motion, motionEasing);\n const pulseDuration =\n castNativeType(makeMotionTime(getIn(theme.motion, pulseMotionDuration))) / 2; // divided by 2 since we animate it with 2 steps in a sequence\n\n // Trigger animation for progress fill\n useEffect(() => {\n const fillDuration = castNativeType(makeMotionTime(getIn(theme.motion, fillMotionDuration)));\n animatedWidth.value = withTiming(progress, {\n duration: fillDuration,\n easing: fillAndPulseEasing,\n });\n return () => {\n cancelAnimation(animatedWidth);\n };\n }, [progress, animatedWidth, fillMotionDuration, theme, fillAndPulseEasing]);\n\n // Animated styles for progress fill animation\n const progressFillAnimatedStyle = useAnimatedStyle(() => {\n return {\n width: `${animatedWidth.value}%`,\n };\n });\n\n // Trigger animation for indeterminate progress bar\n useEffect(() => {\n if (variant === 'progress' && isIndeterminate) {\n const indeterminateDuration = castNativeType(\n makeMotionTime(getIn(theme.motion, indeterminateMotionDuration)),\n );\n const indeterminateEasing = Easing.linear;\n\n // Sliding animation\n animatedLeft.value = withRepeat(\n withTiming(indeterminateAnimation.leftFinal, {\n duration: indeterminateDuration,\n easing: indeterminateEasing,\n }),\n -1,\n );\n\n // Scaling animation\n animatedScaleX.value = withRepeat(\n withSequence(\n withTiming(indeterminateAnimation.scaleXMid, {\n duration: indeterminateDuration / 2, // divided by 2 since we animate it with 2 steps in a sequence\n easing: indeterminateEasing,\n }),\n withTiming(indeterminateAnimation.scaleXFinal, {\n duration: indeterminateDuration / 2, // divided by 2 since we animate it with 2 steps in a sequence\n easing: indeterminateEasing,\n }),\n ),\n -1,\n );\n }\n\n return () => {\n cancelAnimation(animatedLeft);\n cancelAnimation(animatedScaleX);\n };\n }, [animatedLeft, animatedScaleX, indeterminateMotionDuration, isIndeterminate, theme, variant]);\n\n // Animated styles for indeterminate animation\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n //@ts-expect-error TS errors originating from reanimated. Should be fixed in future versions. Ref: https://github.com/software-mansion/react-native-reanimated/issues/4840\n const indeterminateAnimatedStyle = useAnimatedStyle(() => {\n return {\n left: animatedLeft.value,\n transform: [{ scaleX: animatedScaleX.value }],\n };\n });\n\n //Trigger pulsating animation\n useEffect(() => {\n const pulsatingAnimationTimingConfig = {\n duration: pulseDuration,\n easing: fillAndPulseEasing,\n };\n if (variant === 'progress') {\n animatedOpacity.value = withDelay(\n castNativeType(makeMotionTime(getIn(theme.motion, pulseMotionDelay))),\n withRepeat(\n withSequence(\n withTiming(pulseAnimation.opacityMid, pulsatingAnimationTimingConfig),\n withTiming(pulseAnimation.opacityFinal, pulsatingAnimationTimingConfig),\n ),\n -1,\n ),\n );\n }\n\n return () => {\n cancelAnimation(animatedOpacity);\n };\n }, [animatedOpacity, fillAndPulseEasing, pulseDuration, pulseMotionDelay, theme, variant]);\n\n // Animated styles for pulse animation\n const pulseAnimatedStyle = useAnimatedStyle(() => {\n return {\n opacity: animatedOpacity.value,\n };\n });\n\n const ProgressBarFilledContainer = isIndeterminate\n ? ProgressBarIndeterminateFilledContainer\n : ProgressBarDeterminateFilledContainer;\n\n return (\n <ProgressBarFilledContainer\n style={isIndeterminate ? indeterminateAnimatedStyle : progressFillAnimatedStyle}\n backgroundColor={backgroundColor}\n progress={progress}\n >\n <ProgressBarPulseAnimation style={pulseAnimatedStyle} />\n </ProgressBarFilledContainer>\n );\n};\n\nexport type { ProgressBarFilledProps };\nexport { ProgressBarFilled };\n"],"names":["ProgressBarIndeterminateFilledContainer","styled","Animated","View","_ref","backgroundColor","height","width","indeterminateAnimation","fillWidth","position","ProgressBarDeterminateFilledContainer","_ref2","progress","ProgressBarPulseAnimation","pulseAnimation","opacity","opacityInitial","ProgressBarFilled","_ref3","fillMotionDuration","motionEasing","pulseMotionDuration","pulseMotionDelay","variant","isIndeterminate","indeterminateMotionDuration","animatedWidth","useSharedValue","animatedOpacity","animatedScaleX","scaleXInitial","animatedLeft","leftInitial","_useTheme","useTheme","theme","fillAndPulseEasing","getIn","motion","pulseDuration","castNativeType","makeMotionTime","useEffect","fillDuration","value","withTiming","duration","easing","cancelAnimation","progressFillAnimatedStyle","useAnimatedStyle","indeterminateDuration","indeterminateEasing","Easing","linear","withRepeat","leftFinal","withSequence","scaleXMid","scaleXFinal","indeterminateAnimatedStyle","left","transform","scaleX","pulsatingAnimationTimingConfig","withDelay","opacityMid","opacityFinal","pulseAnimatedStyle","ProgressBarFilledContainer","_jsx","style","children"],"mappings":";;;;;;;;;;;;;;;AAmBA,IAAMA,uCAAuC,CAAGC,MAAM,CAACC,QAAQ,CAACC,IAAI,CAAC,CAEnE,SAAAC,IAAA,CAAA,CAAA,IAAGC,eAAe,CAAAD,IAAA,CAAfC,eAAe,QAAQ,CAC1BA,eAAe,CAAfA,eAAe,CACfC,MAAM,CAAE,MAAM,CACdC,KAAK,CAAEC,sBAAsB,CAACC,SAAS,CACvCC,QAAQ,CAAE,UACZ,CAAC,CAAC,CAAA,CAAC,CAEH,IAAMC,qCAAqC,CAAGV,MAAM,CAACC,QAAQ,CAACC,IAAI,CAAC,CAEjE,SAAAS,KAAA,CAAA,CAAA,IAAGP,eAAe,CAAAO,KAAA,CAAfP,eAA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C,CACH,CAAC,CAAE,CAACA,eAAe,CAAEQ,kBAAkB,CAAEG,aAAa,CAAEjB,gBAAgB,CAAEa,KAAK,CAAEZ,OAAO,CAAC,CAAC,CAG1F,IAAM6C,kBAAkB,CAAGlB,gBAAgB,CAAC,UAAM,CAChD,OAAO,CACLnC,OAAO,CAAEa,eAAe,CAACgB,KAC3B,CAAC,CACH,CAAC,CAAC,CAEF,IAAMyB,0BAA0B,CAAG7C,eAAe,CAC9CzB,uCAAuC,CACvCW,qCAAqC,CAEzC,OACE4D,GAAA,CAACD,0BAA0B,CACzBE,CAAAA,KAAK,CAAE/C,eAAe,CAAGoC,0BAA0B,CAAGX,yBAA0B,CAChF7C,eAAe,CAAEA,eAAgB,CACjCQ,QAAQ,CAAEA,QAAS,CAAA4D,QAAA,CAEnBF,GAAA,CAACzD,yBAAyB,CAAA,CAAC0D,KAAK,CAAEH,kBAAmB,CAAE,CAAC,CAC9B,CAAC,CAEjC;;;;"}
|
|
1
|
+
{"version":3,"file":"ProgressBarFilled.native.js","sources":["../../../../../src/components/ProgressBar/ProgressBarFilled.native.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport styled from 'styled-components';\nimport Animated, {\n cancelAnimation,\n Easing,\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withRepeat,\n withSequence,\n withTiming,\n} from 'react-native-reanimated';\nimport type { ProgressBarFilledProps } from './types';\nimport { indeterminateAnimation, pulseAnimation } from './progressBarTokens';\nimport getIn from '~utils/lodashButBetter/get';\nimport { useTheme } from '~components/BladeProvider';\nimport { castNativeType } from '~utils';\nimport { makeMotionTime } from '~utils/makeMotionTime';\n\nconst ProgressBarIndeterminateFilledContainer = styled(Animated.View)<\n Pick<ProgressBarFilledProps, 'backgroundColor' | 'progress'>\n>(({ backgroundColor }) => ({\n backgroundColor,\n height: '100%',\n width: indeterminateAnimation.fillWidth,\n position: 'absolute',\n}));\n\nconst ProgressBarDeterminateFilledContainer = styled(Animated.View)<\n Pick<ProgressBarFilledProps, 'backgroundColor' | 'progress'>\n>(({ backgroundColor, progress }) => ({\n backgroundColor,\n height: '100%',\n width: `${progress}%`,\n}));\n\nconst ProgressBarPulseAnimation = styled(Animated.View)({\n backgroundColor: pulseAnimation.backgroundColor,\n opacity: pulseAnimation.opacityInitial,\n width: '100%',\n height: '100%',\n});\n\nconst ProgressBarFilled = ({\n backgroundColor,\n progress,\n fillMotionDuration,\n motionEasing,\n pulseMotionDuration,\n pulseMotionDelay,\n type,\n isIndeterminate,\n indeterminateMotionDuration,\n}: ProgressBarFilledProps): React.ReactElement => {\n const animatedWidth = useSharedValue(progress); // for progress fill animation\n const animatedOpacity = useSharedValue(pulseAnimation.opacityInitial); // for pulse animation\n const animatedScaleX = useSharedValue(indeterminateAnimation.scaleXInitial); // for indeterminate scale animation\n const animatedLeft = useSharedValue(indeterminateAnimation.leftInitial); // for indeterminate slide animation\n\n const { theme } = useTheme();\n const fillAndPulseEasing = getIn(theme.motion, motionEasing);\n const pulseDuration =\n castNativeType(makeMotionTime(getIn(theme.motion, pulseMotionDuration))) / 2; // divided by 2 since we animate it with 2 steps in a sequence\n\n // Trigger animation for progress fill\n useEffect(() => {\n const fillDuration = castNativeType(makeMotionTime(getIn(theme.motion, fillMotionDuration)));\n animatedWidth.value = withTiming(progress, {\n duration: fillDuration,\n easing: fillAndPulseEasing,\n });\n return () => {\n cancelAnimation(animatedWidth);\n };\n }, [progress, animatedWidth, fillMotionDuration, theme, fillAndPulseEasing]);\n\n // Animated styles for progress fill animation\n const progressFillAnimatedStyle = useAnimatedStyle(() => {\n return {\n width: `${animatedWidth.value}%`,\n };\n });\n\n // Trigger animation for indeterminate progress bar\n useEffect(() => {\n if (type === 'progress' && isIndeterminate) {\n const indeterminateDuration = castNativeType(\n makeMotionTime(getIn(theme.motion, indeterminateMotionDuration)),\n );\n const indeterminateEasing = Easing.linear;\n\n // Sliding animation\n animatedLeft.value = withRepeat(\n withTiming(indeterminateAnimation.leftFinal, {\n duration: indeterminateDuration,\n easing: indeterminateEasing,\n }),\n -1,\n );\n\n // Scaling animation\n animatedScaleX.value = withRepeat(\n withSequence(\n withTiming(indeterminateAnimation.scaleXMid, {\n duration: indeterminateDuration / 2, // divided by 2 since we animate it with 2 steps in a sequence\n easing: indeterminateEasing,\n }),\n withTiming(indeterminateAnimation.scaleXFinal, {\n duration: indeterminateDuration / 2, // divided by 2 since we animate it with 2 steps in a sequence\n easing: indeterminateEasing,\n }),\n ),\n -1,\n );\n }\n\n return () => {\n cancelAnimation(animatedLeft);\n cancelAnimation(animatedScaleX);\n };\n }, [animatedLeft, animatedScaleX, indeterminateMotionDuration, isIndeterminate, theme, type]);\n\n // Animated styles for indeterminate animation\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n //@ts-expect-error TS errors originating from reanimated. Should be fixed in future versions. Ref: https://github.com/software-mansion/react-native-reanimated/issues/4840\n const indeterminateAnimatedStyle = useAnimatedStyle(() => {\n return {\n left: animatedLeft.value,\n transform: [{ scaleX: animatedScaleX.value }],\n };\n });\n\n //Trigger pulsating animation\n useEffect(() => {\n const pulsatingAnimationTimingConfig = {\n duration: pulseDuration,\n easing: fillAndPulseEasing,\n };\n if (type === 'progress') {\n animatedOpacity.value = withDelay(\n castNativeType(makeMotionTime(getIn(theme.motion, pulseMotionDelay))),\n withRepeat(\n withSequence(\n withTiming(pulseAnimation.opacityMid, pulsatingAnimationTimingConfig),\n withTiming(pulseAnimation.opacityFinal, pulsatingAnimationTimingConfig),\n ),\n -1,\n ),\n );\n }\n\n return () => {\n cancelAnimation(animatedOpacity);\n };\n }, [animatedOpacity, fillAndPulseEasing, pulseDuration, pulseMotionDelay, theme, type]);\n\n // Animated styles for pulse animation\n const pulseAnimatedStyle = useAnimatedStyle(() => {\n return {\n opacity: animatedOpacity.value,\n };\n });\n\n const ProgressBarFilledContainer = isIndeterminate\n ? ProgressBarIndeterminateFilledContainer\n : ProgressBarDeterminateFilledContainer;\n\n return (\n <ProgressBarFilledContainer\n style={isIndeterminate ? indeterminateAnimatedStyle : progressFillAnimatedStyle}\n backgroundColor={backgroundColor}\n progress={progress}\n >\n <ProgressBarPulseAnimation style={pulseAnimatedStyle} />\n </ProgressBarFilledContainer>\n );\n};\n\nexport type { ProgressBarFilledProps };\nexport { ProgressBarFilled };\n"],"names":["ProgressBarIndeterminateFilledContainer","styled","Animated","View","_ref","backgroundColor","height","width","indeterminateAnimation","fillWidth","position","ProgressBarDeterminateFilledContainer","_ref2","progress","ProgressBarPulseAnimation","pulseAnimation","opacity","opacityInitial","ProgressBarFilled","_ref3","fillMotionDuration","motionEasing","pulseMotionDuration","pulseMotionDelay","type","isIndeterminate","indeterminateMotionDuration","animatedWidth","useSharedValue","animatedOpacity","animatedScaleX","scaleXInitial","animatedLeft","leftInitial","_useTheme","useTheme","theme","fillAndPulseEasing","getIn","motion","pulseDuration","castNativeType","makeMotionTime","useEffect","fillDuration","value","withTiming","duration","easing","cancelAnimation","progressFillAnimatedStyle","useAnimatedStyle","indeterminateDuration","indeterminateEasing","Easing","linear","withRepeat","leftFinal","withSequence","scaleXMid","scaleXFinal","indeterminateAnimatedStyle","left","transform","scaleX","pulsatingAnimationTimingConfig","withDelay","opacityMid","opacityFinal","pulseAnimatedStyle","ProgressBarFilledContainer","_jsx","style","children"],"mappings":";;;;;;;;;;;;;;;AAmBA,IAAMA,uCAAuC,CAAGC,MAAM,CAACC,QAAQ,CAACC,IAAI,CAAC,CAEnE,SAAAC,IAAA,CAAA,CAAA,IAAGC,eAAe,CAAAD,IAAA,CAAfC,eAAe,QAAQ,CAC1BA,eAAe,CAAfA,eAAe,CACfC,MAAM,CAAE,MAAM,CACdC,KAAK,CAAEC,sBAAsB,CAACC,SAAS,CACvCC,QAAQ,CAAE,UACZ,CAAC,CAAC,CAAA,CAAC,CAEH,IAAMC,qCAAqC,CAAGV,MAAM,CAACC,QAAQ,CAACC,IAAI,CAAC,CAEjE,SAAAS,KAAA,CAAA,CAAA,IAAGP,eAAe,CAAAO,KAAA,CAAfP,eAAe,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ACH,CAAC,CAAE,CAACA,eAAe,CAAEQ,kBAAkB,CAAEG,aAAa,CAAEjB,gBAAgB,CAAEa,KAAK,CAAEZ,IAAI,CAAC,CAAC,CAGvF,IAAM6C,kBAAkB,CAAGlB,gBAAgB,CAAC,UAAM,CAChD,OAAO,CACLnC,OAAO,CAAEa,eAAe,CAACgB,KAC3B,CAAC,CACH,CAAC,CAAC,CAEF,IAAMyB,0BAA0B,CAAG7C,eAAe,CAC9CzB,uCAAuC,CACvCW,qCAAqC,CAEzC,OACE4D,GAAA,CAACD,0BAA0B,CACzBE,CAAAA,KAAK,CAAE/C,eAAe,CAAGoC,0BAA0B,CAAGX,yBAA0B,CAChF7C,eAAe,CAAEA,eAAgB,CACjCQ,QAAQ,CAAEA,QAAS,CAAA4D,QAAA,CAEnBF,GAAA,CAACzD,yBAAyB,CAAA,CAAC0D,KAAK,CAAEH,kBAAmB,CAAE,CAAC,CAC9B,CAAC,CAEjC;;;;"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import '../../tokens/global/typography.js';
|
|
2
|
+
import '../../tokens/global/motion.js';
|
|
3
|
+
import { size } from '../../tokens/global/size.js';
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
var indeterminateAnimation={scaleXInitial:1,scaleXMid:5,scaleXFinal:1,leftInitial:'-8%',leftMid:'50%',leftFinal:'103%',fillWidth:'5%'};var pulseAnimation={opacityInitial:0,opacityMid:0.25,opacityFinal:0,backgroundColor:'white'};var circularProgressSizeTokens={small:{size:size[24],strokeWidth:size[3],percentTextSize:'small'},medium:{size:size[48],strokeWidth:size[5],percentTextSize:'small'},large:{size:size[72],strokeWidth:size[7],percentTextSize:'medium'}};var getCircularProgressSVGTokens=function getCircularProgressSVGTokens(_ref){var size=_ref.size,progressPercent=_ref.progressPercent;var sqSize=circularProgressSizeTokens[size].size;var strokeWidth=circularProgressSizeTokens[size].strokeWidth;var radius=(sqSize-strokeWidth)/2;var viewBox=`0 0 ${sqSize} ${sqSize}`;var dashArray=radius*Math.PI*2;var dashOffset=dashArray-dashArray*progressPercent/100;return {sqSize:sqSize,strokeWidth:strokeWidth,radius:radius,viewBox:viewBox,dashArray:dashArray,dashOffset:dashOffset};};
|
|
6
|
+
|
|
7
|
+
export { circularProgressSizeTokens, getCircularProgressSVGTokens, indeterminateAnimation, pulseAnimation };
|
|
4
8
|
//# sourceMappingURL=progressBarTokens.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progressBarTokens.js","sources":["../../../../../src/components/ProgressBar/progressBarTokens.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"progressBarTokens.js","sources":["../../../../../src/components/ProgressBar/progressBarTokens.ts"],"sourcesContent":["import type { CircularProgressBarFilledProps } from './types';\nimport { size } from '~tokens/global';\n\nconst indeterminateAnimation = {\n scaleXInitial: 1,\n scaleXMid: 5,\n scaleXFinal: 1,\n leftInitial: '-8%',\n leftMid: '50%',\n leftFinal: '103%',\n fillWidth: '5%',\n};\n\nconst pulseAnimation = {\n opacityInitial: 0,\n opacityMid: 0.25,\n opacityFinal: 0,\n backgroundColor: 'white',\n};\n\nconst circularProgressSizeTokens = {\n small: {\n size: size[24],\n strokeWidth: size[3],\n percentTextSize: 'small',\n },\n medium: {\n size: size[48],\n strokeWidth: size[5],\n percentTextSize: 'small',\n },\n large: {\n size: size[72],\n strokeWidth: size[7],\n percentTextSize: 'medium',\n },\n} as const;\n\nconst getCircularProgressSVGTokens = ({\n size,\n progressPercent,\n}: {\n size: NonNullable<CircularProgressBarFilledProps['size']>;\n progressPercent: number;\n}): {\n sqSize: number;\n strokeWidth: number;\n radius: number;\n viewBox: string;\n dashArray: number;\n dashOffset: number;\n} => {\n // Size of the enclosing square\n const sqSize = circularProgressSizeTokens[size].size;\n const strokeWidth = circularProgressSizeTokens[size].strokeWidth;\n\n // SVG centers the stroke width on the radius, subtract out so circle fits in square\n const radius = (sqSize - strokeWidth) / 2;\n // Enclose circle in a circumscribing square\n const viewBox = `0 0 ${sqSize} ${sqSize}`;\n // Arc length at 100% coverage is the circle circumference\n const dashArray = radius * Math.PI * 2;\n // Scale 100% coverage overlay with the actual percent\n const dashOffset = dashArray - (dashArray * progressPercent) / 100;\n\n return {\n sqSize,\n strokeWidth,\n radius,\n viewBox,\n dashArray,\n dashOffset,\n };\n};\n\nexport {\n indeterminateAnimation,\n pulseAnimation,\n circularProgressSizeTokens,\n getCircularProgressSVGTokens,\n};\n"],"names":["indeterminateAnimation","scaleXInitial","scaleXMid","scaleXFinal","leftInitial","leftMid","leftFinal","fillWidth","pulseAnimation","opacityInitial","opacityMid","opacityFinal","backgroundColor","circularProgressSizeTokens","small","size","strokeWidth","percentTextSize","medium","large","getCircularProgressSVGTokens","_ref","progressPercent","sqSize","radius","viewBox","dashArray","Math","PI","dashOffset"],"mappings":";;;;AAGM,IAAAA,sBAAsB,CAAG,CAC7BC,aAAa,CAAE,CAAC,CAChBC,SAAS,CAAE,CAAC,CACZC,WAAW,CAAE,CAAC,CACdC,WAAW,CAAE,KAAK,CAClBC,OAAO,CAAE,KAAK,CACdC,SAAS,CAAE,MAAM,CACjBC,SAAS,CAAE,IACb,EAEM,IAAAC,cAAc,CAAG,CACrBC,cAAc,CAAE,CAAC,CACjBC,UAAU,CAAE,IAAI,CAChBC,YAAY,CAAE,CAAC,CACfC,eAAe,CAAE,OACnB,EAEM,IAAAC,0BAA0B,CAAG,CACjCC,KAAK,CAAE,CACLC,IAAI,CAAEA,IAAI,CAAC,EAAE,CAAC,CACdC,WAAW,CAAED,IAAI,CAAC,CAAC,CAAC,CACpBE,eAAe,CAAE,OACnB,CAAC,CACDC,MAAM,CAAE,CACNH,IAAI,CAAEA,IAAI,CAAC,EAAE,CAAC,CACdC,WAAW,CAAED,IAAI,CAAC,CAAC,CAAC,CACpBE,eAAe,CAAE,OACnB,CAAC,CACDE,KAAK,CAAE,CACLJ,IAAI,CAAEA,IAAI,CAAC,EAAE,CAAC,CACdC,WAAW,CAAED,IAAI,CAAC,CAAC,CAAC,CACpBE,eAAe,CAAE,QACnB,CACF,EAEM,IAAAG,4BAA4B,CAAG,SAA/BA,4BAA4BA,CAAAC,IAAA,CAa7B,CAZH,IAAAN,IAAI,CAAAM,IAAA,CAAJN,IAAI,CACJO,eAAe,CAAAD,IAAA,CAAfC,eAAe,CAaf,IAAMC,MAAM,CAAGV,0BAA0B,CAACE,IAAI,CAAC,CAACA,IAAI,CACpD,IAAMC,WAAW,CAAGH,0BAA0B,CAACE,IAAI,CAAC,CAACC,WAAW,CAGhE,IAAMQ,MAAM,CAAG,CAACD,MAAM,CAAGP,WAAW,EAAI,CAAC,CAEzC,IAAMS,OAAO,CAAI,CAAMF,IAAAA,EAAAA,MAAO,CAAGA,CAAAA,EAAAA,MAAO,CAAC,CAAA,CAEzC,IAAMG,SAAS,CAAGF,MAAM,CAAGG,IAAI,CAACC,EAAE,CAAG,CAAC,CAEtC,IAAMC,UAAU,CAAGH,SAAS,CAAIA,SAAS,CAAGJ,eAAe,CAAI,GAAG,CAElE,OAAO,CACLC,MAAM,CAANA,MAAM,CACNP,WAAW,CAAXA,WAAW,CACXQ,MAAM,CAANA,MAAM,CACNC,OAAO,CAAPA,OAAO,CACPC,SAAS,CAATA,SAAS,CACTG,UAAU,CAAVA,UACF,CAAC,CACH;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var size={0:0,1:1,2:2,3:3,4:4,5:5,6:6,8:8,10:10,12:12,16:16,18:18,20:20,24:24,28:28,32:32,36:36,40:40,44:44,48:48,56:56,64:64,100:100,120:120,140:140,160:160,176:176,200:200,240:240,300:300,360:360,400:400,584:584,640:640,760:760,800:800,1024:1024,1136:1136};
|
|
1
|
+
var size={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,10:10,12:12,16:16,18:18,20:20,24:24,28:28,32:32,36:36,40:40,44:44,48:48,56:56,64:64,72:72,100:100,120:120,140:140,160:160,176:176,200:200,240:240,300:300,360:360,400:400,584:584,640:640,760:760,800:800,1024:1024,1136:1136};
|
|
2
2
|
|
|
3
3
|
export { size };
|
|
4
4
|
//# sourceMappingURL=size.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"size.js","sources":["../../../../../src/tokens/global/size.ts"],"sourcesContent":["/**\n * Size tokens are currently not exposed for users (therefore not available in theme)\n */\nexport const size = {\n /** 0 px */\n 0: 0,\n /** 1 px */\n 1: 1,\n /** 2 px */\n 2: 2,\n /** 3 px */\n 3: 3,\n /** 4 px */\n 4: 4,\n /** 5 px */\n 5: 5,\n /** 6 px */\n 6: 6,\n /** 8 px */\n 8: 8,\n /** 10 px */\n 10: 10,\n /** 12 px */\n 12: 12,\n /** 16 px */\n 16: 16,\n /** 18 px */\n 18: 18,\n /** 20 px */\n 20: 20,\n /** 24 px */\n 24: 24,\n /** 28 px */\n 28: 28,\n /** 32 px */\n 32: 32,\n /** 36 px */\n 36: 36,\n /** 40 px */\n 40: 40,\n /** 44 px */\n 44: 44,\n /** 48 px */\n 48: 48,\n /** 56 px */\n 56: 56,\n /** 64 px */\n 64: 64,\n /** 100 px */\n 100: 100,\n /** 120 px */\n 120: 120,\n /** 140 px */\n 140: 140,\n /** 160 px */\n 160: 160,\n /** 176 px */\n 176: 176,\n /** 200 px */\n 200: 200,\n /** 240 px */\n 240: 240,\n /** 300 px */\n 300: 300,\n /** 360 px */\n 360: 360,\n /** 400 px */\n 400: 400,\n /** 584 px */\n 584: 584,\n /** 640 px */\n 640: 640,\n /** 760 px */\n 760: 760,\n /** 800 px */\n 800: 800,\n /** 1024 px */\n 1024: 1024,\n /** 1136 px */\n 1136: 1136,\n} as const;\n\nexport type Size = typeof size;\n"],"names":["size"],"mappings":"AAGa,IAAAA,IAAI,CAAG,CAElB,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,IAAI,CAAE,IAAI,CAEV,IAAI,CAAE,IACR;;;;"}
|
|
1
|
+
{"version":3,"file":"size.js","sources":["../../../../../src/tokens/global/size.ts"],"sourcesContent":["/**\n * Size tokens are currently not exposed for users (therefore not available in theme)\n */\nexport const size = {\n /** 0 px */\n 0: 0,\n /** 1 px */\n 1: 1,\n /** 2 px */\n 2: 2,\n /** 3 px */\n 3: 3,\n /** 4 px */\n 4: 4,\n /** 5 px */\n 5: 5,\n /** 6 px */\n 6: 6,\n /** 7 px */\n 7: 7,\n /** 8 px */\n 8: 8,\n /** 10 px */\n 10: 10,\n /** 12 px */\n 12: 12,\n /** 16 px */\n 16: 16,\n /** 18 px */\n 18: 18,\n /** 20 px */\n 20: 20,\n /** 24 px */\n 24: 24,\n /** 28 px */\n 28: 28,\n /** 32 px */\n 32: 32,\n /** 36 px */\n 36: 36,\n /** 40 px */\n 40: 40,\n /** 44 px */\n 44: 44,\n /** 48 px */\n 48: 48,\n /** 56 px */\n 56: 56,\n /** 64 px */\n 64: 64,\n /** 72 px */\n 72: 72,\n /** 100 px */\n 100: 100,\n /** 120 px */\n 120: 120,\n /** 140 px */\n 140: 140,\n /** 160 px */\n 160: 160,\n /** 176 px */\n 176: 176,\n /** 200 px */\n 200: 200,\n /** 240 px */\n 240: 240,\n /** 300 px */\n 300: 300,\n /** 360 px */\n 360: 360,\n /** 400 px */\n 400: 400,\n /** 584 px */\n 584: 584,\n /** 640 px */\n 640: 640,\n /** 760 px */\n 760: 760,\n /** 800 px */\n 800: 800,\n /** 1024 px */\n 1024: 1024,\n /** 1136 px */\n 1136: 1136,\n} as const;\n\nexport type Size = typeof size;\n"],"names":["size"],"mappings":"AAGa,IAAAA,IAAI,CAAG,CAElB,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,IAAI,CAAE,IAAI,CAEV,IAAI,CAAE,IACR;;;;"}
|
|
@@ -85,7 +85,15 @@ var CountrySelector = function CountrySelector(_ref) {
|
|
|
85
85
|
variant: "tertiary",
|
|
86
86
|
accessibilityLabel: "".concat(countryNameFormatter.of(selectedCountry), " - Select Country"),
|
|
87
87
|
icon: isDropdownOpen ? ChevronUpIcon : ChevronDownIcon,
|
|
88
|
-
iconPosition: "right"
|
|
88
|
+
iconPosition: "right"
|
|
89
|
+
// We need to prevent the click event from propagating to the BaseInputWrapper,
|
|
90
|
+
// Because the BaseInputWrapper is listening for click events to focus the input.
|
|
91
|
+
// We don't want that to happen when the user clicks on the dropdown button
|
|
92
|
+
// otherwise the dropdown will close immediately after opening
|
|
93
|
+
,
|
|
94
|
+
onClick: function onClick(e) {
|
|
95
|
+
e.stopPropagation();
|
|
96
|
+
},
|
|
89
97
|
children: /*#__PURE__*/jsx("img", {
|
|
90
98
|
loading: "lazy",
|
|
91
99
|
role: "presentation",
|
package/build/lib/web/development/components/Input/PhoneNumberInput/CountrySelector.web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CountrySelector.web.js","sources":["../../../../../../../src/components/Input/PhoneNumberInput/CountrySelector.web.tsx"],"sourcesContent":["import type { CountryCodeType, getFlagsForAllCountries } from '@razorpay/i18nify-js';\nimport { getDialCodeByCountryCode, getFlagOfCountry } from '@razorpay/i18nify-js';\nimport React from 'react';\nimport styled from 'styled-components';\nimport {\n ActionList,\n ActionListItem,\n ActionListItemAsset,\n ActionListItemText,\n} from '~components/ActionList';\nimport { BottomSheet, BottomSheetBody, BottomSheetHeader } from '~components/BottomSheet';\nimport type { DropdownOverlayProps } from '~components/Dropdown';\nimport { Dropdown, DropdownButton, DropdownOverlay } from '~components/Dropdown';\nimport { ChevronDownIcon, ChevronUpIcon } from '~components/Icons';\nimport { useIsMobile } from '~utils/useIsMobile';\nimport { size as sizes } from '~tokens/global';\nimport { makeSize } from '~utils';\nimport BaseBox from '~components/Box/BaseBox';\n\nconst countryNameFormatter = new Intl.DisplayNames(['en'], { type: 'region' });\n\ntype CountryData = {\n code: CountryCodeType;\n name: string;\n}[];\ntype CounterSelectorProps = {\n selectedCountry: CountryCodeType;\n inputWrapperRef: DropdownOverlayProps['referenceRef'];\n countryData: CountryData;\n onItemClick: (props: { name: string }) => void;\n flags: ReturnType<typeof getFlagsForAllCountries>;\n isDisabled?: boolean;\n size: 'medium' | 'large';\n};\n\nconst CountryDropdownButtonWrapper = styled(BaseBox)(() => {\n return {\n '& > button': {\n padding: '0',\n width: '100%',\n },\n };\n});\n\nconst CountrySelector = ({\n isDisabled,\n selectedCountry,\n inputWrapperRef,\n countryData,\n onItemClick,\n flags,\n size,\n}: CounterSelectorProps): React.ReactElement => {\n const [isDropdownOpen, setIsDropdownOpen] = React.useState(false);\n const isMobile = useIsMobile();\n\n const actionList = (\n <ActionList>\n {countryData.map((country) => {\n return (\n <ActionListItem\n key={country.code}\n onClick={onItemClick}\n leading={<ActionListItemAsset src={flags[country.code]['4X3']} alt={country.name} />}\n title={country.name}\n value={country.code}\n trailing={\n <ActionListItemText>{getDialCodeByCountryCode(country.code)}</ActionListItemText>\n }\n />\n );\n })}\n </ActionList>\n );\n\n const flagSize = {\n medium: makeSize(sizes[20]),\n large: makeSize(sizes[24]),\n } as const;\n\n return (\n <Dropdown isOpen={isDropdownOpen} onOpenChange={setIsDropdownOpen}>\n {/* TODO: Remove once CountrySelector's button sizing is fixed in figma */}\n <CountryDropdownButtonWrapper\n width={size === 'medium' ? '45px' : '60px'}\n marginLeft={size === 'medium' ? '-3px' : '-2px'}\n >\n <DropdownButton\n isDisabled={isDisabled}\n size={size === 'medium' ? 'xsmall' : 'medium'}\n variant=\"tertiary\"\n accessibilityLabel={`${countryNameFormatter.of(selectedCountry)} - Select Country`}\n icon={isDropdownOpen ? ChevronUpIcon : ChevronDownIcon}\n iconPosition=\"right\"\n >\n {/* @ts-expect-error */}\n <img\n loading=\"lazy\"\n role=\"presentation\"\n width={flagSize[size]}\n src={getFlagOfCountry(selectedCountry)['4X3']}\n alt=\"\"\n />\n </DropdownButton>\n </CountryDropdownButtonWrapper>\n {isMobile ? (\n <BottomSheet>\n <BottomSheetHeader title=\"Select A Country\" />\n <BottomSheetBody>{actionList}</BottomSheetBody>\n </BottomSheet>\n ) : (\n <DropdownOverlay referenceRef={inputWrapperRef}>{actionList}</DropdownOverlay>\n )}\n </Dropdown>\n );\n};\n\nexport { CountrySelector, countryNameFormatter };\n"],"names":["countryNameFormatter","Intl","DisplayNames","type","CountryDropdownButtonWrapper","styled","BaseBox","withConfig","displayName","componentId","padding","width","CountrySelector","_ref","isDisabled","selectedCountry","inputWrapperRef","countryData","onItemClick","flags","size","_React$useState","React","useState","_React$useState2","_slicedToArray","isDropdownOpen","setIsDropdownOpen","isMobile","useIsMobile","actionList","_jsx","ActionList","children","map","country","ActionListItem","onClick","leading","ActionListItemAsset","src","code","alt","name","title","value","trailing","ActionListItemText","getDialCodeByCountryCode","flagSize","medium","makeSize","sizes","large","_jsxs","Dropdown","isOpen","onOpenChange","marginLeft","DropdownButton","variant","accessibilityLabel","concat","of","icon","ChevronUpIcon","ChevronDownIcon","iconPosition","loading","role","getFlagOfCountry","BottomSheet","BottomSheetHeader","BottomSheetBody","DropdownOverlay","referenceRef"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBMA,IAAAA,oBAAoB,GAAG,IAAIC,IAAI,CAACC,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE;AAAEC,EAAAA,IAAI,EAAE,QAAA;AAAS,CAAC,EAAC;AAgB9E,IAAMC,4BAA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B;AACvDC,QAAAA,YAAY,EAAC,OAAO;
|
|
1
|
+
{"version":3,"file":"CountrySelector.web.js","sources":["../../../../../../../src/components/Input/PhoneNumberInput/CountrySelector.web.tsx"],"sourcesContent":["import type { CountryCodeType, getFlagsForAllCountries } from '@razorpay/i18nify-js';\nimport { getDialCodeByCountryCode, getFlagOfCountry } from '@razorpay/i18nify-js';\nimport React from 'react';\nimport styled from 'styled-components';\nimport {\n ActionList,\n ActionListItem,\n ActionListItemAsset,\n ActionListItemText,\n} from '~components/ActionList';\nimport { BottomSheet, BottomSheetBody, BottomSheetHeader } from '~components/BottomSheet';\nimport type { DropdownOverlayProps } from '~components/Dropdown';\nimport { Dropdown, DropdownButton, DropdownOverlay } from '~components/Dropdown';\nimport { ChevronDownIcon, ChevronUpIcon } from '~components/Icons';\nimport { useIsMobile } from '~utils/useIsMobile';\nimport { size as sizes } from '~tokens/global';\nimport { makeSize } from '~utils';\nimport BaseBox from '~components/Box/BaseBox';\n\nconst countryNameFormatter = new Intl.DisplayNames(['en'], { type: 'region' });\n\ntype CountryData = {\n code: CountryCodeType;\n name: string;\n}[];\ntype CounterSelectorProps = {\n selectedCountry: CountryCodeType;\n inputWrapperRef: DropdownOverlayProps['referenceRef'];\n countryData: CountryData;\n onItemClick: (props: { name: string }) => void;\n flags: ReturnType<typeof getFlagsForAllCountries>;\n isDisabled?: boolean;\n size: 'medium' | 'large';\n};\n\nconst CountryDropdownButtonWrapper = styled(BaseBox)(() => {\n return {\n '& > button': {\n padding: '0',\n width: '100%',\n },\n };\n});\n\nconst CountrySelector = ({\n isDisabled,\n selectedCountry,\n inputWrapperRef,\n countryData,\n onItemClick,\n flags,\n size,\n}: CounterSelectorProps): React.ReactElement => {\n const [isDropdownOpen, setIsDropdownOpen] = React.useState(false);\n const isMobile = useIsMobile();\n\n const actionList = (\n <ActionList>\n {countryData.map((country) => {\n return (\n <ActionListItem\n key={country.code}\n onClick={onItemClick}\n leading={<ActionListItemAsset src={flags[country.code]['4X3']} alt={country.name} />}\n title={country.name}\n value={country.code}\n trailing={\n <ActionListItemText>{getDialCodeByCountryCode(country.code)}</ActionListItemText>\n }\n />\n );\n })}\n </ActionList>\n );\n\n const flagSize = {\n medium: makeSize(sizes[20]),\n large: makeSize(sizes[24]),\n } as const;\n\n return (\n <Dropdown isOpen={isDropdownOpen} onOpenChange={setIsDropdownOpen}>\n {/* TODO: Remove once CountrySelector's button sizing is fixed in figma */}\n <CountryDropdownButtonWrapper\n width={size === 'medium' ? '45px' : '60px'}\n marginLeft={size === 'medium' ? '-3px' : '-2px'}\n >\n <DropdownButton\n isDisabled={isDisabled}\n size={size === 'medium' ? 'xsmall' : 'medium'}\n variant=\"tertiary\"\n accessibilityLabel={`${countryNameFormatter.of(selectedCountry)} - Select Country`}\n icon={isDropdownOpen ? ChevronUpIcon : ChevronDownIcon}\n iconPosition=\"right\"\n // We need to prevent the click event from propagating to the BaseInputWrapper,\n // Because the BaseInputWrapper is listening for click events to focus the input.\n // We don't want that to happen when the user clicks on the dropdown button\n // otherwise the dropdown will close immediately after opening\n onClick={(e) => {\n e.stopPropagation();\n }}\n >\n {/* @ts-expect-error */}\n <img\n loading=\"lazy\"\n role=\"presentation\"\n width={flagSize[size]}\n src={getFlagOfCountry(selectedCountry)['4X3']}\n alt=\"\"\n />\n </DropdownButton>\n </CountryDropdownButtonWrapper>\n {isMobile ? (\n <BottomSheet>\n <BottomSheetHeader title=\"Select A Country\" />\n <BottomSheetBody>{actionList}</BottomSheetBody>\n </BottomSheet>\n ) : (\n <DropdownOverlay referenceRef={inputWrapperRef}>{actionList}</DropdownOverlay>\n )}\n </Dropdown>\n );\n};\n\nexport { CountrySelector, countryNameFormatter };\n"],"names":["countryNameFormatter","Intl","DisplayNames","type","CountryDropdownButtonWrapper","styled","BaseBox","withConfig","displayName","componentId","padding","width","CountrySelector","_ref","isDisabled","selectedCountry","inputWrapperRef","countryData","onItemClick","flags","size","_React$useState","React","useState","_React$useState2","_slicedToArray","isDropdownOpen","setIsDropdownOpen","isMobile","useIsMobile","actionList","_jsx","ActionList","children","map","country","ActionListItem","onClick","leading","ActionListItemAsset","src","code","alt","name","title","value","trailing","ActionListItemText","getDialCodeByCountryCode","flagSize","medium","makeSize","sizes","large","_jsxs","Dropdown","isOpen","onOpenChange","marginLeft","DropdownButton","variant","accessibilityLabel","concat","of","icon","ChevronUpIcon","ChevronDownIcon","iconPosition","e","stopPropagation","loading","role","getFlagOfCountry","BottomSheet","BottomSheetHeader","BottomSheetBody","DropdownOverlay","referenceRef"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBMA,IAAAA,oBAAoB,GAAG,IAAIC,IAAI,CAACC,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE;AAAEC,EAAAA,IAAI,EAAE,QAAA;AAAS,CAAC,EAAC;AAgB9E,IAAMC,4BAA4B,gBAAGC,MAAM,CAACC,OAAO,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,kDAAA;EAAAC,WAAA,EAAA,UAAA;AAAA,CAAA,CAAA,CAAC,YAAM;EACzD,OAAO;AACL,IAAA,YAAY,EAAE;AACZC,MAAAA,OAAO,EAAE,GAAG;AACZC,MAAAA,KAAK,EAAE,MAAA;AACT,KAAA;GACD,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,CAAAC,IAAA,EAQ2B;AAAA,EAAA,IAP9CC,UAAU,GAAAD,IAAA,CAAVC,UAAU;IACVC,eAAe,GAAAF,IAAA,CAAfE,eAAe;IACfC,eAAe,GAAAH,IAAA,CAAfG,eAAe;IACfC,WAAW,GAAAJ,IAAA,CAAXI,WAAW;IACXC,WAAW,GAAAL,IAAA,CAAXK,WAAW;IACXC,KAAK,GAAAN,IAAA,CAALM,KAAK;IACLC,MAAI,GAAAP,IAAA,CAAJO,IAAI,CAAA;AAEJ,EAAA,IAAAC,eAAA,GAA4CC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;IAAAC,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UAAAA;AAAU,OAAkB,CAAC,CAAA;AAAA,KACpC,CAAC,gBAEdC,GAAA,CAAC6C,eAAe,EAAA;AAACC,MAAAA,YAAY,EAAE7D,eAAgB;AAAAiB,MAAAA,QAAA,EAAEH,UAAAA;AAAU,KAAkB,CAC9E,CAAA;AAAA,GACO,CAAC,CAAA;AAEf;;;;"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import styled, { keyframes, css } from 'styled-components';
|
|
3
|
+
import 'react';
|
|
4
|
+
import { pulseAnimation, getCircularProgressSVGTokens, circularProgressSizeTokens } from './progressBarTokens.js';
|
|
5
|
+
import { CircularProgressLabel } from './CircularProgressLabel.js';
|
|
6
|
+
import getIn from '../../utils/lodashButBetter/get.js';
|
|
7
|
+
import '../Box/BaseBox/index.js';
|
|
8
|
+
import '../../utils/index.js';
|
|
9
|
+
import '../../utils/makeMotionTime/index.web.js';
|
|
10
|
+
import '../Typography/index.js';
|
|
11
|
+
import '../Icons/_Svg/index.js';
|
|
12
|
+
import getBaseTextStyles from '../Typography/BaseText/getBaseTextStyles.js';
|
|
13
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
14
|
+
import { getTextProps } from '../Typography/Text/Text.js';
|
|
15
|
+
import { castWebType } from '../../utils/platform/castUtils.js';
|
|
16
|
+
import { makeMotionTime } from '../../utils/makeMotionTime/makeMotionTime.web.js';
|
|
17
|
+
import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
|
|
18
|
+
import Svg from '../Icons/_Svg/Svg/Svg.web.js';
|
|
19
|
+
import Circle from '../Icons/_Svg/Circle/Circle.web.js';
|
|
20
|
+
|
|
21
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
|
+
var pulseKeyframes = /*#__PURE__*/keyframes(["0%{opacity:100;}50%{opacity:0.65;}100%{opacity:100;}"]);
|
|
24
|
+
var getPulseAnimationStyles = function getPulseAnimationStyles(_ref) {
|
|
25
|
+
var duration = _ref.duration,
|
|
26
|
+
easing = _ref.easing,
|
|
27
|
+
progressPercent = _ref.progressPercent,
|
|
28
|
+
isMeter = _ref.isMeter;
|
|
29
|
+
if (isMeter || progressPercent === 100) {
|
|
30
|
+
return css(["height:100%;width:100%;transition:stroke-dashoffset ", " ", ";"], duration, easing);
|
|
31
|
+
}
|
|
32
|
+
return css(["height:100%;width:100%;opacity:", ";background-color:", ";transition:stroke-dashoffset ", " ", ";animation:", " ", " ", " infinite;"], pulseAnimation.opacityInitial, pulseAnimation.backgroundColor, duration, easing, pulseKeyframes, duration, easing);
|
|
33
|
+
};
|
|
34
|
+
var StyledSVGText = /*#__PURE__*/styled.text.withConfig({
|
|
35
|
+
displayName: "CircularProgressBarweb__StyledSVGText",
|
|
36
|
+
componentId: "h4xj3g-0"
|
|
37
|
+
})(function (_ref2) {
|
|
38
|
+
var theme = _ref2.theme,
|
|
39
|
+
size = _ref2.size,
|
|
40
|
+
weight = _ref2.weight;
|
|
41
|
+
return getBaseTextStyles(_objectSpread({
|
|
42
|
+
theme: theme
|
|
43
|
+
}, getTextProps({
|
|
44
|
+
variant: 'body',
|
|
45
|
+
size: size,
|
|
46
|
+
weight: weight
|
|
47
|
+
})));
|
|
48
|
+
});
|
|
49
|
+
var DeterminatePulseAnimation = /*#__PURE__*/styled.circle.withConfig({
|
|
50
|
+
displayName: "CircularProgressBarweb__DeterminatePulseAnimation",
|
|
51
|
+
componentId: "h4xj3g-1"
|
|
52
|
+
})(function (_ref3) {
|
|
53
|
+
var theme = _ref3.theme,
|
|
54
|
+
pulseMotionDuration = _ref3.pulseMotionDuration,
|
|
55
|
+
motionEasing = _ref3.motionEasing,
|
|
56
|
+
progressPercent = _ref3.progressPercent,
|
|
57
|
+
isMeter = _ref3.isMeter;
|
|
58
|
+
var duration = castWebType(makeMotionTime(getIn(theme.motion, pulseMotionDuration)));
|
|
59
|
+
var easing = castWebType(getIn(theme.motion, motionEasing));
|
|
60
|
+
return getPulseAnimationStyles({
|
|
61
|
+
duration: duration,
|
|
62
|
+
easing: easing,
|
|
63
|
+
progressPercent: progressPercent,
|
|
64
|
+
isMeter: isMeter
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
var CircularProgressBarFilled = function CircularProgressBarFilled(_ref4) {
|
|
68
|
+
var progressPercent = _ref4.progressPercent,
|
|
69
|
+
fillColor = _ref4.fillColor,
|
|
70
|
+
backgroundColor = _ref4.backgroundColor,
|
|
71
|
+
_ref4$size = _ref4.size,
|
|
72
|
+
size = _ref4$size === void 0 ? 'small' : _ref4$size,
|
|
73
|
+
label = _ref4.label,
|
|
74
|
+
_ref4$showPercentage = _ref4.showPercentage,
|
|
75
|
+
showPercentage = _ref4$showPercentage === void 0 ? true : _ref4$showPercentage,
|
|
76
|
+
isMeter = _ref4.isMeter;
|
|
77
|
+
var _getCircularProgressS = getCircularProgressSVGTokens({
|
|
78
|
+
size: size,
|
|
79
|
+
progressPercent: progressPercent
|
|
80
|
+
}),
|
|
81
|
+
sqSize = _getCircularProgressS.sqSize,
|
|
82
|
+
strokeWidth = _getCircularProgressS.strokeWidth,
|
|
83
|
+
radius = _getCircularProgressS.radius,
|
|
84
|
+
viewBox = _getCircularProgressS.viewBox,
|
|
85
|
+
dashArray = _getCircularProgressS.dashArray,
|
|
86
|
+
dashOffset = _getCircularProgressS.dashOffset;
|
|
87
|
+
return /*#__PURE__*/jsxs(BaseBox, {
|
|
88
|
+
width: "fit-content",
|
|
89
|
+
textAlign: "center",
|
|
90
|
+
display: "flex",
|
|
91
|
+
flexDirection: "column",
|
|
92
|
+
alignItems: "center",
|
|
93
|
+
children: [/*#__PURE__*/jsxs(Svg, {
|
|
94
|
+
width: String(sqSize),
|
|
95
|
+
height: String(sqSize),
|
|
96
|
+
viewBox: viewBox,
|
|
97
|
+
children: [/*#__PURE__*/jsx(Circle, {
|
|
98
|
+
fill: "none",
|
|
99
|
+
stroke: backgroundColor,
|
|
100
|
+
cx: String(sqSize / 2),
|
|
101
|
+
cy: String(sqSize / 2),
|
|
102
|
+
r: String(radius),
|
|
103
|
+
strokeWidth: "".concat(strokeWidth, "px")
|
|
104
|
+
}), /*#__PURE__*/jsx(DeterminatePulseAnimation, {
|
|
105
|
+
progressPercent: progressPercent,
|
|
106
|
+
isMeter: isMeter,
|
|
107
|
+
fill: "none",
|
|
108
|
+
stroke: fillColor,
|
|
109
|
+
cx: sqSize / 2,
|
|
110
|
+
cy: sqSize / 2,
|
|
111
|
+
r: radius,
|
|
112
|
+
strokeWidth: "".concat(strokeWidth, "px")
|
|
113
|
+
// Start progress marker at 12 O'Clock
|
|
114
|
+
,
|
|
115
|
+
transform: "rotate(-90 ".concat(sqSize / 2, " ").concat(sqSize / 2, ")"),
|
|
116
|
+
strokeDasharray: dashArray,
|
|
117
|
+
strokeDashoffset: dashOffset,
|
|
118
|
+
pulseMotionDuration: "duration.2xgentle",
|
|
119
|
+
pulseMotionDelay: "delay.long",
|
|
120
|
+
motionEasing: "easing.standard.revealing"
|
|
121
|
+
}), showPercentage && size !== 'small' && /*#__PURE__*/jsxs(StyledSVGText, {
|
|
122
|
+
size: circularProgressSizeTokens[size].percentTextSize,
|
|
123
|
+
weight: "semibold",
|
|
124
|
+
x: "50%",
|
|
125
|
+
y: "50%",
|
|
126
|
+
textAnchor: "middle",
|
|
127
|
+
dy: ".4em",
|
|
128
|
+
children: [progressPercent, "%"]
|
|
129
|
+
})]
|
|
130
|
+
}), /*#__PURE__*/jsx(CircularProgressLabel, {
|
|
131
|
+
progressPercent: progressPercent,
|
|
132
|
+
size: size,
|
|
133
|
+
label: label,
|
|
134
|
+
showPercentage: showPercentage
|
|
135
|
+
})]
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export { CircularProgressBarFilled };
|
|
140
|
+
//# sourceMappingURL=CircularProgressBar.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircularProgressBar.web.js","sources":["../../../../../../src/components/ProgressBar/CircularProgressBar.web.tsx"],"sourcesContent":["import type { FlattenSimpleInterpolation } from 'styled-components';\nimport styled, { css, keyframes } from 'styled-components';\nimport React from 'react';\nimport type { CircularProgressBarFilledProps } from './types';\nimport {\n pulseAnimation,\n circularProgressSizeTokens,\n getCircularProgressSVGTokens,\n} from './progressBarTokens';\nimport { CircularProgressLabel } from './CircularProgressLabel';\nimport getIn from '~utils/lodashButBetter/get';\nimport BaseBox from '~components/Box/BaseBox';\nimport { castWebType } from '~utils';\nimport { makeMotionTime } from '~utils/makeMotionTime';\nimport type { TextProps } from '~components/Typography';\nimport { getTextProps } from '~components/Typography';\nimport { Svg, Circle } from '~components/Icons/_Svg';\nimport getBaseTextStyles from '~components/Typography/BaseText/getBaseTextStyles';\n\nconst pulseKeyframes = keyframes`\n 0% {\n opacity: 100;\n }\n 50% {\n opacity: 0.65;\n }\n 100% {\n opacity: 100;\n }\n`;\n\nconst getPulseAnimationStyles = ({\n duration,\n easing,\n progressPercent,\n isMeter,\n}: {\n duration: string;\n easing: string;\n progressPercent: number;\n isMeter: boolean;\n}): FlattenSimpleInterpolation => {\n if (isMeter || progressPercent === 100) {\n return css`\n height: 100%;\n width: 100%;\n transition: stroke-dashoffset ${duration} ${easing};\n `;\n }\n\n return css`\n height: 100%;\n width: 100%;\n opacity: ${pulseAnimation.opacityInitial};\n background-color: ${pulseAnimation.backgroundColor};\n transition: stroke-dashoffset ${duration} ${easing};\n animation: ${pulseKeyframes} ${duration} ${easing} infinite;\n `;\n};\n\nconst StyledSVGText = styled.text<Pick<TextProps<{ variant: 'body' }>, 'size' | 'weight'>>(\n ({ theme, size, weight }) => {\n return getBaseTextStyles({\n theme,\n ...getTextProps({ variant: 'body', size, weight }),\n });\n },\n);\n\nconst DeterminatePulseAnimation = styled.circle<\n Pick<\n CircularProgressBarFilledProps,\n 'pulseMotionDuration' | 'pulseMotionDelay' | 'motionEasing' | 'progressPercent' | 'isMeter'\n >\n>(({ theme, pulseMotionDuration, motionEasing, progressPercent, isMeter }) => {\n const duration = castWebType(makeMotionTime(getIn(theme.motion, pulseMotionDuration)));\n const easing = castWebType(getIn(theme.motion, motionEasing));\n\n return getPulseAnimationStyles({\n duration,\n easing,\n progressPercent,\n isMeter,\n });\n});\n\nconst CircularProgressBarFilled = ({\n progressPercent,\n fillColor,\n backgroundColor,\n size = 'small',\n label,\n showPercentage = true,\n isMeter,\n}: CircularProgressBarFilledProps): React.ReactElement => {\n const {\n sqSize,\n strokeWidth,\n radius,\n viewBox,\n dashArray,\n dashOffset,\n } = getCircularProgressSVGTokens({ size, progressPercent });\n\n return (\n <BaseBox\n width=\"fit-content\"\n textAlign=\"center\"\n display=\"flex\"\n flexDirection=\"column\"\n alignItems=\"center\"\n >\n <Svg width={String(sqSize)} height={String(sqSize)} viewBox={viewBox}>\n <Circle\n fill=\"none\"\n stroke={backgroundColor}\n cx={String(sqSize / 2)}\n cy={String(sqSize / 2)}\n r={String(radius)}\n strokeWidth={`${strokeWidth}px`}\n />\n\n <DeterminatePulseAnimation\n progressPercent={progressPercent}\n isMeter={isMeter}\n fill=\"none\"\n stroke={fillColor}\n cx={sqSize / 2}\n cy={sqSize / 2}\n r={radius}\n strokeWidth={`${strokeWidth}px`}\n // Start progress marker at 12 O'Clock\n transform={`rotate(-90 ${sqSize / 2} ${sqSize / 2})`}\n strokeDasharray={dashArray}\n strokeDashoffset={dashOffset}\n pulseMotionDuration=\"duration.2xgentle\"\n pulseMotionDelay=\"delay.long\"\n motionEasing=\"easing.standard.revealing\"\n />\n {showPercentage && size !== 'small' && (\n <StyledSVGText\n size={circularProgressSizeTokens[size].percentTextSize}\n weight=\"semibold\"\n x=\"50%\"\n y=\"50%\"\n textAnchor=\"middle\"\n dy=\".4em\"\n >\n {progressPercent}%\n </StyledSVGText>\n )}\n </Svg>\n\n <CircularProgressLabel\n progressPercent={progressPercent}\n size={size}\n label={label}\n showPercentage={showPercentage}\n />\n </BaseBox>\n );\n};\n\nexport { CircularProgressBarFilled };\n"],"names":["pulseKeyframes","keyframes","getPulseAnimationStyles","_ref","duration","easing","progressPercent","isMeter","css","pulseAnimation","opacityInitial","backgroundColor","StyledSVGText","styled","text","withConfig","displayName","componentId","_ref2","theme","size","weight","getBaseTextStyles","_objectSpread","getTextProps","variant","DeterminatePulseAnimation","circle","_ref3","pulseMotionDuration","motionEasing","castWebType","makeMotionTime","getIn","motion","CircularProgressBarFilled","_ref4","fillColor","_ref4$size","label","_ref4$showPercentage","showPercentage","_getCircularProgressS","getCircularProgressSVGTokens","sqSize","strokeWidth","radius","viewBox","dashArray","dashOffset","_jsxs","BaseBox","width","textAlign","display","flexDirection","alignItems","children","Svg","String","height","_jsx","Circle","fill","stroke","cx","cy","r","concat","transform","strokeDasharray","strokeDashoffset","pulseMotionDelay","circularProgressSizeTokens","percentTextSize","x","y","textAnchor","dy","CircularProgressLabel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBA,IAAMA,cAAc,gBAAGC,SAAS,CAU/B,CAAA,sDAAA,CAAA,CAAA,CAAA;AAED,IAAMC,uBAAuB,GAAG,SAA1BA,uBAAuBA,CAAAC,IAAA,EAUK;AAAA,EAAA,IAThCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IACRC,MAAM,GAAAF,IAAA,CAANE,MAAM;IACNC,eAAe,GAAAH,IAAA,CAAfG,eAAe;IACfC,OAAO,GAAAJ,IAA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