@transferwise/components 0.0.0-experimental-424b5be → 0.0.0-experimental-0ee6ecc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/button/Button/src/Button.js +2 -0
- package/build/button/Button/src/Button.js.map +1 -1
- package/build/button/Button/src/Button.mjs +2 -0
- package/build/button/Button/src/Button.mjs.map +1 -1
- package/build/button/LegacyButton/Button.js.map +1 -1
- package/build/button/LegacyButton/Button.mjs.map +1 -1
- package/build/button/src/Button.js +9 -11
- package/build/button/src/Button.js.map +1 -1
- package/build/button/src/Button.mjs +9 -11
- package/build/button/src/Button.mjs.map +1 -1
- package/build/types/button/Button/src/Button.d.ts.map +1 -1
- package/build/types/button/Button/src/Button.types.d.ts +1 -0
- package/build/types/button/Button/src/Button.types.d.ts.map +1 -1
- package/build/types/button/LegacyButton/Button.d.ts +1 -2
- package/build/types/button/LegacyButton/Button.d.ts.map +1 -1
- package/build/types/button/src/Button.d.ts +1 -0
- package/build/types/button/src/Button.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/button/Button/src/Button.tsx +2 -0
- package/src/button/Button/src/Button.types.ts +2 -0
- package/src/button/LegacyButton/Button.tsx +1 -2
- package/src/button/src/Button.tsx +10 -14
|
@@ -14,6 +14,7 @@ const Button = /*#__PURE__*/React.forwardRef(({
|
|
|
14
14
|
children,
|
|
15
15
|
className,
|
|
16
16
|
size = 'md',
|
|
17
|
+
href,
|
|
17
18
|
priority = 'primary',
|
|
18
19
|
appearance = 'default',
|
|
19
20
|
iconLeft: LeftIcon,
|
|
@@ -70,6 +71,7 @@ const Button = /*#__PURE__*/React.forwardRef(({
|
|
|
70
71
|
return /*#__PURE__*/jsxRuntime.jsx(PrimitiveAnchor, {
|
|
71
72
|
ref: ref,
|
|
72
73
|
...props,
|
|
74
|
+
href: href,
|
|
73
75
|
className: classNames,
|
|
74
76
|
disabled: props.disabled,
|
|
75
77
|
children: content
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../../src/button/Button/src/Button.tsx"],"sourcesContent":["import React, { forwardRef, useMemo } from 'react';\nimport { clsx } from 'clsx';\nimport type { ButtonProps } from './Button.types';\nimport PrimitiveButton from '../../../primitives/PrimitiveButton';\nimport PrimitiveAnchor from '../../../primitives/PrimitiveAnchor';\nimport ProcessIndicator from '../../../processIndicator/ProcessIndicator';\nimport AvatarView from '../../../avatarView/AvatarView';\nimport AvatarLayout from '../../../avatarLayout/AvatarLayout';\n\nconst Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(\n (\n {\n as = 'button',\n children,\n className,\n size = 'md',\n priority = 'primary',\n appearance = 'default',\n iconLeft: LeftIcon,\n iconRight: RightIcon,\n avatars,\n type = 'button',\n loading = false,\n block = false,\n ...props\n },\n ref,\n ) => {\n const sizeClass = useMemo(() => {\n return size === 'sm' ? 'small' : size === 'md' ? 'medium' : size === 'lg' ? 'large' : '';\n }, [size]);\n\n const classNames = clsx(\n {\n [`wds-Button`]: as === 'a',\n [`wds-Button--block`]: block,\n [`wds-Button--${sizeClass}`]: size,\n [`wds-Button--${priority}`]: priority,\n [`wds-Button--${appearance}`]: appearance,\n },\n className,\n );\n\n const contentClassNames = clsx('wds-Button-content', {\n [`wds-Button-content--loading`]: loading,\n });\n\n const content = (\n <span className={contentClassNames}>\n {loading && (\n <ProcessIndicator\n size=\"xs\"\n className=\"wds-Button-loader\"\n data-testid=\"button-loader-indicator\"\n />\n )}\n <span className=\"wds-Button-label\" aria-hidden={loading}>\n {size === 'lg' ? (\n children\n ) : (\n <>\n {size === 'md' && avatars && (\n <span className=\"wds-Button-avatars\">\n {avatars.length === 1 ? (\n <AvatarView size={24} {...avatars[0]}>\n {avatars[0]?.asset}\n </AvatarView>\n ) : (\n <AvatarLayout orientation=\"horizontal\" avatars={avatars} size={24} />\n )}\n </span>\n )}\n {!avatars && LeftIcon && (\n <LeftIcon className=\"wds-Button-icon wds-Button-icon--left\" />\n )}\n {children}\n {RightIcon && <RightIcon className=\"wds-Button-icon wds-Button-icon--right\" />}\n </>\n )}\n </span>\n </span>\n );\n\n if (as === 'a') {\n return (\n <PrimitiveAnchor\n ref={ref as React.Ref<HTMLAnchorElement>}\n {...(props as any)}\n className={classNames}\n disabled={props.disabled}\n >\n {content}\n </PrimitiveAnchor>\n );\n }\n\n return (\n <PrimitiveButton\n ref={ref as React.Ref<HTMLButtonElement>}\n {...(props as any)}\n className={classNames}\n disabled={props.disabled}\n loading={loading}\n type={type}\n >\n {content}\n </PrimitiveButton>\n );\n },\n);\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["Button","forwardRef","as","children","className","size","priority","appearance","iconLeft","LeftIcon","iconRight","RightIcon","avatars","type","loading","block","props","ref","sizeClass","useMemo","classNames","clsx","contentClassNames","content","_jsxs","_jsx","ProcessIndicator","_Fragment","length","AvatarView","asset","AvatarLayout","orientation","PrimitiveAnchor","disabled","PrimitiveButton","displayName"],"mappings":";;;;;;;;;;;AASA,MAAMA,MAAM,gBAAGC,gBAAU,CACvB,CACE;AACEC,EAAAA,EAAE,GAAG,QAAQ;EACbC,QAAQ;EACRC,SAAS;AACTC,EAAAA,IAAI,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../../src/button/Button/src/Button.tsx"],"sourcesContent":["import React, { forwardRef, useMemo } from 'react';\nimport { clsx } from 'clsx';\nimport type { ButtonProps } from './Button.types';\nimport PrimitiveButton from '../../../primitives/PrimitiveButton';\nimport PrimitiveAnchor from '../../../primitives/PrimitiveAnchor';\nimport ProcessIndicator from '../../../processIndicator/ProcessIndicator';\nimport AvatarView from '../../../avatarView/AvatarView';\nimport AvatarLayout from '../../../avatarLayout/AvatarLayout';\n\nconst Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(\n (\n {\n as = 'button',\n children,\n className,\n size = 'md',\n href,\n priority = 'primary',\n appearance = 'default',\n iconLeft: LeftIcon,\n iconRight: RightIcon,\n avatars,\n type = 'button',\n loading = false,\n block = false,\n ...props\n },\n ref,\n ) => {\n const sizeClass = useMemo(() => {\n return size === 'sm' ? 'small' : size === 'md' ? 'medium' : size === 'lg' ? 'large' : '';\n }, [size]);\n\n const classNames = clsx(\n {\n [`wds-Button`]: as === 'a',\n [`wds-Button--block`]: block,\n [`wds-Button--${sizeClass}`]: size,\n [`wds-Button--${priority}`]: priority,\n [`wds-Button--${appearance}`]: appearance,\n },\n className,\n );\n\n const contentClassNames = clsx('wds-Button-content', {\n [`wds-Button-content--loading`]: loading,\n });\n\n const content = (\n <span className={contentClassNames}>\n {loading && (\n <ProcessIndicator\n size=\"xs\"\n className=\"wds-Button-loader\"\n data-testid=\"button-loader-indicator\"\n />\n )}\n <span className=\"wds-Button-label\" aria-hidden={loading}>\n {size === 'lg' ? (\n children\n ) : (\n <>\n {size === 'md' && avatars && (\n <span className=\"wds-Button-avatars\">\n {avatars.length === 1 ? (\n <AvatarView size={24} {...avatars[0]}>\n {avatars[0]?.asset}\n </AvatarView>\n ) : (\n <AvatarLayout orientation=\"horizontal\" avatars={avatars} size={24} />\n )}\n </span>\n )}\n {!avatars && LeftIcon && (\n <LeftIcon className=\"wds-Button-icon wds-Button-icon--left\" />\n )}\n {children}\n {RightIcon && <RightIcon className=\"wds-Button-icon wds-Button-icon--right\" />}\n </>\n )}\n </span>\n </span>\n );\n\n if (as === 'a') {\n return (\n <PrimitiveAnchor\n ref={ref as React.Ref<HTMLAnchorElement>}\n {...(props as any)}\n href={href}\n className={classNames}\n disabled={props.disabled}\n >\n {content}\n </PrimitiveAnchor>\n );\n }\n\n return (\n <PrimitiveButton\n ref={ref as React.Ref<HTMLButtonElement>}\n {...(props as any)}\n className={classNames}\n disabled={props.disabled}\n loading={loading}\n type={type}\n >\n {content}\n </PrimitiveButton>\n );\n },\n);\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["Button","forwardRef","as","children","className","size","href","priority","appearance","iconLeft","LeftIcon","iconRight","RightIcon","avatars","type","loading","block","props","ref","sizeClass","useMemo","classNames","clsx","contentClassNames","content","_jsxs","_jsx","ProcessIndicator","_Fragment","length","AvatarView","asset","AvatarLayout","orientation","PrimitiveAnchor","disabled","PrimitiveButton","displayName"],"mappings":";;;;;;;;;;;AASA,MAAMA,MAAM,gBAAGC,gBAAU,CACvB,CACE;AACEC,EAAAA,EAAE,GAAG,QAAQ;EACbC,QAAQ;EACRC,SAAS;AACTC,EAAAA,IAAI,GAAG,IAAI;EACXC,IAAI;AACJC,EAAAA,QAAQ,GAAG,SAAS;AACpBC,EAAAA,UAAU,GAAG,SAAS;AACtBC,EAAAA,QAAQ,EAAEC,QAAQ;AAClBC,EAAAA,SAAS,EAAEC,SAAS;EACpBC,OAAO;AACPC,EAAAA,IAAI,GAAG,QAAQ;AACfC,EAAAA,OAAO,GAAG,KAAK;AACfC,EAAAA,KAAK,GAAG,KAAK;EACb,GAAGC,KAAAA;AACJ,CAAA,EACDC,GAAG,KACD;AACF,EAAA,MAAMC,SAAS,GAAGC,aAAO,CAAC,MAAK;AAC7B,IAAA,OAAOf,IAAI,KAAK,IAAI,GAAG,OAAO,GAAGA,IAAI,KAAK,IAAI,GAAG,QAAQ,GAAGA,IAAI,KAAK,IAAI,GAAG,OAAO,GAAG,EAAE,CAAA;AAC1F,GAAC,EAAE,CAACA,IAAI,CAAC,CAAC,CAAA;EAEV,MAAMgB,UAAU,GAAGC,SAAI,CACrB;AACE,IAAA,CAAC,CAAY,UAAA,CAAA,GAAGpB,EAAE,KAAK,GAAG;IAC1B,CAAC,CAAA,iBAAA,CAAmB,GAAGc,KAAK;AAC5B,IAAA,CAAC,CAAeG,YAAAA,EAAAA,SAAS,CAAE,CAAA,GAAGd,IAAI;AAClC,IAAA,CAAC,CAAeE,YAAAA,EAAAA,QAAQ,CAAE,CAAA,GAAGA,QAAQ;IACrC,CAAC,CAAA,YAAA,EAAeC,UAAU,CAAA,CAAE,GAAGA,UAAAA;GAChC,EACDJ,SAAS,CACV,CAAA;A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EACRS,SAAS,iBAAIc,cAAA,CAACd,SAAS,EAAA;AAACR,UAAAA,SAAS,EAAC,wCAAA;AAAwC,SAAA,CAAG,CAAA;OAChF,CAAA;AACD,KACG,CACR,CAAA;AAAA,GAAM,CACP,CAAA;EAED,IAAIF,EAAE,KAAK,GAAG,EAAE;IACd,oBACEwB,cAAA,CAACQ,eAAe,EAAA;AACdhB,MAAAA,GAAG,EAAEA,GAAoC;AAAA,MAAA,GACpCD,KAAa;AAClBX,MAAAA,IAAI,EAAEA,IAAK;AACXF,MAAAA,SAAS,EAAEiB,UAAW;MACtBc,QAAQ,EAAElB,KAAK,CAACkB,QAAS;AAAAhC,MAAAA,QAAA,EAExBqB,OAAAA;AAAO,KACO,CAAC,CAAA;AAEtB,GAAA;EAEA,oBACEE,cAAA,CAACU,eAAe,EAAA;AACdlB,IAAAA,GAAG,EAAEA,GAAoC;AAAA,IAAA,GACpCD,KAAa;AAClBb,IAAAA,SAAS,EAAEiB,UAAW;IACtBc,QAAQ,EAAElB,KAAK,CAACkB,QAAS;AACzBpB,IAAAA,OAAO,EAAEA,OAAQ;AACjBD,IAAAA,IAAI,EAAEA,IAAK;AAAAX,IAAAA,QAAA,EAEVqB,OAAAA;AAAO,GACO,CAAC,CAAA;AAEtB,CAAC,EACF;AAEDxB,MAAM,CAACqC,WAAW,GAAG,QAAQ;;;;"}
|
|
@@ -12,6 +12,7 @@ const Button = /*#__PURE__*/forwardRef(({
|
|
|
12
12
|
children,
|
|
13
13
|
className,
|
|
14
14
|
size = 'md',
|
|
15
|
+
href,
|
|
15
16
|
priority = 'primary',
|
|
16
17
|
appearance = 'default',
|
|
17
18
|
iconLeft: LeftIcon,
|
|
@@ -68,6 +69,7 @@ const Button = /*#__PURE__*/forwardRef(({
|
|
|
68
69
|
return /*#__PURE__*/jsx(PrimitiveAnchor, {
|
|
69
70
|
ref: ref,
|
|
70
71
|
...props,
|
|
72
|
+
href: href,
|
|
71
73
|
className: classNames,
|
|
72
74
|
disabled: props.disabled,
|
|
73
75
|
children: content
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.mjs","sources":["../../../../src/button/Button/src/Button.tsx"],"sourcesContent":["import React, { forwardRef, useMemo } from 'react';\nimport { clsx } from 'clsx';\nimport type { ButtonProps } from './Button.types';\nimport PrimitiveButton from '../../../primitives/PrimitiveButton';\nimport PrimitiveAnchor from '../../../primitives/PrimitiveAnchor';\nimport ProcessIndicator from '../../../processIndicator/ProcessIndicator';\nimport AvatarView from '../../../avatarView/AvatarView';\nimport AvatarLayout from '../../../avatarLayout/AvatarLayout';\n\nconst Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(\n (\n {\n as = 'button',\n children,\n className,\n size = 'md',\n priority = 'primary',\n appearance = 'default',\n iconLeft: LeftIcon,\n iconRight: RightIcon,\n avatars,\n type = 'button',\n loading = false,\n block = false,\n ...props\n },\n ref,\n ) => {\n const sizeClass = useMemo(() => {\n return size === 'sm' ? 'small' : size === 'md' ? 'medium' : size === 'lg' ? 'large' : '';\n }, [size]);\n\n const classNames = clsx(\n {\n [`wds-Button`]: as === 'a',\n [`wds-Button--block`]: block,\n [`wds-Button--${sizeClass}`]: size,\n [`wds-Button--${priority}`]: priority,\n [`wds-Button--${appearance}`]: appearance,\n },\n className,\n );\n\n const contentClassNames = clsx('wds-Button-content', {\n [`wds-Button-content--loading`]: loading,\n });\n\n const content = (\n <span className={contentClassNames}>\n {loading && (\n <ProcessIndicator\n size=\"xs\"\n className=\"wds-Button-loader\"\n data-testid=\"button-loader-indicator\"\n />\n )}\n <span className=\"wds-Button-label\" aria-hidden={loading}>\n {size === 'lg' ? (\n children\n ) : (\n <>\n {size === 'md' && avatars && (\n <span className=\"wds-Button-avatars\">\n {avatars.length === 1 ? (\n <AvatarView size={24} {...avatars[0]}>\n {avatars[0]?.asset}\n </AvatarView>\n ) : (\n <AvatarLayout orientation=\"horizontal\" avatars={avatars} size={24} />\n )}\n </span>\n )}\n {!avatars && LeftIcon && (\n <LeftIcon className=\"wds-Button-icon wds-Button-icon--left\" />\n )}\n {children}\n {RightIcon && <RightIcon className=\"wds-Button-icon wds-Button-icon--right\" />}\n </>\n )}\n </span>\n </span>\n );\n\n if (as === 'a') {\n return (\n <PrimitiveAnchor\n ref={ref as React.Ref<HTMLAnchorElement>}\n {...(props as any)}\n className={classNames}\n disabled={props.disabled}\n >\n {content}\n </PrimitiveAnchor>\n );\n }\n\n return (\n <PrimitiveButton\n ref={ref as React.Ref<HTMLButtonElement>}\n {...(props as any)}\n className={classNames}\n disabled={props.disabled}\n loading={loading}\n type={type}\n >\n {content}\n </PrimitiveButton>\n );\n },\n);\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["Button","forwardRef","as","children","className","size","priority","appearance","iconLeft","LeftIcon","iconRight","RightIcon","avatars","type","loading","block","props","ref","sizeClass","useMemo","classNames","clsx","contentClassNames","content","_jsxs","_jsx","ProcessIndicator","_Fragment","length","AvatarView","asset","AvatarLayout","orientation","PrimitiveAnchor","disabled","PrimitiveButton","displayName"],"mappings":";;;;;;;;;AASA,MAAMA,MAAM,gBAAGC,UAAU,CACvB,CACE;AACEC,EAAAA,EAAE,GAAG,QAAQ;EACbC,QAAQ;EACRC,SAAS;AACTC,EAAAA,IAAI,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"Button.mjs","sources":["../../../../src/button/Button/src/Button.tsx"],"sourcesContent":["import React, { forwardRef, useMemo } from 'react';\nimport { clsx } from 'clsx';\nimport type { ButtonProps } from './Button.types';\nimport PrimitiveButton from '../../../primitives/PrimitiveButton';\nimport PrimitiveAnchor from '../../../primitives/PrimitiveAnchor';\nimport ProcessIndicator from '../../../processIndicator/ProcessIndicator';\nimport AvatarView from '../../../avatarView/AvatarView';\nimport AvatarLayout from '../../../avatarLayout/AvatarLayout';\n\nconst Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(\n (\n {\n as = 'button',\n children,\n className,\n size = 'md',\n href,\n priority = 'primary',\n appearance = 'default',\n iconLeft: LeftIcon,\n iconRight: RightIcon,\n avatars,\n type = 'button',\n loading = false,\n block = false,\n ...props\n },\n ref,\n ) => {\n const sizeClass = useMemo(() => {\n return size === 'sm' ? 'small' : size === 'md' ? 'medium' : size === 'lg' ? 'large' : '';\n }, [size]);\n\n const classNames = clsx(\n {\n [`wds-Button`]: as === 'a',\n [`wds-Button--block`]: block,\n [`wds-Button--${sizeClass}`]: size,\n [`wds-Button--${priority}`]: priority,\n [`wds-Button--${appearance}`]: appearance,\n },\n className,\n );\n\n const contentClassNames = clsx('wds-Button-content', {\n [`wds-Button-content--loading`]: loading,\n });\n\n const content = (\n <span className={contentClassNames}>\n {loading && (\n <ProcessIndicator\n size=\"xs\"\n className=\"wds-Button-loader\"\n data-testid=\"button-loader-indicator\"\n />\n )}\n <span className=\"wds-Button-label\" aria-hidden={loading}>\n {size === 'lg' ? (\n children\n ) : (\n <>\n {size === 'md' && avatars && (\n <span className=\"wds-Button-avatars\">\n {avatars.length === 1 ? (\n <AvatarView size={24} {...avatars[0]}>\n {avatars[0]?.asset}\n </AvatarView>\n ) : (\n <AvatarLayout orientation=\"horizontal\" avatars={avatars} size={24} />\n )}\n </span>\n )}\n {!avatars && LeftIcon && (\n <LeftIcon className=\"wds-Button-icon wds-Button-icon--left\" />\n )}\n {children}\n {RightIcon && <RightIcon className=\"wds-Button-icon wds-Button-icon--right\" />}\n </>\n )}\n </span>\n </span>\n );\n\n if (as === 'a') {\n return (\n <PrimitiveAnchor\n ref={ref as React.Ref<HTMLAnchorElement>}\n {...(props as any)}\n href={href}\n className={classNames}\n disabled={props.disabled}\n >\n {content}\n </PrimitiveAnchor>\n );\n }\n\n return (\n <PrimitiveButton\n ref={ref as React.Ref<HTMLButtonElement>}\n {...(props as any)}\n className={classNames}\n disabled={props.disabled}\n loading={loading}\n type={type}\n >\n {content}\n </PrimitiveButton>\n );\n },\n);\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["Button","forwardRef","as","children","className","size","href","priority","appearance","iconLeft","LeftIcon","iconRight","RightIcon","avatars","type","loading","block","props","ref","sizeClass","useMemo","classNames","clsx","contentClassNames","content","_jsxs","_jsx","ProcessIndicator","_Fragment","length","AvatarView","asset","AvatarLayout","orientation","PrimitiveAnchor","disabled","PrimitiveButton","displayName"],"mappings":";;;;;;;;;AASA,MAAMA,MAAM,gBAAGC,UAAU,CACvB,CACE;AACEC,EAAAA,EAAE,GAAG,QAAQ;EACbC,QAAQ;EACRC,SAAS;AACTC,EAAAA,IAAI,GAAG,IAAI;EACXC,IAAI;AACJC,EAAAA,QAAQ,GAAG,SAAS;AACpBC,EAAAA,UAAU,GAAG,SAAS;AACtBC,EAAAA,QAAQ,EAAEC,QAAQ;AAClBC,EAAAA,SAAS,EAAEC,SAAS;EACpBC,OAAO;AACPC,EAAAA,IAAI,GAAG,QAAQ;AACfC,EAAAA,OAAO,GAAG,KAAK;AACfC,EAAAA,KAAK,GAAG,KAAK;EACb,GAAGC,KAAAA;AACJ,CAAA,EACDC,GAAG,KACD;AACF,EAAA,MAAMC,SAAS,GAAGC,OAAO,CAAC,MAAK;AAC7B,IAAA,OAAOf,IAAI,KAAK,IAAI,GAAG,OAAO,GAAGA,IAAI,KAAK,IAAI,GAAG,QAAQ,GAAGA,IAAI,KAAK,IAAI,GAAG,OAAO,GAAG,EAAE,CAAA;AAC1F,GAAC,EAAE,CAACA,IAAI,CAAC,CAAC,CAAA;EAEV,MAAMgB,UAAU,GAAGC,IAAI,CACrB;AACE,IAAA,CAAC,CAAY,UAAA,CAAA,GAAGpB,EAAE,KAAK,GAAG;IAC1B,CAAC,CAAA,iBAAA,CAAmB,GAAGc,KAAK;AAC5B,IAAA,CAAC,CAAeG,YAAAA,EAAAA,SAAS,CAAE,CAAA,GAAGd,IAAI;AAClC,IAAA,CAAC,CAAeE,YAAAA,EAAAA,QAAQ,CAAE,CAAA,GAAGA,QAAQ;IACrC,CAAC,CAAA,YAAA,EAAeC,UAAU,CAAA,CAAE,GA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,EAAC,uCAAA;SAAuC,CAC5D,EACAD,QAAQ,EACRS,SAAS,iBAAIc,GAAA,CAACd,SAAS,EAAA;AAACR,UAAAA,SAAS,EAAC,wCAAA;AAAwC,SAAA,CAAG,CAAA;OAChF,CAAA;AACD,KACG,CACR,CAAA;AAAA,GAAM,CACP,CAAA;EAED,IAAIF,EAAE,KAAK,GAAG,EAAE;IACd,oBACEwB,GAAA,CAACQ,eAAe,EAAA;AACdhB,MAAAA,GAAG,EAAEA,GAAoC;AAAA,MAAA,GACpCD,KAAa;AAClBX,MAAAA,IAAI,EAAEA,IAAK;AACXF,MAAAA,SAAS,EAAEiB,UAAW;MACtBc,QAAQ,EAAElB,KAAK,CAACkB,QAAS;AAAAhC,MAAAA,QAAA,EAExBqB,OAAAA;AAAO,KACO,CAAC,CAAA;AAEtB,GAAA;EAEA,oBACEE,GAAA,CAACU,eAAe,EAAA;AACdlB,IAAAA,GAAG,EAAEA,GAAoC;AAAA,IAAA,GACpCD,KAAa;AAClBb,IAAAA,SAAS,EAAEiB,UAAW;IACtBc,QAAQ,EAAElB,KAAK,CAACkB,QAAS;AACzBpB,IAAAA,OAAO,EAAEA,OAAQ;AACjBD,IAAAA,IAAI,EAAEA,IAAK;AAAAX,IAAAA,QAAA,EAEVqB,OAAAA;AAAO,GACO,CAAC,CAAA;AAEtB,CAAC,EACF;AAEDxB,MAAM,CAACqC,WAAW,GAAG,QAAQ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../src/button/LegacyButton/Button.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ElementType, forwardRef, MouseEvent } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport {\n Size,\n ControlType,\n Priority,\n ControlTypeAccent,\n ControlTypeNegative,\n ControlTypePositive,\n PriorityPrimary,\n PrioritySecondary,\n PriorityTertiary,\n SizeExtraSmall,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../../common';\nimport ProcessIndicator from '../../processIndicator';\n\nimport messages from '../../i18n/commonMessages/Button.messages';\nimport { typeClassMap, priorityClassMap } from './classMap';\nimport { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n block?: boolean;\n disabled?: boolean;\n loading?: boolean;\n
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../src/button/LegacyButton/Button.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ElementType, forwardRef, MouseEvent } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport {\n Size,\n ControlType,\n Priority,\n ControlTypeAccent,\n ControlTypeNegative,\n ControlTypePositive,\n PriorityPrimary,\n PrioritySecondary,\n PriorityTertiary,\n SizeExtraSmall,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../../common';\nimport ProcessIndicator from '../../processIndicator';\n\nimport messages from '../../i18n/commonMessages/Button.messages';\nimport { typeClassMap, priorityClassMap } from './classMap';\nimport { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n block?: boolean;\n disabled?: boolean;\n loading?: boolean;\n type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;\n size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;\n};\n\nexport type ButtonProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {\n as?: 'button' | undefined;\n htmlType?: 'submit' | 'reset' | 'button';\n };\n\nexport type AnchorProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {\n as?: 'a' | undefined;\n href?: string;\n };\n\nexport type Props = ButtonProps | AnchorProps;\n\nexport type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;\n\nconst Button = forwardRef<ButtonReferenceType, Props>(\n (\n {\n as: component,\n block = false,\n children,\n className,\n disabled,\n loading = false,\n priority = Priority.PRIMARY,\n size = Size.MEDIUM,\n type = ControlType.ACCENT,\n onClick,\n ...rest\n }: Props,\n ref,\n ) => {\n const intl = useIntl();\n\n logDeprecationNotices({ size, type });\n\n const newType = establishNewType(type);\n const newPriority = establishNewPriority(priority, type);\n\n const classes = clsx(\n `btn btn-${size}`,\n `np-btn np-btn-${size}`,\n {\n 'btn-loading': loading,\n 'btn-block np-btn-block': block,\n disabled,\n },\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n typeClassMap[newType],\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n priorityClassMap[newPriority],\n className,\n );\n\n function processIndicatorSize() {\n return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';\n }\n\n const Element = (component as ElementType) ?? 'button';\n let props;\n\n if (Element === 'button') {\n const { htmlType = 'button', ...restProps } = rest as ButtonProps;\n props = {\n ...restProps,\n disabled,\n 'aria-disabled': loading,\n type: htmlType,\n };\n } else {\n props = {\n ...rest,\n 'aria-disabled': loading,\n } as AnchorProps;\n }\n\n /**\n * Ensures that the button cannot be activated in loading or disabled mode,\n * when `aria-disabled` might be used over the `disabled` HTML attribute\n */\n const handleClick =\n (handler: Props['onClick']) =>\n (event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {\n if (disabled || loading) {\n event.preventDefault();\n } else if (typeof handler === 'function') {\n handler(event);\n }\n };\n\n return (\n <Element\n ref={ref}\n className={classes}\n onClick={handleClick(onClick)}\n {...props}\n aria-live={loading ? 'polite' : 'off'}\n aria-busy={loading}\n aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}\n >\n {children}\n {loading && (\n <ProcessIndicator\n size={processIndicatorSize()}\n className=\"btn-loader\"\n data-testid=\"ButtonProgressIndicator\"\n />\n )}\n </Element>\n );\n },\n);\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["Button","forwardRef","as","component","block","children","className","disabled","loading","priority","Priority","PRIMARY","size","Size","MEDIUM","type","ControlType","ACCENT","onClick","rest","ref","intl","useIntl","logDeprecationNotices","newType","establishNewType","newPriority","establishNewPriority","classes","clsx","typeClassMap","priorityClassMap","processIndicatorSize","includes","Element","props","htmlType","restProps","handleClick","handler","event","preventDefault","_jsxs","formatMessage","messages","loadingAriaLabel","_jsx","ProcessIndicator","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAMA,MAAM,gBAAGC,gBAAU,CACvB,CACE;AACEC,EAAAA,EAAE,EAAEC,SAAS;AACbC,EAAAA,KAAK,GAAG,KAAK;EACbC,QAAQ;EACRC,SAAS;EACTC,QAAQ;AACRC,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ,GAAGC,gBAAQ,CAACC,OAAO;QAC3BC,MAAI,GAAGC,SAAI,CAACC,MAAM;EAClBC,IAAI,GAAGC,mBAAW,CAACC,MAAM;EACzBC,OAAO;EACP,GAAGC,IAAAA;AACG,CAAA,EACRC,GAAG,KACD;AACF,EAAA,MAAMC,IAAI,GAAGC,iBAAO,EAAE,CAAA;AAEtBC,EAAAA,iCAAqB,CAAC;UAAEX,MAAI;AAAEG,IAAAA,IAAAA;AAAI,GAAE,CAAC,CAAA;AAErC,EAAA,MAAMS,OAAO,GAAGC,4BAAgB,CAACV,IAAI,CAAC,CAAA;AACtC,EAAA,MAAMW,WAAW,GAAGC,gCAAoB,CAAClB,QAAQ,EAAEM,IAAI,CAAC,CAAA;EAExD,MAAMa,OAAO,GAAGC,SAAI,CAClB,CAAA,QAAA,EAAWjB,MAAI,CAAA,CAAE,EACjB,CA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AEA,GAAI;AACTd,IAAAA,SAAS,EAAEsB,OAAQ;AACnBV,IAAAA,OAAO,EAAEoB,WAAW,CAACpB,OAAO,CAAE;AAAA,IAAA,GAC1BiB,KAAK;AACT,IAAA,WAAA,EAAW3B,OAAO,GAAG,QAAQ,GAAG,KAAM;AACtC,IAAA,WAAA,EAAWA,OAAQ;AACnB,IAAA,YAAA,EAAYA,OAAO,GAAGa,IAAI,CAACsB,aAAa,CAACC,eAAQ,CAACC,gBAAgB,CAAC,GAAG1B,IAAI,CAAC,YAAY,CAAE;AAAAd,IAAAA,QAAA,GAExFA,QAAQ,EACRG,OAAO,iBACNsC,cAAA,CAACC,gBAAgB,EAAA;MACfnC,IAAI,EAAEoB,oBAAoB,EAAG;AAC7B1B,MAAAA,SAAS,EAAC,YAAY;MACtB,aAAY,EAAA,yBAAA;AAAyB,KACrC,CACH,CAAA;AAAA,GACM,CAAC,CAAA;AAEd,CAAC,EACF;AAEDN,MAAM,CAACgD,WAAW,GAAG,QAAQ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.mjs","sources":["../../../src/button/LegacyButton/Button.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ElementType, forwardRef, MouseEvent } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport {\n Size,\n ControlType,\n Priority,\n ControlTypeAccent,\n ControlTypeNegative,\n ControlTypePositive,\n PriorityPrimary,\n PrioritySecondary,\n PriorityTertiary,\n SizeExtraSmall,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../../common';\nimport ProcessIndicator from '../../processIndicator';\n\nimport messages from '../../i18n/commonMessages/Button.messages';\nimport { typeClassMap, priorityClassMap } from './classMap';\nimport { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n block?: boolean;\n disabled?: boolean;\n loading?: boolean;\n
|
|
1
|
+
{"version":3,"file":"Button.mjs","sources":["../../../src/button/LegacyButton/Button.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ElementType, forwardRef, MouseEvent } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport {\n Size,\n ControlType,\n Priority,\n ControlTypeAccent,\n ControlTypeNegative,\n ControlTypePositive,\n PriorityPrimary,\n PrioritySecondary,\n PriorityTertiary,\n SizeExtraSmall,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../../common';\nimport ProcessIndicator from '../../processIndicator';\n\nimport messages from '../../i18n/commonMessages/Button.messages';\nimport { typeClassMap, priorityClassMap } from './classMap';\nimport { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n block?: boolean;\n disabled?: boolean;\n loading?: boolean;\n type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;\n size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;\n};\n\nexport type ButtonProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {\n as?: 'button' | undefined;\n htmlType?: 'submit' | 'reset' | 'button';\n };\n\nexport type AnchorProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {\n as?: 'a' | undefined;\n href?: string;\n };\n\nexport type Props = ButtonProps | AnchorProps;\n\nexport type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;\n\nconst Button = forwardRef<ButtonReferenceType, Props>(\n (\n {\n as: component,\n block = false,\n children,\n className,\n disabled,\n loading = false,\n priority = Priority.PRIMARY,\n size = Size.MEDIUM,\n type = ControlType.ACCENT,\n onClick,\n ...rest\n }: Props,\n ref,\n ) => {\n const intl = useIntl();\n\n logDeprecationNotices({ size, type });\n\n const newType = establishNewType(type);\n const newPriority = establishNewPriority(priority, type);\n\n const classes = clsx(\n `btn btn-${size}`,\n `np-btn np-btn-${size}`,\n {\n 'btn-loading': loading,\n 'btn-block np-btn-block': block,\n disabled,\n },\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n typeClassMap[newType],\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n priorityClassMap[newPriority],\n className,\n );\n\n function processIndicatorSize() {\n return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';\n }\n\n const Element = (component as ElementType) ?? 'button';\n let props;\n\n if (Element === 'button') {\n const { htmlType = 'button', ...restProps } = rest as ButtonProps;\n props = {\n ...restProps,\n disabled,\n 'aria-disabled': loading,\n type: htmlType,\n };\n } else {\n props = {\n ...rest,\n 'aria-disabled': loading,\n } as AnchorProps;\n }\n\n /**\n * Ensures that the button cannot be activated in loading or disabled mode,\n * when `aria-disabled` might be used over the `disabled` HTML attribute\n */\n const handleClick =\n (handler: Props['onClick']) =>\n (event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {\n if (disabled || loading) {\n event.preventDefault();\n } else if (typeof handler === 'function') {\n handler(event);\n }\n };\n\n return (\n <Element\n ref={ref}\n className={classes}\n onClick={handleClick(onClick)}\n {...props}\n aria-live={loading ? 'polite' : 'off'}\n aria-busy={loading}\n aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}\n >\n {children}\n {loading && (\n <ProcessIndicator\n size={processIndicatorSize()}\n className=\"btn-loader\"\n data-testid=\"ButtonProgressIndicator\"\n />\n )}\n </Element>\n );\n },\n);\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["Button","forwardRef","as","component","block","children","className","disabled","loading","priority","Priority","PRIMARY","size","Size","MEDIUM","type","ControlType","ACCENT","onClick","rest","ref","intl","useIntl","logDeprecationNotices","newType","establishNewType","newPriority","establishNewPriority","classes","clsx","typeClassMap","priorityClassMap","processIndicatorSize","includes","Element","props","htmlType","restProps","handleClick","handler","event","preventDefault","_jsxs","formatMessage","messages","loadingAriaLabel","_jsx","ProcessIndicator","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAMA,MAAM,gBAAGC,UAAU,CACvB,CACE;AACEC,EAAAA,EAAE,EAAEC,SAAS;AACbC,EAAAA,KAAK,GAAG,KAAK;EACbC,QAAQ;EACRC,SAAS;EACTC,QAAQ;AACRC,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ,GAAGC,QAAQ,CAACC,OAAO;EAC3BC,IAAI,GAAGC,IAAI,CAACC,MAAM;EAClBC,IAAI,GAAGC,WAAW,CAACC,MAAM;EACzBC,OAAO;EACP,GAAGC,IAAAA;AACG,CAAA,EACRC,GAAG,KACD;AACF,EAAA,MAAMC,IAAI,GAAGC,OAAO,EAAE,CAAA;AAEtBC,EAAAA,qBAAqB,CAAC;IAAEX,IAAI;AAAEG,IAAAA,IAAAA;AAAI,GAAE,CAAC,CAAA;AAErC,EAAA,MAAMS,OAAO,GAAGC,gBAAgB,CAACV,IAAI,CAAC,CAAA;AACtC,EAAA,MAAMW,WAAW,GAAGC,oBAAoB,CAAClB,QAAQ,EAAEM,IAAI,CAAC,CAAA;EAExD,MAAMa,OAAO,GAAGC,IAAI,CAClB,CAAA,QAAA,EAAWjB,IAAI,CAAA,CAAE,EACjB,CAAA,cAAA,EAAiBA,IAAI,CAAA,CAAE,EACvB;AACE,IAAA,aAAa,EAAEJ,OAAO;AACtB,IAAA,wBAAwB,EAAEJ,KAAK;AAC/BG,IAAAA,QAAAA;GACD;AACD;AACA;EACAuB,YAAY,CAACN,OAAO,CAAC;AACrB;AACA;AACAO,EAAAA,gBAAgB,CAACL,WAAW,CAAC,EAC7BpB,SAAS,CACV,CAAA;EAED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I,CAACsB,aAAa,CAACC,QAAQ,CAACC,gBAAgB,CAAC,GAAG1B,IAAI,CAAC,YAAY,CAAE;AAAAd,IAAAA,QAAA,GAExFA,QAAQ,EACRG,OAAO,iBACNsC,GAAA,CAACC,gBAAgB,EAAA;MACfnC,IAAI,EAAEoB,oBAAoB,EAAG;AAC7B1B,MAAAA,SAAS,EAAC,YAAY;MACtB,aAAY,EAAA,yBAAA;AAAyB,KACrC,CACH,CAAA;AAAA,GACM,CAAC,CAAA;AAEd,CAAC,EACF;AAEDN,MAAM,CAACgD,WAAW,GAAG,QAAQ;;;;"}
|
|
@@ -5,14 +5,15 @@ var Button$2 = require('../LegacyButton/Button.js');
|
|
|
5
5
|
var Button$1 = require('../Button/src/Button.js');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
9
|
+
const mapProps = props => {
|
|
9
10
|
const {
|
|
10
11
|
priority,
|
|
11
12
|
size,
|
|
12
13
|
type,
|
|
13
14
|
as,
|
|
14
|
-
...
|
|
15
|
-
} =
|
|
15
|
+
...newProps
|
|
16
|
+
} = props;
|
|
16
17
|
const priorityMapping = {
|
|
17
18
|
accent: {
|
|
18
19
|
primary: 'primary',
|
|
@@ -32,16 +33,13 @@ const mapProps = legacyProps => {
|
|
|
32
33
|
};
|
|
33
34
|
const mappedPriority = type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
|
|
34
35
|
const mappedAppearance = type === 'negative' ? 'negative' : undefined;
|
|
35
|
-
// Map the type to the new button's expected types
|
|
36
|
-
const mappedType = as === 'button' ? legacyProps.htmlType : undefined;
|
|
37
36
|
return {
|
|
38
|
-
|
|
37
|
+
...newProps,
|
|
38
|
+
size: size === 'xs' || size === 'sm' ? 'sm' : size === 'md' ? 'md' : size === 'lg' ? 'lg' : size,
|
|
39
39
|
priority: mappedPriority,
|
|
40
|
-
appearance: mappedAppearance
|
|
41
|
-
type:
|
|
42
|
-
|
|
43
|
-
href: as === 'a' ? legacyProps.href : undefined,
|
|
44
|
-
...props
|
|
40
|
+
appearance: mappedAppearance || ('appearance' in props ? props.appearance : undefined),
|
|
41
|
+
type: as === 'button' ? props.htmlType : undefined,
|
|
42
|
+
href: as === 'a' ? props.href || '' : undefined
|
|
45
43
|
};
|
|
46
44
|
};
|
|
47
45
|
const Button = /*#__PURE__*/React.forwardRef(({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../src/button/src/Button.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../src/button/src/Button.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { forwardRef } from 'react';\nimport LegacyButton, { ButtonProps as LegacyButtonProps } from '../LegacyButton';\nimport NewButton from '../Button';\nimport { ButtonProps as NewButtonProps } from '../Button/src/Button.types';\n\nexport type ButtonProps = {\n useNewButton?: boolean;\n} & (LegacyButtonProps | NewButtonProps);\n\nconst mapProps = (props: LegacyButtonProps): NewButtonProps => {\n const { priority, size, type, as, ...newProps } = props;\n\n const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {\n accent: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'minimal',\n },\n positive: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'tertiary',\n },\n negative: {\n primary: 'primary',\n secondary: 'secondary',\n tertiary: 'secondary',\n },\n };\n\n const mappedPriority =\n type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;\n const mappedAppearance = type === 'negative' ? 'negative' : undefined;\n\n return {\n ...newProps,\n size:\n size === 'xs' || size === 'sm' ? 'sm' : size === 'md' ? 'md' : size === 'lg' ? 'lg' : size,\n priority: mappedPriority,\n appearance: mappedAppearance || ('appearance' in props ? props.appearance : undefined),\n type: as === 'button' ? props.htmlType : undefined,\n href: as === 'a' ? props.href || '' : undefined,\n } as NewButtonProps;\n};\n\nconst Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(\n ({ useNewButton = false, ...props }, ref) => {\n if (useNewButton) {\n const mappedProps = mapProps(props as LegacyButtonProps);\n return <NewButton {...mappedProps} ref={ref as any} />;\n }\n\n return <LegacyButton {...(props as LegacyButtonProps)} ref={ref} />;\n },\n);\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["mapProps","props","priority","size","type","as","newProps","priorityMapping","accent","primary","secondary","tertiary","positive","negative","mappedPriority","undefined","mappedAppearance","appearance","htmlType","href","Button","forwardRef","useNewButton","ref","mappedProps","_jsx","NewButton","LegacyButton","displayName"],"mappings":";;;;;;;AAAA;AAUA,MAAMA,QAAQ,GAAIC,KAAwB,IAAoB;EAC5D,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,IAAI;IAAEC,EAAE;IAAE,GAAGC,QAAAA;AAAU,GAAA,GAAGL,KAAK,CAAA;AAEvD,EAAA,MAAMM,eAAe,GAA+D;AAClFC,IAAAA,MAAM,EAAE;AACNC,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAAE,UAAU;AACrBC,MAAAA,QAAQ,EAAE,SAAA;KACX;AACDC,IAAAA,QAAQ,EAAE;AACRH,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAAE,UAAU;AACrBC,MAAAA,QAAQ,EAAE,UAAA;KACX;AACDE,IAAAA,QAAQ,EAAE;AACRJ,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAAE,WAAW;AACtBC,MAAAA,QAAQ,EAAE,WAAA;AACX,KAAA;GACF,CAAA;AAED,EAAA,MAAMG,cAAc,GAClBV,IAAI,IAAIF,QAAQ,GAAGK,eAAe,CAACH,IAAI,CAAC,GAAGF,QAAQ,CAAC,IAAIA,QAAQ,GAAGA,QAAQ,IAAIa,SAAS,CAAA;EAC1F,MAAMC,gBAAgB,GAAGZ,IAAI,KAAK,UAAU,GAAG,UAA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-runtime';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
7
|
+
const mapProps = props => {
|
|
7
8
|
const {
|
|
8
9
|
priority,
|
|
9
10
|
size,
|
|
10
11
|
type,
|
|
11
12
|
as,
|
|
12
|
-
...
|
|
13
|
-
} =
|
|
13
|
+
...newProps
|
|
14
|
+
} = props;
|
|
14
15
|
const priorityMapping = {
|
|
15
16
|
accent: {
|
|
16
17
|
primary: 'primary',
|
|
@@ -30,16 +31,13 @@ const mapProps = legacyProps => {
|
|
|
30
31
|
};
|
|
31
32
|
const mappedPriority = type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
|
|
32
33
|
const mappedAppearance = type === 'negative' ? 'negative' : undefined;
|
|
33
|
-
// Map the type to the new button's expected types
|
|
34
|
-
const mappedType = as === 'button' ? legacyProps.htmlType : undefined;
|
|
35
34
|
return {
|
|
36
|
-
|
|
35
|
+
...newProps,
|
|
36
|
+
size: size === 'xs' || size === 'sm' ? 'sm' : size === 'md' ? 'md' : size === 'lg' ? 'lg' : size,
|
|
37
37
|
priority: mappedPriority,
|
|
38
|
-
appearance: mappedAppearance
|
|
39
|
-
type:
|
|
40
|
-
|
|
41
|
-
href: as === 'a' ? legacyProps.href : undefined,
|
|
42
|
-
...props
|
|
38
|
+
appearance: mappedAppearance || ('appearance' in props ? props.appearance : undefined),
|
|
39
|
+
type: as === 'button' ? props.htmlType : undefined,
|
|
40
|
+
href: as === 'a' ? props.href || '' : undefined
|
|
43
41
|
};
|
|
44
42
|
};
|
|
45
43
|
const Button = /*#__PURE__*/forwardRef(({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.mjs","sources":["../../../src/button/src/Button.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"Button.mjs","sources":["../../../src/button/src/Button.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { forwardRef } from 'react';\nimport LegacyButton, { ButtonProps as LegacyButtonProps } from '../LegacyButton';\nimport NewButton from '../Button';\nimport { ButtonProps as NewButtonProps } from '../Button/src/Button.types';\n\nexport type ButtonProps = {\n useNewButton?: boolean;\n} & (LegacyButtonProps | NewButtonProps);\n\nconst mapProps = (props: LegacyButtonProps): NewButtonProps => {\n const { priority, size, type, as, ...newProps } = props;\n\n const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {\n accent: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'minimal',\n },\n positive: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'tertiary',\n },\n negative: {\n primary: 'primary',\n secondary: 'secondary',\n tertiary: 'secondary',\n },\n };\n\n const mappedPriority =\n type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;\n const mappedAppearance = type === 'negative' ? 'negative' : undefined;\n\n return {\n ...newProps,\n size:\n size === 'xs' || size === 'sm' ? 'sm' : size === 'md' ? 'md' : size === 'lg' ? 'lg' : size,\n priority: mappedPriority,\n appearance: mappedAppearance || ('appearance' in props ? props.appearance : undefined),\n type: as === 'button' ? props.htmlType : undefined,\n href: as === 'a' ? props.href || '' : undefined,\n } as NewButtonProps;\n};\n\nconst Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(\n ({ useNewButton = false, ...props }, ref) => {\n if (useNewButton) {\n const mappedProps = mapProps(props as LegacyButtonProps);\n return <NewButton {...mappedProps} ref={ref as any} />;\n }\n\n return <LegacyButton {...(props as LegacyButtonProps)} ref={ref} />;\n },\n);\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["mapProps","props","priority","size","type","as","newProps","priorityMapping","accent","primary","secondary","tertiary","positive","negative","mappedPriority","undefined","mappedAppearance","appearance","htmlType","href","Button","forwardRef","useNewButton","ref","mappedProps","_jsx","NewButton","LegacyButton","displayName"],"mappings":";;;;;AAAA;AAUA,MAAMA,QAAQ,GAAIC,KAAwB,IAAoB;EAC5D,MAAM;IAAEC,QAAQ;I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AK,CAACkB,IAAI,IAAI,EAAE,GAAGJ,SAAAA;GACrB,CAAA;AACrB,CAAC,CAAA;AAED,MAAMK,MAAM,gBAAGC,UAAU,CACvB,CAAC;AAAEC,EAAAA,YAAY,GAAG,KAAK;EAAE,GAAGrB,KAAAA;AAAK,CAAE,EAAEsB,GAAG,KAAI;AAC1C,EAAA,IAAID,YAAY,EAAE;AAChB,IAAA,MAAME,WAAW,GAAGxB,QAAQ,CAACC,KAA0B,CAAC,CAAA;IACxD,oBAAOwB,GAAA,CAACC,QAAS,EAAA;AAAA,MAAA,GAAKF,WAAW;AAAED,MAAAA,GAAG,EAAEA,GAAAA;AAAW,MAAG,CAAA;AACxD,GAAA;EAEA,oBAAOE,GAAA,CAACE,QAAY,EAAA;AAAA,IAAA,GAAM1B,KAA2B;AAAEsB,IAAAA,GAAG,EAAEA,GAAAA;AAAI,IAAG,CAAA;AACrE,CAAC,EACF;AAEDH,MAAM,CAACQ,WAAW,GAAG,QAAQ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../src/button/Button/src/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AASnD,QAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../src/button/Button/src/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AASnD,QAAA,MAAM,MAAM,qNAsGX,CAAC;AAIF,eAAe,MAAM,CAAC"}
|
|
@@ -18,6 +18,7 @@ export interface CommonButtonProps {
|
|
|
18
18
|
children?: ReactNode;
|
|
19
19
|
/** Whether the button is disabled */
|
|
20
20
|
disabled?: boolean;
|
|
21
|
+
href?: string;
|
|
21
22
|
/** Whether the button is in a loading state */
|
|
22
23
|
loading?: boolean;
|
|
23
24
|
/** Whether the button should take up the full width of its container */
|
|
@@ -1 +1 @@
|
|
|
1
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IAErB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,+CAA+C;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,wEAAwE;IACxE,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,yBAAyB;IACzB,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAE1B;;;OAGG;IACH,UAAU,CAAC,EAAE,eAAe,CAAC;IAE7B,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IAE7B,2DAA2D;IAC3D,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IAE9B,2DAA2D;IAC3D,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAE7B,iDAAiD;IACjD,GAAG,CAAC,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,GAAG,iBAAiB,CAAC;AAC1E,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,GAAG,iBAAiB,CAAC;AAC1E,MAAM,MAAM,WAAW,GAAG,kBAAkB,GAAG,kBAAkB,CAAC"}
|
|
@@ -7,18 +7,17 @@ type CommonProps = {
|
|
|
7
7
|
block?: boolean;
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
loading?: boolean;
|
|
10
|
-
/** @deprecated */
|
|
11
10
|
type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;
|
|
12
11
|
priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;
|
|
13
12
|
size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;
|
|
14
13
|
};
|
|
15
14
|
export type ButtonProps = CommonProps & Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {
|
|
16
15
|
as?: 'button' | undefined;
|
|
17
|
-
/** @deprecated */
|
|
18
16
|
htmlType?: 'submit' | 'reset' | 'button';
|
|
19
17
|
};
|
|
20
18
|
export type AnchorProps = CommonProps & Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {
|
|
21
19
|
as?: 'a' | undefined;
|
|
20
|
+
href?: string;
|
|
22
21
|
};
|
|
23
22
|
export type Props = ButtonProps | AnchorProps;
|
|
24
23
|
export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/button/LegacyButton/Button.tsx"],"names":[],"mappings":"AAIA,OAAO,EAIL,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,UAAU,EACV,SAAS,EACV,MAAM,cAAc,CAAC;AAOtB,kBAAkB;AAClB,KAAK,eAAe,GAAG,SAAS,GAAG,KAAK,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE3E,kBAAkB;AAClB,KAAK,eAAe,GAAG,cAAc,CAAC;AAEtC,KAAK,WAAW,GAAG;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/button/LegacyButton/Button.tsx"],"names":[],"mappings":"AAIA,OAAO,EAIL,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,UAAU,EACV,SAAS,EACV,MAAM,cAAc,CAAC;AAOtB,kBAAkB;AAClB,KAAK,eAAe,GAAG,SAAS,GAAG,KAAK,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE3E,kBAAkB;AAClB,KAAK,eAAe,GAAG,cAAc,CAAC;AAEtC,KAAK,WAAW,GAAG;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,iBAAiB,GAAG,mBAAmB,GAAG,mBAAmB,GAAG,eAAe,GAAG,IAAI,CAAC;IAC9F,QAAQ,CAAC,EAAE,eAAe,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,IAAI,CAAC;IACzE,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,eAAe,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,WAAW,GACnC,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG;IACpD,EAAE,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;CAC1C,CAAC;AAEJ,MAAM,MAAM,WAAW,GAAG,WAAW,GACnC,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG;IAC/C,EAAE,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEJ,MAAM,MAAM,KAAK,GAAG,WAAW,GAAG,WAAW,CAAC;AAE9C,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAExE,QAAA,MAAM,MAAM,uJAkGX,CAAC;AAIF,eAAe,MAAM,CAAC"}
|
|
@@ -30,6 +30,7 @@ declare const Button: import("react").ForwardRefExoticComponent<(Omit<{
|
|
|
30
30
|
ref?: ((instance: HTMLAnchorElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLAnchorElement> | null | undefined;
|
|
31
31
|
}, "type"> & {
|
|
32
32
|
as?: "a" | undefined;
|
|
33
|
+
href?: string;
|
|
33
34
|
}, "ref"> | Omit<{
|
|
34
35
|
useNewButton?: boolean;
|
|
35
36
|
} & import("../../primitives").PrimitiveButtonProps & import("../Button/src/Button.types").CommonButtonProps, "ref"> | Omit<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/button/src/Button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/button/src/Button.tsx"],"names":[],"mappings":"AAEA,OAAqB,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEjF,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GAAG,CAAC,iBAAiB,GAAG,cAAc,CAAC,CAAC;AAsCzC,QAAA,MAAM,MAAM;mBAvCK,OAAO;;;;;;;;;;;;;;mBAAP,OAAO;;;;;;;;;;;;;;mBAAP,OAAO;;mBAAP,OAAO;6LAgDvB,CAAC;AAIF,eAAe,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-0ee6ecc",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -92,12 +92,12 @@
|
|
|
92
92
|
"rollup-preserve-directives": "^1.1.1",
|
|
93
93
|
"storybook": "^8.2.2",
|
|
94
94
|
"@transferwise/less-config": "3.1.0",
|
|
95
|
-
"@transferwise/neptune-css": "0.0.0-experimental-
|
|
95
|
+
"@transferwise/neptune-css": "0.0.0-experimental-0ee6ecc",
|
|
96
96
|
"@wise/components-theming": "1.6.1"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"@transferwise/icons": "^3.13.1",
|
|
100
|
-
"@transferwise/neptune-css": "0.0.0-experimental-
|
|
100
|
+
"@transferwise/neptune-css": "0.0.0-experimental-0ee6ecc",
|
|
101
101
|
"@wise/art": "^2.16",
|
|
102
102
|
"@wise/components-theming": "^1.0.0",
|
|
103
103
|
"react": ">=18",
|
|
@@ -14,6 +14,7 @@ const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(
|
|
|
14
14
|
children,
|
|
15
15
|
className,
|
|
16
16
|
size = 'md',
|
|
17
|
+
href,
|
|
17
18
|
priority = 'primary',
|
|
18
19
|
appearance = 'default',
|
|
19
20
|
iconLeft: LeftIcon,
|
|
@@ -86,6 +87,7 @@ const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(
|
|
|
86
87
|
<PrimitiveAnchor
|
|
87
88
|
ref={ref as React.Ref<HTMLAnchorElement>}
|
|
88
89
|
{...(props as any)}
|
|
90
|
+
href={href}
|
|
89
91
|
className={classNames}
|
|
90
92
|
disabled={props.disabled}
|
|
91
93
|
>
|
|
@@ -33,7 +33,6 @@ type CommonProps = {
|
|
|
33
33
|
block?: boolean;
|
|
34
34
|
disabled?: boolean;
|
|
35
35
|
loading?: boolean;
|
|
36
|
-
/** @deprecated */
|
|
37
36
|
type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;
|
|
38
37
|
priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;
|
|
39
38
|
size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;
|
|
@@ -42,13 +41,13 @@ type CommonProps = {
|
|
|
42
41
|
export type ButtonProps = CommonProps &
|
|
43
42
|
Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {
|
|
44
43
|
as?: 'button' | undefined;
|
|
45
|
-
/** @deprecated */
|
|
46
44
|
htmlType?: 'submit' | 'reset' | 'button';
|
|
47
45
|
};
|
|
48
46
|
|
|
49
47
|
export type AnchorProps = CommonProps &
|
|
50
48
|
Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {
|
|
51
49
|
as?: 'a' | undefined;
|
|
50
|
+
href?: string;
|
|
52
51
|
};
|
|
53
52
|
|
|
54
53
|
export type Props = ButtonProps | AnchorProps;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
1
2
|
import { forwardRef } from 'react';
|
|
2
3
|
import LegacyButton, { ButtonProps as LegacyButtonProps } from '../LegacyButton';
|
|
3
4
|
import NewButton from '../Button';
|
|
@@ -7,9 +8,8 @@ export type ButtonProps = {
|
|
|
7
8
|
useNewButton?: boolean;
|
|
8
9
|
} & (LegacyButtonProps | NewButtonProps);
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const { priority, size, type, as, ...props } = legacyProps;
|
|
11
|
+
const mapProps = (props: LegacyButtonProps): NewButtonProps => {
|
|
12
|
+
const { priority, size, type, as, ...newProps } = props;
|
|
13
13
|
|
|
14
14
|
const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {
|
|
15
15
|
accent: {
|
|
@@ -31,20 +31,16 @@ const mapProps = (legacyProps: LegacyButtonProps): NewButtonProps => {
|
|
|
31
31
|
|
|
32
32
|
const mappedPriority =
|
|
33
33
|
type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
|
|
34
|
-
|
|
35
34
|
const mappedAppearance = type === 'negative' ? 'negative' : undefined;
|
|
36
35
|
|
|
37
|
-
// Map the type to the new button's expected types
|
|
38
|
-
const mappedType = as === 'button' ? legacyProps.htmlType : undefined;
|
|
39
|
-
|
|
40
36
|
return {
|
|
41
|
-
|
|
37
|
+
...newProps,
|
|
38
|
+
size:
|
|
39
|
+
size === 'xs' || size === 'sm' ? 'sm' : size === 'md' ? 'md' : size === 'lg' ? 'lg' : size,
|
|
42
40
|
priority: mappedPriority,
|
|
43
|
-
appearance:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
href: as === 'a' ? legacyProps.href : undefined,
|
|
47
|
-
...props,
|
|
41
|
+
appearance: mappedAppearance || ('appearance' in props ? props.appearance : undefined),
|
|
42
|
+
type: as === 'button' ? props.htmlType : undefined,
|
|
43
|
+
href: as === 'a' ? props.href || '' : undefined,
|
|
48
44
|
} as NewButtonProps;
|
|
49
45
|
};
|
|
50
46
|
|
|
@@ -52,7 +48,7 @@ const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(
|
|
|
52
48
|
({ useNewButton = false, ...props }, ref) => {
|
|
53
49
|
if (useNewButton) {
|
|
54
50
|
const mappedProps = mapProps(props as LegacyButtonProps);
|
|
55
|
-
return <NewButton {...mappedProps} ref={ref} />;
|
|
51
|
+
return <NewButton {...mappedProps} ref={ref as any} />;
|
|
56
52
|
}
|
|
57
53
|
|
|
58
54
|
return <LegacyButton {...(props as LegacyButtonProps)} ref={ref} />;
|