tfy-web-components 0.0.6 → 0.0.7

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.
@@ -6,6 +6,9 @@ import { LightTooltip, DarkTooltip } from "./Tooltip.es.js";
6
6
  import "classnames";
7
7
  import "tailwind-merge";
8
8
  import "@fortawesome/react-fontawesome";
9
+ import "../theme/useTheme.es.js";
10
+ import "../theme/theme.es.js";
11
+ import "../theme/colors.es.js";
9
12
  import "@mui/material/styles/styled";
10
13
  import "@mui/material/Tooltip";
11
14
  const iconSizeMap = {
@@ -1 +1 @@
1
- {"version":3,"file":"Button.es.js","sources":["../../../src/components/atoms/Button.tsx"],"sourcesContent":["import React, { ReactElement, ReactNode } from 'react'\nimport type { FontAwesomeIconProps } from '@fortawesome/react-fontawesome'\n\nimport classNames from '@/utils/classNames'\n\nimport IconProvider from './IconProvider'\nimport { CustomTooltipProps, DarkTooltip, LightTooltip } from './Tooltip'\n\ntype TooltipProps = Partial<Pick<CustomTooltipProps, 'title' | 'placement' | 'size'>> & {\n disabledTitle?: ReactNode\n}\nexport type ButtonSize = 'large' | 'small'\n\nexport interface ButtonProps {\n id?: string\n icon?: FontAwesomeIconProps['icon'] | string\n text?: React.ReactNode | JSX.Element | string\n block?: boolean\n disabled?: boolean\n loading?: boolean\n dataTestId?: string\n iconToRight?: boolean\n variant?: 'primary' | 'secondary' | 'ghost' | 'tertiary' | 'destructive'\n size?: ButtonSize\n onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void\n iconClasses?: string\n type?: 'submit' | 'reset' | 'button'\n tooltipProps?: TooltipProps\n iconSize?: number\n removeIconContainer?: boolean\n isMenuItem?: boolean\n useLightTooltip?: boolean\n}\n\nconst iconSizeMap = {\n small: 0.75,\n large: 0.875,\n}\n\ntype ButtonComponent = React.ForwardRefExoticComponent<ButtonProps> & {\n Ghost: React.ForwardRefExoticComponent<ButtonProps>\n Primary: React.ForwardRefExoticComponent<ButtonProps>\n Secondary: React.ForwardRefExoticComponent<ButtonProps>\n Tertiary: React.ForwardRefExoticComponent<ButtonProps>\n Destructive: React.ForwardRefExoticComponent<ButtonProps>\n}\n\ntype WrapperProps = {\n condition: boolean\n tooltipWrapper: (children: ReactElement) => JSX.Element\n children: ReactElement\n}\n\nconst getIconContainerSize = (size: ButtonSize, isGhostOrTertiary: boolean, removeContainer: boolean) => {\n const baseClasses = 'flex items-center justify-center'\n\n if (isGhostOrTertiary) {\n return size === 'large' ? `h-3.5 w-3.5 ${baseClasses}` : `h-3 w-3 ${baseClasses}`\n }\n\n if (size === 'large') {\n const width = removeContainer ? 'w-2.5' : 'w-4'\n return `h-4 ${width} ${baseClasses}`\n }\n\n return `h-2.5 w-2.5 ${baseClasses}`\n}\n\nconst Wrapper: React.FC<WrapperProps> = ({ condition, tooltipWrapper, children }) =>\n condition ? tooltipWrapper(children) : <div className={''}>{children}</div>\n\n// TODO: icon related all configs should be clubbed together.\n// Why is iconClasses needed?\n// That control shouldn't be provided.\nconst ButtonBase = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n text,\n icon,\n block = false,\n disabled = false,\n loading = false,\n dataTestId,\n iconToRight = false,\n variant = 'primary',\n size = 'large',\n onClick,\n iconClasses,\n tooltipProps,\n iconSize,\n type,\n removeIconContainer = false,\n isMenuItem,\n id,\n useLightTooltip = false,\n },\n ref,\n ) => {\n const isDisabled = loading || disabled\n const isIconOnly = text && !!icon\n\n const variantClasses = {\n primary: classNames('bg-gray-1000 text-white', {\n 'hover:bg-gray-750': !isDisabled,\n }),\n secondary: classNames('bg-white text-gray-750 border border-gray-250', {\n 'hover:bg-gray-750 hover:text-white hover:border-gray-750': !isDisabled,\n }),\n ghost: classNames('bg-transparent text-gray-750 border-none shadow-none', {\n 'hover:bg-gray-150': !isDisabled,\n }),\n tertiary: classNames('bg-white border text-gray-550 border-gray-250 font-work', {\n 'hover:border-gray-550': !isDisabled,\n }),\n destructive: classNames('bg-white text-rose-500 border border-gray-250', {\n 'hover:bg-rose-500 hover:text-white hover:border-rose-500': !isDisabled,\n }),\n }\n\n const sizeClasses = {\n large: `h-8 ${isIconOnly ? 'px-[0.4375rem]' : 'px-2.5'} text-sm`,\n small: 'h-6 px-1.5 gap-1 text-xs',\n }\n\n const iconContainer = {\n large: getIconContainerSize('large', ['tertiary', 'ghost'].includes(variant), removeIconContainer),\n small: getIconContainerSize('small', ['tertiary', 'ghost'].includes(variant), removeIconContainer),\n }\n\n const classes = classNames(\n 'group/btn shadow-sm gap-2 font-medium flex relative items-center justify-center outline-none transition-all duration-150 rounded-sm whitespace-nowrap font-lab',\n 'disabled:cursor-not-allowed disabled:opacity-40',\n variantClasses[variant],\n sizeClasses[size],\n {\n 'justify-start w-full': isMenuItem,\n 'w-full': block,\n },\n )\n\n const iconClassVariant = {\n primary: 'text-white',\n secondary: isDisabled ? 'text-gray-500' : 'text-gray-500 group-hover/btn:text-white',\n ghost: 'text-gray-750',\n tertiary: 'text-gray-550',\n destructive: isDisabled ? '' : 'group-hover/btn:text-white',\n }\n\n const iconClass = classNames(iconClassVariant[variant], iconContainer[size], {\n [`${iconClasses}`]: iconClasses,\n })\n\n const tooltipWrapper = (children: ReactElement) =>\n disabled || useLightTooltip ? (\n <LightTooltip\n title={tooltipProps?.disabledTitle || tooltipProps?.title}\n placement={tooltipProps?.placement}\n size={tooltipProps?.size}\n >\n {children}\n </LightTooltip>\n ) : (\n <DarkTooltip title={tooltipProps?.title} placement={tooltipProps?.placement} size={tooltipProps?.size}>\n {children}\n </DarkTooltip>\n )\n\n const iconComp = icon && (\n <div className={iconClass}>\n <IconProvider icon={icon} size={iconSize || iconSizeMap[size]} />\n </div>\n )\n\n const spinnerComp = (\n <div className={iconClass}>\n <IconProvider icon=\"fa-spinner\" className=\"fa-spin\" size={iconSizeMap[size]} />\n </div>\n )\n\n const renderedIcon = loading ? spinnerComp : iconComp\n\n return (\n <Wrapper condition={!!tooltipProps?.title || !!tooltipProps?.disabledTitle} tooltipWrapper={tooltipWrapper}>\n <button\n id={id}\n type={type}\n onClick={onClick}\n className={classes}\n disabled={isDisabled}\n ref={ref}\n data-test={dataTestId}\n >\n {!iconToRight && renderedIcon}\n {text}\n {iconToRight && renderedIcon}\n </button>\n </Wrapper>\n )\n },\n)\n\nconst GhostButton = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => (\n <ButtonBase {...props} ref={ref} variant=\"ghost\" />\n))\n\nconst PrimaryButton = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => (\n <ButtonBase {...props} ref={ref} variant=\"primary\" />\n))\n\nconst SecondaryButton = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => (\n <ButtonBase {...props} ref={ref} variant=\"secondary\" />\n))\n\nconst TertiaryButton = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => (\n <ButtonBase {...props} ref={ref} variant=\"tertiary\" />\n))\n\nconst DestructiveButton = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => (\n <ButtonBase {...props} ref={ref} variant=\"destructive\" />\n))\n\nconst Button = ButtonBase as ButtonComponent\n\nButton.displayName = 'Button'\n\nButton.Ghost = GhostButton\nButton.Primary = PrimaryButton\nButton.Secondary = SecondaryButton\nButton.Tertiary = TertiaryButton\nButton.Destructive = DestructiveButton\n\nexport { Button, DestructiveButton, GhostButton, PrimaryButton, SecondaryButton, TertiaryButton }\nexport default Button\n"],"names":["React"],"mappings":";;;;;;;;;;AAkCA,MAAM,cAAc;AAAA,EAClB,OAAO;AAAA,EACP,OAAO;AACT;AAgBA,MAAM,uBAAuB,CAAC,MAAkB,mBAA4B,oBAA6B;AACvG,QAAM,cAAc;AAEpB,MAAI,mBAAmB;AACrB,WAAO,SAAS,UAAU,eAAe,WAAW,KAAK,WAAW,WAAW;AAAA,EACjF;AAEA,MAAI,SAAS,SAAS;AACd,UAAA,QAAQ,kBAAkB,UAAU;AACnC,WAAA,OAAO,KAAK,IAAI,WAAW;AAAA,EACpC;AAEA,SAAO,eAAe,WAAW;AACnC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UAAA;AAAA,UAAA,CAAC,eAAe;AAAA,UAChB;AAAA,UACA,eAAe;AAAA,QAAA;AAAA,MAAA;AAAA,IAEpB,EAAA,CAAA;AAAA,EAEJ;AACF;AAEA,MAAM,cAAcA,eAAM,WAA2C,CAAC,OAAO,QAC1E,oBAAA,YAAA,EAAY,GAAG,OAAO,KAAU,SAAQ,QAAQ,CAAA,CAClD;AAED,MAAM,gBAAgBA,eAAM,WAA2C,CAAC,OAAO,QAC5E,oBAAA,YAAA,EAAY,GAAG,OAAO,KAAU,SAAQ,UAAU,CAAA,CACpD;AAED,MAAM,kBAAkBA,eAAM,WAA2C,CAAC,OAAO,QAC9E,oBAAA,YAAA,EAAY,GAAG,OAAO,KAAU,SAAQ,YAAY,CAAA,CACtD;AAED,MAAM,iBAAiBA,eAAM,WAA2C,CAAC,OAAO,QAC7E,oBAAA,YAAA,EAAY,GAAG,OAAO,KAAU,SAAQ,WAAW,CAAA,CACrD;AAED,MAAM,oBAAoBA,eAAM,WAA2C,CAAC,OAAO,QAChF,oBAAA,YAAA,EAAY,GAAG,OAAO,KAAU,SAAQ,cAAc,CAAA,CACxD;AAED,MAAM,SAAS;AAEf,OAAO,cAAc;AAErB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,YAAY;AACnB,OAAO,WAAW;AAClB,OAAO,cAAc;"}
1
+ {"version":3,"file":"Button.es.js","sources":["../../../src/components/atoms/Button.tsx"],"sourcesContent":["import React, { ReactElement, ReactNode } from 'react'\nimport type { FontAwesomeIconProps } from '@fortawesome/react-fontawesome'\n\nimport classNames from '@/utils/classNames'\n\nimport IconProvider from './IconProvider'\nimport { CustomTooltipProps, DarkTooltip, LightTooltip } from './Tooltip'\n\ntype TooltipProps = Partial<Pick<CustomTooltipProps, 'title' | 'placement' | 'size'>> & {\n disabledTitle?: ReactNode\n}\nexport type ButtonSize = 'large' | 'small'\n\nexport interface ButtonProps {\n id?: string\n icon?: FontAwesomeIconProps['icon'] | string\n text?: React.ReactNode | JSX.Element | string\n block?: boolean\n disabled?: boolean\n loading?: boolean\n dataTestId?: string\n iconToRight?: boolean\n variant?: 'primary' | 'secondary' | 'ghost' | 'tertiary' | 'destructive'\n size?: ButtonSize\n onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void\n iconClasses?: string\n type?: 'submit' | 'reset' | 'button'\n tooltipProps?: TooltipProps\n iconSize?: number\n removeIconContainer?: boolean\n isMenuItem?: boolean\n useLightTooltip?: boolean\n}\n\nconst iconSizeMap = {\n small: 0.75,\n large: 0.875,\n}\n\ntype ButtonComponent = React.ForwardRefExoticComponent<ButtonProps> & {\n Ghost: React.ForwardRefExoticComponent<ButtonProps>\n Primary: React.ForwardRefExoticComponent<ButtonProps>\n Secondary: React.ForwardRefExoticComponent<ButtonProps>\n Tertiary: React.ForwardRefExoticComponent<ButtonProps>\n Destructive: React.ForwardRefExoticComponent<ButtonProps>\n}\n\ntype WrapperProps = {\n condition: boolean\n tooltipWrapper: (children: ReactElement) => JSX.Element\n children: ReactElement\n}\n\nconst getIconContainerSize = (size: ButtonSize, isGhostOrTertiary: boolean, removeContainer: boolean) => {\n const baseClasses = 'flex items-center justify-center'\n\n if (isGhostOrTertiary) {\n return size === 'large' ? `h-3.5 w-3.5 ${baseClasses}` : `h-3 w-3 ${baseClasses}`\n }\n\n if (size === 'large') {\n const width = removeContainer ? 'w-2.5' : 'w-4'\n return `h-4 ${width} ${baseClasses}`\n }\n\n return `h-2.5 w-2.5 ${baseClasses}`\n}\n\nconst Wrapper: React.FC<WrapperProps> = ({ condition, tooltipWrapper, children }) =>\n condition ? tooltipWrapper(children) : <div className={''}>{children}</div>\n\n// TODO: icon related all configs should be clubbed together.\n// Why is iconClasses needed?\n// That control shouldn't be provided.\nconst ButtonBase = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n text,\n icon,\n block = false,\n disabled = false,\n loading = false,\n dataTestId,\n iconToRight = false,\n variant = 'primary',\n size = 'large',\n onClick,\n iconClasses,\n tooltipProps,\n iconSize,\n type,\n removeIconContainer = false,\n isMenuItem,\n id,\n useLightTooltip = false,\n },\n ref,\n ) => {\n const isDisabled = loading || disabled\n const isIconOnly = text && !!icon\n\n const variantClasses = {\n primary: classNames('bg-gray-1000 text-white', {\n 'hover:bg-gray-750': !isDisabled,\n }),\n secondary: classNames('bg-white text-gray-750 border border-gray-250', {\n 'hover:bg-gray-750 hover:text-white hover:border-gray-750': !isDisabled,\n }),\n ghost: classNames('bg-transparent text-gray-750 border-none shadow-none', {\n 'hover:bg-gray-150': !isDisabled,\n }),\n tertiary: classNames('bg-white border text-gray-550 border-gray-250 font-work', {\n 'hover:border-gray-550': !isDisabled,\n }),\n destructive: classNames('bg-white text-rose-500 border border-gray-250', {\n 'hover:bg-rose-500 hover:text-white hover:border-rose-500': !isDisabled,\n }),\n }\n\n const sizeClasses = {\n large: `h-8 ${isIconOnly ? 'px-[0.4375rem]' : 'px-2.5'} text-sm`,\n small: 'h-6 px-1.5 gap-1 text-xs',\n }\n\n const iconContainer = {\n large: getIconContainerSize('large', ['tertiary', 'ghost'].includes(variant), removeIconContainer),\n small: getIconContainerSize('small', ['tertiary', 'ghost'].includes(variant), removeIconContainer),\n }\n\n const classes = classNames(\n 'group/btn shadow-sm gap-2 font-medium flex relative items-center justify-center outline-none transition-all duration-150 rounded-sm whitespace-nowrap font-lab',\n 'disabled:cursor-not-allowed disabled:opacity-40',\n variantClasses[variant],\n sizeClasses[size],\n {\n 'justify-start w-full': isMenuItem,\n 'w-full': block,\n },\n )\n\n const iconClassVariant = {\n primary: 'text-white',\n secondary: isDisabled ? 'text-gray-500' : 'text-gray-500 group-hover/btn:text-white',\n ghost: 'text-gray-750',\n tertiary: 'text-gray-550',\n destructive: isDisabled ? '' : 'group-hover/btn:text-white',\n }\n\n const iconClass = classNames(iconClassVariant[variant], iconContainer[size], {\n [`${iconClasses}`]: iconClasses,\n })\n\n const tooltipWrapper = (children: ReactElement) =>\n disabled || useLightTooltip ? (\n <LightTooltip\n title={tooltipProps?.disabledTitle || tooltipProps?.title}\n placement={tooltipProps?.placement}\n size={tooltipProps?.size}\n >\n {children}\n </LightTooltip>\n ) : (\n <DarkTooltip title={tooltipProps?.title} placement={tooltipProps?.placement} size={tooltipProps?.size}>\n {children}\n </DarkTooltip>\n )\n\n const iconComp = icon && (\n <div className={iconClass}>\n <IconProvider icon={icon} size={iconSize || iconSizeMap[size]} />\n </div>\n )\n\n const spinnerComp = (\n <div className={iconClass}>\n <IconProvider icon=\"fa-spinner\" className=\"fa-spin\" size={iconSizeMap[size]} />\n </div>\n )\n\n const renderedIcon = loading ? spinnerComp : iconComp\n\n return (\n <Wrapper condition={!!tooltipProps?.title || !!tooltipProps?.disabledTitle} tooltipWrapper={tooltipWrapper}>\n <button\n id={id}\n type={type}\n onClick={onClick}\n className={classes}\n disabled={isDisabled}\n ref={ref}\n data-test={dataTestId}\n >\n {!iconToRight && renderedIcon}\n {text}\n {iconToRight && renderedIcon}\n </button>\n </Wrapper>\n )\n },\n)\n\nconst GhostButton = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => (\n <ButtonBase {...props} ref={ref} variant=\"ghost\" />\n))\n\nconst PrimaryButton = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => (\n <ButtonBase {...props} ref={ref} variant=\"primary\" />\n))\n\nconst SecondaryButton = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => (\n <ButtonBase {...props} ref={ref} variant=\"secondary\" />\n))\n\nconst TertiaryButton = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => (\n <ButtonBase {...props} ref={ref} variant=\"tertiary\" />\n))\n\nconst DestructiveButton = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => (\n <ButtonBase {...props} ref={ref} variant=\"destructive\" />\n))\n\nconst Button = ButtonBase as ButtonComponent\n\nButton.displayName = 'Button'\n\nButton.Ghost = GhostButton\nButton.Primary = PrimaryButton\nButton.Secondary = SecondaryButton\nButton.Tertiary = TertiaryButton\nButton.Destructive = DestructiveButton\n\nexport { Button, DestructiveButton, GhostButton, PrimaryButton, SecondaryButton, TertiaryButton }\nexport default Button\n"],"names":["React"],"mappings":";;;;;;;;;;;;;AAkCA,MAAM,cAAc;AAAA,EAClB,OAAO;AAAA,EACP,OAAO;AACT;AAgBA,MAAM,uBAAuB,CAAC,MAAkB,mBAA4B,oBAA6B;AACvG,QAAM,cAAc;AAEpB,MAAI,mBAAmB;AACrB,WAAO,SAAS,UAAU,eAAe,WAAW,KAAK,WAAW,WAAW;AAAA,EACjF;AAEA,MAAI,SAAS,SAAS;AACd,UAAA,QAAQ,kBAAkB,UAAU;AACnC,WAAA,OAAO,KAAK,IAAI,WAAW;AAAA,EACpC;AAEA,SAAO,eAAe,WAAW;AACnC;AAEA,MAAM,UAAkC,CAAC,EAAE,WAAW,gBAAgB,SAAS,MAC7E,YAAY,eAAe,QAAQ,IAAI,oBAAC,OAAI,EAAA,WAAW,IAAK,SAAS,CAAA;AAKvE,MAAM,aAAaA,eAAM;AAAA,EACvB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,UAAU;AAAA,IACV;AAAA,IACA,cAAc;AAAA,IACd,UAAU;AAAA,IACV,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,sBAAsB;AAAA,IACtB;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,KAEpB,QACG;AACH,UAAM,aAAa,WAAW;AACxB,UAAA,aAAa,QAAQ,CAAC,CAAC;AAE7B,UAAM,iBAAiB;AAAA,MACrB,SAAS,WAAW,2BAA2B;AAAA,QAC7C,qBAAqB,CAAC;AAAA,MAAA,CACvB;AAAA,MACD,WAAW,WAAW,iDAAiD;AAAA,QACrE,4DAA4D,CAAC;AAAA,MAAA,CAC9D;AAAA,MACD,OAAO,WAAW,wDAAwD;AAAA,QACxE,qBAAqB,CAAC;AAAA,MAAA,CACvB;AAAA,MACD,UAAU,WA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;AACjB,OAAO,YAAY;AACnB,OAAO,WAAW;AAClB,OAAO,cAAc;"}
@@ -6,6 +6,9 @@ import "classnames";
6
6
  import "tailwind-merge";
7
7
  import "react";
8
8
  import "@fortawesome/react-fontawesome";
9
+ import "../theme/useTheme.es.js";
10
+ import "../theme/theme.es.js";
11
+ import "../theme/colors.es.js";
9
12
  import "@mui/material/styles/styled";
10
13
  import "@mui/material/Tooltip";
11
14
  const IconButton = ({ icon, iconSize, onClick, disabled, tooltip }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.es.js","sources":["../../../src/components/atoms/IconButton.tsx"],"sourcesContent":["import React from 'react'\nimport { IconProp } from '@fortawesome/fontawesome-svg-core'\n\nimport classNames from '@/utils/classNames'\n\nimport IconProvider from './IconProvider'\nimport { DarkTooltip } from './Tooltip'\n\ninterface IconButtonProps {\n icon: string | IconProp\n onClick?: (e: React.MouseEvent) => void\n iconSize?: number\n disabled?: boolean\n tooltip?: string\n}\n\nconst IconButton: React.FC<IconButtonProps> = ({ icon, iconSize, onClick, disabled, tooltip }) => {\n const classes = classNames('text-gray-450 hover:text-gray-750 cursor-pointer w-3', {\n 'text-gray-450 hover:text-gray-450 pointer-event-none opacity-40': disabled,\n })\n\n return (\n <DarkTooltip title={tooltip}>\n <span className=\"leading-none\">\n <IconProvider icon={icon} size={iconSize} onClick={onClick} className={classes} />\n </span>\n </DarkTooltip>\n )\n}\n\nexport default IconButton\n"],"names":[],"mappings":";;;;;;;;;;AAgBM,MAAA,aAAwC,CAAC,EAAE,MAAM,UAAU,SAAS,UAAU,cAAc;AAC1F,QAAA,UAAU,WAAW,wDAAwD;AAAA,IACjF,mEAAmE;AAAA,EAAA,CACpE;AAED,6BACG,aAAY,EAAA,OAAO,SAClB,UAAA,oBAAC,UAAK,WAAU,gBACd,UAAC,oBAAA,cAAA,EAAa,MAAY,MAAM,UAAU,SAAkB,WAAW,QAAA,CAAS,EAClF,CAAA,EACF,CAAA;AAEJ;"}
1
+ {"version":3,"file":"IconButton.es.js","sources":["../../../src/components/atoms/IconButton.tsx"],"sourcesContent":["import React from 'react'\nimport { IconProp } from '@fortawesome/fontawesome-svg-core'\n\nimport classNames from '@/utils/classNames'\n\nimport IconProvider from './IconProvider'\nimport { DarkTooltip } from './Tooltip'\n\ninterface IconButtonProps {\n icon: string | IconProp\n onClick?: (e: React.MouseEvent) => void\n iconSize?: number\n disabled?: boolean\n tooltip?: string\n}\n\nconst IconButton: React.FC<IconButtonProps> = ({ icon, iconSize, onClick, disabled, tooltip }) => {\n const classes = classNames('text-gray-450 hover:text-gray-750 cursor-pointer w-3', {\n 'text-gray-450 hover:text-gray-450 pointer-event-none opacity-40': disabled,\n })\n\n return (\n <DarkTooltip title={tooltip}>\n <span className=\"leading-none\">\n <IconProvider icon={icon} size={iconSize} onClick={onClick} className={classes} />\n </span>\n </DarkTooltip>\n )\n}\n\nexport default IconButton\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgBM,MAAA,aAAwC,CAAC,EAAE,MAAM,UAAU,SAAS,UAAU,cAAc;AAC1F,QAAA,UAAU,WAAW,wDAAwD;AAAA,IACjF,mEAAmE;AAAA,EAAA,CACpE;AAED,6BACG,aAAY,EAAA,OAAO,SAClB,UAAA,oBAAC,UAAK,WAAU,gBACd,UAAC,oBAAA,cAAA,EAAa,MAAY,MAAM,UAAU,SAAkB,WAAW,QAAA,CAAS,EAClF,CAAA,EACF,CAAA;AAEJ;"}
@@ -2,8 +2,11 @@ import { jsx } from "react/jsx-runtime";
2
2
  import React__default, { forwardRef, Suspense } from "react";
3
3
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
4
4
  import { c as classNames } from "../../classNames-f3c6f58e.js";
5
+ import { useTheme } from "../theme/useTheme.es.js";
5
6
  import "classnames";
6
7
  import "tailwind-merge";
8
+ import "../theme/theme.es.js";
9
+ import "../theme/colors.es.js";
7
10
  const IMG_ICONS_MAP = {};
8
11
  const registerImgIcons = (iconMap) => {
9
12
  Object.assign(IMG_ICONS_MAP, iconMap);
@@ -22,6 +25,24 @@ const DynamicIcon = ({ name, ...props }) => {
22
25
  const IconToRender = CUSTOM_ICONS_MAP[name];
23
26
  return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("span", {}), children: /* @__PURE__ */ jsx(IconToRender, { ...props }) });
24
27
  };
28
+ function addDarkSuffix(url) {
29
+ const urlObj = new URL(url);
30
+ const parts = urlObj.pathname.split("/");
31
+ const filename = parts.pop();
32
+ if (!filename) {
33
+ return url + "-dark";
34
+ }
35
+ const dotIndex = filename.lastIndexOf(".");
36
+ let newFilename;
37
+ if (dotIndex !== -1) {
38
+ newFilename = filename.slice(0, dotIndex) + "-dark" + filename.slice(dotIndex);
39
+ } else {
40
+ newFilename = filename + "-dark";
41
+ }
42
+ parts.push(newFilename);
43
+ urlObj.pathname = parts.join("/");
44
+ return urlObj.toString();
45
+ }
25
46
  const IconProvider = ({
26
47
  icon,
27
48
  color,
@@ -32,17 +53,32 @@ const IconProvider = ({
32
53
  forwardedRef,
33
54
  nativeProps = {}
34
55
  }) => {
35
- const imgIcon = typeof icon === "string" && icon.startsWith("http") ? icon : IMG_ICONS_MAP[icon];
56
+ const { isDark } = useTheme();
57
+ let themeAwareImgIcon = null;
58
+ let fallbackImgIcon = null;
59
+ if (typeof icon === "string" && icon.startsWith("http")) {
60
+ themeAwareImgIcon = isDark ? addDarkSuffix(icon) : icon;
61
+ fallbackImgIcon = icon;
62
+ } else if (typeof icon === "string" && IMG_ICONS_MAP[icon]) {
63
+ themeAwareImgIcon = isDark ? IMG_ICONS_MAP[`${icon}-dark`] ?? IMG_ICONS_MAP[icon] : IMG_ICONS_MAP[icon];
64
+ fallbackImgIcon = IMG_ICONS_MAP[icon];
65
+ } else if (Array.isArray(icon) && icon[1] && IMG_ICONS_MAP[icon[1]]) {
66
+ themeAwareImgIcon = isDark ? IMG_ICONS_MAP[`${icon[1]}-dark`] ?? IMG_ICONS_MAP[icon[1]] : IMG_ICONS_MAP[icon[1]];
67
+ fallbackImgIcon = IMG_ICONS_MAP[icon[1]];
68
+ }
36
69
  const faIcon = FA_ICON_ALIAS_MAP[icon] || icon;
37
70
  const iconStyles = width ? { width: `${width}rem`, height: "auto" } : { height: `${size}rem`, width: "auto" };
38
- return imgIcon ? /* @__PURE__ */ jsx(
71
+ return themeAwareImgIcon ? /* @__PURE__ */ jsx(
39
72
  "img",
40
73
  {
41
74
  ref: forwardedRef,
42
- src: imgIcon,
75
+ src: themeAwareImgIcon,
43
76
  style: iconStyles,
44
77
  className: classNames(className),
45
- onClick
78
+ onClick,
79
+ onError: (e) => {
80
+ e.currentTarget.src = fallbackImgIcon;
81
+ }
46
82
  }
47
83
  ) : CUSTOM_ICONS_MAP[icon] ? /* @__PURE__ */ jsx(DynamicIcon, { onClick, style: { ...iconStyles, color }, name: String(icon), className }) : /* @__PURE__ */ jsx(
48
84
  FontAwesomeIcon,
@@ -1 +1 @@
1
- {"version":3,"file":"IconProvider.es.js","sources":["../../../src/components/atoms/IconProvider.tsx"],"sourcesContent":["import React, { ForwardedRef, forwardRef, Suspense } from 'react'\nimport { IconProp } from '@fortawesome/fontawesome-svg-core'\nimport { FontAwesomeIcon, FontAwesomeIconProps } from '@fortawesome/react-fontawesome'\n\nimport classNames from '@/utils/classNames'\n\ntype ImgIconMap = { [key: string]: string }\nconst IMG_ICONS_MAP: ImgIconMap = {}\nexport const registerImgIcons = (iconMap: ImgIconMap) => {\n Object.assign(IMG_ICONS_MAP, iconMap)\n}\n\ntype CustomIcon = React.ComponentType<CustomIconProps>\ntype CustomIconMap = {\n [key: string]: React.LazyExoticComponent<CustomIcon> | CustomIcon\n}\nconst CUSTOM_ICONS_MAP: CustomIconMap = {}\nexport const registerIcons = (iconMap: CustomIconMap) => {\n Object.assign(CUSTOM_ICONS_MAP, iconMap)\n}\n\nconst FA_ICON_ALIAS_MAP: { readonly [key: string]: string } = {\n github: 'fa-brands fa-github',\n gitlab: 'fa-brands fa-gitlab',\n bitbucket: 'fa-brands fa-bitbucket',\n jenkins: 'fa-brands fa-jenkins',\n}\n\ninterface IconProps {\n icon: string | IconProp\n color?: string\n className?: string\n onClick?: (e: React.MouseEvent) => void\n size?: number\n width?: number\n forwardedRef?: React.Ref<HTMLElement>\n nativeProps?: Partial<FontAwesomeIconProps>\n}\n\ntype CustomIconProps = {\n onClick?: (e: React.MouseEvent) => void\n className?: string\n style?: React.CSSProperties\n}\ntype DynamicIconProps = CustomIconProps & {\n name: string\n}\n\nconst DynamicIcon = ({ name, ...props }: DynamicIconProps) => {\n const IconToRender = CUSTOM_ICONS_MAP[name]\n return (\n <Suspense fallback={<span />}>\n <IconToRender {...props} />\n </Suspense>\n )\n}\n\nconst IconProvider = ({\n icon,\n color,\n size = 0.75,\n width,\n className,\n onClick,\n forwardedRef,\n nativeProps = {},\n}: IconProps) => {\n const imgIcon = typeof icon === 'string' && icon.startsWith('http') ? icon : IMG_ICONS_MAP[icon as string]\n const faIcon = FA_ICON_ALIAS_MAP[icon as string] || icon\n\n const iconStyles = width ? { width: `${width}rem`, height: 'auto' } : { height: `${size}rem`, width: 'auto' }\n\n return imgIcon ? (\n <img\n ref={forwardedRef as React.ForwardedRef<HTMLImageElement>}\n src={imgIcon}\n style={iconStyles}\n className={classNames(className)}\n onClick={onClick}\n />\n ) : CUSTOM_ICONS_MAP[icon as string] ? (\n <DynamicIcon onClick={onClick} style={{ ...iconStyles, color }} name={String(icon)} className={className} />\n ) : (\n <FontAwesomeIcon\n ref={forwardedRef as ForwardedRef<SVGSVGElement>}\n icon={faIcon as IconProp}\n style={{ color, fontSize: `${width ?? size}rem` }}\n className={classNames('text-xs', className)}\n onClick={onClick}\n {...nativeProps}\n />\n )\n}\n\nexport default React.memo(\n forwardRef<HTMLElement, IconProps>((props, ref) => <IconProvider {...props} forwardedRef={ref} />),\n)\n"],"names":["React"],"mappings":";;;;;;AAOA,MAAM,gBAA4B,CAAA;AACrB,MAAA,mBAAmB,CAAC,YAAwB;AAChD,SAAA,OAAO,eAAe,OAA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AAS;AAAA,MAC1C;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;AAEA,MAAeA,iBAAAA,eAAM;AAAA,EACnB,WAAmC,CAAC,OAAO,QAAQ,oBAAC,gBAAc,GAAG,OAAO,cAAc,IAAA,CAAK,CAAE;AACnG;"}
1
+ {"version":3,"file":"IconProvider.es.js","sources":["../../../src/components/atoms/IconProvider.tsx"],"sourcesContent":["import React, { ForwardedRef, forwardRef, Suspense } from 'react'\nimport { IconProp } from '@fortawesome/fontawesome-svg-core'\nimport { FontAwesomeIcon, FontAwesomeIconProps } from '@fortawesome/react-fontawesome'\n\nimport classNames from '@/utils/classNames'\n\nimport useTheme from '../theme/useTheme'\n\ntype ImgIconMap = { [key: string]: string }\nconst IMG_ICONS_MAP: ImgIconMap = {}\nexport const registerImgIcons = (iconMap: ImgIconMap) => {\n Object.assign(IMG_ICONS_MAP, iconMap)\n}\n\ntype CustomIcon = React.ComponentType<CustomIconProps>\ntype CustomIconMap = {\n [key: string]: React.LazyExoticComponent<CustomIcon> | CustomIcon\n}\nconst CUSTOM_ICONS_MAP: CustomIconMap = {}\nexport const registerIcons = (iconMap: CustomIconMap) => {\n Object.assign(CUSTOM_ICONS_MAP, iconMap)\n}\n\nconst FA_ICON_ALIAS_MAP: { readonly [key: string]: string } = {\n github: 'fa-brands fa-github',\n gitlab: 'fa-brands fa-gitlab',\n bitbucket: 'fa-brands fa-bitbucket',\n jenkins: 'fa-brands fa-jenkins',\n}\n\ninterface IconProps {\n icon: string | IconProp\n color?: string\n className?: string\n onClick?: (e: React.MouseEvent) => void\n size?: number\n width?: number\n forwardedRef?: React.Ref<HTMLElement>\n nativeProps?: Partial<FontAwesomeIconProps>\n}\n\ntype CustomIconProps = {\n onClick?: (e: React.MouseEvent) => void\n className?: string\n style?: React.CSSProperties\n}\ntype DynamicIconProps = CustomIconProps & {\n name: string\n}\n\nconst DynamicIcon = ({ name, ...props }: DynamicIconProps) => {\n const IconToRender = CUSTOM_ICONS_MAP[name]\n return (\n <Suspense fallback={<span />}>\n <IconToRender {...props} />\n </Suspense>\n )\n}\n\nfunction addDarkSuffix(url: string): string {\n const urlObj = new URL(url)\n const parts = urlObj.pathname.split('/')\n const filename = parts.pop()\n\n if (!filename) {\n return url + '-dark'\n }\n\n const dotIndex = filename.lastIndexOf('.')\n let newFilename: string\n\n if (dotIndex !== -1) {\n newFilename = filename.slice(0, dotIndex) + '-dark' + filename.slice(dotIndex)\n } else {\n newFilename = filename + '-dark'\n }\n\n parts.push(newFilename)\n urlObj.pathname = parts.join('/')\n return urlObj.toString()\n}\n\nconst IconProvider = ({\n icon,\n color,\n size = 0.75,\n width,\n className,\n onClick,\n forwardedRef,\n nativeProps = {},\n}: IconProps) => {\n const { isDark } = useTheme()\n let themeAwareImgIcon: string | null = null\n let fallbackImgIcon: string | null = null\n\n if (typeof icon === 'string' && icon.startsWith('http')) {\n themeAwareImgIcon = isDark ? addDarkSuffix(icon) : icon\n fallbackImgIcon = icon\n } else if (typeof icon === 'string' && IMG_ICONS_MAP[icon as string]) {\n themeAwareImgIcon = isDark\n ? IMG_ICONS_MAP[`${icon}-dark`] ?? IMG_ICONS_MAP[icon as string]\n : IMG_ICONS_MAP[icon as string]\n fallbackImgIcon = IMG_ICONS_MAP[icon as string]\n } else if (Array.isArray(icon) && icon[1] && IMG_ICONS_MAP[icon[1] as string]) {\n themeAwareImgIcon = isDark\n ? IMG_ICONS_MAP[`${icon[1]}-dark`] ?? IMG_ICONS_MAP[icon[1] as string]\n : IMG_ICONS_MAP[icon[1] as string]\n fallbackImgIcon = IMG_ICONS_MAP[icon[1] as string]\n }\n\n const faIcon = FA_ICON_ALIAS_MAP[icon as string] || icon\n\n const iconStyles = width ? { width: `${width}rem`, height: 'auto' } : { height: `${size}rem`, width: 'auto' }\n\n return themeAwareImgIcon ? (\n <img\n ref={forwardedRef as React.ForwardedRef<HTMLImageElement>}\n src={themeAwareImgIcon}\n style={iconStyles}\n className={classNames(className)}\n onClick={onClick}\n onError={(e) => {\n e.currentTarget.src = fallbackImgIcon as string\n }}\n />\n ) : CUSTOM_ICONS_MAP[icon as string] ? (\n <DynamicIcon onClick={onClick} style={{ ...iconStyles, color }} name={String(icon)} className={className} />\n ) : (\n <FontAwesomeIcon\n ref={forwardedRef as ForwardedRef<SVGSVGElement>}\n icon={faIcon as IconProp}\n style={{ color, fontSize: `${width ?? size}rem` }}\n className={classNames('text-xs', className)}\n onClick={onClick}\n {...nativeProps}\n />\n )\n}\n\nexport default React.memo(\n forwardRef<HTMLElement, IconProps>((props, ref) => <IconProvider {...props} forwardedRef={ref} />),\n)\n"],"names":["React"],"mappings":";;;;;;;;;AASA,MAAM,gBAA4B,CAAA;AACrB,MAAA,mBAAmB,CAAC,YAAwB;AAChD,SAAA,OAAO,eAAe,OAAO;AACtC;AAMA,MAAM,mBAAkC,CAAA;AAC3B,MAAA,gBAAgB,CAAC,YAA2B;AAChD,SAAA,OAAO,kBAAkB,OAAO;AACzC;AAEA,MAAM,oBAAwD;AAAA,EAC5D,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,SAAS;AACX;AAsBA,MAAM,cAAc,CAAC,EAAE,MAAM,GAAG,YAA8B;AACtD,QAAA,eAAe,iBAAiB,IAAI;AAExC,SAAA,oBAAC,UAAS,EAAA,UAAW,oBAAA,QAAA,CAAK,CAAA,GACxB,UAAC,oBAAA,cAAA,EAAc,GAAG,MAAO,CAAA,EAC3B,CAAA;AAEJ;AAEA,SAAS,cAAc,KAAqB;AACpC,QAAA,SAAS,IAAI,IAAI,GAAG;AAC1B,QAAM,QAAQ,OAAO,SAAS,MAAM,GAAG;AACjC,QAAA,WAAW,MAAM;AAEvB,MAAI,CAAC,UAAU;AACb,WAAO,MAAM;AAAA,EACf;AAEM,QAAA,WAAW,SAAS,YAAY,GAAG;AACrC,MAAA;AAEJ,MAAI,aAAa,IAAI;AACL,kBAAA,SAAS,MAAM,GAAG,QAAQ,IAAI,UAAU,SAAS,MAAM,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EAAA,IAEA,iBAAiB,IAAc,IAChC,oBAAA,aAAA,EAAY,SAAkB,OAAO,EAAE,GAAG,YAAY,MAAS,GAAA,MAAM,OAAO,IAAI,GAAG,UAAsB,CAAA,IAE1G;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO,EAAE,OAAO,UAAU,GAAG,SAAS,IAAI,MAAM;AAAA,MAChD,WAAW,WAAW,WAAW,SAAS;AAAA,MAC1C;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;AAEA,MAAeA,iBAAAA,eAAM;AAAA,EACnB,WAAmC,CAAC,OAAO,QAAQ,oBAAC,gBAAc,GAAG,OAAO,cAAc,IAAA,CAAK,CAAE;AACnG;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "tfy-web-components",
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "description": "Truefoundry web components",
6
6
  "author": "Truefoundry",
7
7
  "license": "ISC",