@channel.io/bezier-react 3.1.4 → 3.1.5
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/Banner/Banner.js +1 -1
- package/dist/cjs/components/Banner/Banner.js.map +1 -1
- package/dist/cjs/components/Button/Button.js +1 -1
- package/dist/cjs/components/Button/Button.js.map +1 -1
- package/dist/cjs/components/SectionLabel/SectionLabel.js +2 -2
- package/dist/cjs/components/SectionLabel/SectionLabel.js.map +1 -1
- package/dist/cjs/utils/assert.js +12 -3
- package/dist/cjs/utils/assert.js.map +1 -1
- package/dist/esm/components/Banner/Banner.mjs +1 -1
- package/dist/esm/components/Banner/Banner.mjs.map +1 -1
- package/dist/esm/components/Button/Button.mjs +1 -1
- package/dist/esm/components/Button/Button.mjs.map +1 -1
- package/dist/esm/components/SectionLabel/SectionLabel.mjs +2 -2
- package/dist/esm/components/SectionLabel/SectionLabel.mjs.map +1 -1
- package/dist/esm/utils/assert.mjs +12 -3
- package/dist/esm/utils/assert.mjs.map +1 -1
- package/dist/types/components/Banner/Banner.d.ts.map +1 -1
- package/dist/types/components/Button/Button.d.ts.map +1 -1
- package/dist/types/components/SectionLabel/SectionLabel.d.ts.map +1 -1
- package/dist/types/utils/assert.d.ts +1 -0
- package/dist/types/utils/assert.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/Banner/Banner.tsx +2 -1
- package/src/components/Button/Button.tsx +2 -1
- package/src/components/SectionLabel/SectionLabel.tsx +4 -2
- package/src/utils/assert.test.ts +43 -0
- package/src/utils/assert.ts +15 -3
|
@@ -61,7 +61,7 @@ const Banner = /*#__PURE__*/React.forwardRef(function Banner({
|
|
|
61
61
|
...rest
|
|
62
62
|
}, forwardedRef) {
|
|
63
63
|
if (utils.isIconName(icon)) {
|
|
64
|
-
assert.warn('Deprecation: IconName as a value for the icon property of Banner has been deprecated. Use the Icon of bezier-icons instead.');
|
|
64
|
+
assert.warn('Deprecation: IconName as a value for the icon property of Banner has been deprecated. Use the Icon of bezier-icons instead.', 'Banner.IconName');
|
|
65
65
|
}
|
|
66
66
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
67
67
|
ref: forwardedRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.js","sources":["../../../../src/components/Banner/Banner.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef } from 'react'\n\nimport { isBezierIcon } from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { warn } from '~/src/utils/assert'\nimport { isNil } from '~/src/utils/type'\n\nimport { Button } from '~/src/components/Button'\nimport { Icon } from '~/src/components/Icon'\nimport { LegacyIcon, isIconName } from '~/src/components/LegacyIcon'\nimport { Text } from '~/src/components/Text'\n\nimport {\n type BannerProps,\n type BannerVariant,\n type RenderLinkFunc,\n} from './Banner.types'\n\nimport styles from './Banner.module.scss'\n\nconst BANNER_TEST_ID = 'bezier-banner'\n\nfunction getActionButtonColorVariant(variant: BannerVariant) {\n return (\n {\n default: 'monochrome-dark',\n blue: 'blue',\n cobalt: 'cobalt',\n green: 'green',\n orange: 'orange',\n red: 'red',\n alt: 'monochrome-dark',\n } as const\n )[variant]\n}\n\nconst externalLinkRenderer: RenderLinkFunc = ({ content, linkTo }) => (\n <a\n href={linkTo}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {content}\n </a>\n)\n\n/**\n * `Banner` is a component you use when you want to communicate instructions, warnings, recommendations, and other information well.\n * @example\n * ```tsx\n * <Banner\n * variant=\"blue\"\n * icon={LightbulbIcon}\n * content=\"Information here.\"\n * />\n * ```\n */\nexport const Banner = forwardRef<HTMLDivElement, BannerProps>(function Banner(\n {\n className,\n variant = 'default',\n icon,\n iconColor,\n content,\n hasLink = false,\n linkText,\n linkTo,\n renderLink = externalLinkRenderer,\n actionIcon,\n onClickAction,\n ...rest\n },\n forwardedRef\n) {\n if (isIconName(icon)) {\n warn(\n 'Deprecation: IconName as a value for the icon property of Banner has been deprecated. Use the Icon of bezier-icons instead.'\n )\n }\n\n return (\n <div\n ref={forwardedRef}\n className={classNames(\n styles.Banner,\n styles[`variant-${variant}`],\n className\n )}\n data-testid={BANNER_TEST_ID}\n {...rest}\n >\n {!isNil(icon) && (\n <div className={styles.Center}>\n {isBezierIcon(icon) ? (\n <Icon\n className={classNames(!iconColor && styles.Icon)}\n source={icon}\n color={iconColor}\n size=\"s\"\n />\n ) : (\n <LegacyIcon\n className={classNames(!iconColor && styles.Icon)}\n name={icon}\n color={iconColor}\n size=\"s\"\n />\n )}\n </div>\n )}\n\n <div className={styles.Content}>\n <Text typo=\"14\">\n {content}\n\n {hasLink &&\n renderLink({\n content: (\n <Text\n className={styles.Link}\n typo=\"14\"\n bold\n >\n {linkText}\n </Text>\n ),\n linkTo,\n })}\n </Text>\n </div>\n\n {!isNil(actionIcon) && (\n <div className={styles.Center}>\n <Button\n size=\"xs\"\n colorVariant={getActionButtonColorVariant(variant)}\n styleVariant=\"tertiary\"\n leftContent={actionIcon}\n onClick={onClickAction}\n />\n </div>\n )}\n </div>\n )\n})\n"],"names":["BANNER_TEST_ID","getActionButtonColorVariant","variant","default","blue","cobalt","green","orange","red","alt","externalLinkRenderer","content","linkTo","_jsx","href","target","rel","children","Banner","forwardRef","className","icon","iconColor","hasLink","linkText","renderLink","actionIcon","onClickAction","rest","forwardedRef","isIconName","warn","_jsxs","ref","classNames","styles","isNil","Center","isBezierIcon","Icon","source","color","size","LegacyIcon","name","Content","Text","typo","Link","bold","Button","colorVariant","styleVariant","leftContent","onClick"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAMA,cAAc,GAAG,eAAe;AAEtC,SAASC,2BAA2BA,CAACC,OAAsB,EAAE;EAC3D,OACE;AACEC,IAAAA,OAAO,EAAE,iBAAiB;AAC1BC,IAAAA,IAAI,EAAE,MAAM;AACZC,IAAAA,MAAM,EAAE,QAAQ;AAChBC,IAAAA,KAAK,EAAE,OAAO;AACdC,IAAAA,MAAM,EAAE,QAAQ;AAChBC,IAAAA,GAAG,EAAE,KAAK;AACVC,IAAAA,GAAG,EAAE;GACN,CACDP,OAAO,CAAC;AACZ;AAEA,MAAMQ,oBAAoC,GAAGA,CAAC;EAAEC,OAAO;AAAEC,EAAAA;AAAO,CAAC,kBAC/DC,cAAA,CAAA,GAAA,EAAA;AACEC,EAAAA,IAAI,EAAEF,MAAO;AACbG,EAAAA,MAAM,EAAC,QAAQ;AACfC,EAAAA,GAAG,EAAC,qBAAqB;AAAAC,EAAAA,QAAA,EAExBN;AAAO,CACP,CACJ;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaO,MAAM,gBAAGC,gBAAU,CAA8B,SAASD,MAAMA,CAC3E;EACEE,SAAS;AACTlB,EAAAA,OAAO,GAAG,SAAS;EACnBmB,IAAI;EACJC,SAAS;EACTX,OAAO;AACPY,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ;EACRZ,MAAM;AACNa,EAAAA,UAAU,GAAGf,oBAAoB;EACjCgB,UAAU;EACVC,aAAa;EACb,GAAGC;AACL,CAAC,EACDC,YAAY,EACZ;AACA,EAAA,IAAIC,gBAAU,CAACT,IAAI,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"Banner.js","sources":["../../../../src/components/Banner/Banner.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef } from 'react'\n\nimport { isBezierIcon } from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { warn } from '~/src/utils/assert'\nimport { isNil } from '~/src/utils/type'\n\nimport { Button } from '~/src/components/Button'\nimport { Icon } from '~/src/components/Icon'\nimport { LegacyIcon, isIconName } from '~/src/components/LegacyIcon'\nimport { Text } from '~/src/components/Text'\n\nimport {\n type BannerProps,\n type BannerVariant,\n type RenderLinkFunc,\n} from './Banner.types'\n\nimport styles from './Banner.module.scss'\n\nconst BANNER_TEST_ID = 'bezier-banner'\n\nfunction getActionButtonColorVariant(variant: BannerVariant) {\n return (\n {\n default: 'monochrome-dark',\n blue: 'blue',\n cobalt: 'cobalt',\n green: 'green',\n orange: 'orange',\n red: 'red',\n alt: 'monochrome-dark',\n } as const\n )[variant]\n}\n\nconst externalLinkRenderer: RenderLinkFunc = ({ content, linkTo }) => (\n <a\n href={linkTo}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {content}\n </a>\n)\n\n/**\n * `Banner` is a component you use when you want to communicate instructions, warnings, recommendations, and other information well.\n * @example\n * ```tsx\n * <Banner\n * variant=\"blue\"\n * icon={LightbulbIcon}\n * content=\"Information here.\"\n * />\n * ```\n */\nexport const Banner = forwardRef<HTMLDivElement, BannerProps>(function Banner(\n {\n className,\n variant = 'default',\n icon,\n iconColor,\n content,\n hasLink = false,\n linkText,\n linkTo,\n renderLink = externalLinkRenderer,\n actionIcon,\n onClickAction,\n ...rest\n },\n forwardedRef\n) {\n if (isIconName(icon)) {\n warn(\n 'Deprecation: IconName as a value for the icon property of Banner has been deprecated. Use the Icon of bezier-icons instead.',\n 'Banner.IconName'\n )\n }\n\n return (\n <div\n ref={forwardedRef}\n className={classNames(\n styles.Banner,\n styles[`variant-${variant}`],\n className\n )}\n data-testid={BANNER_TEST_ID}\n {...rest}\n >\n {!isNil(icon) && (\n <div className={styles.Center}>\n {isBezierIcon(icon) ? (\n <Icon\n className={classNames(!iconColor && styles.Icon)}\n source={icon}\n color={iconColor}\n size=\"s\"\n />\n ) : (\n <LegacyIcon\n className={classNames(!iconColor && styles.Icon)}\n name={icon}\n color={iconColor}\n size=\"s\"\n />\n )}\n </div>\n )}\n\n <div className={styles.Content}>\n <Text typo=\"14\">\n {content}\n\n {hasLink &&\n renderLink({\n content: (\n <Text\n className={styles.Link}\n typo=\"14\"\n bold\n >\n {linkText}\n </Text>\n ),\n linkTo,\n })}\n </Text>\n </div>\n\n {!isNil(actionIcon) && (\n <div className={styles.Center}>\n <Button\n size=\"xs\"\n colorVariant={getActionButtonColorVariant(variant)}\n styleVariant=\"tertiary\"\n leftContent={actionIcon}\n onClick={onClickAction}\n />\n </div>\n )}\n </div>\n )\n})\n"],"names":["BANNER_TEST_ID","getActionButtonColorVariant","variant","default","blue","cobalt","green","orange","red","alt","externalLinkRenderer","content","linkTo","_jsx","href","target","rel","children","Banner","forwardRef","className","icon","iconColor","hasLink","linkText","renderLink","actionIcon","onClickAction","rest","forwardedRef","isIconName","warn","_jsxs","ref","classNames","styles","isNil","Center","isBezierIcon","Icon","source","color","size","LegacyIcon","name","Content","Text","typo","Link","bold","Button","colorVariant","styleVariant","leftContent","onClick"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAMA,cAAc,GAAG,eAAe;AAEtC,SAASC,2BAA2BA,CAACC,OAAsB,EAAE;EAC3D,OACE;AACEC,IAAAA,OAAO,EAAE,iBAAiB;AAC1BC,IAAAA,IAAI,EAAE,MAAM;AACZC,IAAAA,MAAM,EAAE,QAAQ;AAChBC,IAAAA,KAAK,EAAE,OAAO;AACdC,IAAAA,MAAM,EAAE,QAAQ;AAChBC,IAAAA,GAAG,EAAE,KAAK;AACVC,IAAAA,GAAG,EAAE;GACN,CACDP,OAAO,CAAC;AACZ;AAEA,MAAMQ,oBAAoC,GAAGA,CAAC;EAAEC,OAAO;AAAEC,EAAAA;AAAO,CAAC,kBAC/DC,cAAA,CAAA,GAAA,EAAA;AACEC,EAAAA,IAAI,EAAEF,MAAO;AACbG,EAAAA,MAAM,EAAC,QAAQ;AACfC,EAAAA,GAAG,EAAC,qBAAqB;AAAAC,EAAAA,QAAA,EAExBN;AAAO,CACP,CACJ;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaO,MAAM,gBAAGC,gBAAU,CAA8B,SAASD,MAAMA,CAC3E;EACEE,SAAS;AACTlB,EAAAA,OAAO,GAAG,SAAS;EACnBmB,IAAI;EACJC,SAAS;EACTX,OAAO;AACPY,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ;EACRZ,MAAM;AACNa,EAAAA,UAAU,GAAGf,oBAAoB;EAC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QAAAA,QAAA,GACZN,OAAO,EAEPY,OAAO,IACNE,UAAU,CAAC;UACTd,OAAO,eACLE,cAAA,CAACiC,SAAI,EAAA;YACH1B,SAAS,EAAEe,qBAAM,CAACa,IAAK;AACvBD,YAAAA,IAAI,EAAC,IAAI;YACTE,IAAI,EAAA,IAAA;AAAAhC,YAAAA,QAAA,EAEHO;AAAQ,WACL,CACP;AACDZ,UAAAA;AACF,SAAC,CAAC;OACA;KACH,CAAC,EAEL,CAACwB,UAAK,CAACV,UAAU,CAAC,iBACjBb,cAAA,CAAA,KAAA,EAAA;MAAKO,SAAS,EAAEe,qBAAM,CAACE,MAAO;MAAApB,QAAA,eAC5BJ,cAAA,CAACqC,aAAM,EAAA;AACLR,QAAAA,IAAI,EAAC,IAAI;AACTS,QAAAA,YAAY,EAAElD,2BAA2B,CAACC,OAAO,CAAE;AACnDkD,QAAAA,YAAY,EAAC,UAAU;AACvBC,QAAAA,WAAW,EAAE3B,UAAW;AACxB4B,QAAAA,OAAO,EAAE3B;OACV;AAAC,KACC,CACN;AAAA,GACE,CAAC;AAEV,CAAC;;;;"}
|
|
@@ -46,7 +46,7 @@ function ButtonSideContent({
|
|
|
46
46
|
children
|
|
47
47
|
}) {
|
|
48
48
|
if (utils.isIconName(children)) {
|
|
49
|
-
assert.warn('Deprecation: IconName as a value for the leftContent property of a Button has been deprecated. Use the Icon of bezier-icons instead.');
|
|
49
|
+
assert.warn('Deprecation: IconName as a value for the leftContent property of a Button has been deprecated. Use the Icon of bezier-icons instead.', 'Button.IconName');
|
|
50
50
|
return /*#__PURE__*/jsxRuntime.jsx(LegacyIcon.LegacyIcon, {
|
|
51
51
|
className: Button_module.default.ButtonIcon,
|
|
52
52
|
name: children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, useCallback } from 'react'\n\nimport { isBezierIcon } from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { warn } from '~/src/utils/assert'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { Icon } from '~/src/components/Icon'\nimport { LegacyIcon, isIconName } from '~/src/components/LegacyIcon'\nimport { Spinner } from '~/src/components/Spinner'\nimport { Text } from '~/src/components/Text'\n\nimport type { ButtonProps, ButtonSize, SideContent } from './Button.types'\n\nimport styles from './Button.module.scss'\n\nexport const BUTTON_TEST_ID = 'bezier-button'\n\nfunction getTypography(size: ButtonSize) {\n return (\n {\n xs: '13',\n s: '13',\n m: '14',\n l: '15',\n xl: '18',\n } as const\n )[size]\n}\n\nfunction getIconSize(size: ButtonSize) {\n return (\n {\n xs: 'xs',\n s: 'xs',\n m: 's',\n l: 's',\n xl: 'm',\n } as const\n )[size]\n}\n\nfunction getSpinnerSize(size: ButtonSize) {\n return (\n {\n xs: 'xs',\n s: 'xs',\n m: 's',\n l: 's',\n xl: 's',\n } as const\n )[size]\n}\n\nfunction ButtonSideContent({\n size,\n children,\n}: {\n size: ButtonSize\n children: SideContent\n}) {\n if (isIconName(children)) {\n warn(\n 'Deprecation: IconName as a value for the leftContent property of a Button has been deprecated. Use the Icon of bezier-icons instead.'\n )\n return (\n <LegacyIcon\n className={styles.ButtonIcon}\n name={children}\n size={getIconSize(size)}\n />\n )\n }\n\n if (isBezierIcon(children)) {\n return (\n <Icon\n className={styles.ButtonIcon}\n source={children}\n size={getIconSize(size)}\n />\n )\n }\n\n return <>{children}</>\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n function Button(\n {\n as = BaseButton,\n className,\n text,\n loading = false,\n disabled: disabledProp = false,\n active = false,\n size = 'm',\n styleVariant = 'primary',\n colorVariant = 'blue',\n leftContent,\n rightContent,\n onClick,\n ...rest\n },\n forwardedRef\n ) {\n const Comp = as as typeof BaseButton\n\n const disabled = loading || disabledProp\n\n const handleClick = useCallback<React.MouseEventHandler<HTMLButtonElement>>(\n (event) => {\n if (!disabled) {\n onClick?.(event)\n }\n },\n [onClick, disabled]\n )\n\n return (\n <Comp\n ref={forwardedRef}\n className={classNames(\n styles.Button,\n styles[`size-${size}`],\n styles[`style-${styleVariant}`],\n styles[`color-${colorVariant}`],\n active && styles.active,\n className\n )}\n disabled={disabled}\n onClick={handleClick}\n data-testid={BUTTON_TEST_ID}\n data-bezier-component=\"Button\"\n {...rest}\n >\n <div\n className={classNames(\n styles.ButtonContent,\n loading && styles.loading\n )}\n >\n <ButtonSideContent size={size}>{leftContent}</ButtonSideContent>\n\n {text && (\n <Text\n className={styles.ButtonText}\n typo={getTypography(size)}\n bold\n >\n {text}\n </Text>\n )}\n\n <ButtonSideContent size={size}>{rightContent}</ButtonSideContent>\n </div>\n\n {loading && (\n <div className={styles.ButtonLoader}>\n <Spinner size={getSpinnerSize(size)} />\n </div>\n )}\n </Comp>\n )\n }\n)\n"],"names":["BUTTON_TEST_ID","getTypography","size","xs","s","m","l","xl","getIconSize","getSpinnerSize","ButtonSideContent","children","isIconName","warn","_jsx","LegacyIcon","className","styles","ButtonIcon","name","isBezierIcon","Icon","source","_Fragment","Button","forwardRef","as","BaseButton","text","loading","disabled","disabledProp","active","styleVariant","colorVariant","leftContent","rightContent","onClick","rest","forwardedRef","Comp","handleClick","useCallback","event","_jsxs","ref","classNames","ButtonContent","Text","ButtonText","typo","bold","ButtonLoader","Spinner"],"mappings":";;;;;;;;;;;;;;;AAmBO,MAAMA,cAAc,GAAG;AAE9B,SAASC,aAAaA,CAACC,IAAgB,EAAE;EACvC,OACE;AACEC,IAAAA,EAAE,EAAE,IAAI;AACRC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,EAAE,EAAE;GACL,CACDL,IAAI,CAAC;AACT;AAEA,SAASM,WAAWA,CAACN,IAAgB,EAAE;EACrC,OACE;AACEC,IAAAA,EAAE,EAAE,IAAI;AACRC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,EAAE,EAAE;GACL,CACDL,IAAI,CAAC;AACT;AAEA,SAASO,cAAcA,CAACP,IAAgB,EAAE;EACxC,OACE;AACEC,IAAAA,EAAE,EAAE,IAAI;AACRC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,EAAE,EAAE;GACL,CACDL,IAAI,CAAC;AACT;AAEA,SAASQ,iBAAiBA,CAAC;EACzBR,IAAI;AACJS,EAAAA;AAIF,CAAC,EAAE;AACD,EAAA,IAAIC,gBAAU,CAACD,QAAQ,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, useCallback } from 'react'\n\nimport { isBezierIcon } from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { warn } from '~/src/utils/assert'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { Icon } from '~/src/components/Icon'\nimport { LegacyIcon, isIconName } from '~/src/components/LegacyIcon'\nimport { Spinner } from '~/src/components/Spinner'\nimport { Text } from '~/src/components/Text'\n\nimport type { ButtonProps, ButtonSize, SideContent } from './Button.types'\n\nimport styles from './Button.module.scss'\n\nexport const BUTTON_TEST_ID = 'bezier-button'\n\nfunction getTypography(size: ButtonSize) {\n return (\n {\n xs: '13',\n s: '13',\n m: '14',\n l: '15',\n xl: '18',\n } as const\n )[size]\n}\n\nfunction getIconSize(size: ButtonSize) {\n return (\n {\n xs: 'xs',\n s: 'xs',\n m: 's',\n l: 's',\n xl: 'm',\n } as const\n )[size]\n}\n\nfunction getSpinnerSize(size: ButtonSize) {\n return (\n {\n xs: 'xs',\n s: 'xs',\n m: 's',\n l: 's',\n xl: 's',\n } as const\n )[size]\n}\n\nfunction ButtonSideContent({\n size,\n children,\n}: {\n size: ButtonSize\n children: SideContent\n}) {\n if (isIconName(children)) {\n warn(\n 'Deprecation: IconName as a value for the leftContent property of a Button has been deprecated. Use the Icon of bezier-icons instead.',\n 'Button.IconName'\n )\n return (\n <LegacyIcon\n className={styles.ButtonIcon}\n name={children}\n size={getIconSize(size)}\n />\n )\n }\n\n if (isBezierIcon(children)) {\n return (\n <Icon\n className={styles.ButtonIcon}\n source={children}\n size={getIconSize(size)}\n />\n )\n }\n\n return <>{children}</>\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n function Button(\n {\n as = BaseButton,\n className,\n text,\n loading = false,\n disabled: disabledProp = false,\n active = false,\n size = 'm',\n styleVariant = 'primary',\n colorVariant = 'blue',\n leftContent,\n rightContent,\n onClick,\n ...rest\n },\n forwardedRef\n ) {\n const Comp = as as typeof BaseButton\n\n const disabled = loading || disabledProp\n\n const handleClick = useCallback<React.MouseEventHandler<HTMLButtonElement>>(\n (event) => {\n if (!disabled) {\n onClick?.(event)\n }\n },\n [onClick, disabled]\n )\n\n return (\n <Comp\n ref={forwardedRef}\n className={classNames(\n styles.Button,\n styles[`size-${size}`],\n styles[`style-${styleVariant}`],\n styles[`color-${colorVariant}`],\n active && styles.active,\n className\n )}\n disabled={disabled}\n onClick={handleClick}\n data-testid={BUTTON_TEST_ID}\n data-bezier-component=\"Button\"\n {...rest}\n >\n <div\n className={classNames(\n styles.ButtonContent,\n loading && styles.loading\n )}\n >\n <ButtonSideContent size={size}>{leftContent}</ButtonSideContent>\n\n {text && (\n <Text\n className={styles.ButtonText}\n typo={getTypography(size)}\n bold\n >\n {text}\n </Text>\n )}\n\n <ButtonSideContent size={size}>{rightContent}</ButtonSideContent>\n </div>\n\n {loading && (\n <div className={styles.ButtonLoader}>\n <Spinner size={getSpinnerSize(size)} />\n </div>\n )}\n </Comp>\n )\n }\n)\n"],"names":["BUTTON_TEST_ID","getTypography","size","xs","s","m","l","xl","getIconSize","getSpinnerSize","ButtonSideContent","children","isIconName","warn","_jsx","LegacyIcon","className","styles","ButtonIcon","name","isBezierIcon","Icon","source","_Fragment","Button","forwardRef","as","BaseButton","text","loading","disabled","disabledProp","active","styleVariant","colorVariant","leftContent","rightContent","onClick","rest","forwardedRef","Comp","handleClick","useCallback","event","_jsxs","ref","classNames","ButtonContent","Text","ButtonText","typo","bold","ButtonLoader","Spinner"],"mappings":";;;;;;;;;;;;;;;AAmBO,MAAMA,cAAc,GAAG;AAE9B,SAASC,aAAaA,CAACC,IAAgB,EAAE;EACvC,OACE;AACEC,IAAAA,EAAE,EAAE,IAAI;AACRC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,EAAE,EAAE;GACL,CACDL,IAAI,CAAC;AACT;AAEA,SAASM,WAAWA,CAACN,IAAgB,EAAE;EACrC,OACE;AACEC,IAAAA,EAAE,EAAE,IAAI;AACRC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,EAAE,EAAE;GACL,CACDL,IAAI,CAAC;AACT;AAEA,SAASO,cAAcA,CAACP,IAAgB,EAAE;EACxC,OACE;AACEC,IAAAA,EAAE,EAAE,IAAI;AACRC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,EAAE,EAAE;GACL,CACDL,IAAI,CAAC;AACT;AAEA,SAASQ,iBAAiBA,CAAC;EACzBR,IAAI;AACJS,EAAAA;AAIF,CAAC,EAAE;AACD,EAAA,IAAIC,gBAAU,CAACD,QAAQ,CAAC,EAAE;AACxBE,IAAAA,WAAI,CACF,sIAAsI,EACtI,iBACF,CAAC;IACD,oBACEC,cAAA,CAACC,qBAAU,EAAA;MACTC,SAAS,EAAEC,qBAAM,CAACC,UAAW;AAC7BC,MAAAA,IAAI,EAAER,QAAS;MACfT,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,CACN;AAAA,GACG,CAAC;AAEX,CACF;;;;;"}
|
|
@@ -25,7 +25,7 @@ function LeftContent({
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
if (isLegacyIcon) {
|
|
28
|
-
assert.warn('Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.');
|
|
28
|
+
assert.warn('Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.', 'SectionLabel.LeftContent.IconName');
|
|
29
29
|
}
|
|
30
30
|
const Comp = isLegacyIcon ? LegacyIcon.LegacyIcon : Icon.Icon;
|
|
31
31
|
return (
|
|
@@ -56,7 +56,7 @@ function RightContent({
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
if (isLegacyIcon) {
|
|
59
|
-
assert.warn('Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.');
|
|
59
|
+
assert.warn('Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.', 'SectionLabel.RightContent.IconName');
|
|
60
60
|
}
|
|
61
61
|
return /*#__PURE__*/jsxRuntime.jsx(Button.Button, {
|
|
62
62
|
...(withAction ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionLabel.js","sources":["../../../../src/components/SectionLabel/SectionLabel.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef } from 'react'\n\nimport { isBezierIcon } from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { warn } from '~/src/utils/assert'\nimport {\n isArray,\n isEmpty,\n isNil,\n isNumber,\n isObject,\n isString,\n} from '~/src/utils/type'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { Button } from '~/src/components/Button'\nimport { Help } from '~/src/components/Help'\nimport { Icon } from '~/src/components/Icon'\nimport { LegacyIcon, isIconName } from '~/src/components/LegacyIcon'\nimport { Text } from '~/src/components/Text'\n\nimport {\n type IconWithAction,\n type SectionLabelLeftContent,\n type SectionLabelProps,\n type SectionLabelRightContent,\n} from './SectionLabel.types'\n\nimport styles from './SectionLabel.module.scss'\n\nfunction LeftContent({ children }: { children: SectionLabelLeftContent }) {\n const isLegacyIcon = isIconName(children)\n\n if (!isBezierIcon(children) && !isLegacyIcon) {\n return <>{children}</>\n }\n\n if (isLegacyIcon) {\n warn(\n 'Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.'\n )\n }\n\n const Comp = isLegacyIcon ? LegacyIcon : Icon\n\n return (\n // @ts-expect-error\n <Comp\n {...(isLegacyIcon\n ? {\n name: children,\n }\n : {\n source: children,\n })}\n size=\"s\"\n color=\"txt-black-dark\"\n />\n )\n}\n\nfunction isIconWithAction(args: unknown): args is IconWithAction {\n return isObject(args) && 'icon' in args\n}\n\nfunction RightContent({ children }: { children: SectionLabelRightContent }) {\n const isLegacyIcon = isIconName(children)\n const withAction = isIconWithAction(children)\n\n if (!isBezierIcon(children) && !isLegacyIcon && !withAction) {\n return <>{children}</>\n }\n\n if (isLegacyIcon) {\n warn(\n 'Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.'\n )\n }\n\n return (\n <Button\n {...(withAction\n ? {\n leftContent: children.icon,\n onClick: children.onClick,\n }\n : {\n as: 'div',\n leftContent: children,\n })}\n className={styles.RightItem}\n size=\"xs\"\n styleVariant=\"tertiary\"\n colorVariant=\"monochrome-light\"\n />\n )\n}\n\nexport const SectionLabel = forwardRef<HTMLElement, SectionLabelProps>(\n function SectionLabel(\n {\n children,\n className,\n open = true,\n help,\n leftContent,\n content,\n rightContent,\n onClick,\n ...props\n },\n forwardedRef\n ) {\n const Comp = !isNil(onClick) ? BaseButton : 'div'\n\n return (\n <>\n <Comp\n // @ts-expect-error\n ref={forwardedRef}\n className={classNames(styles.SectionLabel, className)}\n data-testid=\"bezier-section-label\"\n onClick={onClick}\n {...props}\n >\n {leftContent && (\n <div className={styles.LeftContent}>\n <LeftContent>{leftContent}</LeftContent>\n </div>\n )}\n\n <div className={styles.Content}>\n {isString(content) || isNumber(content) ? (\n <Text\n bold\n typo=\"13\"\n color=\"txt-black-dark\"\n truncated\n >\n {content}\n </Text>\n ) : (\n content\n )}\n </div>\n\n {help && (\n <div className={styles.Help}>\n <Help allowHover>{help}</Help>\n </div>\n )}\n\n {!isNil(rightContent) && !isEmpty(rightContent) && (\n <div className={styles.RightContent}>\n {isArray(rightContent) ? (\n rightContent.map((eachContent, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <RightContent key={index}>{eachContent}</RightContent>\n ))\n ) : (\n <RightContent>{rightContent}</RightContent>\n )}\n </div>\n )}\n </Comp>\n\n {children && open && <div>{children}</div>}\n </>\n )\n }\n)\n"],"names":["LeftContent","children","isLegacyIcon","isIconName","isBezierIcon","_jsx","_Fragment","warn","Comp","LegacyIcon","Icon","name","source","size","color","isIconWithAction","args","isObject","RightContent","withAction","Button","leftContent","icon","onClick","as","className","styles","RightItem","styleVariant","colorVariant","SectionLabel","forwardRef","open","help","content","rightContent","props","forwardedRef","isNil","BaseButton","_jsxs","ref","classNames","Content","isString","isNumber","Text","bold","typo","truncated","Help","allowHover","isEmpty","isArray","map","eachContent","index"],"mappings":";;;;;;;;;;;;;;;;;AAiCA,SAASA,WAAWA,CAAC;AAAEC,EAAAA;AAAgD,CAAC,EAAE;AACxE,EAAA,MAAMC,YAAY,GAAGC,gBAAU,CAACF,QAAQ,CAAC;EAEzC,IAAI,CAACG,wBAAY,CAACH,QAAQ,CAAC,IAAI,CAACC,YAAY,EAAE;IAC5C,oBAAOG,cAAA,CAAAC,mBAAA,EAAA;AAAAL,MAAAA,QAAA,EAAGA;AAAQ,KAAG,CAAC;AACxB;AAEA,EAAA,IAAIC,YAAY,EAAE;
|
|
1
|
+
{"version":3,"file":"SectionLabel.js","sources":["../../../../src/components/SectionLabel/SectionLabel.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef } from 'react'\n\nimport { isBezierIcon } from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { warn } from '~/src/utils/assert'\nimport {\n isArray,\n isEmpty,\n isNil,\n isNumber,\n isObject,\n isString,\n} from '~/src/utils/type'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { Button } from '~/src/components/Button'\nimport { Help } from '~/src/components/Help'\nimport { Icon } from '~/src/components/Icon'\nimport { LegacyIcon, isIconName } from '~/src/components/LegacyIcon'\nimport { Text } from '~/src/components/Text'\n\nimport {\n type IconWithAction,\n type SectionLabelLeftContent,\n type SectionLabelProps,\n type SectionLabelRightContent,\n} from './SectionLabel.types'\n\nimport styles from './SectionLabel.module.scss'\n\nfunction LeftContent({ children }: { children: SectionLabelLeftContent }) {\n const isLegacyIcon = isIconName(children)\n\n if (!isBezierIcon(children) && !isLegacyIcon) {\n return <>{children}</>\n }\n\n if (isLegacyIcon) {\n warn(\n 'Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.',\n 'SectionLabel.LeftContent.IconName'\n )\n }\n\n const Comp = isLegacyIcon ? LegacyIcon : Icon\n\n return (\n // @ts-expect-error\n <Comp\n {...(isLegacyIcon\n ? {\n name: children,\n }\n : {\n source: children,\n })}\n size=\"s\"\n color=\"txt-black-dark\"\n />\n )\n}\n\nfunction isIconWithAction(args: unknown): args is IconWithAction {\n return isObject(args) && 'icon' in args\n}\n\nfunction RightContent({ children }: { children: SectionLabelRightContent }) {\n const isLegacyIcon = isIconName(children)\n const withAction = isIconWithAction(children)\n\n if (!isBezierIcon(children) && !isLegacyIcon && !withAction) {\n return <>{children}</>\n }\n\n if (isLegacyIcon) {\n warn(\n 'Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.',\n 'SectionLabel.RightContent.IconName'\n )\n }\n\n return (\n <Button\n {...(withAction\n ? {\n leftContent: children.icon,\n onClick: children.onClick,\n }\n : {\n as: 'div',\n leftContent: children,\n })}\n className={styles.RightItem}\n size=\"xs\"\n styleVariant=\"tertiary\"\n colorVariant=\"monochrome-light\"\n />\n )\n}\n\nexport const SectionLabel = forwardRef<HTMLElement, SectionLabelProps>(\n function SectionLabel(\n {\n children,\n className,\n open = true,\n help,\n leftContent,\n content,\n rightContent,\n onClick,\n ...props\n },\n forwardedRef\n ) {\n const Comp = !isNil(onClick) ? BaseButton : 'div'\n\n return (\n <>\n <Comp\n // @ts-expect-error\n ref={forwardedRef}\n className={classNames(styles.SectionLabel, className)}\n data-testid=\"bezier-section-label\"\n onClick={onClick}\n {...props}\n >\n {leftContent && (\n <div className={styles.LeftContent}>\n <LeftContent>{leftContent}</LeftContent>\n </div>\n )}\n\n <div className={styles.Content}>\n {isString(content) || isNumber(content) ? (\n <Text\n bold\n typo=\"13\"\n color=\"txt-black-dark\"\n truncated\n >\n {content}\n </Text>\n ) : (\n content\n )}\n </div>\n\n {help && (\n <div className={styles.Help}>\n <Help allowHover>{help}</Help>\n </div>\n )}\n\n {!isNil(rightContent) && !isEmpty(rightContent) && (\n <div className={styles.RightContent}>\n {isArray(rightContent) ? (\n rightContent.map((eachContent, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <RightContent key={index}>{eachContent}</RightContent>\n ))\n ) : (\n <RightContent>{rightContent}</RightContent>\n )}\n </div>\n )}\n </Comp>\n\n {children && open && <div>{children}</div>}\n </>\n )\n }\n)\n"],"names":["LeftContent","children","isLegacyIcon","isIconName","isBezierIcon","_jsx","_Fragment","warn","Comp","LegacyIcon","Icon","name","source","size","color","isIconWithAction","args","isObject","RightContent","withAction","Button","leftContent","icon","onClick","as","className","styles","RightItem","styleVariant","colorVariant","SectionLabel","forwardRef","open","help","content","rightContent","props","forwardedRef","isNil","BaseButton","_jsxs","ref","classNames","Content","isString","isNumber","Text","bold","typo","truncated","Help","allowHover","isEmpty","isArray","map","eachContent","index"],"mappings":";;;;;;;;;;;;;;;;;AAiCA,SAASA,WAAWA,CAAC;AAAEC,EAAAA;AAAgD,CAAC,EAAE;AACxE,EAAA,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.env.NODE_ENV !== 'production';
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
const devWarningScopes = new Set();
|
|
7
|
+
function warn(message, scope) {
|
|
7
8
|
if (isDev()) {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
if (scope) {
|
|
10
|
+
if (!devWarningScopes.has(scope)) {
|
|
11
|
+
devWarningScopes.add(scope);
|
|
12
|
+
// eslint-disable-next-line no-console
|
|
13
|
+
console.warn(message);
|
|
14
|
+
}
|
|
15
|
+
} else {
|
|
16
|
+
// eslint-disable-next-line no-console
|
|
17
|
+
console.warn(message);
|
|
18
|
+
}
|
|
10
19
|
}
|
|
11
20
|
}
|
|
12
21
|
class AssertionException extends Error {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.js","sources":["../../../src/utils/assert.ts"],"sourcesContent":["export function isDev() {\n return process.env.NODE_ENV !== 'production'\n}\n\nexport function warn(message: string) {\n if (isDev()) {\n // eslint-disable-next-line no-console\n console.warn(message)\n }\n}\n\nexport class AssertionException extends Error {\n constructor(message?: string) {\n super()\n\n this.name = 'AssertionException'\n this.message = message ?? 'assertion failed'\n }\n}\n\nexport function assert(\n predicate: boolean,\n message?: string\n): asserts predicate {\n if (predicate) {\n return\n }\n\n if (isDev()) {\n throw new AssertionException(message)\n }\n}\n"],"names":["isDev","process","env","NODE_ENV","warn","message","console","AssertionException","Error","constructor","name","assert","predicate"],"mappings":";;AAAO,SAASA,KAAKA,GAAG;AACtB,EAAA,OAAOC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;AAC9C;
|
|
1
|
+
{"version":3,"file":"assert.js","sources":["../../../src/utils/assert.ts"],"sourcesContent":["export function isDev() {\n return process.env.NODE_ENV !== 'production'\n}\n\nconst devWarningScopes = new Set<string>()\n\nexport function warn(message: string): void\nexport function warn(message: string, scope: string): void\nexport function warn(message: string, scope?: string) {\n if (isDev()) {\n if (scope) {\n if (!devWarningScopes.has(scope)) {\n devWarningScopes.add(scope)\n // eslint-disable-next-line no-console\n console.warn(message)\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn(message)\n }\n }\n}\n\nexport class AssertionException extends Error {\n constructor(message?: string) {\n super()\n\n this.name = 'AssertionException'\n this.message = message ?? 'assertion failed'\n }\n}\n\nexport function assert(\n predicate: boolean,\n message?: string\n): asserts predicate {\n if (predicate) {\n return\n }\n\n if (isDev()) {\n throw new AssertionException(message)\n }\n}\n"],"names":["isDev","process","env","NODE_ENV","devWarningScopes","Set","warn","message","scope","has","add","console","AssertionException","Error","constructor","name","assert","predicate"],"mappings":";;AAAO,SAASA,KAAKA,GAAG;AACtB,EAAA,OAAOC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;AAC9C;AAEA,MAAMC,gBAAgB,GAAG,IAAIC,GAAG,EAAU;AAInC,SAASC,IAAIA,CAACC,OAAe,EAAEC,KAAc,EAAE;EACpD,IAAIR,KAAK,EAAE,EAAE;AACX,IAAA,IAAIQ,KAAK,EAAE;AACT,MAAA,IAAI,CAACJ,gBAAgB,CAACK,GAAG,CAACD,KAAK,CAAC,EAAE;AAChCJ,QAAAA,gBAAgB,CAACM,GAAG,CAACF,KAAK,CAAC;AAC3B;AACAG,QAAAA,OAAO,CAACL,IAAI,CAACC,OAAO,CAAC;AACvB;AACF,KAAC,MAAM;AACL;AACAI,MAAAA,OAAO,CAACL,IAAI,CAACC,OAAO,CAAC;AACvB;AACF;AACF;AAEO,MAAMK,kBAAkB,SAASC,KAAK,CAAC;EAC5CC,WAAWA,CAACP,OAAgB,EAAE;AAC5B,IAAA,KAAK,EAAE;IAEP,IAAI,CAACQ,IAAI,GAAG,oBAAoB;IAChC,IAAI,CAACR,OAAO,GAAGA,OAAO,aAAPA,OAAO,KAAA,KAAA,CAAA,GAAPA,OAAO,GAAI,kBAAkB;AAC9C;AACF;AAEO,SAASS,MAAMA,CACpBC,SAAkB,EAClBV,OAAgB,EACG;AACnB,EAAA,IAAIU,SAAS,EAAE;AACb,IAAA;AACF;EAEA,IAAIjB,KAAK,EAAE,EAAE;AACX,IAAA,MAAM,IAAIY,kBAAkB,CAACL,OAAO,CAAC;AACvC;AACF;;;;;;;"}
|
|
@@ -59,7 +59,7 @@ const Banner = /*#__PURE__*/forwardRef(function Banner({
|
|
|
59
59
|
...rest
|
|
60
60
|
}, forwardedRef) {
|
|
61
61
|
if (isIconName(icon)) {
|
|
62
|
-
warn('Deprecation: IconName as a value for the icon property of Banner has been deprecated. Use the Icon of bezier-icons instead.');
|
|
62
|
+
warn('Deprecation: IconName as a value for the icon property of Banner has been deprecated. Use the Icon of bezier-icons instead.', 'Banner.IconName');
|
|
63
63
|
}
|
|
64
64
|
return /*#__PURE__*/jsxs("div", {
|
|
65
65
|
ref: forwardedRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.mjs","sources":["../../../../src/components/Banner/Banner.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef } from 'react'\n\nimport { isBezierIcon } from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { warn } from '~/src/utils/assert'\nimport { isNil } from '~/src/utils/type'\n\nimport { Button } from '~/src/components/Button'\nimport { Icon } from '~/src/components/Icon'\nimport { LegacyIcon, isIconName } from '~/src/components/LegacyIcon'\nimport { Text } from '~/src/components/Text'\n\nimport {\n type BannerProps,\n type BannerVariant,\n type RenderLinkFunc,\n} from './Banner.types'\n\nimport styles from './Banner.module.scss'\n\nconst BANNER_TEST_ID = 'bezier-banner'\n\nfunction getActionButtonColorVariant(variant: BannerVariant) {\n return (\n {\n default: 'monochrome-dark',\n blue: 'blue',\n cobalt: 'cobalt',\n green: 'green',\n orange: 'orange',\n red: 'red',\n alt: 'monochrome-dark',\n } as const\n )[variant]\n}\n\nconst externalLinkRenderer: RenderLinkFunc = ({ content, linkTo }) => (\n <a\n href={linkTo}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {content}\n </a>\n)\n\n/**\n * `Banner` is a component you use when you want to communicate instructions, warnings, recommendations, and other information well.\n * @example\n * ```tsx\n * <Banner\n * variant=\"blue\"\n * icon={LightbulbIcon}\n * content=\"Information here.\"\n * />\n * ```\n */\nexport const Banner = forwardRef<HTMLDivElement, BannerProps>(function Banner(\n {\n className,\n variant = 'default',\n icon,\n iconColor,\n content,\n hasLink = false,\n linkText,\n linkTo,\n renderLink = externalLinkRenderer,\n actionIcon,\n onClickAction,\n ...rest\n },\n forwardedRef\n) {\n if (isIconName(icon)) {\n warn(\n 'Deprecation: IconName as a value for the icon property of Banner has been deprecated. Use the Icon of bezier-icons instead.'\n )\n }\n\n return (\n <div\n ref={forwardedRef}\n className={classNames(\n styles.Banner,\n styles[`variant-${variant}`],\n className\n )}\n data-testid={BANNER_TEST_ID}\n {...rest}\n >\n {!isNil(icon) && (\n <div className={styles.Center}>\n {isBezierIcon(icon) ? (\n <Icon\n className={classNames(!iconColor && styles.Icon)}\n source={icon}\n color={iconColor}\n size=\"s\"\n />\n ) : (\n <LegacyIcon\n className={classNames(!iconColor && styles.Icon)}\n name={icon}\n color={iconColor}\n size=\"s\"\n />\n )}\n </div>\n )}\n\n <div className={styles.Content}>\n <Text typo=\"14\">\n {content}\n\n {hasLink &&\n renderLink({\n content: (\n <Text\n className={styles.Link}\n typo=\"14\"\n bold\n >\n {linkText}\n </Text>\n ),\n linkTo,\n })}\n </Text>\n </div>\n\n {!isNil(actionIcon) && (\n <div className={styles.Center}>\n <Button\n size=\"xs\"\n colorVariant={getActionButtonColorVariant(variant)}\n styleVariant=\"tertiary\"\n leftContent={actionIcon}\n onClick={onClickAction}\n />\n </div>\n )}\n </div>\n )\n})\n"],"names":["BANNER_TEST_ID","getActionButtonColorVariant","variant","default","blue","cobalt","green","orange","red","alt","externalLinkRenderer","content","linkTo","_jsx","href","target","rel","children","Banner","forwardRef","className","icon","iconColor","hasLink","linkText","renderLink","actionIcon","onClickAction","rest","forwardedRef","isIconName","warn","_jsxs","ref","classNames","styles","isNil","Center","isBezierIcon","Icon","source","color","size","LegacyIcon","name","Content","Text","typo","Link","bold","Button","colorVariant","styleVariant","leftContent","onClick"],"mappings":";;;;;;;;;;;;;AAuBA,MAAMA,cAAc,GAAG,eAAe;AAEtC,SAASC,2BAA2BA,CAACC,OAAsB,EAAE;EAC3D,OACE;AACEC,IAAAA,OAAO,EAAE,iBAAiB;AAC1BC,IAAAA,IAAI,EAAE,MAAM;AACZC,IAAAA,MAAM,EAAE,QAAQ;AAChBC,IAAAA,KAAK,EAAE,OAAO;AACdC,IAAAA,MAAM,EAAE,QAAQ;AAChBC,IAAAA,GAAG,EAAE,KAAK;AACVC,IAAAA,GAAG,EAAE;GACN,CACDP,OAAO,CAAC;AACZ;AAEA,MAAMQ,oBAAoC,GAAGA,CAAC;EAAEC,OAAO;AAAEC,EAAAA;AAAO,CAAC,kBAC/DC,GAAA,CAAA,GAAA,EAAA;AACEC,EAAAA,IAAI,EAAEF,MAAO;AACbG,EAAAA,MAAM,EAAC,QAAQ;AACfC,EAAAA,GAAG,EAAC,qBAAqB;AAAAC,EAAAA,QAAA,EAExBN;AAAO,CACP,CACJ;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaO,MAAM,gBAAGC,UAAU,CAA8B,SAASD,MAAMA,CAC3E;EACEE,SAAS;AACTlB,EAAAA,OAAO,GAAG,SAAS;EACnBmB,IAAI;EACJC,SAAS;EACTX,OAAO;AACPY,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ;EACRZ,MAAM;AACNa,EAAAA,UAAU,GAAGf,oBAAoB;EACjCgB,UAAU;EACVC,aAAa;EACb,GAAGC;AACL,CAAC,EACDC,YAAY,EACZ;AACA,EAAA,IAAIC,UAAU,CAACT,IAAI,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"Banner.mjs","sources":["../../../../src/components/Banner/Banner.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef } from 'react'\n\nimport { isBezierIcon } from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { warn } from '~/src/utils/assert'\nimport { isNil } from '~/src/utils/type'\n\nimport { Button } from '~/src/components/Button'\nimport { Icon } from '~/src/components/Icon'\nimport { LegacyIcon, isIconName } from '~/src/components/LegacyIcon'\nimport { Text } from '~/src/components/Text'\n\nimport {\n type BannerProps,\n type BannerVariant,\n type RenderLinkFunc,\n} from './Banner.types'\n\nimport styles from './Banner.module.scss'\n\nconst BANNER_TEST_ID = 'bezier-banner'\n\nfunction getActionButtonColorVariant(variant: BannerVariant) {\n return (\n {\n default: 'monochrome-dark',\n blue: 'blue',\n cobalt: 'cobalt',\n green: 'green',\n orange: 'orange',\n red: 'red',\n alt: 'monochrome-dark',\n } as const\n )[variant]\n}\n\nconst externalLinkRenderer: RenderLinkFunc = ({ content, linkTo }) => (\n <a\n href={linkTo}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {content}\n </a>\n)\n\n/**\n * `Banner` is a component you use when you want to communicate instructions, warnings, recommendations, and other information well.\n * @example\n * ```tsx\n * <Banner\n * variant=\"blue\"\n * icon={LightbulbIcon}\n * content=\"Information here.\"\n * />\n * ```\n */\nexport const Banner = forwardRef<HTMLDivElement, BannerProps>(function Banner(\n {\n className,\n variant = 'default',\n icon,\n iconColor,\n content,\n hasLink = false,\n linkText,\n linkTo,\n renderLink = externalLinkRenderer,\n actionIcon,\n onClickAction,\n ...rest\n },\n forwardedRef\n) {\n if (isIconName(icon)) {\n warn(\n 'Deprecation: IconName as a value for the icon property of Banner has been deprecated. Use the Icon of bezier-icons instead.',\n 'Banner.IconName'\n )\n }\n\n return (\n <div\n ref={forwardedRef}\n className={classNames(\n styles.Banner,\n styles[`variant-${variant}`],\n className\n )}\n data-testid={BANNER_TEST_ID}\n {...rest}\n >\n {!isNil(icon) && (\n <div className={styles.Center}>\n {isBezierIcon(icon) ? (\n <Icon\n className={classNames(!iconColor && styles.Icon)}\n source={icon}\n color={iconColor}\n size=\"s\"\n />\n ) : (\n <LegacyIcon\n className={classNames(!iconColor && styles.Icon)}\n name={icon}\n color={iconColor}\n size=\"s\"\n />\n )}\n </div>\n )}\n\n <div className={styles.Content}>\n <Text typo=\"14\">\n {content}\n\n {hasLink &&\n renderLink({\n content: (\n <Text\n className={styles.Link}\n typo=\"14\"\n bold\n >\n {linkText}\n </Text>\n ),\n linkTo,\n })}\n </Text>\n </div>\n\n {!isNil(actionIcon) && (\n <div className={styles.Center}>\n <Button\n size=\"xs\"\n colorVariant={getActionButtonColorVariant(variant)}\n styleVariant=\"tertiary\"\n leftContent={actionIcon}\n onClick={onClickAction}\n />\n </div>\n )}\n </div>\n )\n})\n"],"names":["BANNER_TEST_ID","getActionButtonColorVariant","variant","default","blue","cobalt","green","orange","red","alt","externalLinkRenderer","content","linkTo","_jsx","href","target","rel","children","Banner","forwardRef","className","icon","iconColor","hasLink","linkText","renderLink","actionIcon","onClickAction","rest","forwardedRef","isIconName","warn","_jsxs","ref","classNames","styles","isNil","Center","isBezierIcon","Icon","source","color","size","LegacyIcon","name","Content","Text","typo","Link","bold","Button","colorVariant","styleVariant","leftContent","onClick"],"mappings":";;;;;;;;;;;;;AAuBA,MAAMA,cAAc,GAAG,eAAe;AAEtC,SAASC,2BAA2BA,CAACC,OAAsB,EAAE;EAC3D,OACE;AACEC,IAAAA,OAAO,EAAE,iBAAiB;AAC1BC,IAAAA,IAAI,EAAE,MAAM;AACZC,IAAAA,MAAM,EAAE,QAAQ;AAChBC,IAAAA,KAAK,EAAE,OAAO;AACdC,IAAAA,MAAM,EAAE,QAAQ;AAChBC,IAAAA,GAAG,EAAE,KAAK;AACVC,IAAAA,GAAG,EAAE;GACN,CACDP,OAAO,CAAC;AACZ;AAEA,MAAMQ,oBAAoC,GAAGA,CAAC;EAAEC,OAAO;AAAEC,EAAAA;AAAO,CAAC,kBAC/DC,GAAA,CAAA,GAAA,EAAA;AACEC,EAAAA,IAAI,EAAEF,MAAO;AACbG,EAAAA,MAAM,EAAC,QAAQ;AACfC,EAAAA,GAAG,EAAC,qBAAqB;AA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C,CAACZ,SAAS,IAAIa,MAAM,CAACI,IAAI,CAAE;AACjDK,QAAAA,IAAI,EAAEvB,IAAK;AACXoB,QAAAA,KAAK,EAAEnB,SAAU;AACjBoB,QAAAA,IAAI,EAAC;OACN;KAEA,CACN,eAED7B,GAAA,CAAA,KAAA,EAAA;MAAKO,SAAS,EAAEe,MAAM,CAACU,OAAQ;MAAA5B,QAAA,eAC7Be,IAAA,CAACc,IAAI,EAAA;AAACC,QAAAA,IAAI,EAAC,IAAI;AAAA9B,QAAAA,QAAA,GACZN,OAAO,EAEPY,OAAO,IACNE,UAAU,CAAC;UACTd,OAAO,eACLE,GAAA,CAACiC,IAAI,EAAA;YACH1B,SAAS,EAAEe,MAAM,CAACa,IAAK;AACvBD,YAAAA,IAAI,EAAC,IAAI;YACTE,IAAI,EAAA,IAAA;AAAAhC,YAAAA,QAAA,EAEHO;AAAQ,WACL,CACP;AACDZ,UAAAA;AACF,SAAC,CAAC;OACA;KACH,CAAC,EAEL,CAACwB,KAAK,CAACV,UAAU,CAAC,iBACjBb,GAAA,CAAA,KAAA,EAAA;MAAKO,SAAS,EAAEe,MAAM,CAACE,MAAO;MAAApB,QAAA,eAC5BJ,GAAA,CAACqC,MAAM,EAAA;AACLR,QAAAA,IAAI,EAAC,IAAI;AACTS,QAAAA,YAAY,EAAElD,2BAA2B,CAACC,OAAO,CAAE;AACnDkD,QAAAA,YAAY,EAAC,UAAU;AACvBC,QAAAA,WAAW,EAAE3B,UAAW;AACxB4B,QAAAA,OAAO,EAAE3B;OACV;AAAC,KACC,CACN;AAAA,GACE,CAAC;AAEV,CAAC;;;;"}
|
|
@@ -44,7 +44,7 @@ function ButtonSideContent({
|
|
|
44
44
|
children
|
|
45
45
|
}) {
|
|
46
46
|
if (isIconName(children)) {
|
|
47
|
-
warn('Deprecation: IconName as a value for the leftContent property of a Button has been deprecated. Use the Icon of bezier-icons instead.');
|
|
47
|
+
warn('Deprecation: IconName as a value for the leftContent property of a Button has been deprecated. Use the Icon of bezier-icons instead.', 'Button.IconName');
|
|
48
48
|
return /*#__PURE__*/jsx(LegacyIcon, {
|
|
49
49
|
className: styles.ButtonIcon,
|
|
50
50
|
name: children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.mjs","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, useCallback } from 'react'\n\nimport { isBezierIcon } from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { warn } from '~/src/utils/assert'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { Icon } from '~/src/components/Icon'\nimport { LegacyIcon, isIconName } from '~/src/components/LegacyIcon'\nimport { Spinner } from '~/src/components/Spinner'\nimport { Text } from '~/src/components/Text'\n\nimport type { ButtonProps, ButtonSize, SideContent } from './Button.types'\n\nimport styles from './Button.module.scss'\n\nexport const BUTTON_TEST_ID = 'bezier-button'\n\nfunction getTypography(size: ButtonSize) {\n return (\n {\n xs: '13',\n s: '13',\n m: '14',\n l: '15',\n xl: '18',\n } as const\n )[size]\n}\n\nfunction getIconSize(size: ButtonSize) {\n return (\n {\n xs: 'xs',\n s: 'xs',\n m: 's',\n l: 's',\n xl: 'm',\n } as const\n )[size]\n}\n\nfunction getSpinnerSize(size: ButtonSize) {\n return (\n {\n xs: 'xs',\n s: 'xs',\n m: 's',\n l: 's',\n xl: 's',\n } as const\n )[size]\n}\n\nfunction ButtonSideContent({\n size,\n children,\n}: {\n size: ButtonSize\n children: SideContent\n}) {\n if (isIconName(children)) {\n warn(\n 'Deprecation: IconName as a value for the leftContent property of a Button has been deprecated. Use the Icon of bezier-icons instead.'\n )\n return (\n <LegacyIcon\n className={styles.ButtonIcon}\n name={children}\n size={getIconSize(size)}\n />\n )\n }\n\n if (isBezierIcon(children)) {\n return (\n <Icon\n className={styles.ButtonIcon}\n source={children}\n size={getIconSize(size)}\n />\n )\n }\n\n return <>{children}</>\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n function Button(\n {\n as = BaseButton,\n className,\n text,\n loading = false,\n disabled: disabledProp = false,\n active = false,\n size = 'm',\n styleVariant = 'primary',\n colorVariant = 'blue',\n leftContent,\n rightContent,\n onClick,\n ...rest\n },\n forwardedRef\n ) {\n const Comp = as as typeof BaseButton\n\n const disabled = loading || disabledProp\n\n const handleClick = useCallback<React.MouseEventHandler<HTMLButtonElement>>(\n (event) => {\n if (!disabled) {\n onClick?.(event)\n }\n },\n [onClick, disabled]\n )\n\n return (\n <Comp\n ref={forwardedRef}\n className={classNames(\n styles.Button,\n styles[`size-${size}`],\n styles[`style-${styleVariant}`],\n styles[`color-${colorVariant}`],\n active && styles.active,\n className\n )}\n disabled={disabled}\n onClick={handleClick}\n data-testid={BUTTON_TEST_ID}\n data-bezier-component=\"Button\"\n {...rest}\n >\n <div\n className={classNames(\n styles.ButtonContent,\n loading && styles.loading\n )}\n >\n <ButtonSideContent size={size}>{leftContent}</ButtonSideContent>\n\n {text && (\n <Text\n className={styles.ButtonText}\n typo={getTypography(size)}\n bold\n >\n {text}\n </Text>\n )}\n\n <ButtonSideContent size={size}>{rightContent}</ButtonSideContent>\n </div>\n\n {loading && (\n <div className={styles.ButtonLoader}>\n <Spinner size={getSpinnerSize(size)} />\n </div>\n )}\n </Comp>\n )\n }\n)\n"],"names":["BUTTON_TEST_ID","getTypography","size","xs","s","m","l","xl","getIconSize","getSpinnerSize","ButtonSideContent","children","isIconName","warn","_jsx","LegacyIcon","className","styles","ButtonIcon","name","isBezierIcon","Icon","source","_Fragment","Button","forwardRef","as","BaseButton","text","loading","disabled","disabledProp","active","styleVariant","colorVariant","leftContent","rightContent","onClick","rest","forwardedRef","Comp","handleClick","useCallback","event","_jsxs","ref","classNames","ButtonContent","Text","ButtonText","typo","bold","ButtonLoader","Spinner"],"mappings":";;;;;;;;;;;;;AAmBO,MAAMA,cAAc,GAAG;AAE9B,SAASC,aAAaA,CAACC,IAAgB,EAAE;EACvC,OACE;AACEC,IAAAA,EAAE,EAAE,IAAI;AACRC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,EAAE,EAAE;GACL,CACDL,IAAI,CAAC;AACT;AAEA,SAASM,WAAWA,CAACN,IAAgB,EAAE;EACrC,OACE;AACEC,IAAAA,EAAE,EAAE,IAAI;AACRC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,EAAE,EAAE;GACL,CACDL,IAAI,CAAC;AACT;AAEA,SAASO,cAAcA,CAACP,IAAgB,EAAE;EACxC,OACE;AACEC,IAAAA,EAAE,EAAE,IAAI;AACRC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,EAAE,EAAE;GACL,CACDL,IAAI,CAAC;AACT;AAEA,SAASQ,iBAAiBA,CAAC;EACzBR,IAAI;AACJS,EAAAA;AAIF,CAAC,EAAE;AACD,EAAA,IAAIC,UAAU,CAACD,QAAQ,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"Button.mjs","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, useCallback } from 'react'\n\nimport { isBezierIcon } from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { warn } from '~/src/utils/assert'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { Icon } from '~/src/components/Icon'\nimport { LegacyIcon, isIconName } from '~/src/components/LegacyIcon'\nimport { Spinner } from '~/src/components/Spinner'\nimport { Text } from '~/src/components/Text'\n\nimport type { ButtonProps, ButtonSize, SideContent } from './Button.types'\n\nimport styles from './Button.module.scss'\n\nexport const BUTTON_TEST_ID = 'bezier-button'\n\nfunction getTypography(size: ButtonSize) {\n return (\n {\n xs: '13',\n s: '13',\n m: '14',\n l: '15',\n xl: '18',\n } as const\n )[size]\n}\n\nfunction getIconSize(size: ButtonSize) {\n return (\n {\n xs: 'xs',\n s: 'xs',\n m: 's',\n l: 's',\n xl: 'm',\n } as const\n )[size]\n}\n\nfunction getSpinnerSize(size: ButtonSize) {\n return (\n {\n xs: 'xs',\n s: 'xs',\n m: 's',\n l: 's',\n xl: 's',\n } as const\n )[size]\n}\n\nfunction ButtonSideContent({\n size,\n children,\n}: {\n size: ButtonSize\n children: SideContent\n}) {\n if (isIconName(children)) {\n warn(\n 'Deprecation: IconName as a value for the leftContent property of a Button has been deprecated. Use the Icon of bezier-icons instead.',\n 'Button.IconName'\n )\n return (\n <LegacyIcon\n className={styles.ButtonIcon}\n name={children}\n size={getIconSize(size)}\n />\n )\n }\n\n if (isBezierIcon(children)) {\n return (\n <Icon\n className={styles.ButtonIcon}\n source={children}\n size={getIconSize(size)}\n />\n )\n }\n\n return <>{children}</>\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n function Button(\n {\n as = BaseButton,\n className,\n text,\n loading = false,\n disabled: disabledProp = false,\n active = false,\n size = 'm',\n styleVariant = 'primary',\n colorVariant = 'blue',\n leftContent,\n rightContent,\n onClick,\n ...rest\n },\n forwardedRef\n ) {\n const Comp = as as typeof BaseButton\n\n const disabled = loading || disabledProp\n\n const handleClick = useCallback<React.MouseEventHandler<HTMLButtonElement>>(\n (event) => {\n if (!disabled) {\n onClick?.(event)\n }\n },\n [onClick, disabled]\n )\n\n return (\n <Comp\n ref={forwardedRef}\n className={classNames(\n styles.Button,\n styles[`size-${size}`],\n styles[`style-${styleVariant}`],\n styles[`color-${colorVariant}`],\n active && styles.active,\n className\n )}\n disabled={disabled}\n onClick={handleClick}\n data-testid={BUTTON_TEST_ID}\n data-bezier-component=\"Button\"\n {...rest}\n >\n <div\n className={classNames(\n styles.ButtonContent,\n loading && styles.loading\n )}\n >\n <ButtonSideContent size={size}>{leftContent}</ButtonSideContent>\n\n {text && (\n <Text\n className={styles.ButtonText}\n typo={getTypography(size)}\n bold\n >\n {text}\n </Text>\n )}\n\n <ButtonSideContent size={size}>{rightContent}</ButtonSideContent>\n </div>\n\n {loading && (\n <div className={styles.ButtonLoader}>\n <Spinner size={getSpinnerSize(size)} />\n </div>\n )}\n </Comp>\n )\n }\n)\n"],"names":["BUTTON_TEST_ID","getTypography","size","xs","s","m","l","xl","getIconSize","getSpinnerSize","ButtonSideContent","children","isIconName","warn","_jsx","LegacyIcon","className","styles","ButtonIcon","name","isBezierIcon","Icon","source","_Fragment","Button","forwardRef","as","BaseButton","text","loading","disabled","disabledProp","active","styleVariant","colorVariant","leftContent","rightContent","onClick","rest","forwardedRef","Comp","handleClick","useCallback","event","_jsxs","ref","classNames","ButtonContent","Text","ButtonText","typo","bold","ButtonLoader","Spinner"],"mappings":";;;;;;;;;;;;;AAmBO,MAAMA,cAAc,GAAG;AAE9B,SAASC,aAAaA,CAACC,IAAgB,EAAE;EACvC,OACE;AACEC,IAAAA,EAAE,EAAE,IAAI;AACRC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,EAAE,EAAE;GACL,CACDL,IAAI,CAAC;AACT;AAEA,SAASM,WAAWA,CAACN,IAAgB,EAAE;EACrC,OACE;AACEC,IAAAA,EAAE,EAAE,IAAI;AACRC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,EAAE,EAAE;GACL,CACDL,IAAI,CAAC;AACT;AAEA,SAASO,cAAcA,CAACP,IAAgB,EAAE;EACxC,OACE;AACEC,IAAAA,EAAE,EAAE,IAAI;AACRC,IAAAA,CAAC,EAAE,IAAI;AACPC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,CAAC,EAAE,GAAG;AACNC,IAAAA,EAAE,EAAE;GACL,CACDL,IAAI,CAAC;AACT;AAEA,SAASQ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AAK;AAAAS,QAAAA,QAAA,EAAEyB;AAAY,OAAoB,CAAC;AAAA,KAC9D,CAAC,EAELP,OAAO,iBACNf,GAAA,CAAA,KAAA,EAAA;MAAKE,SAAS,EAAEC,MAAM,CAACmC,YAAa;MAAAzC,QAAA,eAClCG,GAAA,CAACuC,OAAO,EAAA;QAACnD,IAAI,EAAEO,cAAc,CAACP,IAAI;OAAI;AAAC,KACpC,CACN;AAAA,GACG,CAAC;AAEX,CACF;;;;"}
|
|
@@ -23,7 +23,7 @@ function LeftContent({
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
if (isLegacyIcon) {
|
|
26
|
-
warn('Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.');
|
|
26
|
+
warn('Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.', 'SectionLabel.LeftContent.IconName');
|
|
27
27
|
}
|
|
28
28
|
const Comp = isLegacyIcon ? LegacyIcon : Icon;
|
|
29
29
|
return (
|
|
@@ -54,7 +54,7 @@ function RightContent({
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
if (isLegacyIcon) {
|
|
57
|
-
warn('Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.');
|
|
57
|
+
warn('Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.', 'SectionLabel.RightContent.IconName');
|
|
58
58
|
}
|
|
59
59
|
return /*#__PURE__*/jsx(Button, {
|
|
60
60
|
...(withAction ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionLabel.mjs","sources":["../../../../src/components/SectionLabel/SectionLabel.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef } from 'react'\n\nimport { isBezierIcon } from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { warn } from '~/src/utils/assert'\nimport {\n isArray,\n isEmpty,\n isNil,\n isNumber,\n isObject,\n isString,\n} from '~/src/utils/type'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { Button } from '~/src/components/Button'\nimport { Help } from '~/src/components/Help'\nimport { Icon } from '~/src/components/Icon'\nimport { LegacyIcon, isIconName } from '~/src/components/LegacyIcon'\nimport { Text } from '~/src/components/Text'\n\nimport {\n type IconWithAction,\n type SectionLabelLeftContent,\n type SectionLabelProps,\n type SectionLabelRightContent,\n} from './SectionLabel.types'\n\nimport styles from './SectionLabel.module.scss'\n\nfunction LeftContent({ children }: { children: SectionLabelLeftContent }) {\n const isLegacyIcon = isIconName(children)\n\n if (!isBezierIcon(children) && !isLegacyIcon) {\n return <>{children}</>\n }\n\n if (isLegacyIcon) {\n warn(\n 'Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.'\n )\n }\n\n const Comp = isLegacyIcon ? LegacyIcon : Icon\n\n return (\n // @ts-expect-error\n <Comp\n {...(isLegacyIcon\n ? {\n name: children,\n }\n : {\n source: children,\n })}\n size=\"s\"\n color=\"txt-black-dark\"\n />\n )\n}\n\nfunction isIconWithAction(args: unknown): args is IconWithAction {\n return isObject(args) && 'icon' in args\n}\n\nfunction RightContent({ children }: { children: SectionLabelRightContent }) {\n const isLegacyIcon = isIconName(children)\n const withAction = isIconWithAction(children)\n\n if (!isBezierIcon(children) && !isLegacyIcon && !withAction) {\n return <>{children}</>\n }\n\n if (isLegacyIcon) {\n warn(\n 'Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.'\n )\n }\n\n return (\n <Button\n {...(withAction\n ? {\n leftContent: children.icon,\n onClick: children.onClick,\n }\n : {\n as: 'div',\n leftContent: children,\n })}\n className={styles.RightItem}\n size=\"xs\"\n styleVariant=\"tertiary\"\n colorVariant=\"monochrome-light\"\n />\n )\n}\n\nexport const SectionLabel = forwardRef<HTMLElement, SectionLabelProps>(\n function SectionLabel(\n {\n children,\n className,\n open = true,\n help,\n leftContent,\n content,\n rightContent,\n onClick,\n ...props\n },\n forwardedRef\n ) {\n const Comp = !isNil(onClick) ? BaseButton : 'div'\n\n return (\n <>\n <Comp\n // @ts-expect-error\n ref={forwardedRef}\n className={classNames(styles.SectionLabel, className)}\n data-testid=\"bezier-section-label\"\n onClick={onClick}\n {...props}\n >\n {leftContent && (\n <div className={styles.LeftContent}>\n <LeftContent>{leftContent}</LeftContent>\n </div>\n )}\n\n <div className={styles.Content}>\n {isString(content) || isNumber(content) ? (\n <Text\n bold\n typo=\"13\"\n color=\"txt-black-dark\"\n truncated\n >\n {content}\n </Text>\n ) : (\n content\n )}\n </div>\n\n {help && (\n <div className={styles.Help}>\n <Help allowHover>{help}</Help>\n </div>\n )}\n\n {!isNil(rightContent) && !isEmpty(rightContent) && (\n <div className={styles.RightContent}>\n {isArray(rightContent) ? (\n rightContent.map((eachContent, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <RightContent key={index}>{eachContent}</RightContent>\n ))\n ) : (\n <RightContent>{rightContent}</RightContent>\n )}\n </div>\n )}\n </Comp>\n\n {children && open && <div>{children}</div>}\n </>\n )\n }\n)\n"],"names":["LeftContent","children","isLegacyIcon","isIconName","isBezierIcon","_jsx","_Fragment","warn","Comp","LegacyIcon","Icon","name","source","size","color","isIconWithAction","args","isObject","RightContent","withAction","Button","leftContent","icon","onClick","as","className","styles","RightItem","styleVariant","colorVariant","SectionLabel","forwardRef","open","help","content","rightContent","props","forwardedRef","isNil","BaseButton","_jsxs","ref","classNames","Content","isString","isNumber","Text","bold","typo","truncated","Help","allowHover","isEmpty","isArray","map","eachContent","index"],"mappings":";;;;;;;;;;;;;;;AAiCA,SAASA,WAAWA,CAAC;AAAEC,EAAAA;AAAgD,CAAC,EAAE;AACxE,EAAA,MAAMC,YAAY,GAAGC,UAAU,CAACF,QAAQ,CAAC;EAEzC,IAAI,CAACG,YAAY,CAACH,QAAQ,CAAC,IAAI,CAACC,YAAY,EAAE;IAC5C,oBAAOG,GAAA,CAAAC,QAAA,EAAA;AAAAL,MAAAA,QAAA,EAAGA;AAAQ,KAAG,CAAC;AACxB;AAEA,EAAA,IAAIC,YAAY,EAAE;
|
|
1
|
+
{"version":3,"file":"SectionLabel.mjs","sources":["../../../../src/components/SectionLabel/SectionLabel.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef } from 'react'\n\nimport { isBezierIcon } from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { warn } from '~/src/utils/assert'\nimport {\n isArray,\n isEmpty,\n isNil,\n isNumber,\n isObject,\n isString,\n} from '~/src/utils/type'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { Button } from '~/src/components/Button'\nimport { Help } from '~/src/components/Help'\nimport { Icon } from '~/src/components/Icon'\nimport { LegacyIcon, isIconName } from '~/src/components/LegacyIcon'\nimport { Text } from '~/src/components/Text'\n\nimport {\n type IconWithAction,\n type SectionLabelLeftContent,\n type SectionLabelProps,\n type SectionLabelRightContent,\n} from './SectionLabel.types'\n\nimport styles from './SectionLabel.module.scss'\n\nfunction LeftContent({ children }: { children: SectionLabelLeftContent }) {\n const isLegacyIcon = isIconName(children)\n\n if (!isBezierIcon(children) && !isLegacyIcon) {\n return <>{children}</>\n }\n\n if (isLegacyIcon) {\n warn(\n 'Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.',\n 'SectionLabel.LeftContent.IconName'\n )\n }\n\n const Comp = isLegacyIcon ? LegacyIcon : Icon\n\n return (\n // @ts-expect-error\n <Comp\n {...(isLegacyIcon\n ? {\n name: children,\n }\n : {\n source: children,\n })}\n size=\"s\"\n color=\"txt-black-dark\"\n />\n )\n}\n\nfunction isIconWithAction(args: unknown): args is IconWithAction {\n return isObject(args) && 'icon' in args\n}\n\nfunction RightContent({ children }: { children: SectionLabelRightContent }) {\n const isLegacyIcon = isIconName(children)\n const withAction = isIconWithAction(children)\n\n if (!isBezierIcon(children) && !isLegacyIcon && !withAction) {\n return <>{children}</>\n }\n\n if (isLegacyIcon) {\n warn(\n 'Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.',\n 'SectionLabel.RightContent.IconName'\n )\n }\n\n return (\n <Button\n {...(withAction\n ? {\n leftContent: children.icon,\n onClick: children.onClick,\n }\n : {\n as: 'div',\n leftContent: children,\n })}\n className={styles.RightItem}\n size=\"xs\"\n styleVariant=\"tertiary\"\n colorVariant=\"monochrome-light\"\n />\n )\n}\n\nexport const SectionLabel = forwardRef<HTMLElement, SectionLabelProps>(\n function SectionLabel(\n {\n children,\n className,\n open = true,\n help,\n leftContent,\n content,\n rightContent,\n onClick,\n ...props\n },\n forwardedRef\n ) {\n const Comp = !isNil(onClick) ? BaseButton : 'div'\n\n return (\n <>\n <Comp\n // @ts-expect-error\n ref={forwardedRef}\n className={classNames(styles.SectionLabel, className)}\n data-testid=\"bezier-section-label\"\n onClick={onClick}\n {...props}\n >\n {leftContent && (\n <div className={styles.LeftContent}>\n <LeftContent>{leftContent}</LeftContent>\n </div>\n )}\n\n <div className={styles.Content}>\n {isString(content) || isNumber(content) ? (\n <Text\n bold\n typo=\"13\"\n color=\"txt-black-dark\"\n truncated\n >\n {content}\n </Text>\n ) : (\n content\n )}\n </div>\n\n {help && (\n <div className={styles.Help}>\n <Help allowHover>{help}</Help>\n </div>\n )}\n\n {!isNil(rightContent) && !isEmpty(rightContent) && (\n <div className={styles.RightContent}>\n {isArray(rightContent) ? (\n rightContent.map((eachContent, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <RightContent key={index}>{eachContent}</RightContent>\n ))\n ) : (\n <RightContent>{rightContent}</RightContent>\n )}\n </div>\n )}\n </Comp>\n\n {children && open && <div>{children}</div>}\n </>\n )\n }\n)\n"],"names":["LeftContent","children","isLegacyIcon","isIconName","isBezierIcon","_jsx","_Fragment","warn","Comp","LegacyIcon","Icon","name","source","size","color","isIconWithAction","args","isObject","RightContent","withAction","Button","leftContent","icon","onClick","as","className","styles","RightItem","styleVariant","colorVariant","SectionLabel","forwardRef","open","help","content","rightContent","props","forwardedRef","isNil","BaseButton","_jsxs","ref","classNames","Content","isString","isNumber","Text","bold","typo","truncated","Help","allowHover","isEmpty","isArray","map","eachContent","index"],"mappings":";;;;;;;;;;;;;;;AAiCA,SAASA,WAAWA,CAAC;AAAEC,EAAAA;AAAgD,CAAC,EAAE;AACxE,EAAA,MAAMC,YAAY,GAAGC,UAAU,CAACF,QAAQ,CAAC;EAEzC,IAAI,CAACG,YAAY,CAACH,QAAQ,CAAC,IAAI,CAACC,YAAY,EAAE;IAC5C,oBAAOG,GAAA,CAAAC,QAAA,EAAA;AAAAL,MAAAA,QAAA,EAAGA;AAAQ,KAAG,CAAC;AACxB;AAEA,EAAA,IAAIC,YAAY,EAAE;AAChBK,IAAAA,IAAI,CACF,mIAAmI,EACnI,mCACF,CAAC;AACH;AAEA,EAAA,MAAMC,IAAI,GAAGN,YAAY,GAAGO,UAAU,GAAGC,IAAI;AAE7C,EAAA;AAAA;AACE;AACAL,IAAAA,GAAA,CAACG,IAAI,EAAA;AAAA,MAAA,IACEN,YAAY,GACb;AACES,QAAAA,IAAI,EAAEV;AACR,OAAC,GACD;AACEW,QAAAA,MAAM,EAAEX;OACT,CAAA;AACLY,MAAAA,IAAI,EAAC,GAAG;AACRC,MAAAA,KAAK,EAAC;KACP;AAAC;AAEN;AAEA,SAASC,gBAAgBA,CAACC,IAAa,EAA0B;AAC/D,EAAA,OAAOC,QAAQ,CAACD,IAAI,CAAC,IAAI,MAAM,IAAIA,IAAI;AACzC;AAEA,SAASE,YAAYA,CAAC;AAAEjB,EAAAA;AAAiD,CAAC,EAAE;AAC1E,EAAA,MAAMC,YAAY,GAAGC,UAAU,CAACF,QAAQ,CAAC;AACzC,EAAA,MAAMkB,UAAU,GAAGJ,gBAAgB,CAACd,QAAQ,CAAC;EAE7C,IAAI,CAACG,YAAY,CAACH,QAAQ,CAAC,IAAI,CAACC,YAAY,IAAI,CAACiB,UAAU,EAAE;IAC3D,oBAAOd,GAAA,CAAAC,QA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AAA,KAAA,EAAA;AAAAJ,MAAAA,QAAA,EAAMA;AAAQ,KAAM,CAAC;AAAA,GAC1C,CAAC;AAEP,CACF;;;;"}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
function isDev() {
|
|
2
2
|
return process.env.NODE_ENV !== 'production';
|
|
3
3
|
}
|
|
4
|
-
|
|
4
|
+
const devWarningScopes = new Set();
|
|
5
|
+
function warn(message, scope) {
|
|
5
6
|
if (isDev()) {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
if (scope) {
|
|
8
|
+
if (!devWarningScopes.has(scope)) {
|
|
9
|
+
devWarningScopes.add(scope);
|
|
10
|
+
// eslint-disable-next-line no-console
|
|
11
|
+
console.warn(message);
|
|
12
|
+
}
|
|
13
|
+
} else {
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.warn(message);
|
|
16
|
+
}
|
|
8
17
|
}
|
|
9
18
|
}
|
|
10
19
|
class AssertionException extends Error {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.mjs","sources":["../../../src/utils/assert.ts"],"sourcesContent":["export function isDev() {\n return process.env.NODE_ENV !== 'production'\n}\n\nexport function warn(message: string) {\n if (isDev()) {\n // eslint-disable-next-line no-console\n console.warn(message)\n }\n}\n\nexport class AssertionException extends Error {\n constructor(message?: string) {\n super()\n\n this.name = 'AssertionException'\n this.message = message ?? 'assertion failed'\n }\n}\n\nexport function assert(\n predicate: boolean,\n message?: string\n): asserts predicate {\n if (predicate) {\n return\n }\n\n if (isDev()) {\n throw new AssertionException(message)\n }\n}\n"],"names":["isDev","process","env","NODE_ENV","warn","message","console","AssertionException","Error","constructor","name","assert","predicate"],"mappings":"AAAO,SAASA,KAAKA,GAAG;AACtB,EAAA,OAAOC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;AAC9C;
|
|
1
|
+
{"version":3,"file":"assert.mjs","sources":["../../../src/utils/assert.ts"],"sourcesContent":["export function isDev() {\n return process.env.NODE_ENV !== 'production'\n}\n\nconst devWarningScopes = new Set<string>()\n\nexport function warn(message: string): void\nexport function warn(message: string, scope: string): void\nexport function warn(message: string, scope?: string) {\n if (isDev()) {\n if (scope) {\n if (!devWarningScopes.has(scope)) {\n devWarningScopes.add(scope)\n // eslint-disable-next-line no-console\n console.warn(message)\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn(message)\n }\n }\n}\n\nexport class AssertionException extends Error {\n constructor(message?: string) {\n super()\n\n this.name = 'AssertionException'\n this.message = message ?? 'assertion failed'\n }\n}\n\nexport function assert(\n predicate: boolean,\n message?: string\n): asserts predicate {\n if (predicate) {\n return\n }\n\n if (isDev()) {\n throw new AssertionException(message)\n }\n}\n"],"names":["isDev","process","env","NODE_ENV","devWarningScopes","Set","warn","message","scope","has","add","console","AssertionException","Error","constructor","name","assert","predicate"],"mappings":"AAAO,SAASA,KAAKA,GAAG;AACtB,EAAA,OAAOC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;AAC9C;AAEA,MAAMC,gBAAgB,GAAG,IAAIC,GAAG,EAAU;AAInC,SAASC,IAAIA,CAACC,OAAe,EAAEC,KAAc,EAAE;EACpD,IAAIR,KAAK,EAAE,EAAE;AACX,IAAA,IAAIQ,KAAK,EAAE;AACT,MAAA,IAAI,CAACJ,gBAAgB,CAACK,GAAG,CAACD,KAAK,CAAC,EAAE;AAChCJ,QAAAA,gBAAgB,CAACM,GAAG,CAACF,KAAK,CAAC;AAC3B;AACAG,QAAAA,OAAO,CAACL,IAAI,CAACC,OAAO,CAAC;AACvB;AACF,KAAC,MAAM;AACL;AACAI,MAAAA,OAAO,CAACL,IAAI,CAACC,OAAO,CAAC;AACvB;AACF;AACF;AAEO,MAAMK,kBAAkB,SAASC,KAAK,CAAC;EAC5CC,WAAWA,CAACP,OAAgB,EAAE;AAC5B,IAAA,KAAK,EAAE;IAEP,IAAI,CAACQ,IAAI,GAAG,oBAAoB;IAChC,IAAI,CAACR,OAAO,GAAGA,OAAO,aAAPA,OAAO,KAAA,KAAA,CAAA,GAAPA,OAAO,GAAI,kBAAkB;AAC9C;AACF;AAEO,SAASS,MAAMA,CACpBC,SAAkB,EAClBV,OAAgB,EACG;AACnB,EAAA,IAAIU,SAAS,EAAE;AACb,IAAA;AACF;EAEA,IAAIjB,KAAK,EAAE,EAAE;AACX,IAAA,MAAM,IAAIY,kBAAkB,CAACL,OAAO,CAAC;AACvC;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.d.ts","sourceRoot":"","sources":["../../../../src/components/Banner/Banner.tsx"],"names":[],"mappings":"AAeA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,gBAAgB,CAAA;AA8BvB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"Banner.d.ts","sourceRoot":"","sources":["../../../../src/components/Banner/Banner.tsx"],"names":[],"mappings":"AAeA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,gBAAgB,CAAA;AA8BvB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,wGAwFjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,WAAW,EAA2B,MAAM,gBAAgB,CAAA;AAI1E,eAAO,MAAM,cAAc,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,WAAW,EAA2B,MAAM,gBAAgB,CAAA;AAI1E,eAAO,MAAM,cAAc,kBAAkB,CAAA;AAwE7C,eAAO,MAAM,MAAM,2GA8ElB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionLabel.d.ts","sourceRoot":"","sources":["../../../../src/components/SectionLabel/SectionLabel.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"SectionLabel.d.ts","sourceRoot":"","sources":["../../../../src/components/SectionLabel/SectionLabel.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,sBAAsB,CAAA;AA0E7B,eAAO,MAAM,YAAY,2GAwExB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/utils/assert.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,YAEpB;
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/utils/assert.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,YAEpB;AAID,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;AAC3C,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;AAgB1D,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,CAAC,EAAE,MAAM;CAM7B;AAED,wBAAgB,MAAM,CACpB,SAAS,EAAE,OAAO,EAClB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,SAAS,CAQnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@channel.io/bezier-react",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"description": "React components library that implements Bezier design system.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@babel/preset-env": "^7.26.0",
|
|
64
64
|
"@babel/preset-react": "^7.26.3",
|
|
65
65
|
"@babel/preset-typescript": "^7.26.0",
|
|
66
|
-
"@channel.io/bezier-icons": "0.
|
|
66
|
+
"@channel.io/bezier-icons": "0.45.0",
|
|
67
67
|
"@chromatic-com/storybook": "^3.2.2",
|
|
68
68
|
"@figma/code-connect": "^1.2.4",
|
|
69
69
|
"@rollup/plugin-alias": "^5.1.1",
|
|
@@ -77,7 +77,8 @@ export const Banner = forwardRef<HTMLDivElement, BannerProps>(function Banner(
|
|
|
77
77
|
) {
|
|
78
78
|
if (isIconName(icon)) {
|
|
79
79
|
warn(
|
|
80
|
-
'Deprecation: IconName as a value for the icon property of Banner has been deprecated. Use the Icon of bezier-icons instead.'
|
|
80
|
+
'Deprecation: IconName as a value for the icon property of Banner has been deprecated. Use the Icon of bezier-icons instead.',
|
|
81
|
+
'Banner.IconName'
|
|
81
82
|
)
|
|
82
83
|
}
|
|
83
84
|
|
|
@@ -64,7 +64,8 @@ function ButtonSideContent({
|
|
|
64
64
|
}) {
|
|
65
65
|
if (isIconName(children)) {
|
|
66
66
|
warn(
|
|
67
|
-
'Deprecation: IconName as a value for the leftContent property of a Button has been deprecated. Use the Icon of bezier-icons instead.'
|
|
67
|
+
'Deprecation: IconName as a value for the leftContent property of a Button has been deprecated. Use the Icon of bezier-icons instead.',
|
|
68
|
+
'Button.IconName'
|
|
68
69
|
)
|
|
69
70
|
return (
|
|
70
71
|
<LegacyIcon
|
|
@@ -40,7 +40,8 @@ function LeftContent({ children }: { children: SectionLabelLeftContent }) {
|
|
|
40
40
|
|
|
41
41
|
if (isLegacyIcon) {
|
|
42
42
|
warn(
|
|
43
|
-
'Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.'
|
|
43
|
+
'Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.',
|
|
44
|
+
'SectionLabel.LeftContent.IconName'
|
|
44
45
|
)
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -76,7 +77,8 @@ function RightContent({ children }: { children: SectionLabelRightContent }) {
|
|
|
76
77
|
|
|
77
78
|
if (isLegacyIcon) {
|
|
78
79
|
warn(
|
|
79
|
-
'Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.'
|
|
80
|
+
'Deprecation: IconName as a value for the icon property of SectionLabel has been deprecated. Use the Icon of bezier-icons instead.',
|
|
81
|
+
'SectionLabel.RightContent.IconName'
|
|
80
82
|
)
|
|
81
83
|
}
|
|
82
84
|
|
package/src/utils/assert.test.ts
CHANGED
|
@@ -86,4 +86,47 @@ describe('warn', () => {
|
|
|
86
86
|
|
|
87
87
|
warnSpy.mockRestore()
|
|
88
88
|
})
|
|
89
|
+
|
|
90
|
+
it('should output the message only once per scope when scope is provided', () => {
|
|
91
|
+
process.env.NODE_ENV = 'development'
|
|
92
|
+
|
|
93
|
+
const warnSpy = jest.spyOn(console, 'warn')
|
|
94
|
+
|
|
95
|
+
warn('Warning message', 'test-scope')
|
|
96
|
+
warn('Warning message', 'test-scope')
|
|
97
|
+
warn('Warning message', 'test-scope')
|
|
98
|
+
|
|
99
|
+
expect(warnSpy).toHaveBeenCalledTimes(1)
|
|
100
|
+
expect(warnSpy).toHaveBeenCalledWith('Warning message')
|
|
101
|
+
|
|
102
|
+
warnSpy.mockRestore()
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('should output different messages for different scopes', () => {
|
|
106
|
+
process.env.NODE_ENV = 'development'
|
|
107
|
+
|
|
108
|
+
const warnSpy = jest.spyOn(console, 'warn')
|
|
109
|
+
|
|
110
|
+
warn('Warning message 1', 'scope-1')
|
|
111
|
+
warn('Warning message 2', 'scope-2')
|
|
112
|
+
warn('Warning message 1', 'scope-1') // Should not be called again
|
|
113
|
+
|
|
114
|
+
expect(warnSpy).toHaveBeenCalledTimes(2)
|
|
115
|
+
expect(warnSpy).toHaveBeenNthCalledWith(1, 'Warning message 1')
|
|
116
|
+
expect(warnSpy).toHaveBeenNthCalledWith(2, 'Warning message 2')
|
|
117
|
+
|
|
118
|
+
warnSpy.mockRestore()
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('should not output warning in production environment even with scope', () => {
|
|
122
|
+
process.env.NODE_ENV = 'production'
|
|
123
|
+
|
|
124
|
+
const warnSpy = jest.spyOn(console, 'warn')
|
|
125
|
+
|
|
126
|
+
warn('Warning message', 'test-scope')
|
|
127
|
+
|
|
128
|
+
expect(warnSpy).not.toHaveBeenCalled()
|
|
129
|
+
|
|
130
|
+
warnSpy.mockRestore()
|
|
131
|
+
})
|
|
89
132
|
})
|
package/src/utils/assert.ts
CHANGED
|
@@ -2,10 +2,22 @@ export function isDev() {
|
|
|
2
2
|
return process.env.NODE_ENV !== 'production'
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const devWarningScopes = new Set<string>()
|
|
6
|
+
|
|
7
|
+
export function warn(message: string): void
|
|
8
|
+
export function warn(message: string, scope: string): void
|
|
9
|
+
export function warn(message: string, scope?: string) {
|
|
6
10
|
if (isDev()) {
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
if (scope) {
|
|
12
|
+
if (!devWarningScopes.has(scope)) {
|
|
13
|
+
devWarningScopes.add(scope)
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.warn(message)
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.warn(message)
|
|
20
|
+
}
|
|
9
21
|
}
|
|
10
22
|
}
|
|
11
23
|
|