{"version":3,"sources":["../src/components/Checkbox/CheckboxShim.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport type { ICheckboxProps, ICheckboxStyles, ICheckboxStyleProps } from '@fluentui/react';\nimport { classNamesFunction } from '@fluentui/react';\nimport { Checkbox, mergeClasses } from '@fluentui/react-components';\nimport { useCheckboxProps } from './shimCheckboxProps';\nimport { useCheckboxStyles } from './Checkbox.styles';\nimport type { JSXElement } from '@fluentui/react-utilities';\n\nconst getClassNames = classNamesFunction<ICheckboxStyleProps, ICheckboxStyles>({\n  useStaticStyles: false,\n});\n\nexport const CheckboxShim = React.forwardRef((props, _ref) => {\n  const { className, styles: stylesV8, onRenderLabel, label, componentRef } = props;\n  const shimProps = useCheckboxProps(props);\n  const styles = getClassNames(stylesV8);\n  const stylesV9 = useCheckboxStyles();\n  const checkboxRef = (_ref as React.RefObject<HTMLInputElement>) || React.createRef<HTMLInputElement>();\n\n  React.useImperativeHandle(componentRef, () => ({\n    checked: checkboxRef.current?.checked ?? false,\n    indeterminate: checkboxRef.current?.indeterminate ?? false,\n    focus: () => checkboxRef.current?.focus(),\n  }));\n\n  const defaultLabelRenderer = (checkboxProps?: ICheckboxProps): JSXElement | null => {\n    if (!checkboxProps) {\n      return null;\n    }\n    const { label: defaultLabel, title } = checkboxProps;\n    return defaultLabel ? (\n      <span title={title} className={styles.text}>\n        {defaultLabel}\n      </span>\n    ) : null;\n  };\n\n  if (label || onRenderLabel) {\n    shimProps.label = {\n      className: mergeClasses('ms-Checkbox-text', styles.label, styles.text),\n      children: onRenderLabel ? onRenderLabel(props, defaultLabelRenderer) : label,\n    };\n  }\n\n  return (\n    <Checkbox\n      {...shimProps}\n      ref={checkboxRef}\n      className={mergeClasses(stylesV9.root, 'ms-Checkbox', className, styles.root)}\n      indicator={{ className: mergeClasses('ms-Checkbox-checkbox', styles.checkbox) }}\n    />\n  );\n  // NOTE: cast is necessary as `ICheckboxProps` extends React.Ref<HTMLDivElement> which is not compatible with our defined  React.Ref<HTMLInputElement>\n}) as React.ForwardRefExoticComponent<\n  ICheckboxProps &\n    // eslint-disable-next-line @typescript-eslint/no-restricted-types -- this is expected in order to be compatible with v8, as every v8 interface contains `React.RefAttributes` to accept ref as string\n    React.RefAttributes<HTMLInputElement>\n>;\n\nCheckboxShim.displayName = 'CheckboxShim';\n"],"names":["React","classNamesFunction","Checkbox","mergeClasses","useCheckboxProps","useCheckboxStyles","getClassNames","useStaticStyles","CheckboxShim","forwardRef","props","_ref","className","styles","stylesV8","onRenderLabel","label","componentRef","shimProps","stylesV9","checkboxRef","createRef","useImperativeHandle","checked","current","indeterminate","focus","defaultLabelRenderer","checkboxProps","defaultLabel","title","span","text","children","ref","root","indicator","checkbox","displayName"],"mappings":"AAAA;;;;;+BAeaQ;;;;;;;iEAbU,QAAQ;wBAGI,kBAAkB;iCACd,6BAA6B;mCACnC,yBAAsB;gCACrB,uBAAoB;AAGtD,MAAMF,oBAAgBL,0BAAAA,EAAyD;IAC7EM,iBAAiB;AACnB;AAEO,qBAAMC,WAAAA,GAAeR,OAAMS,UAAU,CAAC,CAACC,OAAOC;IACnD,MAAM,EAAEC,SAAS,EAAEC,QAAQC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,EAAEC,YAAY,EAAE,GAAGP;IAC5E,MAAMQ,gBAAYd,mCAAAA,EAAiBM;IACnC,MAAMG,SAASP,cAAcQ;IAC7B,MAAMK,eAAWd,iCAAAA;IACjB,MAAMe,cAAeT,QAAAA,WAAAA,GAA8CX,OAAMqB,SAAS;IAElFrB,OAAMsB,mBAAmB,CAACL,cAAc;YAC7BG,sBACMA;YADNA,8BACMA;eAF8B;YAC7CG,SAASH,gCAAAA,wBAAAA,YAAYI,OAAAA,AAAO,MAAA,QAAnBJ,yBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,qBAAqBG,OAAAA,AAAO,MAAA,QAA5BH,iCAAAA,KAAAA,IAAAA,+BAAgC;YACzCK,eAAeL,CAAAA,qCAAAA,CAAAA,wBAAA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