@channel.io/bezier-react 3.1.2 → 3.1.4
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/dist/cjs/components/AlphaAvatar/Avatar.js +0 -2
- package/dist/cjs/components/AlphaAvatar/Avatar.js.map +1 -1
- package/dist/cjs/components/Avatar/Avatar.js +0 -2
- package/dist/cjs/components/Avatar/Avatar.js.map +1 -1
- package/dist/cjs/components/Badge/Badge.js +0 -1
- package/dist/cjs/components/Badge/Badge.js.map +1 -1
- package/dist/cjs/components/Checkbox/Checkbox.js +2 -0
- package/dist/cjs/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/cjs/components/Divider/Divider.js +1 -1
- package/dist/cjs/components/Divider/Divider.js.map +1 -1
- package/dist/cjs/components/Emoji/Emoji.js +0 -1
- package/dist/cjs/components/Emoji/Emoji.js.map +1 -1
- package/dist/cjs/components/FormControl/FormControl.js +0 -1
- package/dist/cjs/components/FormControl/FormControl.js.map +1 -1
- package/dist/cjs/components/FormHelperText/FormHelperText.js +4 -2
- package/dist/cjs/components/FormHelperText/FormHelperText.js.map +1 -1
- package/dist/cjs/components/NavGroup/NavGroup.js +4 -2
- package/dist/cjs/components/NavGroup/NavGroup.js.map +1 -1
- package/dist/cjs/components/NavItem/NavItem.js +4 -2
- package/dist/cjs/components/NavItem/NavItem.js.map +1 -1
- package/dist/cjs/components/SegmentedControl/SegmentedControl.js +10 -3
- package/dist/cjs/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/cjs/components/Switch/Switch.js +0 -1
- package/dist/cjs/components/Switch/Switch.js.map +1 -1
- package/dist/cjs/components/Tag/Tag.js +5 -2
- package/dist/cjs/components/Tag/Tag.js.map +1 -1
- package/dist/cjs/components/TextField/TextField.js +5 -2
- package/dist/cjs/components/TextField/TextField.js.map +1 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/esm/components/AlphaAvatar/Avatar.mjs +1 -1
- package/dist/esm/components/AlphaAvatar/Avatar.mjs.map +1 -1
- package/dist/esm/components/Avatar/Avatar.mjs +1 -1
- package/dist/esm/components/Avatar/Avatar.mjs.map +1 -1
- package/dist/esm/components/Badge/Badge.mjs +1 -1
- package/dist/esm/components/Badge/Badge.mjs.map +1 -1
- package/dist/esm/components/Checkbox/Checkbox.mjs +2 -0
- package/dist/esm/components/Checkbox/Checkbox.mjs.map +1 -1
- package/dist/esm/components/Divider/Divider.mjs +2 -1
- package/dist/esm/components/Divider/Divider.mjs.map +1 -1
- package/dist/esm/components/Emoji/Emoji.mjs +1 -1
- package/dist/esm/components/Emoji/Emoji.mjs.map +1 -1
- package/dist/esm/components/FormControl/FormControl.mjs +1 -1
- package/dist/esm/components/FormControl/FormControl.mjs.map +1 -1
- package/dist/esm/components/FormHelperText/FormHelperText.mjs +5 -1
- package/dist/esm/components/FormHelperText/FormHelperText.mjs.map +1 -1
- package/dist/esm/components/NavGroup/NavGroup.mjs +5 -1
- package/dist/esm/components/NavGroup/NavGroup.mjs.map +1 -1
- package/dist/esm/components/NavItem/NavItem.mjs +5 -1
- package/dist/esm/components/NavItem/NavItem.mjs.map +1 -1
- package/dist/esm/components/SegmentedControl/SegmentedControl.mjs +10 -3
- package/dist/esm/components/SegmentedControl/SegmentedControl.mjs.map +1 -1
- package/dist/esm/components/Switch/Switch.mjs +1 -1
- package/dist/esm/components/Switch/Switch.mjs.map +1 -1
- package/dist/esm/components/Tag/Tag.mjs +6 -1
- package/dist/esm/components/Tag/Tag.mjs.map +1 -1
- package/dist/esm/components/TextField/TextField.mjs +6 -1
- package/dist/esm/components/TextField/TextField.mjs.map +1 -1
- package/dist/esm/styles.css +1 -1
- package/dist/types/components/AlphaAvatar/Avatar.d.ts +0 -2
- package/dist/types/components/AlphaAvatar/Avatar.d.ts.map +1 -1
- package/dist/types/components/Avatar/Avatar.d.ts +0 -2
- package/dist/types/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/types/components/Badge/Badge.d.ts +0 -1
- package/dist/types/components/Badge/Badge.d.ts.map +1 -1
- package/dist/types/components/Checkbox/Checkbox.d.ts +2 -1
- package/dist/types/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/types/components/Divider/Divider.d.ts +0 -1
- package/dist/types/components/Divider/Divider.d.ts.map +1 -1
- package/dist/types/components/Emoji/Emoji.d.ts +0 -1
- package/dist/types/components/Emoji/Emoji.d.ts.map +1 -1
- package/dist/types/components/FormControl/FormControl.d.ts +0 -1
- package/dist/types/components/FormControl/FormControl.d.ts.map +1 -1
- package/dist/types/components/FormHelperText/FormHelperText.d.ts +0 -2
- package/dist/types/components/FormHelperText/FormHelperText.d.ts.map +1 -1
- package/dist/types/components/NavGroup/NavGroup.d.ts +0 -2
- package/dist/types/components/NavGroup/NavGroup.d.ts.map +1 -1
- package/dist/types/components/NavItem/NavItem.d.ts +0 -2
- package/dist/types/components/NavItem/NavItem.d.ts.map +1 -1
- package/dist/types/components/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/types/components/Switch/Switch.d.ts +0 -1
- package/dist/types/components/Switch/Switch.d.ts.map +1 -1
- package/dist/types/components/Tag/Tag.d.ts +0 -2
- package/dist/types/components/Tag/Tag.d.ts.map +1 -1
- package/dist/types/components/TextField/TextField.d.ts +0 -2
- package/dist/types/components/TextField/TextField.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/components/AlphaAvatar/Avatar.test.tsx +1 -71
- package/src/components/AlphaAvatar/Avatar.tsx +2 -2
- package/src/components/AlphaAvatarGroup/AvatarGroup.test.tsx +0 -12
- package/src/components/Avatar/Avatar.test.tsx +1 -71
- package/src/components/Avatar/Avatar.tsx +2 -2
- package/src/components/AvatarGroup/AvatarGroup.test.tsx +0 -12
- package/src/components/Badge/Badge.tsx +2 -2
- package/src/components/Checkbox/Checkbox.tsx +6 -1
- package/src/components/Divider/Divider.test.tsx +11 -12
- package/src/components/Divider/Divider.tsx +5 -1
- package/src/components/Emoji/Emoji.tsx +4 -1
- package/src/components/FormControl/FormControl.test.tsx +1 -39
- package/src/components/FormControl/FormControl.tsx +1 -1
- package/src/components/FormHelperText/FormHelperText.test.tsx +11 -30
- package/src/components/FormHelperText/FormHelperText.tsx +9 -2
- package/src/components/FormLabel/FormLabel.test.tsx +0 -7
- package/src/components/Help/Help.test.tsx +0 -14
- package/src/components/LegacyTooltip/LegacyTooltip.test.tsx +0 -12
- package/src/components/Modal/Modal.test.tsx +8 -1
- package/src/components/NavGroup/NavGroup.tsx +9 -2
- package/src/components/NavItem/NavItem.tsx +9 -2
- package/src/components/SegmentedControl/SegmentedControl.module.scss +1 -1
- package/src/components/SegmentedControl/SegmentedControl.tsx +16 -3
- package/src/components/Slider/Slider.test.tsx +1 -8
- package/src/components/SmoothCornersBox/SmoothCornersBox.test.tsx +0 -5
- package/src/components/Switch/Switch.test.tsx +17 -17
- package/src/components/Switch/Switch.tsx +4 -1
- package/src/components/Tag/Tag.test.tsx +11 -15
- package/src/components/Tag/Tag.tsx +10 -2
- package/src/components/TextField/TextField.test.tsx +5 -5
- package/src/components/TextField/TextField.tsx +10 -2
- package/src/components/AlphaAvatar/__snapshots__/Avatar.test.tsx.snap +0 -93
- package/src/components/AlphaAvatarGroup/__snapshots__/AvatarGroup.test.tsx.snap +0 -215
- package/src/components/Avatar/__snapshots__/Avatar.test.tsx.snap +0 -93
- package/src/components/AvatarGroup/__snapshots__/AvatarGroup.test.tsx.snap +0 -215
- package/src/components/Badge/Badge.test.tsx +0 -27
- package/src/components/Badge/__snapshots__/Badge.test.tsx.snap +0 -8
- package/src/components/Emoji/Emoji.test.tsx +0 -32
- package/src/components/Emoji/__snapshots__/Emoji.test.tsx.snap +0 -11
- package/src/components/FormControl/__snapshots__/FormControl.test.tsx.snap +0 -249
- package/src/components/FormGroup/FormGroup.test.tsx +0 -24
- package/src/components/FormGroup/__snapshots__/FormGroup.test.tsx.snap +0 -10
- package/src/components/FormHelperText/__snapshots__/FormHelperText.test.tsx.snap +0 -24
- package/src/components/FormLabel/__snapshots__/FormLabel.test.tsx.snap +0 -11
- package/src/components/Help/__snapshots__/Help.test.tsx.snap +0 -21
- package/src/components/LegacyTooltip/__snapshots__/LegacyTooltip.test.tsx.snap +0 -37
- package/src/components/NavGroup/NavGroup.test.tsx +0 -75
- package/src/components/NavGroup/__snapshots__/NavGroup.test.tsx.snap +0 -121
- package/src/components/NavItem/NavItem.test.tsx +0 -66
- package/src/components/NavItem/__snapshots__/NavItem.test.tsx.snap +0 -75
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +0 -50
- package/src/components/SmoothCornersBox/__snapshots__/SmoothCornersBox.test.tsx.snap +0 -11
- package/src/components/Tag/__snapshots__/Tag.test.tsx.snap +0 -8
|
@@ -119,9 +119,7 @@ const Avatar = /*#__PURE__*/React.forwardRef(function Avatar({
|
|
|
119
119
|
});
|
|
120
120
|
});
|
|
121
121
|
|
|
122
|
-
exports.AVATAR_TEST_ID = AVATAR_TEST_ID;
|
|
123
122
|
exports.AVATAR_WRAPPER_TEST_ID = AVATAR_WRAPPER_TEST_ID;
|
|
124
123
|
exports.Avatar = Avatar;
|
|
125
|
-
exports.STATUS_WRAPPER_TEST_ID = STATUS_WRAPPER_TEST_ID;
|
|
126
124
|
exports.useAvatarRadiusToken = useAvatarRadiusToken;
|
|
127
125
|
//# sourceMappingURL=Avatar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","sources":["../../../../src/components/AlphaAvatar/Avatar.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, isValidElement, useMemo } from 'react'\n\nimport classNames from 'classnames'\n\nimport { isEmpty } from '~/src/utils/type'\n\nimport { useAvatarContext } from '~/src/components/AlphaAvatar/AvatarSizeContext'\nimport {\n SmoothCornersBox,\n type SmoothCornersBoxProps,\n} from '~/src/components/SmoothCornersBox'\nimport { Status, type StatusSize } from '~/src/components/Status'\nimport { useTokens } from '~/src/components/ThemeProvider'\n\nimport type { AvatarProps, AvatarSize } from './Avatar.types'\nimport defaultAvatarUrl from './assets/default-avatar.svg'\nimport useProgressiveImage from './useProgressiveImage'\n\nimport styles from './Avatar.module.scss'\n\nfunction getStatusSize(size: AvatarSize): StatusSize {\n switch (size) {\n case '90':\n case '120':\n return 'l'\n default:\n return 'm'\n }\n}\n\nfunction getShadow(size: AvatarSize): SmoothCornersBoxProps['shadow'] {\n const spreadRadius = (() => {\n switch (size) {\n case '90':\n return 3\n case '120':\n return 4\n default:\n return 2\n }\n })()\n\n return {\n spreadRadius,\n color: 'bg-white-high',\n }\n}\n\nexport function useAvatarRadiusToken() {\n // TODO: Replace this with useAlphaTokens\n return useTokens().global.radius['radius-42-p']\n}\n\nexport const AVATAR_WRAPPER_TEST_ID = 'bezier-avatar-wrapper'\
|
|
1
|
+
{"version":3,"file":"Avatar.js","sources":["../../../../src/components/AlphaAvatar/Avatar.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, isValidElement, useMemo } from 'react'\n\nimport classNames from 'classnames'\n\nimport { isEmpty } from '~/src/utils/type'\n\nimport { useAvatarContext } from '~/src/components/AlphaAvatar/AvatarSizeContext'\nimport {\n SmoothCornersBox,\n type SmoothCornersBoxProps,\n} from '~/src/components/SmoothCornersBox'\nimport { Status, type StatusSize } from '~/src/components/Status'\nimport { useTokens } from '~/src/components/ThemeProvider'\n\nimport type { AvatarProps, AvatarSize } from './Avatar.types'\nimport defaultAvatarUrl from './assets/default-avatar.svg'\nimport useProgressiveImage from './useProgressiveImage'\n\nimport styles from './Avatar.module.scss'\n\nfunction getStatusSize(size: AvatarSize): StatusSize {\n switch (size) {\n case '90':\n case '120':\n return 'l'\n default:\n return 'm'\n }\n}\n\nfunction getShadow(size: AvatarSize): SmoothCornersBoxProps['shadow'] {\n const spreadRadius = (() => {\n switch (size) {\n case '90':\n return 3\n case '120':\n return 4\n default:\n return 2\n }\n })()\n\n return {\n spreadRadius,\n color: 'bg-white-high',\n }\n}\n\nexport function useAvatarRadiusToken() {\n // TODO: Replace this with useAlphaTokens\n return useTokens().global.radius['radius-42-p']\n}\n\nexport const AVATAR_WRAPPER_TEST_ID = 'bezier-avatar-wrapper'\nconst AVATAR_TEST_ID = 'bezier-avatar'\nconst STATUS_WRAPPER_TEST_ID = 'bezier-status-wrapper'\n\n/**\n * `Avatar` is a component for representing some profile image.\n * @example\n *\n * ```tsx\n * <Avatar\n * avatarUrl=\"https://...\"\n * name=\"channel\"\n * size=\"48\"\n * showBorder\n * disabled\n * />\n * ```\n */\nexport const Avatar = forwardRef<HTMLDivElement, AvatarProps>(function Avatar(\n {\n avatarUrl = '',\n fallbackUrl = defaultAvatarUrl,\n size: sizeProps = '24',\n name,\n disabled = false,\n showBorder = false,\n smoothCorners = true,\n status,\n className,\n children,\n ...rest\n },\n forwardedRef\n) {\n const avatarGroupContext = useAvatarContext()\n const size = avatarGroupContext?.size ?? sizeProps\n const loadedAvatarUrl = useProgressiveImage(avatarUrl, fallbackUrl)\n const AVATAR_BORDER_RADIUS = useAvatarRadiusToken()\n\n const StatusComponent = useMemo(() => {\n if (\n (isEmpty(children) && !status) ||\n (children && !isValidElement(children))\n ) {\n return null\n }\n\n const Contents = (() => {\n if (children) {\n return children\n }\n if (status) {\n return (\n <Status\n type={status}\n size={getStatusSize(size)}\n />\n )\n }\n return null\n })()\n\n return (\n Contents && (\n <div\n className={styles.StatusWrapper}\n data-testid={STATUS_WRAPPER_TEST_ID}\n >\n {Contents}\n </div>\n )\n )\n }, [status, size, children])\n\n return (\n <div\n className={classNames(\n styles.Avatar,\n styles[`size-${size}`],\n disabled && styles.disabled,\n className\n )}\n data-disabled={disabled}\n data-testid={AVATAR_WRAPPER_TEST_ID}\n {...rest}\n >\n <SmoothCornersBox\n ref={forwardedRef}\n aria-description={name}\n className={classNames(\n styles.AvatarImage,\n Number(size) >= 72 && styles['big-size'],\n showBorder && styles.bordered\n )}\n disabled={!smoothCorners}\n borderRadius={AVATAR_BORDER_RADIUS}\n shadow={showBorder ? getShadow(size) : undefined}\n backgroundColor=\"bg-white-normal\"\n backgroundImage={loadedAvatarUrl}\n data-testid={AVATAR_TEST_ID}\n >\n {StatusComponent}\n </SmoothCornersBox>\n </div>\n )\n})\n"],"names":["getStatusSize","size","getShadow","spreadRadius","color","useAvatarRadiusToken","useTokens","global","radius","AVATAR_WRAPPER_TEST_ID","AVATAR_TEST_ID","STATUS_WRAPPER_TEST_ID","Avatar","forwardRef","avatarUrl","fallbackUrl","defaultAvatarUrl","sizeProps","name","disabled","showBorder","smoothCorners","status","className","children","rest","forwardedRef","_avatarGroupContext$s","avatarGroupContext","useAvatarContext","loadedAvatarUrl","useProgressiveImage","AVATAR_BORDER_RADIUS","StatusComponent","useMemo","isEmpty","isValidElement","Contents","_jsx","Status","type","styles","StatusWrapper","classNames","SmoothCornersBox","ref","AvatarImage","Number","bordered","borderRadius","shadow","undefined","backgroundColor","backgroundImage"],"mappings":";;;;;;;;;;;;;;AAsBA,SAASA,aAAaA,CAACC,IAAgB,EAAc;AACnD,EAAA,QAAQA,IAAI;AACV,IAAA,KAAK,IAAI;AACT,IAAA,KAAK,KAAK;AACR,MAAA,OAAO,GAAG;AACZ,IAAA;AACE,MAAA,OAAO,GAAG;AACd;AACF;AAEA,SAASC,SAASA,CAACD,IAAgB,EAAmC;EACpE,MAAME,YAAY,GAAG,CAAC,MAAM;AAC1B,IAAA,QAAQF,IAAI;AACV,MAAA,KAAK,IAAI;AACP,QAAA,OAAO,CAAC;AACV,MAAA,KAAK,KAAK;AACR,QAAA,OAAO,CAAC;AACV,MAAA;AACE,QAAA,OAAO,CAAC;AACZ;AACF,GAAC,GAAG;EAEJ,OAAO;IACLE,YAAY;AACZC,IAAAA,KAAK,EAAE;GACR;AACH;AAEO,SAASC,oBAAoBA,GAAG;AACrC;EACA,OAAOC,uBAAS,EAAE,CAACC,MAAM,CAACC,MAAM,CAAC,aAAa,CAAC;AACjD;AAEO,MAAMC,sBAAsB,GAAG;AACtC,MAAMC,cAAc,GAAG,eAAe;AACtC,MAAMC,sBAAsB,GAAG,uBAAuB;;AAEtD;AACA;AACA;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QAAA,EAE3BS;KACe;AAAC,GAChB,CAAC;AAEV,CAAC;;;;;;"}
|
|
@@ -102,9 +102,7 @@ const Avatar = /*#__PURE__*/React.forwardRef(function Avatar({
|
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
exports.AVATAR_TEST_ID = AVATAR_TEST_ID;
|
|
106
105
|
exports.AVATAR_WRAPPER_TEST_ID = AVATAR_WRAPPER_TEST_ID;
|
|
107
106
|
exports.Avatar = Avatar;
|
|
108
|
-
exports.STATUS_WRAPPER_TEST_ID = STATUS_WRAPPER_TEST_ID;
|
|
109
107
|
exports.useAvatarRadiusToken = useAvatarRadiusToken;
|
|
110
108
|
//# sourceMappingURL=Avatar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","sources":["../../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, isValidElement, useMemo } from 'react'\n\nimport classNames from 'classnames'\n\nimport { isEmpty } from '~/src/utils/type'\n\nimport {\n SmoothCornersBox,\n type SmoothCornersBoxProps,\n} from '~/src/components/SmoothCornersBox'\nimport { Status, type StatusSize } from '~/src/components/Status'\nimport { useTokens } from '~/src/components/ThemeProvider'\n\nimport type { AvatarProps } from './Avatar.types'\nimport defaultAvatarUrl from './assets/default-avatar.svg'\nimport useProgressiveImage from './useProgressiveImage'\n\nimport styles from './Avatar.module.scss'\n\nconst shadow: SmoothCornersBoxProps['shadow'] = {\n spreadRadius: 2,\n color: 'bg-white-high',\n}\n\nexport function useAvatarRadiusToken() {\n return useTokens().global.radius['radius-42-p']\n}\n\nexport const AVATAR_WRAPPER_TEST_ID = 'bezier-avatar-wrapper'\
|
|
1
|
+
{"version":3,"file":"Avatar.js","sources":["../../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, isValidElement, useMemo } from 'react'\n\nimport classNames from 'classnames'\n\nimport { isEmpty } from '~/src/utils/type'\n\nimport {\n SmoothCornersBox,\n type SmoothCornersBoxProps,\n} from '~/src/components/SmoothCornersBox'\nimport { Status, type StatusSize } from '~/src/components/Status'\nimport { useTokens } from '~/src/components/ThemeProvider'\n\nimport type { AvatarProps } from './Avatar.types'\nimport defaultAvatarUrl from './assets/default-avatar.svg'\nimport useProgressiveImage from './useProgressiveImage'\n\nimport styles from './Avatar.module.scss'\n\nconst shadow: SmoothCornersBoxProps['shadow'] = {\n spreadRadius: 2,\n color: 'bg-white-high',\n}\n\nexport function useAvatarRadiusToken() {\n return useTokens().global.radius['radius-42-p']\n}\n\nexport const AVATAR_WRAPPER_TEST_ID = 'bezier-avatar-wrapper'\nconst AVATAR_TEST_ID = 'bezier-avatar'\nconst STATUS_WRAPPER_TEST_ID = 'bezier-status-wrapper'\n\n/**\n * `Avatar` is a component for representing some profile image.\n * @example\n *\n * ```tsx\n * <Avatar\n * avatarUrl=\"https://...\"\n * name=\"channel\"\n * size=\"48\"\n * showBorder\n * disabled\n * />\n * ```\n */\nexport const Avatar = forwardRef<HTMLDivElement, AvatarProps>(function Avatar(\n {\n avatarUrl = '',\n fallbackUrl = defaultAvatarUrl,\n size = '24',\n name,\n disabled = false,\n showBorder = false,\n smoothCorners = true,\n status,\n className,\n children,\n ...rest\n },\n forwardedRef\n) {\n const loadedAvatarUrl = useProgressiveImage(avatarUrl, fallbackUrl)\n const AVATAR_BORDER_RADIUS = useAvatarRadiusToken()\n\n const StatusComponent = useMemo(() => {\n if (\n (isEmpty(children) && !status) ||\n (children && !isValidElement(children))\n ) {\n return null\n }\n\n const statusSize: StatusSize = (() => {\n switch (size) {\n case '90':\n case '120':\n return 'l'\n default:\n return 'm'\n }\n })()\n\n const Contents = (() => {\n if (children) {\n return children\n }\n if (status) {\n return (\n <Status\n type={status}\n size={statusSize}\n />\n )\n }\n return null\n })()\n\n return (\n Contents && (\n <div\n className={styles.StatusWrapper}\n data-testid={STATUS_WRAPPER_TEST_ID}\n >\n {Contents}\n </div>\n )\n )\n }, [status, size, children])\n\n return (\n <div\n className={classNames(\n styles.Avatar,\n styles[`size-${size}`],\n disabled && styles.disabled,\n className\n )}\n data-disabled={disabled}\n data-testid={AVATAR_WRAPPER_TEST_ID}\n {...rest}\n >\n <SmoothCornersBox\n ref={forwardedRef}\n aria-description={name}\n className={classNames(\n styles.AvatarImage,\n Number(size) >= 72 && styles['big-size'],\n showBorder && styles.bordered\n )}\n disabled={!smoothCorners}\n borderRadius={AVATAR_BORDER_RADIUS}\n shadow={showBorder ? shadow : undefined}\n backgroundColor=\"bg-white-normal\"\n backgroundImage={loadedAvatarUrl}\n data-testid={AVATAR_TEST_ID}\n >\n {StatusComponent}\n </SmoothCornersBox>\n </div>\n )\n})\n"],"names":["shadow","spreadRadius","color","useAvatarRadiusToken","useTokens","global","radius","AVATAR_WRAPPER_TEST_ID","AVATAR_TEST_ID","STATUS_WRAPPER_TEST_ID","Avatar","forwardRef","avatarUrl","fallbackUrl","defaultAvatarUrl","size","name","disabled","showBorder","smoothCorners","status","className","children","rest","forwardedRef","loadedAvatarUrl","useProgressiveImage","AVATAR_BORDER_RADIUS","StatusComponent","useMemo","isEmpty","isValidElement","statusSize","Contents","_jsx","Status","type","styles","StatusWrapper","classNames","SmoothCornersBox","ref","AvatarImage","Number","bordered","borderRadius","undefined","backgroundColor","backgroundImage"],"mappings":";;;;;;;;;;;;;AAqBA,MAAMA,MAAuC,GAAG;AAC9CC,EAAAA,YAAY,EAAE,CAAC;AACfC,EAAAA,KAAK,EAAE;AACT,CAAC;AAEM,SAASC,oBAAoBA,GAAG;EACrC,OAAOC,uBAAS,EAAE,CAACC,MAAM,CAACC,MAAM,CAAC,aAAa,CAAC;AACjD;AAEO,MAAMC,sBAAsB,GAAG;AACtC,MAAMC,cAAc,GAAG,eAAe;AACtC,MAAMC,sBAAsB,GAAG,uBAAuB;;AAEtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaC,MAAM,gBAAGC,gBAAU,CAA8B,SA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7B,sBAAuB;AAAAa,MAAAA,QAAA,EAEnCW;AAAQ,KACN,CACN;GAEJ,EAAE,CAACb,MAAM,EAAEL,IAAI,EAAEO,QAAQ,CAAC,CAAC;AAE5B,EAAA,oBACEY,cAAA,CAAA,KAAA,EAAA;IACEb,SAAS,EAAEkB,aAAU,CACnBF,qBAAM,CAAC3B,MAAM,EACb2B,qBAAM,CAAC,CAAA,KAAA,EAAQtB,IAAI,CAAE,CAAA,CAAC,EACtBE,QAAQ,IAAIoB,qBAAM,CAACpB,QAAQ,EAC3BI,SACF,CAAE;AACF,IAAA,eAAA,EAAeJ,QAAS;AACxB,IAAA,aAAA,EAAaV,sBAAuB;AAAA,IAAA,GAChCgB,IAAI;IAAAD,QAAA,eAERY,cAAA,CAACM,iCAAgB,EAAA;AACfC,MAAAA,GAAG,EAAEjB,YAAa;AAClB,MAAA,kBAAA,EAAkBR,IAAK;MACvBK,SAAS,EAAEkB,aAAU,CACnBF,qBAAM,CAACK,WAAW,EAClBC,MAAM,CAAC5B,IAAI,CAAC,IAAI,EAAE,IAAIsB,qBAAM,CAAC,UAAU,CAAC,EACxCnB,UAAU,IAAImB,qBAAM,CAACO,QACvB,CAAE;MACF3B,QAAQ,EAAE,CAACE,aAAc;AACzB0B,MAAAA,YAAY,EAAElB,oBAAqB;AACnC3B,MAAAA,MAAM,EAAEkB,UAAU,GAAGlB,MAAM,GAAG8C,SAAU;AACxCC,MAAAA,eAAe,EAAC,iBAAiB;AACjCC,MAAAA,eAAe,EAAEvB,eAAgB;AACjC,MAAA,aAAA,EAAajB,cAAe;AAAAc,MAAAA,QAAA,EAE3BM;KACe;AAAC,GAChB,CAAC;AAEV,CAAC;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sources":["../../../../src/components/Badge/Badge.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, memo } from 'react'\n\nimport { isEmpty } from '~/src/utils/type'\n\nimport { BaseTagBadge, BaseTagBadgeText } from '~/src/components/BaseTagBadge'\nimport { Icon } from '~/src/components/Icon'\n\nimport { type BadgeProps } from './Badge.types'\n\
|
|
1
|
+
{"version":3,"file":"Badge.js","sources":["../../../../src/components/Badge/Badge.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, memo } from 'react'\n\nimport { isEmpty } from '~/src/utils/type'\n\nimport { BaseTagBadge, BaseTagBadgeText } from '~/src/components/BaseTagBadge'\nimport { Icon } from '~/src/components/Icon'\n\nimport { type BadgeProps } from './Badge.types'\n\nconst BADGE_TEST_ID = 'bezier-badge'\n\n/**\n * `Badge` is a component for representing badge, which consists of text and icon.\n * @example\n * ```tsx\n * <Badge\n * size=\"xs\"\n * variant=\"blue\"\n * icon={AppleIcon}\n * >\n * Beta\n * </Badge>\n * ```\n */\nexport const Badge = memo(\n forwardRef<HTMLDivElement, BadgeProps>(function Badge(\n { size = 'm', variant = 'default', truncated, icon, children, ...rest },\n forwardedRef\n ) {\n return (\n <BaseTagBadge\n ref={forwardedRef}\n size={size}\n variant={variant}\n data-testid={BADGE_TEST_ID}\n {...rest}\n >\n {icon && (\n <Icon\n source={icon}\n size=\"xs\"\n />\n )}\n\n {!isEmpty(children) && (\n <BaseTagBadgeText\n size={size}\n marginHorizontal={3}\n truncated={truncated}\n >\n {children}\n </BaseTagBadgeText>\n )}\n </BaseTagBadge>\n )\n })\n)\n"],"names":["BADGE_TEST_ID","Badge","memo","forwardRef","size","variant","truncated","icon","children","rest","forwardedRef","_jsxs","BaseTagBadge","ref","_jsx","Icon","source","isEmpty","BaseTagBadgeText","marginHorizontal"],"mappings":";;;;;;;;AAWA,MAAMA,aAAa,GAAG,cAAc;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,KAAK,gBAAGC,UAAI,cACvBC,gBAAU,CAA6B,SAASF,KAAKA,CACnD;AAAEG,EAAAA,IAAI,GAAG,GAAG;AAAEC,EAAAA,OAAO,GAAG,SAAS;EAAEC,SAAS;EAAEC,IAAI;EAAEC,QAAQ;EAAE,GAAGC;AAAK,CAAC,EACvEC,YAAY,EACZ;EACA,oBACEC,eAAA,CAACC,yBAAY,EAAA;AACXC,IAAAA,GAAG,EAAEH,YAAa;AAClBN,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,OAAO,EAAEA,OAAQ;AACjB,IAAA,aAAA,EAAaL,aAAc;AAAA,IAAA,GACvBS,IAAI;AAAAD,IAAAA,QAAA,EAEPD,CAAAA,IAAI,iBACHO,cAAA,CAACC,SAAI,EAAA;AACHC,MAAAA,MAAM,EAAET,IAAK;AACbH,MAAAA,IAAI,EAAC;KACN,CACF,EAEA,CAACa,YAAO,CAACT,QAAQ,CAAC,iBACjBM,cAAA,CAACI,6BAAgB,EAAA;AACfd,MAAAA,IAAI,EAAEA,IAAK;AACXe,MAAAA,gBAAgB,EAAE,CAAE;AACpBb,MAAAA,SAAS,EAAEA,SAAU;AAAAE,MAAAA,QAAA,EAEpBA;AAAQ,KACO,CACnB;AAAA,GACW,CAAC;AAEnB,CAAC,CACH;;;;"}
|
|
@@ -73,6 +73,8 @@ function CheckboxImpl({
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/* NOTE: This is a workaround to avoid infinite type recursion when directly using `ReturnType` */
|
|
77
|
+
|
|
76
78
|
/**
|
|
77
79
|
* `Checkbox` is a control that allows the user to toggle between checked and not checked.
|
|
78
80
|
* It can be used with labels or standalone.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["'use client'\nimport { forwardRef } from 'react'\nimport * as React from 'react'\n\nimport { CheckBoldIcon, HyphenBoldIcon } from '@channel.io/bezier-icons'\nimport * as CheckboxPrimitive from '@radix-ui/react-checkbox'\nimport classNames from 'classnames'\n\nimport useId from '~/src/hooks/useId'\nimport { getFormFieldSizeClassName } from '~/src/types/props-helpers'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { useFormFieldProps } from '~/src/components/FormControl'\nimport { Icon } from '~/src/components/Icon'\nimport { Text } from '~/src/components/Text'\n\nimport { type CheckboxProps, type CheckedState } from './Checkbox.types'\n\nimport styles from './Checkbox.module.scss'\n\ninterface CheckIconProps {\n style: React.CSSProperties\n 'data-state': 'checked' | 'unchecked' | 'indeterminate'\n 'data-disabled': boolean | undefined\n}\n\n/* NOTE: Props are injected at runtime by `CheckboxPrimitive.Indicator`. */\nconst CheckIcon = forwardRef<SVGSVGElement, CheckIconProps>(\n function CheckIcon(props, forwardedRef) {\n // eslint-disable-next-line react/destructuring-assignment\n const state = props['data-state']\n const isUnchecked = state === 'unchecked'\n const isIndeterminate = state === 'indeterminate'\n\n return (\n <Icon\n className={styles.CheckIcon}\n ref={forwardedRef}\n source={!isIndeterminate ? CheckBoldIcon : HyphenBoldIcon}\n size=\"xs\"\n color={isUnchecked ? 'bg-black-dark' : 'bgtxt-absolute-white-dark'}\n {...props}\n />\n )\n }\n)\n\nfunction CheckboxImpl<Checked extends CheckedState>(\n { children, className, checked, id: idProp, ...rest }: CheckboxProps<Checked>,\n forwardedRef: React.Ref<HTMLButtonElement>\n) {\n const {\n id: formFieldId,\n hasError,\n ...formFieldProps\n } = useFormFieldProps(rest)\n\n const id = useId(idProp ?? formFieldId, 'bezier-checkbox')\n\n return (\n <div\n className={classNames(styles.Container, getFormFieldSizeClassName('m'))}\n >\n <CheckboxPrimitive.Root\n asChild\n className={classNames(styles.Checkbox, className)}\n ref={forwardedRef}\n id={id}\n checked={checked}\n data-invalid={formFieldProps['aria-invalid']}\n {...formFieldProps}\n >\n <BaseButton>\n <CheckboxPrimitive.Indicator\n asChild\n /* NOTE: To allow the icon to be rendered even if unchecked. */\n forceMount\n >\n {/* @ts-expect-error */}\n <CheckIcon />\n </CheckboxPrimitive.Indicator>\n </BaseButton>\n </CheckboxPrimitive.Root>\n {children && (\n <Text\n as=\"label\"\n // TODO: Apply polymorphic types to `as` prop.\n // @ts-expect-error\n htmlFor={id}\n className={styles.Label}\n typo=\"14\"\n color=\"txt-black-darkest\"\n >\n {children}\n </Text>\n )}\n </div>\n )\n}\n\n/**\n * `Checkbox` is a control that allows the user to toggle between checked and not checked.\n * It can be used with labels or standalone.\n * @example\n *\n * ```tsx\n * const [checked, setChecked] = useState(false)\n * // Controlled / With label\n * <Checkbox\n * checked={checked}\n * onCheckedChange={setChecked}\n * >\n * Label\n * </Checkbox>\n * // Controlled / Standalone\n * <Checkbox\n * checked={checked}\n * onCheckedChange={setChecked}\n * />\n * // Uncontrolled\n * <Checkbox\n * defaultChecked={true}\n * >\n * Label\n * </Checkbox>\n * ```\n */\nexport const Checkbox = forwardRef(CheckboxImpl) as <\n Checked extends CheckedState,\n>(\n props: CheckboxProps<Checked> & {\n ref?: React.ForwardedRef<HTMLButtonElement>\n }\n) =>
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["'use client'\nimport { forwardRef } from 'react'\nimport * as React from 'react'\n\nimport { CheckBoldIcon, HyphenBoldIcon } from '@channel.io/bezier-icons'\nimport * as CheckboxPrimitive from '@radix-ui/react-checkbox'\nimport classNames from 'classnames'\n\nimport useId from '~/src/hooks/useId'\nimport { getFormFieldSizeClassName } from '~/src/types/props-helpers'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { useFormFieldProps } from '~/src/components/FormControl'\nimport { Icon } from '~/src/components/Icon'\nimport { Text } from '~/src/components/Text'\n\nimport { type CheckboxProps, type CheckedState } from './Checkbox.types'\n\nimport styles from './Checkbox.module.scss'\n\ninterface CheckIconProps {\n style: React.CSSProperties\n 'data-state': 'checked' | 'unchecked' | 'indeterminate'\n 'data-disabled': boolean | undefined\n}\n\n/* NOTE: Props are injected at runtime by `CheckboxPrimitive.Indicator`. */\nconst CheckIcon = forwardRef<SVGSVGElement, CheckIconProps>(\n function CheckIcon(props, forwardedRef) {\n // eslint-disable-next-line react/destructuring-assignment\n const state = props['data-state']\n const isUnchecked = state === 'unchecked'\n const isIndeterminate = state === 'indeterminate'\n\n return (\n <Icon\n className={styles.CheckIcon}\n ref={forwardedRef}\n source={!isIndeterminate ? CheckBoldIcon : HyphenBoldIcon}\n size=\"xs\"\n color={isUnchecked ? 'bg-black-dark' : 'bgtxt-absolute-white-dark'}\n {...props}\n />\n )\n }\n)\n\nfunction CheckboxImpl<Checked extends CheckedState>(\n { children, className, checked, id: idProp, ...rest }: CheckboxProps<Checked>,\n forwardedRef: React.Ref<HTMLButtonElement>\n) {\n const {\n id: formFieldId,\n hasError,\n ...formFieldProps\n } = useFormFieldProps(rest)\n\n const id = useId(idProp ?? formFieldId, 'bezier-checkbox')\n\n return (\n <div\n className={classNames(styles.Container, getFormFieldSizeClassName('m'))}\n >\n <CheckboxPrimitive.Root\n asChild\n className={classNames(styles.Checkbox, className)}\n ref={forwardedRef}\n id={id}\n checked={checked}\n data-invalid={formFieldProps['aria-invalid']}\n {...formFieldProps}\n >\n <BaseButton>\n <CheckboxPrimitive.Indicator\n asChild\n /* NOTE: To allow the icon to be rendered even if unchecked. */\n forceMount\n >\n {/* @ts-expect-error */}\n <CheckIcon />\n </CheckboxPrimitive.Indicator>\n </BaseButton>\n </CheckboxPrimitive.Root>\n {children && (\n <Text\n as=\"label\"\n // TODO: Apply polymorphic types to `as` prop.\n // @ts-expect-error\n htmlFor={id}\n className={styles.Label}\n typo=\"14\"\n color=\"txt-black-darkest\"\n >\n {children}\n </Text>\n )}\n </div>\n )\n}\n\n/* NOTE: This is a workaround to avoid infinite type recursion when directly using `ReturnType` */\ntype ReturnTypeOfCheckboxImpl<Checked extends CheckedState> = ReturnType<\n typeof CheckboxImpl<Checked>\n>\n\n/**\n * `Checkbox` is a control that allows the user to toggle between checked and not checked.\n * It can be used with labels or standalone.\n * @example\n *\n * ```tsx\n * const [checked, setChecked] = useState(false)\n * // Controlled / With label\n * <Checkbox\n * checked={checked}\n * onCheckedChange={setChecked}\n * >\n * Label\n * </Checkbox>\n * // Controlled / Standalone\n * <Checkbox\n * checked={checked}\n * onCheckedChange={setChecked}\n * />\n * // Uncontrolled\n * <Checkbox\n * defaultChecked={true}\n * >\n * Label\n * </Checkbox>\n * ```\n */\nexport const Checkbox = forwardRef(CheckboxImpl) as <\n Checked extends CheckedState,\n>(\n props: CheckboxProps<Checked> & {\n ref?: React.ForwardedRef<HTMLButtonElement>\n }\n) => ReturnTypeOfCheckboxImpl<Checked>\n"],"names":["CheckIcon","forwardRef","props","forwardedRef","state","isUnchecked","isIndeterminate","_jsx","Icon","className","styles","ref","source","CheckBoldIcon","HyphenBoldIcon","size","color","CheckboxImpl","children","checked","id","idProp","rest","formFieldId","hasError","formFieldProps","useFormFieldProps","useId","_jsxs","classNames","Container","getFormFieldSizeClassName","CheckboxPrimitive","asChild","Checkbox","BaseButton","forceMount","Text","as","htmlFor","Label","typo"],"mappings":";;;;;;;;;;;;;;;AA0BA;AACA,MAAMA,SAAS,gBAAGC,gBAAU,CAC1B,SAASD,SAASA,CAACE,KAAK,EAAEC,YAAY,EAAE;AACtC;AACA,EAAA,MAAMC,KAAK,GAAGF,KAAK,CAAC,YAAY,CAAC;AACjC,EAAA,MAAMG,WAAW,GAAGD,KAAK,KAAK,WAAW;AACzC,EAAA,MAAME,eAAe,GAAGF,KAAK,KAAK,eAAe;EAEjD,oBACEG,cAAA,CAACC,SAAI,EAAA;IACHC,SAAS,EAAEC,uBAAM,CAACV,SAAU;AAC5BW,IAAAA,GAAG,EAAER,YAAa;AAClBS,IAAAA,MAAM,EAAE,CAACN,eAAe,GAAGO,yBAAa,GAAGC,0BAAe;AAC1DC,IAAAA,IAAI,EAAC,IAAI;AACTC,IAAAA,KAAK,EAAEX,WAAW,GAAG,eAAe,GAAG,2BAA4B;IAAA,GAC/DH;AAAK,GACV,CAAC;AAEN,CACF,CAAC;AAED,SAASe,YAAYA,CACnB;EAAEC,QAAQ;EAAET,SAAS;EAAEU,OAAO;AAAEC,EAAAA,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AI;AACTzB,MAAAA,KAAK,EAAC,mBAAmB;AAAAE,MAAAA,QAAA,EAExBA;AAAQ,KACL,CACP;AAAA,GACE,CAAC;AAEV;;AAEA;;AAKA;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;MACagB,QAAQ,gBAAGjC,gBAAU,CAACgB,YAAY;;;;"}
|
|
@@ -35,11 +35,11 @@ const Divider = /*#__PURE__*/React.forwardRef(({
|
|
|
35
35
|
ref: forwardedRef,
|
|
36
36
|
style: style,
|
|
37
37
|
className: index$1.default(Divider_module.default.Divider, Divider_module.default.variables, Divider_module.default[orientation], withoutIndent && Divider_module.default['without-indent'], withoutParallelIndent && Divider_module.default['without-parallel-indent'], withoutSideIndent && Divider_module.default['without-side-indent'], className),
|
|
38
|
+
role: "separator",
|
|
38
39
|
"data-testid": DIVIDER_TEST_ID,
|
|
39
40
|
...rest
|
|
40
41
|
})
|
|
41
42
|
}));
|
|
42
43
|
|
|
43
|
-
exports.DIVIDER_TEST_ID = DIVIDER_TEST_ID;
|
|
44
44
|
exports.Divider = Divider;
|
|
45
45
|
//# sourceMappingURL=Divider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Divider.js","sources":["../../../../src/components/Divider/Divider.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef } from 'react'\n\nimport * as SeparatorPrimitive from '@radix-ui/react-separator'\nimport classNames from 'classnames'\n\nimport { type DividerProps } from './Divider.types'\n\nimport styles from './Divider.module.scss'\n\
|
|
1
|
+
{"version":3,"file":"Divider.js","sources":["../../../../src/components/Divider/Divider.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef } from 'react'\n\nimport * as SeparatorPrimitive from '@radix-ui/react-separator'\nimport classNames from 'classnames'\n\nimport { type DividerProps } from './Divider.types'\n\nimport styles from './Divider.module.scss'\n\n/**\n * @deprecated\n */\nconst DIVIDER_TEST_ID = 'bezier-divider'\n\n/**\n * `Divider` is a component to visually or semantically separate content.\n * @example\n *\n * ```tsx\n * <Divider\n * withoutSideIndent\n * />\n * ```\n */\nexport const Divider = forwardRef<HTMLDivElement, DividerProps>(\n (\n {\n orientation = 'horizontal',\n decorative,\n withoutSideIndent = false,\n withoutParallelIndent = false,\n withoutIndent = false,\n style,\n className,\n ...rest\n },\n forwardedRef\n ) => (\n <SeparatorPrimitive.Root\n asChild\n orientation={orientation}\n decorative={decorative}\n >\n <div\n ref={forwardedRef}\n style={style}\n className={classNames(\n styles.Divider,\n styles.variables,\n styles[orientation],\n withoutIndent && styles['without-indent'],\n withoutParallelIndent && styles['without-parallel-indent'],\n withoutSideIndent && styles['without-side-indent'],\n className\n )}\n role=\"separator\"\n data-testid={DIVIDER_TEST_ID}\n {...rest}\n />\n </SeparatorPrimitive.Root>\n )\n)\n"],"names":["DIVIDER_TEST_ID","Divider","forwardRef","orientation","decorative","withoutSideIndent","withoutParallelIndent","withoutIndent","style","className","rest","forwardedRef","_jsx","SeparatorPrimitive","asChild","children","ref","classNames","styles","variables","role"],"mappings":";;;;;;;;AAcA,MAAMA,eAAe,GAAG,gBAAgB;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaC,MAAAA,OAAO,gBAAGC,gBAAU,CAC/B,CACE;AACEC,EAAAA,WAAW,GAAG,YAAY;EAC1BC,UAAU;AACVC,EAAAA,iBAAiB,GAAG,KAAK;AACzBC,EAAAA,qBAAqB,GAAG,KAAK;AAC7BC,EAAAA,aAAa,GAAG,KAAK;EACrBC,KAAK;EACLC,SAAS;EACT,GAAGC;AACL,CAAC,EACDC,YAAY,kBAEZC,cAAA,CAACC,UAAuB,EAAA;EACtBC,OAAO,EAAA,IAAA;AACPX,EAAAA,WAAW,EAAEA,WAAY;AACzBC,EAAAA,UAAU,EAAEA,UAAW;AAAAW,EAAAA,QAAA,eAEvBH,cAAA,CAAA,KAAA,EAAA;AACEI,IAAAA,GAAG,EAAEL,YAAa;AAClBH,IAAAA,KAAK,EAAEA,KAAM;AACbC,IAAAA,SAAS,EAAEQ,eAAU,CACnBC,sBAAM,CAACjB,OAAO,EACdiB,sBAAM,CAACC,SAAS,EAChBD,sBAAM,CAACf,WAAW,CAAC,EACnBI,aAAa,IAAIW,sBAAM,CAAC,gBAAgB,CAAC,EACzCZ,qBAAqB,IAAIY,sBAAM,CAAC,yBAAyB,CAAC,EAC1Db,iBAAiB,IAAIa,sBAAM,CAAC,qBAAqB,CAAC,EAClDT,SACF,CAAE;AACFW,IAAAA,IAAI,EAAC,WAAW;AAChB,IAAA,aAAA,EAAapB,eAAgB;IAAA,GACzBU;GACL;AAAC,CACqB,CAE7B;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Emoji.js","sources":["../../../../src/components/Emoji/Emoji.tsx"],"sourcesContent":["'use client'\n\nimport { type CSSProperties, forwardRef } from 'react'\n\nimport classNames from 'classnames'\n\nimport { isDev } from '~/src/utils/assert'\nimport { cssUrl } from '~/src/utils/style'\n\nimport { type EmojiProps } from './Emoji.types'\n\nimport styles from './Emoji.module.scss'\n\
|
|
1
|
+
{"version":3,"file":"Emoji.js","sources":["../../../../src/components/Emoji/Emoji.tsx"],"sourcesContent":["'use client'\n\nimport { type CSSProperties, forwardRef } from 'react'\n\nimport classNames from 'classnames'\n\nimport { isDev } from '~/src/utils/assert'\nimport { cssUrl } from '~/src/utils/style'\n\nimport { type EmojiProps } from './Emoji.types'\n\nimport styles from './Emoji.module.scss'\n\n/**\n * @deprecated\n */\nconst EMOJI_TEST_ID = 'bezier-emoji'\n\nconst getEmojiUrl = (name: EmojiProps['name'], size: '160' | '80' | '44') => {\n return `https://cf${isDev() ? '.exp' : ''}.channel.io/asset/emoji/images/${size}/${encodeURIComponent(name)}.png`\n}\n\n/**\n * `Emoji` is a component for representing emoji with variant size.\n * @example\n * ```tsx\n * <Emoji\n * name=\"A\"\n * size=\"20\"\n * />\n * ```\n */\nexport const Emoji = forwardRef<HTMLDivElement, EmojiProps>(function Emoji(\n { style, imageUrl, className, name, size = '24', ...rest },\n forwardedRef\n) {\n const assetSize = Number(size) >= 60 ? '160' : '80'\n\n return (\n <div\n ref={forwardedRef}\n role=\"img\"\n aria-description={name}\n style={\n {\n '--b-emoji-background-image': cssUrl(\n imageUrl ?? getEmojiUrl(name, assetSize)\n ),\n ...style,\n } as CSSProperties\n }\n className={classNames(styles.Emoji, styles[`size-${size}`], className)}\n data-testid={EMOJI_TEST_ID}\n {...rest}\n />\n )\n})\n"],"names":["EMOJI_TEST_ID","getEmojiUrl","name","size","isDev","encodeURIComponent","Emoji","forwardRef","style","imageUrl","className","rest","forwardedRef","assetSize","Number","_jsx","ref","role","cssUrl","classNames","styles"],"mappings":";;;;;;;;;AAgBA,MAAMA,aAAa,GAAG,cAAc;AAEpC,MAAMC,WAAW,GAAGA,CAACC,IAAwB,EAAEC,IAAyB,KAAK;AAC3E,EAAA,OAAO,CAAaC,UAAAA,EAAAA,YAAK,EAAE,GAAG,MAAM,GAAG,EAAE,CAAA,+BAAA,EAAkCD,IAAI,CAAIE,CAAAA,EAAAA,kBAAkB,CAACH,IAAI,CAAC,CAAM,IAAA,CAAA;AACnH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaI,KAAK,gBAAGC,gBAAU,CAA6B,SAASD,KAAKA,CACxE;SAAEE,OAAK;EAAEC,QAAQ;EAAEC,SAAS;EAAER,IAAI;AAAEC,EAAAA,IAAI,GAAG,IAAI;EAAE,GAAGQ;AAAK,CAAC,EAC1DC,YAAY,EACZ;EACA,MAAMC,SAAS,GAAGC,MAAM,CAACX,IAAI,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,IAAI;AAEnD,EAAA,oBACEY,cAAA,CAAA,KAAA,EAAA;AACEC,IAAAA,GAAG,EAAEJ,YAAa;AAClBK,IAAAA,IAAI,EAAC,KAAK;AACV,IAAA,kBAAA,EAAkBf,IAAK;AACvBM,IAAAA,KAAK,EACH;AACE,MAAA,4BAA4B,EAAEU,YAAM,CAClCT,QAAQ,aAARA,QAAQ,KAAA,KAAA,CAAA,GAARA,QAAQ,GAAIR,WAAW,CAACC,IAAI,EAAEW,SAAS,CACzC,CAAC;MACD,GAAGL;KAEN;AACDE,IAAAA,SAAS,EAAES,aAAU,CAACC,oBAAM,CAACd,KAAK,EAAEc,oBAAM,CAAC,QAAQjB,IAAI,CAAA,CAAE,CAAC,EAAEO,SAAS,CAAE;AACvE,IAAA,aAAA,EAAaV,aAAc;IAAA,GACvBW;AAAI,GACT,CAAC;AAEN,CAAC;;;;"}
|
|
@@ -165,7 +165,6 @@ function useFormFieldProps(props) {
|
|
|
165
165
|
return formFieldProps;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
exports.FORM_CONTROL_TEST_ID = FORM_CONTROL_TEST_ID;
|
|
169
168
|
exports.FormControl = FormControl;
|
|
170
169
|
exports.useFormControlContext = useFormControlContext;
|
|
171
170
|
exports.useFormFieldProps = useFormFieldProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormControl.js","sources":["../../../../src/components/FormControl/FormControl.tsx"],"sourcesContent":["'use client'\nimport { forwardRef, useCallback, useMemo, useState } from 'react'\nimport * as React from 'react'\n\nimport classNames from 'classnames'\n\nimport useId from '~/src/hooks/useId'\nimport {\n type FormFieldProps,\n type FormFieldSize,\n type SizeProps,\n} from '~/src/types/props'\nimport { getFormFieldSizeClassName } from '~/src/types/props-helpers'\nimport { ariaAttr } from '~/src/utils/aria'\nimport { createContext } from '~/src/utils/react'\nimport { isNil } from '~/src/utils/type'\n\nimport { Stack } from '~/src/components/Stack'\n\nimport {\n type ContainerProps,\n type ErrorMessagePropsGetter,\n type FieldPropsGetter,\n type FormControlContextValue,\n type FormControlProps,\n type GroupPropsGetter,\n type HelperTextPropsGetter,\n type LabelPropsGetter,\n} from './FormControl.types'\n\nimport styles from './FormControl.module.scss'\n\nconst [FormControlContextProvider, useFormControlContext] = createContext<\n FormControlContextValue | undefined\n>(undefined)\n\nexport { useFormControlContext }\n\nexport const FORM_CONTROL_TEST_ID = 'bezier-form-control'\n\nconst Container = forwardRef<HTMLElement, ContainerProps>(function Container(\n { labelPosition, children, className, ...rest },\n forwardedRef\n) {\n switch (labelPosition) {\n case 'top':\n return (\n <Stack\n className={className}\n ref={forwardedRef}\n direction=\"vertical\"\n {...rest}\n >\n {children}\n </Stack>\n )\n\n case 'left':\n default:\n return (\n <div\n ref={forwardedRef as React.ForwardedRef<HTMLDivElement>}\n className={classNames(styles.Grid, className)}\n {...rest}\n >\n {children}\n </div>\n )\n }\n})\n\nexport const FormControl = forwardRef<HTMLElement, FormControlProps>(\n function FormControl(\n {\n children,\n id: idProp,\n labelPosition = 'top',\n size = 'm',\n hasError,\n required,\n readOnly,\n disabled,\n ...rest\n },\n forwardedRef\n ) {\n const [groupNode, setGroupNode] = useState<HTMLElement | null>(null)\n const [helperTextNode, setHelperTextNode] = useState<HTMLElement | null>(\n null\n )\n const [errorMessageNode, setErrorMessageNode] =\n useState<HTMLElement | null>(null)\n\n const id = useId(idProp, 'field')\n const groupId = `${id}-group`\n const labelId = `${id}-label`\n const helperTextId = `${id}-help-text`\n const errorMessageId = `${id}-error-message`\n\n const fieldId = groupNode ? undefined : id\n\n const describerId = useMemo(() => {\n if (errorMessageNode) {\n return errorMessageId\n }\n if (helperTextNode) {\n return helperTextId\n }\n return undefined\n }, [errorMessageNode, helperTextNode, errorMessageId, helperTextId])\n\n const getGroupProps = useCallback<GroupPropsGetter>(\n (ownProps) => ({\n id: groupId,\n 'aria-labelledby': labelId,\n 'aria-describedby': describerId,\n ref: setGroupNode,\n ...ownProps,\n }),\n [groupId, labelId, describerId]\n )\n\n const getLabelProps = useCallback<LabelPropsGetter>(\n (ownProps) => ({\n id: labelId,\n htmlFor: fieldId,\n className: classNames(\n styles.FormLabelWrapper,\n styles[`position-${labelPosition}`],\n getFormFieldSizeClassName(size)\n ),\n typo: labelPosition === 'top' ? '13' : '14',\n ...ownProps,\n }),\n [fieldId, labelId, labelPosition, size]\n )\n\n const getFieldProps = useCallback<FieldPropsGetter>(\n (ownProps) => ({\n id: fieldId,\n size,\n 'aria-describedby': groupNode ? undefined : describerId,\n hasError,\n required,\n readOnly,\n disabled,\n ...ownProps,\n }),\n [\n fieldId,\n describerId,\n size,\n hasError,\n required,\n readOnly,\n disabled,\n groupNode,\n ]\n )\n\n const getHelperTextProps = useCallback<HelperTextPropsGetter>(\n (ownProps) => ({\n id: helperTextId,\n visible: isNil(hasError) || !hasError,\n ref: setHelperTextNode,\n className: classNames(\n styles.FormHelperTextWrapper,\n labelPosition === 'left' && styles['position-left']\n ),\n ...ownProps,\n }),\n [helperTextId, labelPosition, hasError]\n )\n\n const getErrorMessageProps = useCallback<ErrorMessagePropsGetter>(\n (ownProps) => ({\n id: errorMessageId,\n visible: isNil(hasError) || hasError,\n ref: setErrorMessageNode,\n className: classNames(\n styles.FormHelperTextWrapper,\n labelPosition === 'left' && styles['position-left']\n ),\n ...ownProps,\n }),\n [errorMessageId, labelPosition, hasError]\n )\n\n const contextValue = useMemo(\n () => ({\n id,\n labelId,\n helperTextId,\n errorMessageId,\n getGroupProps,\n getLabelProps,\n getFieldProps,\n getHelperTextProps,\n getErrorMessageProps,\n hasError,\n required,\n readOnly,\n disabled,\n }),\n [\n id,\n labelId,\n helperTextId,\n errorMessageId,\n getGroupProps,\n getLabelProps,\n getFieldProps,\n getHelperTextProps,\n getErrorMessageProps,\n hasError,\n required,\n readOnly,\n disabled,\n ]\n )\n\n if (!children) {\n return null\n }\n\n return (\n <FormControlContextProvider value={contextValue}>\n <Container\n {...rest}\n ref={forwardedRef}\n labelPosition={labelPosition}\n data-testid={FORM_CONTROL_TEST_ID}\n >\n {children}\n </Container>\n </FormControlContextProvider>\n )\n }\n)\n\nexport function useFormFieldProps<\n Props extends FormFieldProps & SizeProps<FormFieldSize>,\n>(props?: Props) {\n const contextValue = useFormControlContext()\n\n const formFieldProps = useMemo(() => {\n const mergedProps = contextValue?.getFieldProps(props) ?? { ...props }\n\n const {\n disabled = false,\n readOnly = false,\n required = false,\n hasError = false,\n size = undefined,\n ...rest\n } = mergedProps\n\n return {\n ...rest,\n 'aria-disabled': ariaAttr(disabled),\n 'aria-invalid': ariaAttr(hasError),\n 'aria-required': ariaAttr(required),\n 'aria-readonly': ariaAttr(readOnly),\n size,\n disabled,\n hasError,\n required,\n readOnly,\n }\n }, [props, contextValue])\n\n return formFieldProps as typeof formFieldProps & Props\n}\n"],"names":["FormControlContextProvider","useFormControlContext","createContext","undefined","FORM_CONTROL_TEST_ID","Container","forwardRef","labelPosition","children","className","rest","forwardedRef","_jsx","Stack","ref","direction","classNames","styles","Grid","FormControl","id","idProp","size","hasError","required","readOnly","disabled","groupNode","setGroupNode","useState","helperTextNode","setHelperTextNode","errorMessageNode","setErrorMessageNode","useId","groupId","labelId","helperTextId","errorMessageId","fieldId","describerId","useMemo","getGroupProps","useCallback","ownProps","getLabelProps","htmlFor","FormLabelWrapper","getFormFieldSizeClassName","typo","getFieldProps","getHelperTextProps","visible","isNil","FormHelperTextWrapper","getErrorMessageProps","contextValue","value","useFormFieldProps","props","formFieldProps","_contextValue$getFiel","mergedProps","ariaAttr"],"mappings":";;;;;;;;;;;;;AAgCM,MAAA,CAACA,0BAA0B,EAAEC,qBAAqB,CAAC,GAAGC,mBAAa,CAEvEC,SAAS;AAIJ,MAAMC,oBAAoB,GAAG;AAEpC,MAAMC,SAAS,gBAAGC,gBAAU,CAA8B,SAASD,SAASA,CAC1E;EAAEE,aAAa;EAAEC,QAAQ;EAAEC,SAAS;EAAE,GAAGC;AAAK,CAAC,EAC/CC,YAAY,EACZ;AACA,EAAA,QAAQJ,aAAa;AACnB,IAAA,KAAK,KAAK;MACR,oBACEK,cAAA,CAACC,WAAK,EAAA;AACJJ,QAAAA,SAAS,EAAEA,SAAU;AACrBK,QAAAA,GAAG,EAAEH,YAAa;AAClBI,Q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BD,MAAAA,IAAI,GAAGnB,SAAS;MAChB,GAAGO;AACL,KAAC,GAAGoD,WAAW;IAEf,OAAO;AACL,MAAA,GAAGpD,IAAI;AACP,MAAA,eAAe,EAAEqD,aAAQ,CAACrC,QAAQ,CAAC;AACnC,MAAA,cAAc,EAAEqC,aAAQ,CAACxC,QAAQ,CAAC;AAClC,MAAA,eAAe,EAAEwC,aAAQ,CAACvC,QAAQ,CAAC;AACnC,MAAA,eAAe,EAAEuC,aAAQ,CAACtC,QAAQ,CAAC;MACnCH,IAAI;MACJI,QAAQ;MACRH,QAAQ;MACRC,QAAQ;AACRC,MAAAA;KACD;AACH,GAAC,EAAE,CAACkC,KAAK,EAAEH,YAAY,CAAC,CAAC;AAEzB,EAAA,OAAOI,cAAc;AACvB;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"FormControl.js","sources":["../../../../src/components/FormControl/FormControl.tsx"],"sourcesContent":["'use client'\nimport { forwardRef, useCallback, useMemo, useState } from 'react'\nimport * as React from 'react'\n\nimport classNames from 'classnames'\n\nimport useId from '~/src/hooks/useId'\nimport {\n type FormFieldProps,\n type FormFieldSize,\n type SizeProps,\n} from '~/src/types/props'\nimport { getFormFieldSizeClassName } from '~/src/types/props-helpers'\nimport { ariaAttr } from '~/src/utils/aria'\nimport { createContext } from '~/src/utils/react'\nimport { isNil } from '~/src/utils/type'\n\nimport { Stack } from '~/src/components/Stack'\n\nimport {\n type ContainerProps,\n type ErrorMessagePropsGetter,\n type FieldPropsGetter,\n type FormControlContextValue,\n type FormControlProps,\n type GroupPropsGetter,\n type HelperTextPropsGetter,\n type LabelPropsGetter,\n} from './FormControl.types'\n\nimport styles from './FormControl.module.scss'\n\nconst [FormControlContextProvider, useFormControlContext] = createContext<\n FormControlContextValue | undefined\n>(undefined)\n\nexport { useFormControlContext }\n\nconst FORM_CONTROL_TEST_ID = 'bezier-form-control'\n\nconst Container = forwardRef<HTMLElement, ContainerProps>(function Container(\n { labelPosition, children, className, ...rest },\n forwardedRef\n) {\n switch (labelPosition) {\n case 'top':\n return (\n <Stack\n className={className}\n ref={forwardedRef}\n direction=\"vertical\"\n {...rest}\n >\n {children}\n </Stack>\n )\n\n case 'left':\n default:\n return (\n <div\n ref={forwardedRef as React.ForwardedRef<HTMLDivElement>}\n className={classNames(styles.Grid, className)}\n {...rest}\n >\n {children}\n </div>\n )\n }\n})\n\nexport const FormControl = forwardRef<HTMLElement, FormControlProps>(\n function FormControl(\n {\n children,\n id: idProp,\n labelPosition = 'top',\n size = 'm',\n hasError,\n required,\n readOnly,\n disabled,\n ...rest\n },\n forwardedRef\n ) {\n const [groupNode, setGroupNode] = useState<HTMLElement | null>(null)\n const [helperTextNode, setHelperTextNode] = useState<HTMLElement | null>(\n null\n )\n const [errorMessageNode, setErrorMessageNode] =\n useState<HTMLElement | null>(null)\n\n const id = useId(idProp, 'field')\n const groupId = `${id}-group`\n const labelId = `${id}-label`\n const helperTextId = `${id}-help-text`\n const errorMessageId = `${id}-error-message`\n\n const fieldId = groupNode ? undefined : id\n\n const describerId = useMemo(() => {\n if (errorMessageNode) {\n return errorMessageId\n }\n if (helperTextNode) {\n return helperTextId\n }\n return undefined\n }, [errorMessageNode, helperTextNode, errorMessageId, helperTextId])\n\n const getGroupProps = useCallback<GroupPropsGetter>(\n (ownProps) => ({\n id: groupId,\n 'aria-labelledby': labelId,\n 'aria-describedby': describerId,\n ref: setGroupNode,\n ...ownProps,\n }),\n [groupId, labelId, describerId]\n )\n\n const getLabelProps = useCallback<LabelPropsGetter>(\n (ownProps) => ({\n id: labelId,\n htmlFor: fieldId,\n className: classNames(\n styles.FormLabelWrapper,\n styles[`position-${labelPosition}`],\n getFormFieldSizeClassName(size)\n ),\n typo: labelPosition === 'top' ? '13' : '14',\n ...ownProps,\n }),\n [fieldId, labelId, labelPosition, size]\n )\n\n const getFieldProps = useCallback<FieldPropsGetter>(\n (ownProps) => ({\n id: fieldId,\n size,\n 'aria-describedby': groupNode ? undefined : describerId,\n hasError,\n required,\n readOnly,\n disabled,\n ...ownProps,\n }),\n [\n fieldId,\n describerId,\n size,\n hasError,\n required,\n readOnly,\n disabled,\n groupNode,\n ]\n )\n\n const getHelperTextProps = useCallback<HelperTextPropsGetter>(\n (ownProps) => ({\n id: helperTextId,\n visible: isNil(hasError) || !hasError,\n ref: setHelperTextNode,\n className: classNames(\n styles.FormHelperTextWrapper,\n labelPosition === 'left' && styles['position-left']\n ),\n ...ownProps,\n }),\n [helperTextId, labelPosition, hasError]\n )\n\n const getErrorMessageProps = useCallback<ErrorMessagePropsGetter>(\n (ownProps) => ({\n id: errorMessageId,\n visible: isNil(hasError) || hasError,\n ref: setErrorMessageNode,\n className: classNames(\n styles.FormHelperTextWrapper,\n labelPosition === 'left' && styles['position-left']\n ),\n ...ownProps,\n }),\n [errorMessageId, labelPosition, hasError]\n )\n\n const contextValue = useMemo(\n () => ({\n id,\n labelId,\n helperTextId,\n errorMessageId,\n getGroupProps,\n getLabelProps,\n getFieldProps,\n getHelperTextProps,\n getErrorMessageProps,\n hasError,\n required,\n readOnly,\n disabled,\n }),\n [\n id,\n labelId,\n helperTextId,\n errorMessageId,\n getGroupProps,\n getLabelProps,\n getFieldProps,\n getHelperTextProps,\n getErrorMessageProps,\n hasError,\n required,\n readOnly,\n disabled,\n ]\n )\n\n if (!children) {\n return null\n }\n\n return (\n <FormControlContextProvider value={contextValue}>\n <Container\n {...rest}\n ref={forwardedRef}\n labelPosition={labelPosition}\n data-testid={FORM_CONTROL_TEST_ID}\n >\n {children}\n </Container>\n </FormControlContextProvider>\n )\n }\n)\n\nexport function useFormFieldProps<\n Props extends FormFieldProps & SizeProps<FormFieldSize>,\n>(props?: Props) {\n const contextValue = useFormControlContext()\n\n const formFieldProps = useMemo(() => {\n const mergedProps = contextValue?.getFieldProps(props) ?? { ...props }\n\n const {\n disabled = false,\n readOnly = false,\n required = false,\n hasError = false,\n size = undefined,\n ...rest\n } = mergedProps\n\n return {\n ...rest,\n 'aria-disabled': ariaAttr(disabled),\n 'aria-invalid': ariaAttr(hasError),\n 'aria-required': ariaAttr(required),\n 'aria-readonly': ariaAttr(readOnly),\n size,\n disabled,\n hasError,\n required,\n readOnly,\n }\n }, [props, contextValue])\n\n return formFieldProps as typeof formFieldProps & Props\n}\n"],"names":["FormControlContextProvider","useFormControlContext","createContext","undefined","FORM_CONTROL_TEST_ID","Container","forwardRef","labelPosition","children","className","rest","forwardedRef","_jsx","Stack","ref","direction","classNames","styles","Grid","FormControl","id","idProp","size","hasError","required","readOnly","disabled","groupNode","setGroupNode","useState","helperTextNode","setHelperTextNode","errorMessageNode","setErrorMessageNode","useId","groupId","labelId","helperTextId","errorMessageId","fieldId","describerId","useMemo","getGroupProps","useCallback","ownProps","getLabelProps","htmlFor","FormLabelWrapper","getFormFieldSizeClassName","typo","getFieldProps","getHelperTextProps","visible","isNil","FormHelperTextWrapper","getErrorMessageProps","contextValue","value","useFormFieldProps","props","formFieldProps","_contextValue$getFiel","mergedProps","ariaAttr"],"mappings":";;;;;;;;;;;;;AAgCM,MAAA,CAACA,0BAA0B,EAAEC,qBAAqB,CAAC,GAAGC,mBAAa,CAEvEC,SAAS;AAIX,MAAMC,oBAAoB,GAAG,qBAAqB;AAElD,MAAMC,SAAS,gBAAGC,gBAAU,CAA8B,SAASD,SAASA,CAC1E;EAAEE,aAAa;EAAEC,QAAQ;EAAEC,SAAS;EAAE,GAAGC;AAAK,CAAC,EAC/CC,YAAY,EACZ;AACA,EAAA,QAAQJ,aAAa;AACnB,IAAA,KAAK,KAAK;MACR,oBACEK,cAAA,CAACC,WAAK,EAAA;AACJJ,QAAAA,SAAS,EAAEA,SAAU;AACrBK,QAAAA,GAAG,EAAEH,YAAa;AAClBI,QAAAA,SAAS,EAAC,UAAU;AAAA,QAAA,GAChBL,IAAI;AAAAF,QAAAA,QAAA,EAEPA;AAAQ,OACJ,CAAC;AAGZ,IAAA,KAAK,MAAM;AACX,IAAA;AACE,MAAA,oBACEI,cAAA,CAAA,KAAA,EAAA;AACEE,QAAAA,G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AQ,CAACxC,QAAQ,CAAC;AAClC,MAAA,eAAe,EAAEwC,aAAQ,CAACvC,QAAQ,CAAC;AACnC,MAAA,eAAe,EAAEuC,aAAQ,CAACtC,QAAQ,CAAC;MACnCH,IAAI;MACJI,QAAQ;MACRH,QAAQ;MACRC,QAAQ;AACRC,MAAAA;KACD;AACH,GAAC,EAAE,CAACkC,KAAK,EAAEH,YAAY,CAAC,CAAC;AAEzB,EAAA,OAAOI,cAAc;AACvB;;;;;;"}
|
|
@@ -11,6 +11,10 @@ var FormControl = require('../FormControl/FormControl.js');
|
|
|
11
11
|
var Text = require('../Text/Text.js');
|
|
12
12
|
|
|
13
13
|
const FORM_HELPER_TEXT_TEST_ID = 'bezier-form-helper-text';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated
|
|
17
|
+
*/
|
|
14
18
|
const FORM_ERROR_MESSAGE_TEST_ID = 'bezier-form-error-message';
|
|
15
19
|
const BaseHelperText = /*#__PURE__*/React.forwardRef(function BaseHelperText(props, forwardedRef) {
|
|
16
20
|
var _getProps;
|
|
@@ -114,8 +118,6 @@ const FormErrorMessage = /*#__PURE__*/React.forwardRef(function FormErrorMessage
|
|
|
114
118
|
});
|
|
115
119
|
});
|
|
116
120
|
|
|
117
|
-
exports.FORM_ERROR_MESSAGE_TEST_ID = FORM_ERROR_MESSAGE_TEST_ID;
|
|
118
|
-
exports.FORM_HELPER_TEXT_TEST_ID = FORM_HELPER_TEXT_TEST_ID;
|
|
119
121
|
exports.FormErrorMessage = FormErrorMessage;
|
|
120
122
|
exports.FormHelperText = FormHelperText;
|
|
121
123
|
//# sourceMappingURL=FormHelperText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormHelperText.js","sources":["../../../../src/components/FormHelperText/FormHelperText.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef } from 'react'\n\nimport classNames from 'classnames'\n\nimport useMergeRefs from '~/src/hooks/useMergeRefs'\nimport { noop } from '~/src/utils/function'\nimport { isEmpty } from '~/src/utils/type'\n\nimport { useFormControlContext } from '~/src/components/FormControl'\nimport { Text } from '~/src/components/Text'\n\nimport type {\n BaseHelperTextProps,\n FormErrorMessageProps,\n FormHelperTextProps,\n} from './FormHelperText.types'\n\nimport styles from './FormHelperText.module.scss'\n\
|
|
1
|
+
{"version":3,"file":"FormHelperText.js","sources":["../../../../src/components/FormHelperText/FormHelperText.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef } from 'react'\n\nimport classNames from 'classnames'\n\nimport useMergeRefs from '~/src/hooks/useMergeRefs'\nimport { noop } from '~/src/utils/function'\nimport { isEmpty } from '~/src/utils/type'\n\nimport { useFormControlContext } from '~/src/components/FormControl'\nimport { Text } from '~/src/components/Text'\n\nimport type {\n BaseHelperTextProps,\n FormErrorMessageProps,\n FormHelperTextProps,\n} from './FormHelperText.types'\n\nimport styles from './FormHelperText.module.scss'\n\n/**\n * @deprecated\n */\nconst FORM_HELPER_TEXT_TEST_ID = 'bezier-form-helper-text'\n\n/**\n * @deprecated\n */\nconst FORM_ERROR_MESSAGE_TEST_ID = 'bezier-form-error-message'\n\nconst BaseHelperText = forwardRef<HTMLSpanElement, BaseHelperTextProps>(\n function BaseHelperText(props, forwardedRef) {\n const { type, typo = '13', children, className, ...rest } = props\n\n const contextValue = useFormControlContext()\n const getProps =\n type === 'info'\n ? contextValue?.getHelperTextProps\n : contextValue?.getErrorMessageProps\n\n const {\n visible,\n ref,\n className: formControlClassName,\n ...ownProps\n } = getProps?.(rest) ?? {\n visible: true,\n ref: noop,\n className: undefined,\n ...rest,\n }\n\n const mergedRef = useMergeRefs(ref, forwardedRef)\n\n if (isEmpty(children) || !visible) {\n return null\n }\n\n return (\n <Text\n ref={mergedRef}\n as=\"p\"\n className={classNames(\n styles.FormHelperText,\n formControlClassName,\n className\n )}\n typo={typo}\n align=\"left\"\n {...ownProps}\n >\n {children}\n </Text>\n )\n }\n)\n\n/**\n * `FormHelperText` is a component to show the description of the input element.\n * `FormControl` component can handle its layout by `position` props.\n * @example\n * ```tsx\n * <FormControl position=\"top\">\n * <FormLabel>\n * Password\n * </FormLabel>\n * <TextField />\n * <FormHelperText>\n * Please use at least 6 characters\n * </FormHelperText>\n * </FormControl>\n * ```\n */\nexport const FormHelperText = forwardRef<HTMLSpanElement, FormHelperTextProps>(\n function FormHelperText(props, forwardedRef) {\n const { color = 'txt-black-dark', children, ...rest } = props\n\n return (\n <BaseHelperText\n type=\"info\"\n ref={forwardedRef}\n color={color}\n data-testid={FORM_HELPER_TEXT_TEST_ID}\n {...rest}\n >\n {children}\n </BaseHelperText>\n )\n }\n)\n\n/**\n * `FormErrorMessage` is a component to show error message when form values are invalid.\n * It should be used with `FormControl` component.\n * @example\n * ```tsx\n * <FormControl>\n * <FormLabel>\n * Password\n * </FormLabel>\n * <TextField />\n * <FormErrorMessage>\n * Password should be at least 6 characters\n * </FormErrorMessage>\n * </FormControl>\n * ```\n */\nexport const FormErrorMessage = forwardRef<\n HTMLSpanElement,\n FormErrorMessageProps\n>(function FormErrorMessage(props, forwardedRef) {\n const { color = 'bgtxt-orange-normal', children, ...rest } = props\n\n return (\n <BaseHelperText\n aria-live=\"polite\"\n type=\"error\"\n ref={forwardedRef}\n color={color}\n data-testid={FORM_ERROR_MESSAGE_TEST_ID}\n {...rest}\n >\n {children}\n </BaseHelperText>\n )\n})\n"],"names":["FORM_HELPER_TEXT_TEST_ID","FORM_ERROR_MESSAGE_TEST_ID","BaseHelperText","forwardRef","props","forwardedRef","_getProps","type","typo","children","className","rest","contextValue","useFormControlContext","getProps","getHelperTextProps","getErrorMessageProps","visible","ref","formControlClassName","ownProps","noop","undefined","mergedRef","useMergeRefs","isEmpty","_jsx","Text","as","classNames","styles","FormHelperText","align","color","FormErrorMessage"],"mappings":";;;;;;;;;;;;AAwBA,MAAMA,wBAAwB,GAAG,yBAAyB;;AAE1D;AACA;AACA;AACA,MAAMC,0BAA0B,GAAG,2BAA2B;AAE9D,MAAMC,cAAc,gBAAGC,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,EAEPA;AAAQ,GACK,CAAC;AAErB,CAAC;;;;;"}
|
|
@@ -12,6 +12,10 @@ var Icon = require('../Icon/Icon.js');
|
|
|
12
12
|
var Text = require('../Text/Text.js');
|
|
13
13
|
|
|
14
14
|
const NAV_GROUP_TEST_ID = 'bezier-nav-group';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated
|
|
18
|
+
*/
|
|
15
19
|
const NAV_GROUP_LEFT_ICON_TEST_ID = 'bezier-nav-group-left-icon';
|
|
16
20
|
const NavGroup = /*#__PURE__*/React.forwardRef(function NavGroup({
|
|
17
21
|
name,
|
|
@@ -76,7 +80,5 @@ const NavGroup = /*#__PURE__*/React.forwardRef(function NavGroup({
|
|
|
76
80
|
});
|
|
77
81
|
});
|
|
78
82
|
|
|
79
|
-
exports.NAV_GROUP_LEFT_ICON_TEST_ID = NAV_GROUP_LEFT_ICON_TEST_ID;
|
|
80
|
-
exports.NAV_GROUP_TEST_ID = NAV_GROUP_TEST_ID;
|
|
81
83
|
exports.NavGroup = NavGroup;
|
|
82
84
|
//# sourceMappingURL=NavGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavGroup.js","sources":["../../../../src/components/NavGroup/NavGroup.tsx"],"sourcesContent":["'use client'\nimport { forwardRef } from 'react'\nimport * as React from 'react'\n\nimport {\n ChevronSmallDownIcon,\n ChevronSmallRightIcon,\n} from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { isNil } from '~/src/utils/type'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { Icon } from '~/src/components/Icon'\nimport { Text } from '~/src/components/Text'\n\n// eslint-disable-next-line no-restricted-imports\nimport commonStyles from '../NavItem/NavItem.module.scss'\n\nimport type { NavGroupProps } from './NavGroup.types'\n\nimport styles from './NavGroup.module.scss'\n\
|
|
1
|
+
{"version":3,"file":"NavGroup.js","sources":["../../../../src/components/NavGroup/NavGroup.tsx"],"sourcesContent":["'use client'\nimport { forwardRef } from 'react'\nimport * as React from 'react'\n\nimport {\n ChevronSmallDownIcon,\n ChevronSmallRightIcon,\n} from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { isNil } from '~/src/utils/type'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { Icon } from '~/src/components/Icon'\nimport { Text } from '~/src/components/Text'\n\n// eslint-disable-next-line no-restricted-imports\nimport commonStyles from '../NavItem/NavItem.module.scss'\n\nimport type { NavGroupProps } from './NavGroup.types'\n\nimport styles from './NavGroup.module.scss'\n\n/**\n * @deprecated\n */\nconst NAV_GROUP_TEST_ID = 'bezier-nav-group'\n\n/**\n * @deprecated\n */\nconst NAV_GROUP_LEFT_ICON_TEST_ID = 'bezier-nav-group-left-icon'\n\nexport const NavGroup = forwardRef<HTMLButtonElement, NavGroupProps>(\n function NavGroup(\n {\n name,\n className,\n children,\n content,\n rightContent,\n leftContent,\n open,\n active,\n onClick,\n ...rest\n },\n forwardedRef\n ) {\n const handleClickItem = (e?: React.MouseEvent) => {\n onClick?.(e, name)\n }\n\n const hasChildren = !isNil(children)\n const chevronIconSource = open\n ? ChevronSmallDownIcon\n : ChevronSmallRightIcon\n const ariaName = `${name}Menu`\n\n return (\n <li\n className={commonStyles.Wrapper}\n role=\"none\"\n >\n <BaseButton\n ref={forwardedRef}\n className={classNames(\n commonStyles.Item,\n active && commonStyles.active,\n className\n )}\n role=\"menuitem\"\n aria-haspopup={hasChildren}\n aria-expanded={open}\n aria-controls={ariaName}\n onClick={handleClickItem}\n data-testid={NAV_GROUP_TEST_ID}\n {...rest}\n >\n <div className={commonStyles.LeftIconWrapper}>\n <Icon\n source={leftContent}\n size=\"s\"\n color={active ? 'bgtxt-blue-normal' : 'txt-black-dark'}\n data-testid={NAV_GROUP_LEFT_ICON_TEST_ID}\n />\n </div>\n\n <Text\n typo=\"14\"\n truncated\n >\n {content}\n </Text>\n\n {hasChildren && (\n <div className={styles.ChevronWrapper}>\n <Icon\n source={chevronIconSource}\n size=\"s\"\n color=\"txt-black-dark\"\n />\n </div>\n )}\n\n {rightContent && (\n <div className={commonStyles.RightContentWrapper}>\n {rightContent}\n </div>\n )}\n </BaseButton>\n\n {open && (\n <ul\n className={styles.ChildrenWrapper}\n role=\"menu\"\n id={ariaName}\n >\n {open && children}\n </ul>\n )}\n </li>\n )\n }\n)\n"],"names":["NAV_GROUP_TEST_ID","NAV_GROUP_LEFT_ICON_TEST_ID","NavGroup","forwardRef","name","className","children","content","rightContent","leftContent","open","active","onClick","rest","forwardedRef","handleClickItem","e","hasChildren","isNil","chevronIconSource","ChevronSmallDownIcon","ChevronSmallRightIcon","ariaName","_jsxs","commonStyles","Wrapper","role","BaseButton","ref","classNames","Item","_jsx","LeftIconWrapper","Icon","source","size","color","Text","typo","truncated","styles","ChevronWrapper","RightContentWrapper","ChildrenWrapper","id"],"mappings":";;;;;;;;;;;;;AA0BA,MAAMA,iBAAiB,GAAG,kBAAkB;;AAE5C;AACA;AACA;AACA,MAAMC,2BAA2B,GAAG,4BAA4B;MAEnDC,QAAQ,gBAAGC,gBAAU,CAChC,SAASD,QAAQA,CACf;EACEE,IAAI;EACJC,SAAS;EACTC,QAAQ;EACRC,OAAO;EACPC,YAAY;EACZC,WAAW;EACXC,IAAI;EACJC,MAAM;EACNC,OAAO;EACP,GAAGC;AACL,CAAC,EACDC,YAAY,EACZ;EACA,MAAMC,eAAe,GAAIC,CAAoB,IAAK;IAChDJ,OAAO,KAAA,IAAA,IAAPA,OAAO,KAAPA,KAAAA,CAAAA,IAAAA,OAAO,CAAGI,CAAC,EAAEZ,IAAI,CAAC;GACnB;AAED,EAAA,MAAMa,WAAW,GAAG,CAACC,UAAK,CAACZ,QAAQ,CAAC;AACpC,EAAA,MAAMa,iBAAiB,GAAGT,IAAI,GAC1BU,gCAAoB,GACpBC,iCAAqB;AACzB,EAAA,MAAMC,QAAQ,GAAG,CAAGlB,EAAAA,IAAI,CAAM,IAAA,CAAA;AAE9B,EAAA,oBACEmB,eAAA,CAAA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ACXuB,cAAA,CAAA,KAAA,EAAA;QAAK1B,SAAS,EAAEmB,sBAAY,CAACkB,mBAAoB;AAAApC,QAAAA,QAAA,EAC9CE;AAAY,OACV,CACN;AAAA,KACS,CAAC,EAEZE,IAAI,iBACHqB,cAAA,CAAA,IAAA,EAAA;MACE1B,SAAS,EAAEmC,uBAAM,CAACG,eAAgB;AAClCjB,MAAAA,IAAI,EAAC,MAAM;AACXkB,MAAAA,EAAE,EAAEtB,QAAS;MAAAhB,QAAA,EAEZI,IAAI,IAAIJ;AAAQ,KACf,CACL;AAAA,GACC,CAAC;AAET,CACF;;;;"}
|
|
@@ -8,6 +8,10 @@ var Icon = require('../Icon/Icon.js');
|
|
|
8
8
|
var Text = require('../Text/Text.js');
|
|
9
9
|
|
|
10
10
|
const NAV_ITEM_TEST_ID = 'bezier-nav-item';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated
|
|
14
|
+
*/
|
|
11
15
|
const NAV_ITEM_LEFT_ICON_TEST_ID = 'bezier-nav-item-left-icon';
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -70,7 +74,5 @@ const NavItem = /*#__PURE__*/React.forwardRef(function NavItem({
|
|
|
70
74
|
});
|
|
71
75
|
});
|
|
72
76
|
|
|
73
|
-
exports.NAV_ITEM_LEFT_ICON_TEST_ID = NAV_ITEM_LEFT_ICON_TEST_ID;
|
|
74
|
-
exports.NAV_ITEM_TEST_ID = NAV_ITEM_TEST_ID;
|
|
75
77
|
exports.NavItem = NavItem;
|
|
76
78
|
//# sourceMappingURL=NavItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavItem.js","sources":["../../../../src/components/NavItem/NavItem.tsx"],"sourcesContent":["'use client'\nimport { forwardRef } from 'react'\nimport * as React from 'react'\n\nimport classNames from 'classnames'\n\nimport { Icon } from '~/src/components/Icon'\nimport { Text } from '~/src/components/Text'\n\nimport type { NavItemProps } from './NavItem.types'\n\nimport styles from './NavItem.module.scss'\n\
|
|
1
|
+
{"version":3,"file":"NavItem.js","sources":["../../../../src/components/NavItem/NavItem.tsx"],"sourcesContent":["'use client'\nimport { forwardRef } from 'react'\nimport * as React from 'react'\n\nimport classNames from 'classnames'\n\nimport { Icon } from '~/src/components/Icon'\nimport { Text } from '~/src/components/Text'\n\nimport type { NavItemProps } from './NavItem.types'\n\nimport styles from './NavItem.module.scss'\n\n/**\n * @deprecated\n */\nconst NAV_ITEM_TEST_ID = 'bezier-nav-item'\n\n/**\n * @deprecated\n */\nconst NAV_ITEM_LEFT_ICON_TEST_ID = 'bezier-nav-item-left-icon'\n\n/**\n * `NavItem` is a component for an item where you can navigate to another link.\n * @example\n * ```tsx\n * <NavItem\n * name=\"channel\"\n * content=\"https://channel.io\"\n * href=\"_parent\"\n * />\n * ```\n */\nexport const NavItem = forwardRef<HTMLAnchorElement, NavItemProps>(\n function NavItem(\n {\n name,\n style,\n className,\n content,\n href,\n target = '_self',\n rightContent,\n leftContent,\n active,\n onClick,\n ...rest\n },\n forwardedRef\n ) {\n const handleClickItem = (e?: React.MouseEvent) => {\n onClick?.(e, name)\n }\n\n return (\n <li\n className={styles.Wrapper}\n role=\"none\"\n >\n <a\n ref={forwardedRef}\n style={style}\n className={classNames(\n styles.Item,\n active && styles.active,\n className\n )}\n href={href}\n target={target}\n role=\"menuitem\"\n onClick={handleClickItem}\n data-testid={NAV_ITEM_TEST_ID}\n {...rest}\n >\n <div className={styles.LeftIconWrapper}>\n {leftContent && (\n <Icon\n data-testid={NAV_ITEM_LEFT_ICON_TEST_ID}\n source={leftContent}\n size=\"s\"\n color={active ? 'bgtxt-blue-normal' : 'txt-black-dark'}\n />\n )}\n </div>\n\n <Text\n typo=\"14\"\n truncated\n >\n {content}\n </Text>\n\n {rightContent && (\n <div className={styles.RightContentWrapper}>{rightContent}</div>\n )}\n </a>\n </li>\n )\n }\n)\n"],"names":["NAV_ITEM_TEST_ID","NAV_ITEM_LEFT_ICON_TEST_ID","NavItem","forwardRef","name","style","className","content","href","target","rightContent","leftContent","active","onClick","rest","forwardedRef","handleClickItem","e","_jsx","styles","Wrapper","role","children","_jsxs","ref","classNames","Item","LeftIconWrapper","Icon","source","size","color","Text","typo","truncated","RightContentWrapper"],"mappings":";;;;;;;;;AAgBA,MAAMA,gBAAgB,GAAG,iBAAiB;;AAE1C;AACA;AACA;AACA,MAAMC,0BAA0B,GAAG,2BAA2B;;AAE9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaC,OAAO,gBAAGC,gBAAU,CAC/B,SAASD,OAAOA,CACd;EACEE,IAAI;EACJC,KAAK;EACLC,SAAS;EACTC,OAAO;EACPC,IAAI;AACJC,EAAAA,MAAM,GAAG,OAAO;EAChBC,YAAY;EACZC,WAAW;EACXC,MAAM;EACNC,OAAO;EACP,GAAGC;AACL,CAAC,EACDC,YAAY,EACZ;EACA,MAAMC,eAAe,GAAIC,CAAoB,IAAK;IAChDJ,OAAO,KAAA,IAAA,IAAPA,OAAO,KAAPA,KAAAA,CAAAA,IAAAA,OAAO,CAAGI,CAAC,EAAEb,IAAI,CAAC;GACnB;AAED,EAAA,oBACEc,cAAA,CAAA,IAAA,EAAA;IACEZ,SAAS,EAAEa,sBAAM,CAACC,OAAQ;AAC1BC,IAAAA,IAAI,EAAC,MAAM;AAAAC,IAAAA,QAAA,eAEXC,eAAA,CAAA,GAAA,EAAA;AACEC,MAAAA,GAAG,EAAET,YAAa;AAClBV,MAAAA,KAAK,EAAEA,KAAM;AACbC,MAAAA,SAAS,EAAEmB,aAAU,CACnBN,sBAAM,CAACO,IAAI,EACXd,MAAM,IAAIO,sBAAM,CAACP,MAAM,EACvBN,SACF,CAAE;AACFE,MAAAA,IAAI,EAAEA,IAAK;AACXC,MAAAA,MAAM,EAAEA,MAAO;AACfY,MAAAA,IAAI,EAAC,UAAU;AACfR,MAAAA,OAAO,EAAEG,eAAgB;AACzB,MAAA,aAAA,EAAahB,gBAAiB;AAAA,MAAA,GAC1Bc,IAAI;AAAAQ,MAAAA,QAAA,gBAERJ,cAAA,CAAA,KAAA,EAAA;QAAKZ,SAAS,EAAEa,sBAAM,CAACQ,eAAgB;AAAAL,QAAAA,QAAA,EACpCX,WAAW,iBACVO,cAAA,CAACU,SAAI,EAAA;AACH,UAAA,aAAA,EAAa3B,0BAA2B;AACxC4B,UAAAA,MAAM,EAAElB,WAAY;AACpBmB,UAAAA,IAAI,EAAC,GAAG;AACRC,UAAAA,KAAK,EAAEnB,MAAM,GAAG,mBAAmB,GAAG;SACvC;AACF,OACE,CAAC,eAENM,cAAA,CAACc,SAAI,EAAA;AACHC,QAAAA,IAAI,EAAC,IAAI;QACTC,SAAS,EAAA,IAAA;AAAAZ,QAAAA,QAAA,EAERf;AAAO,OACJ,CAAC,EAENG,YAAY,iBACXQ,cAAA,CAAA,KAAA,EAAA;QAAKZ,SAAS,EAAEa,sBAAM,CAACgB,mBAAoB;AAAAb,QAAAA,QAAA,EAAEZ;AAAY,OAAM,CAChE;KACA;AAAC,GACF,CAAC;AAET,CACF;;;;"}
|
|
@@ -174,6 +174,14 @@ const SegmentedControl = /*#__PURE__*/React.forwardRef(SegmentedControlImpl);
|
|
|
174
174
|
* NOTE: (@ed) A property injected at runtime by the radix-ui lib.
|
|
175
175
|
*/
|
|
176
176
|
|
|
177
|
+
function getTypography(size) {
|
|
178
|
+
return {
|
|
179
|
+
xs: '13',
|
|
180
|
+
s: '13',
|
|
181
|
+
m: '13',
|
|
182
|
+
l: '14'
|
|
183
|
+
}[size];
|
|
184
|
+
}
|
|
177
185
|
const Item = /*#__PURE__*/React.forwardRef(function Item({
|
|
178
186
|
children,
|
|
179
187
|
leftContent,
|
|
@@ -203,12 +211,11 @@ const Item = /*#__PURE__*/React.forwardRef(function Item({
|
|
|
203
211
|
children: /*#__PURE__*/jsxRuntime.jsxs(Stack.HStack, {
|
|
204
212
|
className: SegmentedControl_module.default.SegmentedControlItemContainer,
|
|
205
213
|
align: "center",
|
|
206
|
-
spacing:
|
|
214
|
+
spacing: 4,
|
|
207
215
|
children: [leftContent, /*#__PURE__*/jsxRuntime.jsx(Text.Text, {
|
|
208
216
|
className: SegmentedControl_module.default.SegmentedControlItemLabel,
|
|
209
217
|
bold: true,
|
|
210
|
-
|
|
211
|
-
typo: size === 'xs' ? '13' : '14',
|
|
218
|
+
typo: getTypography(size),
|
|
212
219
|
children: children
|
|
213
220
|
}), rightContent]
|
|
214
221
|
})
|