@flipdish/portal-library 6.0.1 → 7.0.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/components/atoms/Card/index.cjs.js +1 -1
- package/dist/components/atoms/Card/index.cjs.js.map +1 -1
- package/dist/components/atoms/Card/index.d.ts +23 -2
- package/dist/components/atoms/Card/index.js +1 -1
- package/dist/components/atoms/Card/index.js.map +1 -1
- package/dist/components/atoms/Link/index.cjs.js.map +1 -1
- package/dist/components/atoms/Link/index.d.ts +1 -0
- package/dist/components/atoms/Link/index.js.map +1 -1
- package/dist/components/atoms/Switch/index.cjs.js +2 -0
- package/dist/components/atoms/Switch/index.cjs.js.map +1 -0
- package/dist/components/atoms/Switch/index.d.ts +24 -0
- package/dist/components/atoms/Switch/index.js +2 -0
- package/dist/components/atoms/Switch/index.js.map +1 -0
- package/dist/components/atoms/Text/index.cjs.js +2 -0
- package/dist/components/atoms/Text/index.cjs.js.map +1 -0
- package/dist/components/atoms/Text/index.d.ts +9 -0
- package/dist/components/atoms/Text/index.js +2 -0
- package/dist/components/atoms/Text/index.js.map +1 -0
- package/package.json +1 -1
- package/dist/components/Switch/index.cjs.js +0 -2
- package/dist/components/Switch/index.cjs.js.map +0 -1
- package/dist/components/Switch/index.d.ts +0 -17
- package/dist/components/Switch/index.js +0 -2
- package/dist/components/Switch/index.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var r=require("@mui/material/Card");module.exports=r;
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("@mui/material/Box"),r=require("@mui/material/Card"),i=require("@mui/material/CardContent"),n=require("@mui/material/CardMedia"),a=require("@mui/material/styles"),s=require("@mui/material/Typography"),o=require("../../../icons/ArrowRight02/index.cjs.js"),l=require("../Badge/index.cjs.js"),d=require("../IconContainer/index.cjs.js"),c=require("../Link/index.cjs.js");const h=a.styled(r)((({theme:e,type:t})=>({borderRadius:e.radius["radius-16"],border:`1px solid ${e.palette.semantic.stroke["stroke-weak"]}`,..."horizontal"===t&&{display:"flex",flexDirection:"row",overflow:"hidden"}}))),m=a.styled(i)((({theme:e,type:t})=>({"&:last-child":{paddingBottom:e.spacing(2)},..."horizontal"===t&&{flex:1,display:"flex",flexDirection:"column",justifyContent:"space-between"}}))),p=a.styled(t)((({theme:e})=>({display:"flex",alignItems:"flex-start",gap:e.spacing(2),flex:1}))),u=a.styled(t)((()=>({flex:1,display:"flex",flexDirection:"column"}))),x=a.styled(s)((({theme:e})=>({marginBottom:e.spacing(1)}))),g=a.styled(t)((({theme:e})=>({marginTop:e.spacing(1.5)}))),y=a.styled(c.Link)((({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1)}))),f=a.styled(n)((({theme:e,type:t})=>({..."horizontal"===t?{width:200,height:"auto",borderRight:`1px solid ${e.palette.semantic.stroke["stroke-weak"]}`,borderBottom:"none",flexShrink:0}:{height:204,borderBottom:`1px solid ${e.palette.semantic.stroke["stroke-weak"]}`}}))),j=a.styled(t,{shouldForwardProp:e=>!["hasIcon","hasBadge"].includes(e)})((({theme:e,hasIcon:t,hasBadge:r})=>({display:"flex",flexDirection:"row",justifyContent:r&&!t?"flex-end":"space-between",alignItems:"flex-start",gap:e.spacing(2),marginBottom:e.spacing(1.5)})));module.exports=({fdKey:t,heading:r,content:i,imageSrc:n,icon:a,badge:c,link:k,onMouseEnter:w,onMouseLeave:b,type:C="vertical",...q})=>{if(a&&(B=a,B?.type!==d))throw new Error("Card icon prop must be an IconContainer component");var B;if(c&&!(e=>e?.type===l.default)(c))throw new Error("Card badge prop must be a Badge component");const v=!!c||!!a,I=()=>k?e.jsx(g,{children:e.jsx(y,{fdKey:`card-link-${k.label}`,href:k.href,iconRight:e.jsx(o,{}),onClick:k.onClick,underline:!1,children:k.label})}):null,M=()=>e.jsx(x,{variant:"h4Strong",children:r}),z=()=>e.jsx(s,{variant:"b1Weak",children:i});return e.jsxs(h,{"data-fd":t,type:C,...q,onMouseEnter:w,onMouseLeave:b,children:[n?e.jsx(f,{image:n,type:C}):null,e.jsx(m,{type:C,children:"horizontal"===C?e.jsxs(e.Fragment,{children:[e.jsxs(p,{children:[a&&a,e.jsxs(u,{children:[M(),z()]}),c&&c]}),I()]}):e.jsxs(e.Fragment,{children:[v&&e.jsxs(j,{hasBadge:!!c,hasIcon:!!a,children:[a&&a,c&&c]}),M(),z(),I()]})})]})};
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../../src/components/atoms/Card/index.tsx"],"sourcesContent":["\nimport Box from '@mui/material/Box';\nimport MuiCard from '@mui/material/Card';\nimport CardContent from '@mui/material/CardContent';\nimport CardMedia from '@mui/material/CardMedia';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nimport RightArrowIcon from '../../../icons/ArrowRight02';\nimport Badge from '../Badge';\nimport IconContainer from '../IconContainer';\nimport Link, { type LinkProps } from '../Link';\n\nexport interface CardProps {\n fdKey?: string;\n heading: string;\n content: string;\n imageSrc?: string;\n icon?: React.ReactElement<typeof IconContainer>;\n badge?: React.ReactElement<typeof Badge>;\n link?: {\n label: string;\n href?: string;\n onClick?: () => void;\n }\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n type?: 'horizontal' | 'vertical';\n}\n\nconst StyledCard = styled(MuiCard)<{ type?: 'horizontal' | 'vertical' }>(({ theme, type }) => ({\n borderRadius: theme.radius['radius-16'],\n border: `1px solid ${theme.palette.semantic.stroke['stroke-weak']}`,\n ...(type === 'horizontal' && {\n display: 'flex',\n flexDirection: 'row',\n overflow: 'hidden',\n }),\n}));\n\nconst StyledCardContent = styled(CardContent)<{ type?: 'horizontal' | 'vertical' }>(({ theme, type }) => ({\n '&:last-child': {\n paddingBottom: theme.spacing(2),\n },\n ...(type === 'horizontal' && {\n flex: 1,\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'space-between',\n }),\n}));\n\nconst StyledHorizontalContentWrapper = styled(Box)(({ theme }) => ({\n display: 'flex',\n alignItems: 'flex-start',\n gap: theme.spacing(2),\n flex: 1,\n}));\n\nconst StyledHorizontalTextContent = styled(Box)(() => ({\n flex: 1,\n display: 'flex',\n flexDirection: 'column',\n}));\n\nconst StyledHeading = styled(Typography)(({ theme }) => ({\n marginBottom: theme.spacing(1),\n}));\n\nconst StyledLinkContainer = styled(Box)(({ theme }) => ({\n marginTop: theme.spacing(1.5),\n}));\n\nconst StyledLink = styled(Link)<{ component?: LinkProps['component'] }>(({ theme }) => ({\n display: 'flex',\n alignItems: 'center',\n gap: theme.spacing(1),\n}));\n\nconst StyledCardMedia = styled(CardMedia)<{ type?: 'horizontal' | 'vertical' }>(({ theme, type }) => ({\n ...(type === 'horizontal' ? {\n width: 200,\n height: 'auto',\n borderRight: `1px solid ${theme.palette.semantic.stroke['stroke-weak']}`,\n borderBottom: 'none',\n flexShrink: 0,\n } : {\n height: 204,\n borderBottom: `1px solid ${theme.palette.semantic.stroke['stroke-weak']}`,\n }),\n}));\n\ninterface StyledTopContentContainerProps {\n hasIcon: boolean;\n hasBadge: boolean;\n}\n\nconst StyledTopContentContainer = styled(Box, {\n shouldForwardProp: (prop) => !['hasIcon', 'hasBadge'].includes(prop as string),\n})<StyledTopContentContainerProps>(({ theme, hasIcon, hasBadge }) => {\n\n const onlyHasRightContent = hasBadge && !hasIcon;\n return {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: onlyHasRightContent ? 'flex-end' : 'space-between',\n alignItems: 'flex-start',\n gap: theme.spacing(2),\n marginBottom: theme.spacing(1.5),\n }\n});\n\n// Validation function to ensure only IconContainer components are passed\nconst isValidIconContainer = (element: React.ReactElement): boolean => {\n return element?.type === IconContainer;\n};\n\nconst isValidBadge = (element: React.ReactElement): boolean => {\n return element?.type === Badge;\n};\n\nconst Card = ({\n fdKey,\n heading,\n content,\n imageSrc,\n icon,\n badge,\n link,\n onMouseEnter,\n onMouseLeave,\n type = 'vertical',\n ...rest\n}: CardProps): React.ReactElement => {\n if (icon && !isValidIconContainer(icon)) {\n throw new Error('Card icon prop must be an IconContainer component');\n }\n if (badge && !isValidBadge(badge)) {\n throw new Error('Card badge prop must be a Badge component');\n }\n\n const hasTopContent = !!badge || !!icon;\n\n const renderImage = (): React.ReactElement | null => {\n if (!imageSrc) return null;\n return <StyledCardMedia image={imageSrc} type={type} />;\n };\n\n const renderLink = (): React.ReactElement | null => {\n if (!link) return null;\n return (\n <StyledLinkContainer>\n <StyledLink\n fdKey={`card-link-${link.label}`}\n href={link.href}\n iconRight={<RightArrowIcon />}\n onClick={link.onClick}\n underline={false}\n >\n {link.label}\n </StyledLink>\n </StyledLinkContainer>\n );\n };\n\n const renderHeading = (): React.ReactElement => {\n return (\n <StyledHeading variant=\"h4Strong\">\n {heading}\n </StyledHeading>\n );\n };\n\n const renderContent = (): React.ReactElement => {\n return (\n <Typography variant=\"b1Weak\">\n {content}\n </Typography>\n );\n };\n\n const renderHorizontalContent = (): React.ReactElement => {\n return (\n <>\n <StyledHorizontalContentWrapper>\n {icon && icon}\n <StyledHorizontalTextContent>\n {renderHeading()}\n {renderContent()}\n </StyledHorizontalTextContent>\n {badge && badge}\n </StyledHorizontalContentWrapper>\n {renderLink()}\n </>\n );\n };\n\n const renderVerticalContent = (): React.ReactElement => {\n return (\n <>\n {hasTopContent && (\n <StyledTopContentContainer hasBadge={!!badge} hasIcon={!!icon}>\n {icon && icon}\n {badge && badge}\n </StyledTopContentContainer>\n )}\n {renderHeading()}\n {renderContent()}\n {renderLink()}\n </>\n );\n };\n\n const renderCardContent = (): React.ReactElement => {\n if (type === 'horizontal') {\n return renderHorizontalContent();\n }\n return renderVerticalContent();\n };\n\n return (\n <StyledCard data-fd={fdKey} type={type} {...rest} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>\n {renderImage()}\n <StyledCardContent type={type}>\n {renderCardContent()}\n </StyledCardContent>\n </StyledCard>\n );\n};\n\nexport default Card;"],"names":["StyledCard","styled","MuiCard","theme","type","borderRadius","radius","border","palette","semantic","stroke","display","flexDirection","overflow","StyledCardContent","CardContent","paddingBottom","spacing","flex","justifyContent","StyledHorizontalContentWrapper","Box","alignItems","gap","StyledHorizontalTextContent","StyledHeading","Typography","marginBottom","StyledLinkContainer","marginTop","StyledLink","Link","StyledCardMedia","CardMedia","width","height","borderRight","borderBottom","flexShrink","StyledTopContentContainer","shouldForwardProp","prop","includes","hasIcon","hasBadge","fdKey","heading","content","imageSrc","icon","badge","link","onMouseEnter","onMouseLeave","rest","element","IconContainer","Error","Badge","isValidBadge","hasTopContent","renderLink","_jsx","label","href","iconRight","RightArrowIcon","onClick","underline","renderHeading","variant","children","renderContent","_jsxs","image","_Fragment"],"mappings":"yaA8BA,MAAMA,EAAaC,EAAAA,OAAOC,EAAPD,EAAsD,EAAGE,QAAOC,WAAM,CACvFC,aAAcF,EAAMG,OAAO,aAC3BC,OAAQ,aAAaJ,EAAMK,QAAQC,SAASC,OAAO,oBACtC,eAATN,GAAyB,CAC3BO,QAAS,OACTC,cAAe,MACfC,SAAU,cAIRC,EAAoBb,EAAAA,OAAOc,EAAPd,EAA0D,EAAGE,QAAOC,WAAM,CAClG,eAAgB,CACdY,cAAeb,EAAMc,QAAQ,OAElB,eAATb,GAAyB,CAC3Bc,KAAM,EACNP,QAAS,OACTC,cAAe,SACfO,eAAgB,qBAIdC,EAAiCnB,EAAAA,OAAOoB,EAAPpB,EAAY,EAAGE,YAAO,CAC3DQ,QAAS,OACTW,WAAY,aACZC,IAAKpB,EAAMc,QAAQ,GACnBC,KAAM,MAGFM,EAA8BvB,EAAAA,OAAOoB,EAAPpB,EAAY,KAAA,CAC9CiB,KAAM,EACNP,QAAS,OACTC,cAAe,aAGXa,EAAgBxB,EAAAA,OAAOyB,EAAPzB,EAAmB,EAAGE,YAAO,CACjDwB,aAAcxB,EAAMc,QAAQ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W,WAEVjB,EAAKY,UAVM,KAgBdM,EAAgB,IAElBP,EAAAA,IAACrC,EAAa,CAAC6C,QAAQ,WAAUC,SAC9BzB,IAKD0B,EAAgB,IAElBV,EAAAA,IAACpC,EAAU,CAAC4C,QAAQ,SAAQC,SACzBxB,IA4CP,OACE0B,OAACzE,EAAU,CAAA,UAAU6C,EAAOzC,KAAMA,KAAUkD,EAAMF,aAAcA,EAAcC,aAAcA,YA7EvFL,EACEc,EAAAA,IAAC9B,EAAe,CAAC0C,MAAO1B,EAAU5C,KAAMA,IADzB,KA+EpB0D,EAAAA,IAAChD,EAAiB,CAACV,KAAMA,WATd,eAATA,EA/BFqE,OAAAE,EAAAA,SAAA,CAAAJ,SAAA,CACEE,EAAAA,KAACrD,EAA8B,CAAAmD,SAAA,CAC5BtB,GAAQA,EACTwB,EAAAA,KAACjD,EAA2B,CAAA+C,SAAA,CACzBF,IACAG,OAEFtB,GAASA,KAEXW,OAOHY,EAAAA,KAAAE,EAAAA,SAAA,CAAAJ,SAAA,CACGX,GACCa,EAAAA,KAAClC,EAAyB,CAACK,WAAYM,EAAOP,UAAWM,EAAIsB,SAAA,CAC1DtB,GAAQA,EACRC,GAASA,KAGbmB,IACAG,IACAX"}
|
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import Badge from '../Badge/index.js';
|
|
2
|
+
import IconContainer from '../IconContainer/index.js';
|
|
3
|
+
|
|
4
|
+
interface CardProps {
|
|
5
|
+
fdKey?: string;
|
|
6
|
+
heading: string;
|
|
7
|
+
content: string;
|
|
8
|
+
imageSrc?: string;
|
|
9
|
+
icon?: React.ReactElement<typeof IconContainer>;
|
|
10
|
+
badge?: React.ReactElement<typeof Badge>;
|
|
11
|
+
link?: {
|
|
12
|
+
label: string;
|
|
13
|
+
href?: string;
|
|
14
|
+
onClick?: () => void;
|
|
15
|
+
};
|
|
16
|
+
onMouseEnter?: () => void;
|
|
17
|
+
onMouseLeave?: () => void;
|
|
18
|
+
type?: 'horizontal' | 'vertical';
|
|
19
|
+
}
|
|
20
|
+
declare const Card: ({ fdKey, heading, content, imageSrc, icon, badge, link, onMouseEnter, onMouseLeave, type, ...rest }: CardProps) => React.ReactElement;
|
|
21
|
+
|
|
22
|
+
export { Card as default };
|
|
23
|
+
export type { CardProps };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import r from"@mui/material/Card";
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import i from"@mui/material/Box";import o from"@mui/material/Card";import a from"@mui/material/CardContent";import n from"@mui/material/CardMedia";import{styled as l}from"@mui/material/styles";import m from"@mui/material/Typography";import d from"../../../icons/ArrowRight02/index.js";import s from"../Badge/index.js";import p from"../IconContainer/index.js";import{Link as c}from"../Link/index.js";const h=l(o)((({theme:e,type:t})=>({borderRadius:e.radius["radius-16"],border:`1px solid ${e.palette.semantic.stroke["stroke-weak"]}`,..."horizontal"===t&&{display:"flex",flexDirection:"row",overflow:"hidden"}}))),f=l(a)((({theme:e,type:t})=>({"&:last-child":{paddingBottom:e.spacing(2)},..."horizontal"===t&&{flex:1,display:"flex",flexDirection:"column",justifyContent:"space-between"}}))),g=l(i)((({theme:e})=>({display:"flex",alignItems:"flex-start",gap:e.spacing(2),flex:1}))),u=l(i)((()=>({flex:1,display:"flex",flexDirection:"column"}))),x=l(m)((({theme:e})=>({marginBottom:e.spacing(1)}))),y=l(i)((({theme:e})=>({marginTop:e.spacing(1.5)}))),k=l(c)((({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1)}))),w=l(n)((({theme:e,type:t})=>({..."horizontal"===t?{width:200,height:"auto",borderRight:`1px solid ${e.palette.semantic.stroke["stroke-weak"]}`,borderBottom:"none",flexShrink:0}:{height:204,borderBottom:`1px solid ${e.palette.semantic.stroke["stroke-weak"]}`}}))),b=l(i,{shouldForwardProp:e=>!["hasIcon","hasBadge"].includes(e)})((({theme:e,hasIcon:t,hasBadge:r})=>({display:"flex",flexDirection:"row",justifyContent:r&&!t?"flex-end":"space-between",alignItems:"flex-start",gap:e.spacing(2),marginBottom:e.spacing(1.5)}))),C=({fdKey:i,heading:o,content:a,imageSrc:n,icon:l,badge:c,link:C,onMouseEnter:B,onMouseLeave:I,type:j="vertical",...v})=>{if(l&&(M=l,M?.type!==p))throw new Error("Card icon prop must be an IconContainer component");var M;if(c&&!(e=>e?.type===s)(c))throw new Error("Card badge prop must be a Badge component");const z=!!c||!!l,D=()=>C?t(y,{children:t(k,{fdKey:`card-link-${C.label}`,href:C.href,iconRight:t(d,{}),onClick:C.onClick,underline:!1,children:C.label})}):null,E=()=>t(x,{variant:"h4Strong",children:o}),R=()=>t(m,{variant:"b1Weak",children:a});return e(h,{"data-fd":i,type:j,...v,onMouseEnter:B,onMouseLeave:I,children:[n?t(w,{image:n,type:j}):null,t(f,{type:j,children:e(r,"horizontal"===j?{children:[e(g,{children:[l&&l,e(u,{children:[E(),R()]}),c&&c]}),D()]}:{children:[z&&e(b,{hasBadge:!!c,hasIcon:!!l,children:[l&&l,c&&c]}),E(),R(),D()]})})]})};export{C as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Card/index.tsx"],"sourcesContent":["\nimport Box from '@mui/material/Box';\nimport MuiCard from '@mui/material/Card';\nimport CardContent from '@mui/material/CardContent';\nimport CardMedia from '@mui/material/CardMedia';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nimport RightArrowIcon from '../../../icons/ArrowRight02';\nimport Badge from '../Badge';\nimport IconContainer from '../IconContainer';\nimport Link, { type LinkProps } from '../Link';\n\nexport interface CardProps {\n fdKey?: string;\n heading: string;\n content: string;\n imageSrc?: string;\n icon?: React.ReactElement<typeof IconContainer>;\n badge?: React.ReactElement<typeof Badge>;\n link?: {\n label: string;\n href?: string;\n onClick?: () => void;\n }\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n type?: 'horizontal' | 'vertical';\n}\n\nconst StyledCard = styled(MuiCard)<{ type?: 'horizontal' | 'vertical' }>(({ theme, type }) => ({\n borderRadius: theme.radius['radius-16'],\n border: `1px solid ${theme.palette.semantic.stroke['stroke-weak']}`,\n ...(type === 'horizontal' && {\n display: 'flex',\n flexDirection: 'row',\n overflow: 'hidden',\n }),\n}));\n\nconst StyledCardContent = styled(CardContent)<{ type?: 'horizontal' | 'vertical' }>(({ theme, type }) => ({\n '&:last-child': {\n paddingBottom: theme.spacing(2),\n },\n ...(type === 'horizontal' && {\n flex: 1,\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'space-between',\n }),\n}));\n\nconst StyledHorizontalContentWrapper = styled(Box)(({ theme }) => ({\n display: 'flex',\n alignItems: 'flex-start',\n gap: theme.spacing(2),\n flex: 1,\n}));\n\nconst StyledHorizontalTextContent = styled(Box)(() => ({\n flex: 1,\n display: 'flex',\n flexDirection: 'column',\n}));\n\nconst StyledHeading = styled(Typography)(({ theme }) => ({\n marginBottom: theme.spacing(1),\n}));\n\nconst StyledLinkContainer = styled(Box)(({ theme }) => ({\n marginTop: theme.spacing(1.5),\n}));\n\nconst StyledLink = styled(Link)<{ component?: LinkProps['component'] }>(({ theme }) => ({\n display: 'flex',\n alignItems: 'center',\n gap: theme.spacing(1),\n}));\n\nconst StyledCardMedia = styled(CardMedia)<{ type?: 'horizontal' | 'vertical' }>(({ theme, type }) => ({\n ...(type === 'horizontal' ? {\n width: 200,\n height: 'auto',\n borderRight: `1px solid ${theme.palette.semantic.stroke['stroke-weak']}`,\n borderBottom: 'none',\n flexShrink: 0,\n } : {\n height: 204,\n borderBottom: `1px solid ${theme.palette.semantic.stroke['stroke-weak']}`,\n }),\n}));\n\ninterface StyledTopContentContainerProps {\n hasIcon: boolean;\n hasBadge: boolean;\n}\n\nconst StyledTopContentContainer = styled(Box, {\n shouldForwardProp: (prop) => !['hasIcon', 'hasBadge'].includes(prop as string),\n})<StyledTopContentContainerProps>(({ theme, hasIcon, hasBadge }) => {\n\n const onlyHasRightContent = hasBadge && !hasIcon;\n return {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: onlyHasRightContent ? 'flex-end' : 'space-between',\n alignItems: 'flex-start',\n gap: theme.spacing(2),\n marginBottom: theme.spacing(1.5),\n }\n});\n\n// Validation function to ensure only IconContainer components are passed\nconst isValidIconContainer = (element: React.ReactElement): boolean => {\n return element?.type === IconContainer;\n};\n\nconst isValidBadge = (element: React.ReactElement): boolean => {\n return element?.type === Badge;\n};\n\nconst Card = ({\n fdKey,\n heading,\n content,\n imageSrc,\n icon,\n badge,\n link,\n onMouseEnter,\n onMouseLeave,\n type = 'vertical',\n ...rest\n}: CardProps): React.ReactElement => {\n if (icon && !isValidIconContainer(icon)) {\n throw new Error('Card icon prop must be an IconContainer component');\n }\n if (badge && !isValidBadge(badge)) {\n throw new Error('Card badge prop must be a Badge component');\n }\n\n const hasTopContent = !!badge || !!icon;\n\n const renderImage = (): React.ReactElement | null => {\n if (!imageSrc) return null;\n return <StyledCardMedia image={imageSrc} type={type} />;\n };\n\n const renderLink = (): React.ReactElement | null => {\n if (!link) return null;\n return (\n <StyledLinkContainer>\n <StyledLink\n fdKey={`card-link-${link.label}`}\n href={link.href}\n iconRight={<RightArrowIcon />}\n onClick={link.onClick}\n underline={false}\n >\n {link.label}\n </StyledLink>\n </StyledLinkContainer>\n );\n };\n\n const renderHeading = (): React.ReactElement => {\n return (\n <StyledHeading variant=\"h4Strong\">\n {heading}\n </StyledHeading>\n );\n };\n\n const renderContent = (): React.ReactElement => {\n return (\n <Typography variant=\"b1Weak\">\n {content}\n </Typography>\n );\n };\n\n const renderHorizontalContent = (): React.ReactElement => {\n return (\n <>\n <StyledHorizontalContentWrapper>\n {icon && icon}\n <StyledHorizontalTextContent>\n {renderHeading()}\n {renderContent()}\n </StyledHorizontalTextContent>\n {badge && badge}\n </StyledHorizontalContentWrapper>\n {renderLink()}\n </>\n );\n };\n\n const renderVerticalContent = (): React.ReactElement => {\n return (\n <>\n {hasTopContent && (\n <StyledTopContentContainer hasBadge={!!badge} hasIcon={!!icon}>\n {icon && icon}\n {badge && badge}\n </StyledTopContentContainer>\n )}\n {renderHeading()}\n {renderContent()}\n {renderLink()}\n </>\n );\n };\n\n const renderCardContent = (): React.ReactElement => {\n if (type === 'horizontal') {\n return renderHorizontalContent();\n }\n return renderVerticalContent();\n };\n\n return (\n <StyledCard data-fd={fdKey} type={type} {...rest} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>\n {renderImage()}\n <StyledCardContent type={type}>\n {renderCardContent()}\n </StyledCardContent>\n </StyledCard>\n );\n};\n\nexport default Card;"],"names":["StyledCard","styled","MuiCard","theme","type","borderRadius","radius","border","palette","semantic","stroke","display","flexDirection","overflow","StyledCardContent","CardContent","paddingBottom","spacing","flex","justifyContent","StyledHorizontalContentWrapper","Box","alignItems","gap","StyledHorizontalTextContent","StyledHeading","Typography","marginBottom","StyledLinkContainer","marginTop","StyledLink","Link","StyledCardMedia","CardMedia","width","height","borderRight","borderBottom","flexShrink","StyledTopContentContainer","shouldForwardProp","prop","includes","hasIcon","hasBadge","Card","fdKey","heading","content","imageSrc","icon","badge","link","onMouseEnter","onMouseLeave","rest","element","IconContainer","Error","Badge","isValidBadge","hasTopContent","renderLink","_jsx","label","href","iconRight","RightArrowIcon","onClick","underline","renderHeading","variant","children","renderContent","_jsxs","image","_Fragment"],"mappings":"+cA8BA,MAAMA,EAAaC,EAAOC,EAAPD,EAAsD,EAAGE,QAAOC,WAAM,CACvFC,aAAcF,EAAMG,OAAO,aAC3BC,OAAQ,aAAaJ,EAAMK,QAAQC,SAASC,OAAO,oBACtC,eAATN,GAAyB,CAC3BO,QAAS,OACTC,cAAe,MACfC,SAAU,cAIRC,EAAoBb,EAAOc,EAAPd,EAA0D,EAAGE,QAAOC,WAAM,CAClG,eAAgB,CACdY,cAAe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GAqBvB,MAAM,IAAIC,MAAM,qDAtBS,IAACF,EAwB5B,GAAIL,IApBe,CAACK,GACbA,GAASpD,OAASuD,EAmBXC,CAAaT,GACzB,MAAM,IAAIO,MAAM,6CAGlB,MAAMG,IAAkBV,KAAWD,EAO7BY,EAAa,IACZV,EAEHW,EAACnC,YACCmC,EAACjC,GACCgB,MAAO,aAAaM,EAAKY,QACzBC,KAAMb,EAAKa,KACXC,UAAWH,EAACI,EAAc,CAAA,GAC1BC,QAAShB,EAAKgB,QACdC,WAAW,WAEVjB,EAAKY,UAVM,KAgBdM,EAAgB,IAElBP,EAACtC,EAAa,CAAC8C,QAAQ,WAAUC,SAC9BzB,IAKD0B,EAAgB,IAElBV,EAACrC,EAAU,CAAC6C,QAAQ,SAAQC,SACzBxB,IA4CP,OACE0B,EAAC1E,EAAU,CAAA,UAAU8C,EAAO1C,KAAMA,KAAUmD,EAAMF,aAAcA,EAAcC,aAAcA,YA7EvFL,EACEc,EAAC/B,EAAe,CAAC2C,MAAO1B,EAAU7C,KAAMA,IADzB,KA+EpB2D,EAACjD,EAAiB,CAACV,KAAMA,WAxCzBsE,EAAAE,EA+BW,eAATxE,EA/BF,CAAAoE,SAAA,CACEE,EAACtD,EAA8B,CAAAoD,SAAA,CAC5BtB,GAAQA,EACTwB,EAAClD,EAA2B,CAAAgD,SAAA,CACzBF,IACAG,OAEFtB,GAASA,KAEXW,MAOH,CAAAU,SAAA,CACGX,GACCa,EAACnC,EAAyB,CAACK,WAAYO,EAAOR,UAAWO,EAAIsB,SAAA,CAC1DtB,GAAQA,EACRC,GAASA,KAGbmB,IACAG,IACAX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../../../src/components/atoms/Link/index.tsx"],"sourcesContent":["import React, { type ReactElement } from 'react';\n\nimport MuiLink, { type LinkProps as MuiLinkProps } from '@mui/material/Link';\nimport { styled } from '@mui/material/styles';\n\nimport { getLinkStyles, type LinkTone } from './getLinkStyles';\n\nexport type LinkSize = 'body' | 'caption';\nexport type LinkWeight = 'bold' | 'regular';\nexport type LinkState = 'default' | 'disabled' | 'focus' | 'hover' | 'press';\n\nexport interface StyledLinkProps extends Omit<MuiLinkProps, 'color' | 'state' | 'underline'> {\n className?: string;\n state?: LinkState;\n children: React.ReactNode;\n href?: string;\n target?: '_blank' | '_parent' | '_self' | '_top';\n rel?: string;\n fdKey: string;\n tone?: LinkTone;\n underline?: boolean;\n size?: LinkSize;\n weight?: LinkWeight;\n iconLeft?: React.ReactNode;\n iconRight?: React.ReactNode;\n}\n\nconst StyledLink = styled(MuiLink, {\n shouldForwardProp: (prop: string) => !['tone', 'size', 'weight', 'state', 'underline', 'fdKey', 'iconLeft', 'iconRight'].includes(prop),\n})<StyledLinkProps>((\n { theme, tone = 'Brand', size = 'body', weight = 'regular', underline, state = 'default' }\n) => {\n const styles = getLinkStyles(theme, tone, underline);\n\n const typographyStyle = theme.typography[getTypographyVariant(size, weight)];\n\n return {\n ...styles.default,\n ...styles[state],\n ...typographyStyle,\n\n '&:hover': {\n ...styles.hover,\n },\n '&:focus:not(:focus-visible)': {\n outline: 'none', // Hide focus ring for mouse/touch only\n },\n // focus visible so that the focus ring only shows for keyboard users\n '&:focus-visible': { ...styles.focus },\n '&:active': {\n ...styles.press,\n },\n // Style icons\n '& > svg': {\n flexShrink: 0,\n verticalAlign: 'middle',\n width: '20px',\n height: '20px',\n },\n };\n});\n\nexport const Link = (props: StyledLinkProps): ReactElement => {\n const { children, className, fdKey, href, state = 'default', target, rel, tone = 'Brand', underline = true, size = 'body', weight = 'regular', iconLeft = null, iconRight = null, ...rest } = props;\n // Automatically add rel=\"noopener noreferrer\" for external links\n const linkRel = target === '_blank' && !rel ? 'noopener noreferrer' : rel;\n\n const styledLinkProps = {\n ...rest,\n className,\n 'data-fd': fdKey,\n fdKey,\n href,\n iconLeft,\n iconRight,\n rel: linkRel,\n size,\n state,\n target,\n tone,\n underline,\n weight,\n } as unknown as React.ComponentProps<typeof StyledLink>;\n\n return (\n <StyledLink {...styledLinkProps}>\n {iconLeft}\n {children}\n {iconRight}\n </StyledLink>\n );\n};\n\nconst getTypographyVariant = (size: LinkSize, weight: LinkWeight): 'b1Strong' | 'b1Weak' | 'captionStrong' | 'captionWeak' => {\n if (size === 'caption') {\n return weight === 'bold' ? 'captionStrong' : 'captionWeak';\n }\n if (size === 'body') {\n return weight === 'bold' ? 'b1Strong' : 'b1Weak';\n }\n return 'b1Weak';\n};\n\nexport default Link;\
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../../src/components/atoms/Link/index.tsx"],"sourcesContent":["import React, { type ReactElement } from 'react';\n\nimport MuiLink, { type LinkProps, type LinkProps as MuiLinkProps } from '@mui/material/Link';\nimport { styled } from '@mui/material/styles';\n\nimport { getLinkStyles, type LinkTone } from './getLinkStyles';\n\nexport type LinkSize = 'body' | 'caption';\nexport type LinkWeight = 'bold' | 'regular';\nexport type LinkState = 'default' | 'disabled' | 'focus' | 'hover' | 'press';\n\nexport interface StyledLinkProps extends Omit<MuiLinkProps, 'color' | 'state' | 'underline'> {\n className?: string;\n state?: LinkState;\n children: React.ReactNode;\n href?: string;\n target?: '_blank' | '_parent' | '_self' | '_top';\n rel?: string;\n fdKey: string;\n tone?: LinkTone;\n underline?: boolean;\n size?: LinkSize;\n weight?: LinkWeight;\n iconLeft?: React.ReactNode;\n iconRight?: React.ReactNode;\n}\n\nconst StyledLink = styled(MuiLink, {\n shouldForwardProp: (prop: string) => !['tone', 'size', 'weight', 'state', 'underline', 'fdKey', 'iconLeft', 'iconRight'].includes(prop),\n})<StyledLinkProps>((\n { theme, tone = 'Brand', size = 'body', weight = 'regular', underline, state = 'default' }\n) => {\n const styles = getLinkStyles(theme, tone, underline);\n\n const typographyStyle = theme.typography[getTypographyVariant(size, weight)];\n\n return {\n ...styles.default,\n ...styles[state],\n ...typographyStyle,\n\n '&:hover': {\n ...styles.hover,\n },\n '&:focus:not(:focus-visible)': {\n outline: 'none', // Hide focus ring for mouse/touch only\n },\n // focus visible so that the focus ring only shows for keyboard users\n '&:focus-visible': { ...styles.focus },\n '&:active': {\n ...styles.press,\n },\n // Style icons\n '& > svg': {\n flexShrink: 0,\n verticalAlign: 'middle',\n width: '20px',\n height: '20px',\n },\n };\n});\n\nexport const Link = (props: StyledLinkProps): ReactElement => {\n const { children, className, fdKey, href, state = 'default', target, rel, tone = 'Brand', underline = true, size = 'body', weight = 'regular', iconLeft = null, iconRight = null, ...rest } = props;\n // Automatically add rel=\"noopener noreferrer\" for external links\n const linkRel = target === '_blank' && !rel ? 'noopener noreferrer' : rel;\n\n const styledLinkProps = {\n ...rest,\n className,\n 'data-fd': fdKey,\n fdKey,\n href,\n iconLeft,\n iconRight,\n rel: linkRel,\n size,\n state,\n target,\n tone,\n underline,\n weight,\n } as unknown as React.ComponentProps<typeof StyledLink>;\n\n return (\n <StyledLink {...styledLinkProps}>\n {iconLeft}\n {children}\n {iconRight}\n </StyledLink>\n );\n};\n\nconst getTypographyVariant = (size: LinkSize, weight: LinkWeight): 'b1Strong' | 'b1Weak' | 'captionStrong' | 'captionWeak' => {\n if (size === 'caption') {\n return weight === 'bold' ? 'captionStrong' : 'captionWeak';\n }\n if (size === 'body') {\n return weight === 'bold' ? 'b1Strong' : 'b1Weak';\n }\n return 'b1Weak';\n};\n\nexport default Link;\nexport type { LinkProps };"],"names":["StyledLink","styled","MuiLink","shouldForwardProp","prop","includes","theme","tone","size","weight","underline","state","styles","getLinkStyles","typographyStyle","typography","getTypographyVariant","default","hover","outline","focus","press","flexShrink","verticalAlign","width","height","Link","props","children","className","fdKey","href","target","rel","iconLeft","iconRight","rest","styledLinkProps","_jsxs"],"mappings":"kOA2BA,MAAMA,EAAaC,EAAAA,OAAOC,EAAS,CAC/BC,kBAAoBC,IAAkB,CAAC,OAAQ,OAAQ,SAAU,QAAS,YAAa,QAAS,WAAY,aAAaC,SAASD,IADnHH,EAEC,EACdK,QAAOC,OAAO,QAASC,OAAO,OAAQC,SAAS,UAAWC,YAAWC,QAAQ,cAE/E,MAAMC,EAASC,EAAAA,cAAcP,EAAOC,EAAMG,GAEpCI,EAAkBR,EAAMS,WAAWC,EAAqBR,EAAMC,IAEpE,MAAO,IACAG,EAAOK,WACPL,EAAOD,MACPG,EAEH,UAAW,IACJF,EAAOM,OAEd,8BAA+B,CAC3BC,QAAS,QAGb,kBAAmB,IAAKP,EAAOQ,OAC/B,WAAY,IACLR,EAAOS,OAGd,UAAW,CACPC,WAAY,EACZC,cAAe,SACfC,MAAO,OACPC,OAAQ,YAKPC,EAAQC,IACjB,MAAMC,SAAEA,EAAQC,UAAEA,EAASC,MAAEA,EAAKC,KAAEA,EAAIpB,MAAEA,EAAQ,UAASqB,OAAEA,EAAMC,IAAEA,EAAG1B,KAAEA,EAAO,QAAOG,UAAEA,GAAY,EAAIF,KAAEA,EAAO,OAAMC,OAAEA,EAAS,UAASyB,SAAEA,EAAW,KAAIC,UAAEA,EAAY,QAASC,GAAST,EAIxLU,EAAkB,IACjBD,EACHP,YACA,UAAWC,EACXA,QACAC,OACAG,WACAC,YACAF,IAVuB,WAAXD,GAAwBC,EAA8BA,EAAxB,sBAW1CzB,OACAG,QACAqB,SACAzB,OACAG,YACAD,UAGJ,OACI6B,EAAAA,KAACtC,EAAU,IAAKqC,EAAeT,SAAA,CAC1BM,EACAN,EACAO,MAKPnB,EAAuB,CAACR,EAAgBC,IAC7B,YAATD,EACkB,SAAXC,EAAoB,gBAAkB,cAEpC,SAATD,GACkB,SAAXC,EAAoB,WAExB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Link/index.tsx"],"sourcesContent":["import React, { type ReactElement } from 'react';\n\nimport MuiLink, { type LinkProps as MuiLinkProps } from '@mui/material/Link';\nimport { styled } from '@mui/material/styles';\n\nimport { getLinkStyles, type LinkTone } from './getLinkStyles';\n\nexport type LinkSize = 'body' | 'caption';\nexport type LinkWeight = 'bold' | 'regular';\nexport type LinkState = 'default' | 'disabled' | 'focus' | 'hover' | 'press';\n\nexport interface StyledLinkProps extends Omit<MuiLinkProps, 'color' | 'state' | 'underline'> {\n className?: string;\n state?: LinkState;\n children: React.ReactNode;\n href?: string;\n target?: '_blank' | '_parent' | '_self' | '_top';\n rel?: string;\n fdKey: string;\n tone?: LinkTone;\n underline?: boolean;\n size?: LinkSize;\n weight?: LinkWeight;\n iconLeft?: React.ReactNode;\n iconRight?: React.ReactNode;\n}\n\nconst StyledLink = styled(MuiLink, {\n shouldForwardProp: (prop: string) => !['tone', 'size', 'weight', 'state', 'underline', 'fdKey', 'iconLeft', 'iconRight'].includes(prop),\n})<StyledLinkProps>((\n { theme, tone = 'Brand', size = 'body', weight = 'regular', underline, state = 'default' }\n) => {\n const styles = getLinkStyles(theme, tone, underline);\n\n const typographyStyle = theme.typography[getTypographyVariant(size, weight)];\n\n return {\n ...styles.default,\n ...styles[state],\n ...typographyStyle,\n\n '&:hover': {\n ...styles.hover,\n },\n '&:focus:not(:focus-visible)': {\n outline: 'none', // Hide focus ring for mouse/touch only\n },\n // focus visible so that the focus ring only shows for keyboard users\n '&:focus-visible': { ...styles.focus },\n '&:active': {\n ...styles.press,\n },\n // Style icons\n '& > svg': {\n flexShrink: 0,\n verticalAlign: 'middle',\n width: '20px',\n height: '20px',\n },\n };\n});\n\nexport const Link = (props: StyledLinkProps): ReactElement => {\n const { children, className, fdKey, href, state = 'default', target, rel, tone = 'Brand', underline = true, size = 'body', weight = 'regular', iconLeft = null, iconRight = null, ...rest } = props;\n // Automatically add rel=\"noopener noreferrer\" for external links\n const linkRel = target === '_blank' && !rel ? 'noopener noreferrer' : rel;\n\n const styledLinkProps = {\n ...rest,\n className,\n 'data-fd': fdKey,\n fdKey,\n href,\n iconLeft,\n iconRight,\n rel: linkRel,\n size,\n state,\n target,\n tone,\n underline,\n weight,\n } as unknown as React.ComponentProps<typeof StyledLink>;\n\n return (\n <StyledLink {...styledLinkProps}>\n {iconLeft}\n {children}\n {iconRight}\n </StyledLink>\n );\n};\n\nconst getTypographyVariant = (size: LinkSize, weight: LinkWeight): 'b1Strong' | 'b1Weak' | 'captionStrong' | 'captionWeak' => {\n if (size === 'caption') {\n return weight === 'bold' ? 'captionStrong' : 'captionWeak';\n }\n if (size === 'body') {\n return weight === 'bold' ? 'b1Strong' : 'b1Weak';\n }\n return 'b1Weak';\n};\n\nexport default Link;\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Link/index.tsx"],"sourcesContent":["import React, { type ReactElement } from 'react';\n\nimport MuiLink, { type LinkProps, type LinkProps as MuiLinkProps } from '@mui/material/Link';\nimport { styled } from '@mui/material/styles';\n\nimport { getLinkStyles, type LinkTone } from './getLinkStyles';\n\nexport type LinkSize = 'body' | 'caption';\nexport type LinkWeight = 'bold' | 'regular';\nexport type LinkState = 'default' | 'disabled' | 'focus' | 'hover' | 'press';\n\nexport interface StyledLinkProps extends Omit<MuiLinkProps, 'color' | 'state' | 'underline'> {\n className?: string;\n state?: LinkState;\n children: React.ReactNode;\n href?: string;\n target?: '_blank' | '_parent' | '_self' | '_top';\n rel?: string;\n fdKey: string;\n tone?: LinkTone;\n underline?: boolean;\n size?: LinkSize;\n weight?: LinkWeight;\n iconLeft?: React.ReactNode;\n iconRight?: React.ReactNode;\n}\n\nconst StyledLink = styled(MuiLink, {\n shouldForwardProp: (prop: string) => !['tone', 'size', 'weight', 'state', 'underline', 'fdKey', 'iconLeft', 'iconRight'].includes(prop),\n})<StyledLinkProps>((\n { theme, tone = 'Brand', size = 'body', weight = 'regular', underline, state = 'default' }\n) => {\n const styles = getLinkStyles(theme, tone, underline);\n\n const typographyStyle = theme.typography[getTypographyVariant(size, weight)];\n\n return {\n ...styles.default,\n ...styles[state],\n ...typographyStyle,\n\n '&:hover': {\n ...styles.hover,\n },\n '&:focus:not(:focus-visible)': {\n outline: 'none', // Hide focus ring for mouse/touch only\n },\n // focus visible so that the focus ring only shows for keyboard users\n '&:focus-visible': { ...styles.focus },\n '&:active': {\n ...styles.press,\n },\n // Style icons\n '& > svg': {\n flexShrink: 0,\n verticalAlign: 'middle',\n width: '20px',\n height: '20px',\n },\n };\n});\n\nexport const Link = (props: StyledLinkProps): ReactElement => {\n const { children, className, fdKey, href, state = 'default', target, rel, tone = 'Brand', underline = true, size = 'body', weight = 'regular', iconLeft = null, iconRight = null, ...rest } = props;\n // Automatically add rel=\"noopener noreferrer\" for external links\n const linkRel = target === '_blank' && !rel ? 'noopener noreferrer' : rel;\n\n const styledLinkProps = {\n ...rest,\n className,\n 'data-fd': fdKey,\n fdKey,\n href,\n iconLeft,\n iconRight,\n rel: linkRel,\n size,\n state,\n target,\n tone,\n underline,\n weight,\n } as unknown as React.ComponentProps<typeof StyledLink>;\n\n return (\n <StyledLink {...styledLinkProps}>\n {iconLeft}\n {children}\n {iconRight}\n </StyledLink>\n );\n};\n\nconst getTypographyVariant = (size: LinkSize, weight: LinkWeight): 'b1Strong' | 'b1Weak' | 'captionStrong' | 'captionWeak' => {\n if (size === 'caption') {\n return weight === 'bold' ? 'captionStrong' : 'captionWeak';\n }\n if (size === 'body') {\n return weight === 'bold' ? 'b1Strong' : 'b1Weak';\n }\n return 'b1Weak';\n};\n\nexport default Link;\nexport type { LinkProps };"],"names":["StyledLink","styled","MuiLink","shouldForwardProp","prop","includes","theme","tone","size","weight","underline","state","styles","getLinkStyles","typographyStyle","typography","getTypographyVariant","default","hover","outline","focus","press","flexShrink","verticalAlign","width","height","Link","props","children","className","fdKey","href","target","rel","iconLeft","iconRight","rest","styledLinkProps","_jsxs"],"mappings":"0LA2BA,MAAMA,EAAaC,EAAOC,EAAS,CAC/BC,kBAAoBC,IAAkB,CAAC,OAAQ,OAAQ,SAAU,QAAS,YAAa,QAAS,WAAY,aAAaC,SAASD,IADnHH,EAEC,EACdK,QAAOC,OAAO,QAASC,OAAO,OAAQC,SAAS,UAAWC,YAAWC,QAAQ,cAE/E,MAAMC,EAASC,EAAcP,EAAOC,EAAMG,GAEpCI,EAAkBR,EAAMS,WAAWC,EAAqBR,EAAMC,IAEpE,MAAO,IACAG,EAAOK,WACPL,EAAOD,MACPG,EAEH,UAAW,IACJF,EAAOM,OAEd,8BAA+B,CAC3BC,QAAS,QAGb,kBAAmB,IAAKP,EAAOQ,OAC/B,WAAY,IACLR,EAAOS,OAGd,UAAW,CACPC,WAAY,EACZC,cAAe,SACfC,MAAO,OACPC,OAAQ,YAKPC,EAAQC,IACjB,MAAMC,SAAEA,EAAQC,UAAEA,EAASC,MAAEA,EAAKC,KAAEA,EAAIpB,MAAEA,EAAQ,UAASqB,OAAEA,EAAMC,IAAEA,EAAG1B,KAAEA,EAAO,QAAOG,UAAEA,GAAY,EAAIF,KAAEA,EAAO,OAAMC,OAAEA,EAAS,UAASyB,SAAEA,EAAW,KAAIC,UAAEA,EAAY,QAASC,GAAST,EAIxLU,EAAkB,IACjBD,EACHP,YACA,UAAWC,EACXA,QACAC,OACAG,WACAC,YACAF,IAVuB,WAAXD,GAAwBC,EAA8BA,EAAxB,sBAW1CzB,OACAG,QACAqB,SACAzB,OACAG,YACAD,UAGJ,OACI6B,EAACtC,EAAU,IAAKqC,EAAeT,SAAA,CAC1BM,EACAN,EACAO,MAKPnB,EAAuB,CAACR,EAAgBC,IAC7B,YAATD,EACkB,SAAXC,EAAoB,gBAAkB,cAEpC,SAATD,GACkB,SAAXC,EAAoB,WAExB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("@mui/material/FormControlLabel"),i=require("@mui/material/Switch"),l=require("@mui/material/styles");const a=l.styled(t)((({theme:e,$size:t="medium"})=>({color:e.palette.semantic.text["text-strong"],gap:"12px",margin:0,"& .MuiFormControlLabel-label":{...e.typography["small"===t?"captionWeak":"b1Weak"]}}))),o=l.styled(i)((({theme:e,$size:t="medium",checked:i})=>{const l="small"===t,a=l?24:32,o=l?24:32;return{width:l?48:64,height:a,padding:0,overflow:"visible","& .MuiSwitch-switchBase":{padding:0,transitionDuration:"200ms","&.Mui-checked":{transform:`translateX(${l?24:32}px)`,color:e.palette.semantic.fill["fill-white"],"& .MuiSwitch-thumb":{borderColor:e.palette.semantic.stroke["stroke-selected"]},"& + .MuiSwitch-track":{backgroundColor:e.palette.semantic.fill["fill-selected"],borderColor:e.palette.semantic.stroke["stroke-selected"],opacity:1},"&.Mui-disabled + .MuiSwitch-track":{backgroundColor:e.palette.semantic.fill["fill-disabled"],borderColor:e.palette.semantic.stroke["stroke-disabled"],opacity:1}},"&.Mui-focusVisible + .MuiSwitch-track":{outline:`2px solid ${e.palette.semantic.stroke["stroke-focus"]}`,outlineOffset:"2px"},"&.Mui-disabled .MuiSwitch-thumb":{color:e.palette.semantic.fill["fill-white"]},"&.Mui-disabled + .MuiSwitch-track":{backgroundColor:e.palette.semantic.fill["fill-disabled"],borderColor:e.palette.semantic.stroke["stroke-disabled"],opacity:1}},"& .MuiSwitch-thumb":{width:o,height:o,backgroundColor:e.palette.semantic.fill["fill-white"],border:`2px solid ${e.palette.semantic.stroke["stroke-strong"]}`,transition:e.transitions.create(["border-color"],{duration:200})},"& .MuiSwitch-track":{borderRadius:a,backgroundColor:e.palette.semantic.fill["fill-weak"],border:`1px solid ${e.palette.semantic.stroke["stroke-strong"]}`,boxShadow:i?"none":e.customShadows?.sunken,opacity:1,transition:e.transitions.create(["background-color","border-color","outline"],{duration:200})},"&:hover .MuiSwitch-switchBase:not(.Mui-checked):not(.Mui-disabled) + .MuiSwitch-track":{backgroundColor:e.palette.semantic.fill["fill-hover"]},"&:active .MuiSwitch-switchBase:not(.Mui-checked):not(.Mui-disabled) + .MuiSwitch-track":{backgroundColor:e.palette.semantic.fill["fill-press"]}}}));module.exports=({checked:t,disabled:i=!1,label:l,labelPlacement:r="end",onChange:s,size:c="medium",fdKey:d})=>l?e.jsx(a,{$size:c,control:e.jsx(o,{disableRipple:!0,$size:c,checked:t,"data-fd":d,disabled:i,onChange:s}),disabled:i,label:l,labelPlacement:r}):e.jsx(o,{disableRipple:!0,$size:c,checked:t,"data-fd":d,disabled:i,onChange:s});
|
|
2
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../../src/components/atoms/Switch/index.tsx"],"sourcesContent":["import FormControlLabel, { type FormControlLabelProps } from '@mui/material/FormControlLabel';\nimport MuiSwitch, { type SwitchProps as MuiSwitchProps } from '@mui/material/Switch';\n\nimport styled from '@fd/utilities/styledUtilities';\nimport type { ReactElement } from 'react';\n\nconst StyledFormControlLabel = styled(FormControlLabel)<{ $size?: 'medium' | 'small' }>(({ theme, $size = 'medium' }) => ({\n color: theme.palette.semantic.text['text-strong'],\n gap: '12px',\n margin: 0,\n '& .MuiFormControlLabel-label': {\n ...theme.typography[$size === 'small' ? 'captionWeak' : 'b1Weak'],\n },\n}));\n\nconst StyledSwitch = styled(MuiSwitch)<{ $size?: 'medium' | 'small' }>(({ theme, $size = 'medium', checked }) => {\n const isSmall = $size === 'small';\n const width = isSmall ? 48 : 64;\n const height = isSmall ? 24 : 32;\n const thumbSize = isSmall ? 24 : 32;\n const translateX = isSmall ? 24 : 32;\n\n return {\n width,\n height,\n padding: 0,\n overflow: 'visible',\n '& .MuiSwitch-switchBase': {\n padding: 0,\n transitionDuration: '200ms',\n '&.Mui-checked': {\n transform: `translateX(${translateX}px)`,\n color: theme.palette.semantic.fill['fill-white'],\n '& .MuiSwitch-thumb': {\n borderColor: theme.palette.semantic.stroke['stroke-selected'],\n },\n '& + .MuiSwitch-track': {\n backgroundColor: theme.palette.semantic.fill['fill-selected'],\n borderColor: theme.palette.semantic.stroke['stroke-selected'],\n opacity: 1,\n },\n '&.Mui-disabled + .MuiSwitch-track': {\n backgroundColor: theme.palette.semantic.fill['fill-disabled'],\n borderColor: theme.palette.semantic.stroke['stroke-disabled'],\n opacity: 1,\n },\n },\n '&.Mui-focusVisible + .MuiSwitch-track': {\n outline: `2px solid ${theme.palette.semantic.stroke['stroke-focus']}`,\n outlineOffset: '2px',\n },\n '&.Mui-disabled .MuiSwitch-thumb': {\n color: theme.palette.semantic.fill['fill-white'],\n },\n '&.Mui-disabled + .MuiSwitch-track': {\n backgroundColor: theme.palette.semantic.fill['fill-disabled'],\n borderColor: theme.palette.semantic.stroke['stroke-disabled'],\n opacity: 1,\n },\n },\n '& .MuiSwitch-thumb': {\n width: thumbSize,\n height: thumbSize,\n backgroundColor: theme.palette.semantic.fill['fill-white'],\n border: `2px solid ${theme.palette.semantic.stroke['stroke-strong']}`,\n transition: theme.transitions.create(['border-color'], {\n duration: 200,\n }),\n },\n '& .MuiSwitch-track': {\n borderRadius: height,\n backgroundColor: theme.palette.semantic.fill['fill-weak'],\n border: `1px solid ${theme.palette.semantic.stroke['stroke-strong']}`,\n boxShadow: checked ? 'none' : theme.customShadows?.sunken,\n opacity: 1,\n transition: theme.transitions.create(['background-color', 'border-color', 'outline'], {\n duration: 200,\n }),\n },\n '&:hover .MuiSwitch-switchBase:not(.Mui-checked):not(.Mui-disabled) + .MuiSwitch-track': {\n backgroundColor: theme.palette.semantic.fill['fill-hover'],\n },\n '&:active .MuiSwitch-switchBase:not(.Mui-checked):not(.Mui-disabled) + .MuiSwitch-track': {\n backgroundColor: theme.palette.semantic.fill['fill-press'],\n },\n };\n});\n\nexport interface SwitchProps {\n /** Whether the switch is checked (on) or unchecked (off) */\n checked?: boolean;\n /** Whether the switch is disabled and cannot be interacted with */\n disabled?: boolean;\n /** Optional label text to display next to the switch */\n label?: string;\n /** Position of the label relative to the switch. Options: 'start', 'end', 'top', 'bottom'. Default: 'end' */\n labelPlacement?: FormControlLabelProps['labelPlacement'];\n /** Callback fired when the switch state changes. Receives the event and checked state */\n onChange?: MuiSwitchProps['onChange'];\n /** Size of the switch. Options: 'small' (48x24px), 'medium' (64x32px). Default: 'medium' */\n size?: 'medium' | 'small';\n /** Test ID for the switch element */\n fdKey: string;\n}\n\nconst Switch = ({ checked, disabled = false, label, labelPlacement = 'end', onChange, size = 'medium', fdKey }: SwitchProps): ReactElement => {\n if (!label) {\n return <StyledSwitch disableRipple $size={size} checked={checked} data-fd={fdKey} disabled={disabled} onChange={onChange} />;\n }\n\n return (\n <StyledFormControlLabel\n $size={size}\n control={<StyledSwitch disableRipple $size={size} checked={checked} data-fd={fdKey} disabled={disabled} onChange={onChange} />}\n disabled={disabled}\n label={label}\n labelPlacement={labelPlacement}\n />\n );\n};\n\nexport default Switch;\n"],"names":["StyledFormControlLabel","styled","FormControlLabel","theme","$size","color","palette","semantic","text","gap","margin","typography","StyledSwitch","MuiSwitch","checked","isSmall","height","thumbSize","width","padding","overflow","transitionDuration","transform","fill","borderColor","stroke","backgroundColor","opacity","outline","outlineOffset","border","transition","transitions","create","duration","borderRadius","boxShadow","customShadows","sunken","disabled","label","labelPlacement","onChange","size","fdKey","_jsx","control","disableRipple"],"mappings":"gKAMA,MAAMA,EAAyBC,EAAAA,OAAOC,EAAPD,EAAyD,EAAGE,QAAOC,QAAQ,aAAU,CAChHC,MAAOF,EAAMG,QAAQC,SAASC,KAAK,eACnCC,IAAK,OACLC,OAAQ,EACR,+BAAgC,IACzBP,EAAMQ,WAAqB,UAAVP,EAAoB,cAAgB,eAI1DQ,EAAeX,EAAAA,OAAOY,EAAPZ,EAAkD,EAAGE,QAAOC,QAAQ,SAAUU,cAC/F,MAAMC,EAAoB,UAAVX,EAEVY,EAASD,EAAU,GAAK,GACxBE,EAAYF,EAAU,GAAK,GAGjC,MAAO,CACHG,MANUH,EAAU,GAAK,GAOzBC,SACAG,QAAS,EACTC,SAAU,UACV,0BAA2B,CACvBD,QAAS,EACTE,mBAAoB,QACpB,gBAAiB,CACbC,UAAW,cAXJP,EAAU,GAAK,QAYtBV,MAAOF,EAAMG,QAAQC,SAASgB,KAAK,cACnC,qBAAsB,CAClBC,YAAarB,EAAMG,QAAQC,SAASkB,OAAO,oBAE/C,uBAAwB,CACpBC,gBAAiBvB,EAAMG,QAAQC,SAASgB,KAAK,iBAC7CC,YAAarB,EAAMG,QAAQ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,EACVC,MAAOA,EACPC,eAAgBA,IATbI,EAAAA,IAACjC,EAAY,CAACmC,uBAAqBJ,EAAM7B,QAASA,YAAkB8B,EAAOL,SAAUA,EAAUG,SAAUA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FormControlLabelProps } from '@mui/material/FormControlLabel';
|
|
2
|
+
import { SwitchProps as SwitchProps$1 } from '@mui/material/Switch';
|
|
3
|
+
import { ReactElement } from 'react';
|
|
4
|
+
|
|
5
|
+
interface SwitchProps {
|
|
6
|
+
/** Whether the switch is checked (on) or unchecked (off) */
|
|
7
|
+
checked?: boolean;
|
|
8
|
+
/** Whether the switch is disabled and cannot be interacted with */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** Optional label text to display next to the switch */
|
|
11
|
+
label?: string;
|
|
12
|
+
/** Position of the label relative to the switch. Options: 'start', 'end', 'top', 'bottom'. Default: 'end' */
|
|
13
|
+
labelPlacement?: FormControlLabelProps['labelPlacement'];
|
|
14
|
+
/** Callback fired when the switch state changes. Receives the event and checked state */
|
|
15
|
+
onChange?: SwitchProps$1['onChange'];
|
|
16
|
+
/** Size of the switch. Options: 'small' (48x24px), 'medium' (64x32px). Default: 'medium' */
|
|
17
|
+
size?: 'medium' | 'small';
|
|
18
|
+
/** Test ID for the switch element */
|
|
19
|
+
fdKey: string;
|
|
20
|
+
}
|
|
21
|
+
declare const Switch: ({ checked, disabled, label, labelPlacement, onChange, size, fdKey }: SwitchProps) => ReactElement;
|
|
22
|
+
|
|
23
|
+
export { Switch as default };
|
|
24
|
+
export type { SwitchProps };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import t from"@mui/material/FormControlLabel";import i from"@mui/material/Switch";import{styled as l}from"@mui/material/styles";const o=l(t)((({theme:e,$size:t="medium"})=>({color:e.palette.semantic.text["text-strong"],gap:"12px",margin:0,"& .MuiFormControlLabel-label":{...e.typography["small"===t?"captionWeak":"b1Weak"]}}))),a=l(i)((({theme:e,$size:t="medium",checked:i})=>{const l="small"===t,o=l?24:32,a=l?24:32;return{width:l?48:64,height:o,padding:0,overflow:"visible","& .MuiSwitch-switchBase":{padding:0,transitionDuration:"200ms","&.Mui-checked":{transform:`translateX(${l?24:32}px)`,color:e.palette.semantic.fill["fill-white"],"& .MuiSwitch-thumb":{borderColor:e.palette.semantic.stroke["stroke-selected"]},"& + .MuiSwitch-track":{backgroundColor:e.palette.semantic.fill["fill-selected"],borderColor:e.palette.semantic.stroke["stroke-selected"],opacity:1},"&.Mui-disabled + .MuiSwitch-track":{backgroundColor:e.palette.semantic.fill["fill-disabled"],borderColor:e.palette.semantic.stroke["stroke-disabled"],opacity:1}},"&.Mui-focusVisible + .MuiSwitch-track":{outline:`2px solid ${e.palette.semantic.stroke["stroke-focus"]}`,outlineOffset:"2px"},"&.Mui-disabled .MuiSwitch-thumb":{color:e.palette.semantic.fill["fill-white"]},"&.Mui-disabled + .MuiSwitch-track":{backgroundColor:e.palette.semantic.fill["fill-disabled"],borderColor:e.palette.semantic.stroke["stroke-disabled"],opacity:1}},"& .MuiSwitch-thumb":{width:a,height:a,backgroundColor:e.palette.semantic.fill["fill-white"],border:`2px solid ${e.palette.semantic.stroke["stroke-strong"]}`,transition:e.transitions.create(["border-color"],{duration:200})},"& .MuiSwitch-track":{borderRadius:o,backgroundColor:e.palette.semantic.fill["fill-weak"],border:`1px solid ${e.palette.semantic.stroke["stroke-strong"]}`,boxShadow:i?"none":e.customShadows?.sunken,opacity:1,transition:e.transitions.create(["background-color","border-color","outline"],{duration:200})},"&:hover .MuiSwitch-switchBase:not(.Mui-checked):not(.Mui-disabled) + .MuiSwitch-track":{backgroundColor:e.palette.semantic.fill["fill-hover"]},"&:active .MuiSwitch-switchBase:not(.Mui-checked):not(.Mui-disabled) + .MuiSwitch-track":{backgroundColor:e.palette.semantic.fill["fill-press"]}}})),r=({checked:t,disabled:i=!1,label:l,labelPlacement:r="end",onChange:s,size:c="medium",fdKey:d})=>l?e(o,{$size:c,control:e(a,{disableRipple:!0,$size:c,checked:t,"data-fd":d,disabled:i,onChange:s}),disabled:i,label:l,labelPlacement:r}):e(a,{disableRipple:!0,$size:c,checked:t,"data-fd":d,disabled:i,onChange:s});export{r as default};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Switch/index.tsx"],"sourcesContent":["import FormControlLabel, { type FormControlLabelProps } from '@mui/material/FormControlLabel';\nimport MuiSwitch, { type SwitchProps as MuiSwitchProps } from '@mui/material/Switch';\n\nimport styled from '@fd/utilities/styledUtilities';\nimport type { ReactElement } from 'react';\n\nconst StyledFormControlLabel = styled(FormControlLabel)<{ $size?: 'medium' | 'small' }>(({ theme, $size = 'medium' }) => ({\n color: theme.palette.semantic.text['text-strong'],\n gap: '12px',\n margin: 0,\n '& .MuiFormControlLabel-label': {\n ...theme.typography[$size === 'small' ? 'captionWeak' : 'b1Weak'],\n },\n}));\n\nconst StyledSwitch = styled(MuiSwitch)<{ $size?: 'medium' | 'small' }>(({ theme, $size = 'medium', checked }) => {\n const isSmall = $size === 'small';\n const width = isSmall ? 48 : 64;\n const height = isSmall ? 24 : 32;\n const thumbSize = isSmall ? 24 : 32;\n const translateX = isSmall ? 24 : 32;\n\n return {\n width,\n height,\n padding: 0,\n overflow: 'visible',\n '& .MuiSwitch-switchBase': {\n padding: 0,\n transitionDuration: '200ms',\n '&.Mui-checked': {\n transform: `translateX(${translateX}px)`,\n color: theme.palette.semantic.fill['fill-white'],\n '& .MuiSwitch-thumb': {\n borderColor: theme.palette.semantic.stroke['stroke-selected'],\n },\n '& + .MuiSwitch-track': {\n backgroundColor: theme.palette.semantic.fill['fill-selected'],\n borderColor: theme.palette.semantic.stroke['stroke-selected'],\n opacity: 1,\n },\n '&.Mui-disabled + .MuiSwitch-track': {\n backgroundColor: theme.palette.semantic.fill['fill-disabled'],\n borderColor: theme.palette.semantic.stroke['stroke-disabled'],\n opacity: 1,\n },\n },\n '&.Mui-focusVisible + .MuiSwitch-track': {\n outline: `2px solid ${theme.palette.semantic.stroke['stroke-focus']}`,\n outlineOffset: '2px',\n },\n '&.Mui-disabled .MuiSwitch-thumb': {\n color: theme.palette.semantic.fill['fill-white'],\n },\n '&.Mui-disabled + .MuiSwitch-track': {\n backgroundColor: theme.palette.semantic.fill['fill-disabled'],\n borderColor: theme.palette.semantic.stroke['stroke-disabled'],\n opacity: 1,\n },\n },\n '& .MuiSwitch-thumb': {\n width: thumbSize,\n height: thumbSize,\n backgroundColor: theme.palette.semantic.fill['fill-white'],\n border: `2px solid ${theme.palette.semantic.stroke['stroke-strong']}`,\n transition: theme.transitions.create(['border-color'], {\n duration: 200,\n }),\n },\n '& .MuiSwitch-track': {\n borderRadius: height,\n backgroundColor: theme.palette.semantic.fill['fill-weak'],\n border: `1px solid ${theme.palette.semantic.stroke['stroke-strong']}`,\n boxShadow: checked ? 'none' : theme.customShadows?.sunken,\n opacity: 1,\n transition: theme.transitions.create(['background-color', 'border-color', 'outline'], {\n duration: 200,\n }),\n },\n '&:hover .MuiSwitch-switchBase:not(.Mui-checked):not(.Mui-disabled) + .MuiSwitch-track': {\n backgroundColor: theme.palette.semantic.fill['fill-hover'],\n },\n '&:active .MuiSwitch-switchBase:not(.Mui-checked):not(.Mui-disabled) + .MuiSwitch-track': {\n backgroundColor: theme.palette.semantic.fill['fill-press'],\n },\n };\n});\n\nexport interface SwitchProps {\n /** Whether the switch is checked (on) or unchecked (off) */\n checked?: boolean;\n /** Whether the switch is disabled and cannot be interacted with */\n disabled?: boolean;\n /** Optional label text to display next to the switch */\n label?: string;\n /** Position of the label relative to the switch. Options: 'start', 'end', 'top', 'bottom'. Default: 'end' */\n labelPlacement?: FormControlLabelProps['labelPlacement'];\n /** Callback fired when the switch state changes. Receives the event and checked state */\n onChange?: MuiSwitchProps['onChange'];\n /** Size of the switch. Options: 'small' (48x24px), 'medium' (64x32px). Default: 'medium' */\n size?: 'medium' | 'small';\n /** Test ID for the switch element */\n fdKey: string;\n}\n\nconst Switch = ({ checked, disabled = false, label, labelPlacement = 'end', onChange, size = 'medium', fdKey }: SwitchProps): ReactElement => {\n if (!label) {\n return <StyledSwitch disableRipple $size={size} checked={checked} data-fd={fdKey} disabled={disabled} onChange={onChange} />;\n }\n\n return (\n <StyledFormControlLabel\n $size={size}\n control={<StyledSwitch disableRipple $size={size} checked={checked} data-fd={fdKey} disabled={disabled} onChange={onChange} />}\n disabled={disabled}\n label={label}\n labelPlacement={labelPlacement}\n />\n );\n};\n\nexport default Switch;\n"],"names":["StyledFormControlLabel","styled","FormControlLabel","theme","$size","color","palette","semantic","text","gap","margin","typography","StyledSwitch","MuiSwitch","checked","isSmall","height","thumbSize","width","padding","overflow","transitionDuration","transform","fill","borderColor","stroke","backgroundColor","opacity","outline","outlineOffset","border","transition","transitions","create","duration","borderRadius","boxShadow","customShadows","sunken","Switch","disabled","label","labelPlacement","onChange","size","fdKey","_jsx","control","disableRipple"],"mappings":"wKAMA,MAAMA,EAAyBC,EAAOC,EAAPD,EAAyD,EAAGE,QAAOC,QAAQ,aAAU,CAChHC,MAAOF,EAAMG,QAAQC,SAASC,KAAK,eACnCC,IAAK,OACLC,OAAQ,EACR,+BAAgC,IACzBP,EAAMQ,WAAqB,UAAVP,EAAoB,cAAgB,eAI1DQ,EAAeX,EAAOY,EAAPZ,EAAkD,EAAGE,QAAOC,QAAQ,SAAUU,cAC/F,MAAMC,EAAoB,UAAVX,EAEVY,EAASD,EAAU,GAAK,GACxBE,EAAYF,EAAU,GAAK,GAGjC,MAAO,CACHG,MANUH,EAAU,GAAK,GAOzBC,SACAG,QAAS,EACTC,SAAU,UACV,0BAA2B,CACvBD,QAAS,EACTE,mBAAoB,QACpB,gBAAiB,CACbC,UAAW,cAXJP,EAAU,GAAK,QAYtBV,MAAOF,EAAMG,QAAQC,SAASgB,KAAK,cACnC,qBAAsB,CAClBC,YAAarB,EAAMG,QAAQC,SAASkB,OAA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EAAClC,EAAY,CAACoC,uBAAqBJ,EAAM9B,QAASA,YAAkB+B,EAAOL,SAAUA,EAAUG,SAAUA,IAClHH,SAAUA,EACVC,MAAOA,EACPC,eAAgBA,IATbI,EAAClC,EAAY,CAACoC,uBAAqBJ,EAAM9B,QAASA,YAAkB+B,EAAOL,SAAUA,EAAUG,SAAUA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("@mui/material/Box"),t=require("../../../themes/tokens/typography/line-height.cjs.js");require("../../../themes/typography.cjs.js");var i=require("@mui/material/styles"),a=require("@mui/material/Typography");const h=i.styled(r,{shouldForwardProp:e=>"variant"!==e})((({variant:e})=>({flex:"1 0 0",height:t.lineHeight.desktop[{h1:"h1",h2:"h2",h3:"h3",h4:"h4",body:"b1",caption:"caption"}[e]],display:"flex"})));module.exports=({variant:r,children:t})=>e.jsx(h,{variant:r,children:e.jsx(a,{variant:{h1:"h1Strong",h2:"h2Strong",h3:"h3Strong",h4:"h4Strong",body:"b1Weak",caption:"captionWeak"}[r],children:t})});
|
|
2
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../../src/components/atoms/Text/index.tsx"],"sourcesContent":["import Box from '@fd/components/atoms/Box';\nimport { lineHeight } from '@fd/themes/tokens/typography/line-height';\nimport { typography } from '@fd/themes/typography';\nimport styled from '@fd/utilities/styledUtilities';\n\nimport Typography from '../Typography';\n\nexport type TextVariant = 'body' | 'caption' | 'h1' | 'h2' | 'h3' | 'h4';\n\nexport interface TextProps {\n variant: TextVariant;\n children: React.ReactNode;\n}\n\ntype TypographyVariant = keyof typeof typography;\n\nconst TextFrame = styled(Box, {\n shouldForwardProp: (prop) => prop !== 'variant',\n})<{ variant: TextVariant }>(({ variant }) => {\n const lineHeightMap: Record<TextVariant, keyof typeof lineHeight.desktop> = {\n h1: 'h1',\n h2: 'h2',\n h3: 'h3',\n h4: 'h4',\n body: 'b1',\n caption: 'caption',\n };\n\n return {\n flex: '1 0 0',\n height: lineHeight.desktop[lineHeightMap[variant]],\n display: 'flex',\n };\n});\n\nconst Text: React.FC<TextProps> = ({ variant, children }) => {\n const variantMap: Record<TextVariant, TypographyVariant> = {\n h1: 'h1Strong',\n h2: 'h2Strong',\n h3: 'h3Strong',\n h4: 'h4Strong',\n body: 'b1Weak',\n caption: 'captionWeak',\n };\n\n return (\n <TextFrame variant={variant}>\n <Typography variant={variantMap[variant]}>{children}</Typography>\n </TextFrame>\n );\n};\n\nexport default Text;\n"],"names":["TextFrame","styled","Box","shouldForwardProp","prop","variant","flex","height","lineHeight","desktop","h1","h2","h3","h4","body","caption","display","children","_jsx","Typography"],"mappings":"0QAgBA,MAAMA,EAAYC,EAAAA,OAAOC,EAAK,CAC5BC,kBAAoBC,GAAkB,YAATA,GADbH,EAEW,EAAGI,cAUvB,CACLC,KAAM,QACNC,OAAQC,EAAAA,WAAWC,QAXuD,CAC1EC,GAAI,KACJC,GAAI,KACJC,GAAI,KACJC,GAAI,KACJC,KAAM,KACNC,QAAS,WAKgCV,IACzCW,QAAS,0BAIqB,EAAGX,UAASY,cAW1CC,EAAAA,IAAClB,EAAS,CAACK,QAASA,EAAOY,SACzBC,MAACC,EAAU,CAACd,QAX2C,CACzDK,GAAI,WACJC,GAAI,WACJC,GAAI,WACJC,GAAI,WACJC,KAAM,SACNC,QAAS,eAKyBV,YAAWY"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type TextVariant = 'body' | 'caption' | 'h1' | 'h2' | 'h3' | 'h4';
|
|
2
|
+
interface TextProps {
|
|
3
|
+
variant: TextVariant;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
declare const Text: React.FC<TextProps>;
|
|
7
|
+
|
|
8
|
+
export { Text as default };
|
|
9
|
+
export type { TextProps, TextVariant };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import r from"@mui/material/Box";import{lineHeight as o}from"../../../themes/tokens/typography/line-height.js";import"../../../themes/typography.js";import{styled as a}from"@mui/material/styles";import h from"@mui/material/Typography";const i=a(r,{shouldForwardProp:t=>"variant"!==t})((({variant:t})=>({flex:"1 0 0",height:o.desktop[{h1:"h1",h2:"h2",h3:"h3",h4:"h4",body:"b1",caption:"caption"}[t]],display:"flex"}))),e=({variant:r,children:o})=>t(i,{variant:r,children:t(h,{variant:{h1:"h1Strong",h2:"h2Strong",h3:"h3Strong",h4:"h4Strong",body:"b1Weak",caption:"captionWeak"}[r],children:o})});export{e as default};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Text/index.tsx"],"sourcesContent":["import Box from '@fd/components/atoms/Box';\nimport { lineHeight } from '@fd/themes/tokens/typography/line-height';\nimport { typography } from '@fd/themes/typography';\nimport styled from '@fd/utilities/styledUtilities';\n\nimport Typography from '../Typography';\n\nexport type TextVariant = 'body' | 'caption' | 'h1' | 'h2' | 'h3' | 'h4';\n\nexport interface TextProps {\n variant: TextVariant;\n children: React.ReactNode;\n}\n\ntype TypographyVariant = keyof typeof typography;\n\nconst TextFrame = styled(Box, {\n shouldForwardProp: (prop) => prop !== 'variant',\n})<{ variant: TextVariant }>(({ variant }) => {\n const lineHeightMap: Record<TextVariant, keyof typeof lineHeight.desktop> = {\n h1: 'h1',\n h2: 'h2',\n h3: 'h3',\n h4: 'h4',\n body: 'b1',\n caption: 'caption',\n };\n\n return {\n flex: '1 0 0',\n height: lineHeight.desktop[lineHeightMap[variant]],\n display: 'flex',\n };\n});\n\nconst Text: React.FC<TextProps> = ({ variant, children }) => {\n const variantMap: Record<TextVariant, TypographyVariant> = {\n h1: 'h1Strong',\n h2: 'h2Strong',\n h3: 'h3Strong',\n h4: 'h4Strong',\n body: 'b1Weak',\n caption: 'captionWeak',\n };\n\n return (\n <TextFrame variant={variant}>\n <Typography variant={variantMap[variant]}>{children}</Typography>\n </TextFrame>\n );\n};\n\nexport default Text;\n"],"names":["TextFrame","styled","Box","shouldForwardProp","prop","variant","flex","height","lineHeight","desktop","h1","h2","h3","h4","body","caption","display","Text","children","_jsx","Typography"],"mappings":"mRAgBA,MAAMA,EAAYC,EAAOC,EAAK,CAC5BC,kBAAoBC,GAAkB,YAATA,GADbH,EAEW,EAAGI,cAUvB,CACLC,KAAM,QACNC,OAAQC,EAAWC,QAXuD,CAC1EC,GAAI,KACJC,GAAI,KACJC,GAAI,KACJC,GAAI,KACJC,KAAM,KACNC,QAAS,WAKgCV,IACzCW,QAAS,WAIPC,EAA4B,EAAGZ,UAASa,cAW1CC,EAACnB,EAAS,CAACK,QAASA,EAAOa,SACzBC,EAACC,EAAU,CAACf,QAX2C,CACzDK,GAAI,WACJC,GAAI,WACJC,GAAI,WACJC,GAAI,WACJC,KAAM,SACNC,QAAS,eAKyBV,YAAWa"}
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),a=require("@mui/material/FormControlLabel"),r=require("@mui/material/Switch");module.exports=({label:l,checked:t,onChange:i,labelPlacement:m="start",size:s="medium",disabled:c=!1,testId:d})=>e.jsx(a,{label:l,labelPlacement:m,control:e.jsx(r,{checked:t,onChange:i,color:"primary",size:s,disabled:c,"data-fd":d})});
|
|
2
|
-
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../../src/components/Switch/index.tsx"],"sourcesContent":["import FormControlLabel, { type FormControlLabelProps } from '@mui/material/FormControlLabel';\nimport MuiSwitch, { type SwitchProps as MuiSwitchProps } from '@mui/material/Switch';\n\nexport type SwitchProps = {\n label: string;\n labelPlacement?: FormControlLabelProps['labelPlacement'];\n checked?: boolean;\n onChange?: MuiSwitchProps['onChange'];\n size?: MuiSwitchProps['size'];\n disabled?: boolean;\n testId?: string;\n};\n\nconst Switch = ({ label, checked, onChange, labelPlacement = 'start', size = 'medium', disabled = false, testId = undefined }: SwitchProps) => {\n return (\n <FormControlLabel\n label={label}\n labelPlacement={labelPlacement}\n control={<MuiSwitch checked={checked} onChange={onChange} color=\"primary\" size={size} disabled={disabled} data-fd={testId} />}\n />\n );\n};\n\nexport default Switch;\n"],"names":["label","checked","onChange","labelPlacement","size","disabled","testId","_jsx","FormControlLabel","control","MuiSwitch","color"],"mappings":"6IAae,EAAGA,QAAOC,UAASC,WAAUC,iBAAiB,QAASC,OAAO,SAAUC,YAAW,EAAOC,YAEjGC,MAACC,GACGR,MAAOA,EACPG,eAAgBA,EAChBM,QAASF,MAACG,EAAS,CAACT,QAASA,EAASC,SAAUA,EAAUS,MAAM,UAAUP,KAAMA,EAAMC,SAAUA,EAAQ,UAAWC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { FormControlLabelProps } from '@mui/material/FormControlLabel';
|
|
3
|
-
import { SwitchProps as SwitchProps$1 } from '@mui/material/Switch';
|
|
4
|
-
|
|
5
|
-
type SwitchProps = {
|
|
6
|
-
label: string;
|
|
7
|
-
labelPlacement?: FormControlLabelProps['labelPlacement'];
|
|
8
|
-
checked?: boolean;
|
|
9
|
-
onChange?: SwitchProps$1['onChange'];
|
|
10
|
-
size?: SwitchProps$1['size'];
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
testId?: string;
|
|
13
|
-
};
|
|
14
|
-
declare const Switch: ({ label, checked, onChange, labelPlacement, size, disabled, testId }: SwitchProps) => react_jsx_runtime.JSX.Element;
|
|
15
|
-
|
|
16
|
-
export { Switch as default };
|
|
17
|
-
export type { SwitchProps };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import a from"@mui/material/FormControlLabel";import t from"@mui/material/Switch";const l=({label:l,checked:r,onChange:m,labelPlacement:o="start",size:i="medium",disabled:c=!1,testId:d})=>e(a,{label:l,labelPlacement:o,control:e(t,{checked:r,onChange:m,color:"primary",size:i,disabled:c,"data-fd":d})});export{l as default};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/Switch/index.tsx"],"sourcesContent":["import FormControlLabel, { type FormControlLabelProps } from '@mui/material/FormControlLabel';\nimport MuiSwitch, { type SwitchProps as MuiSwitchProps } from '@mui/material/Switch';\n\nexport type SwitchProps = {\n label: string;\n labelPlacement?: FormControlLabelProps['labelPlacement'];\n checked?: boolean;\n onChange?: MuiSwitchProps['onChange'];\n size?: MuiSwitchProps['size'];\n disabled?: boolean;\n testId?: string;\n};\n\nconst Switch = ({ label, checked, onChange, labelPlacement = 'start', size = 'medium', disabled = false, testId = undefined }: SwitchProps) => {\n return (\n <FormControlLabel\n label={label}\n labelPlacement={labelPlacement}\n control={<MuiSwitch checked={checked} onChange={onChange} color=\"primary\" size={size} disabled={disabled} data-fd={testId} />}\n />\n );\n};\n\nexport default Switch;\n"],"names":["Switch","label","checked","onChange","labelPlacement","size","disabled","testId","_jsx","FormControlLabel","control","MuiSwitch","color"],"mappings":"0HAaA,MAAMA,EAAS,EAAGC,QAAOC,UAASC,WAAUC,iBAAiB,QAASC,OAAO,SAAUC,YAAW,EAAOC,YAEjGC,EAACC,GACGR,MAAOA,EACPG,eAAgBA,EAChBM,QAASF,EAACG,EAAS,CAACT,QAASA,EAASC,SAAUA,EAAUS,MAAM,UAAUP,KAAMA,EAAMC,SAAUA,EAAQ,UAAWC"}
|