@channel.io/bezier-react 3.1.4 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/components/Select/Select.js +23 -8
- package/dist/cjs/components/Select/Select.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/components/Select/Select.mjs +23 -8
- package/dist/esm/components/Select/Select.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/components/Select/Select.d.ts.map +1 -1
- package/dist/types/components/Select/Select.types.d.ts +2 -1
- package/dist/types/components/Select/Select.types.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/components/Select/Select.tsx +31 -8
- package/src/components/Select/Select.types.ts +3 -1
- 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;;A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,IAAI,CAAE;AACjDK,QAAAA,IAAI,EAAEvB,IAAK;AACXoB,QAAAA,KAAK,EAAEnB,SAAU;AACjBoB,QAAAA,IAAI,EAAC;OACN;KAEA,CACN,eAED7B,cAAA,CAAA,KAAA,EAAA;MAAKO,SAAS,EAAEe,qBAAM,CAACU,OAAQ;MAAA5B,QAAA,eAC7Be,eAAA,CAACc,SAAI,EAAA;AAACC,QAAAA,IAAI,EAAC,IAAI;AAAA9B,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,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AACR,QAAAA,IAAI,EAAEA,IAAK;AAAAS,QAAAA,QAAA,EAAEyB;AAAY,OAAoB,CAAC;AAAA,KAC9D,CAAC,EAELP,OAAO,iBACNf,cAAA,CAAA,KAAA,EAAA;MAAKE,SAAS,EAAEC,qBAAM,CAACmC,YAAa;MAAAzC,QAAA,eAClCG,cAAA,CAACuC,eAAO,EAAA;QAACnD,IAAI,EAAEO,cAAc,CAACP,IAAI;OAAI;AAAC,KACpC,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,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;AAChBK,IAAAA,WAAI,CACF,mIAAmI,EACnI,mCACF,CAAC;AACH;AAEA,EAAA,MAAMC,IAAI,GAAGN,YAAY,GAAGO,qBAAU,GAAGC,SAAI;AAE7C,EAAA;AAAA;AACE;AACAL,IAAAA,cAAA,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,aAAQ,CAACD,IAAI,CAAC,IAAI,MAAM,IAAIA,IAAI;AACzC;AAEA,SAASE,YAAYA,CAAC;AAAEjB,EAAAA;AAAiD,CAAC,EAAE;AAC1E,EAAA,MAAMC,YAAY,GAAGC,gBAAU,CAACF,QAAQ,CAAC;AACzC,EAAA,MAAMkB,UAAU,GAAGJ,gBAAgB,CAACd,QAAQ,CAAC;EAE7C,IAAI,CAACG,wBAAY,CAACH,QAAQ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AAEkC;SAA2B;AAC3C,OACE,CACN;AAAA,KACG,CAAC,EAENlC,QAAQ,IAAI+B,IAAI,iBAAI3B,cAAA,CAAA,KAAA,EAAA;AAAAJ,MAAAA,QAAA,EAAMA;AAAQ,KAAM,CAAC;AAAA,GAC1C,CAAC;AAEP,CACF;;;;"}
|
|
@@ -10,8 +10,8 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
10
10
|
var FormControl = require('../FormControl/FormControl.js');
|
|
11
11
|
var BaseButton = require('../BaseButton/BaseButton.js');
|
|
12
12
|
var Icon = require('../Icon/Icon.js');
|
|
13
|
-
var Text = require('../Text/Text.js');
|
|
14
13
|
var Overlay = require('../Overlay/Overlay.js');
|
|
14
|
+
var Text = require('../Text/Text.js');
|
|
15
15
|
|
|
16
16
|
const SELECT_DROPDOWN_TEST_ID = 'bezier-select-dropdown';
|
|
17
17
|
const Select = /*#__PURE__*/React.forwardRef(function Select({
|
|
@@ -74,6 +74,27 @@ const Select = /*#__PURE__*/React.forwardRef(function Select({
|
|
|
74
74
|
}, [defaultFocus, disabled, readOnly]);
|
|
75
75
|
React.useImperativeHandle(forwardedRef, () => handle);
|
|
76
76
|
const hasContent = !type.isEmpty(text);
|
|
77
|
+
const Content = (() => {
|
|
78
|
+
if (!hasContent) {
|
|
79
|
+
return /*#__PURE__*/jsxRuntime.jsx(Text.Text, {
|
|
80
|
+
"data-testid": "bezier-select-trigger-text",
|
|
81
|
+
typo: "14",
|
|
82
|
+
truncated: true,
|
|
83
|
+
color: "txt-black-dark",
|
|
84
|
+
children: placeholder
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (typeof text === 'string') {
|
|
88
|
+
return /*#__PURE__*/jsxRuntime.jsx(Text.Text, {
|
|
89
|
+
"data-testid": "bezier-select-trigger-text",
|
|
90
|
+
typo: "14",
|
|
91
|
+
truncated: true,
|
|
92
|
+
color: textColor,
|
|
93
|
+
children: text
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return text;
|
|
97
|
+
})();
|
|
77
98
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
78
99
|
style: style,
|
|
79
100
|
className: index.default(Select_module.default.SelectContainer, className),
|
|
@@ -91,13 +112,7 @@ const Select = /*#__PURE__*/React.forwardRef(function Select({
|
|
|
91
112
|
size: "xs",
|
|
92
113
|
marginRight: 6,
|
|
93
114
|
color: iconColor
|
|
94
|
-
}) : leftContent, /*#__PURE__*/jsxRuntime.jsx(
|
|
95
|
-
"data-testid": "bezier-select-trigger-text",
|
|
96
|
-
typo: "14",
|
|
97
|
-
truncated: true,
|
|
98
|
-
color: hasContent ? textColor : 'txt-black-dark',
|
|
99
|
-
children: hasContent ? text : placeholder
|
|
100
|
-
}), bezierIcons.isBezierIcon(rightContent) ? /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
|
|
115
|
+
}) : leftContent, Content, bezierIcons.isBezierIcon(rightContent) ? /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
|
|
101
116
|
source: rightContent,
|
|
102
117
|
size: "xs",
|
|
103
118
|
marginRight: 6,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../../../src/components/Select/Select.tsx"],"sourcesContent":["'use client'\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport * as React from 'react'\n\nimport {\n ChevronDownIcon,\n ChevronUpIcon,\n isBezierIcon,\n} from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { getFormFieldSizeClassName } from '~/src/types/props-helpers'\nimport { isEmpty } from '~/src/utils/type'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { useFormFieldProps } from '~/src/components/FormControl'\nimport { Icon } from '~/src/components/Icon'\nimport { Overlay } from '~/src/components/Overlay'\nimport { Text } from '~/src/components/Text'\n\nimport { type SelectProps, type SelectRef } from './Select.types'\n\nimport styles from './Select.module.scss'\n\nexport const SELECT_DROPDOWN_TEST_ID = 'bezier-select-dropdown'\n\nexport const Select = forwardRef<SelectRef, SelectProps>(function Select(\n {\n children,\n style,\n className,\n size: sizeProps,\n defaultFocus = false,\n placeholder = '',\n leftContent,\n rightContent,\n iconColor = 'txt-black-dark',\n text,\n textColor = 'txt-black-darkest',\n withoutChevron = false,\n dropdownStyle,\n dropdownClassName,\n dropdownContainer,\n dropdownMarginX,\n dropdownMarginY = 6,\n dropdownZIndex = 'overlay',\n dropdownPosition = 'bottom-left',\n dropdownKeepInContainer = false,\n onClickTrigger,\n onHideDropdown,\n ...rest\n },\n forwardedRef\n) {\n const {\n disabled,\n readOnly,\n hasError,\n size: formFieldSize,\n ...ownProps\n } = useFormFieldProps(rest)\n\n const containerRef = useRef<HTMLDivElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n\n const size = sizeProps ?? formFieldSize ?? 'm'\n\n const [isDropdownOpened, setIsDropdownOpened] = useState(false)\n\n const handleClickTrigger = useCallback(\n (event: React.MouseEvent) => {\n if (!disabled && !readOnly) {\n setIsDropdownOpened((prevState) => !prevState)\n onClickTrigger?.(event)\n }\n },\n [disabled, readOnly, onClickTrigger]\n )\n\n const handleHideDropdown = useCallback(() => {\n setIsDropdownOpened(false)\n onHideDropdown?.()\n }, [onHideDropdown])\n\n const getDOMNode = useCallback(() => triggerRef.current, [])\n\n const handle = useMemo(\n (): SelectRef => ({\n handleClickTrigger,\n handleHideDropdown,\n getDOMNode,\n }),\n [handleClickTrigger, handleHideDropdown, getDOMNode]\n )\n\n useEffect(\n function handleDefaultFocus() {\n if (defaultFocus && !disabled && !readOnly) {\n setIsDropdownOpened(true)\n }\n },\n [defaultFocus, disabled, readOnly]\n )\n\n useImperativeHandle(forwardedRef, () => handle)\n\n const hasContent = !isEmpty(text)\n\n return (\n <div\n style={style}\n className={classNames(styles.SelectContainer, className)}\n ref={containerRef}\n >\n <BaseButton\n className={classNames(\n styles.SelectTrigger,\n getFormFieldSizeClassName(size),\n hasError && styles.invalid,\n readOnly && styles.readonly,\n isDropdownOpened && styles.active\n )}\n ref={triggerRef}\n disabled={disabled}\n onClick={handleClickTrigger}\n {...ownProps}\n >\n <div className={styles.SelectMainContent}>\n {isBezierIcon(leftContent) ? (\n <Icon\n source={leftContent}\n size=\"xs\"\n marginRight={6}\n color={iconColor}\n />\n ) : (\n leftContent\n )}\n\n <Text\n data-testid=\"bezier-select-trigger-text\"\n typo=\"14\"\n truncated\n color={hasContent ? textColor : 'txt-black-dark'}\n >\n {hasContent ? text : placeholder}\n </Text>\n\n {isBezierIcon(rightContent) ? (\n <Icon\n source={rightContent}\n size=\"xs\"\n marginRight={6}\n color={iconColor}\n />\n ) : (\n rightContent\n )}\n </div>\n\n {!withoutChevron && (\n <Icon\n source={isDropdownOpened ? ChevronUpIcon : ChevronDownIcon}\n size=\"xs\"\n color={readOnly ? 'txt-black-dark' : 'txt-black-darker'}\n marginLeft={6}\n />\n )}\n </BaseButton>\n\n <Overlay\n zIndex={dropdownZIndex}\n style={dropdownStyle}\n className={classNames(styles.SelectDropdown, dropdownClassName)}\n withTransition\n show={isDropdownOpened && !disabled}\n marginX={dropdownMarginX}\n marginY={dropdownMarginY}\n target={triggerRef.current}\n container={dropdownContainer || containerRef.current}\n position={dropdownPosition}\n keepInContainer={dropdownKeepInContainer}\n data-testid={SELECT_DROPDOWN_TEST_ID}\n onHide={handleHideDropdown}\n >\n {children}\n </Overlay>\n </div>\n )\n})\n"],"names":["SELECT_DROPDOWN_TEST_ID","Select","forwardRef","children","style","className","size","sizeProps","defaultFocus","placeholder","leftContent","rightContent","iconColor","text","textColor","withoutChevron","dropdownStyle","dropdownClassName","dropdownContainer","dropdownMarginX","dropdownMarginY","dropdownZIndex","dropdownPosition","dropdownKeepInContainer","onClickTrigger","onHideDropdown","rest","forwardedRef","_ref","disabled","readOnly","hasError","formFieldSize","ownProps","useFormFieldProps","containerRef","useRef","triggerRef","isDropdownOpened","setIsDropdownOpened","useState","handleClickTrigger","useCallback","event","prevState","handleHideDropdown","getDOMNode","current","handle","useMemo","useEffect","handleDefaultFocus","useImperativeHandle","hasContent","isEmpty","_jsxs","classNames","styles","SelectContainer","ref","BaseButton","SelectTrigger","getFormFieldSizeClassName","invalid","readonly","active","onClick","SelectMainContent","isBezierIcon","_jsx","Icon","source","marginRight","color","Text","typo","truncated","ChevronUpIcon","ChevronDownIcon","marginLeft","Overlay","zIndex","SelectDropdown","withTransition","show","marginX","marginY","target","container","position","keepInContainer","onHide"],"mappings":";;;;;;;;;;;;;;;AAiCO,MAAMA,uBAAuB,GAAG;MAE1BC,MAAM,gBAAGC,gBAAU,CAAyB,SAASD,MAAMA,CACtE;EACEE,QAAQ;EACRC,KAAK;EACLC,SAAS;AACTC,EAAAA,IAAI,EAAEC,SAAS;AACfC,EAAAA,YAAY,GAAG,KAAK;AACpBC,EAAAA,WAAW,GAAG,EAAE;EAChBC,WAAW;EACXC,YAAY;AACZC,EAAAA,SAAS,GAAG,gBAAgB;EAC5BC,IAAI;AACJC,EAAAA,SAAS,GAAG,mBAAmB;AAC/BC,EAAAA,cAAc,GAAG,KAAK;EACtBC,aAAa;EACbC,iBAAiB;EACjBC,iBAAiB;EACjBC,eAAe;AACfC,EAAAA,eAAe,GAAG,CAAC;AACnBC,EAAAA,cAAc,GAAG,SAAS;AAC1BC,EAAAA,gBAAgB,GAAG,aAAa;AAChCC,EAAAA,uBAAuB,GAAG,KAAK;EAC/BC,cAAc;EACdC,cAAc;EACd,GAAGC;AACL,CAAC,EACDC,YAAY,EACZ;AAAA,EAAA,IAAAC,IAAA;EACA,MAAM;IACJC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;AACRzB,IAAAA,IAAI,EAAE0B,aAAa;IACnB,GAAGC;AACL,GAAC,GAAGC,6BAAiB,CAACR,IAAI,CAAC;AAE3B,EAAA,MAAMS,YAAY,GAAGC,YAAM,CAAiB,IAAI,CAAC;AACjD,EAAA,MAAMC,UAAU,GAAGD,YAAM,CAAoB,IAAI,CAAC;AAElD,EAAA,M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,EAAavB,uBAAwB;AACrC2F,MAAAA,MAAM,EAAE9C,kBAAmB;AAAA1C,MAAAA,QAAA,EAE1BA;AAAQ,KACF,CAAC;AAAA,GACP,CAAC;AAEV,CAAC;;;;;"}
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../../src/components/Select/Select.tsx"],"sourcesContent":["'use client'\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport * as React from 'react'\n\nimport {\n ChevronDownIcon,\n ChevronUpIcon,\n isBezierIcon,\n} from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { getFormFieldSizeClassName } from '~/src/types/props-helpers'\nimport { isEmpty } from '~/src/utils/type'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { useFormFieldProps } from '~/src/components/FormControl'\nimport { Icon } from '~/src/components/Icon'\nimport { Overlay } from '~/src/components/Overlay'\nimport { Text } from '~/src/components/Text'\n\nimport { type SelectProps, type SelectRef } from './Select.types'\n\nimport styles from './Select.module.scss'\n\nexport const SELECT_DROPDOWN_TEST_ID = 'bezier-select-dropdown'\n\nexport const Select = forwardRef<SelectRef, SelectProps>(function Select(\n {\n children,\n style,\n className,\n size: sizeProps,\n defaultFocus = false,\n placeholder = '',\n leftContent,\n rightContent,\n iconColor = 'txt-black-dark',\n text,\n textColor = 'txt-black-darkest',\n withoutChevron = false,\n dropdownStyle,\n dropdownClassName,\n dropdownContainer,\n dropdownMarginX,\n dropdownMarginY = 6,\n dropdownZIndex = 'overlay',\n dropdownPosition = 'bottom-left',\n dropdownKeepInContainer = false,\n onClickTrigger,\n onHideDropdown,\n ...rest\n },\n forwardedRef\n) {\n const {\n disabled,\n readOnly,\n hasError,\n size: formFieldSize,\n ...ownProps\n } = useFormFieldProps(rest)\n\n const containerRef = useRef<HTMLDivElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n\n const size = sizeProps ?? formFieldSize ?? 'm'\n\n const [isDropdownOpened, setIsDropdownOpened] = useState(false)\n\n const handleClickTrigger = useCallback(\n (event: React.MouseEvent) => {\n if (!disabled && !readOnly) {\n setIsDropdownOpened((prevState) => !prevState)\n onClickTrigger?.(event)\n }\n },\n [disabled, readOnly, onClickTrigger]\n )\n\n const handleHideDropdown = useCallback(() => {\n setIsDropdownOpened(false)\n onHideDropdown?.()\n }, [onHideDropdown])\n\n const getDOMNode = useCallback(() => triggerRef.current, [])\n\n const handle = useMemo(\n (): SelectRef => ({\n handleClickTrigger,\n handleHideDropdown,\n getDOMNode,\n }),\n [handleClickTrigger, handleHideDropdown, getDOMNode]\n )\n\n useEffect(\n function handleDefaultFocus() {\n if (defaultFocus && !disabled && !readOnly) {\n setIsDropdownOpened(true)\n }\n },\n [defaultFocus, disabled, readOnly]\n )\n\n useImperativeHandle(forwardedRef, () => handle)\n\n const hasContent = !isEmpty(text)\n\n const Content = (() => {\n if (!hasContent) {\n return (\n <Text\n data-testid=\"bezier-select-trigger-text\"\n typo=\"14\"\n truncated\n color=\"txt-black-dark\"\n >\n {placeholder}\n </Text>\n )\n }\n\n if (typeof text === 'string') {\n return (\n <Text\n data-testid=\"bezier-select-trigger-text\"\n typo=\"14\"\n truncated\n color={textColor}\n >\n {text}\n </Text>\n )\n }\n\n return text\n })()\n\n return (\n <div\n style={style}\n className={classNames(styles.SelectContainer, className)}\n ref={containerRef}\n >\n <BaseButton\n className={classNames(\n styles.SelectTrigger,\n getFormFieldSizeClassName(size),\n hasError && styles.invalid,\n readOnly && styles.readonly,\n isDropdownOpened && styles.active\n )}\n ref={triggerRef}\n disabled={disabled}\n onClick={handleClickTrigger}\n {...ownProps}\n >\n <div className={styles.SelectMainContent}>\n {isBezierIcon(leftContent) ? (\n <Icon\n source={leftContent}\n size=\"xs\"\n marginRight={6}\n color={iconColor}\n />\n ) : (\n leftContent\n )}\n\n {Content}\n\n {isBezierIcon(rightContent) ? (\n <Icon\n source={rightContent}\n size=\"xs\"\n marginRight={6}\n color={iconColor}\n />\n ) : (\n rightContent\n )}\n </div>\n\n {!withoutChevron && (\n <Icon\n source={isDropdownOpened ? ChevronUpIcon : ChevronDownIcon}\n size=\"xs\"\n color={readOnly ? 'txt-black-dark' : 'txt-black-darker'}\n marginLeft={6}\n />\n )}\n </BaseButton>\n\n <Overlay\n zIndex={dropdownZIndex}\n style={dropdownStyle}\n className={classNames(styles.SelectDropdown, dropdownClassName)}\n withTransition\n show={isDropdownOpened && !disabled}\n marginX={dropdownMarginX}\n marginY={dropdownMarginY}\n target={triggerRef.current}\n container={dropdownContainer || containerRef.current}\n position={dropdownPosition}\n keepInContainer={dropdownKeepInContainer}\n data-testid={SELECT_DROPDOWN_TEST_ID}\n onHide={handleHideDropdown}\n >\n {children}\n </Overlay>\n </div>\n )\n})\n"],"names":["SELECT_DROPDOWN_TEST_ID","Select","forwardRef","children","style","className","size","sizeProps","defaultFocus","placeholder","leftContent","rightContent","iconColor","text","textColor","withoutChevron","dropdownStyle","dropdownClassName","dropdownContainer","dropdownMarginX","dropdownMarginY","dropdownZIndex","dropdownPosition","dropdownKeepInContainer","onClickTrigger","onHideDropdown","rest","forwardedRef","_ref","disabled","readOnly","hasError","formFieldSize","ownProps","useFormFieldProps","containerRef","useRef","triggerRef","isDropdownOpened","setIsDropdownOpened","useState","handleClickTrigger","useCallback","event","prevState","handleHideDropdown","getDOMNode","current","handle","useMemo","useEffect","handleDefaultFocus","useImperativeHandle","hasContent","isEmpty","Content","_jsx","Text","typo","truncated","color","_jsxs","classNames","styles","SelectContainer","ref","BaseButton","SelectTrigger","getFormFieldSizeClassName","invalid","readonly","active","onClick","SelectMainContent","isBezierIcon","Icon","source","marginRight","ChevronUpIcon","ChevronDownIcon","marginLeft","Overlay","zIndex","SelectDropdown","withTransition","show","marginX","marginY","target","container","position","keepInContainer","onHide"],"mappings":";;;;;;;;;;;;;;;AAiCO,MAAMA,uBAAuB,GAAG;MAE1BC,MAAM,gBAAGC,gBAAU,CAAyB,SAASD,MAAMA,CACtE;EACEE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/C,kBAAmB;AAAA1C,MAAAA,QAAA,EAE1BA;AAAQ,KACF,CAAC;AAAA,GACP,CAAC;AAEV,CAAC;;;;;"}
|
package/dist/cjs/utils/assert.js
CHANGED
|
@@ -3,10 +3,19 @@
|
|
|
3
3
|
function isDev() {
|
|
4
4
|
return process.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,G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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;AACE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7BC,QAAAA,IAAI,EAAEjD,aAAa,CAACC,IAAI,CAAE;QAC1BiD,IAAI,EAAA,IAAA;AAAAxC,QAAAA,QAAA,EAEHiB;AAAI,OACD,CACP,eAEDd,GAAA,CAACJ,iBAAiB,EAAA;AAACR,QAAAA,IAAI,EAAEA,IAAK;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,C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W,SAAA,EAAnBC,KAAkC,CACtD,CAAC,gBAEFnD,GAAA,CAACa,YAAY,EAAA;AAAAjB,UAAAA,QAAA,EAAEkC;SAA2B;AAC3C,OACE,CACN;AAAA,KACG,CAAC,EAENlC,QAAQ,IAAI+B,IAAI,iBAAI3B,GAAA,CAAA,KAAA,EAAA;AAAAJ,MAAAA,QAAA,EAAMA;AAAQ,KAAM,CAAC;AAAA,GAC1C,CAAC;AAEP,CACF;;;;"}
|
|
@@ -8,8 +8,8 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
8
8
|
import { useFormFieldProps } from '../FormControl/FormControl.mjs';
|
|
9
9
|
import { BaseButton } from '../BaseButton/BaseButton.mjs';
|
|
10
10
|
import { Icon } from '../Icon/Icon.mjs';
|
|
11
|
-
import { Text } from '../Text/Text.mjs';
|
|
12
11
|
import { Overlay } from '../Overlay/Overlay.mjs';
|
|
12
|
+
import { Text } from '../Text/Text.mjs';
|
|
13
13
|
|
|
14
14
|
const SELECT_DROPDOWN_TEST_ID = 'bezier-select-dropdown';
|
|
15
15
|
const Select = /*#__PURE__*/forwardRef(function Select({
|
|
@@ -72,6 +72,27 @@ const Select = /*#__PURE__*/forwardRef(function Select({
|
|
|
72
72
|
}, [defaultFocus, disabled, readOnly]);
|
|
73
73
|
useImperativeHandle(forwardedRef, () => handle);
|
|
74
74
|
const hasContent = !isEmpty(text);
|
|
75
|
+
const Content = (() => {
|
|
76
|
+
if (!hasContent) {
|
|
77
|
+
return /*#__PURE__*/jsx(Text, {
|
|
78
|
+
"data-testid": "bezier-select-trigger-text",
|
|
79
|
+
typo: "14",
|
|
80
|
+
truncated: true,
|
|
81
|
+
color: "txt-black-dark",
|
|
82
|
+
children: placeholder
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (typeof text === 'string') {
|
|
86
|
+
return /*#__PURE__*/jsx(Text, {
|
|
87
|
+
"data-testid": "bezier-select-trigger-text",
|
|
88
|
+
typo: "14",
|
|
89
|
+
truncated: true,
|
|
90
|
+
color: textColor,
|
|
91
|
+
children: text
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return text;
|
|
95
|
+
})();
|
|
75
96
|
return /*#__PURE__*/jsxs("div", {
|
|
76
97
|
style: style,
|
|
77
98
|
className: classNames(styles.SelectContainer, className),
|
|
@@ -89,13 +110,7 @@ const Select = /*#__PURE__*/forwardRef(function Select({
|
|
|
89
110
|
size: "xs",
|
|
90
111
|
marginRight: 6,
|
|
91
112
|
color: iconColor
|
|
92
|
-
}) : leftContent, /*#__PURE__*/jsx(
|
|
93
|
-
"data-testid": "bezier-select-trigger-text",
|
|
94
|
-
typo: "14",
|
|
95
|
-
truncated: true,
|
|
96
|
-
color: hasContent ? textColor : 'txt-black-dark',
|
|
97
|
-
children: hasContent ? text : placeholder
|
|
98
|
-
}), isBezierIcon(rightContent) ? /*#__PURE__*/jsx(Icon, {
|
|
113
|
+
}) : leftContent, Content, isBezierIcon(rightContent) ? /*#__PURE__*/jsx(Icon, {
|
|
99
114
|
source: rightContent,
|
|
100
115
|
size: "xs",
|
|
101
116
|
marginRight: 6,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.mjs","sources":["../../../../src/components/Select/Select.tsx"],"sourcesContent":["'use client'\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport * as React from 'react'\n\nimport {\n ChevronDownIcon,\n ChevronUpIcon,\n isBezierIcon,\n} from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { getFormFieldSizeClassName } from '~/src/types/props-helpers'\nimport { isEmpty } from '~/src/utils/type'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { useFormFieldProps } from '~/src/components/FormControl'\nimport { Icon } from '~/src/components/Icon'\nimport { Overlay } from '~/src/components/Overlay'\nimport { Text } from '~/src/components/Text'\n\nimport { type SelectProps, type SelectRef } from './Select.types'\n\nimport styles from './Select.module.scss'\n\nexport const SELECT_DROPDOWN_TEST_ID = 'bezier-select-dropdown'\n\nexport const Select = forwardRef<SelectRef, SelectProps>(function Select(\n {\n children,\n style,\n className,\n size: sizeProps,\n defaultFocus = false,\n placeholder = '',\n leftContent,\n rightContent,\n iconColor = 'txt-black-dark',\n text,\n textColor = 'txt-black-darkest',\n withoutChevron = false,\n dropdownStyle,\n dropdownClassName,\n dropdownContainer,\n dropdownMarginX,\n dropdownMarginY = 6,\n dropdownZIndex = 'overlay',\n dropdownPosition = 'bottom-left',\n dropdownKeepInContainer = false,\n onClickTrigger,\n onHideDropdown,\n ...rest\n },\n forwardedRef\n) {\n const {\n disabled,\n readOnly,\n hasError,\n size: formFieldSize,\n ...ownProps\n } = useFormFieldProps(rest)\n\n const containerRef = useRef<HTMLDivElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n\n const size = sizeProps ?? formFieldSize ?? 'm'\n\n const [isDropdownOpened, setIsDropdownOpened] = useState(false)\n\n const handleClickTrigger = useCallback(\n (event: React.MouseEvent) => {\n if (!disabled && !readOnly) {\n setIsDropdownOpened((prevState) => !prevState)\n onClickTrigger?.(event)\n }\n },\n [disabled, readOnly, onClickTrigger]\n )\n\n const handleHideDropdown = useCallback(() => {\n setIsDropdownOpened(false)\n onHideDropdown?.()\n }, [onHideDropdown])\n\n const getDOMNode = useCallback(() => triggerRef.current, [])\n\n const handle = useMemo(\n (): SelectRef => ({\n handleClickTrigger,\n handleHideDropdown,\n getDOMNode,\n }),\n [handleClickTrigger, handleHideDropdown, getDOMNode]\n )\n\n useEffect(\n function handleDefaultFocus() {\n if (defaultFocus && !disabled && !readOnly) {\n setIsDropdownOpened(true)\n }\n },\n [defaultFocus, disabled, readOnly]\n )\n\n useImperativeHandle(forwardedRef, () => handle)\n\n const hasContent = !isEmpty(text)\n\n return (\n <div\n style={style}\n className={classNames(styles.SelectContainer, className)}\n ref={containerRef}\n >\n <BaseButton\n className={classNames(\n styles.SelectTrigger,\n getFormFieldSizeClassName(size),\n hasError && styles.invalid,\n readOnly && styles.readonly,\n isDropdownOpened && styles.active\n )}\n ref={triggerRef}\n disabled={disabled}\n onClick={handleClickTrigger}\n {...ownProps}\n >\n <div className={styles.SelectMainContent}>\n {isBezierIcon(leftContent) ? (\n <Icon\n source={leftContent}\n size=\"xs\"\n marginRight={6}\n color={iconColor}\n />\n ) : (\n leftContent\n )}\n\n <Text\n data-testid=\"bezier-select-trigger-text\"\n typo=\"14\"\n truncated\n color={hasContent ? textColor : 'txt-black-dark'}\n >\n {hasContent ? text : placeholder}\n </Text>\n\n {isBezierIcon(rightContent) ? (\n <Icon\n source={rightContent}\n size=\"xs\"\n marginRight={6}\n color={iconColor}\n />\n ) : (\n rightContent\n )}\n </div>\n\n {!withoutChevron && (\n <Icon\n source={isDropdownOpened ? ChevronUpIcon : ChevronDownIcon}\n size=\"xs\"\n color={readOnly ? 'txt-black-dark' : 'txt-black-darker'}\n marginLeft={6}\n />\n )}\n </BaseButton>\n\n <Overlay\n zIndex={dropdownZIndex}\n style={dropdownStyle}\n className={classNames(styles.SelectDropdown, dropdownClassName)}\n withTransition\n show={isDropdownOpened && !disabled}\n marginX={dropdownMarginX}\n marginY={dropdownMarginY}\n target={triggerRef.current}\n container={dropdownContainer || containerRef.current}\n position={dropdownPosition}\n keepInContainer={dropdownKeepInContainer}\n data-testid={SELECT_DROPDOWN_TEST_ID}\n onHide={handleHideDropdown}\n >\n {children}\n </Overlay>\n </div>\n )\n})\n"],"names":["SELECT_DROPDOWN_TEST_ID","Select","forwardRef","children","style","className","size","sizeProps","defaultFocus","placeholder","leftContent","rightContent","iconColor","text","textColor","withoutChevron","dropdownStyle","dropdownClassName","dropdownContainer","dropdownMarginX","dropdownMarginY","dropdownZIndex","dropdownPosition","dropdownKeepInContainer","onClickTrigger","onHideDropdown","rest","forwardedRef","_ref","disabled","readOnly","hasError","formFieldSize","ownProps","useFormFieldProps","containerRef","useRef","triggerRef","isDropdownOpened","setIsDropdownOpened","useState","handleClickTrigger","useCallback","event","prevState","handleHideDropdown","getDOMNode","current","handle","useMemo","useEffect","handleDefaultFocus","useImperativeHandle","hasContent","isEmpty","_jsxs","classNames","styles","SelectContainer","ref","BaseButton","SelectTrigger","getFormFieldSizeClassName","invalid","readonly","active","onClick","SelectMainContent","isBezierIcon","_jsx","Icon","source","marginRight","color","Text","typo","truncated","ChevronUpIcon","ChevronDownIcon","marginLeft","Overlay","zIndex","SelectDropdown","withTransition","show","marginX","marginY","target","container","position","keepInContainer","onHide"],"mappings":";;;;;;;;;;;;;AAiCO,MAAMA,uBAAuB,GAAG;MAE1BC,MAAM,gBAAGC,UAAU,CAAyB,SAASD,MAAMA,CACtE;EACEE,QAAQ;EACRC,KAAK;EACLC,SAAS;AACTC,EAAAA,IAAI,EAAEC,SAAS;AACfC,EAAAA,YAAY,GAAG,KAAK;AACpBC,EAAAA,WAAW,GAAG,EAAE;EAChBC,WAAW;EACXC,YAAY;AACZC,EAAAA,SAAS,GAAG,gBAAgB;EAC5BC,IAAI;AACJC,EAAAA,SAAS,GAAG,mBAAmB;AAC/BC,EAAAA,cAAc,GAAG,KAAK;EACtBC,aAAa;EACbC,iBAAiB;EACjBC,iBAAiB;EACjBC,eAAe;AACfC,EAAAA,eAAe,GAAG,CAAC;AACnBC,EAAAA,cAAc,GAAG,SAAS;AAC1BC,EAAAA,gBAAgB,GAAG,aAAa;AAChCC,EAAAA,uBAAuB,GAAG,KAAK;EAC/BC,cAAc;EACdC,cAAc;EACd,GAAGC;AACL,CAAC,EACDC,YAAY,EACZ;AAAA,EAAA,IAAAC,IAAA;EACA,MAAM;IACJC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;AACRzB,IAAAA,IAAI,EAAE0B,aAAa;IACnB,GAAGC;AACL,GAAC,GAAGC,iBAAiB,CAACR,IAAI,CAAC;AAE3B,EAAA,MAAMS,YAAY,GAAGC,MAAM,CAAiB,IAAI,CAAC;AACjD,EAAA,MAAMC,UAAU,GAAGD,MAAM,CAAoB,IAAI,CAAC;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avB,uBAAwB;AACrC2F,MAAAA,MAAM,EAAE9C,kBAAmB;AAAA1C,MAAAA,QAAA,EAE1BA;AAAQ,KACF,CAAC;AAAA,GACP,CAAC;AAEV,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Select.mjs","sources":["../../../../src/components/Select/Select.tsx"],"sourcesContent":["'use client'\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport * as React from 'react'\n\nimport {\n ChevronDownIcon,\n ChevronUpIcon,\n isBezierIcon,\n} from '@channel.io/bezier-icons'\nimport classNames from 'classnames'\n\nimport { getFormFieldSizeClassName } from '~/src/types/props-helpers'\nimport { isEmpty } from '~/src/utils/type'\n\nimport { BaseButton } from '~/src/components/BaseButton'\nimport { useFormFieldProps } from '~/src/components/FormControl'\nimport { Icon } from '~/src/components/Icon'\nimport { Overlay } from '~/src/components/Overlay'\nimport { Text } from '~/src/components/Text'\n\nimport { type SelectProps, type SelectRef } from './Select.types'\n\nimport styles from './Select.module.scss'\n\nexport const SELECT_DROPDOWN_TEST_ID = 'bezier-select-dropdown'\n\nexport const Select = forwardRef<SelectRef, SelectProps>(function Select(\n {\n children,\n style,\n className,\n size: sizeProps,\n defaultFocus = false,\n placeholder = '',\n leftContent,\n rightContent,\n iconColor = 'txt-black-dark',\n text,\n textColor = 'txt-black-darkest',\n withoutChevron = false,\n dropdownStyle,\n dropdownClassName,\n dropdownContainer,\n dropdownMarginX,\n dropdownMarginY = 6,\n dropdownZIndex = 'overlay',\n dropdownPosition = 'bottom-left',\n dropdownKeepInContainer = false,\n onClickTrigger,\n onHideDropdown,\n ...rest\n },\n forwardedRef\n) {\n const {\n disabled,\n readOnly,\n hasError,\n size: formFieldSize,\n ...ownProps\n } = useFormFieldProps(rest)\n\n const containerRef = useRef<HTMLDivElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n\n const size = sizeProps ?? formFieldSize ?? 'm'\n\n const [isDropdownOpened, setIsDropdownOpened] = useState(false)\n\n const handleClickTrigger = useCallback(\n (event: React.MouseEvent) => {\n if (!disabled && !readOnly) {\n setIsDropdownOpened((prevState) => !prevState)\n onClickTrigger?.(event)\n }\n },\n [disabled, readOnly, onClickTrigger]\n )\n\n const handleHideDropdown = useCallback(() => {\n setIsDropdownOpened(false)\n onHideDropdown?.()\n }, [onHideDropdown])\n\n const getDOMNode = useCallback(() => triggerRef.current, [])\n\n const handle = useMemo(\n (): SelectRef => ({\n handleClickTrigger,\n handleHideDropdown,\n getDOMNode,\n }),\n [handleClickTrigger, handleHideDropdown, getDOMNode]\n )\n\n useEffect(\n function handleDefaultFocus() {\n if (defaultFocus && !disabled && !readOnly) {\n setIsDropdownOpened(true)\n }\n },\n [defaultFocus, disabled, readOnly]\n )\n\n useImperativeHandle(forwardedRef, () => handle)\n\n const hasContent = !isEmpty(text)\n\n const Content = (() => {\n if (!hasContent) {\n return (\n <Text\n data-testid=\"bezier-select-trigger-text\"\n typo=\"14\"\n truncated\n color=\"txt-black-dark\"\n >\n {placeholder}\n </Text>\n )\n }\n\n if (typeof text === 'string') {\n return (\n <Text\n data-testid=\"bezier-select-trigger-text\"\n typo=\"14\"\n truncated\n color={textColor}\n >\n {text}\n </Text>\n )\n }\n\n return text\n })()\n\n return (\n <div\n style={style}\n className={classNames(styles.SelectContainer, className)}\n ref={containerRef}\n >\n <BaseButton\n className={classNames(\n styles.SelectTrigger,\n getFormFieldSizeClassName(size),\n hasError && styles.invalid,\n readOnly && styles.readonly,\n isDropdownOpened && styles.active\n )}\n ref={triggerRef}\n disabled={disabled}\n onClick={handleClickTrigger}\n {...ownProps}\n >\n <div className={styles.SelectMainContent}>\n {isBezierIcon(leftContent) ? (\n <Icon\n source={leftContent}\n size=\"xs\"\n marginRight={6}\n color={iconColor}\n />\n ) : (\n leftContent\n )}\n\n {Content}\n\n {isBezierIcon(rightContent) ? (\n <Icon\n source={rightContent}\n size=\"xs\"\n marginRight={6}\n color={iconColor}\n />\n ) : (\n rightContent\n )}\n </div>\n\n {!withoutChevron && (\n <Icon\n source={isDropdownOpened ? ChevronUpIcon : ChevronDownIcon}\n size=\"xs\"\n color={readOnly ? 'txt-black-dark' : 'txt-black-darker'}\n marginLeft={6}\n />\n )}\n </BaseButton>\n\n <Overlay\n zIndex={dropdownZIndex}\n style={dropdownStyle}\n className={classNames(styles.SelectDropdown, dropdownClassName)}\n withTransition\n show={isDropdownOpened && !disabled}\n marginX={dropdownMarginX}\n marginY={dropdownMarginY}\n target={triggerRef.current}\n container={dropdownContainer || containerRef.current}\n position={dropdownPosition}\n keepInContainer={dropdownKeepInContainer}\n data-testid={SELECT_DROPDOWN_TEST_ID}\n onHide={handleHideDropdown}\n >\n {children}\n </Overlay>\n </div>\n )\n})\n"],"names":["SELECT_DROPDOWN_TEST_ID","Select","forwardRef","children","style","className","size","sizeProps","defaultFocus","placeholder","leftContent","rightContent","iconColor","text","textColor","withoutChevron","dropdownStyle","dropdownClassName","dropdownContainer","dropdownMarginX","dropdownMarginY","dropdownZIndex","dropdownPosition","dropdownKeepInContainer","onClickTrigger","onHideDropdown","rest","forwardedRef","_ref","disabled","readOnly","hasError","formFieldSize","ownProps","useFormFieldProps","containerRef","useRef","triggerRef","isDropdownOpened","setIsDropdownOpened","useState","handleClickTrigger","useCallback","event","prevState","handleHideDropdown","getDOMNode","current","handle","useMemo","useEffect","handleDefaultFocus","useImperativeHandle","hasContent","isEmpty","Content","_jsx","Text","typo","truncated","color","_jsxs","classNames","styles","SelectContainer","ref","BaseButton","SelectTrigger","getFormFieldSizeClassName","invalid","readonly","active","onClick","SelectMainContent","isBezierIcon","Icon","source","marginRight","ChevronUpIcon","ChevronDownIcon","marginLeft","Overlay","zIndex","SelectDropdown","withTransition","show","marginX","marginY","target","container","position","keepInContainer","onHide"],"mappings":";;;;;;;;;;;;;AAiCO,MAAMA,uBAAuB,GAAG;MAE1BC,MAAM,gBAAGC,UAAU,CAAyB,SAASD,MAAMA,CACtE;EACEE,QAAQ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A,QAAA,EAE1BA;AAAQ,KACF,CAAC;AAAA,GACP,CAAC;AAEV,CAAC;;;;"}
|
|
@@ -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":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAkB9B,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAIjE,eAAO,MAAM,uBAAuB,2BAA2B,CAAA;AAE/D,eAAO,MAAM,MAAM,+
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAkB9B,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAIjE,eAAO,MAAM,uBAAuB,2BAA2B,CAAA;AAE/D,eAAO,MAAM,MAAM,+EA0LjB,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
1
2
|
import { type BezierIcon } from '@channel.io/bezier-icons';
|
|
2
3
|
import type { AdditionalColorProps, AdditionalOverridableStyleProps, BezierComponentProps, ChildrenProps, FormFieldProps, FormFieldSize, SideContentProps, SizeProps } from "../../types/props";
|
|
3
4
|
import { type ZIndex } from "../../types/tokens";
|
|
@@ -10,7 +11,7 @@ export interface SelectRef {
|
|
|
10
11
|
interface SelectOwnProps {
|
|
11
12
|
defaultFocus?: boolean;
|
|
12
13
|
placeholder?: string;
|
|
13
|
-
text?:
|
|
14
|
+
text?: ReactNode;
|
|
14
15
|
withoutChevron?: boolean;
|
|
15
16
|
dropdownContainer?: HTMLElement | null;
|
|
16
17
|
dropdownMarginX?: OverlayProps['marginX'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.types.d.ts","sourceRoot":"","sources":["../../../../src/components/Select/Select.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,KAAK,EACV,oBAAoB,EACpB,+BAA+B,EAC/B,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,SAAS,EACV,0BAAyB;AAC1B,OAAO,EAAE,KAAK,MAAM,EAAE,2BAA0B;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAgC;AAE5D,MAAM,WAAW,SAAS;IACxB,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,GAAG,IAAI,CAAA;IACjD,kBAAkB,IAAI,IAAI,CAAA;IAC1B,UAAU,IAAI,OAAO,GAAG,IAAI,GAAG,IAAI,CAAA;CACpC;AAED,UAAU,cAAc;IACtB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"Select.types.d.ts","sourceRoot":"","sources":["../../../../src/components/Select/Select.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,KAAK,EACV,oBAAoB,EACpB,+BAA+B,EAC/B,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,SAAS,EACV,0BAAyB;AAC1B,OAAO,EAAE,KAAK,MAAM,EAAE,2BAA0B;AAEhD,OAAO,KAAK,EAAE,YAAY,EAA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,"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.
|
|
3
|
+
"version": "3.2.0",
|
|
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
|
|
|
@@ -115,6 +115,36 @@ export const Select = forwardRef<SelectRef, SelectProps>(function Select(
|
|
|
115
115
|
|
|
116
116
|
const hasContent = !isEmpty(text)
|
|
117
117
|
|
|
118
|
+
const Content = (() => {
|
|
119
|
+
if (!hasContent) {
|
|
120
|
+
return (
|
|
121
|
+
<Text
|
|
122
|
+
data-testid="bezier-select-trigger-text"
|
|
123
|
+
typo="14"
|
|
124
|
+
truncated
|
|
125
|
+
color="txt-black-dark"
|
|
126
|
+
>
|
|
127
|
+
{placeholder}
|
|
128
|
+
</Text>
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (typeof text === 'string') {
|
|
133
|
+
return (
|
|
134
|
+
<Text
|
|
135
|
+
data-testid="bezier-select-trigger-text"
|
|
136
|
+
typo="14"
|
|
137
|
+
truncated
|
|
138
|
+
color={textColor}
|
|
139
|
+
>
|
|
140
|
+
{text}
|
|
141
|
+
</Text>
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return text
|
|
146
|
+
})()
|
|
147
|
+
|
|
118
148
|
return (
|
|
119
149
|
<div
|
|
120
150
|
style={style}
|
|
@@ -146,14 +176,7 @@ export const Select = forwardRef<SelectRef, SelectProps>(function Select(
|
|
|
146
176
|
leftContent
|
|
147
177
|
)}
|
|
148
178
|
|
|
149
|
-
|
|
150
|
-
data-testid="bezier-select-trigger-text"
|
|
151
|
-
typo="14"
|
|
152
|
-
truncated
|
|
153
|
-
color={hasContent ? textColor : 'txt-black-dark'}
|
|
154
|
-
>
|
|
155
|
-
{hasContent ? text : placeholder}
|
|
156
|
-
</Text>
|
|
179
|
+
{Content}
|
|
157
180
|
|
|
158
181
|
{isBezierIcon(rightContent) ? (
|
|
159
182
|
<Icon
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type ReactNode } from 'react'
|
|
2
|
+
|
|
1
3
|
import { type BezierIcon } from '@channel.io/bezier-icons'
|
|
2
4
|
|
|
3
5
|
import type {
|
|
@@ -23,7 +25,7 @@ export interface SelectRef {
|
|
|
23
25
|
interface SelectOwnProps {
|
|
24
26
|
defaultFocus?: boolean
|
|
25
27
|
placeholder?: string
|
|
26
|
-
text?:
|
|
28
|
+
text?: ReactNode
|
|
27
29
|
withoutChevron?: boolean
|
|
28
30
|
dropdownContainer?: HTMLElement | null
|
|
29
31
|
dropdownMarginX?: OverlayProps['marginX']
|
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
|
|