@razorpay/blade 11.14.0 → 11.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/native/components/Amount/Amount.js.map +1 -1
- package/build/lib/native/components/Box/BaseBox/baseBoxStyles.js +1 -1
- package/build/lib/native/components/Box/BaseBox/baseBoxStyles.js.map +1 -1
- package/build/lib/native/components/Box/BaseBox/types/propsTypes.js.map +1 -1
- package/build/lib/native/components/Box/Box.js +1 -1
- package/build/lib/native/components/Box/Box.js.map +1 -1
- package/build/lib/native/components/Box/styledProps/getStyledProps.js +1 -1
- package/build/lib/native/components/Box/styledProps/getStyledProps.js.map +1 -1
- package/build/lib/native/components/Indicator/Indicator.js +1 -1
- package/build/lib/native/components/Indicator/Indicator.js.map +1 -1
- package/build/lib/native/components/StepGroup/StepGroup.native.js +17 -0
- package/build/lib/native/components/StepGroup/StepGroup.native.js.map +1 -0
- package/build/lib/native/components/StepGroup/StepGroupContext.js +6 -0
- package/build/lib/native/components/StepGroup/StepGroupContext.js.map +1 -0
- package/build/lib/native/components/StepGroup/StepItem.native.js +17 -0
- package/build/lib/native/components/StepGroup/StepItem.native.js.map +1 -0
- package/build/lib/native/components/StepGroup/StepItemMarker.js +15 -0
- package/build/lib/native/components/StepGroup/StepItemMarker.js.map +1 -0
- package/build/lib/native/components/StepGroup/tokens.js +8 -0
- package/build/lib/native/components/StepGroup/tokens.js.map +1 -0
- package/build/lib/native/components/index.js +3 -0
- package/build/lib/native/components/index.js.map +1 -1
- package/build/lib/native/tokens/global/size.js +1 -1
- package/build/lib/native/tokens/global/size.js.map +1 -1
- package/build/lib/native/utils/metaAttribute/metaConstants.js +1 -1
- package/build/lib/native/utils/metaAttribute/metaConstants.js.map +1 -1
- package/build/lib/web/development/components/Amount/Amount.js +7 -2
- package/build/lib/web/development/components/Amount/Amount.js.map +1 -1
- package/build/lib/web/development/components/Box/BaseBox/baseBoxStyles.js +17 -5
- package/build/lib/web/development/components/Box/BaseBox/baseBoxStyles.js.map +1 -1
- package/build/lib/web/development/components/Box/BaseBox/types/propsTypes.js.map +1 -1
- package/build/lib/web/development/components/Box/Box.js +5 -0
- package/build/lib/web/development/components/Box/Box.js.map +1 -1
- package/build/lib/web/development/components/Box/styledProps/getStyledProps.js +2 -1
- package/build/lib/web/development/components/Box/styledProps/getStyledProps.js.map +1 -1
- package/build/lib/web/development/components/Indicator/Indicator.js +1 -1
- package/build/lib/web/development/components/Indicator/Indicator.js.map +1 -1
- package/build/lib/web/development/components/StepGroup/StepGroup.web.js +138 -0
- package/build/lib/web/development/components/StepGroup/StepGroup.web.js.map +1 -0
- package/build/lib/web/development/components/StepGroup/StepGroupContext.js +15 -0
- package/build/lib/web/development/components/StepGroup/StepGroupContext.js.map +1 -0
- package/build/lib/web/development/components/StepGroup/StepItem.web.js +224 -0
- package/build/lib/web/development/components/StepGroup/StepItem.web.js.map +1 -0
- package/build/lib/web/development/components/StepGroup/StepItemMarker.js +65 -0
- package/build/lib/web/development/components/StepGroup/StepItemMarker.js.map +1 -0
- package/build/lib/web/development/components/StepGroup/StepLine.web.js +336 -0
- package/build/lib/web/development/components/StepGroup/StepLine.web.js.map +1 -0
- package/build/lib/web/development/components/StepGroup/componentIds.js +7 -0
- package/build/lib/web/development/components/StepGroup/componentIds.js.map +1 -0
- package/build/lib/web/development/components/StepGroup/index.js +4 -0
- package/build/lib/web/development/components/StepGroup/index.js.map +1 -0
- package/build/lib/web/development/components/StepGroup/tokens.js +62 -0
- package/build/lib/web/development/components/StepGroup/tokens.js.map +1 -0
- package/build/lib/web/development/components/Tabs/TabItem.web.js +1 -0
- package/build/lib/web/development/components/Tabs/TabItem.web.js.map +1 -1
- package/build/lib/web/development/components/index.js +4 -0
- package/build/lib/web/development/components/index.js.map +1 -1
- package/build/lib/web/development/tokens/global/size.js +4 -0
- package/build/lib/web/development/tokens/global/size.js.map +1 -1
- package/build/lib/web/development/utils/metaAttribute/metaConstants.js +3 -1
- package/build/lib/web/development/utils/metaAttribute/metaConstants.js.map +1 -1
- package/build/lib/web/development/utils/omitPropsFromHTML/index.js +1 -1
- package/build/lib/web/development/utils/omitPropsFromHTML/index.js.map +1 -1
- package/build/lib/web/production/components/Amount/Amount.js +7 -2
- package/build/lib/web/production/components/Amount/Amount.js.map +1 -1
- package/build/lib/web/production/components/Box/BaseBox/baseBoxStyles.js +17 -5
- package/build/lib/web/production/components/Box/BaseBox/baseBoxStyles.js.map +1 -1
- package/build/lib/web/production/components/Box/BaseBox/types/propsTypes.js.map +1 -1
- package/build/lib/web/production/components/Box/Box.js +5 -0
- package/build/lib/web/production/components/Box/Box.js.map +1 -1
- package/build/lib/web/production/components/Box/styledProps/getStyledProps.js +2 -1
- package/build/lib/web/production/components/Box/styledProps/getStyledProps.js.map +1 -1
- package/build/lib/web/production/components/Indicator/Indicator.js +1 -1
- package/build/lib/web/production/components/Indicator/Indicator.js.map +1 -1
- package/build/lib/web/production/components/StepGroup/StepGroup.web.js +138 -0
- package/build/lib/web/production/components/StepGroup/StepGroup.web.js.map +1 -0
- package/build/lib/web/production/components/StepGroup/StepGroupContext.js +15 -0
- package/build/lib/web/production/components/StepGroup/StepGroupContext.js.map +1 -0
- package/build/lib/web/production/components/StepGroup/StepItem.web.js +224 -0
- package/build/lib/web/production/components/StepGroup/StepItem.web.js.map +1 -0
- package/build/lib/web/production/components/StepGroup/StepItemMarker.js +65 -0
- package/build/lib/web/production/components/StepGroup/StepItemMarker.js.map +1 -0
- package/build/lib/web/production/components/StepGroup/StepLine.web.js +336 -0
- package/build/lib/web/production/components/StepGroup/StepLine.web.js.map +1 -0
- package/build/lib/web/production/components/StepGroup/componentIds.js +7 -0
- package/build/lib/web/production/components/StepGroup/componentIds.js.map +1 -0
- package/build/lib/web/production/components/StepGroup/index.js +4 -0
- package/build/lib/web/production/components/StepGroup/index.js.map +1 -0
- package/build/lib/web/production/components/StepGroup/tokens.js +62 -0
- package/build/lib/web/production/components/StepGroup/tokens.js.map +1 -0
- package/build/lib/web/production/components/Tabs/TabItem.web.js +1 -0
- package/build/lib/web/production/components/Tabs/TabItem.web.js.map +1 -1
- package/build/lib/web/production/components/index.js +4 -0
- package/build/lib/web/production/components/index.js.map +1 -1
- package/build/lib/web/production/tokens/global/size.js +4 -0
- package/build/lib/web/production/tokens/global/size.js.map +1 -1
- package/build/lib/web/production/utils/metaAttribute/metaConstants.js +3 -1
- package/build/lib/web/production/utils/metaAttribute/metaConstants.js.map +1 -1
- package/build/lib/web/production/utils/omitPropsFromHTML/index.js +1 -1
- package/build/lib/web/production/utils/omitPropsFromHTML/index.js.map +1 -1
- package/build/types/components/index.d.ts +1905 -81
- package/build/types/components/index.native.d.ts +944 -94
- package/build/types/tokens/index.d.ts +4 -0
- package/build/types/tokens/index.native.d.ts +4 -0
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Box.js","sources":["../../../../../../src/components/Box/Box.tsx"],"sourcesContent":["import React from 'react';\nimport BaseBox from './BaseBox';\nimport type { BoxProps, BoxRefType, MakeValueResponsive } from './BaseBox/types';\nimport { validBoxAsValues } from './BaseBox/types/propsTypes';\nimport type { KeysRequired } from '~utils/types';\nimport { isReactNative } from '~utils';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { throwBladeError } from '~utils/logger';\n\nconst validateBackgroundString = (stringBackgroundColorValue: string): void => {\n if (__DEV__) {\n if (\n !stringBackgroundColorValue.startsWith('surface.background') &&\n !stringBackgroundColorValue.startsWith('brand.') &&\n stringBackgroundColorValue !== 'transparent'\n ) {\n throwBladeError({\n message: `Oops! Currently you can only use \\`transparent\\`, \\`surface.background.*\\`, and \\`brand.*\\` tokens with backgroundColor property but we received \\`${stringBackgroundColorValue}\\` instead.\\n\\n Do you have a usecase of using other values? Create an issue on https://github.com/razorpay/blade repo to let us know and we can discuss ✨`,\n moduleName: 'Box',\n });\n }\n }\n};\n\nconst validateBackgroundProp = (\n responsiveBackgroundColor: MakeValueResponsive<string | undefined>,\n): void => {\n if (__DEV__) {\n if (responsiveBackgroundColor) {\n if (typeof responsiveBackgroundColor === 'string') {\n validateBackgroundString(responsiveBackgroundColor);\n return;\n }\n\n Object.values(responsiveBackgroundColor).forEach((backgroundColor) => {\n if (typeof backgroundColor === 'string') {\n validateBackgroundString(backgroundColor);\n }\n });\n }\n }\n};\n\n/**\n * This function is to filter out any unexpected props passed by the user\n */\nconst makeBoxProps = (\n props: BoxProps,\n): KeysRequired<Omit<BoxProps, 'testID' | 'id' | '__brand__'>> => {\n return {\n // Layout\n display: props.display,\n overflow: props.overflow,\n overflowX: props.overflowX,\n overflowY: props.overflowY,\n whiteSpace: props.whiteSpace,\n height: props.height,\n minHeight: props.minHeight,\n maxHeight: props.maxHeight,\n width: props.width,\n minWidth: props.minWidth,\n maxWidth: props.maxWidth,\n textAlign: props.textAlign,\n\n // Flex\n flex: props.flex,\n flexWrap: props.flexWrap,\n flexDirection: props.flexDirection,\n flexGrow: props.flexGrow,\n flexShrink: props.flexShrink,\n flexBasis: props.flexBasis,\n alignItems: props.alignItems,\n alignContent: props.alignContent,\n alignSelf: props.alignSelf,\n justifyItems: props.justifyItems,\n justifyContent: props.justifyContent,\n justifySelf: props.justifySelf,\n placeSelf: props.placeSelf,\n placeItems: props.placeItems,\n order: props.order,\n\n // Grid\n grid: props.grid,\n gridColumn: props.gridColumn,\n gridRow: props.gridRow,\n gridRowStart: props.gridRowStart,\n gridRowEnd: props.gridRowEnd,\n gridColumnStart: props.gridColumnStart,\n gridColumnEnd: props.gridColumnEnd,\n gridArea: props.gridArea,\n gridAutoFlow: props.gridAutoFlow,\n gridAutoRows: props.gridAutoRows,\n gridAutoColumns: props.gridAutoColumns,\n gridTemplate: props.gridTemplate,\n gridTemplateAreas: props.gridTemplateAreas,\n gridTemplateColumns: props.gridTemplateColumns,\n gridTemplateRows: props.gridTemplateRows,\n\n // Spacing\n padding: props.padding,\n paddingTop: props.paddingTop,\n paddingBottom: props.paddingBottom,\n paddingRight: props.paddingRight,\n paddingLeft: props.paddingLeft,\n paddingX: props.paddingX,\n paddingY: props.paddingY,\n margin: props.margin,\n marginBottom: props.marginBottom,\n marginTop: props.marginTop,\n marginRight: props.marginRight,\n marginLeft: props.marginLeft,\n marginX: props.marginX,\n marginY: props.marginY,\n gap: props.gap,\n rowGap: props.rowGap,\n columnGap: props.columnGap,\n\n // Position\n position: props.position,\n zIndex: props.zIndex,\n top: props.top,\n right: props.right,\n bottom: props.bottom,\n left: props.left,\n\n // Visual\n backgroundColor: props.backgroundColor,\n backgroundImage: props.backgroundImage,\n backgroundSize: props.backgroundSize,\n backgroundPosition: props.backgroundPosition,\n backgroundOrigin: props.backgroundOrigin,\n backgroundRepeat: props.backgroundRepeat,\n elevation: props.elevation,\n opacity: props.opacity,\n visibility: props.visibility,\n\n // Border\n borderWidth: props.borderWidth,\n borderColor: props.borderColor,\n borderTopWidth: props.borderTopWidth,\n borderTopColor: props.borderTopColor,\n borderRightWidth: props.borderRightWidth,\n borderRightColor: props.borderRightColor,\n borderBottomWidth: props.borderBottomWidth,\n borderBottomColor: props.borderBottomColor,\n borderLeftWidth: props.borderLeftWidth,\n borderLeftColor: props.borderLeftColor,\n borderRadius: props.borderRadius,\n borderTopLeftRadius: props.borderTopLeftRadius,\n borderTopRightRadius: props.borderTopRightRadius,\n borderBottomRightRadius: props.borderBottomRightRadius,\n borderBottomLeftRadius: props.borderBottomLeftRadius,\n\n // Polygon Support\n transform: props.transform,\n transformOrigin: props.transformOrigin,\n clipPath: props.clipPath,\n\n // callbacks\n onMouseEnter: props.onMouseEnter,\n onMouseLeave: props.onMouseLeave,\n onMouseOver: props.onMouseOver,\n onScroll: props.onScroll,\n\n // Drag and Drop\n draggable: props.draggable,\n onDragStart: props.onDragStart,\n onDragEnd: props.onDragEnd,\n onDragEnter: props.onDragEnter,\n onDragLeave: props.onDragLeave,\n onDragOver: props.onDragOver,\n onDrop: props.onDrop,\n\n pointerEvents: props.pointerEvents,\n children: props.children,\n tabIndex: props.tabIndex,\n as: isReactNative() ? undefined : props.as, // as is not supported on react-native\n };\n};\n\n/**\n * ## Box\n * \n * Box is the basic Layout component.\n *\n *\n * Box components supports most spacing CSS properties like `display`, `padding*`, `flex*`, `height`, `width`, etc.\n *\n * Check out {@linkcode BoxProps BoxPropsType} for complete list of props and [Layout RFC](https://github.com/razorpay/blade/blob/master/rfcs/2023-01-06-layout.md) for more details on API decision.\n * \n * ----\n * \n * ### Usage\n * \n * ```jsx\n * <Box display=\"flex\">\n * ```\n\n * #### Responsive Props\n *\n * ```jsx\n * <Box padding={{ base: 'spacing.3', m: 'spacing.10' }} />\n * ```\n * \n * #### Margin and Padding Shorthands\n * \n * ```jsx\n * <Box padding={[\"spacing.3\", \"spacing.10\"]} />\n * ```\n *\n * ---\n * \n * Checkout {@link https://blade.razorpay.com/?path=/docs/components-box Box Documentation}\n * \n */\nconst _Box: React.ForwardRefRenderFunction<BoxRefType, BoxProps> = (props, ref) => {\n React.useEffect(() => {\n if (__DEV__) {\n validateBackgroundProp(props.backgroundColor);\n }\n }, [props.backgroundColor]);\n\n React.useEffect(() => {\n if (__DEV__) {\n if (props.as) {\n if (isReactNative()) {\n throwBladeError({\n message: '`as` prop is not supported on React Native',\n moduleName: 'Box',\n });\n }\n\n if (!validBoxAsValues.includes(props.as)) {\n throwBladeError({\n message: `Invalid \\`as\\` prop value - ${props.as}. Only ${validBoxAsValues.join(\n ', ',\n )} are valid values`,\n moduleName: 'Box',\n });\n }\n }\n }\n }, [props.as]);\n\n return (\n <BaseBox\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n id={props.id}\n {...metaAttribute({ name: MetaConstants.Box, testID: props.testID })}\n {...makeBoxProps(props)}\n />\n );\n};\n\nconst Box = assignWithoutSideEffects(React.forwardRef(_Box), {\n displayName: 'Box',\n componentId: 'Box',\n});\n\nexport { Box, makeBoxProps };\n"],"names":["validateBackgroundString","stringBackgroundColorValue","startsWith","throwBladeError","message","concat","moduleName","validateBackgroundProp","responsiveBackgroundColor","Object","values","forEach","backgroundColor","makeBoxProps","props","display","overflow","overflowX","overflowY","whiteSpace","height","minHeight","maxHeight","width","minWidth","maxWidth","textAlign","flex","flexWrap","flexDirection","flexGrow","flexShrink","flexBasis","alignItems","alignContent","alignSelf","justifyItems","justifyContent","justifySelf","placeSelf","placeItems","order","grid","gridColumn","gridRow","gridRowStart","gridRowEnd","gridColumnStart","gridColumnEnd","gridArea","gridAutoFlow","gridAutoRows","gridAutoColumns","gridTemplate","gridTemplateAreas","gridTemplateColumns","gridTemplateRows","padding","paddingTop","paddingBottom","paddingRight","paddingLeft","paddingX","paddingY","margin","marginBottom","marginTop","marginRight","marginLeft","marginX","marginY","gap","rowGap","columnGap","position","zIndex","top","right","bottom","left","backgroundImage","backgroundSize","backgroundPosition","backgroundOrigin","backgroundRepeat","elevation","opacity","visibility","borderWidth","borderColor","borderTopWidth","borderTopColor","borderRightWidth","borderRightColor","borderBottomWidth","borderBottomColor","borderLeftWidth","borderLeftColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","transform","transformOrigin","clipPath","onMouseEnter","onMouseLeave","onMouseOver","onScroll","draggable","onDragStart","onDragEnd","onDragEnter","onDragLeave","onDragOver","onDrop","pointerEvents","children","tabIndex","as","isReactNative","undefined","_Box","ref","React","useEffect","validBoxAsValues","includes","join","_jsx","BaseBox","_objectSpread","id","metaAttribute","name","MetaConstants","Box","testID","assignWithoutSideEffects","forwardRef","displayName","componentId"],"mappings":";;;;;;;;;;;;;;;;;;AAUA,IAAMA,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAAIC,0BAAkC,EAAW;AAC7E,EAAA,IAAI,KAAO,EAAE;AACX,IAAA,IACE,CAACA,0BAA0B,CAACC,UAAU,CAAC,oBAAoB,CAAC,IAC5D,CAACD,0BAA0B,CAACC,UAAU,CAAC,QAAQ,CAAC,IAChDD,0BAA0B,KAAK,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AACC,QAAQ,CAAClH,KAAK,CAAC0G,EAAE,CAAC,EAAE;AACxCrH,UAAAA,eAAe,CAAC;AACdC,YAAAA,OAAO,EAAAC,4BAAAA,CAAAA,MAAA,CAAiCS,KAAK,CAAC0G,EAAE,EAAA,SAAA,CAAA,CAAAnH,MAAA,CAAU0H,gBAAgB,CAACE,IAAI,CAC7E,IACF,CAAC,EAAmB,mBAAA,CAAA;AACpB3H,YAAAA,UAAU,EAAE,KAAA;AACd,WAAC,CAAC,CAAA;AACJ,SAAA;AACF,OAAA;AACF,KAAA;AACF,GAAC,EAAE,CAACQ,KAAK,CAAC0G,EAAE,CAAC,CAAC,CAAA;AAEd,EAAA,oBACEU,GAAA,CAACC,OAAAA;AACC;IAAAC,aAAA,CAAAA,aAAA,CAAA;AACAR,IAAAA,GAAG,EAAEA,GAAW;IAChBS,EAAE,EAAEvH,KAAK,CAACuH,EAAAA;AAAG,GAAA,EACTC,aAAa,CAAC;IAAEC,IAAI,EAAEC,aAAa,CAACC,GAAG;IAAEC,MAAM,EAAE5H,KAAK,CAAC4H,MAAAA;AAAO,GAAC,CAAC,CAChE7H,EAAAA,YAAY,CAACC,KAAK,CAAC,CACxB,CAAC,CAAA;AAEN,CAAC,CAAA;AAEK2H,IAAAA,GAAG,gBAAGE,wBAAwB,eAACd,cAAK,CAACe,UAAU,CAACjB,IAAI,CAAC,EAAE;AAC3DkB,EAAAA,WAAW,EAAE,KAAK;AAClBC,EAAAA,WAAW,EAAE,KAAA;AACf,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Box.js","sources":["../../../../../../src/components/Box/Box.tsx"],"sourcesContent":["import React from 'react';\nimport BaseBox from './BaseBox';\nimport type { BoxProps, BoxRefType, MakeValueResponsive } from './BaseBox/types';\nimport { validBoxAsValues } from './BaseBox/types/propsTypes';\nimport type { KeysRequired } from '~utils/types';\nimport { isReactNative } from '~utils';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { throwBladeError } from '~utils/logger';\n\nconst validateBackgroundString = (stringBackgroundColorValue: string): void => {\n if (__DEV__) {\n if (\n !stringBackgroundColorValue.startsWith('surface.background') &&\n !stringBackgroundColorValue.startsWith('brand.') &&\n stringBackgroundColorValue !== 'transparent'\n ) {\n throwBladeError({\n message: `Oops! Currently you can only use \\`transparent\\`, \\`surface.background.*\\`, and \\`brand.*\\` tokens with backgroundColor property but we received \\`${stringBackgroundColorValue}\\` instead.\\n\\n Do you have a usecase of using other values? Create an issue on https://github.com/razorpay/blade repo to let us know and we can discuss ✨`,\n moduleName: 'Box',\n });\n }\n }\n};\n\nconst validateBackgroundProp = (\n responsiveBackgroundColor: MakeValueResponsive<string | undefined>,\n): void => {\n if (__DEV__) {\n if (responsiveBackgroundColor) {\n if (typeof responsiveBackgroundColor === 'string') {\n validateBackgroundString(responsiveBackgroundColor);\n return;\n }\n\n Object.values(responsiveBackgroundColor).forEach((backgroundColor) => {\n if (typeof backgroundColor === 'string') {\n validateBackgroundString(backgroundColor);\n }\n });\n }\n }\n};\n\n/**\n * This function is to filter out any unexpected props passed by the user\n */\nconst makeBoxProps = (\n props: BoxProps,\n): KeysRequired<Omit<BoxProps, 'testID' | 'id' | '__brand__'>> => {\n return {\n // Layout\n display: props.display,\n overflow: props.overflow,\n overflowX: props.overflowX,\n overflowY: props.overflowY,\n whiteSpace: props.whiteSpace,\n height: props.height,\n minHeight: props.minHeight,\n maxHeight: props.maxHeight,\n width: props.width,\n minWidth: props.minWidth,\n maxWidth: props.maxWidth,\n textAlign: props.textAlign,\n\n // Flex\n flex: props.flex,\n flexWrap: props.flexWrap,\n flexDirection: props.flexDirection,\n flexGrow: props.flexGrow,\n flexShrink: props.flexShrink,\n flexBasis: props.flexBasis,\n alignItems: props.alignItems,\n alignContent: props.alignContent,\n alignSelf: props.alignSelf,\n justifyItems: props.justifyItems,\n justifyContent: props.justifyContent,\n justifySelf: props.justifySelf,\n placeSelf: props.placeSelf,\n placeItems: props.placeItems,\n order: props.order,\n\n // Grid\n grid: props.grid,\n gridColumn: props.gridColumn,\n gridRow: props.gridRow,\n gridRowStart: props.gridRowStart,\n gridRowEnd: props.gridRowEnd,\n gridColumnStart: props.gridColumnStart,\n gridColumnEnd: props.gridColumnEnd,\n gridArea: props.gridArea,\n gridAutoFlow: props.gridAutoFlow,\n gridAutoRows: props.gridAutoRows,\n gridAutoColumns: props.gridAutoColumns,\n gridTemplate: props.gridTemplate,\n gridTemplateAreas: props.gridTemplateAreas,\n gridTemplateColumns: props.gridTemplateColumns,\n gridTemplateRows: props.gridTemplateRows,\n\n // Spacing\n padding: props.padding,\n paddingTop: props.paddingTop,\n paddingBottom: props.paddingBottom,\n paddingRight: props.paddingRight,\n paddingLeft: props.paddingLeft,\n paddingX: props.paddingX,\n paddingY: props.paddingY,\n margin: props.margin,\n marginBottom: props.marginBottom,\n marginTop: props.marginTop,\n marginRight: props.marginRight,\n marginLeft: props.marginLeft,\n marginX: props.marginX,\n marginY: props.marginY,\n gap: props.gap,\n rowGap: props.rowGap,\n columnGap: props.columnGap,\n\n // Position\n position: props.position,\n zIndex: props.zIndex,\n top: props.top,\n right: props.right,\n bottom: props.bottom,\n left: props.left,\n\n // Visual\n backgroundColor: props.backgroundColor,\n backgroundImage: props.backgroundImage,\n backgroundSize: props.backgroundSize,\n backgroundPosition: props.backgroundPosition,\n backgroundOrigin: props.backgroundOrigin,\n backgroundRepeat: props.backgroundRepeat,\n elevation: props.elevation,\n opacity: props.opacity,\n visibility: props.visibility,\n\n // Border\n borderWidth: props.borderWidth,\n borderColor: props.borderColor,\n borderStyle: props.borderStyle,\n borderTopWidth: props.borderTopWidth,\n borderTopColor: props.borderTopColor,\n borderTopStyle: props.borderTopStyle,\n borderRightWidth: props.borderRightWidth,\n borderRightColor: props.borderRightColor,\n borderRightStyle: props.borderRightStyle,\n borderBottomWidth: props.borderBottomWidth,\n borderBottomColor: props.borderBottomColor,\n borderBottomStyle: props.borderBottomStyle,\n borderLeftWidth: props.borderLeftWidth,\n borderLeftColor: props.borderLeftColor,\n borderLeftStyle: props.borderLeftStyle,\n borderRadius: props.borderRadius,\n borderTopLeftRadius: props.borderTopLeftRadius,\n borderTopRightRadius: props.borderTopRightRadius,\n borderBottomRightRadius: props.borderBottomRightRadius,\n borderBottomLeftRadius: props.borderBottomLeftRadius,\n\n // Polygon Support\n transform: props.transform,\n transformOrigin: props.transformOrigin,\n clipPath: props.clipPath,\n\n // callbacks\n onMouseEnter: props.onMouseEnter,\n onMouseLeave: props.onMouseLeave,\n onMouseOver: props.onMouseOver,\n onScroll: props.onScroll,\n\n // Drag and Drop\n draggable: props.draggable,\n onDragStart: props.onDragStart,\n onDragEnd: props.onDragEnd,\n onDragEnter: props.onDragEnter,\n onDragLeave: props.onDragLeave,\n onDragOver: props.onDragOver,\n onDrop: props.onDrop,\n\n pointerEvents: props.pointerEvents,\n children: props.children,\n tabIndex: props.tabIndex,\n as: isReactNative() ? undefined : props.as, // as is not supported on react-native\n };\n};\n\n/**\n * ## Box\n * \n * Box is the basic Layout component.\n *\n *\n * Box components supports most spacing CSS properties like `display`, `padding*`, `flex*`, `height`, `width`, etc.\n *\n * Check out {@linkcode BoxProps BoxPropsType} for complete list of props and [Layout RFC](https://github.com/razorpay/blade/blob/master/rfcs/2023-01-06-layout.md) for more details on API decision.\n * \n * ----\n * \n * ### Usage\n * \n * ```jsx\n * <Box display=\"flex\">\n * ```\n\n * #### Responsive Props\n *\n * ```jsx\n * <Box padding={{ base: 'spacing.3', m: 'spacing.10' }} />\n * ```\n * \n * #### Margin and Padding Shorthands\n * \n * ```jsx\n * <Box padding={[\"spacing.3\", \"spacing.10\"]} />\n * ```\n *\n * ---\n * \n * Checkout {@link https://blade.razorpay.com/?path=/docs/components-box Box Documentation}\n * \n */\nconst _Box: React.ForwardRefRenderFunction<BoxRefType, BoxProps> = (props, ref) => {\n React.useEffect(() => {\n if (__DEV__) {\n validateBackgroundProp(props.backgroundColor);\n }\n }, [props.backgroundColor]);\n\n React.useEffect(() => {\n if (__DEV__) {\n if (props.as) {\n if (isReactNative()) {\n throwBladeError({\n message: '`as` prop is not supported on React Native',\n moduleName: 'Box',\n });\n }\n\n if (!validBoxAsValues.includes(props.as)) {\n throwBladeError({\n message: `Invalid \\`as\\` prop value - ${props.as}. Only ${validBoxAsValues.join(\n ', ',\n )} are valid values`,\n moduleName: 'Box',\n });\n }\n }\n }\n }, [props.as]);\n\n return (\n <BaseBox\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n id={props.id}\n {...metaAttribute({ name: MetaConstants.Box, testID: props.testID })}\n {...makeBoxProps(props)}\n />\n );\n};\n\nconst Box = assignWithoutSideEffects(React.forwardRef(_Box), {\n displayName: 'Box',\n componentId: 'Box',\n});\n\nexport { Box, makeBoxProps };\n"],"names":["validateBackgroundString","stringBackgroundColorValue","startsWith","throwBladeError","message","concat","moduleName","validateBackgroundProp","responsiveBackgroundColor","Object","values","forEach","backgroundColor","makeBoxProps","props","display","overflow","overflowX","overflowY","whiteSpace","height","minHeight","maxHeight","width","minWidth","maxWidth","textAlign","flex","flexWrap","flexDirection","flexGrow","flexShrink","flexBasis","alignItems","alignContent","alignSelf","justifyItems","justifyContent","justifySelf","placeSelf","placeItems","order","grid","gridColumn","gridRow","gridRowStart","gridRowEnd","gridColumnStart","gridColumnEnd","gridArea","gridAutoFlow","gridAutoRows","gridAutoColumns","gridTemplate","gridTemplateAreas","gridTemplateColumns","gridTemplateRows","padding","paddingTop","paddingBottom","paddingRight","paddingLeft","paddingX","paddingY","margin","marginBottom","marginTop","marginRight","marginLeft","marginX","marginY","gap","rowGap","columnGap","position","zIndex","top","right","bottom","left","backgroundImage","backgroundSize","backgroundPosition","backgroundOrigin","backgroundRepeat","elevation","opacity","visibility","borderWidth","borderColor","borderStyle","borderTopWidth","borderTopColor","borderTopStyle","borderRightWidth","borderRightColor","borderRightStyle","borderBottomWidth","borderBottomColor","borderBottomStyle","borderLeftWidth","borderLeftColor","borderLeftStyle","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","transform","transformOrigin","clipPath","onMouseEnter","onMouseLeave","onMouseOver","onScroll","draggable","onDragStart","onDragEnd","onDragEnter","onDragLeave","onDragOver","onDrop","pointerEvents","children","tabIndex","as","isReactNative","undefined","_Box","ref","React","useEffect","validBoxAsValues","includes","join","_jsx","BaseBox","_objectSpread","id","metaAttribute","name","MetaConstants","Box","testID","assignWithoutSideEffects","forwardRef","displayName","componentId"],"mappings":";;;;;;;;;;;;;;;;;;AAUA,IAAMA,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAAIC,0BAAkC,EAAW;AAC7E,EAAA,IAAI,KAAO,EAAE;AACX,IAAA,IACE,CAACA,0BAA0B,CAACC,UAAU,CAAC,oBAAoB,CAAC,IAC5D,CAACD,0BAA0B,CAACC,UAAU,CAAC,QAAQ,CAAC,IAChDD,0BAA0B,KAAK,aAAa,EAC5C;AACAE,MAAAA,eAAe,CAAC;AACdC,QAAAA,OAAO,EAAAC,8IAAAA,CAAAA,MAAA,CAAwJJ,0BAA0B,EAA4J,gKAAA,CAAA;AACrVK,QAAAA,UAAU,EAAE,KAAA;AACd,OAAC,CAAC,CAAA;AACJ,KAAA;AACF,GAAA;AACF,CAAC,CAAA;AAED,IAAMC,sBAAsB,GAAG,SAAzBA,sBAAsBA,CAC1BC,yBAAkE,EACzD;AACT,EAAA,IAAI,KAAO,EAAE;AACX,IAAA,IAAIA,yBAAyB,EAAE;AAC7B,MAAA,IAAI,OAAOA,yBAAyB,KAAK,QAAQ,EAAE;QACjDR,wBAAwB,CAACQ,yBAAyB,CAAC,CAAA;AACnD,QAAA,OAAA;AACF,OAAA;MAEAC,MAAM,CAACC,MAAM,CAACF,yBAAyB,CAAC,CAACG,OAAO,CAAC,UAACC,eAAe,EAAK;AACpE,QAAA,IAAI,OAAOA,eAAe,KAAK,QAAQ,EAAE;UACvCZ,wBAAwB,CAACY,eAAe,CAAC,CA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oBACEU,GAAA,CAACC,OAAAA;AACC;IAAAC,aAAA,CAAAA,aAAA,CAAA;AACAR,IAAAA,GAAG,EAAEA,GAAW;IAChBS,EAAE,EAAE5H,KAAK,CAAC4H,EAAAA;AAAG,GAAA,EACTC,aAAa,CAAC;IAAEC,IAAI,EAAEC,aAAa,CAACC,GAAG;IAAEC,MAAM,EAAEjI,KAAK,CAACiI,MAAAA;AAAO,GAAC,CAAC,CAChElI,EAAAA,YAAY,CAACC,KAAK,CAAC,CACxB,CAAC,CAAA;AAEN,CAAC,CAAA;AAEKgI,IAAAA,GAAG,gBAAGE,wBAAwB,eAACd,cAAK,CAACe,UAAU,CAACjB,IAAI,CAAC,EAAE;AAC3DkB,EAAAA,WAAW,EAAE,KAAK;AAClBC,EAAAA,WAAW,EAAE,KAAA;AACf,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStyledProps.js","sources":["../../../../../../../src/components/Box/styledProps/getStyledProps.ts"],"sourcesContent":["import type { StyledPropsBlade } from '../BaseBox/types';\nimport type { KeysRequired } from '~utils/types';\n\n/**\n * The input type to these styledProps utilities can be anything as we can just pass all the props and then get the filtered styledProps out of it\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StyledPropsInputType = Record<string, any>;\n\n/**\n * Removing undefined styledProps because when used with spread operator, undefined can override the earlier defined values.\n\n * Example: the following code will print display: undefined since it is given priority in spread.\n * \n * ```ts\n * const styledProps = {\n * display: undefined,\n * }\n *\n * const buttonProps = {\n * display: 'block',\n * }\n *\n * const styles = {\n * ...buttonProps,\n * ...styledProps,\n * } // -> Prints { display: undefined }\n * ```\n */\nconst removeUndefinedStyledProps = (obj: StyledPropsInputType): StyledPropsInputType => {\n const onlyDefinedStyledProps: StyledPropsBlade = {};\n for (const key in obj) {\n if (obj[key] !== undefined) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error\n // @ts-ignore: complex type error\n onlyDefinedStyledProps[key] = obj[key];\n }\n }\n return onlyDefinedStyledProps;\n};\n\n/**\n * - Removes the props that are not styledProps\n * - Returns all the styled props along with undefined values.\n *\n * Can be used in generating storybook docs and testing the possible props.\n *\n *\n * **Use `getStyledProps` instead if you're using this for adding styledProps!**\n */\nconst makeStyledProps = (props: StyledPropsInputType): KeysRequired<StyledPropsBlade> => {\n return {\n alignSelf: props.alignSelf,\n display: props.display,\n justifySelf: props.justifySelf,\n placeSelf: props.placeSelf,\n order: props.order,\n position: props.position,\n zIndex: props.zIndex,\n gridColumn: props.gridColumn,\n gridColumnStart: props.gridColumnStart,\n gridColumnEnd: props.gridColumnEnd,\n gridRow: props.gridRow,\n gridRowStart: props.gridRowStart,\n gridRowEnd: props.gridRowEnd,\n gridArea: props.gridArea,\n margin: props.margin,\n marginX: props.marginX,\n marginY: props.marginY,\n marginBottom: props.marginBottom,\n marginTop: props.marginTop,\n marginRight: props.marginRight,\n marginLeft: props.marginLeft,\n top: props.top,\n right: props.right,\n bottom: props.bottom,\n left: props.left,\n };\n};\n\n/**\n *\n * ## How to add Styled Props to components?\n *\n * There are 2 ways\n * - Using `getStyledProps` + BaseBox wrapper\n * - Using `useStyledProps`\n *\n * You can use `getStyledProps` method if you're fine adding or already have BaseBox wrapper around your component\n * And use `useStyledProps` when adding BaseBox wrapper can cause styling issues or is unneccessary and you want to prevent unnecessary renders\n *\n * ### Usage\n *\n * #### `getStyledProps` + BaseBox wrapper\n *\n * ```tsx\n * import type { StyledPropsBlade } from '~src/components/Box/styledProps';\n * import { getStyledProps } from '~src/components/Box/styledProps';\n *\n * type MyComponentProps = {\n * // ... Your Props\n * } & StyledPropsBlade;\n *\n * const MyComponent = (props: MyComponentProps): React.ReactElement => {\n * return (\n * // Make sure styledProps come last so they take priority in stylings in-case of overrides\n * <BaseBox someOtherProp={someValue} {...getStyledProps(props)}>\n * // Your component code\n * </BaseBox>\n * )\n * }\n * ```\n *\n * #### `useStyledProps`\n *\n *\n * ```tsx\n * import type { StyledPropsBlade } from '~src/components/Box/styledProps';\n * import { useStyledProps } from '~src/components/Box/styledProps';\n *\n * type MyTextComponentProps = {\n * // ... Your Props\n * } & StyledPropsBlade;\n *\n *\n * const TextComponentWithStyledProps = styled.p<MyTextComponentProps>((props) => {\n * const styledPropsCSSObject = useStyledProps(props);\n *\n * return {\n * // ...your other CSS,\n * ...styledPropsCSSObject, // Make sure styledProps come last so they take priority in styles\n * }\n * })\n * ```\n *\n * Checkout implementation in `BaseText` components for example of `useStyledProps`\n *\n * - Web: [`BaseText.web.tsx`](../../components/Typography/BaseText/BaseText.web.tsx)\n * - Native: [`BaseText.native.tsx`](../../components/Typography/BaseText/BaseText.native.tsx)\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst getStyledProps = (props: Record<string, any>): StyledPropsBlade => {\n return removeUndefinedStyledProps(makeStyledProps(props));\n};\n\nexport type { StyledPropsBlade };\nexport { getStyledProps, makeStyledProps, removeUndefinedStyledProps };\n"],"names":["removeUndefinedStyledProps","obj","onlyDefinedStyledProps","key","undefined","makeStyledProps","props","alignSelf","display","justifySelf","placeSelf","order","position","zIndex","gridColumn","gridColumnStart","gridColumnEnd","gridRow","gridRowStart","gridRowEnd","gridArea","margin","marginX","marginY","marginBottom","marginTop","marginRight","marginLeft","top","right","bottom","left","getStyledProps"],"mappings":"AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMA,0BAA0B,GAAG,SAA7BA,0BAA0BA,CAAIC,GAAyB,EAA2B;EACtF,IAAMC,sBAAwC,GAAG,EAAE,CAAA;AACnD,EAAA,KAAK,IAAMC,GAAG,IAAIF,GAAG,EAAE;AACrB,IAAA,IAAIA,GAAG,CAACE,GAAG,CAAC,KAAKC,SAAS,EAAE;AAC1B;AACA;AACAF,MAAAA,sBAAsB,CAACC,GAAG,CAAC,GAAGF,GAAG,CAAC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sources":["../../../../../../../src/components/Box/styledProps/getStyledProps.ts"],"sourcesContent":["import type { StyledPropsBlade } from '../BaseBox/types';\nimport type { KeysRequired } from '~utils/types';\n\n/**\n * The input type to these styledProps utilities can be anything as we can just pass all the props and then get the filtered styledProps out of it\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StyledPropsInputType = Record<string, any>;\n\n/**\n * Removing undefined styledProps because when used with spread operator, undefined can override the earlier defined values.\n\n * Example: the following code will print display: undefined since it is given priority in spread.\n * \n * ```ts\n * const styledProps = {\n * display: undefined,\n * }\n *\n * const buttonProps = {\n * display: 'block',\n * }\n *\n * const styles = {\n * ...buttonProps,\n * ...styledProps,\n * } // -> Prints { display: undefined }\n * ```\n */\nconst removeUndefinedStyledProps = (obj: StyledPropsInputType): StyledPropsInputType => {\n const onlyDefinedStyledProps: StyledPropsBlade = {};\n for (const key in obj) {\n if (obj[key] !== undefined) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error\n // @ts-ignore: complex type error\n onlyDefinedStyledProps[key] = obj[key];\n }\n }\n return onlyDefinedStyledProps;\n};\n\n/**\n * - Removes the props that are not styledProps\n * - Returns all the styled props along with undefined values.\n *\n * Can be used in generating storybook docs and testing the possible props.\n *\n *\n * **Use `getStyledProps` instead if you're using this for adding styledProps!**\n */\nconst makeStyledProps = (props: StyledPropsInputType): KeysRequired<StyledPropsBlade> => {\n return {\n alignSelf: props.alignSelf,\n display: props.display,\n justifySelf: props.justifySelf,\n placeSelf: props.placeSelf,\n order: props.order,\n position: props.position,\n zIndex: props.zIndex,\n gridColumn: props.gridColumn,\n gridColumnStart: props.gridColumnStart,\n gridColumnEnd: props.gridColumnEnd,\n gridRow: props.gridRow,\n gridRowStart: props.gridRowStart,\n gridRowEnd: props.gridRowEnd,\n gridArea: props.gridArea,\n margin: props.margin,\n marginX: props.marginX,\n marginY: props.marginY,\n marginBottom: props.marginBottom,\n marginTop: props.marginTop,\n marginRight: props.marginRight,\n marginLeft: props.marginLeft,\n top: props.top,\n right: props.right,\n bottom: props.bottom,\n left: props.left,\n visibility: props.visibility,\n };\n};\n\n/**\n *\n * ## How to add Styled Props to components?\n *\n * There are 2 ways\n * - Using `getStyledProps` + BaseBox wrapper\n * - Using `useStyledProps`\n *\n * You can use `getStyledProps` method if you're fine adding or already have BaseBox wrapper around your component\n * And use `useStyledProps` when adding BaseBox wrapper can cause styling issues or is unneccessary and you want to prevent unnecessary renders\n *\n * ### Usage\n *\n * #### `getStyledProps` + BaseBox wrapper\n *\n * ```tsx\n * import type { StyledPropsBlade } from '~src/components/Box/styledProps';\n * import { getStyledProps } from '~src/components/Box/styledProps';\n *\n * type MyComponentProps = {\n * // ... Your Props\n * } & StyledPropsBlade;\n *\n * const MyComponent = (props: MyComponentProps): React.ReactElement => {\n * return (\n * // Make sure styledProps come last so they take priority in stylings in-case of overrides\n * <BaseBox someOtherProp={someValue} {...getStyledProps(props)}>\n * // Your component code\n * </BaseBox>\n * )\n * }\n * ```\n *\n * #### `useStyledProps`\n *\n *\n * ```tsx\n * import type { StyledPropsBlade } from '~src/components/Box/styledProps';\n * import { useStyledProps } from '~src/components/Box/styledProps';\n *\n * type MyTextComponentProps = {\n * // ... Your Props\n * } & StyledPropsBlade;\n *\n *\n * const TextComponentWithStyledProps = styled.p<MyTextComponentProps>((props) => {\n * const styledPropsCSSObject = useStyledProps(props);\n *\n * return {\n * // ...your other CSS,\n * ...styledPropsCSSObject, // Make sure styledProps come last so they take priority in styles\n * }\n * })\n * ```\n *\n * Checkout implementation in `BaseText` components for example of `useStyledProps`\n *\n * - Web: [`BaseText.web.tsx`](../../components/Typography/BaseText/BaseText.web.tsx)\n * - Native: [`BaseText.native.tsx`](../../components/Typography/BaseText/BaseText.native.tsx)\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst getStyledProps = (props: Record<string, any>): StyledPropsBlade => {\n return removeUndefinedStyledProps(makeStyledProps(props));\n};\n\nexport type { StyledPropsBlade };\nexport { getStyledProps, makeStyledProps, removeUndefinedStyledProps };\n"],"names":["removeUndefinedStyledProps","obj","onlyDefinedStyledProps","key","undefined","makeStyledProps","props","alignSelf","display","justifySelf","placeSelf","order","position","zIndex","gridColumn","gridColumnStart","gridColumnEnd","gridRow","gridRowStart","gridRowEnd","gridArea","margin","marginX","marginY","marginBottom","marginTop","marginRight","marginLeft","top","right","bottom","left","visibility","getStyledProps"],"mappings":"AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMA,0BAA0B,GAAG,SAA7BA,0BAA0BA,CAAIC,GAAyB,EAA2B;EACtF,IAAMC,sBAAwC,GAAG,EAAE,CAAA;AACnD,EAAA,KAAK,IAAMC,GAAG,IAAIF,GAAG,EAAE;AACrB,IAAA,IAAIA,GAAG,CAACE,GAAG,CAAC,KAAKC,SAAS,EAAE;AAC1B;AACA;AACAF,MAAAA,sBAAsB,CAACC,GAAG,CAAC,GAAGF,GAAG,CAACE,GAAG,CAAC,CAAA;AACxC,KAAA;AACF,GAAA;AACA,EAAA,OAAOD,sBAAsB,CAAA;AAC/B,EAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMG,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,KAA2B,EAAqC;EACvF,OAAO;IACLC,SAAS,EAAED,KAAK,CAACC,SAAS;IAC1BC,OAAO,EAAEF,KAAK,CAACE,OAAO;IACtBC,WAAW,EAAEH,KAAK,CAACG,WAAW;IAC9BC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,QAAQ,EAAEN,KAAK,CAACM,QAAQ;IACxBC,MAAM,EAAEP,KAAK,CAACO,MAAM;IACpBC,UAAU,EAAER,KAAK,CAACQ,UAAU;IAC5BC,eAAe,EAAET,KAAK,CAACS,eAAe;IACtCC,aAAa,EAAEV,KAAK,CAACU,aAAa;IAClCC,OAAO,EAAEX,KAAK,CAACW,OAAO;IACtBC,YAAY,EAAEZ,KAAK,CAACY,YAAY;IAChCC,UAAU,EAAEb,KAAK,CAACa,UAAU;IAC5BC,QAAQ,EAAEd,KAAK,CAACc,QAAQ;IACxBC,MAAM,EAAEf,KAAK,CAACe,MAAM;IACpBC,OAAO,EAAEhB,KAAK,CAACgB,OAAO;IACtBC,OAAO,EAAEjB,KAAK,CAACiB,OAAO;IACtBC,YAAY,EAAElB,KAAK,CAACkB,YAAY;IAChCC,SAAS,EAAEnB,KAAK,CAACmB,SAAS;IAC1BC,WAAW,EAAEpB,KAAK,CAACoB,WAAW;IAC9BC,UAAU,EAAErB,KAAK,CAACqB,UAAU;IAC5BC,GAAG,EAAEtB,KAAK,CAACsB,GAAG;IACdC,KAAK,EAAEvB,KAAK,CAACuB,KAAK;IAClBC,MAAM,EAAExB,KAAK,CAACwB,MAAM;IACpBC,IAAI,EAAEzB,KAAK,CAACyB,IAAI;IAChBC,UAAU,EAAE1B,KAAK,CAAC0B,UAAAA;GACnB,CAAA;AACH,EAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAI3B,KAA0B,EAAuB;AACvE,EAAA,OAAON,0BAA0B,CAACK,eAAe,CAACC,KAAK,CAAC,CAAC,CAAA;AAC3D;;;;"}
|
|
@@ -41,7 +41,7 @@ var Indicator = function Indicator(_ref) {
|
|
|
41
41
|
var _useTheme = useTheme(),
|
|
42
42
|
theme = _useTheme.theme;
|
|
43
43
|
var childrenString = getStringFromReactText(children);
|
|
44
|
-
var fillColor = theme.colors.feedback.background[color].intense;
|
|
44
|
+
var fillColor = color === 'primary' ? theme.colors.surface.background.primary.intense : theme.colors.feedback.background[color].intense;
|
|
45
45
|
var getDimension = useCallback(function () {
|
|
46
46
|
switch (size$1) {
|
|
47
47
|
case 'small':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Indicator.js","sources":["../../../../../../src/components/Indicator/Indicator.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport { useCallback } from 'react';\nimport { useTheme } from '~components/BladeProvider';\nimport BaseBox from '~components/Box/BaseBox';\nimport Svg from '~components/Icons/_Svg';\nimport Circle from '~components/Icons/_Svg/Circle';\nimport { Text } from '~components/Typography';\nimport { size as sizeToken } from '~tokens/global';\nimport { getStringFromReactText } from '~src/utils/getStringChildren';\nimport type { StringChildrenType, TestID } from '~utils/types';\nimport type { FeedbackColors } from '~tokens/theme/theme';\nimport { isReactNative } from '~utils';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { makeAccessible } from '~utils/makeAccessible';\n\ntype IndicatorCommonProps = {\n /**\n * Sets the color tone\n *\n * @default neutral\n */\n color?: FeedbackColors;\n\n /**\n * Size of the indicator\n *\n * @default medium\n */\n size?: 'small' | 'medium' | 'large';\n} & TestID &\n StyledPropsBlade;\n\ntype IndicatorWithoutA11yLabel = {\n /**\n * A text label to show alongside the indicator dot\n */\n children: StringChildrenType;\n\n /**\n * a11y label for screen readers\n */\n accessibilityLabel?: string;\n};\n\ntype IndicatorWithA11yLabel = {\n /**\n * a11y label for screen readers\n */\n accessibilityLabel: string;\n\n /**\n * A text label to show alongside the indicator dot\n */\n children?: StringChildrenType;\n};\n\ntype IndicatorProps = IndicatorCommonProps & (IndicatorWithA11yLabel | IndicatorWithoutA11yLabel);\n\ntype Dimensions = {\n svgSize: number;\n textSize: 'small' | 'medium';\n};\n\nconst Indicator = ({\n accessibilityLabel,\n children,\n size = 'medium',\n color = 'neutral',\n testID,\n ...styledProps\n}: IndicatorProps): ReactElement => {\n const { theme } = useTheme();\n const childrenString = getStringFromReactText(children);\n\n const fillColor
|
|
1
|
+
{"version":3,"file":"Indicator.js","sources":["../../../../../../src/components/Indicator/Indicator.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport { useCallback } from 'react';\nimport { useTheme } from '~components/BladeProvider';\nimport BaseBox from '~components/Box/BaseBox';\nimport Svg from '~components/Icons/_Svg';\nimport Circle from '~components/Icons/_Svg/Circle';\nimport { Text } from '~components/Typography';\nimport { size as sizeToken } from '~tokens/global';\nimport { getStringFromReactText } from '~src/utils/getStringChildren';\nimport type { StringChildrenType, TestID } from '~utils/types';\nimport type { FeedbackColors } from '~tokens/theme/theme';\nimport { isReactNative } from '~utils';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { makeAccessible } from '~utils/makeAccessible';\n\ntype IndicatorCommonProps = {\n /**\n * Sets the color tone\n *\n * @default neutral\n */\n color?: FeedbackColors | 'primary';\n\n /**\n * Size of the indicator\n *\n * @default medium\n */\n size?: 'small' | 'medium' | 'large';\n} & TestID &\n StyledPropsBlade;\n\ntype IndicatorWithoutA11yLabel = {\n /**\n * A text label to show alongside the indicator dot\n */\n children: StringChildrenType;\n\n /**\n * a11y label for screen readers\n */\n accessibilityLabel?: string;\n};\n\ntype IndicatorWithA11yLabel = {\n /**\n * a11y label for screen readers\n */\n accessibilityLabel: string;\n\n /**\n * A text label to show alongside the indicator dot\n */\n children?: StringChildrenType;\n};\n\ntype IndicatorProps = IndicatorCommonProps & (IndicatorWithA11yLabel | IndicatorWithoutA11yLabel);\n\ntype Dimensions = {\n svgSize: number;\n textSize: 'small' | 'medium';\n};\n\nconst Indicator = ({\n accessibilityLabel,\n children,\n size = 'medium',\n color = 'neutral',\n testID,\n ...styledProps\n}: IndicatorProps): ReactElement => {\n const { theme } = useTheme();\n const childrenString = getStringFromReactText(children);\n\n const fillColor =\n color === 'primary'\n ? theme.colors.surface.background.primary.intense\n : theme.colors.feedback.background[color].intense;\n const getDimension = useCallback((): Dimensions => {\n switch (size) {\n case 'small':\n return { svgSize: sizeToken[6], textSize: 'small' };\n case 'large':\n return { svgSize: sizeToken[10], textSize: 'medium' };\n default:\n return { svgSize: sizeToken[8], textSize: 'medium' };\n }\n }, [size]);\n const dimensions = getDimension();\n\n const isWeb = !isReactNative();\n const a11yProps = makeAccessible({\n label: accessibilityLabel ?? childrenString,\n ...(isWeb && { role: 'status' }),\n });\n\n return (\n <BaseBox\n display={(isWeb ? 'inline-flex' : 'flex') as never}\n {...a11yProps}\n {...metaAttribute({ name: MetaConstants.Indicator, testID })}\n {...getStyledProps(styledProps)}\n >\n <BaseBox display=\"flex\" flexDirection=\"row\" alignItems=\"center\">\n <Svg\n width={String(dimensions.svgSize)}\n height={String(dimensions.svgSize)}\n viewBox=\"0 0 10 10\"\n fill=\"none\"\n >\n <Circle cx=\"5\" cy=\"5\" r=\"5\" fill={fillColor} />\n </Svg>\n <BaseBox marginLeft=\"spacing.2\">\n <Text\n weight=\"medium\"\n color=\"surface.text.gray.subtle\"\n textAlign=\"left\"\n size={dimensions.textSize}\n >\n {children}\n </Text>\n </BaseBox>\n </BaseBox>\n </BaseBox>\n );\n};\n\nexport type { IndicatorProps };\nexport { Indicator };\n"],"names":["Indicator","_ref","accessibilityLabel","children","_ref$size","size","_ref$color","color","testID","styledProps","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","childrenString","getStringFromReactText","fillColor","colors","surface","background","primary","intense","feedback","getDimension","useCallback","svgSize","sizeToken","textSize","dimensions","isWeb","isReactNative","a11yProps","makeAccessible","_objectSpread","label","role","_jsx","BaseBox","display","metaAttribute","name","MetaConstants","getStyledProps","_jsxs","flexDirection","alignItems","Svg","width","String","height","viewBox","fill","Circle","cx","cy","r","marginLeft","Text","weight","textAlign"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,IAAMA,SAAS,GAAG,SAAZA,SAASA,CAAAC,IAAA,EAOqB;AAAA,EAAA,IANlCC,kBAAkB,GAAAD,IAAA,CAAlBC,kBAAkB;IAClBC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IAAAC,SAAA,GAAAH,IAAA,CACRI,IAAI;AAAJA,IAAAA,MAAI,GAAAD,SAAA,KAAG,KAAA,CAAA,GAAA,QAAQ,GAAAA,SAAA;IAAAE,UAAA,GAAAL,IAAA,CACfM,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAG,KAAA,CAAA,GAAA,SAAS,GAAAA,UAAA;IACjBE,MAAM,GAAAP,IAAA,CAANO,MAAM;AACHC,IAAAA,WAAW,GAAAC,wBAAA,CAAAT,IAAA,EAAAU,SAAA,CAAA,CAAA;AAEd,EAAA,IAAAC,SAAA,GAAkBC,QAAQ,EAAE;IAApBC,KAAK,GAAAF,SAAA,CAALE,KAAK,CAAA;AACb,EAAA,IAAMC,cAAc,GAAGC,sBAAsB,CAACb,QAAQ,CAAC,CAAA;AAEvD,EAAA,IAAMc,SAAS,GACbV,KAAK,KAAK,SAAS,GACfO,KAAK,CAACI,MAAM,CAACC,OAAO,CAACC,UAAU,CAACC,OAAO,CAACC,OAAO,GAC/CR,KAAK,CAACI,MAAM,CAACK,QAAQ,CAACH,UAAU,CAACb,KAAK,CAAC,CAACe,OAAO,CAAA;AACrD,EAAA,IAAME,YAAY,GAAGC,WAAW,CAAC,YAAkB;AACjD,IAAA,QAAQpB,MAAI;AACV,MAAA,KAAK,OAAO;QACV,OAAO;AAAEqB,UAAAA,OAAO,EAAEC,IAAS,CAAC,CAAC,CAAC;AAAEC,UAAAA,QAAQ,EAAE,OAAA;SAAS,CAAA;AACrD,MAAA,KAAK,OAAO;QAC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EAAEC,MAAM,CAACpB,UAAU,CAACH,OAAO,CAAE;AAClCwB,QAAAA,MAAM,EAAED,MAAM,CAACpB,UAAU,CAACH,OAAO,CAAE;AACnCyB,QAAAA,OAAO,EAAC,WAAW;AACnBC,QAAAA,IAAI,EAAC,MAAM;QAAAjD,QAAA,eAEXkC,GAAA,CAACgB,MAAM,EAAA;AAACC,UAAAA,EAAE,EAAC,GAAG;AAACC,UAAAA,EAAE,EAAC,GAAG;AAACC,UAAAA,CAAC,EAAC,GAAG;AAACJ,UAAAA,IAAI,EAAEnC,SAAAA;SAAY,CAAA;AAAC,OAC5C,CAAC,eACNoB,GAAA,CAACC,OAAO,EAAA;AAACmB,QAAAA,UAAU,EAAC,WAAW;QAAAtD,QAAA,eAC7BkC,GAAA,CAACqB,IAAI,EAAA;AACHC,UAAAA,MAAM,EAAC,QAAQ;AACfpD,UAAAA,KAAK,EAAC,0BAA0B;AAChCqD,UAAAA,SAAS,EAAC,MAAM;UAChBvD,IAAI,EAAEwB,UAAU,CAACD,QAAS;AAAAzB,UAAAA,QAAA,EAEzBA,QAAAA;SACG,CAAA;AAAC,OACA,CAAC,CAAA;KACH,CAAA;AAAC,GAAA,CACH,CAAC,CAAA;AAEd;;;;"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
import { useStepGroup, StepGroupContext } from './StepGroupContext.js';
|
|
5
|
+
import { componentIds } from './componentIds.js';
|
|
6
|
+
import '../Box/BaseBox/index.js';
|
|
7
|
+
import '../Box/styledProps/index.js';
|
|
8
|
+
import '../../utils/isValidAllowedChildren/index.js';
|
|
9
|
+
import '../../utils/assignWithoutSideEffects/index.js';
|
|
10
|
+
import '../../utils/metaAttribute/index.js';
|
|
11
|
+
import { jsx } from 'react/jsx-runtime';
|
|
12
|
+
import { getComponentId } from '../../utils/isValidAllowedChildren/isValidAllowedChildren.js';
|
|
13
|
+
import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
|
|
14
|
+
import { getStyledProps } from '../Box/styledProps/getStyledProps.js';
|
|
15
|
+
import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.web.js';
|
|
16
|
+
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
|
|
17
|
+
import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
18
|
+
|
|
19
|
+
var _excluded = ["_nestingLevel", "children"],
|
|
20
|
+
_excluded2 = ["size", "orientation", "children", "testID", "_nestingLevel", "width", "minWidth", "maxWidth"];
|
|
21
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
|
+
var useChildrenWithIndexes = function useChildrenWithIndexes(_ref) {
|
|
24
|
+
var _nestingLevel = _ref._nestingLevel,
|
|
25
|
+
children = _ref.children,
|
|
26
|
+
parentStepGroupProps = _objectWithoutProperties(_ref, _excluded);
|
|
27
|
+
var _useStepGroup = useStepGroup(),
|
|
28
|
+
totalItemsFromPreviousParent = _useStepGroup.totalItemsInParentGroupCount;
|
|
29
|
+
var totalIndex = 0;
|
|
30
|
+
var traverseGroupAndAddIndex = function traverseGroupAndAddIndex(groupChildrenProp) {
|
|
31
|
+
var nestingLevelOfGroup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
32
|
+
var stepItemIndex = 0;
|
|
33
|
+
return React__default.Children.map(groupChildrenProp, function (child, index) {
|
|
34
|
+
var componentId = getComponentId(child);
|
|
35
|
+
if (componentId === componentIds.StepItem) {
|
|
36
|
+
return /*#__PURE__*/React__default.cloneElement(child, {
|
|
37
|
+
_index: stepItemIndex++,
|
|
38
|
+
_totalIndex: totalIndex++,
|
|
39
|
+
_nestingLevel: nestingLevelOfGroup,
|
|
40
|
+
key: index
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (componentId === componentIds.StepGroup && nestingLevelOfGroup < 3) {
|
|
44
|
+
return /*#__PURE__*/React__default.cloneElement(child, _objectSpread(_objectSpread({}, parentStepGroupProps), {}, {
|
|
45
|
+
children: traverseGroupAndAddIndex(child.props.children, nestingLevelOfGroup + 1),
|
|
46
|
+
_nestingLevel: nestingLevelOfGroup + 1
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
return child;
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
var childrenWithIndex = React__default.useMemo(function () {
|
|
53
|
+
return _nestingLevel === 0 ? traverseGroupAndAddIndex(children) : children;
|
|
54
|
+
},
|
|
55
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
|
+
[children, _nestingLevel]);
|
|
57
|
+
var totalItemsInParentGroupCount = _nestingLevel === 0 ? totalIndex : totalItemsFromPreviousParent;
|
|
58
|
+
return {
|
|
59
|
+
childrenWithIndex: childrenWithIndex,
|
|
60
|
+
totalItemsInParentGroupCount: totalItemsInParentGroupCount
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
var _StepGroup = function _StepGroup(_ref2) {
|
|
64
|
+
var _ref2$size = _ref2.size,
|
|
65
|
+
size = _ref2$size === void 0 ? 'medium' : _ref2$size,
|
|
66
|
+
_ref2$orientation = _ref2.orientation,
|
|
67
|
+
orientation = _ref2$orientation === void 0 ? 'vertical' : _ref2$orientation,
|
|
68
|
+
children = _ref2.children,
|
|
69
|
+
testID = _ref2.testID,
|
|
70
|
+
_ref2$_nestingLevel = _ref2._nestingLevel,
|
|
71
|
+
_nestingLevel = _ref2$_nestingLevel === void 0 ? 0 : _ref2$_nestingLevel,
|
|
72
|
+
width = _ref2.width,
|
|
73
|
+
minWidth = _ref2.minWidth,
|
|
74
|
+
maxWidth = _ref2.maxWidth,
|
|
75
|
+
styledProps = _objectWithoutProperties(_ref2, _excluded2);
|
|
76
|
+
var itemsInGroupCount = React__default.Children.count(children);
|
|
77
|
+
var _useChildrenWithIndex = useChildrenWithIndexes({
|
|
78
|
+
children: children,
|
|
79
|
+
size: size,
|
|
80
|
+
orientation: orientation,
|
|
81
|
+
_nestingLevel: _nestingLevel
|
|
82
|
+
}),
|
|
83
|
+
childrenWithIndex = _useChildrenWithIndex.childrenWithIndex,
|
|
84
|
+
totalItemsInParentGroupCount = _useChildrenWithIndex.totalItemsInParentGroupCount;
|
|
85
|
+
var contextValue = React__default.useMemo(function () {
|
|
86
|
+
return {
|
|
87
|
+
size: size,
|
|
88
|
+
orientation: orientation,
|
|
89
|
+
itemsInGroupCount: itemsInGroupCount,
|
|
90
|
+
totalItemsInParentGroupCount: totalItemsInParentGroupCount
|
|
91
|
+
};
|
|
92
|
+
}, [size, orientation, itemsInGroupCount, totalItemsInParentGroupCount]);
|
|
93
|
+
var isHorizontal = orientation === 'horizontal';
|
|
94
|
+
var defaultWidth = isHorizontal ? '100%' : undefined;
|
|
95
|
+
return /*#__PURE__*/jsx(StepGroupContext.Provider, {
|
|
96
|
+
value: contextValue,
|
|
97
|
+
children: /*#__PURE__*/jsx(BaseBox, _objectSpread(_objectSpread(_objectSpread({}, getStyledProps(styledProps)), {}, {
|
|
98
|
+
display: "inline-flex",
|
|
99
|
+
maxWidth: maxWidth !== null && maxWidth !== void 0 ? maxWidth : '100%',
|
|
100
|
+
minWidth: minWidth,
|
|
101
|
+
width: width !== null && width !== void 0 ? width : defaultWidth,
|
|
102
|
+
padding: _nestingLevel === 0 ? 'spacing.4' : undefined,
|
|
103
|
+
overflowX: orientation === 'horizontal' ? 'auto' : undefined,
|
|
104
|
+
flexDirection: orientation === 'vertical' ? 'column' : 'row'
|
|
105
|
+
}, metaAttribute({
|
|
106
|
+
name: MetaConstants.StepGroup,
|
|
107
|
+
testID: testID
|
|
108
|
+
})), {}, {
|
|
109
|
+
children: childrenWithIndex
|
|
110
|
+
}))
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* ## StepGroup
|
|
116
|
+
*
|
|
117
|
+
* Step Group visualises sequential processes with a consistent structure. It can be interactive, guiding users through steps, or function as a timeline for reference.
|
|
118
|
+
*
|
|
119
|
+
* ### Usage
|
|
120
|
+
*
|
|
121
|
+
* ```jsx
|
|
122
|
+
* <StepGroup orientation="vertical" size="medium">
|
|
123
|
+
* <StepItem title="Personal Details" />
|
|
124
|
+
* <StepItem title="Business Details" />
|
|
125
|
+
* </StepGroup>
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* ---
|
|
129
|
+
*
|
|
130
|
+
* Checkout {@link https://blade.razorpay.com/?path=/docs/components-stepgroup--docs StepGroup Documentation}
|
|
131
|
+
*/
|
|
132
|
+
var StepGroup = /*#__PURE__*/assignWithoutSideEffects(_StepGroup, {
|
|
133
|
+
componentId: componentIds.StepGroup,
|
|
134
|
+
displayName: componentIds.StepGroup
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
export { StepGroup };
|
|
138
|
+
//# sourceMappingURL=StepGroup.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepGroup.web.js","sources":["../../../../../../src/components/StepGroup/StepGroup.web.tsx"],"sourcesContent":["import React from 'react';\nimport type { StepGroupContextType, StepGroupProps } from './types';\nimport { StepGroupContext, useStepGroup } from './StepGroupContext';\nimport { componentIds } from './componentIds';\nimport BaseBox from '~components/Box/BaseBox';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\n\nconst useChildrenWithIndexes = ({\n _nestingLevel,\n children,\n ...parentStepGroupProps\n}: Pick<StepGroupProps, 'children' | '_nestingLevel' | 'size' | 'orientation'>): {\n childrenWithIndex: React.ReactNode;\n totalItemsInParentGroupCount: number;\n} => {\n const { totalItemsInParentGroupCount: totalItemsFromPreviousParent } = useStepGroup();\n\n let totalIndex = 0;\n const traverseGroupAndAddIndex = (\n groupChildrenProp: StepGroupProps['children'],\n nestingLevelOfGroup = 0,\n ): React.ReactNode => {\n let stepItemIndex = 0;\n return React.Children.map(groupChildrenProp, (child, index) => {\n const componentId = getComponentId(child);\n if (componentId === componentIds.StepItem) {\n return React.cloneElement(child, {\n _index: stepItemIndex++,\n _totalIndex: totalIndex++,\n _nestingLevel: nestingLevelOfGroup,\n key: index,\n });\n }\n\n if (componentId === componentIds.StepGroup && nestingLevelOfGroup < 3) {\n return React.cloneElement(child, {\n ...parentStepGroupProps,\n children: traverseGroupAndAddIndex(child.props.children, nestingLevelOfGroup + 1),\n _nestingLevel: nestingLevelOfGroup + 1,\n });\n }\n\n return child;\n });\n };\n\n const childrenWithIndex: React.ReactNode = React.useMemo(\n () => (_nestingLevel === 0 ? traverseGroupAndAddIndex(children) : children),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [children, _nestingLevel],\n );\n\n const totalItemsInParentGroupCount =\n _nestingLevel === 0 ? totalIndex : totalItemsFromPreviousParent;\n\n return { childrenWithIndex, totalItemsInParentGroupCount };\n};\n\nconst _StepGroup = ({\n size = 'medium',\n orientation = 'vertical',\n children,\n testID,\n _nestingLevel = 0,\n width,\n minWidth,\n maxWidth,\n ...styledProps\n}: StepGroupProps): React.ReactElement => {\n const itemsInGroupCount = React.Children.count(children);\n const { childrenWithIndex, totalItemsInParentGroupCount } = useChildrenWithIndexes({\n children,\n size,\n orientation,\n _nestingLevel,\n });\n const contextValue = React.useMemo<StepGroupContextType>(\n () => ({\n size,\n orientation,\n itemsInGroupCount,\n totalItemsInParentGroupCount,\n }),\n [size, orientation, itemsInGroupCount, totalItemsInParentGroupCount],\n );\n\n const isHorizontal = orientation === 'horizontal';\n const defaultWidth = isHorizontal ? '100%' : undefined;\n\n return (\n <StepGroupContext.Provider value={contextValue}>\n <BaseBox\n {...getStyledProps(styledProps)}\n display=\"inline-flex\"\n maxWidth={maxWidth ?? '100%'}\n minWidth={minWidth}\n width={width ?? defaultWidth}\n padding={_nestingLevel === 0 ? 'spacing.4' : undefined}\n overflowX={orientation === 'horizontal' ? 'auto' : undefined}\n flexDirection={orientation === 'vertical' ? 'column' : 'row'}\n {...metaAttribute({ name: MetaConstants.StepGroup, testID })}\n >\n {childrenWithIndex}\n </BaseBox>\n </StepGroupContext.Provider>\n );\n};\n\n/**\n * ## StepGroup\n *\n * Step Group visualises sequential processes with a consistent structure. It can be interactive, guiding users through steps, or function as a timeline for reference.\n *\n * ### Usage\n *\n * ```jsx\n * <StepGroup orientation=\"vertical\" size=\"medium\">\n * <StepItem title=\"Personal Details\" />\n * <StepItem title=\"Business Details\" />\n * </StepGroup>\n * ```\n *\n * ---\n *\n * Checkout {@link https://blade.razorpay.com/?path=/docs/components-stepgroup--docs StepGroup Documentation}\n */\nconst StepGroup = assignWithoutSideEffects(_StepGroup, {\n componentId: componentIds.StepGroup,\n displayName: componentIds.StepGroup,\n});\n\nexport { StepGroup };\n"],"names":["useChildrenWithIndexes","_ref","_nestingLevel","children","parentStepGroupProps","_objectWithoutProperties","_excluded","_useStepGroup","useStepGroup","totalItemsFromPreviousParent","totalItemsInParentGroupCount","totalIndex","traverseGroupAndAddIndex","groupChildrenProp","nestingLevelOfGroup","arguments","length","undefined","stepItemIndex","React","Children","map","child","index","componentId","getComponentId","componentIds","StepItem","cloneElement","_index","_totalIndex","key","StepGroup","_objectSpread","props","childrenWithIndex","useMemo","_StepGroup","_ref2","_ref2$size","size","_ref2$orientation","orientation","testID","_ref2$_nestingLevel","width","minWidth","maxWidth","styledProps","_excluded2","itemsInGroupCount","count","_useChildrenWithIndex","contextValue","isHorizontal","defaultWidth","_jsx","StepGroupContext","Provider","value","BaseBox","getStyledProps","display","padding","overflowX","flexDirection","metaAttribute","name","MetaConstants","assignWithoutSideEffects","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAUA,IAAMA,sBAAsB,GAAG,SAAzBA,sBAAsBA,CAAAC,IAAA,EAOvB;AAAA,EAAA,IANHC,aAAa,GAAAD,IAAA,CAAbC,aAAa;IACbC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;AACLC,IAAAA,oBAAoB,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA,CAAA,CAAA;AAKvB,EAAA,IAAAC,aAAA,GAAuEC,YAAY,EAAE;IAA/CC,4BAA4B,GAAAF,aAAA,CAA1DG,4BAA4B,CAAA;EAEpC,IAAIC,UAAU,GAAG,CAAC,CAAA;AAClB,EAAA,IAAMC,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAC5BC,iBAA6C,EAEzB;AAAA,IAAA,IADpBC,mBAAmB,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,CAAC,CAAA;IAEvB,IAAIG,aAAa,GAAG,CAAC,CAAA;AACrB,IAAA,OAAOC,cAAK,CAACC,QAAQ,CAACC,GAAG,CAACR,iBAAiB,EAAE,UAACS,KAAK,EAAEC,KAAK,EAAK;AAC7D,MAAA,IAAMC,WAAW,GAAGC,cAAc,CAACH,KAAK,CAAC,CAAA;AACzC,MAAA,IAAIE,WAAW,KAAKE,YAAY,CAACC,QAAQ,EAAE;AACzC,QAAA,oBAAOR,cAAK,CAACS,YAAY,CAACN,KAAK,EAAE;UAC/BO,MAAM,EAAEX,aA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ACA,IAAMH,SAAS,gBAAGqC,wBAAwB,CAAChC,UAAU,EAAE;EACrDb,WAAW,EAAEE,YAAY,CAACM,SAAS;EACnCsC,WAAW,EAAE5C,YAAY,CAACM,SAAAA;AAC5B,CAAC;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
var StepGroupContext = /*#__PURE__*/React__default.createContext({
|
|
4
|
+
itemsInGroupCount: 0,
|
|
5
|
+
totalItemsInParentGroupCount: 0,
|
|
6
|
+
size: 'medium',
|
|
7
|
+
orientation: 'vertical'
|
|
8
|
+
});
|
|
9
|
+
var useStepGroup = function useStepGroup() {
|
|
10
|
+
var stepGroupContext = React__default.useContext(StepGroupContext);
|
|
11
|
+
return stepGroupContext;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { StepGroupContext, useStepGroup };
|
|
15
|
+
//# sourceMappingURL=StepGroupContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepGroupContext.js","sources":["../../../../../../src/components/StepGroup/StepGroupContext.tsx"],"sourcesContent":["import React from 'react';\nimport type { StepGroupContextType } from './types';\n\nconst StepGroupContext = React.createContext<StepGroupContextType>({\n itemsInGroupCount: 0,\n totalItemsInParentGroupCount: 0,\n size: 'medium',\n orientation: 'vertical',\n});\n\nconst useStepGroup = (): StepGroupContextType => {\n const stepGroupContext = React.useContext(StepGroupContext);\n\n return stepGroupContext;\n};\n\nexport { useStepGroup, StepGroupContext };\n"],"names":["StepGroupContext","React","createContext","itemsInGroupCount","totalItemsInParentGroupCount","size","orientation","useStepGroup","stepGroupContext","useContext"],"mappings":";;AAGA,IAAMA,gBAAgB,gBAAGC,cAAK,CAACC,aAAa,CAAuB;AACjEC,EAAAA,iBAAiB,EAAE,CAAC;AACpBC,EAAAA,4BAA4B,EAAE,CAAC;AAC/BC,EAAAA,IAAI,EAAE,QAAQ;AACdC,EAAAA,WAAW,EAAE,UAAA;AACf,CAAC,EAAC;AAEF,IAAMC,YAAY,GAAG,SAAfA,YAAYA,GAA+B;AAC/C,EAAA,IAAMC,gBAAgB,GAAGP,cAAK,CAACQ,UAAU,CAACT,gBAAgB,CAAC,CAAA;AAE3D,EAAA,OAAOQ,gBAAgB,CAAA;AACzB;;;;"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { StepLine } from './StepLine.web.js';
|
|
5
|
+
import { useStepGroup } from './StepGroupContext.js';
|
|
6
|
+
import { componentIds } from './componentIds.js';
|
|
7
|
+
import { stepItemHeaderTokens, itemLineGap } from './tokens.js';
|
|
8
|
+
import '../Box/index.js';
|
|
9
|
+
import '../Typography/index.js';
|
|
10
|
+
import '../../utils/assignWithoutSideEffects/index.js';
|
|
11
|
+
import '../Box/BaseBox/index.js';
|
|
12
|
+
import '../../utils/index.js';
|
|
13
|
+
import '../../tokens/global/index.js';
|
|
14
|
+
import '../../utils/getFocusRingStyles/index.js';
|
|
15
|
+
import getIn from '../../utils/lodashButBetter/get.js';
|
|
16
|
+
import '../../utils/logger/index.js';
|
|
17
|
+
import '../../utils/metaAttribute/index.js';
|
|
18
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
19
|
+
import { makeSpace } from '../../utils/makeSpace/makeSpace.js';
|
|
20
|
+
import { getFocusRingStyles } from '../../utils/getFocusRingStyles/getFocusRingStyles.web.js';
|
|
21
|
+
import { throwBladeError } from '../../utils/logger/logger.js';
|
|
22
|
+
import { Box } from '../Box/Box.js';
|
|
23
|
+
import { Text } from '../Typography/Text/Text.js';
|
|
24
|
+
import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
|
|
25
|
+
import { makeSize } from '../../utils/makeSize/makeSize.js';
|
|
26
|
+
import { size } from '../../tokens/global/size.js';
|
|
27
|
+
import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.web.js';
|
|
28
|
+
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
|
|
29
|
+
import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
30
|
+
|
|
31
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
32
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
33
|
+
var InteractiveItemHeaderBox = /*#__PURE__*/styled.button.withConfig({
|
|
34
|
+
displayName: "StepItemweb__InteractiveItemHeaderBox",
|
|
35
|
+
componentId: "x6btk4-0"
|
|
36
|
+
})(function (props) {
|
|
37
|
+
return {
|
|
38
|
+
padding: "".concat(makeSpace(getIn(props.theme, props.paddingY)), " ").concat(makeSpace(getIn(props.theme, props.paddingX))),
|
|
39
|
+
cursor: 'pointer',
|
|
40
|
+
display: 'inline-block',
|
|
41
|
+
textDecoration: 'none',
|
|
42
|
+
border: 'none',
|
|
43
|
+
textAlign: 'inherit',
|
|
44
|
+
backgroundColor: props.isSelected ? props.theme.colors.interactive.background.primary.faded : props.theme.colors.transparent,
|
|
45
|
+
borderRadius: props.theme.border.radius.medium,
|
|
46
|
+
width: '100%',
|
|
47
|
+
transition: "background-color ".concat(props.theme.motion.duration.xquick, " ").concat(props.theme.motion.easing.standard.effective),
|
|
48
|
+
':hover': {
|
|
49
|
+
backgroundColor: props.isSelected ? props.theme.colors.interactive.background.primary.fadedHighlighted : props.theme.colors.interactive.background.gray.fadedHighlighted
|
|
50
|
+
},
|
|
51
|
+
':focus-visible': _objectSpread({}, getFocusRingStyles({
|
|
52
|
+
theme: props.theme
|
|
53
|
+
}))
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
var getStepTypeFromIndex = function getStepTypeFromIndex(_ref) {
|
|
57
|
+
var _index = _ref._index,
|
|
58
|
+
_nestingLevel = _ref._nestingLevel,
|
|
59
|
+
itemsCount = _ref.itemsCount;
|
|
60
|
+
if (_nestingLevel === 0) {
|
|
61
|
+
return 'default';
|
|
62
|
+
}
|
|
63
|
+
if (itemsCount === 1) {
|
|
64
|
+
return 'single-item';
|
|
65
|
+
}
|
|
66
|
+
if (_index === 0) {
|
|
67
|
+
return 'start';
|
|
68
|
+
}
|
|
69
|
+
if (_index === itemsCount - 1) {
|
|
70
|
+
return 'end';
|
|
71
|
+
}
|
|
72
|
+
return 'middle';
|
|
73
|
+
};
|
|
74
|
+
var _StepItem = function _StepItem(_ref2) {
|
|
75
|
+
var title = _ref2.title,
|
|
76
|
+
timestamp = _ref2.timestamp,
|
|
77
|
+
description = _ref2.description,
|
|
78
|
+
_ref2$stepProgress = _ref2.stepProgress,
|
|
79
|
+
stepProgress = _ref2$stepProgress === void 0 ? 'none' : _ref2$stepProgress,
|
|
80
|
+
marker = _ref2.marker,
|
|
81
|
+
trailing = _ref2.trailing,
|
|
82
|
+
isSelected = _ref2.isSelected,
|
|
83
|
+
href = _ref2.href,
|
|
84
|
+
target = _ref2.target,
|
|
85
|
+
onClick = _ref2.onClick,
|
|
86
|
+
children = _ref2.children,
|
|
87
|
+
_ref2$_index = _ref2._index,
|
|
88
|
+
_index = _ref2$_index === void 0 ? 0 : _ref2$_index,
|
|
89
|
+
_ref2$_totalIndex = _ref2._totalIndex,
|
|
90
|
+
_totalIndex = _ref2$_totalIndex === void 0 ? 0 : _ref2$_totalIndex,
|
|
91
|
+
_ref2$_nestingLevel = _ref2._nestingLevel,
|
|
92
|
+
_nestingLevel = _ref2$_nestingLevel === void 0 ? 0 : _ref2$_nestingLevel;
|
|
93
|
+
var _useStepGroup = useStepGroup(),
|
|
94
|
+
itemsCount = _useStepGroup.itemsInGroupCount,
|
|
95
|
+
totalItemsInParentGroupCount = _useStepGroup.totalItemsInParentGroupCount,
|
|
96
|
+
orientation = _useStepGroup.orientation,
|
|
97
|
+
size$1 = _useStepGroup.size;
|
|
98
|
+
var stepType = React__default.useMemo(function () {
|
|
99
|
+
return getStepTypeFromIndex({
|
|
100
|
+
_index: _index,
|
|
101
|
+
_nestingLevel: _nestingLevel,
|
|
102
|
+
itemsCount: itemsCount
|
|
103
|
+
});
|
|
104
|
+
}, [_index, _nestingLevel, itemsCount]);
|
|
105
|
+
var itemRef = React__default.useRef(null);
|
|
106
|
+
var isFirstItem = _totalIndex === 0;
|
|
107
|
+
var isLastItem = _totalIndex === totalItemsInParentGroupCount - 1;
|
|
108
|
+
var isInteractive = Boolean(href) || Boolean(onClick);
|
|
109
|
+
var isVertical = orientation === 'vertical';
|
|
110
|
+
if (false) {
|
|
111
|
+
if (trailing && orientation === 'horizontal') {
|
|
112
|
+
throwBladeError({
|
|
113
|
+
message: 'trailing is not allowed in horizontal StepGroup',
|
|
114
|
+
moduleName: 'StepItem'
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (_nestingLevel >= 1 && orientation === 'horizontal') {
|
|
118
|
+
throwBladeError({
|
|
119
|
+
message: 'Nested StepGroup components are not allowed in horizontal orientation',
|
|
120
|
+
moduleName: 'StepItem'
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
var stepItemHeaderJSX = /*#__PURE__*/jsxs(Box, {
|
|
125
|
+
display: "flex",
|
|
126
|
+
flexDirection: "row",
|
|
127
|
+
justifyContent: "space-between",
|
|
128
|
+
gap: "spacing.4",
|
|
129
|
+
children: [/*#__PURE__*/jsxs(Box, {
|
|
130
|
+
children: [/*#__PURE__*/jsx(Text, {
|
|
131
|
+
size: stepItemHeaderTokens[size$1].title,
|
|
132
|
+
color: "surface.text.gray.subtle",
|
|
133
|
+
weight: "semibold",
|
|
134
|
+
children: title
|
|
135
|
+
}), /*#__PURE__*/jsx(Text, {
|
|
136
|
+
size: stepItemHeaderTokens[size$1].timestamp,
|
|
137
|
+
marginY: "spacing.2",
|
|
138
|
+
color: "surface.text.gray.muted",
|
|
139
|
+
variant: "caption",
|
|
140
|
+
children: timestamp
|
|
141
|
+
}), /*#__PURE__*/jsx(Text, {
|
|
142
|
+
size: stepItemHeaderTokens[size$1].description,
|
|
143
|
+
color: "surface.text.gray.muted",
|
|
144
|
+
children: description
|
|
145
|
+
})]
|
|
146
|
+
}), /*#__PURE__*/jsx(Box, {
|
|
147
|
+
children: trailing
|
|
148
|
+
})]
|
|
149
|
+
});
|
|
150
|
+
var stepItemHeaderPaddings = {
|
|
151
|
+
paddingY: 'spacing.3',
|
|
152
|
+
paddingX: 'spacing.4'
|
|
153
|
+
};
|
|
154
|
+
return /*#__PURE__*/jsxs(BaseBox, _objectSpread(_objectSpread({
|
|
155
|
+
display: "flex",
|
|
156
|
+
flexDirection: isVertical ? 'row' : 'column',
|
|
157
|
+
gap: itemLineGap[size$1],
|
|
158
|
+
className: "step-item step-index-".concat(_index, " step-nesting-level-").concat(_nestingLevel),
|
|
159
|
+
textAlign: isVertical ? 'left' : 'center',
|
|
160
|
+
alignItems: isVertical ? undefined : 'center',
|
|
161
|
+
minWidth: isVertical ? undefined : "min(".concat(makeSize(size['120']), ", 100%)"),
|
|
162
|
+
width: isVertical ? '100%' : undefined,
|
|
163
|
+
flex: isVertical ? undefined : '1'
|
|
164
|
+
}, metaAttribute({
|
|
165
|
+
name: MetaConstants.StepItem
|
|
166
|
+
})), {}, {
|
|
167
|
+
ref: itemRef,
|
|
168
|
+
children: [/*#__PURE__*/jsx(StepLine, {
|
|
169
|
+
shouldShowStartBranch: !isFirstItem,
|
|
170
|
+
shouldShowEndBranch: !isLastItem,
|
|
171
|
+
stepType: stepType,
|
|
172
|
+
marker: marker,
|
|
173
|
+
stepProgress: stepProgress
|
|
174
|
+
}), /*#__PURE__*/jsxs(Box, {
|
|
175
|
+
marginTop: "spacing.3",
|
|
176
|
+
flex: "1",
|
|
177
|
+
marginRight: isVertical ? undefined : undefined,
|
|
178
|
+
children: [isInteractive ? /*#__PURE__*/jsx(InteractiveItemHeaderBox, _objectSpread(_objectSpread({}, stepItemHeaderPaddings), {}, {
|
|
179
|
+
as: href ? 'a' : 'button',
|
|
180
|
+
href: href,
|
|
181
|
+
target: target,
|
|
182
|
+
isSelected: isSelected,
|
|
183
|
+
onClick: onClick,
|
|
184
|
+
children: stepItemHeaderJSX
|
|
185
|
+
})) : /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, stepItemHeaderPaddings), {}, {
|
|
186
|
+
children: stepItemHeaderJSX
|
|
187
|
+
})), children ? /*#__PURE__*/jsx(Box, {
|
|
188
|
+
paddingX: "spacing.4",
|
|
189
|
+
paddingY: "spacing.3",
|
|
190
|
+
children: children
|
|
191
|
+
}) : null]
|
|
192
|
+
})]
|
|
193
|
+
}));
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* ## StepItem
|
|
198
|
+
*
|
|
199
|
+
* Component meant to be used inside the StepGroup parent component
|
|
200
|
+
*
|
|
201
|
+
* ### Usage
|
|
202
|
+
*
|
|
203
|
+
* ```jsx
|
|
204
|
+
* <StepGroup orientation="vertical" size="medium">
|
|
205
|
+
* <StepItem
|
|
206
|
+
* title="Personal Details"
|
|
207
|
+
* timestamp="Thu 15th Oct'23 | 12:00pm"
|
|
208
|
+
* description="Fill your personal details here"
|
|
209
|
+
* marker={<StepItemIndicator color="negative" />}
|
|
210
|
+
* />
|
|
211
|
+
* </StepGroup>
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
214
|
+
* ---
|
|
215
|
+
*
|
|
216
|
+
* Checkout {@link https://blade.razorpay.com/?path=/docs/components-stepgroup--docs StepGroup Documentation}
|
|
217
|
+
*/
|
|
218
|
+
var StepItem = /*#__PURE__*/assignWithoutSideEffects(_StepItem, {
|
|
219
|
+
componentId: componentIds.StepItem,
|
|
220
|
+
displayName: componentIds.StepItem
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
export { StepItem, StepLine };
|
|
224
|
+
//# sourceMappingURL=StepItem.web.js.map
|