@lax-wp/design-system 0.13.47 → 0.13.48
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/forms/checkbox/Checkbox.cjs.js +1 -1
- package/dist/components/forms/checkbox/Checkbox.cjs.js.map +1 -1
- package/dist/components/forms/checkbox/Checkbox.es.js +56 -52
- package/dist/components/forms/checkbox/Checkbox.es.js.map +1 -1
- package/dist/components/user-avatar/UserAvatar.cjs.js +1 -1
- package/dist/components/user-avatar/UserAvatar.cjs.js.map +1 -1
- package/dist/components/user-avatar/UserAvatar.es.js +1 -1
- package/dist/components/user-avatar/UserAvatar.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),M=require("antd"),t=require("../../../_virtual/index.cjs.js"),f=require("framer-motion"),R=require("react"),g=require("../../data-display/typography/Typography.cjs.js"),h=R.forwardRef(({id:a,label:o,checked:s,isChecked:p,onChange:b,disabled:i=!1,required:l=!1,message:n,messageType:e="default",wrapperClassName:k,checkboxClassName:y,labelClassName:v,size:u="medium",variant:j="default",labelPosition:c="right",checkboxProps:w},C)=>{const z=s!==void 0?s:p||!1,N=()=>{switch(u){case"small":return"[--checkbox-size:clamp(10px,0.625vw,12px)]";case"large":return"[--checkbox-size:clamp(18px,calc(8px_+_0.625vw),20px)]";default:return"[--checkbox-size:clamp(14px,calc(4px_+_0.625vw),16px)]"}},q=()=>{if(e==="error")return"text-red-600 border-red-300 focus:ring-red-500 dark:focus:ring-red-600";if(e==="success")return"text-green-600 border-green-300 focus:ring-green-500 dark:focus:ring-green-600";if(e==="info")return"text-blue-600 border-blue-300 focus:ring-blue-500 dark:focus:ring-blue-600";switch(j){case"outline":return"text-primary-600 bg-transparent border-neutral-300 focus:ring-primary-500 dark:focus:ring-primary-600";case"solid":return"text-primary-600 bg-primary-50 border-primary-300 focus:ring-primary-500 dark:focus:ring-primary-600 dark:bg-primary-900/20";default:return"text-primary-600 bg-gray-100 border-gray-300 focus:ring-primary-500 dark:focus:ring-primary-600 dark:bg-neutral-600 dark:border-gray-600"}},_=()=>e==="error"?"text-red-500 dark:text-red-400":e==="success"?"text-green-500 dark:text-green-400":e==="info"?"text-blue-500 dark:text-blue-400":"text-neutral-500 dark:text-neutral-400",S=()=>{switch(u){case"small":return"extra-small";case"large":return"medium";default:return"small"}},F=m=>{b(m.target.checked,m)},d=r.jsx(M.Checkbox,{...w,ref:C,id:a,checked:z,onChange:F,disabled:i,className:t("rounded focus:ring-2 focus:ring-primary-500 dark:focus:ring-primary-400 focus:ring-offset-gray-800 transition-colors duration-200",N(),"w-[var(--checkbox-size)] h-[var(--checkbox-size)]","[&_.ant-checkbox-inner]:!w-[var(--checkbox-size)] [&_.ant-checkbox-inner]:!h-[var(--checkbox-size)]",q(),i&&"opacity-50 cursor-not-allowed",y),"aria-required":l,"aria-invalid":n&&e==="error"?"true":"false","aria-describedby":n?`${a}-message`:void 0}),x=o?r.jsx("label",{htmlFor:a,className:t("font-medium cursor-pointer transition-colors duration-200",i?"text-neutral-400 dark:text-neutral-600 cursor-not-allowed":"text-neutral-900 dark:text-neutral-100",c==="right"?"ml-2":"mr-2",v),children:r.jsxs(g.Typography,{variant:"medium",size:S(),appearance:"body",children:[o,l&&r.jsx("span",{className:"text-red-500 ml-1",children:"*"})]})}):null;return r.jsxs("div",{className:t("flex flex-col",k),children:[r.jsx("div",{className:t("flex items-center",c==="left"&&"flex-row-reverse justify-end"),children:c==="left"?r.jsxs(r.Fragment,{children:[d,x]}):r.jsxs(r.Fragment,{children:[d,x]})}),r.jsx(f.AnimatePresence,{children:n&&r.jsx(f.motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},id:`${a}-message`,role:e==="error"?"alert":void 0,children:r.jsx(g.Typography,{className:t("mt-1",_()),appearance:"custom",size:"extra-small",variant:"medium",children:n})})})]})});h.displayName="Checkbox";exports.Checkbox=h;
|
|
2
2
|
//# sourceMappingURL=Checkbox.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.cjs.js","sources":["../../../../src/components/forms/checkbox/Checkbox.tsx"],"sourcesContent":["import { Checkbox as AntdCheckbox } from \"antd\";\nimport type { CheckboxChangeEvent, CheckboxProps, CheckboxRef } from \"antd\";\nimport cn from \"classnames\";\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport { forwardRef } from \"react\";\nimport { Typography } from \"../../data-display/typography/Typography\";\n\n/**\n * Props for the Checkbox component\n */\nexport interface CheckboxComponentProps {\n /** Unique identifier for the checkbox */\n id: string;\n /** Label text to display next to the checkbox */\n label?: string;\n /** Whether the checkbox is checked */\n checked?: boolean;\n /** Whether the checkbox is checked (alias for checked) */\n isChecked?: boolean;\n /** Callback function called when checkbox state changes */\n onChange: (checked: boolean, event: CheckboxChangeEvent) => void;\n /** Whether the checkbox is disabled */\n disabled?: boolean;\n /** Whether the field is required */\n required?: boolean;\n /** Message to display below the checkbox */\n message?: string;\n /** Type of message to display */\n messageType?: \"success\" | \"error\" | \"info\" | \"default\";\n /** Additional CSS classes for the wrapper container */\n wrapperClassName?: string;\n /** Additional CSS classes for the checkbox input */\n checkboxClassName?: string;\n /** Additional CSS classes for the label */\n labelClassName?: string;\n /** Size variant for the checkbox */\n size?: \"small\" | \"medium\" | \"large\";\n /** Visual variant for the checkbox */\n variant?: \"default\" | \"outline\" | \"solid\";\n /** Whether to show the label on the left side */\n labelPosition?: \"left\" | \"right\";\n /** Additional props to pass to the Ant Design Checkbox */\n checkboxProps?: Omit<\n CheckboxProps,\n \"checked\" | \"onChange\" | \"id\" | \"disabled\"\n >;\n}\n\n/**\n * A highly customizable checkbox component with label, validation, and styling support.\n * Features dark mode support, accessibility enhancements, and comprehensive prop support.\n *\n * @example\n * ```tsx\n * <Checkbox\n * id=\"terms\"\n * label=\"I agree to the terms and conditions\"\n * checked={agreedToTerms}\n * onChange={(checked) => setAgreedToTerms(checked)}\n * required\n * />\n * ```\n */\nexport const Checkbox = forwardRef<CheckboxRef, CheckboxComponentProps>(\n (\n {\n id,\n label,\n checked,\n isChecked,\n onChange,\n disabled = false,\n required = false,\n message,\n messageType = \"default\",\n wrapperClassName,\n checkboxClassName,\n labelClassName,\n size = \"medium\",\n variant = \"default\",\n labelPosition = \"right\",\n checkboxProps,\n },\n ref\n ) => {\n // Use checked prop, fallback to isChecked for backward compatibility\n const isCheckboxChecked =\n checked !== undefined ? checked : isChecked || false;\n\n // Size-based styling\n const getSizeClasses = (): string => {\n switch (size) {\n case \"small\":\n return \"w-3 h-3\";\n case \"large\":\n return \"w-5 h-5\";\n default:\n return \"w-4 h-4\";\n }\n };\n\n // Variant-based styling\n const getVariantClasses = (): string => {\n if (messageType === \"error\") {\n return \"text-red-600 border-red-300 focus:ring-red-500 dark:focus:ring-red-600\";\n }\n if (messageType === \"success\") {\n return \"text-green-600 border-green-300 focus:ring-green-500 dark:focus:ring-green-600\";\n }\n if (messageType === \"info\") {\n return \"text-blue-600 border-blue-300 focus:ring-blue-500 dark:focus:ring-blue-600\";\n }\n\n switch (variant) {\n case \"outline\":\n return \"text-primary-600 bg-transparent border-neutral-300 focus:ring-primary-500 dark:focus:ring-primary-600\";\n case \"solid\":\n return \"text-primary-600 bg-primary-50 border-primary-300 focus:ring-primary-500 dark:focus:ring-primary-600 dark:bg-primary-900/20\";\n default:\n return \"text-primary-600 bg-gray-100 border-gray-300 focus:ring-primary-500 dark:focus:ring-primary-600 dark:bg-neutral-600 dark:border-gray-600\";\n }\n };\n\n // Message typography class\n const getMessageTypographyClass = (): string => {\n if (messageType === \"error\") return \"text-red-500 dark:text-red-400\";\n if (messageType === \"success\")\n return \"text-green-500 dark:text-green-400\";\n if (messageType === \"info\") return \"text-blue-500 dark:text-blue-400\";\n return \"text-neutral-500 dark:text-neutral-400\";\n };\n\n // Label typography size based on checkbox size\n const getLabelSize = (): \"extra-small\" | \"small\" | \"medium\" => {\n switch (size) {\n case \"small\":\n return \"extra-small\";\n case \"large\":\n return \"medium\";\n default:\n return \"small\";\n }\n };\n\n const handleChange = (e: CheckboxChangeEvent) => {\n onChange(e.target.checked, e);\n };\n\n const checkboxElement = (\n <AntdCheckbox\n {...checkboxProps}\n ref={ref}\n id={id}\n checked={isCheckboxChecked}\n onChange={handleChange}\n disabled={disabled}\n className={cn(\n // Base styles\n \"rounded focus:ring-2 focus:ring-primary-500 dark:focus:ring-primary-400 focus:ring-offset-gray-800 transition-colors duration-200\",\n\n // Size classes\n getSizeClasses(),\n\n // Variant classes\n getVariantClasses(),\n\n // Disabled styles\n disabled && \"opacity-50 cursor-not-allowed\",\n\n // Custom classes\n checkboxClassName\n )}\n aria-required={required}\n aria-invalid={message && messageType === \"error\" ? \"true\" : \"false\"}\n aria-describedby={message ? `${id}-message` : undefined}\n />\n );\n\n const labelElement = label ? (\n <label\n htmlFor={id}\n className={cn(\n \"font-medium cursor-pointer transition-colors duration-200\",\n disabled\n ? \"text-neutral-400 dark:text-neutral-600 cursor-not-allowed\"\n : \"text-neutral-900 dark:text-neutral-100\",\n labelPosition === \"right\" ? \"ml-2\" : \"mr-2\",\n labelClassName\n )}\n >\n <Typography variant=\"medium\" size={getLabelSize()} appearance=\"body\">\n {label}\n {required && <span className=\"text-red-500 ml-1\">*</span>}\n </Typography>\n </label>\n ) : null;\n\n return (\n <div className={cn(\"flex flex-col\", wrapperClassName)}>\n <div\n className={cn(\n \"flex items-center\",\n labelPosition === \"left\" && \"flex-row-reverse justify-end\"\n )}\n >\n {labelPosition === \"left\" ? (\n <>\n {checkboxElement}\n {labelElement}\n </>\n ) : (\n <>\n {checkboxElement}\n {labelElement}\n </>\n )}\n </div>\n\n {/* Message */}\n <AnimatePresence>\n {message && (\n <motion.div\n initial={{ opacity: 0, y: -10 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: -10 }}\n transition={{ duration: 0.2 }}\n id={`${id}-message`}\n role={messageType === \"error\" ? \"alert\" : undefined}\n >\n <Typography\n className={cn(\"mt-1\", getMessageTypographyClass())}\n appearance=\"custom\"\n size=\"extra-small\"\n variant=\"medium\"\n >\n {message}\n </Typography>\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n );\n }\n);\n\nCheckbox.displayName = \"Checkbox\";\n\n// Export type alias for backward compatibility\nexport type TCheckboxComponentProps = CheckboxComponentProps;\n"],"names":["Checkbox","forwardRef","id","label","checked","isChecked","onChange","disabled","required","message","messageType","wrapperClassName","checkboxClassName","labelClassName","size","variant","labelPosition","checkboxProps","ref","isCheckboxChecked","getSizeClasses","getVariantClasses","getMessageTypographyClass","getLabelSize","handleChange","e","checkboxElement","jsx","AntdCheckbox","cn","labelElement","jsxs","Typography","Fragment","AnimatePresence","motion"],"mappings":"8RA+DaA,EAAWC,EAAAA,WACtB,CACE,CACE,GAAAC,EACA,MAAAC,EACA,QAAAC,EACA,UAAAC,EACA,SAAAC,EACA,SAAAC,EAAW,GACX,SAAAC,EAAW,GACX,QAAAC,EACA,YAAAC,EAAc,UACd,iBAAAC,EACA,kBAAAC,EACA,eAAAC,EACA,KAAAC,EAAO,SACP,QAAAC,EAAU,UACV,cAAAC,EAAgB,QAChB,cAAAC,CAAA,EAEFC,IACG,CAEH,MAAMC,EACJf,IAAY,OAAYA,EAAUC,GAAa,GAG3Ce,EAAiB,IAAc,CACnC,OAAQN,EAAA,CACN,IAAK,QACH,MAAO,UACT,IAAK,QACH,MAAO,UACT,QACE,MAAO,SAAA,CAEb,EAGMO,EAAoB,IAAc,CACtC,GAAIX,IAAgB,QAClB,MAAO,yEAET,GAAIA,IAAgB,UAClB,MAAO,iFAET,GAAIA,IAAgB,OAClB,MAAO,6EAGT,OAAQK,EAAA,CACN,IAAK,UACH,MAAO,wGACT,IAAK,QACH,MAAO,8HACT,Q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AAA,CACH,CAAA,CAAA,EAKJH,EAAAA,IAACO,EAAAA,iBACE,SAAAzB,GACCkB,EAAAA,IAACQ,EAAAA,OAAO,IAAP,CACC,QAAS,CAAE,QAAS,EAAG,EAAG,GAAA,EAC1B,QAAS,CAAE,QAAS,EAAG,EAAG,CAAA,EAC1B,KAAM,CAAE,QAAS,EAAG,EAAG,GAAA,EACvB,WAAY,CAAE,SAAU,EAAA,EACxB,GAAI,GAAGjC,CAAE,WACT,KAAMQ,IAAgB,QAAU,QAAU,OAE1C,SAAAiB,EAAAA,IAACK,EAAAA,WAAA,CACC,UAAWH,EAAG,OAAQP,GAA2B,EACjD,WAAW,SACX,KAAK,cACL,QAAQ,SAEP,SAAAb,CAAA,CAAA,CACH,CAAA,CACF,CAEJ,CAAA,EACF,CAEJ,CACF,EAEAT,EAAS,YAAc"}
|
|
1
|
+
{"version":3,"file":"Checkbox.cjs.js","sources":["../../../../src/components/forms/checkbox/Checkbox.tsx"],"sourcesContent":["import { Checkbox as AntdCheckbox } from \"antd\";\nimport type { CheckboxChangeEvent, CheckboxProps, CheckboxRef } from \"antd\";\nimport cn from \"classnames\";\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport { forwardRef } from \"react\";\nimport { Typography } from \"../../data-display/typography/Typography\";\n\n/**\n * Props for the Checkbox component\n */\nexport interface CheckboxComponentProps {\n /** Unique identifier for the checkbox */\n id: string;\n /** Label text to display next to the checkbox */\n label?: string;\n /** Whether the checkbox is checked */\n checked?: boolean;\n /** Whether the checkbox is checked (alias for checked) */\n isChecked?: boolean;\n /** Callback function called when checkbox state changes */\n onChange: (checked: boolean, event: CheckboxChangeEvent) => void;\n /** Whether the checkbox is disabled */\n disabled?: boolean;\n /** Whether the field is required */\n required?: boolean;\n /** Message to display below the checkbox */\n message?: string;\n /** Type of message to display */\n messageType?: \"success\" | \"error\" | \"info\" | \"default\";\n /** Additional CSS classes for the wrapper container */\n wrapperClassName?: string;\n /** Additional CSS classes for the checkbox input */\n checkboxClassName?: string;\n /** Additional CSS classes for the label */\n labelClassName?: string;\n /** Size variant for the checkbox */\n size?: \"small\" | \"medium\" | \"large\";\n /** Visual variant for the checkbox */\n variant?: \"default\" | \"outline\" | \"solid\";\n /** Whether to show the label on the left side */\n labelPosition?: \"left\" | \"right\";\n /** Additional props to pass to the Ant Design Checkbox */\n checkboxProps?: Omit<\n CheckboxProps,\n \"checked\" | \"onChange\" | \"id\" | \"disabled\"\n >;\n}\n\n/**\n * A highly customizable checkbox component with label, validation, and styling support.\n * Features dark mode support, accessibility enhancements, and comprehensive prop support.\n *\n * @example\n * ```tsx\n * <Checkbox\n * id=\"terms\"\n * label=\"I agree to the terms and conditions\"\n * checked={agreedToTerms}\n * onChange={(checked) => setAgreedToTerms(checked)}\n * required\n * />\n * ```\n */\nexport const Checkbox = forwardRef<CheckboxRef, CheckboxComponentProps>(\n (\n {\n id,\n label,\n checked,\n isChecked,\n onChange,\n disabled = false,\n required = false,\n message,\n messageType = \"default\",\n wrapperClassName,\n checkboxClassName,\n labelClassName,\n size = \"medium\",\n variant = \"default\",\n labelPosition = \"right\",\n checkboxProps,\n },\n ref\n ) => {\n // Use checked prop, fallback to isChecked for backward compatibility\n const isCheckboxChecked =\n checked !== undefined ? checked : isChecked || false;\n\n // Fluid size scaling: each size clamps from 2px smaller on <=1600px\n // screens up to its full size at 1920px — the same clamp() curve used for\n // the fluid fontSize / icon spacing tokens in tailwind.config.js.\n const getSizeClasses = (): string => {\n switch (size) {\n case \"small\":\n return \"[--checkbox-size:clamp(10px,0.625vw,12px)]\";\n case \"large\":\n return \"[--checkbox-size:clamp(18px,calc(8px_+_0.625vw),20px)]\";\n default:\n return \"[--checkbox-size:clamp(14px,calc(4px_+_0.625vw),16px)]\";\n }\n };\n\n // Variant-based styling\n const getVariantClasses = (): string => {\n if (messageType === \"error\") {\n return \"text-red-600 border-red-300 focus:ring-red-500 dark:focus:ring-red-600\";\n }\n if (messageType === \"success\") {\n return \"text-green-600 border-green-300 focus:ring-green-500 dark:focus:ring-green-600\";\n }\n if (messageType === \"info\") {\n return \"text-blue-600 border-blue-300 focus:ring-blue-500 dark:focus:ring-blue-600\";\n }\n\n switch (variant) {\n case \"outline\":\n return \"text-primary-600 bg-transparent border-neutral-300 focus:ring-primary-500 dark:focus:ring-primary-600\";\n case \"solid\":\n return \"text-primary-600 bg-primary-50 border-primary-300 focus:ring-primary-500 dark:focus:ring-primary-600 dark:bg-primary-900/20\";\n default:\n return \"text-primary-600 bg-gray-100 border-gray-300 focus:ring-primary-500 dark:focus:ring-primary-600 dark:bg-neutral-600 dark:border-gray-600\";\n }\n };\n\n // Message typography class\n const getMessageTypographyClass = (): string => {\n if (messageType === \"error\") return \"text-red-500 dark:text-red-400\";\n if (messageType === \"success\")\n return \"text-green-500 dark:text-green-400\";\n if (messageType === \"info\") return \"text-blue-500 dark:text-blue-400\";\n return \"text-neutral-500 dark:text-neutral-400\";\n };\n\n // Label typography size based on checkbox size\n const getLabelSize = (): \"extra-small\" | \"small\" | \"medium\" => {\n switch (size) {\n case \"small\":\n return \"extra-small\";\n case \"large\":\n return \"medium\";\n default:\n return \"small\";\n }\n };\n\n const handleChange = (e: CheckboxChangeEvent) => {\n onChange(e.target.checked, e);\n };\n\n const checkboxElement = (\n <AntdCheckbox\n {...checkboxProps}\n ref={ref}\n id={id}\n checked={isCheckboxChecked}\n onChange={handleChange}\n disabled={disabled}\n className={cn(\n // Base styles\n \"rounded focus:ring-2 focus:ring-primary-500 dark:focus:ring-primary-400 focus:ring-offset-gray-800 transition-colors duration-200\",\n\n // Size classes — the clamp() value set by getSizeClasses drives the\n // antd wrapper and the visible .ant-checkbox-inner box (!important\n // needed to beat antd's own token-based width/height)\n getSizeClasses(),\n \"w-[var(--checkbox-size)] h-[var(--checkbox-size)]\",\n \"[&_.ant-checkbox-inner]:!w-[var(--checkbox-size)] [&_.ant-checkbox-inner]:!h-[var(--checkbox-size)]\",\n\n // Variant classes\n getVariantClasses(),\n\n // Disabled styles\n disabled && \"opacity-50 cursor-not-allowed\",\n\n // Custom classes\n checkboxClassName\n )}\n aria-required={required}\n aria-invalid={message && messageType === \"error\" ? \"true\" : \"false\"}\n aria-describedby={message ? `${id}-message` : undefined}\n />\n );\n\n const labelElement = label ? (\n <label\n htmlFor={id}\n className={cn(\n \"font-medium cursor-pointer transition-colors duration-200\",\n disabled\n ? \"text-neutral-400 dark:text-neutral-600 cursor-not-allowed\"\n : \"text-neutral-900 dark:text-neutral-100\",\n labelPosition === \"right\" ? \"ml-2\" : \"mr-2\",\n labelClassName\n )}\n >\n <Typography variant=\"medium\" size={getLabelSize()} appearance=\"body\">\n {label}\n {required && <span className=\"text-red-500 ml-1\">*</span>}\n </Typography>\n </label>\n ) : null;\n\n return (\n <div className={cn(\"flex flex-col\", wrapperClassName)}>\n <div\n className={cn(\n \"flex items-center\",\n labelPosition === \"left\" && \"flex-row-reverse justify-end\"\n )}\n >\n {labelPosition === \"left\" ? (\n <>\n {checkboxElement}\n {labelElement}\n </>\n ) : (\n <>\n {checkboxElement}\n {labelElement}\n </>\n )}\n </div>\n\n {/* Message */}\n <AnimatePresence>\n {message && (\n <motion.div\n initial={{ opacity: 0, y: -10 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: -10 }}\n transition={{ duration: 0.2 }}\n id={`${id}-message`}\n role={messageType === \"error\" ? \"alert\" : undefined}\n >\n <Typography\n className={cn(\"mt-1\", getMessageTypographyClass())}\n appearance=\"custom\"\n size=\"extra-small\"\n variant=\"medium\"\n >\n {message}\n </Typography>\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n );\n }\n);\n\nCheckbox.displayName = \"Checkbox\";\n\n// Export type alias for backward compatibility\nexport type TCheckboxComponentProps = CheckboxComponentProps;\n"],"names":["Checkbox","forwardRef","id","label","checked","isChecked","onChange","disabled","required","message","messageType","wrapperClassName","checkboxClassName","labelClassName","size","variant","labelPosition","checkboxProps","ref","isCheckboxChecked","getSizeClasses","getVariantClasses","getMessageTypographyClass","getLabelSize","handleChange","e","checkboxElement","jsx","AntdCheckbox","cn","labelElement","jsxs","Typography","Fragment","AnimatePresence","motion"],"mappings":"8RA+DaA,EAAWC,EAAAA,WACtB,CACE,CACE,GAAAC,EACA,MAAAC,EACA,QAAAC,EACA,UAAAC,EACA,SAAAC,EACA,SAAAC,EAAW,GACX,SAAAC,EAAW,GACX,QAAAC,EACA,YAAAC,EAAc,UACd,iBAAAC,EACA,kBAAAC,EACA,eAAAC,EACA,KAAAC,EAAO,SACP,QAAAC,EAAU,UACV,cAAAC,EAAgB,QAChB,cAAAC,CAAA,EAEFC,IACG,CAEH,MAAMC,EACJf,IAAY,OAAYA,EAAUC,GAAa,GAK3Ce,EAAiB,IAAc,CACnC,OAAQN,EAAA,CACN,IAAK,QACH,MAAO,6CACT,IAAK,QACH,MAAO,yDACT,QACE,MAAO,wDAAA,CAEb,EAGMO,EAAoB,IAAc,CACtC,GAAIX,IAAgB,QAClB,MAAO,yEAET,GAAIA,IAAgB,UAClB,MAAO,iFAET,GAAIA,IAAgB,OAClB,MAAO,6EAGT,OAAQK,EAAA,CACN,IAAK,UACH,MAAO,wGACT,IAAK,QACH,MAAO,8HACT,QACE,MAAO,0IAAA,CAEb,EAGMO,EAA4B,IAC5BZ,IAAgB,QAAgB,iCAChCA,IAAgB,UACX,qCACLA,IAAgB,OAAe,mCAC5B,yCAIHa,EAAe,IAA0C,CAC7D,OAAQT,EAAA,CACN,IAAK,QACH,MAAO,cACT,IAAK,QACH,MAAO,SACT,QACE,MAAO,OAAA,CAEb,EAEMU,EAAgBC,GAA2B,CAC/CnB,EAASmB,EAAE,OAAO,QAASA,CAAC,CAC9B,EAEMC,EACJC,EAAAA,IAACC,EAAAA,SAAA,CACE,GAAGX,EACJ,IAAAC,EACA,GAAAhB,EACA,QAASiB,EACT,SAAUK,EACV,SAAAjB,EACA,UAAWsB,EAET,oIAKAT,EAAA,EACA,oDACA,sGAGAC,EAAA,EAGAd,GAAY,gCAGZK,CAAA,EAEF,gBAAeJ,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F,EAEAT,EAAS,YAAc"}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { jsx as e, jsxs as i, Fragment as
|
|
2
|
-
import { Checkbox as
|
|
1
|
+
import { jsx as e, jsxs as i, Fragment as h } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox as F } from "antd";
|
|
3
3
|
import t from "../../../_virtual/index.es.js";
|
|
4
|
-
import { AnimatePresence as
|
|
5
|
-
import { forwardRef as
|
|
6
|
-
import { Typography as
|
|
7
|
-
const
|
|
4
|
+
import { AnimatePresence as S, motion as A } from "framer-motion";
|
|
5
|
+
import { forwardRef as L } from "react";
|
|
6
|
+
import { Typography as p } from "../../data-display/typography/Typography.es.js";
|
|
7
|
+
const M = L(
|
|
8
8
|
({
|
|
9
9
|
id: a,
|
|
10
10
|
label: l,
|
|
11
11
|
checked: s,
|
|
12
|
-
isChecked:
|
|
13
|
-
onChange:
|
|
14
|
-
disabled:
|
|
12
|
+
isChecked: g,
|
|
13
|
+
onChange: b,
|
|
14
|
+
disabled: c = !1,
|
|
15
15
|
required: u = !1,
|
|
16
16
|
message: n,
|
|
17
17
|
messageType: r = "default",
|
|
18
|
-
wrapperClassName:
|
|
19
|
-
checkboxClassName:
|
|
20
|
-
labelClassName:
|
|
18
|
+
wrapperClassName: k,
|
|
19
|
+
checkboxClassName: y,
|
|
20
|
+
labelClassName: v,
|
|
21
21
|
size: d = "medium",
|
|
22
|
-
variant:
|
|
23
|
-
labelPosition:
|
|
24
|
-
checkboxProps:
|
|
25
|
-
},
|
|
26
|
-
const
|
|
22
|
+
variant: w = "default",
|
|
23
|
+
labelPosition: o = "right",
|
|
24
|
+
checkboxProps: C
|
|
25
|
+
}, z) => {
|
|
26
|
+
const N = s !== void 0 ? s : g || !1, _ = () => {
|
|
27
27
|
switch (d) {
|
|
28
28
|
case "small":
|
|
29
|
-
return "
|
|
29
|
+
return "[--checkbox-size:clamp(10px,0.625vw,12px)]";
|
|
30
30
|
case "large":
|
|
31
|
-
return "
|
|
31
|
+
return "[--checkbox-size:clamp(18px,calc(8px_+_0.625vw),20px)]";
|
|
32
32
|
default:
|
|
33
|
-
return "
|
|
33
|
+
return "[--checkbox-size:clamp(14px,calc(4px_+_0.625vw),16px)]";
|
|
34
34
|
}
|
|
35
|
-
},
|
|
35
|
+
}, j = () => {
|
|
36
36
|
if (r === "error")
|
|
37
37
|
return "text-red-600 border-red-300 focus:ring-red-500 dark:focus:ring-red-600";
|
|
38
38
|
if (r === "success")
|
|
39
39
|
return "text-green-600 border-green-300 focus:ring-green-500 dark:focus:ring-green-600";
|
|
40
40
|
if (r === "info")
|
|
41
41
|
return "text-blue-600 border-blue-300 focus:ring-blue-500 dark:focus:ring-blue-600";
|
|
42
|
-
switch (
|
|
42
|
+
switch (w) {
|
|
43
43
|
case "outline":
|
|
44
44
|
return "text-primary-600 bg-transparent border-neutral-300 focus:ring-primary-500 dark:focus:ring-primary-600";
|
|
45
45
|
case "solid":
|
|
@@ -47,7 +47,7 @@ const R = M(
|
|
|
47
47
|
default:
|
|
48
48
|
return "text-primary-600 bg-gray-100 border-gray-300 focus:ring-primary-500 dark:focus:ring-primary-600 dark:bg-neutral-600 dark:border-gray-600";
|
|
49
49
|
}
|
|
50
|
-
},
|
|
50
|
+
}, $ = () => r === "error" ? "text-red-500 dark:text-red-400" : r === "success" ? "text-green-500 dark:text-green-400" : r === "info" ? "text-blue-500 dark:text-blue-400" : "text-neutral-500 dark:text-neutral-400", E = () => {
|
|
51
51
|
switch (d) {
|
|
52
52
|
case "small":
|
|
53
53
|
return "extra-small";
|
|
@@ -57,67 +57,71 @@ const R = M(
|
|
|
57
57
|
return "small";
|
|
58
58
|
}
|
|
59
59
|
}, m = /* @__PURE__ */ e(
|
|
60
|
-
|
|
60
|
+
F,
|
|
61
61
|
{
|
|
62
|
-
...
|
|
63
|
-
ref:
|
|
62
|
+
...C,
|
|
63
|
+
ref: z,
|
|
64
64
|
id: a,
|
|
65
|
-
checked:
|
|
66
|
-
onChange: (
|
|
67
|
-
|
|
65
|
+
checked: N,
|
|
66
|
+
onChange: (f) => {
|
|
67
|
+
b(f.target.checked, f);
|
|
68
68
|
},
|
|
69
|
-
disabled:
|
|
69
|
+
disabled: c,
|
|
70
70
|
className: t(
|
|
71
71
|
// Base styles
|
|
72
72
|
"rounded focus:ring-2 focus:ring-primary-500 dark:focus:ring-primary-400 focus:ring-offset-gray-800 transition-colors duration-200",
|
|
73
|
-
// Size classes
|
|
74
|
-
|
|
73
|
+
// Size classes — the clamp() value set by getSizeClasses drives the
|
|
74
|
+
// antd wrapper and the visible .ant-checkbox-inner box (!important
|
|
75
|
+
// needed to beat antd's own token-based width/height)
|
|
76
|
+
_(),
|
|
77
|
+
"w-[var(--checkbox-size)] h-[var(--checkbox-size)]",
|
|
78
|
+
"[&_.ant-checkbox-inner]:!w-[var(--checkbox-size)] [&_.ant-checkbox-inner]:!h-[var(--checkbox-size)]",
|
|
75
79
|
// Variant classes
|
|
76
|
-
|
|
80
|
+
j(),
|
|
77
81
|
// Disabled styles
|
|
78
|
-
|
|
82
|
+
c && "opacity-50 cursor-not-allowed",
|
|
79
83
|
// Custom classes
|
|
80
|
-
|
|
84
|
+
y
|
|
81
85
|
),
|
|
82
86
|
"aria-required": u,
|
|
83
87
|
"aria-invalid": n && r === "error" ? "true" : "false",
|
|
84
88
|
"aria-describedby": n ? `${a}-message` : void 0
|
|
85
89
|
}
|
|
86
|
-
),
|
|
90
|
+
), x = l ? /* @__PURE__ */ e(
|
|
87
91
|
"label",
|
|
88
92
|
{
|
|
89
93
|
htmlFor: a,
|
|
90
94
|
className: t(
|
|
91
95
|
"font-medium cursor-pointer transition-colors duration-200",
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
c ? "text-neutral-400 dark:text-neutral-600 cursor-not-allowed" : "text-neutral-900 dark:text-neutral-100",
|
|
97
|
+
o === "right" ? "ml-2" : "mr-2",
|
|
98
|
+
v
|
|
95
99
|
),
|
|
96
|
-
children: /* @__PURE__ */ i(
|
|
100
|
+
children: /* @__PURE__ */ i(p, { variant: "medium", size: E(), appearance: "body", children: [
|
|
97
101
|
l,
|
|
98
102
|
u && /* @__PURE__ */ e("span", { className: "text-red-500 ml-1", children: "*" })
|
|
99
103
|
] })
|
|
100
104
|
}
|
|
101
105
|
) : null;
|
|
102
|
-
return /* @__PURE__ */ i("div", { className: t("flex flex-col",
|
|
106
|
+
return /* @__PURE__ */ i("div", { className: t("flex flex-col", k), children: [
|
|
103
107
|
/* @__PURE__ */ e(
|
|
104
108
|
"div",
|
|
105
109
|
{
|
|
106
110
|
className: t(
|
|
107
111
|
"flex items-center",
|
|
108
|
-
|
|
112
|
+
o === "left" && "flex-row-reverse justify-end"
|
|
109
113
|
),
|
|
110
|
-
children:
|
|
114
|
+
children: o === "left" ? /* @__PURE__ */ i(h, { children: [
|
|
111
115
|
m,
|
|
112
|
-
|
|
113
|
-
] }) : /* @__PURE__ */ i(
|
|
116
|
+
x
|
|
117
|
+
] }) : /* @__PURE__ */ i(h, { children: [
|
|
114
118
|
m,
|
|
115
|
-
|
|
119
|
+
x
|
|
116
120
|
] })
|
|
117
121
|
}
|
|
118
122
|
),
|
|
119
|
-
/* @__PURE__ */ e(
|
|
120
|
-
|
|
123
|
+
/* @__PURE__ */ e(S, { children: n && /* @__PURE__ */ e(
|
|
124
|
+
A.div,
|
|
121
125
|
{
|
|
122
126
|
initial: { opacity: 0, y: -10 },
|
|
123
127
|
animate: { opacity: 1, y: 0 },
|
|
@@ -126,9 +130,9 @@ const R = M(
|
|
|
126
130
|
id: `${a}-message`,
|
|
127
131
|
role: r === "error" ? "alert" : void 0,
|
|
128
132
|
children: /* @__PURE__ */ e(
|
|
129
|
-
|
|
133
|
+
p,
|
|
130
134
|
{
|
|
131
|
-
className: t("mt-1",
|
|
135
|
+
className: t("mt-1", $()),
|
|
132
136
|
appearance: "custom",
|
|
133
137
|
size: "extra-small",
|
|
134
138
|
variant: "medium",
|
|
@@ -140,8 +144,8 @@ const R = M(
|
|
|
140
144
|
] });
|
|
141
145
|
}
|
|
142
146
|
);
|
|
143
|
-
|
|
147
|
+
M.displayName = "Checkbox";
|
|
144
148
|
export {
|
|
145
|
-
|
|
149
|
+
M as Checkbox
|
|
146
150
|
};
|
|
147
151
|
//# sourceMappingURL=Checkbox.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.es.js","sources":["../../../../src/components/forms/checkbox/Checkbox.tsx"],"sourcesContent":["import { Checkbox as AntdCheckbox } from \"antd\";\nimport type { CheckboxChangeEvent, CheckboxProps, CheckboxRef } from \"antd\";\nimport cn from \"classnames\";\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport { forwardRef } from \"react\";\nimport { Typography } from \"../../data-display/typography/Typography\";\n\n/**\n * Props for the Checkbox component\n */\nexport interface CheckboxComponentProps {\n /** Unique identifier for the checkbox */\n id: string;\n /** Label text to display next to the checkbox */\n label?: string;\n /** Whether the checkbox is checked */\n checked?: boolean;\n /** Whether the checkbox is checked (alias for checked) */\n isChecked?: boolean;\n /** Callback function called when checkbox state changes */\n onChange: (checked: boolean, event: CheckboxChangeEvent) => void;\n /** Whether the checkbox is disabled */\n disabled?: boolean;\n /** Whether the field is required */\n required?: boolean;\n /** Message to display below the checkbox */\n message?: string;\n /** Type of message to display */\n messageType?: \"success\" | \"error\" | \"info\" | \"default\";\n /** Additional CSS classes for the wrapper container */\n wrapperClassName?: string;\n /** Additional CSS classes for the checkbox input */\n checkboxClassName?: string;\n /** Additional CSS classes for the label */\n labelClassName?: string;\n /** Size variant for the checkbox */\n size?: \"small\" | \"medium\" | \"large\";\n /** Visual variant for the checkbox */\n variant?: \"default\" | \"outline\" | \"solid\";\n /** Whether to show the label on the left side */\n labelPosition?: \"left\" | \"right\";\n /** Additional props to pass to the Ant Design Checkbox */\n checkboxProps?: Omit<\n CheckboxProps,\n \"checked\" | \"onChange\" | \"id\" | \"disabled\"\n >;\n}\n\n/**\n * A highly customizable checkbox component with label, validation, and styling support.\n * Features dark mode support, accessibility enhancements, and comprehensive prop support.\n *\n * @example\n * ```tsx\n * <Checkbox\n * id=\"terms\"\n * label=\"I agree to the terms and conditions\"\n * checked={agreedToTerms}\n * onChange={(checked) => setAgreedToTerms(checked)}\n * required\n * />\n * ```\n */\nexport const Checkbox = forwardRef<CheckboxRef, CheckboxComponentProps>(\n (\n {\n id,\n label,\n checked,\n isChecked,\n onChange,\n disabled = false,\n required = false,\n message,\n messageType = \"default\",\n wrapperClassName,\n checkboxClassName,\n labelClassName,\n size = \"medium\",\n variant = \"default\",\n labelPosition = \"right\",\n checkboxProps,\n },\n ref\n ) => {\n // Use checked prop, fallback to isChecked for backward compatibility\n const isCheckboxChecked =\n checked !== undefined ? checked : isChecked || false;\n\n // Size-based styling\n const getSizeClasses = (): string => {\n switch (size) {\n case \"small\":\n return \"w-3 h-3\";\n case \"large\":\n return \"w-5 h-5\";\n default:\n return \"w-4 h-4\";\n }\n };\n\n // Variant-based styling\n const getVariantClasses = (): string => {\n if (messageType === \"error\") {\n return \"text-red-600 border-red-300 focus:ring-red-500 dark:focus:ring-red-600\";\n }\n if (messageType === \"success\") {\n return \"text-green-600 border-green-300 focus:ring-green-500 dark:focus:ring-green-600\";\n }\n if (messageType === \"info\") {\n return \"text-blue-600 border-blue-300 focus:ring-blue-500 dark:focus:ring-blue-600\";\n }\n\n switch (variant) {\n case \"outline\":\n return \"text-primary-600 bg-transparent border-neutral-300 focus:ring-primary-500 dark:focus:ring-primary-600\";\n case \"solid\":\n return \"text-primary-600 bg-primary-50 border-primary-300 focus:ring-primary-500 dark:focus:ring-primary-600 dark:bg-primary-900/20\";\n default:\n return \"text-primary-600 bg-gray-100 border-gray-300 focus:ring-primary-500 dark:focus:ring-primary-600 dark:bg-neutral-600 dark:border-gray-600\";\n }\n };\n\n // Message typography class\n const getMessageTypographyClass = (): string => {\n if (messageType === \"error\") return \"text-red-500 dark:text-red-400\";\n if (messageType === \"success\")\n return \"text-green-500 dark:text-green-400\";\n if (messageType === \"info\") return \"text-blue-500 dark:text-blue-400\";\n return \"text-neutral-500 dark:text-neutral-400\";\n };\n\n // Label typography size based on checkbox size\n const getLabelSize = (): \"extra-small\" | \"small\" | \"medium\" => {\n switch (size) {\n case \"small\":\n return \"extra-small\";\n case \"large\":\n return \"medium\";\n default:\n return \"small\";\n }\n };\n\n const handleChange = (e: CheckboxChangeEvent) => {\n onChange(e.target.checked, e);\n };\n\n const checkboxElement = (\n <AntdCheckbox\n {...checkboxProps}\n ref={ref}\n id={id}\n checked={isCheckboxChecked}\n onChange={handleChange}\n disabled={disabled}\n className={cn(\n // Base styles\n \"rounded focus:ring-2 focus:ring-primary-500 dark:focus:ring-primary-400 focus:ring-offset-gray-800 transition-colors duration-200\",\n\n // Size classes\n getSizeClasses(),\n\n // Variant classes\n getVariantClasses(),\n\n // Disabled styles\n disabled && \"opacity-50 cursor-not-allowed\",\n\n // Custom classes\n checkboxClassName\n )}\n aria-required={required}\n aria-invalid={message && messageType === \"error\" ? \"true\" : \"false\"}\n aria-describedby={message ? `${id}-message` : undefined}\n />\n );\n\n const labelElement = label ? (\n <label\n htmlFor={id}\n className={cn(\n \"font-medium cursor-pointer transition-colors duration-200\",\n disabled\n ? \"text-neutral-400 dark:text-neutral-600 cursor-not-allowed\"\n : \"text-neutral-900 dark:text-neutral-100\",\n labelPosition === \"right\" ? \"ml-2\" : \"mr-2\",\n labelClassName\n )}\n >\n <Typography variant=\"medium\" size={getLabelSize()} appearance=\"body\">\n {label}\n {required && <span className=\"text-red-500 ml-1\">*</span>}\n </Typography>\n </label>\n ) : null;\n\n return (\n <div className={cn(\"flex flex-col\", wrapperClassName)}>\n <div\n className={cn(\n \"flex items-center\",\n labelPosition === \"left\" && \"flex-row-reverse justify-end\"\n )}\n >\n {labelPosition === \"left\" ? (\n <>\n {checkboxElement}\n {labelElement}\n </>\n ) : (\n <>\n {checkboxElement}\n {labelElement}\n </>\n )}\n </div>\n\n {/* Message */}\n <AnimatePresence>\n {message && (\n <motion.div\n initial={{ opacity: 0, y: -10 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: -10 }}\n transition={{ duration: 0.2 }}\n id={`${id}-message`}\n role={messageType === \"error\" ? \"alert\" : undefined}\n >\n <Typography\n className={cn(\"mt-1\", getMessageTypographyClass())}\n appearance=\"custom\"\n size=\"extra-small\"\n variant=\"medium\"\n >\n {message}\n </Typography>\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n );\n }\n);\n\nCheckbox.displayName = \"Checkbox\";\n\n// Export type alias for backward compatibility\nexport type TCheckboxComponentProps = CheckboxComponentProps;\n"],"names":["Checkbox","forwardRef","id","label","checked","isChecked","onChange","disabled","required","message","messageType","wrapperClassName","checkboxClassName","labelClassName","size","variant","labelPosition","checkboxProps","ref","isCheckboxChecked","getSizeClasses","getVariantClasses","getMessageTypographyClass","getLabelSize","checkboxElement","jsx","AntdCheckbox","e","cn","labelElement","jsxs","Typography","Fragment","AnimatePresence","motion"],"mappings":";;;;;;AA+DO,MAAMA,IAAWC;AAAA,EACtB,CACE;AAAA,IACE,IAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,UAAAC,IAAW;AAAA,IACX,SAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,kBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,SAAAC,IAAU;AAAA,IACV,eAAAC,IAAgB;AAAA,IAChB,eAAAC;AAAA,EAAA,GAEFC,MACG;AAEH,UAAMC,IACJf,MAAY,SAAYA,IAAUC,KAAa,IAG3Ce,IAAiB,MAAc;AACnC,cAAQN,GAAA;AAAA,QACN,KAAK;AACH,iBAAO;AAAA,QACT,KAAK;AACH,iBAAO;AAAA,QACT;AACE,iBAAO;AAAA,MAAA;AAAA,IAEb,GAGMO,IAAoB,MAAc;AACtC,UAAIX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checkbox.tsx"],"sourcesContent":["import { Checkbox as AntdCheckbox } from \"antd\";\nimport type { CheckboxChangeEvent, CheckboxProps, CheckboxRef } from \"antd\";\nimport cn from \"classnames\";\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport { forwardRef } from \"react\";\nimport { Typography } from \"../../data-display/typography/Typography\";\n\n/**\n * Props for the Checkbox component\n */\nexport interface CheckboxComponentProps {\n /** Unique identifier for the checkbox */\n id: string;\n /** Label text to display next to the checkbox */\n label?: string;\n /** Whether the checkbox is checked */\n checked?: boolean;\n /** Whether the checkbox is checked (alias for checked) */\n isChecked?: boolean;\n /** Callback function called when checkbox state changes */\n onChange: (checked: boolean, event: CheckboxChangeEvent) => void;\n /** Whether the checkbox is disabled */\n disabled?: boolean;\n /** Whether the field is required */\n required?: boolean;\n /** Message to display below the checkbox */\n message?: string;\n /** Type of message to display */\n messageType?: \"success\" | \"error\" | \"info\" | \"default\";\n /** Additional CSS classes for the wrapper container */\n wrapperClassName?: string;\n /** Additional CSS classes for the checkbox input */\n checkboxClassName?: string;\n /** Additional CSS classes for the label */\n labelClassName?: string;\n /** Size variant for the checkbox */\n size?: \"small\" | \"medium\" | \"large\";\n /** Visual variant for the checkbox */\n variant?: \"default\" | \"outline\" | \"solid\";\n /** Whether to show the label on the left side */\n labelPosition?: \"left\" | \"right\";\n /** Additional props to pass to the Ant Design Checkbox */\n checkboxProps?: Omit<\n CheckboxProps,\n \"checked\" | \"onChange\" | \"id\" | \"disabled\"\n >;\n}\n\n/**\n * A highly customizable checkbox component with label, validation, and styling support.\n * Features dark mode support, accessibility enhancements, and comprehensive prop support.\n *\n * @example\n * ```tsx\n * <Checkbox\n * id=\"terms\"\n * label=\"I agree to the terms and conditions\"\n * checked={agreedToTerms}\n * onChange={(checked) => setAgreedToTerms(checked)}\n * required\n * />\n * ```\n */\nexport const Checkbox = forwardRef<CheckboxRef, CheckboxComponentProps>(\n (\n {\n id,\n label,\n checked,\n isChecked,\n onChange,\n disabled = false,\n required = false,\n message,\n messageType = \"default\",\n wrapperClassName,\n checkboxClassName,\n labelClassName,\n size = \"medium\",\n variant = \"default\",\n labelPosition = \"right\",\n checkboxProps,\n },\n ref\n ) => {\n // Use checked prop, fallback to isChecked for backward compatibility\n const isCheckboxChecked =\n checked !== undefined ? checked : isChecked || false;\n\n // Fluid size scaling: each size clamps from 2px smaller on <=1600px\n // screens up to its full size at 1920px — the same clamp() curve used for\n // the fluid fontSize / icon spacing tokens in tailwind.config.js.\n const getSizeClasses = (): string => {\n switch (size) {\n case \"small\":\n return \"[--checkbox-size:clamp(10px,0.625vw,12px)]\";\n case \"large\":\n return \"[--checkbox-size:clamp(18px,calc(8px_+_0.625vw),20px)]\";\n default:\n return \"[--checkbox-size:clamp(14px,calc(4px_+_0.625vw),16px)]\";\n }\n };\n\n // Variant-based styling\n const getVariantClasses = (): string => {\n if (messageType === \"error\") {\n return \"text-red-600 border-red-300 focus:ring-red-500 dark:focus:ring-red-600\";\n }\n if (messageType === \"success\") {\n return \"text-green-600 border-green-300 focus:ring-green-500 dark:focus:ring-green-600\";\n }\n if (messageType === \"info\") {\n return \"text-blue-600 border-blue-300 focus:ring-blue-500 dark:focus:ring-blue-600\";\n }\n\n switch (variant) {\n case \"outline\":\n return \"text-primary-600 bg-transparent border-neutral-300 focus:ring-primary-500 dark:focus:ring-primary-600\";\n case \"solid\":\n return \"text-primary-600 bg-primary-50 border-primary-300 focus:ring-primary-500 dark:focus:ring-primary-600 dark:bg-primary-900/20\";\n default:\n return \"text-primary-600 bg-gray-100 border-gray-300 focus:ring-primary-500 dark:focus:ring-primary-600 dark:bg-neutral-600 dark:border-gray-600\";\n }\n };\n\n // Message typography class\n const getMessageTypographyClass = (): string => {\n if (messageType === \"error\") return \"text-red-500 dark:text-red-400\";\n if (messageType === \"success\")\n return \"text-green-500 dark:text-green-400\";\n if (messageType === \"info\") return \"text-blue-500 dark:text-blue-400\";\n return \"text-neutral-500 dark:text-neutral-400\";\n };\n\n // Label typography size based on checkbox size\n const getLabelSize = (): \"extra-small\" | \"small\" | \"medium\" => {\n switch (size) {\n case \"small\":\n return \"extra-small\";\n case \"large\":\n return \"medium\";\n default:\n return \"small\";\n }\n };\n\n const handleChange = (e: CheckboxChangeEvent) => {\n onChange(e.target.checked, e);\n };\n\n const checkboxElement = (\n <AntdCheckbox\n {...checkboxProps}\n ref={ref}\n id={id}\n checked={isCheckboxChecked}\n onChange={handleChange}\n disabled={disabled}\n className={cn(\n // Base styles\n \"rounded focus:ring-2 focus:ring-primary-500 dark:focus:ring-primary-400 focus:ring-offset-gray-800 transition-colors duration-200\",\n\n // Size classes — the clamp() value set by getSizeClasses drives the\n // antd wrapper and the visible .ant-checkbox-inner box (!important\n // needed to beat antd's own token-based width/height)\n getSizeClasses(),\n \"w-[var(--checkbox-size)] h-[var(--checkbox-size)]\",\n \"[&_.ant-checkbox-inner]:!w-[var(--checkbox-size)] [&_.ant-checkbox-inner]:!h-[var(--checkbox-size)]\",\n\n // Variant classes\n getVariantClasses(),\n\n // Disabled styles\n disabled && \"opacity-50 cursor-not-allowed\",\n\n // Custom classes\n checkboxClassName\n )}\n aria-required={required}\n aria-invalid={message && messageType === \"error\" ? \"true\" : \"false\"}\n aria-describedby={message ? `${id}-message` : undefined}\n />\n );\n\n const labelElement = label ? (\n <label\n htmlFor={id}\n className={cn(\n \"font-medium cursor-pointer transition-colors duration-200\",\n disabled\n ? \"text-neutral-400 dark:text-neutral-600 cursor-not-allowed\"\n : \"text-neutral-900 dark:text-neutral-100\",\n labelPosition === \"right\" ? \"ml-2\" : \"mr-2\",\n labelClassName\n )}\n >\n <Typography variant=\"medium\" size={getLabelSize()} appearance=\"body\">\n {label}\n {required && <span className=\"text-red-500 ml-1\">*</span>}\n </Typography>\n </label>\n ) : null;\n\n return (\n <div className={cn(\"flex flex-col\", wrapperClassName)}>\n <div\n className={cn(\n \"flex items-center\",\n labelPosition === \"left\" && \"flex-row-reverse justify-end\"\n )}\n >\n {labelPosition === \"left\" ? (\n <>\n {checkboxElement}\n {labelElement}\n </>\n ) : (\n <>\n {checkboxElement}\n {labelElement}\n </>\n )}\n </div>\n\n {/* Message */}\n <AnimatePresence>\n {message && (\n <motion.div\n initial={{ opacity: 0, y: -10 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: -10 }}\n transition={{ duration: 0.2 }}\n id={`${id}-message`}\n role={messageType === \"error\" ? \"alert\" : undefined}\n >\n <Typography\n className={cn(\"mt-1\", getMessageTypographyClass())}\n appearance=\"custom\"\n size=\"extra-small\"\n variant=\"medium\"\n >\n {message}\n </Typography>\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n );\n }\n);\n\nCheckbox.displayName = \"Checkbox\";\n\n// Export type alias for backward compatibility\nexport type TCheckboxComponentProps = CheckboxComponentProps;\n"],"names":["Checkbox","forwardRef","id","label","checked","isChecked","onChange","disabled","required","message","messageType","wrapperClassName","checkboxClassName","labelClassName","size","variant","labelPosition","checkboxProps","ref","isCheckboxChecked","getSizeClasses","getVariantClasses","getMessageTypographyClass","getLabelSize","checkboxElement","jsx","AntdCheckbox","e","cn","labelElement","jsxs","Typography","Fragment","AnimatePresence","motion"],"mappings":";;;;;;AA+DO,MAAMA,IAAWC;AAAA,EACtB,CACE;AAAA,IACE,IAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,UAAAC,IAAW;AAAA,IACX,SAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,kBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,SAAAC,IAAU;AAAA,IACV,eAAAC,IAAgB;AAAA,IAChB,eAAAC;AAAA,EAAA,GAEFC,MACG;AAEH,UAAMC,IACJf,MAAY,SAAYA,IAAUC,KAAa,IAK3Ce,IAAiB,MAAc;AACnC,cAAQN,GAAA;AAAA,QACN,KAAK;AACH,iB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ACH;AAAA,MAAA,EACF,CAEJ;AAAA,IAAA,GACF;AAAA,EAEJ;AACF;AAEAT,EAAS,cAAc;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),O=require("@mui/icons-material"),V=require("@mui/icons-material/EditOutlined"),D=require("@mui/icons-material/WarningRounded"),o=require("../../_virtual/index.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),O=require("@mui/icons-material"),V=require("@mui/icons-material/EditOutlined"),D=require("@mui/icons-material/WarningRounded"),o=require("../../_virtual/index.cjs.js"),t=require("react"),d=require("../data-display/typography/Typography.cjs.js"),p=require("../data-display/tag/Tag.cjs.js"),ee=require("../data-display/skeleton/Skeleton.cjs.js"),re=require("../../utils/countryFlags.cjs.js"),ae=require("./UserAvatarPopper.cjs.js"),oe=require("./StatusInfoRow.cjs.js"),g=require("./constants.cjs.js"),se=require("./PersonIcon.cjs.js"),te=require("./useDynamicPosition.cjs.js"),j=({label:n,content:l})=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(d.Typography,{size:"small",variant:"medium",className:"mr-5",appearance:"body",children:n}),l]}),H=({firstName:n,lastName:l,email:U,profilePic:c,size:N="md",hoverSize:T="lg",containerClassName:A="",enablePopper:P=!0,className:B,userId:C,lastViewedOn:u,isActive:m,statusIndicator:F=!1,userDetails:r,isFetchingUserDetails:$=!1,authToken:R,onHover:G,currentlyEditing:z})=>{if(n==="All"&&l==="Users")return e.jsx("div",{className:"p-1 rounded-full bg-primary-100 dark:bg-black-600 flex items-center justify-center",children:e.jsx(O.GroupsOutlined,{sx:{fontSize:16},className:"text-primary-600 dark:text-primary-600"})});const[W,v]=t.useState(!1),[M,i]=t.useState(!1),J=g.sizeClasses[N],{triggerRef:K,dropdownRef:Q,position:f,isVisible:X,show:S,hide:q}=te.useDynamicPosition(),k=t.useRef({}),I=t.useMemo(()=>{if(m||!u)return!1;const a=new Date(u);return(new Date().getTime()-a.getTime())/(1e3*60*60)<24},[m,u]),h=m?"bg-primary-600 dark:bg-primary-600":I?"bg-primary-300 dark:bg-primary-300":u?"bg-neutral-400 dark:bg-neutral-400":null,b=m?"border-primary-600 dark:border-primary-600":I?"border-primary-300 dark:border-primary-300":u?"border-neutral-400 dark:border-neutral-400":"border-primary-200 dark:border-neutral-800",Y={"2xs":"w-1.5 h-1.5",xs:"w-2 h-2",sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5",xl:"w-4 h-4"};t.useEffect(()=>{if(c)if(k.current[c])i(!0);else{i(!1);const a=new Image,x=R||(typeof localStorage<"u"?localStorage.getItem("token"):null);a.src=c+(x?"?token="+x:""),a.onload=()=>{k.current[c]=a.src,i(!0)},a.onerror=()=>{i(!1)}}else i(!1)},[c,R]),t.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const y=c?k.current[c]:void 0,s=t.useRef(null),w=t.useRef(null),Z=()=>{G?.(),n&&l&&P&&(s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{v(!0)},300))},L=a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{w.current&&!w.current.contains(a.relatedTarget)&&v(!1)},200)},_=e.jsxs("div",{ref:w,className:"bg-white dark:bg-black-800 shadow rounded-lg border border-neutral-200 dark:border-black-700 min-w-[280px]",onMouseEnter:()=>{s.current&&clearTimeout(s.current)},onMouseLeave:a=>L(a),children:[e.jsxs("div",{className:"flex flex-col gap-1 items-center p-5",children:[e.jsxs("div",{className:o("relative",g.sizeClasses[T]),children:[y&&M?e.jsx("img",{src:y,alt:"Profile",className:o("rounded-full border-2 object-cover w-full h-full",b),onError:()=>i(!1)}):e.jsx("div",{className:o("bg-primary-100 dark:bg-primary-950 text-primary-600 border-2 flex items-center justify-center rounded-full w-full h-full",b),children:g.getInitials((n||"")+" "+(l||""))}),h&&e.jsx("div",{className:o("absolute bottom-0 right-0 rounded-full border-2 border-white dark:border-black-800",Y[T],h)})]}),e.jsxs("div",{className:"flex flex-row gap-1 items-center justify-center",children:[e.jsxs(d.Typography,{size:"medium",variant:"semibold",className:"w-full text-center",children:[n||""," ",l||""]}),r?.region&&e.jsx("span",{children:re.getFlagComponentRectangleMd(r?.region)})]}),e.jsx(d.Typography,{size:"small",variant:"medium",appearance:"body",children:U||r?.email||""})]}),z?e.jsx("div",{className:"px-5 pb-3",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-primary-100 dark:border-primary-900 bg-[rgba(230,241,252,0.60)] dark:bg-primary-950/40 px-[13px] py-[7px]",children:[e.jsx("div",{className:"flex items-center justify-center shrink-0 w-7 h-7 rounded-[5px] border-[0.4px] border-primary-100 dark:border-primary-900 bg-primary-50 dark:bg-primary-950",children:e.jsx(V,{sx:{width:13,height:13},className:"text-primary-600 dark:text-primary-500"})}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx(d.Typography,{size:"extra-small",variant:"semibold",appearance:"custom",className:"text-2xs leading-4 uppercase tracking-[0.2px] text-primary-600 dark:text-primary-500",children:"Currently editing"}),e.jsx(d.Typography,{size:"extra-small",variant:"semibold",className:"truncate",children:z})]})]})}):null,C&&($?e.jsx("div",{className:"p-5",children:e.jsx(ee.Skeleton,{})}):C&&(r?.teams||r?.clearanceLevel||r?.group)?e.jsxs("div",{className:"flex flex-col gap-4 bg-neutral-50 border-t border-neutral-200 dark:bg-black-700 dark:border-none p-5 rounded-b-lg",children:[e.jsx(oe.StatusInfoRow,{isActive:m,lastViewedOn:u}),r.username&&e.jsx(j,{label:"Username",content:e.jsx("div",{className:"flex gap-2",children:e.jsx(d.Typography,{size:"small",variant:"medium",appearance:"body",children:r.username})})}),r?.teams&&r?.teams?.length>0&&e.jsx(j,{label:"Team",content:e.jsxs("div",{className:"flex gap-2",children:[r?.teams?.length>0&&e.jsx(p.Tag,{label:r?.teams[0]?.name,color:r?.teams[0]?.color||"#e38715",size:"md",isHashColor:!0},r?.teams[0]?.id),r?.teams?.length>=2&&e.jsxs("div",{ref:K,className:"relative cursor-pointer",onMouseEnter:S,onMouseLeave:q,onClick:a=>a.stopPropagation(),children:[e.jsx(p.Tag,{label:`+ ${r?.teams?.length-1} More`,color:"#004f08",size:"md",isHashColor:!0},1),X&&e.jsx("div",{ref:Q,className:o("absolute w-max bg-white dark:text-black-200 dark:bg-black-800 shadow-md border border-neutral-200 dark:border-black-800 rounded-md px-2 z-10 overflow-y-auto max-h-60",{"top-full":f.vertical==="bottom","bottom-full":f.vertical==="top","left-0":f.horizontal==="left","right-0":f.horizontal==="right"}),onMouseEnter:S,onMouseLeave:q,children:r?.teams?.slice(1)?.map((a,x)=>e.jsx("div",{className:"my-2",children:e.jsx(p.Tag,{label:a?.name,color:a?.color||"#4A5568",size:"md",isHashColor:!0,className:"w-fit"},a?.id)},a?.id||x))})]})]})}),r?.group&&e.jsx(j,{label:"Role",content:e.jsx(p.Tag,{label:r?.group,color:"#004094",size:"md",isHashColor:!0},r?.group)}),r?.clearanceLevel&&e.jsx(j,{label:"Clearance Level",content:e.jsx(p.Tag,{label:`Level ${r?.clearanceLevel}`,color:"#b30000",size:"md",isHashColor:!0},String(r?.clearanceLevel))})]}):e.jsx("div",{className:"flex items-center justify-center bg-neutral-50 dark:bg-black-700 border-t border-neutral-200 dark:border-black-700 p-5 rounded-b-lg",children:e.jsxs(d.Typography,{className:"flex items-center justify-center gap-1",size:"extra-small",variant:"medium",appearance:"body",children:[e.jsx(D,{sx:{height:"16px",width:"16px",color:"#F04438"}}),"No other information found!"]})}))]}),E=t.useRef(null);return e.jsxs("div",{onMouseEnter:Z,onMouseLeave:L,className:o("inline-block relative cursor-pointer",B),ref:E,children:[e.jsxs("div",{className:o("relative",A||J),children:[y&&M?e.jsx("img",{src:y,alt:"Profile",className:o("rounded-full border object-cover w-full h-full",b),onError:()=>i(!1)}):n&&l?e.jsx("div",{className:o(" bg-primary-100 text-primary-600 flex items-center justify-center rounded-full border dark:bg-black-700 text-2xs",g.sizeClasses[N],b),children:g.getInitials((n||"")+" "+(l||""))}):e.jsx("div",{className:o(b,"p-1 rounded-full bg-neutral-200 dark:bg-black-600 flex items-center justify-center border w-full h-full"),children:e.jsx(se.PersonIcon,{fill:"#98A2B3"})}),F&&h&&e.jsx("div",{className:o("absolute bottom-0 right-0 rounded-full border border-white dark:border-black-800 w-2 h-2",h)})]}),e.jsx(ae.UserAvatarPopper,{isOpen:W,onClose:()=>v(!1),anchorEl:E.current,className:"bg-white dark:bg-black-700 shadow rounded-lg border border-neutral-200 dark:border-black-600",children:_})]})};H.displayName="UserAvatar";exports.UserAvatar=H;
|
|
2
2
|
//# sourceMappingURL=UserAvatar.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAvatar.cjs.js","sources":["../../../src/components/user-avatar/UserAvatar.tsx"],"sourcesContent":["import { GroupsOutlined } from '@mui/icons-material';\nimport EditOutlinedIcon from '@mui/icons-material/EditOutlined';\nimport WarningRoundedIcon from '@mui/icons-material/WarningRounded';\nimport cn from 'classnames';\nimport { type FC, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Typography } from '../data-display/typography/Typography';\nimport { Tag } from '../data-display/tag/Tag';\nimport { Skeleton } from '../data-display/skeleton/Skeleton';\nimport { getFlagComponentRectangleMd } from '../../utils/countryFlags';\nimport { UserAvatarPopper } from './UserAvatarPopper';\nimport { StatusInfoRow } from './StatusInfoRow';\nimport { sizeClasses, getInitials } from './constants';\nimport { PersonIcon } from './PersonIcon';\nimport { useDynamicPosition } from './useDynamicPosition';\n\nexport type UserAvatarSize = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\nexport type UserDetailsTeam = {\n id?: string;\n name: string;\n color?: string;\n};\n\nexport type UserDetails = {\n email?: string;\n username?: string;\n teams?: UserDetailsTeam[];\n group?: string;\n clearanceLevel?: number | string;\n region?: string;\n};\n\nexport type UserAvatarProps = {\n firstName?: string;\n lastName?: string;\n email?: string;\n enablePopper?: boolean;\n profilePic?: string;\n size?: UserAvatarSize;\n hoverSize?: UserAvatarSize;\n containerClassName?: string;\n className?: string;\n userId?: string;\n lastViewedOn?: string;\n isActive?: boolean;\n statusIndicator?: boolean;\n /** User details to display in the popper - replaces the useTeamMemberFilter hook */\n userDetails?: UserDetails | null;\n /** Whether user details are being fetched */\n isFetchingUserDetails?: boolean;\n /** Optional token for authenticated image loading */\n authToken?: string;\n /** Callback triggered when mouse enters the avatar */\n onHover?: () => void;\n /** Name of the clause / line item the user is currently editing. When set, a highlighted \"Currently editing\" card is shown in the popper. */\n currentlyEditing?: string;\n};\n\nconst InfoRow = ({ label, content }: { label: string; content: React.ReactNode }) => (\n <div className='flex justify-between items-center'>\n <Typography size='small' variant='medium' className='mr-5' appearance='body'>\n {label}\n </Typography>\n {content}\n </div>\n);\n\n/**\n * UserAvatar component for displaying user profile pictures with hover popper\n *\n * @example\n * ```tsx\n * <UserAvatar\n * firstName=\"John\"\n * lastName=\"Doe\"\n * email=\"john@example.com\"\n * profilePic=\"/avatar.jpg\"\n * userDetails={{ teams: [{ name: 'Engineering', color: '#0066cc' }], group: 'Admin' }}\n * />\n * ```\n */\nexport const UserAvatar: FC<UserAvatarProps> = ({\n firstName,\n lastName,\n email,\n profilePic,\n size = 'md',\n hoverSize = 'lg',\n containerClassName = '',\n enablePopper = true,\n className,\n userId,\n lastViewedOn,\n isActive,\n statusIndicator = false,\n userDetails,\n isFetchingUserDetails = false,\n authToken,\n onHover,\n currentlyEditing,\n}) => {\n if (firstName === 'All' && lastName === 'Users') {\n return (\n <div className='p-1 rounded-full bg-primary-100 dark:bg-black-600 flex items-center justify-center'>\n <GroupsOutlined sx={{ fontSize: 16 }} className='text-primary-600 dark:text-primary-600' />\n </div>\n );\n }\n\n const [visible, setVisible] = useState<boolean>(false);\n const [imageLoaded, setImageLoaded] = useState<boolean>(false);\n\n const avatarSizeClass = sizeClasses[size];\n\n const {\n triggerRef: moreTagRef,\n dropdownRef,\n position: dropdownPosition,\n isVisible: showMore,\n show: handleShowMore,\n hide: handleHideMore,\n } = useDynamicPosition();\n\n const imageCacheRef = useRef<{ [key: string]: string }>({});\n\n const isRecent = useMemo(() => {\n if (isActive || !lastViewedOn) return false;\n const date = new Date(lastViewedOn);\n const now = new Date();\n const diffInHours = (now.getTime() - date.getTime()) / (1000 * 60 * 60);\n return diffInHours < 24;\n }, [isActive, lastViewedOn]);\n\n const getStatusColor = () => {\n if (isActive) return 'bg-primary-600 dark:bg-primary-600';\n if (isRecent) return 'bg-primary-300 dark:bg-primary-300';\n if (lastViewedOn) return 'bg-neutral-400 dark:bg-neutral-400';\n return null;\n };\n\n const statusColor = getStatusColor();\n\n const getBorderColor = () => {\n if (isActive) return 'border-primary-600 dark:border-primary-600';\n if (isRecent) return 'border-primary-300 dark:border-primary-300';\n if (lastViewedOn) return 'border-neutral-400 dark:border-neutral-400';\n return 'border-primary-200 dark:border-neutral-800';\n };\n\n const borderColor = getBorderColor();\n\n const indicatorSizes = {\n '2xs': 'w-1.5 h-1.5',\n xs: 'w-2 h-2',\n sm: 'w-2.5 h-2.5',\n md: 'w-3 h-3',\n lg: 'w-3.5 h-3.5',\n xl: 'w-4 h-4',\n };\n\n useEffect(() => {\n if (profilePic) {\n if (imageCacheRef.current[profilePic]) {\n setImageLoaded(true);\n } else {\n setImageLoaded(false);\n const img = new Image();\n const token = authToken || (typeof localStorage !== 'undefined' ? localStorage.getItem('token') : null);\n img.src = profilePic + (token ? '?token=' + token : '');\n img.onload = () => {\n imageCacheRef.current[profilePic] = img.src;\n setImageLoaded(true);\n };\n img.onerror = () => {\n setImageLoaded(false);\n };\n }\n } else {\n setImageLoaded(false);\n }\n }, [profilePic, authToken]);\n\n useEffect(() => {\n return () => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n };\n }, []);\n\n const cachedSrc = profilePic ? imageCacheRef.current[profilePic] : undefined;\n\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const popperRef = useRef<HTMLDivElement | null>(null);\n\n const handleMouseEnter = () => {\n onHover?.();\n if (firstName && lastName && enablePopper) {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n timerRef.current = setTimeout(() => {\n setVisible(true);\n }, 300);\n }\n };\n\n const handleMouseLeave = (event: React.MouseEvent) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n timerRef.current = setTimeout(() => {\n if (popperRef.current && !popperRef.current.contains(event.relatedTarget as Node)) {\n setVisible(false);\n }\n }, 200);\n };\n\n const popperContent = (\n <div\n ref={popperRef}\n className='bg-white dark:bg-black-800 shadow rounded-lg border border-neutral-200 dark:border-black-700 min-w-[280px]'\n onMouseEnter={() => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n }}\n onMouseLeave={(event) => handleMouseLeave(event)}\n >\n <div className='flex flex-col gap-1 items-center p-5'>\n <div className={cn('relative', sizeClasses[hoverSize])}>\n {cachedSrc && imageLoaded ? (\n <img\n src={cachedSrc}\n alt='Profile'\n className={cn('rounded-full border-2 object-cover w-full h-full', borderColor)}\n onError={() => setImageLoaded(false)}\n />\n ) : (\n <div\n className={cn(\n 'bg-primary-100 dark:bg-primary-950 text-primary-600 border-2 flex items-center justify-center rounded-full w-full h-full',\n borderColor,\n )}\n >\n {getInitials((firstName || '') + ' ' + (lastName || ''))}\n </div>\n )}\n\n {statusColor && (\n <div\n className={cn(\n 'absolute bottom-0 right-0 rounded-full border-2 border-white dark:border-black-800',\n indicatorSizes[hoverSize],\n statusColor,\n )}\n />\n )}\n </div>\n <div className='flex flex-row gap-1 items-center justify-center'>\n <Typography size='medium' variant='semibold' className='w-full text-center'>\n {firstName || ''} {lastName || ''}\n </Typography>\n {userDetails?.region && <span>{getFlagComponentRectangleMd(userDetails?.region)}</span>}\n </div>\n\n <Typography size='small' variant='medium' appearance='body'>\n {email || userDetails?.email || ''}\n </Typography>\n </div>\n\n {currentlyEditing ? (\n <div className='px-5 pb-3'>\n <div className='flex items-center gap-3 rounded-lg border border-primary-100 dark:border-primary-900 bg-[rgba(230,241,252,0.60)] dark:bg-primary-950/40 px-[13px] py-[7px]'>\n <div className='flex items-center justify-center shrink-0 w-7 h-7 rounded-[5px] border-[0.4px] border-primary-100 dark:border-primary-900 bg-primary-50 dark:bg-primary-950'>\n <EditOutlinedIcon sx={{ width: 13, height: 13 }} className='text-primary-600 dark:text-primary-500' />\n </div>\n <div className='flex flex-col min-w-0'>\n <Typography\n size='extra-small'\n variant='semibold'\n appearance='custom'\n className='text-2xs leading-4 uppercase tracking-[0.2px] text-primary-600 dark:text-primary-500'\n >\n Currently editing\n </Typography>\n <Typography size='extra-small' variant='semibold' className='truncate'>\n {currentlyEditing}\n </Typography>\n </div>\n </div>\n </div>\n ) : null}\n\n {userId &&\n (isFetchingUserDetails ? (\n <div className='p-5'>\n <Skeleton />\n </div>\n ) : userId && (userDetails?.teams || userDetails?.clearanceLevel || userDetails?.group) ? (\n <div className='flex flex-col gap-4 bg-neutral-50 border-t border-neutral-200 dark:bg-black-700 dark:border-none p-5 rounded-b-lg'>\n <StatusInfoRow isActive={isActive} lastViewedOn={lastViewedOn} />\n {userDetails.username && (\n <InfoRow\n label='Username'\n content={\n <div className='flex gap-2'>\n <Typography size='small' variant='medium' appearance='body'>\n {userDetails.username}\n </Typography>\n </div>\n }\n />\n )}\n\n {userDetails?.teams && userDetails?.teams?.length > 0 && (\n <InfoRow\n label='Team'\n content={\n <div className='flex gap-2'>\n {userDetails?.teams?.length > 0 && (\n <Tag\n key={userDetails?.teams[0]?.id}\n label={userDetails?.teams[0]?.name}\n color={userDetails?.teams[0]?.color || '#e38715'}\n size='md'\n isHashColor\n />\n )}\n {userDetails?.teams?.length >= 2 && (\n <div\n ref={moreTagRef}\n className='relative cursor-pointer'\n onMouseEnter={handleShowMore}\n onMouseLeave={handleHideMore}\n onClick={(e) => e.stopPropagation()}\n >\n <Tag key={1} label={`+ ${userDetails?.teams?.length - 1} More`} color='#004f08' size='md' isHashColor />\n\n {showMore && (\n <div\n ref={dropdownRef}\n className={cn(\n 'absolute w-max bg-white dark:text-black-200 dark:bg-black-800 shadow-md border border-neutral-200 dark:border-black-800 rounded-md px-2 z-10 overflow-y-auto max-h-60',\n {\n 'top-full': dropdownPosition.vertical === 'bottom',\n 'bottom-full': dropdownPosition.vertical === 'top',\n 'left-0': dropdownPosition.horizontal === 'left',\n 'right-0': dropdownPosition.horizontal === 'right',\n },\n )}\n onMouseEnter={handleShowMore}\n onMouseLeave={handleHideMore}\n >\n {userDetails?.teams?.slice(1)?.map((team, index) => (\n <div key={team?.id || index} className='my-2'>\n <Tag key={team?.id} label={team?.name} color={team?.color || '#4A5568'} size='md' isHashColor className='w-fit' />\n </div>\n ))}\n </div>\n )}\n </div>\n )}\n </div>\n }\n />\n )}\n\n {userDetails?.group && (\n <InfoRow\n label='Role'\n content={<Tag key={userDetails?.group} label={userDetails?.group} color='#004094' size='md' isHashColor />}\n />\n )}\n\n {userDetails?.clearanceLevel && (\n <InfoRow\n label='Clearance Level'\n content={\n <Tag\n key={String(userDetails?.clearanceLevel)}\n label={`Level ${userDetails?.clearanceLevel}`}\n color='#b30000'\n size='md'\n isHashColor\n />\n }\n />\n )}\n </div>\n ) : (\n <div className='flex items-center justify-center bg-neutral-50 dark:bg-black-700 border-t border-neutral-200 dark:border-black-700 p-5 rounded-b-lg'>\n <Typography className='flex items-center justify-center gap-1' size='extra-small' variant='medium' appearance='body'>\n <WarningRoundedIcon\n sx={{\n height: '16px',\n width: '16px',\n color: '#F04438',\n }}\n />\n No other information found!\n </Typography>\n </div>\n ))}\n </div>\n );\n const containerRef = useRef<HTMLDivElement>(null);\n return (\n <div\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n className={cn('inline-block relative cursor-pointer', className)}\n ref={containerRef}\n >\n <div className={cn('relative', containerClassName || avatarSizeClass)}>\n {cachedSrc && imageLoaded ? (\n <img\n src={cachedSrc}\n alt='Profile'\n className={cn('rounded-full border object-cover w-full h-full', borderColor)}\n onError={() => setImageLoaded(false)}\n />\n ) : firstName && lastName ? (\n <div\n className={cn(\n ' bg-primary-100 text-primary-600 flex items-center justify-center rounded-full border dark:bg-black-700', \n sizeClasses[size],\n borderColor,\n )}\n >\n {getInitials((firstName || '') + ' ' + (lastName || ''))}\n </div>\n ) : (\n <div className={cn(borderColor, 'p-1 rounded-full bg-neutral-200 dark:bg-black-600 flex items-center justify-center border w-full h-full')}>\n <PersonIcon fill='#98A2B3' />\n </div>\n )}\n\n {statusIndicator && statusColor && (\n <div\n className={cn(\n 'absolute bottom-0 right-0 rounded-full border border-white dark:border-black-800 w-2 h-2',\n\n statusColor,\n )}\n />\n )}\n </div>\n <UserAvatarPopper\n isOpen={visible}\n onClose={() => setVisible(false)}\n anchorEl={containerRef.current}\n className='bg-white dark:bg-black-700 shadow rounded-lg border border-neutral-200 dark:border-black-600'\n >\n {popperContent}\n </UserAvatarPopper>\n </div>\n );\n};\n\nUserAvatar.displayName = 'UserAvatar';\n\n"],"names":["InfoRow","label","content","jsxs","jsx","Typography","UserAvatar","firstName","lastName","email","profilePic","size","hoverSize","containerClassName","enablePopper","className","userId","lastViewedOn","isActive","statusIndicator","userDetails","isFetchingUserDetails","authToken","onHover","currentlyEditing","GroupsOutlined","visible","setVisible","useState","imageLoaded","setImageLoaded","avatarSizeClass","sizeClasses","moreTagRef","dropdownRef","dropdownPosition","showMore","handleShowMore","handleHideMore","useDynamicPosition","imageCacheRef","useRef","isRecent","useMemo","date","statusColor","borderColor","indicatorSizes","useEffect","img","token","timerRef","cachedSrc","popperRef","handleMouseEnter","handleMouseLeave","event","popperContent","cn","getInitials","getFlagComponentRectangleMd","EditOutlinedIcon","Skeleton","StatusInfoRow","Tag","e","team","index","WarningRoundedIcon","containerRef","PersonIcon","UserAvatarPopper"],"mappings":"orBA2DMA,EAAU,CAAC,CAAE,MAAAC,EAAO,QAAAC,KACxBC,OAAC,MAAA,CAAI,UAAU,oCACb,SAAA,CAAAC,EAAAA,IAACC,EAAA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.tsx"],"sourcesContent":["import { GroupsOutlined } from '@mui/icons-material';\nimport EditOutlinedIcon from '@mui/icons-material/EditOutlined';\nimport WarningRoundedIcon from '@mui/icons-material/WarningRounded';\nimport cn from 'classnames';\nimport { type FC, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Typography } from '../data-display/typography/Typography';\nimport { Tag } from '../data-display/tag/Tag';\nimport { Skeleton } from '../data-display/skeleton/Skeleton';\nimport { getFlagComponentRectangleMd } from '../../utils/countryFlags';\nimport { UserAvatarPopper } from './UserAvatarPopper';\nimport { StatusInfoRow } from './StatusInfoRow';\nimport { sizeClasses, getInitials } from './constants';\nimport { PersonIcon } from './PersonIcon';\nimport { useDynamicPosition } from './useDynamicPosition';\n\nexport type UserAvatarSize = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\nexport type UserDetailsTeam = {\n id?: string;\n name: string;\n color?: string;\n};\n\nexport type UserDetails = {\n email?: string;\n username?: string;\n teams?: UserDetailsTeam[];\n group?: string;\n clearanceLevel?: number | string;\n region?: string;\n};\n\nexport type UserAvatarProps = {\n firstName?: string;\n lastName?: string;\n email?: string;\n enablePopper?: boolean;\n profilePic?: string;\n size?: UserAvatarSize;\n hoverSize?: UserAvatarSize;\n containerClassName?: string;\n className?: string;\n userId?: string;\n lastViewedOn?: string;\n isActive?: boolean;\n statusIndicator?: boolean;\n /** User details to display in the popper - replaces the useTeamMemberFilter hook */\n userDetails?: UserDetails | null;\n /** Whether user details are being fetched */\n isFetchingUserDetails?: boolean;\n /** Optional token for authenticated image loading */\n authToken?: string;\n /** Callback triggered when mouse enters the avatar */\n onHover?: () => void;\n /** Name of the clause / line item the user is currently editing. When set, a highlighted \"Currently editing\" card is shown in the popper. */\n currentlyEditing?: string;\n};\n\nconst InfoRow = ({ label, content }: { label: string; content: React.ReactNode }) => (\n <div className='flex justify-between items-center'>\n <Typography size='small' variant='medium' className='mr-5' appearance='body'>\n {label}\n </Typography>\n {content}\n </div>\n);\n\n/**\n * UserAvatar component for displaying user profile pictures with hover popper\n *\n * @example\n * ```tsx\n * <UserAvatar\n * firstName=\"John\"\n * lastName=\"Doe\"\n * email=\"john@example.com\"\n * profilePic=\"/avatar.jpg\"\n * userDetails={{ teams: [{ name: 'Engineering', color: '#0066cc' }], group: 'Admin' }}\n * />\n * ```\n */\nexport const UserAvatar: FC<UserAvatarProps> = ({\n firstName,\n lastName,\n email,\n profilePic,\n size = 'md',\n hoverSize = 'lg',\n containerClassName = '',\n enablePopper = true,\n className,\n userId,\n lastViewedOn,\n isActive,\n statusIndicator = false,\n userDetails,\n isFetchingUserDetails = false,\n authToken,\n onHover,\n currentlyEditing,\n}) => {\n if (firstName === 'All' && lastName === 'Users') {\n return (\n <div className='p-1 rounded-full bg-primary-100 dark:bg-black-600 flex items-center justify-center'>\n <GroupsOutlined sx={{ fontSize: 16 }} className='text-primary-600 dark:text-primary-600' />\n </div>\n );\n }\n\n const [visible, setVisible] = useState<boolean>(false);\n const [imageLoaded, setImageLoaded] = useState<boolean>(false);\n\n const avatarSizeClass = sizeClasses[size];\n\n const {\n triggerRef: moreTagRef,\n dropdownRef,\n position: dropdownPosition,\n isVisible: showMore,\n show: handleShowMore,\n hide: handleHideMore,\n } = useDynamicPosition();\n\n const imageCacheRef = useRef<{ [key: string]: string }>({});\n\n const isRecent = useMemo(() => {\n if (isActive || !lastViewedOn) return false;\n const date = new Date(lastViewedOn);\n const now = new Date();\n const diffInHours = (now.getTime() - date.getTime()) / (1000 * 60 * 60);\n return diffInHours < 24;\n }, [isActive, lastViewedOn]);\n\n const getStatusColor = () => {\n if (isActive) return 'bg-primary-600 dark:bg-primary-600';\n if (isRecent) return 'bg-primary-300 dark:bg-primary-300';\n if (lastViewedOn) return 'bg-neutral-400 dark:bg-neutral-400';\n return null;\n };\n\n const statusColor = getStatusColor();\n\n const getBorderColor = () => {\n if (isActive) return 'border-primary-600 dark:border-primary-600';\n if (isRecent) return 'border-primary-300 dark:border-primary-300';\n if (lastViewedOn) return 'border-neutral-400 dark:border-neutral-400';\n return 'border-primary-200 dark:border-neutral-800';\n };\n\n const borderColor = getBorderColor();\n\n const indicatorSizes = {\n '2xs': 'w-1.5 h-1.5',\n xs: 'w-2 h-2',\n sm: 'w-2.5 h-2.5',\n md: 'w-3 h-3',\n lg: 'w-3.5 h-3.5',\n xl: 'w-4 h-4',\n };\n\n useEffect(() => {\n if (profilePic) {\n if (imageCacheRef.current[profilePic]) {\n setImageLoaded(true);\n } else {\n setImageLoaded(false);\n const img = new Image();\n const token = authToken || (typeof localStorage !== 'undefined' ? localStorage.getItem('token') : null);\n img.src = profilePic + (token ? '?token=' + token : '');\n img.onload = () => {\n imageCacheRef.current[profilePic] = img.src;\n setImageLoaded(true);\n };\n img.onerror = () => {\n setImageLoaded(false);\n };\n }\n } else {\n setImageLoaded(false);\n }\n }, [profilePic, authToken]);\n\n useEffect(() => {\n return () => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n };\n }, []);\n\n const cachedSrc = profilePic ? imageCacheRef.current[profilePic] : undefined;\n\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const popperRef = useRef<HTMLDivElement | null>(null);\n\n const handleMouseEnter = () => {\n onHover?.();\n if (firstName && lastName && enablePopper) {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n timerRef.current = setTimeout(() => {\n setVisible(true);\n }, 300);\n }\n };\n\n const handleMouseLeave = (event: React.MouseEvent) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n timerRef.current = setTimeout(() => {\n if (popperRef.current && !popperRef.current.contains(event.relatedTarget as Node)) {\n setVisible(false);\n }\n }, 200);\n };\n\n const popperContent = (\n <div\n ref={popperRef}\n className='bg-white dark:bg-black-800 shadow rounded-lg border border-neutral-200 dark:border-black-700 min-w-[280px]'\n onMouseEnter={() => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n }}\n onMouseLeave={(event) => handleMouseLeave(event)}\n >\n <div className='flex flex-col gap-1 items-center p-5'>\n <div className={cn('relative', sizeClasses[hoverSize])}>\n {cachedSrc && imageLoaded ? (\n <img\n src={cachedSrc}\n alt='Profile'\n className={cn('rounded-full border-2 object-cover w-full h-full', borderColor)}\n onError={() => setImageLoaded(false)}\n />\n ) : (\n <div\n className={cn(\n 'bg-primary-100 dark:bg-primary-950 text-primary-600 border-2 flex items-center justify-center rounded-full w-full h-full',\n borderColor,\n )}\n >\n {getInitials((firstName || '') + ' ' + (lastName || ''))}\n </div>\n )}\n\n {statusColor && (\n <div\n className={cn(\n 'absolute bottom-0 right-0 rounded-full border-2 border-white dark:border-black-800',\n indicatorSizes[hoverSize],\n statusColor,\n )}\n />\n )}\n </div>\n <div className='flex flex-row gap-1 items-center justify-center'>\n <Typography size='medium' variant='semibold' className='w-full text-center'>\n {firstName || ''} {lastName || ''}\n </Typography>\n {userDetails?.region && <span>{getFlagComponentRectangleMd(userDetails?.region)}</span>}\n </div>\n\n <Typography size='small' variant='medium' appearance='body'>\n {email || userDetails?.email || ''}\n </Typography>\n </div>\n\n {currentlyEditing ? (\n <div className='px-5 pb-3'>\n <div className='flex items-center gap-3 rounded-lg border border-primary-100 dark:border-primary-900 bg-[rgba(230,241,252,0.60)] dark:bg-primary-950/40 px-[13px] py-[7px]'>\n <div className='flex items-center justify-center shrink-0 w-7 h-7 rounded-[5px] border-[0.4px] border-primary-100 dark:border-primary-900 bg-primary-50 dark:bg-primary-950'>\n <EditOutlinedIcon sx={{ width: 13, height: 13 }} className='text-primary-600 dark:text-primary-500' />\n </div>\n <div className='flex flex-col min-w-0'>\n <Typography\n size='extra-small'\n variant='semibold'\n appearance='custom'\n className='text-2xs leading-4 uppercase tracking-[0.2px] text-primary-600 dark:text-primary-500'\n >\n Currently editing\n </Typography>\n <Typography size='extra-small' variant='semibold' className='truncate'>\n {currentlyEditing}\n </Typography>\n </div>\n </div>\n </div>\n ) : null}\n\n {userId &&\n (isFetchingUserDetails ? (\n <div className='p-5'>\n <Skeleton />\n </div>\n ) : userId && (userDetails?.teams || userDetails?.clearanceLevel || userDetails?.group) ? (\n <div className='flex flex-col gap-4 bg-neutral-50 border-t border-neutral-200 dark:bg-black-700 dark:border-none p-5 rounded-b-lg'>\n <StatusInfoRow isActive={isActive} lastViewedOn={lastViewedOn} />\n {userDetails.username && (\n <InfoRow\n label='Username'\n content={\n <div className='flex gap-2'>\n <Typography size='small' variant='medium' appearance='body'>\n {userDetails.username}\n </Typography>\n </div>\n }\n />\n )}\n\n {userDetails?.teams && userDetails?.teams?.length > 0 && (\n <InfoRow\n label='Team'\n content={\n <div className='flex gap-2'>\n {userDetails?.teams?.length > 0 && (\n <Tag\n key={userDetails?.teams[0]?.id}\n label={userDetails?.teams[0]?.name}\n color={userDetails?.teams[0]?.color || '#e38715'}\n size='md'\n isHashColor\n />\n )}\n {userDetails?.teams?.length >= 2 && (\n <div\n ref={moreTagRef}\n className='relative cursor-pointer'\n onMouseEnter={handleShowMore}\n onMouseLeave={handleHideMore}\n onClick={(e) => e.stopPropagation()}\n >\n <Tag key={1} label={`+ ${userDetails?.teams?.length - 1} More`} color='#004f08' size='md' isHashColor />\n\n {showMore && (\n <div\n ref={dropdownRef}\n className={cn(\n 'absolute w-max bg-white dark:text-black-200 dark:bg-black-800 shadow-md border border-neutral-200 dark:border-black-800 rounded-md px-2 z-10 overflow-y-auto max-h-60',\n {\n 'top-full': dropdownPosition.vertical === 'bottom',\n 'bottom-full': dropdownPosition.vertical === 'top',\n 'left-0': dropdownPosition.horizontal === 'left',\n 'right-0': dropdownPosition.horizontal === 'right',\n },\n )}\n onMouseEnter={handleShowMore}\n onMouseLeave={handleHideMore}\n >\n {userDetails?.teams?.slice(1)?.map((team, index) => (\n <div key={team?.id || index} className='my-2'>\n <Tag key={team?.id} label={team?.name} color={team?.color || '#4A5568'} size='md' isHashColor className='w-fit' />\n </div>\n ))}\n </div>\n )}\n </div>\n )}\n </div>\n }\n />\n )}\n\n {userDetails?.group && (\n <InfoRow\n label='Role'\n content={<Tag key={userDetails?.group} label={userDetails?.group} color='#004094' size='md' isHashColor />}\n />\n )}\n\n {userDetails?.clearanceLevel && (\n <InfoRow\n label='Clearance Level'\n content={\n <Tag\n key={String(userDetails?.clearanceLevel)}\n label={`Level ${userDetails?.clearanceLevel}`}\n color='#b30000'\n size='md'\n isHashColor\n />\n }\n />\n )}\n </div>\n ) : (\n <div className='flex items-center justify-center bg-neutral-50 dark:bg-black-700 border-t border-neutral-200 dark:border-black-700 p-5 rounded-b-lg'>\n <Typography className='flex items-center justify-center gap-1' size='extra-small' variant='medium' appearance='body'>\n <WarningRoundedIcon\n sx={{\n height: '16px',\n width: '16px',\n color: '#F04438',\n }}\n />\n No other information found!\n </Typography>\n </div>\n ))}\n </div>\n );\n const containerRef = useRef<HTMLDivElement>(null);\n return (\n <div\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n className={cn('inline-block relative cursor-pointer', className)}\n ref={containerRef}\n >\n <div className={cn('relative', containerClassName || avatarSizeClass)}>\n {cachedSrc && imageLoaded ? (\n <img\n src={cachedSrc}\n alt='Profile'\n className={cn('rounded-full border object-cover w-full h-full', borderColor)}\n onError={() => setImageLoaded(false)}\n />\n ) : firstName && lastName ? (\n <div\n className={cn(\n ' bg-primary-100 text-primary-600 flex items-center justify-center rounded-full border dark:bg-black-700 text-2xs', \n sizeClasses[size],\n borderColor,\n )}\n >\n {getInitials((firstName || '') + ' ' + (lastName || ''))}\n </div>\n ) : (\n <div className={cn(borderColor, 'p-1 rounded-full bg-neutral-200 dark:bg-black-600 flex items-center justify-center border w-full h-full')}>\n <PersonIcon fill='#98A2B3' />\n </div>\n )}\n\n {statusIndicator && statusColor && (\n <div\n className={cn(\n 'absolute bottom-0 right-0 rounded-full border border-white dark:border-black-800 w-2 h-2',\n\n statusColor,\n )}\n />\n )}\n </div>\n <UserAvatarPopper\n isOpen={visible}\n onClose={() => setVisible(false)}\n anchorEl={containerRef.current}\n className='bg-white dark:bg-black-700 shadow rounded-lg border border-neutral-200 dark:border-black-600'\n >\n {popperContent}\n </UserAvatarPopper>\n </div>\n );\n};\n\nUserAvatar.displayName = 'UserAvatar';\n\n"],"names":["InfoRow","label","content","jsxs","jsx","Typography","UserAvatar","firstName","lastName","email","profilePic","size","hoverSize","containerClassName","enablePopper","className","userId","lastViewedOn","isActive","statusIndicator","userDetails","isFetchingUserDetails","authToken","onHover","currentlyEditing","GroupsOutlined","visible","setVisible","useState","imageLoaded","setImageLoaded","avatarSizeClass","sizeClasses","moreTagRef","dropdownRef","dropdownPosition","showMore","handleShowMore","handleHideMore","useDynamicPosition","imageCacheRef","useRef","isRecent","useMemo","date","statusColor","borderColor","indicatorSizes","useEffect","img","token","timerRef","cachedSrc","popperRef","handleMouseEnter","handleMouseLeave","event","popperContent","cn","getInitials","getFlagComponentRectangleMd","EditOutlinedIcon","Skeleton","StatusInfoRow","Tag","e","team","index","WarningRoundedIcon","containerRef","PersonIcon","UserAvatarPopper"],"mappings":"orBA2DMA,EAAU,CAAC,CAAE,MAAAC,EAAO,QAAAC,KACxBC,OAAC,MAAA,CAAI,UAAU,oCACb,SAAA,CAAAC,EAAAA,IAACC,EAAAA,WAAA,CAAW,KAAK,QAAQ,QAAQ,SAAS,UAAU,OAAO,WAAW,OACnE,SAAAJ,CAAA,CACH,EACCC,CAAA,EACH,EAiBWI,EAAkC,CAAC,CAC9C,UAAAC,EACA,SAAAC,EACA,MAAAC,EACA,WAAAC,EACA,KAAAC,EAAO,KACP,UAAAC,EAAY,KACZ,mBAAAC,EAAqB,GACrB,aAAAC,EAAe,GACf,UAAAC,EACA,OAAAC,EACA,aAAAC,EACA,SAAAC,EACA,gBAAAC,EAAkB,GAClB,YAAAC,EACA,sBAAAC,EAAwB,GACxB,UAAAC,EACA,QAAAC,EACA,iBAAAC,CACF,IAAM,CACJ,GAAIjB,IAAc,OAASC,IAAa,QACtC,OACEJ,EAAAA,IAAC,MAAA,CAAI,UAAU,qFACb,SAAAA,MAACqB,EAAAA,eAAA,CAAe,GAAI,CAAE,SAA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e,EAAK,CAAA,CAAA,EAEnCvB,GAAaC,EACfJ,EAAAA,IAAC,MAAA,CACC,UAAWsD,EACT,mHACA1B,EAAAA,YAAYrB,CAAI,EAChBmC,CAAA,EAGD,SAAAa,EAAAA,aAAapD,GAAa,IAAM,KAAOC,GAAY,GAAG,CAAA,CAAA,EAGzDJ,EAAAA,IAAC,MAAA,CAAI,UAAWsD,EAAGZ,EAAa,yGAAyG,EACvI,SAAA1C,EAAAA,IAACkE,GAAAA,WAAA,CAAW,KAAK,SAAA,CAAU,CAAA,CAC7B,EAGDnD,GAAmB0B,GAClBzC,EAAAA,IAAC,MAAA,CACC,UAAWsD,EACT,2FAEAb,CAAA,CACF,CAAA,CACF,EAEJ,EACAzC,EAAAA,IAACmE,GAAAA,iBAAA,CACC,OAAQ7C,EACR,QAAS,IAAMC,EAAW,EAAK,EAC/B,SAAU0C,EAAa,QACvB,UAAU,+FAET,SAAAZ,CAAA,CAAA,CACH,CAAA,CAAA,CAGN,EAEAnD,EAAW,YAAc"}
|
|
@@ -268,7 +268,7 @@ const v = ({ label: n, content: d }) => /* @__PURE__ */ a("div", { className: "f
|
|
|
268
268
|
"div",
|
|
269
269
|
{
|
|
270
270
|
className: l(
|
|
271
|
-
" bg-primary-100 text-primary-600 flex items-center justify-center rounded-full border dark:bg-black-700",
|
|
271
|
+
" bg-primary-100 text-primary-600 flex items-center justify-center rounded-full border dark:bg-black-700 text-2xs",
|
|
272
272
|
C[z],
|
|
273
273
|
b
|
|
274
274
|
),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAvatar.es.js","sources":["../../../src/components/user-avatar/UserAvatar.tsx"],"sourcesContent":["import { GroupsOutlined } from '@mui/icons-material';\nimport EditOutlinedIcon from '@mui/icons-material/EditOutlined';\nimport WarningRoundedIcon from '@mui/icons-material/WarningRounded';\nimport cn from 'classnames';\nimport { type FC, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Typography } from '../data-display/typography/Typography';\nimport { Tag } from '../data-display/tag/Tag';\nimport { Skeleton } from '../data-display/skeleton/Skeleton';\nimport { getFlagComponentRectangleMd } from '../../utils/countryFlags';\nimport { UserAvatarPopper } from './UserAvatarPopper';\nimport { StatusInfoRow } from './StatusInfoRow';\nimport { sizeClasses, getInitials } from './constants';\nimport { PersonIcon } from './PersonIcon';\nimport { useDynamicPosition } from './useDynamicPosition';\n\nexport type UserAvatarSize = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\nexport type UserDetailsTeam = {\n id?: string;\n name: string;\n color?: string;\n};\n\nexport type UserDetails = {\n email?: string;\n username?: string;\n teams?: UserDetailsTeam[];\n group?: string;\n clearanceLevel?: number | string;\n region?: string;\n};\n\nexport type UserAvatarProps = {\n firstName?: string;\n lastName?: string;\n email?: string;\n enablePopper?: boolean;\n profilePic?: string;\n size?: UserAvatarSize;\n hoverSize?: UserAvatarSize;\n containerClassName?: string;\n className?: string;\n userId?: string;\n lastViewedOn?: string;\n isActive?: boolean;\n statusIndicator?: boolean;\n /** User details to display in the popper - replaces the useTeamMemberFilter hook */\n userDetails?: UserDetails | null;\n /** Whether user details are being fetched */\n isFetchingUserDetails?: boolean;\n /** Optional token for authenticated image loading */\n authToken?: string;\n /** Callback triggered when mouse enters the avatar */\n onHover?: () => void;\n /** Name of the clause / line item the user is currently editing. When set, a highlighted \"Currently editing\" card is shown in the popper. */\n currentlyEditing?: string;\n};\n\nconst InfoRow = ({ label, content }: { label: string; content: React.ReactNode }) => (\n <div className='flex justify-between items-center'>\n <Typography size='small' variant='medium' className='mr-5' appearance='body'>\n {label}\n </Typography>\n {content}\n </div>\n);\n\n/**\n * UserAvatar component for displaying user profile pictures with hover popper\n *\n * @example\n * ```tsx\n * <UserAvatar\n * firstName=\"John\"\n * lastName=\"Doe\"\n * email=\"john@example.com\"\n * profilePic=\"/avatar.jpg\"\n * userDetails={{ teams: [{ name: 'Engineering', color: '#0066cc' }], group: 'Admin' }}\n * />\n * ```\n */\nexport const UserAvatar: FC<UserAvatarProps> = ({\n firstName,\n lastName,\n email,\n profilePic,\n size = 'md',\n hoverSize = 'lg',\n containerClassName = '',\n enablePopper = true,\n className,\n userId,\n lastViewedOn,\n isActive,\n statusIndicator = false,\n userDetails,\n isFetchingUserDetails = false,\n authToken,\n onHover,\n currentlyEditing,\n}) => {\n if (firstName === 'All' && lastName === 'Users') {\n return (\n <div className='p-1 rounded-full bg-primary-100 dark:bg-black-600 flex items-center justify-center'>\n <GroupsOutlined sx={{ fontSize: 16 }} className='text-primary-600 dark:text-primary-600' />\n </div>\n );\n }\n\n const [visible, setVisible] = useState<boolean>(false);\n const [imageLoaded, setImageLoaded] = useState<boolean>(false);\n\n const avatarSizeClass = sizeClasses[size];\n\n const {\n triggerRef: moreTagRef,\n dropdownRef,\n position: dropdownPosition,\n isVisible: showMore,\n show: handleShowMore,\n hide: handleHideMore,\n } = useDynamicPosition();\n\n const imageCacheRef = useRef<{ [key: string]: string }>({});\n\n const isRecent = useMemo(() => {\n if (isActive || !lastViewedOn) return false;\n const date = new Date(lastViewedOn);\n const now = new Date();\n const diffInHours = (now.getTime() - date.getTime()) / (1000 * 60 * 60);\n return diffInHours < 24;\n }, [isActive, lastViewedOn]);\n\n const getStatusColor = () => {\n if (isActive) return 'bg-primary-600 dark:bg-primary-600';\n if (isRecent) return 'bg-primary-300 dark:bg-primary-300';\n if (lastViewedOn) return 'bg-neutral-400 dark:bg-neutral-400';\n return null;\n };\n\n const statusColor = getStatusColor();\n\n const getBorderColor = () => {\n if (isActive) return 'border-primary-600 dark:border-primary-600';\n if (isRecent) return 'border-primary-300 dark:border-primary-300';\n if (lastViewedOn) return 'border-neutral-400 dark:border-neutral-400';\n return 'border-primary-200 dark:border-neutral-800';\n };\n\n const borderColor = getBorderColor();\n\n const indicatorSizes = {\n '2xs': 'w-1.5 h-1.5',\n xs: 'w-2 h-2',\n sm: 'w-2.5 h-2.5',\n md: 'w-3 h-3',\n lg: 'w-3.5 h-3.5',\n xl: 'w-4 h-4',\n };\n\n useEffect(() => {\n if (profilePic) {\n if (imageCacheRef.current[profilePic]) {\n setImageLoaded(true);\n } else {\n setImageLoaded(false);\n const img = new Image();\n const token = authToken || (typeof localStorage !== 'undefined' ? localStorage.getItem('token') : null);\n img.src = profilePic + (token ? '?token=' + token : '');\n img.onload = () => {\n imageCacheRef.current[profilePic] = img.src;\n setImageLoaded(true);\n };\n img.onerror = () => {\n setImageLoaded(false);\n };\n }\n } else {\n setImageLoaded(false);\n }\n }, [profilePic, authToken]);\n\n useEffect(() => {\n return () => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n };\n }, []);\n\n const cachedSrc = profilePic ? imageCacheRef.current[profilePic] : undefined;\n\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const popperRef = useRef<HTMLDivElement | null>(null);\n\n const handleMouseEnter = () => {\n onHover?.();\n if (firstName && lastName && enablePopper) {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n timerRef.current = setTimeout(() => {\n setVisible(true);\n }, 300);\n }\n };\n\n const handleMouseLeave = (event: React.MouseEvent) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n timerRef.current = setTimeout(() => {\n if (popperRef.current && !popperRef.current.contains(event.relatedTarget as Node)) {\n setVisible(false);\n }\n }, 200);\n };\n\n const popperContent = (\n <div\n ref={popperRef}\n className='bg-white dark:bg-black-800 shadow rounded-lg border border-neutral-200 dark:border-black-700 min-w-[280px]'\n onMouseEnter={() => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n }}\n onMouseLeave={(event) => handleMouseLeave(event)}\n >\n <div className='flex flex-col gap-1 items-center p-5'>\n <div className={cn('relative', sizeClasses[hoverSize])}>\n {cachedSrc && imageLoaded ? (\n <img\n src={cachedSrc}\n alt='Profile'\n className={cn('rounded-full border-2 object-cover w-full h-full', borderColor)}\n onError={() => setImageLoaded(false)}\n />\n ) : (\n <div\n className={cn(\n 'bg-primary-100 dark:bg-primary-950 text-primary-600 border-2 flex items-center justify-center rounded-full w-full h-full',\n borderColor,\n )}\n >\n {getInitials((firstName || '') + ' ' + (lastName || ''))}\n </div>\n )}\n\n {statusColor && (\n <div\n className={cn(\n 'absolute bottom-0 right-0 rounded-full border-2 border-white dark:border-black-800',\n indicatorSizes[hoverSize],\n statusColor,\n )}\n />\n )}\n </div>\n <div className='flex flex-row gap-1 items-center justify-center'>\n <Typography size='medium' variant='semibold' className='w-full text-center'>\n {firstName || ''} {lastName || ''}\n </Typography>\n {userDetails?.region && <span>{getFlagComponentRectangleMd(userDetails?.region)}</span>}\n </div>\n\n <Typography size='small' variant='medium' appearance='body'>\n {email || userDetails?.email || ''}\n </Typography>\n </div>\n\n {currentlyEditing ? (\n <div className='px-5 pb-3'>\n <div className='flex items-center gap-3 rounded-lg border border-primary-100 dark:border-primary-900 bg-[rgba(230,241,252,0.60)] dark:bg-primary-950/40 px-[13px] py-[7px]'>\n <div className='flex items-center justify-center shrink-0 w-7 h-7 rounded-[5px] border-[0.4px] border-primary-100 dark:border-primary-900 bg-primary-50 dark:bg-primary-950'>\n <EditOutlinedIcon sx={{ width: 13, height: 13 }} className='text-primary-600 dark:text-primary-500' />\n </div>\n <div className='flex flex-col min-w-0'>\n <Typography\n size='extra-small'\n variant='semibold'\n appearance='custom'\n className='text-2xs leading-4 uppercase tracking-[0.2px] text-primary-600 dark:text-primary-500'\n >\n Currently editing\n </Typography>\n <Typography size='extra-small' variant='semibold' className='truncate'>\n {currentlyEditing}\n </Typography>\n </div>\n </div>\n </div>\n ) : null}\n\n {userId &&\n (isFetchingUserDetails ? (\n <div className='p-5'>\n <Skeleton />\n </div>\n ) : userId && (userDetails?.teams || userDetails?.clearanceLevel || userDetails?.group) ? (\n <div className='flex flex-col gap-4 bg-neutral-50 border-t border-neutral-200 dark:bg-black-700 dark:border-none p-5 rounded-b-lg'>\n <StatusInfoRow isActive={isActive} lastViewedOn={lastViewedOn} />\n {userDetails.username && (\n <InfoRow\n label='Username'\n content={\n <div className='flex gap-2'>\n <Typography size='small' variant='medium' appearance='body'>\n {userDetails.username}\n </Typography>\n </div>\n }\n />\n )}\n\n {userDetails?.teams && userDetails?.teams?.length > 0 && (\n <InfoRow\n label='Team'\n content={\n <div className='flex gap-2'>\n {userDetails?.teams?.length > 0 && (\n <Tag\n key={userDetails?.teams[0]?.id}\n label={userDetails?.teams[0]?.name}\n color={userDetails?.teams[0]?.color || '#e38715'}\n size='md'\n isHashColor\n />\n )}\n {userDetails?.teams?.length >= 2 && (\n <div\n ref={moreTagRef}\n className='relative cursor-pointer'\n onMouseEnter={handleShowMore}\n onMouseLeave={handleHideMore}\n onClick={(e) => e.stopPropagation()}\n >\n <Tag key={1} label={`+ ${userDetails?.teams?.length - 1} More`} color='#004f08' size='md' isHashColor />\n\n {showMore && (\n <div\n ref={dropdownRef}\n className={cn(\n 'absolute w-max bg-white dark:text-black-200 dark:bg-black-800 shadow-md border border-neutral-200 dark:border-black-800 rounded-md px-2 z-10 overflow-y-auto max-h-60',\n {\n 'top-full': dropdownPosition.vertical === 'bottom',\n 'bottom-full': dropdownPosition.vertical === 'top',\n 'left-0': dropdownPosition.horizontal === 'left',\n 'right-0': dropdownPosition.horizontal === 'right',\n },\n )}\n onMouseEnter={handleShowMore}\n onMouseLeave={handleHideMore}\n >\n {userDetails?.teams?.slice(1)?.map((team, index) => (\n <div key={team?.id || index} className='my-2'>\n <Tag key={team?.id} label={team?.name} color={team?.color || '#4A5568'} size='md' isHashColor className='w-fit' />\n </div>\n ))}\n </div>\n )}\n </div>\n )}\n </div>\n }\n />\n )}\n\n {userDetails?.group && (\n <InfoRow\n label='Role'\n content={<Tag key={userDetails?.group} label={userDetails?.group} color='#004094' size='md' isHashColor />}\n />\n )}\n\n {userDetails?.clearanceLevel && (\n <InfoRow\n label='Clearance Level'\n content={\n <Tag\n key={String(userDetails?.clearanceLevel)}\n label={`Level ${userDetails?.clearanceLevel}`}\n color='#b30000'\n size='md'\n isHashColor\n />\n }\n />\n )}\n </div>\n ) : (\n <div className='flex items-center justify-center bg-neutral-50 dark:bg-black-700 border-t border-neutral-200 dark:border-black-700 p-5 rounded-b-lg'>\n <Typography className='flex items-center justify-center gap-1' size='extra-small' variant='medium' appearance='body'>\n <WarningRoundedIcon\n sx={{\n height: '16px',\n width: '16px',\n color: '#F04438',\n }}\n />\n No other information found!\n </Typography>\n </div>\n ))}\n </div>\n );\n const containerRef = useRef<HTMLDivElement>(null);\n return (\n <div\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n className={cn('inline-block relative cursor-pointer', className)}\n ref={containerRef}\n >\n <div className={cn('relative', containerClassName || avatarSizeClass)}>\n {cachedSrc && imageLoaded ? (\n <img\n src={cachedSrc}\n alt='Profile'\n className={cn('rounded-full border object-cover w-full h-full', borderColor)}\n onError={() => setImageLoaded(false)}\n />\n ) : firstName && lastName ? (\n <div\n className={cn(\n ' bg-primary-100 text-primary-600 flex items-center justify-center rounded-full border dark:bg-black-700', \n sizeClasses[size],\n borderColor,\n )}\n >\n {getInitials((firstName || '') + ' ' + (lastName || ''))}\n </div>\n ) : (\n <div className={cn(borderColor, 'p-1 rounded-full bg-neutral-200 dark:bg-black-600 flex items-center justify-center border w-full h-full')}>\n <PersonIcon fill='#98A2B3' />\n </div>\n )}\n\n {statusIndicator && statusColor && (\n <div\n className={cn(\n 'absolute bottom-0 right-0 rounded-full border border-white dark:border-black-800 w-2 h-2',\n\n statusColor,\n )}\n />\n )}\n </div>\n <UserAvatarPopper\n isOpen={visible}\n onClose={() => setVisible(false)}\n anchorEl={containerRef.current}\n className='bg-white dark:bg-black-700 shadow rounded-lg border border-neutral-200 dark:border-black-600'\n >\n {popperContent}\n </UserAvatarPopper>\n </div>\n );\n};\n\nUserAvatar.displayName = 'UserAvatar';\n\n"],"names":["InfoRow","label","content","jsxs","jsx","Typography","UserAvatar","firstName","lastName","email","profilePic","size","hoverSize","containerClassName","enablePopper","className","userId","lastViewedOn","isActive","statusIndicator","userDetails","isFetchingUserDetails","authToken","onHover","currentlyEditing","GroupsOutlined","visible","setVisible","useState","imageLoaded","setImageLoaded","avatarSizeClass","sizeClasses","moreTagRef","dropdownRef","dropdownPosition","showMore","handleShowMore","handleHideMore","useDynamicPosition","imageCacheRef","useRef","isRecent","useMemo","date","statusColor","borderColor","indicatorSizes","useEffect","img","token","timerRef","cachedSrc","popperRef","handleMouseEnter","handleMouseLeave","event","popperContent","cn","getInitials","getFlagComponentRectangleMd","EditOutlinedIcon","Skeleton","StatusInfoRow","Tag","e","team","index","WarningRoundedIcon","containerRef","PersonIcon","UserAvatarPopper"],"mappings":";;;;;;;;;;;;;;;AA2DA,MAAMA,IAAU,CAAC,EAAE,OAAAC,GAAO,SAAAC,QACxB,gBAAAC,EAAC,OAAA,EAAI,WAAU,qCACb,UAAA;AAAA,EAAA,gBAAAC,EAACC,GAAA,EAAW,MAAK,SAAQ,SAAQ,UAAS,WAAU,QAAO,YAAW,QACnE,UAAAJ,EAAA,CACH;AAAA,EACCC;AAAA,GACH,GAiBWI,KAAkC,CAAC;AAAA,EAC9C,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,WAAAC,IAAY;AAAA,EACZ,oBAAAC,IAAqB;AAAA,EACrB,cAAAC,IAAe;AAAA,EACf,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,aAAAC;AAAA,EACA,uBAAAC,IAAwB;AAAA,EACxB,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,kBAAAC;AACF,MAAM;AACJ,MAAIjB,MAAc,SAASC,MAAa;AACtC,WACE,gBAAAJ,EAAC,OAAA,EAAI,WAAU,sFACb,UAAA,gBAAAA,EAACqB,IAAA,EAAe,IAAI,EAAE,UAAU,GAAA,GAAM,WAAU,0CAAyC,GAC3F;AAIJ,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAkB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AaC,IACf,gBAAAJ;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWsD;AAAA,gBACT;AAAA,gBACA1B,EAAYrB,CAAI;AAAA,gBAChBmC;AAAA,cAAA;AAAA,cAGD,UAAAa,GAAapD,KAAa,MAAM,OAAOC,KAAY,GAAG;AAAA,YAAA;AAAA,UAAA,IAGzD,gBAAAJ,EAAC,OAAA,EAAI,WAAWsD,EAAGZ,GAAa,yGAAyG,GACvI,UAAA,gBAAA1C,EAACkE,IAAA,EAAW,MAAK,UAAA,CAAU,EAAA,CAC7B;AAAA,UAGDnD,KAAmB0B,KAClB,gBAAAzC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWsD;AAAA,gBACT;AAAA,gBAEAb;AAAA,cAAA;AAAA,YACF;AAAA,UAAA;AAAA,QACF,GAEJ;AAAA,QACA,gBAAAzC;AAAA,UAACmE;AAAA,UAAA;AAAA,YACC,QAAQ7C;AAAA,YACR,SAAS,MAAMC,EAAW,EAAK;AAAA,YAC/B,UAAU0C,EAAa;AAAA,YACvB,WAAU;AAAA,YAET,UAAAZ;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAGN;AAEAnD,GAAW,cAAc;"}
|
|
1
|
+
{"version":3,"file":"UserAvatar.es.js","sources":["../../../src/components/user-avatar/UserAvatar.tsx"],"sourcesContent":["import { GroupsOutlined } from '@mui/icons-material';\nimport EditOutlinedIcon from '@mui/icons-material/EditOutlined';\nimport WarningRoundedIcon from '@mui/icons-material/WarningRounded';\nimport cn from 'classnames';\nimport { type FC, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Typography } from '../data-display/typography/Typography';\nimport { Tag } from '../data-display/tag/Tag';\nimport { Skeleton } from '../data-display/skeleton/Skeleton';\nimport { getFlagComponentRectangleMd } from '../../utils/countryFlags';\nimport { UserAvatarPopper } from './UserAvatarPopper';\nimport { StatusInfoRow } from './StatusInfoRow';\nimport { sizeClasses, getInitials } from './constants';\nimport { PersonIcon } from './PersonIcon';\nimport { useDynamicPosition } from './useDynamicPosition';\n\nexport type UserAvatarSize = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\nexport type UserDetailsTeam = {\n id?: string;\n name: string;\n color?: string;\n};\n\nexport type UserDetails = {\n email?: string;\n username?: string;\n teams?: UserDetailsTeam[];\n group?: string;\n clearanceLevel?: number | string;\n region?: string;\n};\n\nexport type UserAvatarProps = {\n firstName?: string;\n lastName?: string;\n email?: string;\n enablePopper?: boolean;\n profilePic?: string;\n size?: UserAvatarSize;\n hoverSize?: UserAvatarSize;\n containerClassName?: string;\n className?: string;\n userId?: string;\n lastViewedOn?: string;\n isActive?: boolean;\n statusIndicator?: boolean;\n /** User details to display in the popper - replaces the useTeamMemberFilter hook */\n userDetails?: UserDetails | null;\n /** Whether user details are being fetched */\n isFetchingUserDetails?: boolean;\n /** Optional token for authenticated image loading */\n authToken?: string;\n /** Callback triggered when mouse enters the avatar */\n onHover?: () => void;\n /** Name of the clause / line item the user is currently editing. When set, a highlighted \"Currently editing\" card is shown in the popper. */\n currentlyEditing?: string;\n};\n\nconst InfoRow = ({ label, content }: { label: string; content: React.ReactNode }) => (\n <div className='flex justify-between items-center'>\n <Typography size='small' variant='medium' className='mr-5' appearance='body'>\n {label}\n </Typography>\n {content}\n </div>\n);\n\n/**\n * UserAvatar component for displaying user profile pictures with hover popper\n *\n * @example\n * ```tsx\n * <UserAvatar\n * firstName=\"John\"\n * lastName=\"Doe\"\n * email=\"john@example.com\"\n * profilePic=\"/avatar.jpg\"\n * userDetails={{ teams: [{ name: 'Engineering', color: '#0066cc' }], group: 'Admin' }}\n * />\n * ```\n */\nexport const UserAvatar: FC<UserAvatarProps> = ({\n firstName,\n lastName,\n email,\n profilePic,\n size = 'md',\n hoverSize = 'lg',\n containerClassName = '',\n enablePopper = true,\n className,\n userId,\n lastViewedOn,\n isActive,\n statusIndicator = false,\n userDetails,\n isFetchingUserDetails = false,\n authToken,\n onHover,\n currentlyEditing,\n}) => {\n if (firstName === 'All' && lastName === 'Users') {\n return (\n <div className='p-1 rounded-full bg-primary-100 dark:bg-black-600 flex items-center justify-center'>\n <GroupsOutlined sx={{ fontSize: 16 }} className='text-primary-600 dark:text-primary-600' />\n </div>\n );\n }\n\n const [visible, setVisible] = useState<boolean>(false);\n const [imageLoaded, setImageLoaded] = useState<boolean>(false);\n\n const avatarSizeClass = sizeClasses[size];\n\n const {\n triggerRef: moreTagRef,\n dropdownRef,\n position: dropdownPosition,\n isVisible: showMore,\n show: handleShowMore,\n hide: handleHideMore,\n } = useDynamicPosition();\n\n const imageCacheRef = useRef<{ [key: string]: string }>({});\n\n const isRecent = useMemo(() => {\n if (isActive || !lastViewedOn) return false;\n const date = new Date(lastViewedOn);\n const now = new Date();\n const diffInHours = (now.getTime() - date.getTime()) / (1000 * 60 * 60);\n return diffInHours < 24;\n }, [isActive, lastViewedOn]);\n\n const getStatusColor = () => {\n if (isActive) return 'bg-primary-600 dark:bg-primary-600';\n if (isRecent) return 'bg-primary-300 dark:bg-primary-300';\n if (lastViewedOn) return 'bg-neutral-400 dark:bg-neutral-400';\n return null;\n };\n\n const statusColor = getStatusColor();\n\n const getBorderColor = () => {\n if (isActive) return 'border-primary-600 dark:border-primary-600';\n if (isRecent) return 'border-primary-300 dark:border-primary-300';\n if (lastViewedOn) return 'border-neutral-400 dark:border-neutral-400';\n return 'border-primary-200 dark:border-neutral-800';\n };\n\n const borderColor = getBorderColor();\n\n const indicatorSizes = {\n '2xs': 'w-1.5 h-1.5',\n xs: 'w-2 h-2',\n sm: 'w-2.5 h-2.5',\n md: 'w-3 h-3',\n lg: 'w-3.5 h-3.5',\n xl: 'w-4 h-4',\n };\n\n useEffect(() => {\n if (profilePic) {\n if (imageCacheRef.current[profilePic]) {\n setImageLoaded(true);\n } else {\n setImageLoaded(false);\n const img = new Image();\n const token = authToken || (typeof localStorage !== 'undefined' ? localStorage.getItem('token') : null);\n img.src = profilePic + (token ? '?token=' + token : '');\n img.onload = () => {\n imageCacheRef.current[profilePic] = img.src;\n setImageLoaded(true);\n };\n img.onerror = () => {\n setImageLoaded(false);\n };\n }\n } else {\n setImageLoaded(false);\n }\n }, [profilePic, authToken]);\n\n useEffect(() => {\n return () => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n };\n }, []);\n\n const cachedSrc = profilePic ? imageCacheRef.current[profilePic] : undefined;\n\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const popperRef = useRef<HTMLDivElement | null>(null);\n\n const handleMouseEnter = () => {\n onHover?.();\n if (firstName && lastName && enablePopper) {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n timerRef.current = setTimeout(() => {\n setVisible(true);\n }, 300);\n }\n };\n\n const handleMouseLeave = (event: React.MouseEvent) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n timerRef.current = setTimeout(() => {\n if (popperRef.current && !popperRef.current.contains(event.relatedTarget as Node)) {\n setVisible(false);\n }\n }, 200);\n };\n\n const popperContent = (\n <div\n ref={popperRef}\n className='bg-white dark:bg-black-800 shadow rounded-lg border border-neutral-200 dark:border-black-700 min-w-[280px]'\n onMouseEnter={() => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n }}\n onMouseLeave={(event) => handleMouseLeave(event)}\n >\n <div className='flex flex-col gap-1 items-center p-5'>\n <div className={cn('relative', sizeClasses[hoverSize])}>\n {cachedSrc && imageLoaded ? (\n <img\n src={cachedSrc}\n alt='Profile'\n className={cn('rounded-full border-2 object-cover w-full h-full', borderColor)}\n onError={() => setImageLoaded(false)}\n />\n ) : (\n <div\n className={cn(\n 'bg-primary-100 dark:bg-primary-950 text-primary-600 border-2 flex items-center justify-center rounded-full w-full h-full',\n borderColor,\n )}\n >\n {getInitials((firstName || '') + ' ' + (lastName || ''))}\n </div>\n )}\n\n {statusColor && (\n <div\n className={cn(\n 'absolute bottom-0 right-0 rounded-full border-2 border-white dark:border-black-800',\n indicatorSizes[hoverSize],\n statusColor,\n )}\n />\n )}\n </div>\n <div className='flex flex-row gap-1 items-center justify-center'>\n <Typography size='medium' variant='semibold' className='w-full text-center'>\n {firstName || ''} {lastName || ''}\n </Typography>\n {userDetails?.region && <span>{getFlagComponentRectangleMd(userDetails?.region)}</span>}\n </div>\n\n <Typography size='small' variant='medium' appearance='body'>\n {email || userDetails?.email || ''}\n </Typography>\n </div>\n\n {currentlyEditing ? (\n <div className='px-5 pb-3'>\n <div className='flex items-center gap-3 rounded-lg border border-primary-100 dark:border-primary-900 bg-[rgba(230,241,252,0.60)] dark:bg-primary-950/40 px-[13px] py-[7px]'>\n <div className='flex items-center justify-center shrink-0 w-7 h-7 rounded-[5px] border-[0.4px] border-primary-100 dark:border-primary-900 bg-primary-50 dark:bg-primary-950'>\n <EditOutlinedIcon sx={{ width: 13, height: 13 }} className='text-primary-600 dark:text-primary-500' />\n </div>\n <div className='flex flex-col min-w-0'>\n <Typography\n size='extra-small'\n variant='semibold'\n appearance='custom'\n className='text-2xs leading-4 uppercase tracking-[0.2px] text-primary-600 dark:text-primary-500'\n >\n Currently editing\n </Typography>\n <Typography size='extra-small' variant='semibold' className='truncate'>\n {currentlyEditing}\n </Typography>\n </div>\n </div>\n </div>\n ) : null}\n\n {userId &&\n (isFetchingUserDetails ? (\n <div className='p-5'>\n <Skeleton />\n </div>\n ) : userId && (userDetails?.teams || userDetails?.clearanceLevel || userDetails?.group) ? (\n <div className='flex flex-col gap-4 bg-neutral-50 border-t border-neutral-200 dark:bg-black-700 dark:border-none p-5 rounded-b-lg'>\n <StatusInfoRow isActive={isActive} lastViewedOn={lastViewedOn} />\n {userDetails.username && (\n <InfoRow\n label='Username'\n content={\n <div className='flex gap-2'>\n <Typography size='small' variant='medium' appearance='body'>\n {userDetails.username}\n </Typography>\n </div>\n }\n />\n )}\n\n {userDetails?.teams && userDetails?.teams?.length > 0 && (\n <InfoRow\n label='Team'\n content={\n <div className='flex gap-2'>\n {userDetails?.teams?.length > 0 && (\n <Tag\n key={userDetails?.teams[0]?.id}\n label={userDetails?.teams[0]?.name}\n color={userDetails?.teams[0]?.color || '#e38715'}\n size='md'\n isHashColor\n />\n )}\n {userDetails?.teams?.length >= 2 && (\n <div\n ref={moreTagRef}\n className='relative cursor-pointer'\n onMouseEnter={handleShowMore}\n onMouseLeave={handleHideMore}\n onClick={(e) => e.stopPropagation()}\n >\n <Tag key={1} label={`+ ${userDetails?.teams?.length - 1} More`} color='#004f08' size='md' isHashColor />\n\n {showMore && (\n <div\n ref={dropdownRef}\n className={cn(\n 'absolute w-max bg-white dark:text-black-200 dark:bg-black-800 shadow-md border border-neutral-200 dark:border-black-800 rounded-md px-2 z-10 overflow-y-auto max-h-60',\n {\n 'top-full': dropdownPosition.vertical === 'bottom',\n 'bottom-full': dropdownPosition.vertical === 'top',\n 'left-0': dropdownPosition.horizontal === 'left',\n 'right-0': dropdownPosition.horizontal === 'right',\n },\n )}\n onMouseEnter={handleShowMore}\n onMouseLeave={handleHideMore}\n >\n {userDetails?.teams?.slice(1)?.map((team, index) => (\n <div key={team?.id || index} className='my-2'>\n <Tag key={team?.id} label={team?.name} color={team?.color || '#4A5568'} size='md' isHashColor className='w-fit' />\n </div>\n ))}\n </div>\n )}\n </div>\n )}\n </div>\n }\n />\n )}\n\n {userDetails?.group && (\n <InfoRow\n label='Role'\n content={<Tag key={userDetails?.group} label={userDetails?.group} color='#004094' size='md' isHashColor />}\n />\n )}\n\n {userDetails?.clearanceLevel && (\n <InfoRow\n label='Clearance Level'\n content={\n <Tag\n key={String(userDetails?.clearanceLevel)}\n label={`Level ${userDetails?.clearanceLevel}`}\n color='#b30000'\n size='md'\n isHashColor\n />\n }\n />\n )}\n </div>\n ) : (\n <div className='flex items-center justify-center bg-neutral-50 dark:bg-black-700 border-t border-neutral-200 dark:border-black-700 p-5 rounded-b-lg'>\n <Typography className='flex items-center justify-center gap-1' size='extra-small' variant='medium' appearance='body'>\n <WarningRoundedIcon\n sx={{\n height: '16px',\n width: '16px',\n color: '#F04438',\n }}\n />\n No other information found!\n </Typography>\n </div>\n ))}\n </div>\n );\n const containerRef = useRef<HTMLDivElement>(null);\n return (\n <div\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n className={cn('inline-block relative cursor-pointer', className)}\n ref={containerRef}\n >\n <div className={cn('relative', containerClassName || avatarSizeClass)}>\n {cachedSrc && imageLoaded ? (\n <img\n src={cachedSrc}\n alt='Profile'\n className={cn('rounded-full border object-cover w-full h-full', borderColor)}\n onError={() => setImageLoaded(false)}\n />\n ) : firstName && lastName ? (\n <div\n className={cn(\n ' bg-primary-100 text-primary-600 flex items-center justify-center rounded-full border dark:bg-black-700 text-2xs', \n sizeClasses[size],\n borderColor,\n )}\n >\n {getInitials((firstName || '') + ' ' + (lastName || ''))}\n </div>\n ) : (\n <div className={cn(borderColor, 'p-1 rounded-full bg-neutral-200 dark:bg-black-600 flex items-center justify-center border w-full h-full')}>\n <PersonIcon fill='#98A2B3' />\n </div>\n )}\n\n {statusIndicator && statusColor && (\n <div\n className={cn(\n 'absolute bottom-0 right-0 rounded-full border border-white dark:border-black-800 w-2 h-2',\n\n statusColor,\n )}\n />\n )}\n </div>\n <UserAvatarPopper\n isOpen={visible}\n onClose={() => setVisible(false)}\n anchorEl={containerRef.current}\n className='bg-white dark:bg-black-700 shadow rounded-lg border border-neutral-200 dark:border-black-600'\n >\n {popperContent}\n </UserAvatarPopper>\n </div>\n );\n};\n\nUserAvatar.displayName = 'UserAvatar';\n\n"],"names":["InfoRow","label","content","jsxs","jsx","Typography","UserAvatar","firstName","lastName","email","profilePic","size","hoverSize","containerClassName","enablePopper","className","userId","lastViewedOn","isActive","statusIndicator","userDetails","isFetchingUserDetails","authToken","onHover","currentlyEditing","GroupsOutlined","visible","setVisible","useState","imageLoaded","setImageLoaded","avatarSizeClass","sizeClasses","moreTagRef","dropdownRef","dropdownPosition","showMore","handleShowMore","handleHideMore","useDynamicPosition","imageCacheRef","useRef","isRecent","useMemo","date","statusColor","borderColor","indicatorSizes","useEffect","img","token","timerRef","cachedSrc","popperRef","handleMouseEnter","handleMouseLeave","event","popperContent","cn","getInitials","getFlagComponentRectangleMd","EditOutlinedIcon","Skeleton","StatusInfoRow","Tag","e","team","index","WarningRoundedIcon","containerRef","PersonIcon","UserAvatarPopper"],"mappings":";;;;;;;;;;;;;;;AA2DA,MAAMA,IAAU,CAAC,EAAE,OAAAC,GAAO,SAAAC,QACxB,gBAAAC,EAAC,OAAA,EAAI,WAAU,qCACb,UAAA;AAAA,EAAA,gBAAAC,EAACC,GAAA,EAAW,MAAK,SAAQ,SAAQ,UAAS,WAAU,QAAO,YAAW,QACnE,UAAAJ,EAAA,CACH;AAAA,EACCC;AAAA,GACH,GAiBWI,KAAkC,CAAC;AAAA,EAC9C,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,WAAAC,IAAY;AAAA,EACZ,oBAAAC,IAAqB;AAAA,EACrB,cAAAC,IAAe;AAAA,EACf,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,aAAAC;AAAA,EACA,uBAAAC,IAAwB;AAAA,EACxB,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,kBAAAC;AACF,MAAM;AACJ,MAAIjB,MAAc,SAASC,MAAa;AACtC,WACE,gBAAAJ,EAAC,OAAA,EAAI,WAAU,sFACb,UAAA,gBAAAA,EAACqB,IAAA,EAAe,IAAI,EAAE,UAAU,GAAA,GAAM,WAAU,0CAAyC,GAC3F;AAIJ,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAkB,EAAK,GAC/C,CAACC,GAAaC,CAAc,IAAIF,EAAkB,EAAK,GAEvDG,IAAkBC,EAAYrB,CAAI,GAElC;AAAA,IACJ,YAAYsB;AAAA,IACZ,aAAAC;AAAA,IACA,UAAUC;AAAA,IACV,WAAWC;AAAA,I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