{"version":3,"file":"AttributeIcon.mjs","sources":["../../../admin/src/components/AttributeIcon.tsx"],"sourcesContent":["import { ComponentType, SVGProps } from 'react';\n\nimport { useStrapiApp } from '@strapi/admin/strapi-admin';\nimport { Box } from '@strapi/design-system';\nimport {\n  BooleanField,\n  CollectionType,\n  ComponentField,\n  DateField,\n  DynamicZoneField,\n  EmailField,\n  EnumerationField,\n  JsonField,\n  MediaField,\n  NumberField,\n  PasswordField,\n  RelationField,\n  MarkdownField,\n  SingleType,\n  TextField,\n  UidField,\n  BlocksField,\n} from '@strapi/icons/symbols';\nimport { styled } from 'styled-components';\n\nconst iconByTypes: Record<string, ComponentType<SVGProps<SVGSVGElement>>> = {\n  biginteger: NumberField,\n  blocks: BlocksField,\n  boolean: BooleanField,\n  collectionType: CollectionType,\n  component: ComponentField,\n  contentType: CollectionType,\n  date: DateField,\n  datetime: DateField,\n  decimal: NumberField,\n  dynamiczone: DynamicZoneField,\n  email: EmailField,\n  enum: EnumerationField,\n  enumeration: EnumerationField,\n  file: MediaField,\n  files: MediaField,\n  float: NumberField,\n  integer: NumberField,\n  json: JsonField,\n  JSON: JsonField,\n  media: MediaField,\n  number: NumberField,\n  password: PasswordField,\n  relation: RelationField,\n  richtext: MarkdownField,\n  singleType: SingleType,\n  string: TextField,\n  text: TextField,\n  time: DateField,\n  timestamp: DateField,\n  uid: UidField,\n};\n\nconst IconBox = styled(Box)`\n  svg {\n    height: 100%;\n    width: 100%;\n  }\n`;\n\nexport type IconByType = keyof typeof iconByTypes;\n\ntype AttributeIconProps = {\n  type: IconByType;\n  customField?: string | null;\n};\n\nexport const AttributeIcon = ({ type, customField = null, ...rest }: AttributeIconProps) => {\n  const getCustomField = useStrapiApp('AttributeIcon', (state) => state.customFields.get);\n\n  let Compo: any = iconByTypes[type];\n\n  if (customField) {\n    const customFieldObject = getCustomField(customField);\n    const icon = customFieldObject?.icon;\n    if (icon) {\n      Compo = icon;\n    }\n  }\n\n  if (!iconByTypes[type]) {\n    return null;\n  }\n\n  return (\n    <IconBox width=\"3.2rem\" height=\"3.2rem\" shrink={0} {...rest} aria-hidden>\n      <Box tag={Compo} />\n    </IconBox>\n  );\n};\n"],"names":["iconByTypes","biginteger","NumberField","blocks","BlocksField","boolean","BooleanField","collectionType","CollectionType","component","ComponentField","contentType","date","DateField","datetime","decimal","dynamiczone","DynamicZoneField","email","EmailField","enum","EnumerationField","enumeration","file","MediaField","files","float","integer","json","JsonField","JSON","media","number","password","PasswordField","relation","RelationField","richtext","MarkdownField","singleType","SingleType","string","TextField","text","time","timestamp","uid","UidField","IconBox","styled","Box","AttributeIcon","type","customField","rest","getCustomField","useStrapiApp","state","customFields","get","Compo","customFieldObject","icon","_jsx","width","height","shrink","aria-hidden","tag"],"mappings":";;;;;;AAyBA,MAAMA,WAAsE,GAAA;IAC1EC,UAAYC,EAAAA,WAAAA;IACZC,MAAQC,EAAAA,WAAAA;IACRC,OAASC,EAAAA,YAAAA;IACTC,cAAgBC,EAAAA,cAAAA;IAChBC,SAAWC,EAAAA,cAAAA;IACXC,WAAaH,EAAAA,cAAAA;IACbI,IAAMC,EAAAA,SAAAA;IACNC,QAAUD,EAAAA,SAAAA;IACVE,OAASb,EAAAA,WAAAA;IACTc,WAAaC,EAAAA,gBAAAA;IACbC,KAAOC,EAAAA,UAAAA;IACPC,IAAMC,EAAAA,gBAAAA;IACNC,WAAaD,EAAAA,gBAAAA;IACbE,IAAMC,EAAAA,UAAAA;IACNC,KAAOD,EAAAA,UAAAA;IACPE,KAAOxB,EAAAA,WAAAA;IACPyB,OAASzB,EAAAA,WAAAA;IACT0B,IAAMC,EAAAA,SAAAA;IACNC,IAAMD,EAAAA,SAAAA;IACNE,KAAOP,EAAAA,UAAAA;IACPQ,MAAQ9B,EAAAA,WAAAA;IACR+B,QAAUC,EAAAA,aAAAA;IACVC,QAAUC,EAAAA,aAAAA;IACVC,QAAUC,EAAAA,aAAAA;IACVC,UAAYC,EAAAA,UAAAA;IACZC,MAAQC,EAAAA,SAAAA;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