@razorpay/blade 12.26.0 → 12.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/native/components/Input/BaseInput/useTaggedInput.js +1 -1
- package/build/lib/native/components/Input/BaseInput/useTaggedInput.js.map +1 -1
- package/build/lib/native/components/StepGroup/StepItemMarker.js +1 -1
- package/build/lib/native/components/StepGroup/StepItemMarker.js.map +1 -1
- package/build/lib/native/tokens/theme/createTheme.js +1 -1
- package/build/lib/native/tokens/theme/createTheme.js.map +1 -1
- package/build/lib/web/development/components/Input/BaseInput/useTaggedInput.js +8 -32
- package/build/lib/web/development/components/Input/BaseInput/useTaggedInput.js.map +1 -1
- package/build/lib/web/development/components/StepGroup/StepItem.web.js +9 -5
- package/build/lib/web/development/components/StepGroup/StepItem.web.js.map +1 -1
- package/build/lib/web/development/components/StepGroup/StepItemMarker.js +4 -2
- package/build/lib/web/development/components/StepGroup/StepItemMarker.js.map +1 -1
- package/build/lib/web/development/components/StepGroup/StepLine.web.js +2 -10
- package/build/lib/web/development/components/StepGroup/StepLine.web.js.map +1 -1
- package/build/lib/web/development/tokens/theme/createTheme.js +4 -4
- package/build/lib/web/development/tokens/theme/createTheme.js.map +1 -1
- package/build/lib/web/production/components/Input/BaseInput/useTaggedInput.js +8 -32
- package/build/lib/web/production/components/Input/BaseInput/useTaggedInput.js.map +1 -1
- package/build/lib/web/production/components/StepGroup/StepItem.web.js +9 -5
- package/build/lib/web/production/components/StepGroup/StepItem.web.js.map +1 -1
- package/build/lib/web/production/components/StepGroup/StepItemMarker.js +4 -2
- package/build/lib/web/production/components/StepGroup/StepItemMarker.js.map +1 -1
- package/build/lib/web/production/components/StepGroup/StepLine.web.js +2 -10
- package/build/lib/web/production/components/StepGroup/StepLine.web.js.map +1 -1
- package/build/lib/web/production/tokens/theme/createTheme.js +4 -4
- package/build/lib/web/production/tokens/theme/createTheme.js.map +1 -1
- package/build/types/components/index.d.ts +2 -1
- package/build/types/components/index.native.d.ts +2 -1
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import { isReactNative } from '../../../utils/platform/isReactNative.js';
|
|
|
7
7
|
import '../../BladeProvider/useTheme.js';
|
|
8
8
|
import { useControllableState } from '../../../utils/useControllable.js';
|
|
9
9
|
|
|
10
|
-
var useTaggedInput=function useTaggedInput(_ref){var tags=_ref.tags,isDisabled=_ref.isDisabled,onTagChange=_ref.onTagChange,isTaggedInput=_ref.isTaggedInput,inputRef=_ref.inputRef,onChange=_ref.onChange,name=_ref.name,value=_ref.value,defaultValue=_ref.defaultValue;var _React$useState=React__default.useState(-1),_React$useState2=_slicedToArray(_React$useState,2),activeTagIndex=_React$useState2[0],setActiveTagIndex=_React$useState2[1];var _React$useState3=React__default.useState(defaultValue!=null?defaultValue:''),_React$useState4=_slicedToArray(_React$useState3,2),inputValueUncontrolled=_React$useState4[0],setInputValueUncontrolled=_React$useState4[1];var _useControllableState=useControllableState({value:tags,defaultValue:[],onChange:function onChange(tags){onTagChange==null?void 0:onTagChange({tags:tags});}}),_useControllableState2=_slicedToArray(_useControllableState,2),tagsValue=_useControllableState2[0],setTagsValue=_useControllableState2[1];var
|
|
10
|
+
var useTaggedInput=function useTaggedInput(_ref){var tags=_ref.tags,isDisabled=_ref.isDisabled,onTagChange=_ref.onTagChange,isTaggedInput=_ref.isTaggedInput,inputRef=_ref.inputRef,onChange=_ref.onChange,name=_ref.name,value=_ref.value,defaultValue=_ref.defaultValue;var _React$useState=React__default.useState(-1),_React$useState2=_slicedToArray(_React$useState,2),activeTagIndex=_React$useState2[0],setActiveTagIndex=_React$useState2[1];var _React$useState3=React__default.useState(defaultValue!=null?defaultValue:''),_React$useState4=_slicedToArray(_React$useState3,2),inputValueUncontrolled=_React$useState4[0],setInputValueUncontrolled=_React$useState4[1];var _useControllableState=useControllableState({value:tags,defaultValue:[],onChange:function onChange(tags){onTagChange==null?void 0:onTagChange({tags:tags});}}),_useControllableState2=_slicedToArray(_useControllableState,2),tagsValue=_useControllableState2[0],setTagsValue=_useControllableState2[1];var getNewTagsArray=function getNewTagsArray(indexToRemove){var currentTags=tagsValue;if(!currentTags){return [];}if(indexToRemove<0||indexToRemove>=currentTags.length){return currentTags;}var newArray=currentTags.slice(0,indexToRemove).concat(currentTags.slice(indexToRemove+1));return newArray;};var getTags=React__default.useMemo(function(){return function(_ref2){var size=_ref2.size;return getTagsGroup({size:size,tags:tagsValue,activeTagIndex:activeTagIndex,isDisabled:isDisabled,onDismiss:function onDismiss(_ref3){var tagIndex=_ref3.tagIndex;setTagsValue(function(){return getNewTagsArray(tagIndex);});}});};},[activeTagIndex,tags,tagsValue,isDisabled]);var handleTaggedInputChange=function handleTaggedInputChange(_ref4){var value=_ref4.value;if(!isTaggedInput){return;}setInputValueUncontrolled(value!=null?value:'');};var handleTagsClear=function handleTagsClear(){if(!isTaggedInput){return;}setTagsValue(function(){return [];});};var clearInput=function clearInput(){var isControlledValue=value!==undefined;if(isControlledValue){onChange==null?void 0:onChange({name:name,value:''});return;}if(!inputRef.current){return;}setInputValueUncontrolled('');if(isReactNative()){setTimeout(function(){var _inputRef$current;(_inputRef$current=inputRef.current)==null?void 0:_inputRef$current.clear();},10);return;}inputRef.current.value='';};var handleTaggedInputKeydown=function handleTaggedInputKeydown(e){if(!isTaggedInput){return;}var currentTags=tagsValue;var isControlledValue=value!==undefined;var inputValue=isControlledValue?value==null?void 0:value.trim():inputValueUncontrolled.trim();if(e.key==='Enter'||e.key===','){e.event.preventDefault==null?void 0:e.event.preventDefault();if(inputValue){setTagsValue(function(){return [].concat(_toConsumableArray(currentTags),[inputValue]);});clearInput();setActiveTagIndex(-1);}}if(e.key==='Backspace'&&!inputValue&&activeTagIndex<0&¤tTags.length>0){setTagsValue(function(){return currentTags.slice(0,-1);});}};return {activeTagIndex:activeTagIndex,setActiveTagIndex:setActiveTagIndex,getTags:getTags,handleTaggedInputKeydown:handleTaggedInputKeydown,handleTaggedInputChange:handleTaggedInputChange,handleTagsClear:handleTagsClear};};
|
|
11
11
|
|
|
12
12
|
export { useTaggedInput };
|
|
13
13
|
//# sourceMappingURL=useTaggedInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTaggedInput.js","sources":["../../../../../../src/components/Input/BaseInput/useTaggedInput.ts"],"sourcesContent":["import React from 'react';\nimport type { BaseInputProps } from './BaseInput';\nimport type { BladeElementRefWithValue } from '~utils/types';\nimport type { FormInputOnEvent, FormInputOnKeyDownEvent } from '~components/Form/FormTypes';\n// import { isReactNative } from '~utils';\nimport { getTagsGroup } from '~components/Tag/getTagsGroup';\nimport { isReactNative } from '~utils';\nimport { useControllableState } from '~utils/useControllable';\n\ntype TaggedInputProps = {\n isTaggedInput?: boolean;\n tags?: string[];\n onTagChange?: ({ tags }: { tags: string[] }) => void;\n};\n\ntype UseTaggedInputProps = TaggedInputProps &\n Pick<BaseInputProps, 'isDisabled' | 'onChange' | 'name' | 'value' | 'defaultValue'> & {\n inputRef: React.RefObject<BladeElementRefWithValue | null>;\n };\n\ntype UseTaggedInputReturn = {\n activeTagIndex: number;\n setActiveTagIndex: (activeTagIndex: number) => void;\n getTags: ({ size }: { size: NonNullable<BaseInputProps['size']> }) => React.ReactElement[];\n handleTaggedInputKeydown: (e: FormInputOnKeyDownEvent) => void;\n handleTaggedInputChange: FormInputOnEvent;\n handleTagsClear: () => void;\n};\n\nconst useTaggedInput = ({\n tags,\n isDisabled,\n onTagChange,\n isTaggedInput,\n inputRef,\n onChange,\n name,\n value,\n defaultValue,\n}: UseTaggedInputProps): UseTaggedInputReturn => {\n const [activeTagIndex, setActiveTagIndex] = React.useState(-1);\n const [inputValueUncontrolled, setInputValueUncontrolled] = React.useState(defaultValue ?? '');\n const [tagsValue, setTagsValue] = useControllableState({\n value: tags,\n defaultValue: [],\n onChange: (tags) => {\n onTagChange?.({ tags });\n },\n });\n\n const isTagsControlled = Boolean(tags);\n\n const getNewTagsArray = (indexToRemove: number): string[] => {\n const currentTags = tagsValue;\n\n if (!currentTags) {\n return [];\n }\n\n // Check if the index is valid\n if (indexToRemove < 0 || indexToRemove >= currentTags.length) {\n return currentTags; // Return the original array\n }\n\n // Create a new array without the element at the specified index\n const newArray = currentTags\n .slice(0, indexToRemove)\n .concat(currentTags.slice(indexToRemove + 1));\n\n return newArray;\n };\n\n const getTags = React.useMemo(\n () => ({ size }: { size: NonNullable<BaseInputProps['size']> }): React.ReactElement[] => {\n return getTagsGroup({\n size,\n tags: tagsValue,\n activeTagIndex,\n isDisabled,\n onDismiss: ({ tagIndex }) => {\n console.log('dismiss', { tagIndex });\n if (!isTagsControlled) {\n setTagsValue(() => getNewTagsArray(tagIndex));\n }\n onTagChange?.({ tags: getNewTagsArray(tagIndex) });\n },\n });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [activeTagIndex, tags, tagsValue, isDisabled],\n );\n\n const handleTaggedInputChange: FormInputOnEvent = ({ value }) => {\n if (!isTaggedInput) {\n return;\n }\n setInputValueUncontrolled(value ?? '');\n };\n\n const handleTagsClear = (): void => {\n if (!isTaggedInput) {\n return;\n }\n\n if (!isTagsControlled) {\n setTagsValue(() => []);\n }\n\n onTagChange?.({ tags: [] });\n };\n\n const clearInput = (): void => {\n const isControlledValue = value !== undefined;\n\n if (isControlledValue) {\n // In Controlled component, we don't clear input ourselves. We just call onChange with empty value\n onChange?.({ name, value: '' });\n return;\n }\n\n if (!inputRef.current) {\n return;\n }\n\n setInputValueUncontrolled('');\n\n if (isReactNative()) {\n setTimeout(() => {\n // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error\n // @ts-ignore: clear does exist in react native\n inputRef.current?.clear();\n }, 10);\n return;\n }\n\n inputRef.current.value = '';\n };\n\n const handleTaggedInputKeydown = (e: FormInputOnKeyDownEvent): void => {\n if (!isTaggedInput) {\n return;\n }\n\n const currentTags = tagsValue;\n const isControlledValue = value !== undefined;\n const inputValue = isControlledValue ? value?.trim() : inputValueUncontrolled.trim();\n if (e.key === 'Enter' || e.key === ',') {\n e.event.preventDefault?.(); // we don't want textarea to treat enter as line break in tagged inputs\n if (inputValue) {\n if (!isTagsControlled) {\n setTagsValue(() => [...currentTags, inputValue]);\n }\n onTagChange?.({ tags: [...currentTags, inputValue] });\n clearInput();\n setActiveTagIndex(-1);\n }\n }\n if (e.key === 'Backspace' && !inputValue && activeTagIndex < 0 && currentTags.length > 0) {\n if (!isTagsControlled) {\n setTagsValue(() => currentTags.slice(0, -1));\n }\n onTagChange?.({ tags: currentTags.slice(0, -1) });\n }\n };\n\n return {\n activeTagIndex,\n setActiveTagIndex,\n getTags,\n handleTaggedInputKeydown,\n handleTaggedInputChange,\n handleTagsClear,\n };\n};\n\nexport type { TaggedInputProps };\nexport { useTaggedInput };\n"],"names":["useTaggedInput","_ref","tags","isDisabled","onTagChange","isTaggedInput","inputRef","onChange","name","value","defaultValue","_React$useState","React","useState","_React$useState2","_slicedToArray","activeTagIndex","setActiveTagIndex","_React$useState3","_React$useState4","inputValueUncontrolled","setInputValueUncontrolled","_useControllableState","useControllableState","_useControllableState2","tagsValue","setTagsValue","isTagsControlled","Boolean","getNewTagsArray","indexToRemove","currentTags","length","newArray","slice","concat","getTags","useMemo","_ref2","size","getTagsGroup","onDismiss","_ref3","tagIndex","console","log","handleTaggedInputChange","_ref4","handleTagsClear","clearInput","isControlledValue","undefined","current","isReactNative","setTimeout","_inputRef$current","clear","handleTaggedInputKeydown","e","inputValue","trim","key","event","preventDefault","_toConsumableArray"],"mappings":";;;;;;;;;AA6BM,IAAAA,cAAc,CAAG,SAAjBA,cAAcA,CAAAC,IAAA,CAU6B,CAAA,IAT/CC,IAAI,CAAAD,IAAA,CAAJC,IAAI,CACJC,UAAU,CAAAF,IAAA,CAAVE,UAAU,CACVC,WAAW,CAAAH,IAAA,CAAXG,WAAW,CACXC,aAAa,CAAAJ,IAAA,CAAbI,aAAa,CACbC,QAAQ,CAAAL,IAAA,CAARK,QAAQ,CACRC,QAAQ,CAAAN,IAAA,CAARM,QAAQ,CACRC,IAAI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AAO,CAAPA,OAAO,CACPqB,wBAAwB,CAAxBA,wBAAwB,CACxBX,uBAAuB,CAAvBA,uBAAuB,CACvBE,eAAe,CAAfA,eACF,CAAC,CACH;;;;"}
|
|
1
|
+
{"version":3,"file":"useTaggedInput.js","sources":["../../../../../../src/components/Input/BaseInput/useTaggedInput.ts"],"sourcesContent":["import React from 'react';\nimport type { BaseInputProps } from './BaseInput';\nimport type { BladeElementRefWithValue } from '~utils/types';\nimport type { FormInputOnEvent, FormInputOnKeyDownEvent } from '~components/Form/FormTypes';\nimport { getTagsGroup } from '~components/Tag/getTagsGroup';\nimport { isReactNative } from '~utils';\nimport { useControllableState } from '~utils/useControllable';\n\ntype TaggedInputProps = {\n isTaggedInput?: boolean;\n tags?: string[];\n onTagChange?: ({ tags }: { tags: string[] }) => void;\n};\n\ntype UseTaggedInputProps = TaggedInputProps &\n Pick<BaseInputProps, 'isDisabled' | 'onChange' | 'name' | 'value' | 'defaultValue'> & {\n inputRef: React.RefObject<BladeElementRefWithValue | null>;\n };\n\ntype UseTaggedInputReturn = {\n activeTagIndex: number;\n setActiveTagIndex: (activeTagIndex: number) => void;\n getTags: ({ size }: { size: NonNullable<BaseInputProps['size']> }) => React.ReactElement[];\n handleTaggedInputKeydown: (e: FormInputOnKeyDownEvent) => void;\n handleTaggedInputChange: FormInputOnEvent;\n handleTagsClear: () => void;\n};\n\nconst useTaggedInput = ({\n tags,\n isDisabled,\n onTagChange,\n isTaggedInput,\n inputRef,\n onChange,\n name,\n value,\n defaultValue,\n}: UseTaggedInputProps): UseTaggedInputReturn => {\n const [activeTagIndex, setActiveTagIndex] = React.useState(-1);\n const [inputValueUncontrolled, setInputValueUncontrolled] = React.useState(defaultValue ?? '');\n const [tagsValue, setTagsValue] = useControllableState({\n value: tags,\n defaultValue: [],\n onChange: (tags) => {\n onTagChange?.({ tags });\n },\n });\n\n const getNewTagsArray = (indexToRemove: number): string[] => {\n const currentTags = tagsValue;\n\n if (!currentTags) {\n return [];\n }\n\n // Check if the index is valid\n if (indexToRemove < 0 || indexToRemove >= currentTags.length) {\n return currentTags; // Return the original array\n }\n\n // Create a new array without the element at the specified index\n const newArray = currentTags\n .slice(0, indexToRemove)\n .concat(currentTags.slice(indexToRemove + 1));\n\n return newArray;\n };\n\n const getTags = React.useMemo(\n () => ({ size }: { size: NonNullable<BaseInputProps['size']> }): React.ReactElement[] => {\n return getTagsGroup({\n size,\n tags: tagsValue,\n activeTagIndex,\n isDisabled,\n onDismiss: ({ tagIndex }) => {\n setTagsValue(() => getNewTagsArray(tagIndex));\n },\n });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [activeTagIndex, tags, tagsValue, isDisabled],\n );\n\n const handleTaggedInputChange: FormInputOnEvent = ({ value }) => {\n if (!isTaggedInput) {\n return;\n }\n setInputValueUncontrolled(value ?? '');\n };\n\n const handleTagsClear = (): void => {\n if (!isTaggedInput) {\n return;\n }\n\n setTagsValue(() => []);\n };\n\n const clearInput = (): void => {\n const isControlledValue = value !== undefined;\n\n if (isControlledValue) {\n // In Controlled component, we don't clear input ourselves. We just call onChange with empty value\n onChange?.({ name, value: '' });\n return;\n }\n\n if (!inputRef.current) {\n return;\n }\n\n setInputValueUncontrolled('');\n\n if (isReactNative()) {\n setTimeout(() => {\n // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error\n // @ts-ignore: clear does exist in react native\n inputRef.current?.clear();\n }, 10);\n return;\n }\n\n inputRef.current.value = '';\n };\n\n const handleTaggedInputKeydown = (e: FormInputOnKeyDownEvent): void => {\n if (!isTaggedInput) {\n return;\n }\n\n const currentTags = tagsValue;\n const isControlledValue = value !== undefined;\n const inputValue = isControlledValue ? value?.trim() : inputValueUncontrolled.trim();\n if (e.key === 'Enter' || e.key === ',') {\n e.event.preventDefault?.(); // we don't want textarea to treat enter as line break in tagged inputs\n if (inputValue) {\n setTagsValue(() => [...currentTags, inputValue]);\n clearInput();\n setActiveTagIndex(-1);\n }\n }\n if (e.key === 'Backspace' && !inputValue && activeTagIndex < 0 && currentTags.length > 0) {\n setTagsValue(() => currentTags.slice(0, -1));\n }\n };\n\n return {\n activeTagIndex,\n setActiveTagIndex,\n getTags,\n handleTaggedInputKeydown,\n handleTaggedInputChange,\n handleTagsClear,\n };\n};\n\nexport type { TaggedInputProps };\nexport { useTaggedInput };\n"],"names":["useTaggedInput","_ref","tags","isDisabled","onTagChange","isTaggedInput","inputRef","onChange","name","value","defaultValue","_React$useState","React","useState","_React$useState2","_slicedToArray","activeTagIndex","setActiveTagIndex","_React$useState3","_React$useState4","inputValueUncontrolled","setInputValueUncontrolled","_useControllableState","useControllableState","_useControllableState2","tagsValue","setTagsValue","getNewTagsArray","indexToRemove","currentTags","length","newArray","slice","concat","getTags","useMemo","_ref2","size","getTagsGroup","onDismiss","_ref3","tagIndex","handleTaggedInputChange","_ref4","handleTagsClear","clearInput","isControlledValue","undefined","current","isReactNative","setTimeout","_inputRef$current","clear","handleTaggedInputKeydown","e","inputValue","trim","key","event","preventDefault","_toConsumableArray"],"mappings":";;;;;;;;;AA4BM,IAAAA,cAAc,CAAG,SAAjBA,cAAcA,CAAAC,IAAA,CAU6B,CAT/C,IAAAC,IAAI,CAAAD,IAAA,CAAJC,IAAI,CACJC,UAAU,CAAAF,IAAA,CAAVE,UAAU,CACVC,WAAW,CAAAH,IAAA,CAAXG,WAAW,CACXC,aAAa,CAAAJ,IAAA,CAAbI,aAAa,CACbC,QAAQ,CAAAL,IAAA,CAARK,QAAQ,CACRC,QAAQ,CAAAN,IAAA,CAARM,QAAQ,CACRC,IAAI,CAAAP,IAAA,CAAJO,IAAI,CACJC,KAAK,CAAAR,IAAA,CAALQ,KAAK,CACLC,YAAY,CAAAT,IAAA,CAAZS,YAAY,CAEZ,IAAAC,eAAA,CAA4CC,cAAK,CAACC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAAC,gBAAA,CAAAC,cAAA,CAAAJ,eAAA,CAAA,CAAA,CAAA,CAAvDK,cAAc,CAAAF,gBAAA,IAAEG,iB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AAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAA,CAAA,CAAC,CAC9C,CACF,CAAC,CAED,OAAO,CACLhB,cAAc,CAAdA,cAAc,CACdC,iBAAiB,CAAjBA,iBAAiB,CACjBiB,OAAO,CAAPA,OAAO,CACPmB,wBAAwB,CAAxBA,wBAAwB,CACxBX,uBAAuB,CAAvBA,uBAAuB,CACvBE,eAAe,CAAfA,eACF,CAAC,CACH;;;;"}
|
|
@@ -9,7 +9,7 @@ import { makeSize } from '../../utils/makeSize/makeSize.js';
|
|
|
9
9
|
import '../BladeProvider/useTheme.js';
|
|
10
10
|
import { jsx } from 'react/jsx-runtime';
|
|
11
11
|
|
|
12
|
-
var MarkerBackgroundCircle=function MarkerBackgroundCircle(_ref){var color=_ref.color,size=_ref.size,margin=_ref.margin,children=_ref.children;return jsx(BaseBox,{backgroundColor:color==='primary'?'surface.background.primary.subtle':`feedback.background.${color}.subtle`,display:"flex",alignItems:"center",justifyContent:"center",height:size,width:size,borderRadius:"round",margin:margin,children:children});};var StepItemIndicator=function StepItemIndicator(_ref2){var color=_ref2.color;var _useStepGroup=useStepGroup(),size=_useStepGroup.size;var spacingTokens=getMarkerLineSpacings(size);return jsx(MarkerBackgroundCircle,{color:color,size:makeSize(spacingTokens.markerBackgroundSize),margin:makeSize(spacingTokens.markerMargin),children:jsx(Indicator,{position:"relative",color:color,size:size,accessibilityLabel:`${color} indicator`})});};var StepItemIcon=function StepItemIcon(_ref3){var Icon=_ref3.icon,_ref3$color=_ref3.color,color=_ref3$color===void 0?'neutral':_ref3$color;var _useStepGroup2=useStepGroup(),size=_useStepGroup2.size;var spacingTokens=getMarkerLineSpacings(size);return jsx(MarkerBackgroundCircle,{color:color,size:makeSize(spacingTokens.markerBackgroundSize),margin:makeSize(spacingTokens.markerMargin),children:jsx(Icon,{size:iconSizeTokens[size],color:color==='primary'?'surface.icon.primary.normal':`feedback.icon.${color}.intense`})});};
|
|
12
|
+
var MarkerBackgroundCircle=function MarkerBackgroundCircle(_ref){var color=_ref.color,size=_ref.size,margin=_ref.margin,children=_ref.children;return jsx(BaseBox,{backgroundColor:color==='primary'?'surface.background.primary.subtle':`feedback.background.${color}.subtle`,display:"flex",alignItems:"center",justifyContent:"center",height:size,width:size,borderRadius:"round",margin:margin,children:children});};var StepItemIndicator=function StepItemIndicator(_ref2){var color=_ref2.color;var _useStepGroup=useStepGroup(),size=_useStepGroup.size;var spacingTokens=getMarkerLineSpacings(size);return jsx(MarkerBackgroundCircle,{color:color,size:makeSize(spacingTokens.markerBackgroundSize),margin:makeSize(spacingTokens.markerMargin),children:jsx(Indicator,{position:"relative",color:color,size:size,accessibilityLabel:`${color} indicator`})});};var StepItemIcon=function StepItemIcon(_ref3){var Icon=_ref3.icon,_ref3$color=_ref3.color,color=_ref3$color===void 0?'neutral':_ref3$color,_ref3$isDisabled=_ref3.isDisabled,isDisabled=_ref3$isDisabled===void 0?false:_ref3$isDisabled;var _useStepGroup2=useStepGroup(),size=_useStepGroup2.size;var spacingTokens=getMarkerLineSpacings(size);return jsx(MarkerBackgroundCircle,{color:color,size:makeSize(spacingTokens.markerBackgroundSize),margin:makeSize(spacingTokens.markerMargin),children:jsx(Icon,{size:iconSizeTokens[size],color:isDisabled?'surface.icon.gray.disabled':color==='primary'?'surface.icon.primary.normal':`feedback.icon.${color}.intense`})});};
|
|
13
13
|
|
|
14
14
|
export { StepItemIcon, StepItemIndicator };
|
|
15
15
|
//# sourceMappingURL=StepItemMarker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepItemMarker.js","sources":["../../../../../src/components/StepGroup/StepItemMarker.tsx"],"sourcesContent":["import { useStepGroup } from './StepGroupContext';\nimport { getMarkerLineSpacings, iconSizeTokens } from './tokens';\nimport type { BaseBoxProps } from '~components/Box/BaseBox';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { IconComponent } from '~components/Icons';\nimport type { IndicatorProps } from '~components/Indicator';\nimport { Indicator } from '~components/Indicator';\nimport { makeSize } from '~utils';\n\ntype MarkerBackgroundCircleProps = {\n color: IndicatorProps['color'];\n size: BaseBoxProps['width'];\n margin: BaseBoxProps['margin'];\n children: BaseBoxProps['children'];\n};\n\nconst MarkerBackgroundCircle = ({\n color,\n size,\n margin,\n children,\n}: MarkerBackgroundCircleProps): React.ReactElement => {\n return (\n <BaseBox\n backgroundColor={\n color === 'primary'\n ? 'surface.background.primary.subtle'\n : `feedback.background.${color}.subtle`\n }\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n height={size}\n width={size}\n borderRadius=\"round\"\n margin={margin}\n >\n {children}\n </BaseBox>\n );\n};\n\nconst StepItemIndicator = ({ color }: { color: IndicatorProps['color'] }): React.ReactElement => {\n const { size } = useStepGroup();\n const spacingTokens = getMarkerLineSpacings(size);\n\n return (\n <MarkerBackgroundCircle\n color={color}\n size={makeSize(spacingTokens.markerBackgroundSize)}\n margin={makeSize(spacingTokens.markerMargin)}\n >\n <Indicator\n position=\"relative\"\n color={color}\n size={size}\n accessibilityLabel={`${color} indicator`}\n />\n </MarkerBackgroundCircle>\n );\n};\n\ntype StepItemIconProps = {\n icon: IconComponent;\n color: IndicatorProps['color'];\n};\n\nconst StepItemIcon = ({
|
|
1
|
+
{"version":3,"file":"StepItemMarker.js","sources":["../../../../../src/components/StepGroup/StepItemMarker.tsx"],"sourcesContent":["import { useStepGroup } from './StepGroupContext';\nimport { getMarkerLineSpacings, iconSizeTokens } from './tokens';\nimport type { BaseBoxProps } from '~components/Box/BaseBox';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { IconComponent } from '~components/Icons';\nimport type { IndicatorProps } from '~components/Indicator';\nimport { Indicator } from '~components/Indicator';\nimport { makeSize } from '~utils';\n\ntype MarkerBackgroundCircleProps = {\n color: IndicatorProps['color'];\n size: BaseBoxProps['width'];\n margin: BaseBoxProps['margin'];\n children: BaseBoxProps['children'];\n};\n\nconst MarkerBackgroundCircle = ({\n color,\n size,\n margin,\n children,\n}: MarkerBackgroundCircleProps): React.ReactElement => {\n return (\n <BaseBox\n backgroundColor={\n color === 'primary'\n ? 'surface.background.primary.subtle'\n : `feedback.background.${color}.subtle`\n }\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n height={size}\n width={size}\n borderRadius=\"round\"\n margin={margin}\n >\n {children}\n </BaseBox>\n );\n};\n\nconst StepItemIndicator = ({ color }: { color: IndicatorProps['color'] }): React.ReactElement => {\n const { size } = useStepGroup();\n const spacingTokens = getMarkerLineSpacings(size);\n\n return (\n <MarkerBackgroundCircle\n color={color}\n size={makeSize(spacingTokens.markerBackgroundSize)}\n margin={makeSize(spacingTokens.markerMargin)}\n >\n <Indicator\n position=\"relative\"\n color={color}\n size={size}\n accessibilityLabel={`${color} indicator`}\n />\n </MarkerBackgroundCircle>\n );\n};\n\ntype StepItemIconProps = {\n icon: IconComponent;\n color: IndicatorProps['color'];\n isDisabled?: boolean;\n};\n\nconst StepItemIcon = ({\n icon: Icon,\n color = 'neutral',\n isDisabled = false,\n}: StepItemIconProps): React.ReactElement => {\n const { size } = useStepGroup();\n const spacingTokens = getMarkerLineSpacings(size);\n\n return (\n <MarkerBackgroundCircle\n color={color}\n size={makeSize(spacingTokens.markerBackgroundSize)}\n margin={makeSize(spacingTokens.markerMargin)}\n >\n <Icon\n size={iconSizeTokens[size]}\n color={\n isDisabled\n ? 'surface.icon.gray.disabled'\n : color === 'primary'\n ? 'surface.icon.primary.normal'\n : `feedback.icon.${color}.intense`\n }\n />\n </MarkerBackgroundCircle>\n );\n};\n\nexport { StepItemIndicator, StepItemIcon };\n"],"names":["MarkerBackgroundCircle","_ref","color","size","margin","children","_jsx","BaseBox","backgroundColor","display","alignItems","justifyContent","height","width","borderRadius","StepItemIndicator","_ref2","_useStepGroup","useStepGroup","spacingTokens","getMarkerLineSpacings","makeSize","markerBackgroundSize","markerMargin","Indicator","position","accessibilityLabel","StepItemIcon","_ref3","Icon","icon","_ref3$color","_ref3$isDisabled","isDisabled","_useStepGroup2","iconSizeT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C,CAAC,CACoB,CAAC,CAE7B,EAQM,IAAAyB,YAAY,CAAG,SAAfA,YAAYA,CAAAC,KAAA,CAI2B,KAHrCC,IAAI,CAAAD,KAAA,CAAVE,IAAI,CAAAC,WAAA,CAAAH,KAAA,CACJ1B,KAAK,CAALA,KAAK,CAAA6B,WAAA,GAAG,KAAA,CAAA,CAAA,SAAS,CAAAA,WAAA,CAAAC,gBAAA,CAAAJ,KAAA,CACjBK,UAAU,CAAVA,UAAU,CAAAD,gBAAA,GAAG,KAAA,CAAA,CAAA,KAAK,CAAAA,gBAAA,CAElB,IAAAE,cAAA,CAAiBhB,YAAY,EAAE,CAAvBf,IAAI,CAAA+B,cAAA,CAAJ/B,IAAI,CACZ,IAAMgB,aAAa,CAAGC,qBAAqB,CAACjB,IAAI,CAAC,CAEjD,OACEG,GAAA,CAACN,sBAAsB,CACrBE,CAAAA,KAAK,CAAEA,KAAM,CACbC,IAAI,CAAEkB,QAAQ,CAACF,aAAa,CAACG,oBAAoB,CAAE,CACnDlB,MAAM,CAAEiB,QAAQ,CAACF,aAAa,CAACI,YAAY,CAAE,CAAAlB,QAAA,CAE7CC,GAAA,CAACuB,IAAI,CACH1B,CAAAA,IAAI,CAAEgC,cAAc,CAAChC,IAAI,CAAE,CAC3BD,KAAK,CACH+B,UAAU,CACN,4BAA4B,CAC5B/B,KAAK,GAAK,SAAS,CACnB,6BAA6B,CAC5B,CAAA,cAAA,EAAgBA,KAAM,CAC5B,QAAA,CAAA,CACF,CAAC,CACoB,CAAC,CAE7B;;;;"}
|
|
@@ -7,7 +7,7 @@ import '../global/typography.js';
|
|
|
7
7
|
import '../global/motion.js';
|
|
8
8
|
import { throwBladeError } from '../../utils/logger/logger.js';
|
|
9
9
|
|
|
10
|
-
var WCAG2ContrastOptions={level:'AAA',size:'large'};var getColorWithOpacity=function getColorWithOpacity(color,opacity){return tinycolor(color).setAlpha(opacity).toHslString();};var generateChromaticBrandColors=function generateChromaticBrandColors(baseColorInput){var baseColor=tinycolor(baseColorInput);var baseColorHslString=baseColor.toHslString();if(__DEV__){if(!baseColor.isValid()){throwBladeError({message:'Invalid brandColor passed',moduleName:'createTheme'});}}var palette=[baseColorHslString];var brightness=tinycolor(baseColor).getBrightness();var lightnessFactor=brightness>150?3:6;var darknessFactor=brightness<50?3:5;var currentColor=baseColor;for(var lightShadeIndex=0;lightShadeIndex<6;lightShadeIndex++){currentColor=currentColor.brighten(lightnessFactor);palette.push(currentColor.toHslString());}currentColor=tinycolor(baseColorHslString);for(var darkShadeIndex=0;darkShadeIndex<4;darkShadeIndex++){currentColor=currentColor.darken(darknessFactor);palette.unshift(currentColor.toHslString());}var colorPalette=palette.reverse();var brandPrimaryColor=colorPalette[6];var brandColors={'50':colorPalette[0],'100':colorPalette[1],'200':colorPalette[2],'300':colorPalette[3],'400':colorPalette[4],'500':colorPalette[5],'600':brandPrimaryColor,'700':colorPalette[7],'800':colorPalette[8],'900':colorPalette[9],'1000':colorPalette[10],a50:getColorWithOpacity(brandPrimaryColor,opacity[100]),a150:getColorWithOpacity(brandPrimaryColor,opacity[100]),a100:getColorWithOpacity(brandPrimaryColor,opacity[200]),a200:getColorWithOpacity(brandPrimaryColor,opacity[300]),a400:getColorWithOpacity(brandPrimaryColor,opacity[400])};return brandColors;};var getOnLightOverrides=function getOnLightOverrides(brandColors){var foregroundOnSurface=tinycolor.isReadable(colors.neutral.blueGrayLight[50],brandColors[600],WCAG2ContrastOptions)?brandColors[600]:colors.neutral.blueGrayLight[1100];var foregroundOnBrand=tinycolor.mostReadable(brandColors[900],[colors.neutral.white[500],colors.neutral.black[500]],WCAG2ContrastOptions).toHslString();var lightThemeOverrides={interactive:{background:{primary:{default:brandColors[600],highlighted:brandColors[700],disabled:brandColors.a100,faded:brandColors.a100,fadedHighlighted:brandColors.a150}},border:{primary:{default:brandColors[600],highlighted:brandColors[700],disabled:brandColors.a100,faded:brandColors.a100}},text:{primary:{normal:foregroundOnSurface,disabled:
|
|
10
|
+
var WCAG2ContrastOptions={level:'AAA',size:'large'};var getColorWithOpacity=function getColorWithOpacity(color,opacity){return tinycolor(color).setAlpha(opacity).toHslString();};var generateChromaticBrandColors=function generateChromaticBrandColors(baseColorInput){var baseColor=tinycolor(baseColorInput);var baseColorHslString=baseColor.toHslString();if(__DEV__){if(!baseColor.isValid()){throwBladeError({message:'Invalid brandColor passed',moduleName:'createTheme'});}}var palette=[baseColorHslString];var brightness=tinycolor(baseColor).getBrightness();var lightnessFactor=brightness>150?3:6;var darknessFactor=brightness<50?3:5;var currentColor=baseColor;for(var lightShadeIndex=0;lightShadeIndex<6;lightShadeIndex++){currentColor=currentColor.brighten(lightnessFactor);palette.push(currentColor.toHslString());}currentColor=tinycolor(baseColorHslString);for(var darkShadeIndex=0;darkShadeIndex<4;darkShadeIndex++){currentColor=currentColor.darken(darknessFactor);palette.unshift(currentColor.toHslString());}var colorPalette=palette.reverse();var brandPrimaryColor=colorPalette[6];var brandColors={'50':colorPalette[0],'100':colorPalette[1],'200':colorPalette[2],'300':colorPalette[3],'400':colorPalette[4],'500':colorPalette[5],'600':brandPrimaryColor,'700':colorPalette[7],'800':colorPalette[8],'900':colorPalette[9],'1000':colorPalette[10],a50:getColorWithOpacity(brandPrimaryColor,opacity[100]),a150:getColorWithOpacity(brandPrimaryColor,opacity[100]),a100:getColorWithOpacity(brandPrimaryColor,opacity[200]),a200:getColorWithOpacity(brandPrimaryColor,opacity[300]),a400:getColorWithOpacity(brandPrimaryColor,opacity[400])};return brandColors;};var getOnLightOverrides=function getOnLightOverrides(brandColors){var foregroundOnSurface=tinycolor.isReadable(colors.neutral.blueGrayLight[50],brandColors[600],WCAG2ContrastOptions)?brandColors[600]:colors.neutral.blueGrayLight[1100];var foregroundOnBrand=tinycolor.mostReadable(brandColors[900],[colors.neutral.white[500],colors.neutral.black[500]],WCAG2ContrastOptions).toHslString();var lightThemeOverrides={interactive:{background:{primary:{default:brandColors[600],highlighted:brandColors[700],disabled:brandColors.a100,faded:brandColors.a100,fadedHighlighted:brandColors.a150}},border:{primary:{default:brandColors[600],highlighted:brandColors[700],disabled:brandColors.a100,faded:brandColors.a100}},text:{primary:{normal:foregroundOnSurface,disabled:brandColors.a200,muted:foregroundOnSurface,subtle:foregroundOnSurface},onPrimary:{normal:foregroundOnBrand,disabled:foregroundOnBrand,muted:foregroundOnBrand,subtle:foregroundOnBrand}},icon:{primary:{normal:foregroundOnSurface,disabled:brandColors.a200,muted:foregroundOnSurface,subtle:foregroundOnSurface},onPrimary:{normal:foregroundOnBrand,disabled:foregroundOnBrand,muted:foregroundOnBrand,subtle:foregroundOnBrand}}},surface:{background:{primary:{intense:brandColors[600],subtle:brandColors[200]}},icon:{primary:{normal:brandColors[600]}},text:{primary:{normal:brandColors[600]}}}};return lightThemeOverrides;};var getOnDarkOverrides=function getOnDarkOverrides(brandColors){var foregroundOnSurface=tinycolor.isReadable(colors.neutral.blueGrayDark[1100],brandColors[400],WCAG2ContrastOptions)?brandColors[400]:colors.neutral.blueGrayDark[0];var foregroundOnBrand=tinycolor.mostReadable(brandColors[900],[colors.neutral.white[500],colors.neutral.black[500]],WCAG2ContrastOptions).toHslString();var darkThemeOverrides={interactive:{background:{primary:{default:brandColors[600],highlighted:brandColors[700],disabled:brandColors.a100,faded:brandColors.a100,fadedHighlighted:brandColors.a150}},border:{primary:{default:brandColors[600],highlighted:brandColors[700],disabled:brandColors.a100,faded:brandColors.a100}},text:{primary:{normal:foregroundOnSurface,disabled:brandColors.a400,muted:foregroundOnSurface,subtle:foregroundOnSurface},onPrimary:{normal:foregroundOnBrand,disabled:foregroundOnBrand,muted:foregroundOnBrand,subtle:foregroundOnBrand}},icon:{primary:{normal:foregroundOnSurface,disabled:brandColors.a400,muted:foregroundOnSurface,subtle:foregroundOnSurface},onPrimary:{normal:foregroundOnBrand,disabled:foregroundOnBrand,muted:foregroundOnBrand,subtle:foregroundOnBrand}}},surface:{background:{primary:{intense:brandColors[600],subtle:brandColors[200]}},icon:{primary:{normal:brandColors[600]}}}};return darkThemeOverrides;};var createTheme=function createTheme(_ref){var brandColor=_ref.brandColor;var chromaticBrandColors=generateChromaticBrandColors(brandColor);var brandedLightTheme=getOnLightOverrides(chromaticBrandColors);var brandedDarkTheme=getOnDarkOverrides(chromaticBrandColors);var brandedThemeTokens=overrideTheme({baseThemeTokens:bladeTheme,overrides:{name:`custom-${tinycolor(brandColor).toHex()}`,colors:{onLight:Object.assign({},brandedLightTheme),onDark:Object.assign({},brandedDarkTheme)}}});return {theme:brandedThemeTokens,brandColors:chromaticBrandColors};};
|
|
11
11
|
|
|
12
12
|
export { createTheme };
|
|
13
13
|
//# sourceMappingURL=createTheme.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTheme.js","sources":["../../../../../src/tokens/theme/createTheme.ts"],"sourcesContent":["import tinycolor from 'tinycolor2';\nimport type { WCAG2Options, ColorInput } from 'tinycolor2';\nimport type { ThemeTokens } from './theme';\nimport overrideTheme from './overrideTheme';\nimport bladeTheme from './bladeTheme';\nimport { colors as globalColors, opacity } from '~tokens/global';\nimport type { ColorChromaticScale } from '~tokens/global/colors';\nimport { throwBladeError } from '~utils/logger';\nimport type { DeepPartial } from '~utils/isPartialMatchObjectKeys';\n\n// WCAG2ContrastOptions are the options used to determine if a color is readable\nconst WCAG2ContrastOptions: WCAG2Options = {\n level: 'AAA',\n size: 'large',\n};\n\n/**\n * getColorWithOpacity\n * @param color - The color to add opacity to\n * @param opacity - The opacity to add to the color\n * @returns The color with the opacity added\n * @example\n * getColorWithOpacity('#fff', 0.5) // returns 'hsla(0, 0%, 100%, 0.5)'\n *\n **/\nconst getColorWithOpacity = (color: ColorInput, opacity: number): string => {\n return tinycolor(color).setAlpha(opacity).toHslString();\n};\n\n/**\n *\n * @description\n * Generates a chromatic color palette based on the base color passed in.\n * The base color is used to generate a palette of 11 colors, 5 shades lighter and 5 shades darker than the base color.\n * @param baseColorInput - The base color to generate the chromatic color palette from in hex, rgb, or hsl format\n * @returns Array of chromatic color palette\n */\nconst generateChromaticBrandColors = (baseColorInput: ColorInput): ColorChromaticScale => {\n const baseColor = tinycolor(baseColorInput);\n const baseColorHslString = baseColor.toHslString();\n if (__DEV__) {\n if (!baseColor.isValid()) {\n throwBladeError({\n message: 'Invalid brandColor passed',\n moduleName: 'createTheme',\n });\n }\n }\n\n const palette = [baseColorHslString]; // Include the original color\n const brightness = tinycolor(baseColor).getBrightness();\n // Determine how much to lighten or darken the colors depending on the brightness of the base color\n const lightnessFactor = brightness > 150 ? 3 : 6;\n const darknessFactor = brightness < 50 ? 3 : 5;\n\n let currentColor = baseColor;\n\n // Generate shades lighter\n for (let lightShadeIndex = 0; lightShadeIndex < 6; lightShadeIndex++) {\n currentColor = currentColor.brighten(lightnessFactor);\n palette.push(currentColor.toHslString());\n }\n\n currentColor = tinycolor(baseColorHslString); // Reset to the base color\n\n // Generate shades darker\n for (let darkShadeIndex = 0; darkShadeIndex < 4; darkShadeIndex++) {\n currentColor = currentColor.darken(darknessFactor);\n palette.unshift(currentColor.toHslString()); // Add shades at the beginning of the palette\n }\n\n const colorPalette = palette.reverse();\n const brandPrimaryColor = colorPalette[6];\n\n const brandColors: ColorChromaticScale = {\n '50': colorPalette[0],\n '100': colorPalette[1],\n '200': colorPalette[2],\n '300': colorPalette[3],\n '400': colorPalette[4],\n '500': colorPalette[5],\n '600': brandPrimaryColor,\n '700': colorPalette[7],\n '800': colorPalette[8],\n '900': colorPalette[9],\n '1000': colorPalette[10],\n a50: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a150: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a100: getColorWithOpacity(brandPrimaryColor, opacity[200]),\n a200: getColorWithOpacity(brandPrimaryColor, opacity[300]),\n a400: getColorWithOpacity(brandPrimaryColor, opacity[400]),\n };\n\n return brandColors;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the light theme\n * @description Returns overrides for the light theme with the brand colors passed in\n * @returns Overrides for the light theme with the custom brand colors\n */\nconst getOnLightOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onLight']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayLight[50],\n brandColors[600],\n WCAG2ContrastOptions,\n )\n ? brandColors[600]\n : globalColors.neutral.blueGrayLight[1100];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the light theme with the brand colors passed in\n const lightThemeOverrides: DeepPartial<ThemeTokens['colors']['onLight']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: foregroundOnSurface,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: foregroundOnSurface,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n text: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return lightThemeOverrides;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the dark theme\n * @description Returns overrides for the dark theme with the brand colors passed in\n * @returns Overrides for the dark theme with the custom brand colors\n */\nconst getOnDarkOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onDark']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayDark[1100],\n brandColors[400],\n WCAG2ContrastOptions,\n )\n ? brandColors[400]\n : globalColors.neutral.blueGrayDark[0];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the dark theme with the brand colors passed in\n const darkThemeOverrides: DeepPartial<ThemeTokens['colors']['onDark']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: foregroundOnSurface,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: foregroundOnSurface,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return darkThemeOverrides;\n};\n\n/**\n * @param {Object} themeConfig - The brand color and overrides to apply to the theme\n * @param {string} themeConfig.brandColor - The brand color to use to generate the theme. Can be in hex, rgb, or hsl format.\n * @description\n * Creates a Blade Theme based on the custom brand color\n * @returns The Theme Tokens with the custom brand colors\n * @example\n * const { theme, brandColors } = createTheme({ brandColor: '#19BEA2'})\n **/\nexport const createTheme = ({\n brandColor,\n}: {\n brandColor: ColorInput;\n}): { theme: ThemeTokens; brandColors: ColorChromaticScale } => {\n const chromaticBrandColors = generateChromaticBrandColors(brandColor);\n // Get onLight overrides\n const brandedLightTheme = getOnLightOverrides(chromaticBrandColors);\n // Get onDark overrides\n const brandedDarkTheme = getOnDarkOverrides(chromaticBrandColors);\n // Override the payment theme with the brand colors\n const brandedThemeTokens = overrideTheme({\n baseThemeTokens: bladeTheme,\n overrides: {\n name: `custom-${tinycolor(brandColor).toHex()}`,\n colors: {\n onLight: {\n ...brandedLightTheme,\n },\n onDark: {\n ...brandedDarkTheme,\n },\n },\n },\n });\n\n return { theme: brandedThemeTokens, brandColors: chromaticBrandColors };\n};\n"],"names":["WCAG2ContrastOptions","level","size","getColorWithOpacity","color","opacity","tinycolor","setAlpha","toHslString","generateChromaticBrandColors","baseColorInput","baseColor","baseColorHslString","__DEV__","isValid","throwBladeError","message","moduleName","palette","brightness","getBrightness","lightnessFactor","darknessFactor","currentColor","lightShadeIndex","brighten","push","darkShadeIndex","darken","unshift","colorPalette","reverse","brandPrimaryColor","brandColors","a50","a150","a100","a200","a400","getOnLightOverrides","foregroundOnSurface","isReadable","globalColors","neutral","blueGrayLight","foregroundOnBrand","mostReadable","white","black","lightThemeOverrides","interactive","background","primary","default","highlighted","disabled","faded","fadedHighlighted","border","text","normal","muted","subtle","onPrimary","icon","surface","intense","getOnDarkOverrides","blueGrayDark","darkThemeOverrides","createTheme","_ref","brandColor","chromaticBrandColors","brandedLightTheme","brandedDarkTheme","brandedThemeTokens","overrideTheme","baseThemeTokens","bladeTheme","overrides","name","toHex","colors","onLight","Object","assign","on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me/createTheme.ts"],"sourcesContent":["import tinycolor from 'tinycolor2';\nimport type { WCAG2Options, ColorInput } from 'tinycolor2';\nimport type { ThemeTokens } from './theme';\nimport overrideTheme from './overrideTheme';\nimport bladeTheme from './bladeTheme';\nimport { colors as globalColors, opacity } from '~tokens/global';\nimport type { ColorChromaticScale } from '~tokens/global/colors';\nimport { throwBladeError } from '~utils/logger';\nimport type { DeepPartial } from '~utils/isPartialMatchObjectKeys';\n\n// WCAG2ContrastOptions are the options used to determine if a color is readable\nconst WCAG2ContrastOptions: WCAG2Options = {\n level: 'AAA',\n size: 'large',\n};\n\n/**\n * getColorWithOpacity\n * @param color - The color to add opacity to\n * @param opacity - The opacity to add to the color\n * @returns The color with the opacity added\n * @example\n * getColorWithOpacity('#fff', 0.5) // returns 'hsla(0, 0%, 100%, 0.5)'\n *\n **/\nconst getColorWithOpacity = (color: ColorInput, opacity: number): string => {\n return tinycolor(color).setAlpha(opacity).toHslString();\n};\n\n/**\n *\n * @description\n * Generates a chromatic color palette based on the base color passed in.\n * The base color is used to generate a palette of 11 colors, 5 shades lighter and 5 shades darker than the base color.\n * @param baseColorInput - The base color to generate the chromatic color palette from in hex, rgb, or hsl format\n * @returns Array of chromatic color palette\n */\nconst generateChromaticBrandColors = (baseColorInput: ColorInput): ColorChromaticScale => {\n const baseColor = tinycolor(baseColorInput);\n const baseColorHslString = baseColor.toHslString();\n if (__DEV__) {\n if (!baseColor.isValid()) {\n throwBladeError({\n message: 'Invalid brandColor passed',\n moduleName: 'createTheme',\n });\n }\n }\n\n const palette = [baseColorHslString]; // Include the original color\n const brightness = tinycolor(baseColor).getBrightness();\n // Determine how much to lighten or darken the colors depending on the brightness of the base color\n const lightnessFactor = brightness > 150 ? 3 : 6;\n const darknessFactor = brightness < 50 ? 3 : 5;\n\n let currentColor = baseColor;\n\n // Generate shades lighter\n for (let lightShadeIndex = 0; lightShadeIndex < 6; lightShadeIndex++) {\n currentColor = currentColor.brighten(lightnessFactor);\n palette.push(currentColor.toHslString());\n }\n\n currentColor = tinycolor(baseColorHslString); // Reset to the base color\n\n // Generate shades darker\n for (let darkShadeIndex = 0; darkShadeIndex < 4; darkShadeIndex++) {\n currentColor = currentColor.darken(darknessFactor);\n palette.unshift(currentColor.toHslString()); // Add shades at the beginning of the palette\n }\n\n const colorPalette = palette.reverse();\n const brandPrimaryColor = colorPalette[6];\n\n const brandColors: ColorChromaticScale = {\n '50': colorPalette[0],\n '100': colorPalette[1],\n '200': colorPalette[2],\n '300': colorPalette[3],\n '400': colorPalette[4],\n '500': colorPalette[5],\n '600': brandPrimaryColor,\n '700': colorPalette[7],\n '800': colorPalette[8],\n '900': colorPalette[9],\n '1000': colorPalette[10],\n a50: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a150: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a100: getColorWithOpacity(brandPrimaryColor, opacity[200]),\n a200: getColorWithOpacity(brandPrimaryColor, opacity[300]),\n a400: getColorWithOpacity(brandPrimaryColor, opacity[400]),\n };\n\n return brandColors;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the light theme\n * @description Returns overrides for the light theme with the brand colors passed in\n * @returns Overrides for the light theme with the custom brand colors\n */\nconst getOnLightOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onLight']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayLight[50],\n brandColors[600],\n WCAG2ContrastOptions,\n )\n ? brandColors[600]\n : globalColors.neutral.blueGrayLight[1100];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the light theme with the brand colors passed in\n const lightThemeOverrides: DeepPartial<ThemeTokens['colors']['onLight']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a200,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a200,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n text: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return lightThemeOverrides;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the dark theme\n * @description Returns overrides for the dark theme with the brand colors passed in\n * @returns Overrides for the dark theme with the custom brand colors\n */\nconst getOnDarkOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onDark']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayDark[1100],\n brandColors[400],\n WCAG2ContrastOptions,\n )\n ? brandColors[400]\n : globalColors.neutral.blueGrayDark[0];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the dark theme with the brand colors passed in\n const darkThemeOverrides: DeepPartial<ThemeTokens['colors']['onDark']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a400,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a400,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return darkThemeOverrides;\n};\n\n/**\n * @param {Object} themeConfig - The brand color and overrides to apply to the theme\n * @param {string} themeConfig.brandColor - The brand color to use to generate the theme. Can be in hex, rgb, or hsl format.\n * @description\n * Creates a Blade Theme based on the custom brand color\n * @returns The Theme Tokens with the custom brand colors\n * @example\n * const { theme, brandColors } = createTheme({ brandColor: '#19BEA2'})\n **/\nexport const createTheme = ({\n brandColor,\n}: {\n brandColor: ColorInput;\n}): { theme: ThemeTokens; brandColors: ColorChromaticScale } => {\n const chromaticBrandColors = generateChromaticBrandColors(brandColor);\n // Get onLight overrides\n const brandedLightTheme = getOnLightOverrides(chromaticBrandColors);\n // Get onDark overrides\n const brandedDarkTheme = getOnDarkOverrides(chromaticBrandColors);\n // Override the payment theme with the brand colors\n const brandedThemeTokens = overrideTheme({\n baseThemeTokens: bladeTheme,\n overrides: {\n name: `custom-${tinycolor(brandColor).toHex()}`,\n colors: {\n onLight: {\n ...brandedLightTheme,\n },\n onDark: {\n ...brandedDarkTheme,\n },\n },\n },\n });\n\n return { theme: brandedThemeTokens, brandColors: chromaticBrandColors };\n};\n"],"names":["WCAG2ContrastOptions","level","size","getColorWithOpacity","color","opacity","tinycolor","setAlpha","toHslString","generateChromaticBrandColors","baseColorInput","baseColor","baseColorHslString","__DEV__","isValid","throwBladeError","message","moduleName","palette","brightness","getBrightness","lightnessFactor","darknessFactor","currentColor","lightShadeIndex","brighten","push","darkShadeIndex","darken","unshift","colorPalette","reverse","brandPrimaryColor","brandColors","a50","a150","a100","a200","a400","getOnLightOverrides","foregroundOnSurface","isReadable","globalColors","neutral","blueGrayLight","foregroundOnBrand","mostReadable","white","black","lightThemeOverrides","interactive","background","primary","default","highlighted","disabled","faded","fadedHighlighted","border","text","normal","muted","subtle","onPrimary","icon","surface","intense","getOnDarkOverrides","blueGrayDark","darkThemeOverrides","createTheme","_ref","brandColor","chromaticBrandColors","brandedLightTheme","brandedDarkTheme","brandedThemeTokens","overrideTheme","baseThemeTokens","bladeTheme","overrides","name","toHex","colors","onLight","Object","assign","onDark","theme"],"mappings":";;;;;;;;;AAWA,IAAMA,oBAAkC,CAAG,CACzCC,KAAK,CAAE,KAAK,CACZC,IAAI,CAAE,OACR,CAAC,CAWD,IAAMC,mBAAmB,CAAG,SAAtBA,mBAAmBA,CAAIC,KAAiB,CAAEC,OAAe,CAAa,CAC1E,OAAOC,SAAS,CAACF,KAAK,CAAC,CAACG,QAAQ,CAACF,OAAO,CAAC,CAACG,WAAW,EAAE,CACzD,CAAC,CAUD,IAAMC,4BAA4B,CAAG,SAA/BA,4BAA4BA,CAAIC,cAA0B,CAA0B,CACxF,IAAMC,SAAS,CAAGL,SAAS,CAACI,cAAc,CAAC,CAC3C,IAAME,kBAAkB,CAAGD,SAAS,CAACH,WAAW,EAAE,CAClD,GAAIK,OA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AAkB,CAC3B,CAAC,CAWY,IAAAC,WAAW,CAAG,SAAdA,WAAWA,CAAAC,IAAA,CAIwC,CAH9D,IAAAC,UAAU,CAAAD,IAAA,CAAVC,UAAU,CAIV,IAAMC,oBAAoB,CAAGhE,4BAA4B,CAAC+D,UAAU,CAAC,CAErE,IAAME,iBAAiB,CAAGnC,mBAAmB,CAACkC,oBAAoB,CAAC,CAEnE,IAAME,gBAAgB,CAAGR,kBAAkB,CAACM,oBAAoB,CAAC,CAEjE,IAAMG,kBAAkB,CAAGC,aAAa,CAAC,CACvCC,eAAe,CAAEC,UAAU,CAC3BC,SAAS,CAAE,CACTC,IAAI,CAAG,CAAS3E,OAAAA,EAAAA,SAAS,CAACkE,UAAU,CAAC,CAACU,KAAK,EAAG,EAAC,CAC/CC,MAAM,CAAE,CACNC,OAAO,CAAAC,MAAA,CAAAC,MAAA,CACFZ,EAAAA,CAAAA,iBAAiB,CACrB,CACDa,MAAM,CAAAF,MAAA,CAAAC,MAAA,CACDX,EAAAA,CAAAA,gBAAgB,CAEvB,CACF,CACF,CAAC,CAAC,CAEF,OAAO,CAAEa,KAAK,CAAEZ,kBAAkB,CAAE3C,WAAW,CAAEwC,oBAAqB,CAAC,CACzE;;;;"}
|
|
@@ -36,7 +36,6 @@ var useTaggedInput = function useTaggedInput(_ref) {
|
|
|
36
36
|
_useControllableState2 = _slicedToArray(_useControllableState, 2),
|
|
37
37
|
tagsValue = _useControllableState2[0],
|
|
38
38
|
setTagsValue = _useControllableState2[1];
|
|
39
|
-
var isTagsControlled = Boolean(tags);
|
|
40
39
|
var getNewTagsArray = function getNewTagsArray(indexToRemove) {
|
|
41
40
|
var currentTags = tagsValue;
|
|
42
41
|
if (!currentTags) {
|
|
@@ -62,16 +61,8 @@ var useTaggedInput = function useTaggedInput(_ref) {
|
|
|
62
61
|
isDisabled: isDisabled,
|
|
63
62
|
onDismiss: function onDismiss(_ref3) {
|
|
64
63
|
var tagIndex = _ref3.tagIndex;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
if (!isTagsControlled) {
|
|
69
|
-
setTagsValue(function () {
|
|
70
|
-
return getNewTagsArray(tagIndex);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
onTagChange === null || onTagChange === void 0 ? void 0 : onTagChange({
|
|
74
|
-
tags: getNewTagsArray(tagIndex)
|
|
64
|
+
setTagsValue(function () {
|
|
65
|
+
return getNewTagsArray(tagIndex);
|
|
75
66
|
});
|
|
76
67
|
}
|
|
77
68
|
});
|
|
@@ -90,13 +81,8 @@ var useTaggedInput = function useTaggedInput(_ref) {
|
|
|
90
81
|
if (!isTaggedInput) {
|
|
91
82
|
return;
|
|
92
83
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return [];
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
onTagChange === null || onTagChange === void 0 ? void 0 : onTagChange({
|
|
99
|
-
tags: []
|
|
84
|
+
setTagsValue(function () {
|
|
85
|
+
return [];
|
|
100
86
|
});
|
|
101
87
|
};
|
|
102
88
|
var clearInput = function clearInput() {
|
|
@@ -135,26 +121,16 @@ var useTaggedInput = function useTaggedInput(_ref) {
|
|
|
135
121
|
var _e$event$preventDefau, _e$event;
|
|
136
122
|
(_e$event$preventDefau = (_e$event = e.event).preventDefault) === null || _e$event$preventDefau === void 0 ? void 0 : _e$event$preventDefau.call(_e$event); // we don't want textarea to treat enter as line break in tagged inputs
|
|
137
123
|
if (inputValue) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return [].concat(_toConsumableArray(currentTags), [inputValue]);
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
onTagChange === null || onTagChange === void 0 ? void 0 : onTagChange({
|
|
144
|
-
tags: [].concat(_toConsumableArray(currentTags), [inputValue])
|
|
124
|
+
setTagsValue(function () {
|
|
125
|
+
return [].concat(_toConsumableArray(currentTags), [inputValue]);
|
|
145
126
|
});
|
|
146
127
|
clearInput();
|
|
147
128
|
setActiveTagIndex(-1);
|
|
148
129
|
}
|
|
149
130
|
}
|
|
150
131
|
if (e.key === 'Backspace' && !inputValue && activeTagIndex < 0 && currentTags.length > 0) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
return currentTags.slice(0, -1);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
onTagChange === null || onTagChange === void 0 ? void 0 : onTagChange({
|
|
157
|
-
tags: currentTags.slice(0, -1)
|
|
132
|
+
setTagsValue(function () {
|
|
133
|
+
return currentTags.slice(0, -1);
|
|
158
134
|
});
|
|
159
135
|
}
|
|
160
136
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTaggedInput.js","sources":["../../../../../../../src/components/Input/BaseInput/useTaggedInput.ts"],"sourcesContent":["import React from 'react';\nimport type { BaseInputProps } from './BaseInput';\nimport type { BladeElementRefWithValue } from '~utils/types';\nimport type { FormInputOnEvent, FormInputOnKeyDownEvent } from '~components/Form/FormTypes';\n// import { isReactNative } from '~utils';\nimport { getTagsGroup } from '~components/Tag/getTagsGroup';\nimport { isReactNative } from '~utils';\nimport { useControllableState } from '~utils/useControllable';\n\ntype TaggedInputProps = {\n isTaggedInput?: boolean;\n tags?: string[];\n onTagChange?: ({ tags }: { tags: string[] }) => void;\n};\n\ntype UseTaggedInputProps = TaggedInputProps &\n Pick<BaseInputProps, 'isDisabled' | 'onChange' | 'name' | 'value' | 'defaultValue'> & {\n inputRef: React.RefObject<BladeElementRefWithValue | null>;\n };\n\ntype UseTaggedInputReturn = {\n activeTagIndex: number;\n setActiveTagIndex: (activeTagIndex: number) => void;\n getTags: ({ size }: { size: NonNullable<BaseInputProps['size']> }) => React.ReactElement[];\n handleTaggedInputKeydown: (e: FormInputOnKeyDownEvent) => void;\n handleTaggedInputChange: FormInputOnEvent;\n handleTagsClear: () => void;\n};\n\nconst useTaggedInput = ({\n tags,\n isDisabled,\n onTagChange,\n isTaggedInput,\n inputRef,\n onChange,\n name,\n value,\n defaultValue,\n}: UseTaggedInputProps): UseTaggedInputReturn => {\n const [activeTagIndex, setActiveTagIndex] = React.useState(-1);\n const [inputValueUncontrolled, setInputValueUncontrolled] = React.useState(defaultValue ?? '');\n const [tagsValue, setTagsValue] = useControllableState({\n value: tags,\n defaultValue: [],\n onChange: (tags) => {\n onTagChange?.({ tags });\n },\n });\n\n const isTagsControlled = Boolean(tags);\n\n const getNewTagsArray = (indexToRemove: number): string[] => {\n const currentTags = tagsValue;\n\n if (!currentTags) {\n return [];\n }\n\n // Check if the index is valid\n if (indexToRemove < 0 || indexToRemove >= currentTags.length) {\n return currentTags; // Return the original array\n }\n\n // Create a new array without the element at the specified index\n const newArray = currentTags\n .slice(0, indexToRemove)\n .concat(currentTags.slice(indexToRemove + 1));\n\n return newArray;\n };\n\n const getTags = React.useMemo(\n () => ({ size }: { size: NonNullable<BaseInputProps['size']> }): React.ReactElement[] => {\n return getTagsGroup({\n size,\n tags: tagsValue,\n activeTagIndex,\n isDisabled,\n onDismiss: ({ tagIndex }) => {\n console.log('dismiss', { tagIndex });\n if (!isTagsControlled) {\n setTagsValue(() => getNewTagsArray(tagIndex));\n }\n onTagChange?.({ tags: getNewTagsArray(tagIndex) });\n },\n });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [activeTagIndex, tags, tagsValue, isDisabled],\n );\n\n const handleTaggedInputChange: FormInputOnEvent = ({ value }) => {\n if (!isTaggedInput) {\n return;\n }\n setInputValueUncontrolled(value ?? '');\n };\n\n const handleTagsClear = (): void => {\n if (!isTaggedInput) {\n return;\n }\n\n if (!isTagsControlled) {\n setTagsValue(() => []);\n }\n\n onTagChange?.({ tags: [] });\n };\n\n const clearInput = (): void => {\n const isControlledValue = value !== undefined;\n\n if (isControlledValue) {\n // In Controlled component, we don't clear input ourselves. We just call onChange with empty value\n onChange?.({ name, value: '' });\n return;\n }\n\n if (!inputRef.current) {\n return;\n }\n\n setInputValueUncontrolled('');\n\n if (isReactNative()) {\n setTimeout(() => {\n // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error\n // @ts-ignore: clear does exist in react native\n inputRef.current?.clear();\n }, 10);\n return;\n }\n\n inputRef.current.value = '';\n };\n\n const handleTaggedInputKeydown = (e: FormInputOnKeyDownEvent): void => {\n if (!isTaggedInput) {\n return;\n }\n\n const currentTags = tagsValue;\n const isControlledValue = value !== undefined;\n const inputValue = isControlledValue ? value?.trim() : inputValueUncontrolled.trim();\n if (e.key === 'Enter' || e.key === ',') {\n e.event.preventDefault?.(); // we don't want textarea to treat enter as line break in tagged inputs\n if (inputValue) {\n if (!isTagsControlled) {\n setTagsValue(() => [...currentTags, inputValue]);\n }\n onTagChange?.({ tags: [...currentTags, inputValue] });\n clearInput();\n setActiveTagIndex(-1);\n }\n }\n if (e.key === 'Backspace' && !inputValue && activeTagIndex < 0 && currentTags.length > 0) {\n if (!isTagsControlled) {\n setTagsValue(() => currentTags.slice(0, -1));\n }\n onTagChange?.({ tags: currentTags.slice(0, -1) });\n }\n };\n\n return {\n activeTagIndex,\n setActiveTagIndex,\n getTags,\n handleTaggedInputKeydown,\n handleTaggedInputChange,\n handleTagsClear,\n };\n};\n\nexport type { TaggedInputProps };\nexport { useTaggedInput };\n"],"names":["useTaggedInput","_ref","tags","isDisabled","onTagChange","isTaggedInput","inputRef","onChange","name","value","defaultValue","_React$useState","React","useState","_React$useState2","_slicedToArray","activeTagIndex","setActiveTagIndex","_React$useState3","_React$useState4","inputValueUncontrolled","setInputValueUncontrolled","_useControllableState","useControllableState","_useControllableState2","tagsValue","setTagsValue","isTagsControlled","Boolean","getNewTagsArray","indexToRemove","currentTags","length","newArray","slice","concat","getTags","useMemo","_ref2","size","getTagsGroup","onDismiss","_ref3","tagIndex","console","log","handleTaggedInputChange","_ref4","handleTagsClear","clearInput","isControlledValue","undefined","current","isReactNative","setTimeout","_inputRef$current","clear","handleTaggedInputKeydown","e","inputValue","trim","key","_e$event$preventDefau","_e$event","event","preventDefault","call","_toConsumableArray"],"mappings":";;;;;;;;AA6BA,I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cAAc,GAAG,CAAC,IAAIe,WAAW,CAACC,MAAM,GAAG,CAAC,EAAE;MACxF,IAAI,CAACL,gBAAgB,EAAE;AACrBD,QAAAA,YAAY,CAAC,YAAA;UAAA,OAAMK,WAAW,CAACG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;SAAC,CAAA,CAAA;AAC9C,OAAA;AACA9B,MAAAA,WAAW,KAAXA,IAAAA,IAAAA,WAAW,KAAXA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,WAAW,CAAG;QAAEF,IAAI,EAAE6B,WAAW,CAACG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAAE,OAAC,CAAC,CAAA;AACnD,KAAA;GACD,CAAA;EAED,OAAO;AACLlB,IAAAA,cAAc,EAAdA,cAAc;AACdC,IAAAA,iBAAiB,EAAjBA,iBAAiB;AACjBmB,IAAAA,OAAO,EAAPA,OAAO;AACPqB,IAAAA,wBAAwB,EAAxBA,wBAAwB;AACxBX,IAAAA,uBAAuB,EAAvBA,uBAAuB;AACvBE,IAAAA,eAAe,EAAfA,eAAAA;GACD,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"useTaggedInput.js","sources":["../../../../../../../src/components/Input/BaseInput/useTaggedInput.ts"],"sourcesContent":["import React from 'react';\nimport type { BaseInputProps } from './BaseInput';\nimport type { BladeElementRefWithValue } from '~utils/types';\nimport type { FormInputOnEvent, FormInputOnKeyDownEvent } from '~components/Form/FormTypes';\nimport { getTagsGroup } from '~components/Tag/getTagsGroup';\nimport { isReactNative } from '~utils';\nimport { useControllableState } from '~utils/useControllable';\n\ntype TaggedInputProps = {\n isTaggedInput?: boolean;\n tags?: string[];\n onTagChange?: ({ tags }: { tags: string[] }) => void;\n};\n\ntype UseTaggedInputProps = TaggedInputProps &\n Pick<BaseInputProps, 'isDisabled' | 'onChange' | 'name' | 'value' | 'defaultValue'> & {\n inputRef: React.RefObject<BladeElementRefWithValue | null>;\n };\n\ntype UseTaggedInputReturn = {\n activeTagIndex: number;\n setActiveTagIndex: (activeTagIndex: number) => void;\n getTags: ({ size }: { size: NonNullable<BaseInputProps['size']> }) => React.ReactElement[];\n handleTaggedInputKeydown: (e: FormInputOnKeyDownEvent) => void;\n handleTaggedInputChange: FormInputOnEvent;\n handleTagsClear: () => void;\n};\n\nconst useTaggedInput = ({\n tags,\n isDisabled,\n onTagChange,\n isTaggedInput,\n inputRef,\n onChange,\n name,\n value,\n defaultValue,\n}: UseTaggedInputProps): UseTaggedInputReturn => {\n const [activeTagIndex, setActiveTagIndex] = React.useState(-1);\n const [inputValueUncontrolled, setInputValueUncontrolled] = React.useState(defaultValue ?? '');\n const [tagsValue, setTagsValue] = useControllableState({\n value: tags,\n defaultValue: [],\n onChange: (tags) => {\n onTagChange?.({ tags });\n },\n });\n\n const getNewTagsArray = (indexToRemove: number): string[] => {\n const currentTags = tagsValue;\n\n if (!currentTags) {\n return [];\n }\n\n // Check if the index is valid\n if (indexToRemove < 0 || indexToRemove >= currentTags.length) {\n return currentTags; // Return the original array\n }\n\n // Create a new array without the element at the specified index\n const newArray = currentTags\n .slice(0, indexToRemove)\n .concat(currentTags.slice(indexToRemove + 1));\n\n return newArray;\n };\n\n const getTags = React.useMemo(\n () => ({ size }: { size: NonNullable<BaseInputProps['size']> }): React.ReactElement[] => {\n return getTagsGroup({\n size,\n tags: tagsValue,\n activeTagIndex,\n isDisabled,\n onDismiss: ({ tagIndex }) => {\n setTagsValue(() => getNewTagsArray(tagIndex));\n },\n });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [activeTagIndex, tags, tagsValue, isDisabled],\n );\n\n const handleTaggedInputChange: FormInputOnEvent = ({ value }) => {\n if (!isTaggedInput) {\n return;\n }\n setInputValueUncontrolled(value ?? '');\n };\n\n const handleTagsClear = (): void => {\n if (!isTaggedInput) {\n return;\n }\n\n setTagsValue(() => []);\n };\n\n const clearInput = (): void => {\n const isControlledValue = value !== undefined;\n\n if (isControlledValue) {\n // In Controlled component, we don't clear input ourselves. We just call onChange with empty value\n onChange?.({ name, value: '' });\n return;\n }\n\n if (!inputRef.current) {\n return;\n }\n\n setInputValueUncontrolled('');\n\n if (isReactNative()) {\n setTimeout(() => {\n // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error\n // @ts-ignore: clear does exist in react native\n inputRef.current?.clear();\n }, 10);\n return;\n }\n\n inputRef.current.value = '';\n };\n\n const handleTaggedInputKeydown = (e: FormInputOnKeyDownEvent): void => {\n if (!isTaggedInput) {\n return;\n }\n\n const currentTags = tagsValue;\n const isControlledValue = value !== undefined;\n const inputValue = isControlledValue ? value?.trim() : inputValueUncontrolled.trim();\n if (e.key === 'Enter' || e.key === ',') {\n e.event.preventDefault?.(); // we don't want textarea to treat enter as line break in tagged inputs\n if (inputValue) {\n setTagsValue(() => [...currentTags, inputValue]);\n clearInput();\n setActiveTagIndex(-1);\n }\n }\n if (e.key === 'Backspace' && !inputValue && activeTagIndex < 0 && currentTags.length > 0) {\n setTagsValue(() => currentTags.slice(0, -1));\n }\n };\n\n return {\n activeTagIndex,\n setActiveTagIndex,\n getTags,\n handleTaggedInputKeydown,\n handleTaggedInputChange,\n handleTagsClear,\n };\n};\n\nexport type { TaggedInputProps };\nexport { useTaggedInput };\n"],"names":["useTaggedInput","_ref","tags","isDisabled","onTagChange","isTaggedInput","inputRef","onChange","name","value","defaultValue","_React$useState","React","useState","_React$useState2","_slicedToArray","activeTagIndex","setActiveTagIndex","_React$useState3","_React$useState4","inputValueUncontrolled","setInputValueUncontrolled","_useControllableState","useControllableState","_useControllableState2","tagsValue","setTagsValue","getNewTagsArray","indexToRemove","currentTags","length","newArray","slice","concat","getTags","useMemo","_ref2","size","getTagsGroup","onDismiss","_ref3","tagIndex","handleTaggedInputChange","_ref4","handleTagsClear","clearInput","isControlledValue","undefined","current","isReactNative","setTimeout","_inputRef$current","clear","handleTaggedInputKeydown","e","inputValue","trim","key","_e$event$preventDefau","_e$event","event","preventDefault","call","_toCons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AC;AAC3B,MAAA,IAAIJ,UAAU,EAAE;AACd7B,QAAAA,YAAY,CAAC,YAAA;AAAA,UAAA,OAAA,EAAA,CAAAO,MAAA,CAAA8B,kBAAA,CAAUlC,WAAW,IAAE0B,UAAU,CAAA,CAAA,CAAA;AAAA,SAAC,CAAC,CAAA;AAChDV,QAAAA,UAAU,EAAE,CAAA;QACZ5B,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAA;AACvB,OAAA;AACF,KAAA;AACA,IAAA,IAAIqC,CAAC,CAACG,GAAG,KAAK,WAAW,IAAI,CAACF,UAAU,IAAIvC,cAAc,GAAG,CAAC,IAAIa,WAAW,CAACC,MAAM,GAAG,CAAC,EAAE;AACxFJ,MAAAA,YAAY,CAAC,YAAA;QAAA,OAAMG,WAAW,CAACG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;OAAC,CAAA,CAAA;AAC9C,KAAA;GACD,CAAA;EAED,OAAO;AACLhB,IAAAA,cAAc,EAAdA,cAAc;AACdC,IAAAA,iBAAiB,EAAjBA,iBAAiB;AACjBiB,IAAAA,OAAO,EAAPA,OAAO;AACPmB,IAAAA,wBAAwB,EAAxBA,wBAAwB;AACxBX,IAAAA,uBAAuB,EAAvBA,uBAAuB;AACvBE,IAAAA,eAAe,EAAfA,eAAAA;GACD,CAAA;AACH;;;;"}
|
|
@@ -45,12 +45,12 @@ var InteractiveItemHeaderBox = /*#__PURE__*/styled.button.withConfig({
|
|
|
45
45
|
textDecoration: 'none',
|
|
46
46
|
border: 'none',
|
|
47
47
|
textAlign: 'inherit',
|
|
48
|
-
backgroundColor: props.
|
|
48
|
+
backgroundColor: props.theme.colors.transparent,
|
|
49
49
|
borderRadius: props.theme.border.radius.medium,
|
|
50
50
|
width: '100%',
|
|
51
51
|
transition: "background-color ".concat(props.theme.motion.duration.xquick, " ").concat(props.theme.motion.easing.standard),
|
|
52
52
|
':not([disabled]):hover': {
|
|
53
|
-
backgroundColor: props.isSelected ? props.theme.colors.interactive.background.primary.
|
|
53
|
+
backgroundColor: props.isSelected ? props.theme.colors.interactive.background.primary.faded : props.theme.colors.interactive.background.gray["default"]
|
|
54
54
|
},
|
|
55
55
|
':not([disabled]):focus-visible': _objectSpread({}, getFocusRingStyles({
|
|
56
56
|
theme: props.theme
|
|
@@ -79,6 +79,7 @@ var getStepTypeFromIndex = function getStepTypeFromIndex(_ref) {
|
|
|
79
79
|
return 'middle';
|
|
80
80
|
};
|
|
81
81
|
var _StepItem = function _StepItem(_ref2) {
|
|
82
|
+
var _marker$props;
|
|
82
83
|
var title = _ref2.title,
|
|
83
84
|
titleColor = _ref2.titleColor,
|
|
84
85
|
timestamp = _ref2.timestamp,
|
|
@@ -140,8 +141,8 @@ var _StepItem = function _StepItem(_ref2) {
|
|
|
140
141
|
children: [/*#__PURE__*/jsxs(Box, {
|
|
141
142
|
children: [/*#__PURE__*/jsx(Text, {
|
|
142
143
|
size: stepItemHeaderTokens[size$1].title,
|
|
143
|
-
color: isDisabled ? 'surface.text.gray.disabled' : titleColor !== null && titleColor !== void 0 ? titleColor : 'surface.text.gray.subtle',
|
|
144
|
-
weight: isNested ? 'regular' : '
|
|
144
|
+
color: isDisabled ? 'surface.text.gray.disabled' : isSelected ? 'surface.text.primary.normal' : titleColor !== null && titleColor !== void 0 ? titleColor : 'surface.text.gray.subtle',
|
|
145
|
+
weight: isNested ? 'regular' : 'medium',
|
|
145
146
|
children: title
|
|
146
147
|
}), /*#__PURE__*/jsx(Text, {
|
|
147
148
|
size: stepItemHeaderTokens[size$1].timestamp,
|
|
@@ -162,6 +163,9 @@ var _StepItem = function _StepItem(_ref2) {
|
|
|
162
163
|
paddingY: 'spacing.3',
|
|
163
164
|
paddingX: 'spacing.4'
|
|
164
165
|
};
|
|
166
|
+
var enhancedMarker = marker ? /*#__PURE__*/React__default.cloneElement(marker, {
|
|
167
|
+
isDisabled: isDisabled !== null && isDisabled !== void 0 ? isDisabled : marker === null || marker === void 0 ? void 0 : (_marker$props = marker.props) === null || _marker$props === void 0 ? void 0 : _marker$props.isDisabled
|
|
168
|
+
}) : undefined;
|
|
165
169
|
return /*#__PURE__*/jsxs(BaseBox, _objectSpread(_objectSpread(_objectSpread({
|
|
166
170
|
display: "flex",
|
|
167
171
|
flexDirection: isVertical ? 'row' : 'column',
|
|
@@ -181,7 +185,7 @@ var _StepItem = function _StepItem(_ref2) {
|
|
|
181
185
|
shouldShowStartBranch: !isFirstItem,
|
|
182
186
|
shouldShowEndBranch: !isLastItem,
|
|
183
187
|
stepType: stepType,
|
|
184
|
-
marker:
|
|
188
|
+
marker: enhancedMarker,
|
|
185
189
|
stepProgress: stepProgress
|
|
186
190
|
}), /*#__PURE__*/jsxs(Box, {
|
|
187
191
|
flex: "1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepItem.web.js","sources":["../../../../../../src/components/StepGroup/StepItem.web.tsx"],"sourcesContent":["import React from 'react';\nimport styled from 'styled-components';\nimport { StepLine } from './StepLine';\nimport type { StepLineProps } from './StepLine';\nimport { useStepGroup } from './StepGroupContext';\nimport type {\n InteractiveItemHeaderProps,\n StepGroupContextType,\n StepGroupProps,\n StepItemProps,\n} from './types';\nimport { componentIds } from './componentIds';\nimport { itemLineGap, stepItemHeaderTokens } from './tokens';\nimport { Box } from '~components/Box';\nimport { Text } from '~components/Typography';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport BaseBox from '~components/Box/BaseBox';\nimport { makeSize, makeSpace } from '~utils';\nimport { size as sizeTokens } from '~tokens/global';\nimport { getFocusRingStyles } from '~utils/getFocusRingStyles';\nimport getIn from '~utils/lodashButBetter/get';\nimport { throwBladeError } from '~utils/logger';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype GetStepTypeFromIndexProps = {\n _index: StepItemProps['_index'];\n _nestingLevel: StepGroupProps['_nestingLevel'];\n itemsCount: StepGroupContextType['itemsInGroupCount'];\n};\n\nconst InteractiveItemHeaderBox = styled.button<InteractiveItemHeaderProps>((props) => {\n return {\n padding: `${makeSpace(getIn(props.theme, props.paddingY))} ${makeSpace(\n getIn(props.theme, props.paddingX),\n )}`,\n cursor: 'pointer',\n display: 'inline-block',\n textDecoration: 'none',\n border: 'none',\n textAlign: 'inherit',\n backgroundColor: props.isSelected\n ? props.theme.colors.interactive.background.primary.faded\n : props.theme.colors.transparent,\n borderRadius: props.theme.border.radius.medium,\n width: '100%',\n transition: `background-color ${props.theme.motion.duration.xquick} ${props.theme.motion.easing.standard}`,\n ':not([disabled]):hover': {\n backgroundColor: props.isSelected\n ? props.theme.colors.interactive.background.primary.fadedHighlighted\n : props.theme.colors.interactive.background.gray.fadedHighlighted,\n },\n ':not([disabled]):focus-visible': {\n ...getFocusRingStyles({ theme: props.theme }),\n },\n '&[disabled]': {\n cursor: 'not-allowed',\n },\n };\n});\n\nconst getStepTypeFromIndex = ({\n _index,\n _nestingLevel,\n itemsCount,\n}: GetStepTypeFromIndexProps): StepLineProps['stepType'] => {\n if (_nestingLevel === 0) {\n return 'default';\n }\n\n if (itemsCount === 1) {\n return 'single-item';\n }\n\n if (_index === 0) {\n return 'start';\n }\n\n if (_index === itemsCount - 1) {\n return 'end';\n }\n\n return 'middle';\n};\n\nconst _StepItem = ({\n title,\n titleColor,\n timestamp,\n description,\n stepProgress = 'none',\n marker,\n trailing,\n isSelected,\n isDisabled,\n href,\n target,\n onClick,\n children,\n _index = 0,\n _totalIndex = 0,\n _nestingLevel = 0,\n ...rest\n}: StepItemProps): React.ReactElement => {\n const {\n itemsInGroupCount: itemsCount,\n totalItemsInParentGroupCount,\n orientation,\n size,\n } = useStepGroup();\n const stepType = React.useMemo(\n () => getStepTypeFromIndex({ _index, _nestingLevel, itemsCount }),\n [_index, _nestingLevel, itemsCount],\n );\n\n const itemRef = React.useRef<HTMLDivElement>(null);\n\n const isFirstItem = _totalIndex === 0;\n const isLastItem = _totalIndex === totalItemsInParentGroupCount - 1;\n const isInteractive = Boolean(href) || Boolean(onClick);\n const isVertical = orientation === 'vertical';\n const isNested = _nestingLevel > 0;\n\n if (__DEV__) {\n if (trailing && orientation === 'horizontal') {\n throwBladeError({\n message: 'trailing is not allowed in horizontal StepGroup',\n moduleName: 'StepItem',\n });\n }\n\n if (_nestingLevel >= 1 && orientation === 'horizontal') {\n throwBladeError({\n message: 'Nested StepGroup components are not allowed in horizontal orientation',\n moduleName: 'StepItem',\n });\n }\n }\n\n const stepItemHeaderJSX = (\n <Box display=\"flex\" flexDirection=\"row\" justifyContent=\"space-between\" gap=\"spacing.4\">\n <Box>\n <Text\n size={stepItemHeaderTokens[size].title}\n color={\n isDisabled ? 'surface.text.gray.disabled' : titleColor ?? 'surface.text.gray.subtle'\n }\n weight={isNested ? 'regular' : 'semibold'}\n >\n {title}\n </Text>\n <Text\n size={stepItemHeaderTokens[size].timestamp}\n marginY=\"spacing.2\"\n color={isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.muted'}\n variant=\"caption\"\n >\n {timestamp}\n </Text>\n <Text\n size={stepItemHeaderTokens[size].description}\n color={isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.muted'}\n >\n {description}\n </Text>\n </Box>\n {trailing ? <Box>{trailing}</Box> : null}\n </Box>\n );\n\n const stepItemHeaderPaddings: Omit<InteractiveItemHeaderProps, 'isSelected'> = {\n paddingY: 'spacing.3',\n paddingX: 'spacing.4',\n } as const;\n\n return (\n <BaseBox\n display=\"flex\"\n flexDirection={isVertical ? 'row' : 'column'}\n gap={itemLineGap[size]}\n className={`step-item step-index-${_index} step-nesting-level-${_nestingLevel}`}\n textAlign={isVertical ? 'left' : 'center'}\n alignItems={isVertical ? undefined : 'center'}\n minWidth={isVertical ? undefined : `min(${makeSize(sizeTokens['120'])}, 100%)`}\n width={isVertical ? '100%' : undefined}\n flex={isVertical ? undefined : '1'}\n marginX={isVertical ? 'spacing.4' : 'spacing.0'}\n {...metaAttribute({ name: MetaConstants.StepItem })}\n {...makeAnalyticsAttribute(rest)}\n ref={itemRef}\n >\n <StepLine\n shouldShowStartBranch={!isFirstItem}\n shouldShowEndBranch={!isLastItem}\n stepType={stepType}\n marker={marker}\n stepProgress={stepProgress}\n />\n <Box flex=\"1\" marginRight={isVertical ? undefined : undefined}>\n {isInteractive ? (\n <InteractiveItemHeaderBox\n {...stepItemHeaderPaddings}\n as={href ? 'a' : 'button'}\n href={href}\n target={target}\n isSelected={isSelected}\n onClick={onClick}\n disabled={isDisabled}\n >\n {stepItemHeaderJSX}\n </InteractiveItemHeaderBox>\n ) : (\n <Box {...stepItemHeaderPaddings}>{stepItemHeaderJSX}</Box>\n )}\n {children ? (\n <Box paddingX=\"spacing.4\" paddingBottom=\"spacing.3\">\n {children}\n </Box>\n ) : null}\n </Box>\n </BaseBox>\n );\n};\n\n/**\n * ## StepItem\n *\n * Component meant to be used inside the StepGroup parent component\n *\n * ### Usage\n *\n * ```jsx\n * <StepGroup orientation=\"vertical\" size=\"medium\">\n * <StepItem\n * title=\"Personal Details\"\n * timestamp=\"Thu 15th Oct'23 | 12:00pm\"\n * description=\"Fill your personal details here\"\n * marker={<StepItemIndicator color=\"negative\" />}\n * />\n * </StepGroup>\n * ```\n *\n * ---\n *\n * Checkout {@link https://blade.razorpay.com/?path=/docs/components-stepgroup--docs StepGroup Documentation}\n */\nconst StepItem = assignWithoutSideEffects(_StepItem, {\n componentId: componentIds.StepItem,\n displayName: componentIds.StepItem,\n});\n\nexport { StepLine, StepItem };\n"],"names":["InteractiveItemHeaderBox","styled","button","withConfig","displayName","componentId","props","padding","concat","makeSpace","getIn","theme","paddingY","paddingX","cursor","display","textDecoration","border","textAlign","backgroundColor","isSelected","colors","interactive","background","primary","faded","transparent","borderRadius","radius","medium","width","transition","motion","duration","xquick","easing","standard","fadedHighlighted","gray","_objectSpread","getFocusRingStyles","getStepTypeFromIndex","_ref","_index","_nestingLevel","itemsCount","_StepItem","_ref2","title","titleColor","timestamp","description","_ref2$stepProgress","stepProgress","marker","trailing","isDisabled","href","target","onClick","children","_ref2$_index","_ref2$_totalIndex","_totalIndex","_ref2$_nestingLevel","rest","_objectWithoutProperties","_excluded","_useStepGroup","useStepGroup","itemsInGroupCount","totalItemsInParentGroupCount","orientation","size","stepType","React","useMemo","itemRef","useRef","isFirstItem","isLastItem","isInteractive","Boolean","isVertical","isNested","throwBladeError","message","moduleName","stepItemHeaderJSX","_jsxs","Box","flexDirection","justifyContent","gap","_jsx","Text","stepItemHeaderTokens","color","weight","marginY","variant","stepItemHeaderPaddings","BaseBox","itemLineGap","className","alignItems","undefined","minWidth","makeSize","sizeTokens","flex","marginX","metaAttribute","name","MetaConstants","StepItem","makeAnalyticsAttribute","ref","StepLine","shouldShowStartBranch","shouldShowEndBranch","marginRight","as","disabled","paddingBottom","assignWithoutSideEffects","componentIds"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAMA,wBAAwB,gBAAGC,MAAM,CAACC,MAAM,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,uCAAA;EAAAC,WAAA,EAAA,UAAA;AAAA,CAA6B,CAAA,CAAA,UAACC,KAAK,EAAK;EACpF,OAAO;AACLC,IAAAA,OAAO,EAAAC,EAAAA,CAAAA,MAAA,CAAKC,SAAS,CAACC,KAAK,CAACJ,KAAK,CAACK,KAAK,EAAEL,KAAK,CAACM,QAAQ,CAAC,CAAC,EAAAJ,GAAAA,CAAAA,CAAAA,MAAA,CAAIC,SAAS,CACpEC,KAAK,CAACJ,KAAK,CAACK,KAAK,EAAEL,KAAK,CAACO,QAAQ,CACnC,CAAC,CAAE;AACHC,IAAAA,MAAM,EAAE,SAAS;AACjBC,IAAAA,OAAO,EAAE,cAAc;AACvBC,IAAAA,cAAc,EAAE,MAAM;AACtBC,IAAAA,MAAM,EAAE,MAAM;AACdC,IAAAA,SAAS,EAAE,SAAS;IACpBC,eAAe,EAAEb,KAAK,CAACc,UAAU,GAC7Bd,KAAK,CAACK,KAAK,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AC,WAAW;AAAAhE,QAAAA,QAAA,EAChDA,QAAAA;OACE,CAAC,GACJ,IAAI,CAAA;AAAA,KACL,CAAC,CAAA;AAAA,GAAA,CACC,CAAC,CAAA;AAEd,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMuD,QAAQ,gBAAGU,wBAAwB,CAAC/E,SAAS,EAAE;EACnDzC,WAAW,EAAEyH,YAAY,CAACX,QAAQ;EAClC/G,WAAW,EAAE0H,YAAY,CAACX,QAAAA;AAC5B,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"StepItem.web.js","sources":["../../../../../../src/components/StepGroup/StepItem.web.tsx"],"sourcesContent":["import React from 'react';\nimport styled from 'styled-components';\nimport { StepLine } from './StepLine';\nimport type { StepLineProps } from './StepLine';\nimport { useStepGroup } from './StepGroupContext';\nimport type {\n InteractiveItemHeaderProps,\n StepGroupContextType,\n StepGroupProps,\n StepItemProps,\n} from './types';\nimport { componentIds } from './componentIds';\nimport { itemLineGap, stepItemHeaderTokens } from './tokens';\nimport { Box } from '~components/Box';\nimport { Text } from '~components/Typography';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport BaseBox from '~components/Box/BaseBox';\nimport { makeSize, makeSpace } from '~utils';\nimport { size as sizeTokens } from '~tokens/global';\nimport { getFocusRingStyles } from '~utils/getFocusRingStyles';\nimport getIn from '~utils/lodashButBetter/get';\nimport { throwBladeError } from '~utils/logger';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype GetStepTypeFromIndexProps = {\n _index: StepItemProps['_index'];\n _nestingLevel: StepGroupProps['_nestingLevel'];\n itemsCount: StepGroupContextType['itemsInGroupCount'];\n};\n\nconst InteractiveItemHeaderBox = styled.button<InteractiveItemHeaderProps>((props) => {\n return {\n padding: `${makeSpace(getIn(props.theme, props.paddingY))} ${makeSpace(\n getIn(props.theme, props.paddingX),\n )}`,\n cursor: 'pointer',\n display: 'inline-block',\n textDecoration: 'none',\n border: 'none',\n textAlign: 'inherit',\n backgroundColor: props.theme.colors.transparent,\n borderRadius: props.theme.border.radius.medium,\n width: '100%',\n transition: `background-color ${props.theme.motion.duration.xquick} ${props.theme.motion.easing.standard}`,\n ':not([disabled]):hover': {\n backgroundColor: props.isSelected\n ? props.theme.colors.interactive.background.primary.faded\n : props.theme.colors.interactive.background.gray.default,\n },\n ':not([disabled]):focus-visible': {\n ...getFocusRingStyles({ theme: props.theme }),\n },\n '&[disabled]': {\n cursor: 'not-allowed',\n },\n };\n});\n\nconst getStepTypeFromIndex = ({\n _index,\n _nestingLevel,\n itemsCount,\n}: GetStepTypeFromIndexProps): StepLineProps['stepType'] => {\n if (_nestingLevel === 0) {\n return 'default';\n }\n\n if (itemsCount === 1) {\n return 'single-item';\n }\n\n if (_index === 0) {\n return 'start';\n }\n\n if (_index === itemsCount - 1) {\n return 'end';\n }\n\n return 'middle';\n};\n\nconst _StepItem = ({\n title,\n titleColor,\n timestamp,\n description,\n stepProgress = 'none',\n marker,\n trailing,\n isSelected,\n isDisabled,\n href,\n target,\n onClick,\n children,\n _index = 0,\n _totalIndex = 0,\n _nestingLevel = 0,\n ...rest\n}: StepItemProps): React.ReactElement => {\n const {\n itemsInGroupCount: itemsCount,\n totalItemsInParentGroupCount,\n orientation,\n size,\n } = useStepGroup();\n const stepType = React.useMemo(\n () => getStepTypeFromIndex({ _index, _nestingLevel, itemsCount }),\n [_index, _nestingLevel, itemsCount],\n );\n\n const itemRef = React.useRef<HTMLDivElement>(null);\n\n const isFirstItem = _totalIndex === 0;\n const isLastItem = _totalIndex === totalItemsInParentGroupCount - 1;\n const isInteractive = Boolean(href) || Boolean(onClick);\n const isVertical = orientation === 'vertical';\n const isNested = _nestingLevel > 0;\n\n if (__DEV__) {\n if (trailing && orientation === 'horizontal') {\n throwBladeError({\n message: 'trailing is not allowed in horizontal StepGroup',\n moduleName: 'StepItem',\n });\n }\n\n if (_nestingLevel >= 1 && orientation === 'horizontal') {\n throwBladeError({\n message: 'Nested StepGroup components are not allowed in horizontal orientation',\n moduleName: 'StepItem',\n });\n }\n }\n\n const stepItemHeaderJSX = (\n <Box display=\"flex\" flexDirection=\"row\" justifyContent=\"space-between\" gap=\"spacing.4\">\n <Box>\n <Text\n size={stepItemHeaderTokens[size].title}\n color={\n isDisabled\n ? 'surface.text.gray.disabled'\n : isSelected\n ? 'surface.text.primary.normal'\n : titleColor ?? 'surface.text.gray.subtle'\n }\n weight={isNested ? 'regular' : 'medium'}\n >\n {title}\n </Text>\n <Text\n size={stepItemHeaderTokens[size].timestamp}\n marginY=\"spacing.2\"\n color={isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.muted'}\n variant=\"caption\"\n >\n {timestamp}\n </Text>\n <Text\n size={stepItemHeaderTokens[size].description}\n color={isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.muted'}\n >\n {description}\n </Text>\n </Box>\n {trailing ? <Box>{trailing}</Box> : null}\n </Box>\n );\n\n const stepItemHeaderPaddings: Omit<InteractiveItemHeaderProps, 'isSelected'> = {\n paddingY: 'spacing.3',\n paddingX: 'spacing.4',\n } as const;\n\n const enhancedMarker = marker\n ? React.cloneElement(marker, {\n isDisabled: isDisabled ?? marker?.props?.isDisabled,\n })\n : undefined;\n\n return (\n <BaseBox\n display=\"flex\"\n flexDirection={isVertical ? 'row' : 'column'}\n gap={itemLineGap[size]}\n className={`step-item step-index-${_index} step-nesting-level-${_nestingLevel}`}\n textAlign={isVertical ? 'left' : 'center'}\n alignItems={isVertical ? undefined : 'center'}\n minWidth={isVertical ? undefined : `min(${makeSize(sizeTokens['120'])}, 100%)`}\n width={isVertical ? '100%' : undefined}\n flex={isVertical ? undefined : '1'}\n marginX={isVertical ? 'spacing.4' : 'spacing.0'}\n {...metaAttribute({ name: MetaConstants.StepItem })}\n {...makeAnalyticsAttribute(rest)}\n ref={itemRef}\n >\n <StepLine\n shouldShowStartBranch={!isFirstItem}\n shouldShowEndBranch={!isLastItem}\n stepType={stepType}\n marker={enhancedMarker}\n stepProgress={stepProgress}\n />\n <Box flex=\"1\" marginRight={isVertical ? undefined : undefined}>\n {isInteractive ? (\n <InteractiveItemHeaderBox\n {...stepItemHeaderPaddings}\n as={href ? 'a' : 'button'}\n href={href}\n target={target}\n isSelected={isSelected}\n onClick={onClick}\n disabled={isDisabled}\n >\n {stepItemHeaderJSX}\n </InteractiveItemHeaderBox>\n ) : (\n <Box {...stepItemHeaderPaddings}>{stepItemHeaderJSX}</Box>\n )}\n {children ? (\n <Box paddingX=\"spacing.4\" paddingBottom=\"spacing.3\">\n {children}\n </Box>\n ) : null}\n </Box>\n </BaseBox>\n );\n};\n\n/**\n * ## StepItem\n *\n * Component meant to be used inside the StepGroup parent component\n *\n * ### Usage\n *\n * ```jsx\n * <StepGroup orientation=\"vertical\" size=\"medium\">\n * <StepItem\n * title=\"Personal Details\"\n * timestamp=\"Thu 15th Oct'23 | 12:00pm\"\n * description=\"Fill your personal details here\"\n * marker={<StepItemIndicator color=\"negative\" />}\n * />\n * </StepGroup>\n * ```\n *\n * ---\n *\n * Checkout {@link https://blade.razorpay.com/?path=/docs/components-stepgroup--docs StepGroup Documentation}\n */\nconst StepItem = assignWithoutSideEffects(_StepItem, {\n componentId: componentIds.StepItem,\n displayName: componentIds.StepItem,\n});\n\nexport { StepLine, StepItem };\n"],"names":["InteractiveItemHeaderBox","styled","button","withConfig","displayName","componentId","props","padding","concat","makeSpace","getIn","theme","paddingY","paddingX","cursor","display","textDecoration","border","textAlign","backgroundColor","colors","transparent","borderRadius","radius","medium","width","transition","motion","duration","xquick","easing","standard","isSelected","interactive","background","primary","faded","gray","_objectSpread","getFocusRingStyles","getStepTypeFromIndex","_ref","_index","_nestingLevel","itemsCount","_StepItem","_ref2","_marker$props","title","titleColor","timestamp","description","_ref2$stepProgress","stepProgress","marker","trailing","isDisabled","href","target","onClick","children","_ref2$_index","_ref2$_totalIndex","_totalIndex","_ref2$_nestingLevel","rest","_objectWithoutProperties","_excluded","_useStepGroup","useStepGroup","itemsInGroupCount","totalItemsInParentGroupCount","orientation","size","stepType","React","useMemo","itemRef","useRef","isFirstItem","isLastItem","isInteractive","Boolean","isVertical","isNested","throwBladeError","message","moduleName","stepItemHeaderJSX","_jsxs","Box","flexDirection","justifyContent","gap","_jsx","Text","stepItemHeaderTokens","color","weight","marginY","variant","stepItemHeaderPaddings","enhancedMarker","cloneElement","undefined","BaseBox","itemLineGap","className","alignItems","minWidth","makeSize","sizeTokens","flex","marginX","metaAttribute","name","MetaConstants","StepItem","makeAnalyticsAttribute","ref","StepLine","shouldShowStartBranch","shouldShowEndBranch","marginRight","as","disabled","paddingBottom","assignWithoutSideEffects","componentIds"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAMA,wBAAwB,gBAAGC,MAAM,CAACC,MAAM,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,uCAAA;EAAAC,WAAA,EAAA,UAAA;AAAA,CAA6B,CAAA,CAAA,UAACC,KAAK,EAAK;EACpF,OAAO;AACLC,IAAAA,OAAO,EAAAC,EAAAA,CAAAA,MAAA,CAAKC,SAAS,CAACC,KAAK,CAACJ,KAAK,CAACK,KAAK,EAAEL,KAAK,CAACM,QAAQ,CAAC,CAAC,EAAAJ,GAAAA,CAAAA,CAAAA,MAAA,CAAIC,SAAS,CACpEC,KAAK,CAACJ,KAAK,CAACK,KAAK,EAAEL,KAAK,CAACO,QAAQ,CACnC,CAAC,CAAE;AACHC,IAAAA,MAAM,EAAE,SAAS;AACjBC,IAAAA,OAAO,EAAE,cAAc;AACvBC,IAAAA,cAAc,EAAE,MAAM;AACtBC,IAAAA,MAAM,EAAE,MAAM;AACdC,IAAAA,SAAS,EAAE,SAAS;AACpBC,IAAAA,eAAe,EAAEb,KAAK,CAACK,KAAK,CAACS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AI,QAAAA,QAAA,EAEpB4B,iBAAAA;OACuB,CAAA,CAAC,gBAE3BM,GAAA,CAACJ,GAAG,EAAApD,aAAA,CAAAA,aAAA,CAAA,EAAA,EAAK+D,sBAAsB,CAAA,EAAA,EAAA,EAAA;AAAAzC,QAAAA,QAAA,EAAG4B,iBAAAA;AAAiB,OAAA,CAAM,CAC1D,EACA5B,QAAQ,gBACPkC,GAAA,CAACJ,GAAG,EAAA;AAAC7E,QAAAA,QAAQ,EAAC,WAAW;AAACiH,QAAAA,aAAa,EAAC,WAAW;AAAAlE,QAAAA,QAAA,EAChDA,QAAAA;OACE,CAAC,GACJ,IAAI,CAAA;AAAA,KACL,CAAC,CAAA;AAAA,GAAA,CACC,CAAC,CAAA;AAEd,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMyD,QAAQ,gBAAGU,wBAAwB,CAAClF,SAAS,EAAE;EACnDxC,WAAW,EAAE2H,YAAY,CAACX,QAAQ;EAClCjH,WAAW,EAAE4H,YAAY,CAACX,QAAAA;AAC5B,CAAC;;;;"}
|
|
@@ -45,7 +45,9 @@ var StepItemIndicator = function StepItemIndicator(_ref2) {
|
|
|
45
45
|
var StepItemIcon = function StepItemIcon(_ref3) {
|
|
46
46
|
var Icon = _ref3.icon,
|
|
47
47
|
_ref3$color = _ref3.color,
|
|
48
|
-
color = _ref3$color === void 0 ? 'neutral' : _ref3$color
|
|
48
|
+
color = _ref3$color === void 0 ? 'neutral' : _ref3$color,
|
|
49
|
+
_ref3$isDisabled = _ref3.isDisabled,
|
|
50
|
+
isDisabled = _ref3$isDisabled === void 0 ? false : _ref3$isDisabled;
|
|
49
51
|
var _useStepGroup2 = useStepGroup(),
|
|
50
52
|
size = _useStepGroup2.size;
|
|
51
53
|
var spacingTokens = getMarkerLineSpacings(size);
|
|
@@ -55,7 +57,7 @@ var StepItemIcon = function StepItemIcon(_ref3) {
|
|
|
55
57
|
margin: makeSize(spacingTokens.markerMargin),
|
|
56
58
|
children: /*#__PURE__*/jsx(Icon, {
|
|
57
59
|
size: iconSizeTokens[size],
|
|
58
|
-
color: color === 'primary' ? 'surface.icon.primary.normal' : "feedback.icon.".concat(color, ".intense")
|
|
60
|
+
color: isDisabled ? 'surface.icon.gray.disabled' : color === 'primary' ? 'surface.icon.primary.normal' : "feedback.icon.".concat(color, ".intense")
|
|
59
61
|
})
|
|
60
62
|
});
|
|
61
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepItemMarker.js","sources":["../../../../../../src/components/StepGroup/StepItemMarker.tsx"],"sourcesContent":["import { useStepGroup } from './StepGroupContext';\nimport { getMarkerLineSpacings, iconSizeTokens } from './tokens';\nimport type { BaseBoxProps } from '~components/Box/BaseBox';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { IconComponent } from '~components/Icons';\nimport type { IndicatorProps } from '~components/Indicator';\nimport { Indicator } from '~components/Indicator';\nimport { makeSize } from '~utils';\n\ntype MarkerBackgroundCircleProps = {\n color: IndicatorProps['color'];\n size: BaseBoxProps['width'];\n margin: BaseBoxProps['margin'];\n children: BaseBoxProps['children'];\n};\n\nconst MarkerBackgroundCircle = ({\n color,\n size,\n margin,\n children,\n}: MarkerBackgroundCircleProps): React.ReactElement => {\n return (\n <BaseBox\n backgroundColor={\n color === 'primary'\n ? 'surface.background.primary.subtle'\n : `feedback.background.${color}.subtle`\n }\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n height={size}\n width={size}\n borderRadius=\"round\"\n margin={margin}\n >\n {children}\n </BaseBox>\n );\n};\n\nconst StepItemIndicator = ({ color }: { color: IndicatorProps['color'] }): React.ReactElement => {\n const { size } = useStepGroup();\n const spacingTokens = getMarkerLineSpacings(size);\n\n return (\n <MarkerBackgroundCircle\n color={color}\n size={makeSize(spacingTokens.markerBackgroundSize)}\n margin={makeSize(spacingTokens.markerMargin)}\n >\n <Indicator\n position=\"relative\"\n color={color}\n size={size}\n accessibilityLabel={`${color} indicator`}\n />\n </MarkerBackgroundCircle>\n );\n};\n\ntype StepItemIconProps = {\n icon: IconComponent;\n color: IndicatorProps['color'];\n};\n\nconst StepItemIcon = ({
|
|
1
|
+
{"version":3,"file":"StepItemMarker.js","sources":["../../../../../../src/components/StepGroup/StepItemMarker.tsx"],"sourcesContent":["import { useStepGroup } from './StepGroupContext';\nimport { getMarkerLineSpacings, iconSizeTokens } from './tokens';\nimport type { BaseBoxProps } from '~components/Box/BaseBox';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { IconComponent } from '~components/Icons';\nimport type { IndicatorProps } from '~components/Indicator';\nimport { Indicator } from '~components/Indicator';\nimport { makeSize } from '~utils';\n\ntype MarkerBackgroundCircleProps = {\n color: IndicatorProps['color'];\n size: BaseBoxProps['width'];\n margin: BaseBoxProps['margin'];\n children: BaseBoxProps['children'];\n};\n\nconst MarkerBackgroundCircle = ({\n color,\n size,\n margin,\n children,\n}: MarkerBackgroundCircleProps): React.ReactElement => {\n return (\n <BaseBox\n backgroundColor={\n color === 'primary'\n ? 'surface.background.primary.subtle'\n : `feedback.background.${color}.subtle`\n }\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n height={size}\n width={size}\n borderRadius=\"round\"\n margin={margin}\n >\n {children}\n </BaseBox>\n );\n};\n\nconst StepItemIndicator = ({ color }: { color: IndicatorProps['color'] }): React.ReactElement => {\n const { size } = useStepGroup();\n const spacingTokens = getMarkerLineSpacings(size);\n\n return (\n <MarkerBackgroundCircle\n color={color}\n size={makeSize(spacingTokens.markerBackgroundSize)}\n margin={makeSize(spacingTokens.markerMargin)}\n >\n <Indicator\n position=\"relative\"\n color={color}\n size={size}\n accessibilityLabel={`${color} indicator`}\n />\n </MarkerBackgroundCircle>\n );\n};\n\ntype StepItemIconProps = {\n icon: IconComponent;\n color: IndicatorProps['color'];\n isDisabled?: boolean;\n};\n\nconst StepItemIcon = ({\n icon: Icon,\n color = 'neutral',\n isDisabled = false,\n}: StepItemIconProps): React.ReactElement => {\n const { size } = useStepGroup();\n const spacingTokens = getMarkerLineSpacings(size);\n\n return (\n <MarkerBackgroundCircle\n color={color}\n size={makeSize(spacingTokens.markerBackgroundSize)}\n margin={makeSize(spacingTokens.markerMargin)}\n >\n <Icon\n size={iconSizeTokens[size]}\n color={\n isDisabled\n ? 'surface.icon.gray.disabled'\n : color === 'primary'\n ? 'surface.icon.primary.normal'\n : `feedback.icon.${color}.intense`\n }\n />\n </MarkerBackgroundCircle>\n );\n};\n\nexport { StepItemIndicator, StepItemIcon };\n"],"names":["MarkerBackgroundCircle","_ref","color","size","margin","children","_jsx","BaseBox","backgroundColor","concat","display","alignItems","justifyContent","height","width","borderRadius","StepItemIndicator","_ref2","_useStepGroup","useStepGroup","spacingTokens","getMarkerLineSpacings","makeSize","markerBackgroundSize","markerMargin","Indicator","position","accessibilityLabel","StepItemIcon","_ref3","Icon","icon","_ref3$color","_ref3$isDisabled","isDisabled","_useStepGroup2","iconSizeTokens"],"mappings":";;;;;;;;;;AAgBA,IAAMA,sBAAsB,GAAG,SAAzBA,sBAAsBA,CAAAC,IAAA,EAK2B;AAAA,EAAA,IAJrDC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IACJC,MAAM,GAAAH,IAAA,CAANG,MAAM;IACNC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ,CAAA;EAER,oBACEC,GAAA,CAACC,OAAO,EAAA;IACNC,eAAe,EACbN,KAAK,KAAK,SAAS,GACf,mCAAmC,GAAAO,sBAAAA,CAAAA,MAAA,CACZP,KAAK,EACjC,SAAA,CAAA;AACDQ,IAAAA,OAAO,EAAC,MAAM;AACdC,IAAAA,UAAU,EAAC,QAAQ;AACnBC,IAAAA,cAAc,EAAC,QAAQ;AACvBC,IAAAA,MAAM,EAAEV,IAAK;AACbW,IAAAA,KAAK,EAAEX,IA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