@razorpay/blade 12.0.3 → 12.1.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/Button/IconButton/IconButton.js +1 -1
- package/build/lib/native/components/Button/IconButton/IconButton.js.map +1 -1
- package/build/lib/native/components/Radio/Radio.js +1 -1
- package/build/lib/native/components/Radio/Radio.js.map +1 -1
- package/build/lib/native/components/Radio/RadioGroup/RadioGroup.js.map +1 -1
- package/build/lib/native/components/Radio/RadioGroup/useRadioGroup.js +1 -1
- package/build/lib/native/components/Radio/RadioGroup/useRadioGroup.js.map +1 -1
- package/build/lib/native/components/Radio/useRadio.js.map +1 -1
- package/build/lib/native/utils/useControllable.js +1 -1
- package/build/lib/native/utils/useControllable.js.map +1 -1
- package/build/lib/web/development/components/BottomSheet/BottomSheet.web.js +17 -1
- package/build/lib/web/development/components/BottomSheet/BottomSheet.web.js.map +1 -1
- package/build/lib/web/development/components/Button/IconButton/IconButton.js +2 -2
- package/build/lib/web/development/components/Button/IconButton/IconButton.js.map +1 -1
- package/build/lib/web/development/components/Button/IconButton/StyledIconButton.web.js +7 -4
- package/build/lib/web/development/components/Button/IconButton/StyledIconButton.web.js.map +1 -1
- package/build/lib/web/development/components/ButtonGroup/ButtonGroup.web.js +7 -17
- package/build/lib/web/development/components/ButtonGroup/ButtonGroup.web.js.map +1 -1
- package/build/lib/web/development/components/Drawer/Drawer.web.js +6 -4
- package/build/lib/web/development/components/Drawer/Drawer.web.js.map +1 -1
- package/build/lib/web/development/components/Radio/Radio.js +3 -2
- package/build/lib/web/development/components/Radio/Radio.js.map +1 -1
- package/build/lib/web/development/components/Radio/RadioGroup/RadioGroup.js.map +1 -1
- package/build/lib/web/development/components/Radio/RadioGroup/useRadioGroup.js +7 -6
- package/build/lib/web/development/components/Radio/RadioGroup/useRadioGroup.js.map +1 -1
- package/build/lib/web/development/components/Radio/useRadio.js.map +1 -1
- package/build/lib/web/development/components/SideNav/SideNav.web.js +22 -8
- package/build/lib/web/development/components/SideNav/SideNav.web.js.map +1 -1
- package/build/lib/web/development/components/SideNav/SideNavItems/SideNavLink.web.js +14 -7
- package/build/lib/web/development/components/SideNav/SideNavItems/SideNavLink.web.js.map +1 -1
- package/build/lib/web/development/components/Tooltip/Tooltip.web.js +7 -1
- package/build/lib/web/development/components/Tooltip/Tooltip.web.js.map +1 -1
- package/build/lib/web/development/components/Tooltip/componentIds.js +6 -0
- package/build/lib/web/development/components/Tooltip/componentIds.js.map +1 -0
- package/build/lib/web/development/components/TopNav/TabNav/TabNavItem.web.js +1 -1
- package/build/lib/web/development/components/TopNav/TabNav/TabNavItem.web.js.map +1 -1
- package/build/lib/web/development/components/TopNav/TopNav.web.js +1 -1
- package/build/lib/web/development/components/TopNav/TopNav.web.js.map +1 -1
- package/build/lib/web/development/utils/useControllable.js +2 -1
- package/build/lib/web/development/utils/useControllable.js.map +1 -1
- package/build/lib/web/production/components/BottomSheet/BottomSheet.web.js +17 -1
- package/build/lib/web/production/components/BottomSheet/BottomSheet.web.js.map +1 -1
- package/build/lib/web/production/components/Button/IconButton/IconButton.js +2 -2
- package/build/lib/web/production/components/Button/IconButton/IconButton.js.map +1 -1
- package/build/lib/web/production/components/Button/IconButton/StyledIconButton.web.js +7 -4
- package/build/lib/web/production/components/Button/IconButton/StyledIconButton.web.js.map +1 -1
- package/build/lib/web/production/components/ButtonGroup/ButtonGroup.web.js +7 -17
- package/build/lib/web/production/components/ButtonGroup/ButtonGroup.web.js.map +1 -1
- package/build/lib/web/production/components/Drawer/Drawer.web.js +6 -4
- package/build/lib/web/production/components/Drawer/Drawer.web.js.map +1 -1
- package/build/lib/web/production/components/Radio/Radio.js +3 -2
- package/build/lib/web/production/components/Radio/Radio.js.map +1 -1
- package/build/lib/web/production/components/Radio/RadioGroup/RadioGroup.js.map +1 -1
- package/build/lib/web/production/components/Radio/RadioGroup/useRadioGroup.js +7 -6
- package/build/lib/web/production/components/Radio/RadioGroup/useRadioGroup.js.map +1 -1
- package/build/lib/web/production/components/Radio/useRadio.js.map +1 -1
- package/build/lib/web/production/components/SideNav/SideNav.web.js +22 -8
- package/build/lib/web/production/components/SideNav/SideNav.web.js.map +1 -1
- package/build/lib/web/production/components/SideNav/SideNavItems/SideNavLink.web.js +14 -7
- package/build/lib/web/production/components/SideNav/SideNavItems/SideNavLink.web.js.map +1 -1
- package/build/lib/web/production/components/Tooltip/Tooltip.web.js +7 -1
- package/build/lib/web/production/components/Tooltip/Tooltip.web.js.map +1 -1
- package/build/lib/web/production/components/Tooltip/componentIds.js +6 -0
- package/build/lib/web/production/components/Tooltip/componentIds.js.map +1 -0
- package/build/lib/web/production/components/TopNav/TabNav/TabNavItem.web.js +1 -1
- package/build/lib/web/production/components/TopNav/TabNav/TabNavItem.web.js.map +1 -1
- package/build/lib/web/production/components/TopNav/TopNav.web.js +1 -1
- package/build/lib/web/production/components/TopNav/TopNav.web.js.map +1 -1
- package/build/lib/web/production/utils/useControllable.js +2 -1
- package/build/lib/web/production/utils/useControllable.js.map +1 -1
- package/build/types/components/index.d.ts +1168 -45
- package/build/types/components/index.native.d.ts +345 -4
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.js","sources":["../../../../../../../src/components/Button/IconButton/IconButton.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable react/display-name */\nimport React from 'react';\nimport type { GestureResponderEvent } from 'react-native';\nimport StyledIconButton from './StyledIconButton';\nimport type { IconComponent } from '~components/Icons';\nimport type { BladeElementRef, DataAnalyticsAttribute } from '~utils/types';\nimport type { BladeCommonEvents } from '~components/types';\nimport type { Platform } from '~utils';\nimport type { SubtleOrIntense } from '~tokens/theme/theme';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype IconButtonProps = {\n /**\n * Icon component to be rendered, eg. `CloseIcon`\n */\n icon: IconComponent;\n\n /**\n * Icon size\n *\n * @default 'medium'\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * Icon contrast\n *\n * @default 'intense'\n */\n emphasis?: SubtleOrIntense;\n\n /**\n * Sets aria-label to help users know what the action does, eg 'Dismiss alert'\n */\n accessibilityLabel: string;\n\n /**\n * Disabled state for IconButton\n */\n isDisabled?: boolean;\n\n /**\n * Sets tabindex property on button element\n */\n _tabIndex?: number;\n} & DataAnalyticsAttribute &\n BladeCommonEvents &\n Platform.Select<{\n web: {\n onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /**\n * This changes the hover interaction to highlight icon more\n *\n * **Only available on web currently**\n */\n isHighlighted?: boolean;\n };\n native: {\n onClick: (event: GestureResponderEvent) => void;\n isHighlighted?: undefined;\n };\n }>;\n\n/**\n * Component for making clickable icons with transparent background.\n * For other cases please use `Button` component with `icon` prop.\n */\nconst _IconButton: React.ForwardRefRenderFunction<BladeElementRef, IconButtonProps> = (\n {\n icon,\n onClick,\n size = 'medium',\n emphasis = 'intense',\n accessibilityLabel,\n isDisabled,\n onBlur,\n onFocus,\n onMouseLeave,\n onMouseMove,\n onPointerDown,\n onPointerEnter,\n onTouchEnd,\n onTouchStart,\n isHighlighted,\n _tabIndex,\n ...rest\n },\n ref,\n) => {\n return (\n <StyledIconButton\n ref={ref as any}\n onClick={onClick}\n emphasis={emphasis}\n size={size}\n icon={icon}\n tabIndex={_tabIndex}\n accessibilityLabel={accessibilityLabel}\n isDisabled={isDisabled}\n isHighlighted={isHighlighted}\n onBlur={onBlur}\n onFocus={onFocus}\n onMouseLeave={onMouseLeave}\n onMouseMove={onMouseMove}\n onPointerDown={onPointerDown}\n onPointerEnter={onPointerEnter}\n onTouchEnd={onTouchEnd}\n onTouchStart={onTouchStart}\n {...makeAnalyticsAttribute(rest)}\n />\n );\n};\n\nconst IconButton = React.forwardRef(_IconButton);\n\nexport type { IconButtonProps };\nexport { IconButton };\n"],"names":["_IconButton","_ref","ref","icon","onClick","_ref$size","size","_ref$emphasis","emphasis","accessibilityLabel","isDisabled","onBlur","onFocus","onMouseLeave","onMouseMove","onPointerDown","onPointerEnter","onTouchEnd","onTouchStart","isHighlighted","_tabIndex","rest","_objectWithoutProperties","_excluded","_jsx","StyledIconButton","_objectSpread","tabIndex","makeAnalyticsAttribute","IconButton","React","forwardRef"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"IconButton.js","sources":["../../../../../../../src/components/Button/IconButton/IconButton.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable react/display-name */\nimport React from 'react';\nimport type { GestureResponderEvent } from 'react-native';\nimport StyledIconButton from './StyledIconButton';\nimport type { IconComponent } from '~components/Icons';\nimport type { BladeElementRef, DataAnalyticsAttribute } from '~utils/types';\nimport type { BladeCommonEvents } from '~components/types';\nimport type { Platform } from '~utils';\nimport type { SubtleOrIntense } from '~tokens/theme/theme';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\n\ntype IconButtonProps = {\n /**\n * Icon component to be rendered, eg. `CloseIcon`\n */\n icon: IconComponent;\n\n /**\n * Icon size\n *\n * @default 'medium'\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * Icon contrast\n *\n * @default 'intense'\n */\n emphasis?: SubtleOrIntense;\n\n /**\n * Sets aria-label to help users know what the action does, eg 'Dismiss alert'\n */\n accessibilityLabel: string;\n\n /**\n * Disabled state for IconButton\n */\n isDisabled?: boolean;\n\n /**\n * Sets tabindex property on button element\n */\n _tabIndex?: number;\n} & DataAnalyticsAttribute &\n BladeCommonEvents &\n StyledPropsBlade &\n Platform.Select<{\n web: {\n onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /**\n * This changes the hover interaction to highlight icon more\n *\n * **Only available on web currently**\n */\n isHighlighted?: boolean;\n };\n native: {\n onClick: (event: GestureResponderEvent) => void;\n isHighlighted?: undefined;\n };\n }>;\n\n/**\n * Component for making clickable icons with transparent background.\n * For other cases please use `Button` component with `icon` prop.\n */\nconst _IconButton: React.ForwardRefRenderFunction<BladeElementRef, IconButtonProps> = (\n {\n icon,\n onClick,\n size = 'medium',\n emphasis = 'intense',\n accessibilityLabel,\n isDisabled,\n onBlur,\n onFocus,\n onMouseLeave,\n onMouseMove,\n onPointerDown,\n onPointerEnter,\n onTouchEnd,\n onTouchStart,\n isHighlighted,\n _tabIndex,\n ...rest\n },\n ref,\n) => {\n return (\n <StyledIconButton\n ref={ref as any}\n onClick={onClick}\n emphasis={emphasis}\n size={size}\n icon={icon}\n tabIndex={_tabIndex}\n accessibilityLabel={accessibilityLabel}\n isDisabled={isDisabled}\n isHighlighted={isHighlighted}\n onBlur={onBlur}\n onFocus={onFocus}\n onMouseLeave={onMouseLeave}\n onMouseMove={onMouseMove}\n onPointerDown={onPointerDown}\n onPointerEnter={onPointerEnter}\n onTouchEnd={onTouchEnd}\n onTouchStart={onTouchStart}\n {...makeAnalyticsAttribute(rest)}\n {...rest}\n />\n );\n};\n\nconst IconButton = React.forwardRef(_IconButton);\n\nexport type { IconButtonProps };\nexport { IconButton };\n"],"names":["_IconButton","_ref","ref","icon","onClick","_ref$size","size","_ref$emphasis","emphasis","accessibilityLabel","isDisabled","onBlur","onFocus","onMouseLeave","onMouseMove","onPointerDown","onPointerEnter","onTouchEnd","onTouchStart","isHighlighted","_tabIndex","rest","_objectWithoutProperties","_excluded","_jsx","StyledIconButton","_objectSpread","tabIndex","makeAnalyticsAttribute","IconButton","React","forwardRef"],"mappings":";;;;;;;;;;;AAkEA;AACA;AACA;AACA;AACA,IAAMA,WAA6E,GAAG,SAAhFA,WAA6EA,CAAAC,IAAA,EAoBjFC,GAAG,EACA;AAAA,EAAA,IAnBDC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IACJC,OAAO,GAAAH,IAAA,CAAPG,OAAO;IAAAC,SAAA,GAAAJ,IAAA,CACPK,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAG,KAAA,CAAA,GAAA,QAAQ,GAA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AAC7BC,IAAAA,cAAc,EAAEA,cAAe;AAC/BC,IAAAA,UAAU,EAAEA,UAAW;AACvBC,IAAAA,YAAY,EAAEA,YAAAA;AAAa,GAAA,EACvBU,sBAAsB,CAACP,IAAI,CAAC,CAC5BA,EAAAA,IAAI,CACT,CAAC,CAAA;AAEN,CAAC,CAAA;AAED,IAAMQ,UAAU,gBAAGC,cAAK,CAACC,UAAU,CAAC/B,WAAW;;;;"}
|
|
@@ -11,7 +11,9 @@ import '../../../utils/getFocusRingStyles/index.js';
|
|
|
11
11
|
import '../../../utils/logger/index.js';
|
|
12
12
|
import getIn from '../../../utils/lodashButBetter/get.js';
|
|
13
13
|
import '../../../utils/makeAnalyticsAttribute/index.js';
|
|
14
|
+
import '../../Box/styledProps/index.js';
|
|
14
15
|
import { jsx } from 'react/jsx-runtime';
|
|
16
|
+
import { useStyledProps } from '../../Box/styledProps/useStyledProps.js';
|
|
15
17
|
import { throwBladeError } from '../../../utils/logger/logger.js';
|
|
16
18
|
import { makeSize } from '../../../utils/makeSize/makeSize.js';
|
|
17
19
|
import { castWebType } from '../../../utils/platform/castUtils.js';
|
|
@@ -32,6 +34,7 @@ var StyledButton = /*#__PURE__*/styled.button.withConfig({
|
|
|
32
34
|
var theme = props.theme,
|
|
33
35
|
emphasis = props.emphasis;
|
|
34
36
|
var motionToken = theme.motion;
|
|
37
|
+
var styledPropsCSSObject = useStyledProps(props);
|
|
35
38
|
var emphasisColor = emphasis === 'intense' ? 'gray' : 'staticWhite';
|
|
36
39
|
if (true) {
|
|
37
40
|
if (props.$size === 'large' && props.$isHighlighted) {
|
|
@@ -42,7 +45,7 @@ var StyledButton = /*#__PURE__*/styled.button.withConfig({
|
|
|
42
45
|
return null;
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
|
-
return {
|
|
48
|
+
return _objectSpread({
|
|
46
49
|
border: 'none',
|
|
47
50
|
cursor: props.disabled ? 'not-allowed' : 'pointer',
|
|
48
51
|
padding: 0,
|
|
@@ -71,7 +74,7 @@ var StyledButton = /*#__PURE__*/styled.button.withConfig({
|
|
|
71
74
|
'&:active': {
|
|
72
75
|
color: theme.colors.interactive.icon[emphasisColor].subtle
|
|
73
76
|
}
|
|
74
|
-
};
|
|
77
|
+
}, styledPropsCSSObject);
|
|
75
78
|
});
|
|
76
79
|
var StyledIconButton = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
77
80
|
var Icon = _ref.icon,
|
|
@@ -92,7 +95,7 @@ var StyledIconButton = /*#__PURE__*/React__default.forwardRef(function (_ref, re
|
|
|
92
95
|
onTouchStart = _ref.onTouchStart,
|
|
93
96
|
tabIndex = _ref.tabIndex,
|
|
94
97
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
95
|
-
return /*#__PURE__*/jsx(StyledButton, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
98
|
+
return /*#__PURE__*/jsx(StyledButton, _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
96
99
|
ref: ref,
|
|
97
100
|
onClick: castWebType(onClick),
|
|
98
101
|
emphasis: emphasis,
|
|
@@ -114,7 +117,7 @@ var StyledIconButton = /*#__PURE__*/React__default.forwardRef(function (_ref, re
|
|
|
114
117
|
})), metaAttribute({
|
|
115
118
|
name: MetaConstants.IconButton,
|
|
116
119
|
testID: testID
|
|
117
|
-
})), makeAnalyticsAttribute(rest)), {}, {
|
|
120
|
+
})), makeAnalyticsAttribute(rest)), rest), {}, {
|
|
118
121
|
children: /*#__PURE__*/jsx(Icon, {
|
|
119
122
|
size: size,
|
|
120
123
|
color: isDisabled ? 'interactive.icon.gray.disabled' : 'currentColor'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledIconButton.web.js","sources":["../../../../../../../src/components/Button/IconButton/StyledIconButton.web.tsx"],"sourcesContent":["/* eslint-disable react/display-name */\nimport styled from 'styled-components';\nimport type { ReactElement } from 'react';\nimport React from 'react';\nimport type { StyledIconButtonProps } from './types';\nimport { highlightedButtonSizeMap, highlightedHoverColorMap } from './tokens';\nimport { castWebType, makeSize } from '~utils';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport type { SubtleOrIntense } from '~tokens/theme/theme';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { makeMotionTime } from '~utils/makeMotionTime';\nimport { getFocusRingStyles } from '~utils/getFocusRingStyles';\nimport { throwBladeError } from '~utils/logger';\nimport getIn from '~utils/lodashButBetter/get';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype StyledButtonProps = {\n emphasis: SubtleOrIntense;\n $isHighlighted: StyledIconButtonProps['isHighlighted'];\n $size: StyledIconButtonProps['size'];\n};\n\nconst StyledButton = styled.button<StyledButtonProps>((props) => {\n const { theme, emphasis } = props;\n const motionToken = theme.motion;\n
|
|
1
|
+
{"version":3,"file":"StyledIconButton.web.js","sources":["../../../../../../../src/components/Button/IconButton/StyledIconButton.web.tsx"],"sourcesContent":["/* eslint-disable react/display-name */\nimport styled from 'styled-components';\nimport type { ReactElement } from 'react';\nimport React from 'react';\nimport type { StyledIconButtonProps } from './types';\nimport { highlightedButtonSizeMap, highlightedHoverColorMap } from './tokens';\nimport { castWebType, makeSize } from '~utils';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport type { SubtleOrIntense } from '~tokens/theme/theme';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { makeMotionTime } from '~utils/makeMotionTime';\nimport { getFocusRingStyles } from '~utils/getFocusRingStyles';\nimport { throwBladeError } from '~utils/logger';\nimport getIn from '~utils/lodashButBetter/get';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport { useStyledProps } from '~components/Box/styledProps';\n\ntype StyledButtonProps = {\n emphasis: SubtleOrIntense;\n $isHighlighted: StyledIconButtonProps['isHighlighted'];\n $size: StyledIconButtonProps['size'];\n};\n\nconst StyledButton = styled.button<StyledButtonProps>((props) => {\n const { theme, emphasis } = props;\n const motionToken = theme.motion;\n const styledPropsCSSObject = useStyledProps(props);\n const emphasisColor = emphasis === 'intense' ? 'gray' : 'staticWhite';\n\n if (__DEV__) {\n if (props.$size === 'large' && props.$isHighlighted) {\n throwBladeError({\n moduleName: 'IconButton',\n message: 'size large is not allowed with isHighlighted true',\n });\n return null;\n }\n }\n\n return {\n border: 'none',\n cursor: props.disabled ? 'not-allowed' : 'pointer',\n padding: 0,\n height: props.$isHighlighted\n ? // We throw error for size large on top\n makeSize(highlightedButtonSizeMap[props.$size as 'small' | 'medium'])\n : undefined,\n width: props.$isHighlighted\n ? makeSize(highlightedButtonSizeMap[props.$size as 'small' | 'medium'])\n : undefined,\n borderRadius: props.$isHighlighted ? theme.border.radius.round : theme.border.radius.small,\n background: 'transparent',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n color: props.disabled\n ? theme.colors.interactive.icon[emphasisColor].disabled\n : theme.colors.interactive.icon[emphasisColor].muted,\n transitionProperty: 'color, box-shadow',\n transitionDuration: castWebType(makeMotionTime(motionToken.duration.xquick)),\n transitionTimingFunction: motionToken.easing.standard as string,\n\n '&:hover:not([disabled])': {\n color: theme.colors.interactive.icon[emphasisColor].subtle,\n backgroundColor: props.$isHighlighted\n ? getIn(theme.colors, highlightedHoverColorMap[emphasis])\n : 'transparent',\n },\n\n '&:focus-visible': {\n ...getFocusRingStyles({ theme }),\n color: theme.colors.interactive.icon[emphasisColor].subtle,\n },\n\n '&:active': {\n color: theme.colors.interactive.icon[emphasisColor].subtle,\n },\n ...styledPropsCSSObject,\n };\n});\n\nconst StyledIconButton = React.forwardRef<HTMLButtonElement, StyledIconButtonProps>(\n (\n {\n icon: Icon,\n onClick,\n size,\n emphasis,\n accessibilityLabel,\n isDisabled,\n isHighlighted,\n testID,\n onBlur,\n onFocus,\n onMouseLeave,\n onMouseMove,\n onPointerDown,\n onPointerEnter,\n onTouchEnd,\n onTouchStart,\n tabIndex,\n ...rest\n },\n ref,\n ): ReactElement => (\n <StyledButton\n ref={ref}\n onClick={castWebType(onClick)}\n emphasis={emphasis}\n type=\"button\"\n onBlur={onBlur}\n onFocus={onFocus}\n onMouseLeave={onMouseLeave}\n onMouseMove={onMouseMove}\n onPointerDown={onPointerDown}\n onPointerEnter={onPointerEnter}\n onTouchEnd={onTouchEnd}\n onTouchStart={onTouchStart}\n disabled={isDisabled}\n $isHighlighted={isHighlighted}\n $size={size}\n tabIndex={tabIndex}\n {...makeAccessible({ label: accessibilityLabel })}\n {...metaAttribute({ name: MetaConstants.IconButton, testID })}\n {...makeAnalyticsAttribute(rest)}\n {...rest}\n >\n <Icon size={size} color={isDisabled ? 'interactive.icon.gray.disabled' : 'currentColor'} />\n </StyledButton>\n ),\n);\n\nexport default StyledIconButton;\n"],"names":["StyledButton","styled","button","withConfig","displayName","componentId","props","theme","emphasis","motionToken","motion","styledPropsCSSObject","useStyledProps","emphasisColor","$size","$isHighlighted","throwBladeError","moduleName","message","_objectSpread","border","cursor","disabled","padding","height","makeSize","highlightedButtonSizeMap","undefined","width","borderRadius","radius","round","small","background","display","alignItems","justifyContent","color","colors","interactive","icon","muted","transitionProperty","transitionDuration","castWebType","makeMotionTime","duration","xquick","transitionTimingFunction","easing","standard","subtle","backgroundColor","getIn","highlightedHoverColorMap","getFocusRingStyles","StyledIconButton","React","forwardRef","_ref","ref","Icon","onClick","size","accessibilityLabel","isDisabled","isHighlighted","testID","onBlur","onFocus","onMouseLeave","onMouseMove","onPointerDown","onPointerEnter","onTouchEnd","onTouchStart","tabIndex","rest","_objectWithoutProperties","_excluded","_jsx","type","makeAccessible","label","metaAttribute","name","MetaConstants","IconButton","makeAnalyticsAttribute","children"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAMA,YAAY,gBAAGC,MAAM,CAACC,MAAM,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,mCAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAAoB,CAAA,CAAA,UAACC,KAAK,EAAK;AAC/D,EAAA,IAAQC,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,EAAEA,aAAc;AAC7BC,IAAAA,cAAc,EAAEA,cAAe;AAC/BC,IAAAA,UAAU,EAAEA,UAAW;AACvBC,IAAAA,YAAY,EAAEA,YAAa;AAC3BrD,IAAAA,QAAQ,EAAE2C,UAAW;AACrBlD,IAAAA,cAAc,EAAEmD,aAAc;AAC9BpD,IAAAA,KAAK,EAAEiD,IAAK;AACZa,IAAAA,QAAQ,EAAEA,QAAAA;AAAS,GAAA,EACfM,cAAc,CAAC;AAAEC,IAAAA,KAAK,EAAEnB,kBAAAA;GAAoB,CAAC,CAC7CoB,EAAAA,aAAa,CAAC;IAAEC,IAAI,EAAEC,aAAa,CAACC,UAAU;AAAEpB,IAAAA,MAAM,EAANA,MAAAA;AAAO,GAAC,CAAC,CACzDqB,EAAAA,sBAAsB,CAACX,IAAI,CAAC,GAC5BA,IAAI,CAAA,EAAA,EAAA,EAAA;IAAAY,QAAA,eAERT,GAAA,CAACnB,IAAI,EAAA;AAACE,MAAAA,IAAI,EAAEA,IAAK;AAAC1B,MAAAA,KAAK,EAAE4B,UAAU,GAAG,gCAAgC,GAAG,cAAA;KAAiB,CAAA;AAAC,GAAA,CAC/E,CAAC,CAAA;AAAA,CAEnB;;;;"}
|
|
@@ -11,18 +11,16 @@ import '../../utils/assignWithoutSideEffects/index.js';
|
|
|
11
11
|
import '../../utils/index.js';
|
|
12
12
|
import getIn from '../../utils/lodashButBetter/get.js';
|
|
13
13
|
import { getBackgroundColorToken } from '../Button/BaseButton/BaseButton.js';
|
|
14
|
-
import '../../utils/logger/index.js';
|
|
15
|
-
import '../../utils/isValidAllowedChildren/index.js';
|
|
16
14
|
import '../../utils/makeAnalyticsAttribute/index.js';
|
|
15
|
+
import '../../utils/useVerifyAllowedChildren/index.js';
|
|
17
16
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
18
17
|
import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
|
|
19
18
|
import { makeBorderSize } from '../../utils/makeBorderSize/makeBorderSize.js';
|
|
19
|
+
import { useVerifyAllowedChildren } from '../../utils/useVerifyAllowedChildren/useVerifyAllowedChildren.js';
|
|
20
20
|
import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.web.js';
|
|
21
21
|
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
|
|
22
22
|
import { getStyledProps } from '../Box/styledProps/getStyledProps.js';
|
|
23
23
|
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
24
|
-
import { isValidAllowedChildren } from '../../utils/isValidAllowedChildren/isValidAllowedChildren.js';
|
|
25
|
-
import { throwBladeError } from '../../utils/logger/logger.js';
|
|
26
24
|
import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
27
25
|
|
|
28
26
|
var _excluded = ["children", "isDisabled", "size", "color", "variant", "isFullWidth", "testID"];
|
|
@@ -86,6 +84,11 @@ var _ButtonGroup = function _ButtonGroup(_ref3, ref) {
|
|
|
86
84
|
variant: variant,
|
|
87
85
|
isFullWidth: isFullWidth
|
|
88
86
|
};
|
|
87
|
+
useVerifyAllowedChildren({
|
|
88
|
+
allowedComponents: ['Button', 'Dropdown', 'Tooltip', 'Popover'],
|
|
89
|
+
componentName: 'ButtonGroup',
|
|
90
|
+
children: children
|
|
91
|
+
});
|
|
89
92
|
return /*#__PURE__*/jsx(ButtonGroupProvider, {
|
|
90
93
|
value: contextValue,
|
|
91
94
|
children: /*#__PURE__*/jsx(StyledButtonGroup, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
@@ -100,19 +103,6 @@ var _ButtonGroup = function _ButtonGroup(_ref3, ref) {
|
|
|
100
103
|
})), getStyledProps(rest)), makeAnalyticsAttribute(rest)), {}, {
|
|
101
104
|
role: "group",
|
|
102
105
|
children: React__default.Children.map(children, function (child, index) {
|
|
103
|
-
if (true) {
|
|
104
|
-
// throw error if child is not a button or dropdown with button trigger
|
|
105
|
-
/* eslint-disable no-restricted-properties */
|
|
106
|
-
if (!isValidAllowedChildren(child, 'Button') && !(isValidAllowedChildren(child, 'Dropdown') && child.props.children.some(function (c) {
|
|
107
|
-
return isValidAllowedChildren(c, 'DropdownButton');
|
|
108
|
-
}))) {
|
|
109
|
-
throwBladeError({
|
|
110
|
-
moduleName: 'ButtonGroup',
|
|
111
|
-
message: "Only \"Button\" or \"Dropdown\" component with Button trigger are allowed as children."
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
/* eslint-enable no-restricted-properties */
|
|
115
|
-
}
|
|
116
106
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
117
107
|
children: [child, React__default.Children.count(children) - 1 !== index && /*#__PURE__*/jsx(StyledDivider, {
|
|
118
108
|
variant: variant,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonGroup.web.js","sources":["../../../../../../src/components/ButtonGroup/ButtonGroup.web.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"ButtonGroup.web.js","sources":["../../../../../../src/components/ButtonGroup/ButtonGroup.web.tsx"],"sourcesContent":["import React from 'react';\nimport styled from 'styled-components';\nimport type { ButtonGroupProps } from './types';\nimport { StyledButtonGroup } from './StyledButtonGroup';\nimport { ButtonGroupProvider } from './ButtonGroupContext';\nimport BaseBox from '~components/Box/BaseBox';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { makeBorderSize } from '~utils';\nimport type { DotNotationToken } from '~utils/lodashButBetter/get';\nimport getIn from '~utils/lodashButBetter/get';\nimport { getBackgroundColorToken } from '~components/Button/BaseButton/BaseButton';\nimport type { Theme } from '~components/BladeProvider';\nimport type { BladeElementRef } from '~utils/types';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport { useVerifyAllowedChildren } from '~utils/useVerifyAllowedChildren';\n\nconst getDividerColorToken = ({\n color,\n variant,\n isDisabled,\n}: Pick<ButtonGroupProps, 'color' | 'isDisabled' | 'variant'>): DotNotationToken<\n Theme['colors']\n> => {\n if (variant === 'primary') {\n return 'surface.border.gray.subtle';\n }\n\n if (variant === 'secondary') {\n return getBackgroundColorToken({\n property: 'border',\n variant,\n color,\n state: isDisabled ? 'disabled' : 'default',\n });\n }\n\n return 'surface.border.gray.muted';\n};\n\nconst StyledDivider = styled(BaseBox)<Pick<ButtonGroupProps, 'color' | 'isDisabled' | 'variant'>>(\n ({ theme, color, variant, isDisabled }) => {\n return {\n borderWidth: 0,\n borderLeftStyle: 'solid',\n borderLeftWidth: makeBorderSize(theme.border.width.thin),\n alignSelf: 'stretch',\n color: getIn(theme.colors, getDividerColorToken({ color, variant, isDisabled })),\n };\n },\n);\n\nconst _ButtonGroup = (\n {\n children,\n isDisabled = false,\n size = 'medium',\n color = 'primary',\n variant = 'primary',\n isFullWidth = false,\n testID,\n ...rest\n }: ButtonGroupProps,\n ref: React.Ref<BladeElementRef>,\n): React.ReactElement => {\n const contextValue = {\n isDisabled,\n size,\n color,\n variant,\n isFullWidth,\n };\n\n useVerifyAllowedChildren({\n allowedComponents: ['Button', 'Dropdown', 'Tooltip', 'Popover'],\n componentName: 'ButtonGroup',\n children,\n });\n\n return (\n <ButtonGroupProvider value={contextValue}>\n <StyledButtonGroup\n ref={ref as never}\n color={color}\n variant={variant}\n isDisabled={isDisabled}\n isFullWidth={isFullWidth}\n {...metaAttribute({ name: MetaConstants.ButtonGroup, testID })}\n {...getStyledProps(rest)}\n {...makeAnalyticsAttribute(rest)}\n role=\"group\"\n >\n {React.Children.map(children, (child, index) => {\n return (\n <>\n {child}\n {React.Children.count(children) - 1 !== index && (\n <StyledDivider variant={variant} color={color} isDisabled={isDisabled} />\n )}\n </>\n );\n })}\n </StyledButtonGroup>\n </ButtonGroupProvider>\n );\n};\n\n/**\n * ### ButtonGroup Component\n * \n * The ButtonGroup component is used to group related buttons together.\n * \n * ---\n * \n * #### Usage\n * \n * ```jsx\n const App = () => {\n return (\n <ButtonGroup>\n <Button icon={RefreshIcon}>Sync</Button>\n <Button icon={ShareIcon}>Share</Button>\n <Button icon={DownloadIcon}>Download</Button>\n </ButtonGroup>\n );\n }\n * ```\n *\n * ---\n *\n * Checkout {@link https://blade.razorpay.com/?path=/docs/components-buttongroup FileUpload Documentation}\n * \n */\nconst ButtonGroup = assignWithoutSideEffects(React.forwardRef(_ButtonGroup), {\n displayName: 'ButtonGroup',\n componentId: 'ButtonGroup',\n});\n\nexport { ButtonGroup };\nexport type { ButtonGroupProps };\n"],"names":["getDividerColorToken","_ref","color","variant","isDisabled","getBackgroundColorToken","property","state","StyledDivider","styled","BaseBox","withConfig","displayName","componentId","_ref2","theme","borderWidth","borderLeftStyle","borderLeftWidth","makeBorderSize","border","width","thin","alignSelf","getIn","colors","_ButtonGroup","_ref3","ref","children","_ref3$isDisabled","_ref3$size","size","_ref3$color","_ref3$variant","_ref3$isFullWidth","isFullWidth","testID","rest","_objectWithoutProperties","_excluded","contextValue","useVerifyAllowedChildren","allowedComponents","componentName","_jsx","ButtonGroupProvider","value","StyledButtonGroup","_objectSpread","metaAttribute","name","MetaConstants","ButtonGroup","getStyledProps","makeAnalyticsAttribute","role","React","Children","map","child","index","_jsxs","_Fragment","count","assignWithoutSideEffects","forwardRef"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAAAC,IAAA,EAMrB;AAAA,EAAA,IALHC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,OAAO,GAAAF,IAAA,CAAPE,OAAO;IACPC,UAAU,GAAAH,IAAA,CAAVG,UAAU,CAAA;EAIV,IAAID,OAAO,KAAK,SAAS,EAAE;AACzB,IAAA,OAAO,4BAA4B,CAAA;AACrC,GAAA;EAEA,IAAIA,OAAO,KAAK,WAAW,EAAE;AAC3B,IAAA,OAAOE,uBAAuB,CAAC;AAC7BC,MAAAA,QAAQ,EAAE,QAAQ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/metaAttribute/index.js';
|
|
|
17
17
|
import { useId } from '../../utils/useId.js';
|
|
18
18
|
import '../../utils/useVerifyAllowedChildren/index.js';
|
|
19
19
|
import '../../utils/makeAnalyticsAttribute/index.js';
|
|
20
|
+
import { mergeRefs } from '../../utils/useMergeRefs.js';
|
|
20
21
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
21
22
|
import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
|
|
22
23
|
import { castWebType } from '../../utils/platform/castUtils.js';
|
|
@@ -63,7 +64,7 @@ var DrawerOverlay = /*#__PURE__*/styled(FloatingOverlay).withConfig({
|
|
|
63
64
|
transition: "opacity ".concat(makeMotionTime(theme.motion.duration.gentle), " ").concat(castWebType(theme.motion.easing.entrance))
|
|
64
65
|
});
|
|
65
66
|
});
|
|
66
|
-
var _Drawer = function _Drawer(_ref4) {
|
|
67
|
+
var _Drawer = function _Drawer(_ref4, ref) {
|
|
67
68
|
var isOpen = _ref4.isOpen,
|
|
68
69
|
onDismiss = _ref4.onDismiss,
|
|
69
70
|
_ref4$zIndex = _ref4.zIndex,
|
|
@@ -161,7 +162,7 @@ var _Drawer = function _Drawer(_ref4) {
|
|
|
161
162
|
testID: testID
|
|
162
163
|
})), makeAnalyticsAttribute(rest)), {}, {
|
|
163
164
|
zIndex: zIndexState,
|
|
164
|
-
children: [showOverlay
|
|
165
|
+
children: [showOverlay ? /*#__PURE__*/jsx(DrawerOverlay, _objectSpread({
|
|
165
166
|
onClick: function onClick() {
|
|
166
167
|
onDismiss();
|
|
167
168
|
},
|
|
@@ -190,7 +191,7 @@ var _Drawer = function _Drawer(_ref4) {
|
|
|
190
191
|
height: "100%",
|
|
191
192
|
display: "flex",
|
|
192
193
|
flexDirection: "column",
|
|
193
|
-
ref: refs.setFloating,
|
|
194
|
+
ref: mergeRefs(ref, refs.setFloating),
|
|
194
195
|
onKeyDown: function onKeyDown(event) {
|
|
195
196
|
if ((event === null || event === void 0 ? void 0 : event.key) === 'Escape' || (event === null || event === void 0 ? void 0 : event.code) === 'Escape') {
|
|
196
197
|
onDismiss();
|
|
@@ -241,7 +242,8 @@ var _Drawer = function _Drawer(_ref4) {
|
|
|
241
242
|
*
|
|
242
243
|
*
|
|
243
244
|
*/
|
|
244
|
-
var Drawer = /*#__PURE__*/assignWithoutSideEffects(_Drawer, {
|
|
245
|
+
var Drawer = /*#__PURE__*/assignWithoutSideEffects( /*#__PURE__*/React__default.forwardRef(_Drawer), {
|
|
246
|
+
displayName: 'Drawer',
|
|
245
247
|
componentId: drawerComponentIds.Drawer
|
|
246
248
|
});
|
|
247
249
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.web.js","sources":["../../../../../../src/components/Drawer/Drawer.web.tsx"],"sourcesContent":["import {\n FloatingFocusManager,\n FloatingOverlay,\n FloatingPortal,\n useFloating,\n} from '@floating-ui/react';\nimport type { CSSProperties } from 'react';\nimport React from 'react';\nimport styled from 'styled-components';\nimport usePresence from 'use-presence';\nimport { drawerComponentIds } from './drawerComponentIds';\nimport { DrawerContext } from './DrawerContext';\nimport type { DrawerProps } from './types';\nimport BaseBox from '~components/Box/BaseBox';\nimport { castWebType, makeMotionTime, useTheme } from '~utils';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { componentZIndices } from '~utils/componentZIndices';\nimport { useDrawerStack } from '~components/Drawer/StackProvider';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { useId } from '~utils/useId';\nimport { useVerifyAllowedChildren } from '~utils/useVerifyAllowedChildren';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\nconst SHOW_DRAWER = 'show-drawer';\n\nconst AnimatedDrawerContainer = styled(BaseBox)<{\n isFirstDrawerInStack: boolean;\n isVisible: boolean;\n}>(({ theme, isFirstDrawerInStack, isVisible }) => {\n const entranceTransition: CSSProperties['transition'] = `all ${castWebType(\n castWebType(makeMotionTime(theme.motion.duration.xmoderate)),\n )} ${castWebType(theme.motion.easing.entrance)}`;\n\n const exitTransition: CSSProperties['transition'] = `all\n ${castWebType(makeMotionTime(theme.motion.duration.moderate))}\n ${castWebType(theme.motion.easing.exit)}`;\n\n return {\n opacity: isVisible ? 1 : 0,\n transform: isVisible\n ? isFirstDrawerInStack\n ? 'translateX(calc(-100% - 16px))'\n : 'translateX(-100%)'\n : 'translateX(0%)',\n transition: isVisible ? entranceTransition : exitTransition,\n animationFillMode: 'initial',\n };\n});\n\nconst DrawerOverlay = styled(FloatingOverlay)(({ theme }) => {\n return {\n opacity: 0,\n transition: `opacity\n ${makeMotionTime(theme.motion.duration.xmoderate)}\n ${castWebType(theme.motion.easing.exit)}`,\n backgroundColor: theme.colors.overlay.background.subtle,\n\n [`&.${SHOW_DRAWER}`]: {\n opacity: 1,\n transition: `opacity ${makeMotionTime(theme.motion.duration.gentle)} ${castWebType(\n theme.motion.easing.entrance,\n )}`,\n },\n };\n});\n\nconst _Drawer = ({\n isOpen,\n onDismiss,\n zIndex = componentZIndices.drawer,\n children,\n accessibilityLabel,\n showOverlay = true,\n initialFocusRef,\n isLazy = true,\n testID,\n ...rest\n}: DrawerProps): React.ReactElement => {\n const closeButtonRef = React.useRef<HTMLDivElement>(null);\n const [zIndexState, setZIndexState] = React.useState<number>(zIndex);\n\n useVerifyAllowedChildren({\n children,\n componentName: 'Drawer',\n allowedComponents: [drawerComponentIds.DrawerHeader, drawerComponentIds.DrawerBody],\n });\n\n const { theme } = useTheme();\n const drawerId = useId('drawer');\n const { drawerStack, addToDrawerStack, removeFromDrawerStack } = useDrawerStack();\n\n const { isMounted, isVisible, isExiting } = usePresence(isOpen, {\n enterTransitionDuration: theme.motion.duration.gentle,\n exitTransitionDuration: theme.motion.duration.xmoderate,\n initialEnter: true,\n });\n\n const { stackingLevel, isFirstDrawerInStack } = React.useMemo(() => {\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n const level = Object.keys(drawerStack).indexOf(drawerId) + 1;\n return {\n stackingLevel: level,\n isFirstDrawerInStack: level === 1 && Object.keys(drawerStack).length > 1,\n };\n }, [drawerId, drawerStack]);\n\n const { refs, context } = useFloating({\n open: isMounted,\n });\n\n React.useEffect(() => {\n if (isOpen) {\n addToDrawerStack({ elementId: drawerId, onDismiss });\n } else {\n removeFromDrawerStack({ elementId: drawerId });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isOpen]);\n\n // When z-index is not defined by user, we use default drawer z index and add stackingLevel to ensure\n // new drawer that opens, always opens on top of previous one.\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n setZIndexState(zIndex + stackingLevel);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isMounted]);\n\n const contextValue = React.useMemo(\n () => ({\n close: onDismiss,\n closeButtonRef,\n stackingLevel,\n isExiting,\n }),\n [isExiting, onDismiss, stackingLevel],\n );\n\n return (\n <DrawerContext.Provider value={contextValue}>\n <FloatingPortal>\n {isMounted || !isLazy ? (\n <FloatingFocusManager\n context={context}\n initialFocus={initialFocusRef ?? closeButtonRef}\n returnFocus={true}\n >\n <BaseBox\n display={isLazy ? undefined : isMounted ? 'block' : 'none'}\n position=\"fixed\"\n {...metaAttribute({\n name: MetaConstants.Drawer,\n testID,\n })}\n {...makeAnalyticsAttribute(rest)}\n zIndex={zIndexState}\n >\n {showOverlay || stackingLevel === 2 ? (\n <DrawerOverlay\n onClick={() => {\n onDismiss();\n }}\n className={isVisible ? SHOW_DRAWER : ''}\n lockScroll={true}\n {...metaAttribute({\n testID: 'drawer-overlay',\n })}\n />\n ) : null}\n <AnimatedDrawerContainer\n isVisible={isVisible}\n isFirstDrawerInStack={isFirstDrawerInStack}\n width={{ base: '90%', s: '375px', m: '420px' }}\n {...makeAccessible({\n role: 'dialog',\n modal: true,\n label: accessibilityLabel,\n })}\n position=\"fixed\"\n top=\"spacing.0\"\n left=\"100%\"\n backgroundColor=\"popup.background.subtle\"\n elevation=\"highRaised\"\n height=\"100%\"\n display=\"flex\"\n flexDirection=\"column\"\n ref={refs.setFloating}\n onKeyDown={(event) => {\n if (event?.key === 'Escape' || event?.code === 'Escape') {\n onDismiss();\n }\n }}\n >\n {children}\n </AnimatedDrawerContainer>\n </BaseBox>\n </FloatingFocusManager>\n ) : null}\n </FloatingPortal>\n </DrawerContext.Provider>\n );\n};\n\n/**\n * ### Drawer Component\n * \n * A drawer is a panel that slides in mostly from right side of the screen over the existing content in the viewport. \n * It helps in providing additional details or context and can also be used to promote product features or new products.\n * \n * ---\n * \n * #### Usage\n * \n * ```jsx\n const MyDrawer = () => {\n const [showDrawer, setShowDrawer] = React.useState(false);\n return (\n <Box>\n <Button onClick={() => setShowDrawer(true)}>Open Drawer</Button>\n <Drawer\n isOpen={showDrawer}\n onDismiss={() => setShowDrawer(false)}\n >\n <DrawerHeader title=\"Announcements\" />\n <DrawerBody>\n <FTXAnnouncement />\n <CatPictures />\n </DrawerBody>\n <Drawer>\n </Box>\n )\n }\n * ```\n *\n * ---\n *\n * Checkout {@link https://blade.razorpay.com/?path=/docs/components-drawer Drawer Documentation}\n * \n * \n */\nconst Drawer = assignWithoutSideEffects(_Drawer, {\n componentId: drawerComponentIds.Drawer,\n});\n\nexport { Drawer };\n"],"names":["SHOW_DRAWER","AnimatedDrawerContainer","styled","BaseBox","withConfig","displayName","componentId","_ref","theme","isFirstDrawerInStack","isVisible","entranceTransition","concat","castWebType","makeMotionTime","motion","duration","xmoderate","easing","entrance","exitTransition","moderate","exit","opacity","transform","transition","animationFillMode","DrawerOverlay","FloatingOverlay","_ref2","_defineProperty","backgroundColor","colors","overlay","background","subtle","gentle","_Drawer","_ref4","isOpen","onDismiss","_ref4$zIndex","zIndex","componentZIndices","drawer","children","accessibilityLabel","_ref4$showOverlay","showOverlay","initialFocusRef","_ref4$isLazy","isLazy","testID","rest","_objectWithoutProperties","_excluded","closeButtonRef","React","useRef","_React$useState","useState","_React$useState2","_slicedToArray","zIndexState","setZIndexState","useVerifyAllowedChildren","componentName","allowedComponents","drawerComponentIds","DrawerHeader","DrawerBody","_useTheme","useTheme","drawerId","useId","_useDrawerStack","useDrawerStack","drawerStack","addToDrawerStack","removeFromDrawerStack","_usePresence","usePresence","enterTransitionDuration","exitTransitionDuration","initialEnter","isMounted","isExiting","_React$useMemo","useMemo","level","Object","keys","indexOf","stackingLevel","length","_useFloating","useFloating","open","refs","context","useEffect","elementId","contextValue","close","_jsx","DrawerContext","Provider","value","FloatingPortal","FloatingFocusManager","initialFocus","returnFocus","_jsxs","_objectSpread","display","undefined","position","metaAttribute","name","MetaConstants","Drawer","makeAnalyticsAttribute","onClick","className","lockScroll","width","base","s","m","makeAccessible","role","modal","label","top","left","elevation","height","flexDirection","ref","setFloating","onKeyDown","event","key","code","assignWithoutSideEffects"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAMA,WAAW,GAAG,aAAa,CAAA;AAEjC,IAAMC,uBAAuB,gBAAGC,MAAM,CAACC,OAAO,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,oCAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAG5C,CAAA,CAAA,UAAAC,IAAA,EAAgD;AAAA,EAAA,IAA7CC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,oBAAoB,GAAAF,IAAA,CAApBE,oBAAoB;IAAEC,SAAS,GAAAH,IAAA,CAATG,SAAS,CAAA;AAC1C,EAAA,IAAMC,kBAA+C,GAAA,MAAA,CAAAC,MAAA,CAAUC,WAAW,CACxEA,WAAW,CAACC,cAAc,CAACN,KAAK,CAACO,MAAM,CAACC,QAAQ,CAACC,SAAS,CAAC,CAC7D,CAAC,EAAAL,GAAAA,CAAAA,CAAAA,MAAA,CAAIC,WAAW,CAACL,KAAK,CAACO,MAAM,CAACG,MAAM,CAACC,QAAQ,CAAC,CAAE,CAAA;AAEhD,EAAA,IAAMC,cAA2C,GAAA,SAAA,CAAAR,MAAA,CAC/CC,WAAW,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7B,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAM2E,MAAM,gBAAGwB,wBAAwB,CAAC3G,OAAO,EAAE;EAC/C/B,WAAW,EAAE8D,kBAAkB,CAACoD,MAAAA;AAClC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Drawer.web.js","sources":["../../../../../../src/components/Drawer/Drawer.web.tsx"],"sourcesContent":["import {\n FloatingFocusManager,\n FloatingOverlay,\n FloatingPortal,\n useFloating,\n} from '@floating-ui/react';\nimport type { CSSProperties } from 'react';\nimport React from 'react';\nimport styled from 'styled-components';\nimport usePresence from 'use-presence';\nimport { drawerComponentIds } from './drawerComponentIds';\nimport { DrawerContext } from './DrawerContext';\nimport type { DrawerProps } from './types';\nimport BaseBox from '~components/Box/BaseBox';\nimport { castWebType, makeMotionTime, useTheme } from '~utils';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { componentZIndices } from '~utils/componentZIndices';\nimport { useDrawerStack } from '~components/Drawer/StackProvider';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { useId } from '~utils/useId';\nimport { useVerifyAllowedChildren } from '~utils/useVerifyAllowedChildren';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport type { BladeElementRef } from '~utils/types';\nimport { mergeRefs } from '~utils/useMergeRefs';\n\nconst SHOW_DRAWER = 'show-drawer';\n\nconst AnimatedDrawerContainer = styled(BaseBox)<{\n isFirstDrawerInStack: boolean;\n isVisible: boolean;\n}>(({ theme, isFirstDrawerInStack, isVisible }) => {\n const entranceTransition: CSSProperties['transition'] = `all ${castWebType(\n castWebType(makeMotionTime(theme.motion.duration.xmoderate)),\n )} ${castWebType(theme.motion.easing.entrance)}`;\n\n const exitTransition: CSSProperties['transition'] = `all\n ${castWebType(makeMotionTime(theme.motion.duration.moderate))}\n ${castWebType(theme.motion.easing.exit)}`;\n\n return {\n opacity: isVisible ? 1 : 0,\n transform: isVisible\n ? isFirstDrawerInStack\n ? 'translateX(calc(-100% - 16px))'\n : 'translateX(-100%)'\n : 'translateX(0%)',\n transition: isVisible ? entranceTransition : exitTransition,\n animationFillMode: 'initial',\n };\n});\n\nconst DrawerOverlay = styled(FloatingOverlay)(({ theme }) => {\n return {\n opacity: 0,\n transition: `opacity\n ${makeMotionTime(theme.motion.duration.xmoderate)}\n ${castWebType(theme.motion.easing.exit)}`,\n backgroundColor: theme.colors.overlay.background.subtle,\n\n [`&.${SHOW_DRAWER}`]: {\n opacity: 1,\n transition: `opacity ${makeMotionTime(theme.motion.duration.gentle)} ${castWebType(\n theme.motion.easing.entrance,\n )}`,\n },\n };\n});\n\nconst _Drawer: React.ForwardRefRenderFunction<BladeElementRef, DrawerProps> = (\n {\n isOpen,\n onDismiss,\n zIndex = componentZIndices.drawer,\n children,\n accessibilityLabel,\n showOverlay = true,\n initialFocusRef,\n isLazy = true,\n testID,\n ...rest\n },\n ref,\n) => {\n const closeButtonRef = React.useRef<HTMLDivElement>(null);\n const [zIndexState, setZIndexState] = React.useState<number>(zIndex);\n\n useVerifyAllowedChildren({\n children,\n componentName: 'Drawer',\n allowedComponents: [drawerComponentIds.DrawerHeader, drawerComponentIds.DrawerBody],\n });\n\n const { theme } = useTheme();\n const drawerId = useId('drawer');\n const { drawerStack, addToDrawerStack, removeFromDrawerStack } = useDrawerStack();\n\n const { isMounted, isVisible, isExiting } = usePresence(isOpen, {\n enterTransitionDuration: theme.motion.duration.gentle,\n exitTransitionDuration: theme.motion.duration.xmoderate,\n initialEnter: true,\n });\n\n const { stackingLevel, isFirstDrawerInStack } = React.useMemo(() => {\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n const level = Object.keys(drawerStack).indexOf(drawerId) + 1;\n return {\n stackingLevel: level,\n isFirstDrawerInStack: level === 1 && Object.keys(drawerStack).length > 1,\n };\n }, [drawerId, drawerStack]);\n\n const { refs, context } = useFloating({\n open: isMounted,\n });\n\n React.useEffect(() => {\n if (isOpen) {\n addToDrawerStack({ elementId: drawerId, onDismiss });\n } else {\n removeFromDrawerStack({ elementId: drawerId });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isOpen]);\n\n // When z-index is not defined by user, we use default drawer z index and add stackingLevel to ensure\n // new drawer that opens, always opens on top of previous one.\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n setZIndexState(zIndex + stackingLevel);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isMounted]);\n\n const contextValue = React.useMemo(\n () => ({\n close: onDismiss,\n closeButtonRef,\n stackingLevel,\n isExiting,\n }),\n [isExiting, onDismiss, stackingLevel],\n );\n\n return (\n <DrawerContext.Provider value={contextValue}>\n <FloatingPortal>\n {isMounted || !isLazy ? (\n <FloatingFocusManager\n context={context}\n initialFocus={initialFocusRef ?? closeButtonRef}\n returnFocus={true}\n >\n <BaseBox\n display={isLazy ? undefined : isMounted ? 'block' : 'none'}\n position=\"fixed\"\n {...metaAttribute({\n name: MetaConstants.Drawer,\n testID,\n })}\n {...makeAnalyticsAttribute(rest)}\n zIndex={zIndexState}\n >\n {showOverlay ? (\n <DrawerOverlay\n onClick={() => {\n onDismiss();\n }}\n className={isVisible ? SHOW_DRAWER : ''}\n lockScroll={true}\n {...metaAttribute({\n testID: 'drawer-overlay',\n })}\n />\n ) : null}\n <AnimatedDrawerContainer\n isVisible={isVisible}\n isFirstDrawerInStack={isFirstDrawerInStack}\n width={{ base: '90%', s: '375px', m: '420px' }}\n {...makeAccessible({\n role: 'dialog',\n modal: true,\n label: accessibilityLabel,\n })}\n position=\"fixed\"\n top=\"spacing.0\"\n left=\"100%\"\n backgroundColor=\"popup.background.subtle\"\n elevation=\"highRaised\"\n height=\"100%\"\n display=\"flex\"\n flexDirection=\"column\"\n ref={mergeRefs(ref, refs.setFloating)}\n onKeyDown={(event) => {\n if (event?.key === 'Escape' || event?.code === 'Escape') {\n onDismiss();\n }\n }}\n >\n {children}\n </AnimatedDrawerContainer>\n </BaseBox>\n </FloatingFocusManager>\n ) : null}\n </FloatingPortal>\n </DrawerContext.Provider>\n );\n};\n\n/**\n * ### Drawer Component\n * \n * A drawer is a panel that slides in mostly from right side of the screen over the existing content in the viewport. \n * It helps in providing additional details or context and can also be used to promote product features or new products.\n * \n * ---\n * \n * #### Usage\n * \n * ```jsx\n const MyDrawer = () => {\n const [showDrawer, setShowDrawer] = React.useState(false);\n return (\n <Box>\n <Button onClick={() => setShowDrawer(true)}>Open Drawer</Button>\n <Drawer\n isOpen={showDrawer}\n onDismiss={() => setShowDrawer(false)}\n >\n <DrawerHeader title=\"Announcements\" />\n <DrawerBody>\n <FTXAnnouncement />\n <CatPictures />\n </DrawerBody>\n <Drawer>\n </Box>\n )\n }\n * ```\n *\n * ---\n *\n * Checkout {@link https://blade.razorpay.com/?path=/docs/components-drawer Drawer Documentation}\n * \n * \n */\nconst Drawer = assignWithoutSideEffects(React.forwardRef(_Drawer), {\n displayName: 'Drawer',\n componentId: drawerComponentIds.Drawer,\n});\n\nexport { Drawer };\n"],"names":["SHOW_DRAWER","AnimatedDrawerContainer","styled","BaseBox","withConfig","displayName","componentId","_ref","theme","isFirstDrawerInStack","isVisible","entranceTransition","concat","castWebType","makeMotionTime","motion","duration","xmoderate","easing","entrance","exitTransition","moderate","exit","opacity","transform","transition","animationFillMode","DrawerOverlay","FloatingOverlay","_ref2","_defineProperty","backgroundColor","colors","overlay","background","subtle","gentle","_Drawer","_ref4","ref","isOpen","onDismiss","_ref4$zIndex","zIndex","componentZIndices","drawer","children","accessibilityLabel","_ref4$showOverlay","showOverlay","initialFocusRef","_ref4$isLazy","isLazy","testID","rest","_objectWithoutProperties","_excluded","closeButtonRef","React","useRef","_React$useState","useState","_React$useState2","_slicedToArray","zIndexState","setZIndexState","useVerifyAllowedChildren","componentName","allowedComponents","drawerComponentIds","DrawerHeader","DrawerBody","_useTheme","useTheme","drawerId","useId","_useDrawerStack","useDrawerStack","drawerStack","addToDrawerStack","removeFromDrawerStack","_usePresence","usePresence","enterTransitionDuration","exitTransitionDuration","initialEnter","isMounted","isExiting","_React$useMemo","useMemo","level","Object","keys","indexOf","stackingLevel","length","_useFloating","useFloating","open","refs","context","useEffect","elementId","contextValue","close","_jsx","DrawerContext","Provider","value","FloatingPortal","FloatingFocusManager","initialFocus","returnFocus","_jsxs","_objectSpread","display","undefined","position","metaAttribute","name","MetaConstants","Drawer","makeAnalyticsAttribute","onClick","className","lockScroll","width","base","s","m","makeAccessible","role","modal","label","top","left","elevation","height","flexDirection","mergeRefs","setFloating","onKeyDown","event","key","code","assignWithoutSideEffects","forwardRef"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAMA,WAAW,GAAG,aAAa,CAAA;AAEjC,IAAMC,uBAAuB,gBAAGC,MAAM,CAACC,OAAO,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,oCAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAG5C,CAAA,CAAA,UAAAC,IAAA,EAAgD;AAAA,EAAA,IAA7CC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,oBAAoB,GAAAF,IAAA,CAApBE,oBAAoB;IAAEC,SAAS,GAAAH,IAAA,CAATG,SAAS,CAAA;AAC1C,EAAA,IAAMC,kBAA+C,GAAA,MAAA,CAAAC,MAAA,CAAUC,WAAW,CACxEA,WAAW,CAACC,cAAc,CAACN,KAAK,CAACO,MAAM,CAACC,QAAQ,CAACC,SAAS,CAAC,CAC7D,CAAC,EAAAL,GAAAA,CAAAA,CAAAA,MAAA,CAAIC,WAAW,CAACL,KAAK,CAACO,MAAM,CAACG,MAAM,CAACC,QAAQ,CAAC,CAAE,CAAA;AAEhD,EAA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CAAA,CAAA;AAAC,OACU,CAAC,GACrB,IAAA;KACU,CAAA;AAAC,GACK,CAAC,CAAA;AAE7B,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACM2E,IAAAA,MAAM,gBAAGwB,wBAAwB,eAACvF,cAAK,CAACwF,UAAU,CAAC7G,OAAO,CAAC,EAAE;AACjEhC,EAAAA,WAAW,EAAE,QAAQ;EACrBC,WAAW,EAAE+D,kBAAkB,CAACoD,MAAAA;AAClC,CAAC;;;;"}
|
|
@@ -67,10 +67,11 @@ var _Radio = function _Radio(_ref, ref) {
|
|
|
67
67
|
var _size = (_groupProps$size = groupProps.size) !== null && _groupProps$size !== void 0 ? _groupProps$size : size;
|
|
68
68
|
var handleChange = function handleChange(_ref2) {
|
|
69
69
|
var isChecked = _ref2.isChecked,
|
|
70
|
-
value = _ref2.value
|
|
70
|
+
value = _ref2.value,
|
|
71
|
+
event = _ref2.event;
|
|
71
72
|
if (isChecked) {
|
|
72
73
|
var _groupProps$state2;
|
|
73
|
-
groupProps === null || groupProps === void 0 ? void 0 : (_groupProps$state2 = groupProps.state) === null || _groupProps$state2 === void 0 ? void 0 : _groupProps$state2.setValue(value);
|
|
74
|
+
groupProps === null || groupProps === void 0 ? void 0 : (_groupProps$state2 = groupProps.state) === null || _groupProps$state2 === void 0 ? void 0 : _groupProps$state2.setValue(value, event);
|
|
74
75
|
} else {
|
|
75
76
|
var _groupProps$state3;
|
|
76
77
|
groupProps === null || groupProps === void 0 ? void 0 : (_groupProps$state3 = groupProps.state) === null || _groupProps$state3 === void 0 ? void 0 : _groupProps$state3.removeValue();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","sources":["../../../../../../src/components/Radio/Radio.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport type { OnChange } from './useRadio';\nimport { useRadio } from './useRadio';\nimport { RadioIcon } from './RadioIcon/RadioIcon';\nimport { useRadioGroupContext } from './RadioGroup/RadioContext';\nimport { radioHoverTokens, radioSizes } from './radioTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport BaseBox from '~components/Box/BaseBox';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport type {\n BladeElementRef,\n DataAnalyticsAttribute,\n StringChildrenType,\n TestID,\n} from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getPlatformType, makeSize, useTheme } from '~utils';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { throwBladeError } from '~utils/logger';\nimport type { MotionMetaProp } from '~components/BaseMotion';\nimport { getInnerMotionRef, getOuterMotionRef } from '~utils/getMotionRefs';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype RadioProps = {\n /**\n * Sets the label text of the Radio\n */\n children?: StringChildrenType;\n /**\n * Help text for the Radio\n */\n helpText?: string;\n /**\n * The value to be used in the Radio input.\n * This is the value that will be returned on form submission.\n */\n value: string;\n /**\n * If `true`, the Radio will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Size of the radios\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n} & TestID &\n DataAnalyticsAttribute &\n StyledPropsBlade &\n MotionMetaProp;\n\nconst _Radio: React.ForwardRefRenderFunction<BladeElementRef, RadioProps> = (\n { value, children, helpText, isDisabled, size = 'medium', testID, _motionMeta, ...rest },\n ref,\n) => {\n const { theme } = useTheme();\n const groupProps = useRadioGroupContext();\n const isInsideGroup = !isEmpty(groupProps);\n\n if (__DEV__) {\n if (!isInsideGroup) {\n throwBladeError({\n moduleName: 'Radio',\n message: 'Cannot use <Radio /> outside of <RadioGroup />',\n });\n }\n }\n\n const isChecked = groupProps?.state?.isChecked(value);\n const defaultChecked =\n groupProps?.defaultValue === undefined ? undefined : groupProps?.defaultValue === value;\n const validationState = groupProps?.validationState;\n const hasError = validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = groupProps?.isRequired || groupProps?.necessityIndicator === 'required';\n const name = groupProps?.name;\n const showHelpText = helpText;\n const isReactNative = getPlatformType() === 'react-native';\n const _size = groupProps.size ?? size;\n\n const handleChange: OnChange = ({ isChecked, value }) => {\n if (isChecked) {\n groupProps?.state?.setValue(value!);\n } else {\n groupProps?.state?.removeValue();\n }\n };\n\n const { state, ids, inputProps } = useRadio({\n defaultChecked,\n isChecked,\n hasError,\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name,\n value,\n onChange: handleChange,\n });\n\n // radio icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(radioSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox ref={getOuterMotionRef({ _motionMeta, ref })} {...getStyledProps(rest)}>\n <SelectorLabel\n componentName={MetaConstants.RadioLabel}\n inputProps={isReactNative ? inputProps : {}}\n testID={testID}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" alignItems=\"center\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={radioHoverTokens}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n hasError={hasError}\n inputProps={inputProps}\n ref={getInnerMotionRef({ _motionMeta, ref })}\n {...makeAnalyticsAttribute(rest)}\n />\n <RadioIcon\n size={_size}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n isNegative={hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showHelpText && (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n )}\n </BaseBox>\n </SelectorLabel>\n </BaseBox>\n );\n};\n\nconst Radio = assignWithoutSideEffects(React.forwardRef(_Radio), { displayName: 'Radio' });\n\nexport type { RadioProps };\nexport { Radio };\n"],"names":["_Radio","_ref","ref","_groupProps$state","_groupProps$size","value","children","helpText","isDisabled","_ref$size","size","testID","_motionMeta","rest","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","groupProps","useRadioGroupContext","isInsideGroup","isEmpty","throwBladeError","moduleName","message","isChecked","state","defaultChecked","defaultValue","undefined","validationState","hasError","_isDisabled","_isRequired","isRequired","necessityIndicator","name","showHelpText","isReactNative","getPlatformType","_size","handleChange","_ref2","_groupProps$state2","setValue","_groupProps$state3","removeValue","_useRadio","useRadio","onChange","ids","inputProps","helpTextLeftSpacing","makeSize","radioSizes","icon","width","spacing","_jsx","BaseBox","_objectSpread","getOuterMotionRef","getStyledProps","SelectorLabel","componentName","MetaConstants","RadioLabel","_jsxs","display","flexDirection","alignItems","SelectorInput","hoverTokens","radioHoverTokens","getInnerMotionRef","makeAnalyticsAttribute","RadioIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","Radio","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,IAAMA,MAAmE,GAAG,SAAtEA,MAAmEA,CAAAC,IAAA,EAEvEC,GAAG,EACA;EAAA,IAAAC,iBAAA,EAAAC,gBAAA,CAAA;AAAA,EAAA,IAFDC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IAAEC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAEC,QAAQ,GAAAN,IAA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3BlB,YAAAA,UAAU,EAAEyB,WAAY;AACxB6C,YAAAA,UAAU,EAAE9C,QAAAA;AAAS,WACtB,CAAC,EACD1B,QAAQ,gBACPqD,GAAA,CAACoB,aAAa,EAAA;AAACrE,YAAAA,IAAI,EAAE+B,KAAM;AAACjC,YAAAA,UAAU,EAAEyB,WAAY;AAAA3B,YAAAA,QAAA,EACjDA,QAAAA;WACY,CAAC,GACd,IAAI,CAAA;AAAA,SACD,CAAC,EACTgC,YAAY,iBACXqB,GAAA,CAACC,OAAO,EAAA;AAACoB,UAAAA,UAAU,EAAE3B,mBAAoB;UAAA/C,QAAA,eACvCqD,GAAA,CAACsB,mBAAmB,EAAA;AAACvE,YAAAA,IAAI,EAAE+B,KAAM;AAACyC,YAAAA,EAAE,EAAE/B,GAAG,KAAA,IAAA,IAAHA,GAAG,KAAHA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,GAAG,CAAEgC,UAAW;AAAA7E,YAAAA,QAAA,EACnDC,QAAAA;WACkB,CAAA;AAAC,SACf,CACV,CAAA;OACM,CAAA;KACI,CAAA;AAAC,GAAA,CACT,CAAC,CAAA;AAEd,CAAC,CAAA;AAEK6E,IAAAA,KAAK,gBAAGC,wBAAwB,eAACC,cAAK,CAACC,UAAU,CAACvF,MAAM,CAAC,EAAE;AAAEwF,EAAAA,WAAW,EAAE,OAAA;AAAQ,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Radio.js","sources":["../../../../../../src/components/Radio/Radio.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport type { OnChange } from './useRadio';\nimport { useRadio } from './useRadio';\nimport { RadioIcon } from './RadioIcon/RadioIcon';\nimport { useRadioGroupContext } from './RadioGroup/RadioContext';\nimport { radioHoverTokens, radioSizes } from './radioTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport BaseBox from '~components/Box/BaseBox';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport type {\n BladeElementRef,\n DataAnalyticsAttribute,\n StringChildrenType,\n TestID,\n} from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getPlatformType, makeSize, useTheme } from '~utils';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { throwBladeError } from '~utils/logger';\nimport type { MotionMetaProp } from '~components/BaseMotion';\nimport { getInnerMotionRef, getOuterMotionRef } from '~utils/getMotionRefs';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype RadioProps = {\n /**\n * Sets the label text of the Radio\n */\n children?: StringChildrenType;\n /**\n * Help text for the Radio\n */\n helpText?: string;\n /**\n * The value to be used in the Radio input.\n * This is the value that will be returned on form submission.\n */\n value: string;\n /**\n * If `true`, the Radio will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Size of the radios\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n} & TestID &\n DataAnalyticsAttribute &\n StyledPropsBlade &\n MotionMetaProp;\n\nconst _Radio: React.ForwardRefRenderFunction<BladeElementRef, RadioProps> = (\n { value, children, helpText, isDisabled, size = 'medium', testID, _motionMeta, ...rest },\n ref,\n) => {\n const { theme } = useTheme();\n const groupProps = useRadioGroupContext();\n const isInsideGroup = !isEmpty(groupProps);\n\n if (__DEV__) {\n if (!isInsideGroup) {\n throwBladeError({\n moduleName: 'Radio',\n message: 'Cannot use <Radio /> outside of <RadioGroup />',\n });\n }\n }\n\n const isChecked = groupProps?.state?.isChecked(value);\n const defaultChecked =\n groupProps?.defaultValue === undefined ? undefined : groupProps?.defaultValue === value;\n const validationState = groupProps?.validationState;\n const hasError = validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = groupProps?.isRequired || groupProps?.necessityIndicator === 'required';\n const name = groupProps?.name;\n const showHelpText = helpText;\n const isReactNative = getPlatformType() === 'react-native';\n const _size = groupProps.size ?? size;\n\n const handleChange: OnChange = ({ isChecked, value, event }) => {\n if (isChecked) {\n groupProps?.state?.setValue(value!, event);\n } else {\n groupProps?.state?.removeValue();\n }\n };\n\n const { state, ids, inputProps } = useRadio({\n defaultChecked,\n isChecked,\n hasError,\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name,\n value,\n onChange: handleChange,\n });\n\n // radio icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(radioSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox ref={getOuterMotionRef({ _motionMeta, ref })} {...getStyledProps(rest)}>\n <SelectorLabel\n componentName={MetaConstants.RadioLabel}\n inputProps={isReactNative ? inputProps : {}}\n testID={testID}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" alignItems=\"center\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={radioHoverTokens}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n hasError={hasError}\n inputProps={inputProps}\n ref={getInnerMotionRef({ _motionMeta, ref })}\n {...makeAnalyticsAttribute(rest)}\n />\n <RadioIcon\n size={_size}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n isNegative={hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showHelpText && (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n )}\n </BaseBox>\n </SelectorLabel>\n </BaseBox>\n );\n};\n\nconst Radio = assignWithoutSideEffects(React.forwardRef(_Radio), { displayName: 'Radio' });\n\nexport type { RadioProps };\nexport { Radio };\n"],"names":["_Radio","_ref","ref","_groupProps$state","_groupProps$size","value","children","helpText","isDisabled","_ref$size","size","testID","_motionMeta","rest","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","groupProps","useRadioGroupContext","isInsideGroup","isEmpty","throwBladeError","moduleName","message","isChecked","state","defaultChecked","defaultValue","undefined","validationState","hasError","_isDisabled","_isRequired","isRequired","necessityIndicator","name","showHelpText","isReactNative","getPlatformType","_size","handleChange","_ref2","event","_groupProps$state2","setValue","_groupProps$state3","removeValue","_useRadio","useRadio","onChange","ids","inputProps","helpTextLeftSpacing","makeSize","radioSizes","icon","width","spacing","_jsx","BaseBox","_objectSpread","getOuterMotionRef","getStyledProps","SelectorLabel","componentName","MetaConstants","RadioLabel","_jsxs","display","flexDirection","alignItems","SelectorInput","hoverTokens","radioHoverTokens","getInnerMotionRef","makeAnalyticsAttribute","RadioIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","Radio","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,IAAMA,MAAmE,GAAG,SAAtEA,MAAmEA,CAAAC,IAAA,EAEvEC,GAAG,EACA;EAAA,IAAAC,iBAAA,EAAAC,gBAAA,CAAA;AAAA,EAAA,IAFDC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IAAEC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAEC,QAAQ,GAAAN,IAAA,CAARM,QAAQ;IAAEC,UAAU,GAAAP,IAAA,CAAVO,UAAU;IAAAC,SAAA,GAAAR,IAAA,CAAES,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAG,KAAA,CAAA,GAAA,QAAQ,GAAAA,SAAA;IAAEE,MAAM,GAAAV,IAAA,CAANU,MAAM;IAAEC,WAAW,GAAAX,IAAA,CAAXW,WAAW;AAAKC,IAAAA,IAAI,GAAAC,wBAAA,CAAAb,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AAAA3B,YAAAA,QAAA,EACjDA,QAAAA;WACY,CAAC,GACd,IAAI,CAAA;AAAA,SACD,CAAC,EACTgC,YAAY,iBACXsB,GAAA,CAACC,OAAO,EAAA;AAACoB,UAAAA,UAAU,EAAE3B,mBAAoB;UAAAhD,QAAA,eACvCsD,GAAA,CAACsB,mBAAmB,EAAA;AAACxE,YAAAA,IAAI,EAAE+B,KAAM;AAAC0C,YAAAA,EAAE,EAAE/B,GAAG,KAAA,IAAA,IAAHA,GAAG,KAAHA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,GAAG,CAAEgC,UAAW;AAAA9E,YAAAA,QAAA,EACnDC,QAAAA;WACkB,CAAA;AAAC,SACf,CACV,CAAA;OACM,CAAA;KACI,CAAA;AAAC,GAAA,CACT,CAAC,CAAA;AAEd,CAAC,CAAA;AAEK8E,IAAAA,KAAK,gBAAGC,wBAAwB,eAACC,cAAK,CAACC,UAAU,CAACxF,MAAM,CAAC,EAAE;AAAEyF,EAAAA,WAAW,EAAE,OAAA;AAAQ,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","sources":["../../../../../../../src/components/Radio/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import React from 'react';\nimport { radioSizes } from '../radioTokens';\nimport { RadioGroupProvider } from './RadioContext';\nimport { useRadioGroup } from './useRadioGroup';\nimport BaseBox from '~components/Box/BaseBox';\nimport { FormHint, FormLabel } from '~components/Form';\nimport { SelectorGroupField } from '~components/Form/Selector/SelectorGroupField';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { useBreakpoint } from '~utils';\nimport { useTheme } from '~components/BladeProvider';\nimport type { DataAnalyticsAttribute, TestID } from '~utils/types';\nimport { makeSize } from '~utils/makeSize';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype RadioGroupProps = {\n /**\n * Accepts multiple radios as children\n */\n children: React.ReactNode;\n /**\n * Help text of the radio group\n */\n helpText?: string;\n /**\n * Error text of the radio group\n * Renders when `validationState` is set to 'error'\n *\n * Overrides helpText\n */\n errorText?: string;\n /**\n * Sets the error state of the radioGroup\n * If set to `error` it will render the `errorText` of the group,\n * and propagate `invalid` prop to every radio\n */\n validationState?: 'error' | 'none';\n /**\n * Renders a necessity indicator after radioGroup label\n *\n * If set to `undefined` it renders nothing.\n */\n necessityIndicator?: 'required' | 'optional' | 'none';\n /**\n * Sets the disabled state of the radioGroup\n * If set to `true` it propagate down to all the radios\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Sets the required state of the radioGroup\n * @default false\n */\n isRequired?: boolean;\n /**\n * Renders the label of the radio group\n */\n label?: string;\n /**\n * Sets the position of the label\n *\n * @default 'top'\n */\n labelPosition?: 'top' | 'left';\n /**\n * Initial value of the radio group\n */\n defaultValue?: string;\n /**\n * value of the radio group\n *\n * Use `onChange` to update its value\n */\n value?: string;\n /**\n * The callback invoked when any of the radio's state changes\n */\n onChange?: ({ name, value }: { name: string | undefined; value: string }) => void;\n /**\n * The name of the input field in a radio\n * (Useful for form submission).\n */\n name?: string;\n /**\n * Size of the radios\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n} & TestID &\n DataAnalyticsAttribute &\n StyledPropsBlade;\n\nconst RadioGroup = ({\n children,\n label,\n helpText,\n isDisabled = false,\n isRequired = false,\n necessityIndicator = 'none',\n labelPosition = 'top',\n validationState = 'none',\n errorText,\n name,\n defaultValue,\n onChange,\n value,\n size = 'medium',\n testID,\n ...rest\n}: RadioGroupProps): React.ReactElement => {\n const { contextValue, ids } = useRadioGroup({\n defaultValue,\n isDisabled,\n isRequired,\n labelPosition,\n name,\n necessityIndicator,\n onChange,\n validationState,\n value,\n size,\n });\n\n const { theme } = useTheme();\n const { matchedDeviceType } = useBreakpoint({ breakpoints: theme.breakpoints });\n const showError = validationState === 'error' && errorText;\n const showHelpText = !showError && helpText;\n const accessibilityText = `${showError ? errorText : ''} ${showHelpText ? helpText : ''}`.trim();\n const gap = radioSizes.group.gap[size][matchedDeviceType];\n const childCount = React.Children.count(children);\n\n return (\n <RadioGroupProvider value={contextValue}>\n <BaseBox {...getStyledProps(rest)}>\n <SelectorGroupField\n position={labelPosition}\n labelledBy={ids.labelId}\n accessibilityRole=\"radiogroup\"\n componentName=\"radio-group\"\n testID={testID}\n {...makeAnalyticsAttribute(rest)}\n >\n {label ? (\n <FormLabel\n as=\"span\"\n necessityIndicator={necessityIndicator}\n position={labelPosition}\n id={ids.labelId}\n accessibilityText={accessibilityText && `,${accessibilityText}`}\n size={size}\n >\n {label}\n </FormLabel>\n ) : null}\n <BaseBox>\n <BaseBox display=\"flex\" flexDirection=\"column\">\n {React.Children.map(children, (child, index) => {\n return (\n <BaseBox\n key={index}\n {...{ marginBottom: index === childCount - 1 ? makeSize(0) : gap }}\n >\n {child}\n </BaseBox>\n );\n })}\n </BaseBox>\n <FormHint\n size={size}\n type={validationState === 'error' ? 'error' : 'help'}\n errorText={errorText}\n helpText={helpText}\n />\n </BaseBox>\n </SelectorGroupField>\n </BaseBox>\n </RadioGroupProvider>\n );\n};\n\nexport type { RadioGroupProps };\nexport { RadioGroup };\n"],"names":["RadioGroup","_ref","children","label","helpText","_ref$isDisabled","isDisabled","_ref$isRequired","isRequired","_ref$necessityIndicat","necessityIndicator","_ref$labelPosition","labelPosition","_ref$validationState","validationState","errorText","name","defaultValue","onChange","value","_ref$size","size","testID","rest","_objectWithoutProperties","_excluded","_useRadioGroup","useRadioGroup","contextValue","ids","_useTheme","useTheme","theme","_useBreakpoint","useBreakpoint","breakpoints","matchedDeviceType","showError","showHelpText","accessibilityText","concat","trim","gap","radioSizes","group","childCount","React","Children","count","_jsx","RadioGroupProvider","BaseBox","_objectSpread","getStyledProps","_jsxs","SelectorGroupField","position","labelledBy","labelId","accessibilityRole","componentName","makeAnalyticsAttribute","FormLabel","as","id","display","flexDirection","map","child","index","marginBottom","makeSize","FormHint","type"],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AE,UAACkE,KAAK,EAAEC,KAAK,EAAK;cAC9C,oBACEpB,GAAA,CAACE,OAAO,EAAA;AAEAmB,gBAAAA,YAAY,EAAED,KAAK,KAAKxB,UAAU,GAAG,CAAC,GAAG0B,QAAQ,CAAC,CAAC,CAAC,GAAG7B,GAAG;AAAAxC,gBAAAA,QAAA,EAE/DkE,KAAAA;AAAK,eAAA,EAHDC,KAIE,CAAC,CAAA;aAEb,CAAA;AAAC,WACK,CAAC,eACVpB,GAAA,CAACuB,QAAQ,EAAA;AACPnD,YAAAA,IAAI,EAAEA,IAAK;AACXoD,YAAAA,IAAI,EAAE3D,eAAe,KAAK,OAAO,GAAG,OAAO,GAAG,MAAO;AACrDC,YAAAA,SAAS,EAAEA,SAAU;AACrBX,YAAAA,QAAQ,EAAEA,QAAAA;AAAS,WACpB,CAAC,CAAA;AAAA,SACK,CAAC,CAAA;OACQ,CAAA,CAAA;KACb,CAAA,CAAA;AAAC,GACQ,CAAC,CAAA;AAEzB;;;;"}
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","sources":["../../../../../../../src/components/Radio/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import React from 'react';\nimport { radioSizes } from '../radioTokens';\nimport { RadioGroupProvider } from './RadioContext';\nimport { useRadioGroup } from './useRadioGroup';\nimport BaseBox from '~components/Box/BaseBox';\nimport { FormHint, FormLabel } from '~components/Form';\nimport { SelectorGroupField } from '~components/Form/Selector/SelectorGroupField';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { useBreakpoint } from '~utils';\nimport { useTheme } from '~components/BladeProvider';\nimport type { DataAnalyticsAttribute, TestID } from '~utils/types';\nimport { makeSize } from '~utils/makeSize';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype RadioGroupProps = {\n /**\n * Accepts multiple radios as children\n */\n children: React.ReactNode;\n /**\n * Help text of the radio group\n */\n helpText?: string;\n /**\n * Error text of the radio group\n * Renders when `validationState` is set to 'error'\n *\n * Overrides helpText\n */\n errorText?: string;\n /**\n * Sets the error state of the radioGroup\n * If set to `error` it will render the `errorText` of the group,\n * and propagate `invalid` prop to every radio\n */\n validationState?: 'error' | 'none';\n /**\n * Renders a necessity indicator after radioGroup label\n *\n * If set to `undefined` it renders nothing.\n */\n necessityIndicator?: 'required' | 'optional' | 'none';\n /**\n * Sets the disabled state of the radioGroup\n * If set to `true` it propagate down to all the radios\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Sets the required state of the radioGroup\n * @default false\n */\n isRequired?: boolean;\n /**\n * Renders the label of the radio group\n */\n label?: string;\n /**\n * Sets the position of the label\n *\n * @default 'top'\n */\n labelPosition?: 'top' | 'left';\n /**\n * Initial value of the radio group\n */\n defaultValue?: string;\n /**\n * value of the radio group\n *\n * Use `onChange` to update its value\n */\n value?: string;\n /**\n * The callback invoked when any of the radio's state changes\n */\n onChange?: ({\n name,\n value,\n event,\n }: {\n name: string | undefined;\n value: string;\n event: React.ChangeEvent<HTMLInputElement>;\n }) => void;\n /**\n * The name of the input field in a radio\n * (Useful for form submission).\n */\n name?: string;\n /**\n * Size of the radios\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n} & TestID &\n DataAnalyticsAttribute &\n StyledPropsBlade;\n\nconst RadioGroup = ({\n children,\n label,\n helpText,\n isDisabled = false,\n isRequired = false,\n necessityIndicator = 'none',\n labelPosition = 'top',\n validationState = 'none',\n errorText,\n name,\n defaultValue,\n onChange,\n value,\n size = 'medium',\n testID,\n ...rest\n}: RadioGroupProps): React.ReactElement => {\n const { contextValue, ids } = useRadioGroup({\n defaultValue,\n isDisabled,\n isRequired,\n labelPosition,\n name,\n necessityIndicator,\n onChange,\n validationState,\n value,\n size,\n });\n\n const { theme } = useTheme();\n const { matchedDeviceType } = useBreakpoint({ breakpoints: theme.breakpoints });\n const showError = validationState === 'error' && errorText;\n const showHelpText = !showError && helpText;\n const accessibilityText = `${showError ? errorText : ''} ${showHelpText ? helpText : ''}`.trim();\n const gap = radioSizes.group.gap[size][matchedDeviceType];\n const childCount = React.Children.count(children);\n\n return (\n <RadioGroupProvider value={contextValue}>\n <BaseBox {...getStyledProps(rest)}>\n <SelectorGroupField\n position={labelPosition}\n labelledBy={ids.labelId}\n accessibilityRole=\"radiogroup\"\n componentName=\"radio-group\"\n testID={testID}\n {...makeAnalyticsAttribute(rest)}\n >\n {label ? (\n <FormLabel\n as=\"span\"\n necessityIndicator={necessityIndicator}\n position={labelPosition}\n id={ids.labelId}\n accessibilityText={accessibilityText && `,${accessibilityText}`}\n size={size}\n >\n {label}\n </FormLabel>\n ) : null}\n <BaseBox>\n <BaseBox display=\"flex\" flexDirection=\"column\">\n {React.Children.map(children, (child, index) => {\n return (\n <BaseBox\n key={index}\n {...{ marginBottom: index === childCount - 1 ? makeSize(0) : gap }}\n >\n {child}\n </BaseBox>\n );\n })}\n </BaseBox>\n <FormHint\n size={size}\n type={validationState === 'error' ? 'error' : 'help'}\n errorText={errorText}\n helpText={helpText}\n />\n </BaseBox>\n </SelectorGroupField>\n </BaseBox>\n </RadioGroupProvider>\n );\n};\n\nexport type { RadioGroupProps };\nexport { RadioGroup };\n"],"names":["RadioGroup","_ref","children","label","helpText","_ref$isDisabled","isDisabled","_ref$isRequired","isRequired","_ref$necessityIndicat","necessityIndicator","_ref$labelPosition","labelPosition","_ref$validationState","validationState","errorText","name","defaultValue","onChange","value","_ref$size","size","testID","rest","_objectWithoutProperties","_excluded","_useRadioGroup","useRadioGroup","contextValue","ids","_useTheme","useTheme","theme","_useBreakpoint","useBreakpoint","breakpoints","matchedDeviceType","showError","showHelpText","accessibilityText","concat","trim","gap","radioSizes","group","childCount","React","Children","count","_jsx","RadioGroupProvider","BaseBox","_objectSpread","getStyledProps","_jsxs","SelectorGroupField","position","labelledBy","labelId","accessibilityRole","componentName","makeAnalyticsAttribute","FormLabel","as","id","display","flexDirection","map","child","index","marginBottom","makeSize","FormHint","type"],"mappings":";;;;;;;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K,EAAEC,KAAK,EAAK;cAC9C,oBACEpB,GAAA,CAACE,OAAO,EAAA;AAEAmB,gBAAAA,YAAY,EAAED,KAAK,KAAKxB,UAAU,GAAG,CAAC,GAAG0B,QAAQ,CAAC,CAAC,CAAC,GAAG7B,GAAG;AAAAxC,gBAAAA,QAAA,EAE/DkE,KAAAA;AAAK,eAAA,EAHDC,KAIE,CAAC,CAAA;aAEb,CAAA;AAAC,WACK,CAAC,eACVpB,GAAA,CAACuB,QAAQ,EAAA;AACPnD,YAAAA,IAAI,EAAEA,IAAK;AACXoD,YAAAA,IAAI,EAAE3D,eAAe,KAAK,OAAO,GAAG,OAAO,GAAG,MAAO;AACrDC,YAAAA,SAAS,EAAEA,SAAU;AACrBX,YAAAA,QAAQ,EAAEA,QAAAA;AAAS,WACpB,CAAC,CAAA;AAAA,SACK,CAAC,CAAA;OACQ,CAAA,CAAA;KACb,CAAA,CAAA;AAAC,GACQ,CAAC,CAAA;AAEzB;;;;"}
|
|
@@ -25,10 +25,11 @@ var useRadioGroup = function useRadioGroup(_ref) {
|
|
|
25
25
|
var _useControllableState = useControllableState({
|
|
26
26
|
value: value,
|
|
27
27
|
defaultValue: defaultValue,
|
|
28
|
-
onChange: function onChange(v) {
|
|
29
|
-
|
|
28
|
+
onChange: function onChange(v, event) {
|
|
29
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange({
|
|
30
30
|
value: v,
|
|
31
|
-
name: fallbackName
|
|
31
|
+
name: fallbackName,
|
|
32
|
+
event: event
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
}),
|
|
@@ -39,20 +40,20 @@ var useRadioGroup = function useRadioGroup(_ref) {
|
|
|
39
40
|
return {
|
|
40
41
|
value: checkedValue,
|
|
41
42
|
setValue: function (_setValue) {
|
|
42
|
-
function setValue(_x) {
|
|
43
|
+
function setValue(_x, _x2) {
|
|
43
44
|
return _setValue.apply(this, arguments);
|
|
44
45
|
}
|
|
45
46
|
setValue.toString = function () {
|
|
46
47
|
return _setValue.toString();
|
|
47
48
|
};
|
|
48
49
|
return setValue;
|
|
49
|
-
}(function (v) {
|
|
50
|
+
}(function (v, event) {
|
|
50
51
|
if (isDisabled) {
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
54
|
setValue(function () {
|
|
54
55
|
return v;
|
|
55
|
-
});
|
|
56
|
+
}, false, event);
|
|
56
57
|
}),
|
|
57
58
|
removeValue: function removeValue() {
|
|
58
59
|
if (isDisabled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRadioGroup.js","sources":["../../../../../../../src/components/Radio/RadioGroup/useRadioGroup.ts"],"sourcesContent":["import React from 'react';\nimport type { RadioGroupProps } from './RadioGroup';\nimport type { RadioGroupContextType } from './RadioContext';\nimport isUndefined from '~utils/lodashButBetter/isUndefined';\nimport { useControllableState } from '~utils/useControllable';\nimport { useTheme } from '~components/BladeProvider';\nimport { useId } from '~utils/useId';\n\ntype UseRadioGroupProps = Pick<\n RadioGroupProps,\n | 'isDisabled'\n | 'isRequired'\n | 'labelPosition'\n | 'validationState'\n | 'name'\n | 'value'\n | 'defaultValue'\n | 'onChange'\n | 'necessityIndicator'\n | 'size'\n>;\n\nexport type State = {\n value: string;\n setValue(value: string): void;\n removeValue(): void;\n isChecked(value: string): boolean;\n};\n\ntype UseRadioGroupReturn = {\n state: State;\n contextValue: RadioGroupContextType;\n ids: { labelId: string };\n};\n\nconst useRadioGroup = ({\n value,\n defaultValue,\n isDisabled,\n isRequired,\n labelPosition,\n onChange,\n validationState,\n necessityIndicator,\n name,\n size,\n}: UseRadioGroupProps): UseRadioGroupReturn => {\n const { platform } = useTheme();\n const idBase = useId('radio-group');\n const labelId = `${idBase}-label`;\n const fallbackName = name ?? idBase;\n const [checkedValue, setValue] = useControllableState({\n value,\n defaultValue,\n onChange: (v
|
|
1
|
+
{"version":3,"file":"useRadioGroup.js","sources":["../../../../../../../src/components/Radio/RadioGroup/useRadioGroup.ts"],"sourcesContent":["import React from 'react';\nimport type { RadioGroupProps } from './RadioGroup';\nimport type { RadioGroupContextType } from './RadioContext';\nimport isUndefined from '~utils/lodashButBetter/isUndefined';\nimport { useControllableState } from '~utils/useControllable';\nimport { useTheme } from '~components/BladeProvider';\nimport { useId } from '~utils/useId';\n\ntype UseRadioGroupProps = Pick<\n RadioGroupProps,\n | 'isDisabled'\n | 'isRequired'\n | 'labelPosition'\n | 'validationState'\n | 'name'\n | 'value'\n | 'defaultValue'\n | 'onChange'\n | 'necessityIndicator'\n | 'size'\n>;\n\nexport type State = {\n value: string;\n setValue(value: string, event: React.ChangeEvent<Element>): void;\n removeValue(): void;\n isChecked(value: string): boolean;\n};\n\ntype UseRadioGroupReturn = {\n state: State;\n contextValue: RadioGroupContextType;\n ids: { labelId: string };\n};\n\nconst useRadioGroup = ({\n value,\n defaultValue,\n isDisabled,\n isRequired,\n labelPosition,\n onChange,\n validationState,\n necessityIndicator,\n name,\n size,\n}: UseRadioGroupProps): UseRadioGroupReturn => {\n const { platform } = useTheme();\n const idBase = useId('radio-group');\n const labelId = `${idBase}-label`;\n const fallbackName = name ?? idBase;\n const [checkedValue, setValue] = useControllableState({\n value,\n defaultValue,\n onChange: (v, event) => {\n onChange?.({ value: v, name: fallbackName, event });\n },\n });\n\n const state = React.useMemo<State>(() => {\n return {\n value: checkedValue,\n setValue(v, event): void {\n if (isDisabled) {\n return;\n }\n\n setValue(() => v, false, event);\n },\n removeValue(): void {\n if (isDisabled) {\n return;\n }\n\n setValue(undefined!);\n },\n isChecked(v: string): boolean {\n if (isUndefined(v) || isUndefined(checkedValue)) return false;\n return checkedValue === v;\n },\n };\n }, [checkedValue, isDisabled, setValue]);\n\n const contextValue = React.useMemo<RadioGroupContextType>(() => {\n return {\n necessityIndicator,\n validationState,\n isDisabled,\n isRequired,\n labelPosition: platform === 'onMobile' ? 'top' : labelPosition,\n name: fallbackName,\n state,\n size,\n };\n }, [\n validationState,\n isDisabled,\n isRequired,\n platform,\n labelPosition,\n state,\n fallbackName,\n necessityIndicator,\n size,\n ]);\n\n return { state, contextValue, ids: { labelId } };\n};\n\nexport { useRadioGroup };\n"],"names":["useRadioGroup","_ref","value","defaultValue","isDisabled","isRequired","labelPosition","onChange","validationState","necessityIndicator","name","size","_useTheme","useTheme","platform","idBase","useId","labelId","concat","fallbackName","_useControllableState","useControllableState","v","event","_useControllableState2","_slicedToArray","checkedValue","setValue","state","React","useMemo","_setValue","_x","_x2","apply","arguments","toString","removeValue","undefined","isChecked","isUndefined","contextValue","ids"],"mappings":";;;;;;;;AAmCA,IAAMA,aAAa,GAAG,SAAhBA,aAAaA,CAAAC,IAAA,EAW4B;AAAA,EAAA,IAV7CC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,YAAY,GAAAF,IAAA,CAAZE,YAAY;IACZC,UAAU,GAAAH,IAAA,CAAVG,UAAU;IACVC,UAAU,GAAAJ,IAAA,CAAVI,UAAU;IACVC,aAAa,GAAAL,IAAA,CAAbK,aAAa;IACbC,SAAQ,GAAAN,IAAA,CAARM,QAAQ;IACRC,eAAe,GAAAP,IAAA,CAAfO,eAAe;IACfC,kBAAkB,GAAAR,IAAA,CAAlBQ,kBAAkB;IAClBC,IAAI,GAAAT,IAAA,CAAJS,IAAI;IACJC,IAAI,GAAAV,IAAA,CAAJU,IAAI,CAAA;AAEJ,EAAA,IAAAC,SAAA,GAAqBC,QAAQ,EAAE;IAAvBC,QAAQ,GAAAF,SAAA,CAARE,QAAQ,CAAA;AAChB,EAAA,IAAMC,MAAM,GAAGC,KAAK,CAAC,aAAa,CAAC,CAAA;AACnC,EAAA,IAAMC,OAAO,GAAA,EAAA,CAAAC,MAAA,CAAMH,MAAM,EAAQ,QAAA,CAAA,CAAA;EACjC,IAAMI,YAAY,GAAGT,IAAI,KAAA,IAAA,IAAJA,IAAI,KAAJA,KAAAA,CAAAA,GAAAA,IAAI,GAAIK,MAAM,CAAA;EACnC,IAAAK,qBAAA,GAAiCC,oBAAoB,CAAC;AACpDnB,MAAAA,KAAK,EAALA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