{"version":3,"file":"FieldLabel.cjs","names":["_react","require","_i18n","_ScreenReaderText","_Typography","_jsxRuntime","_interopRequireDefault","e","__esModule","default","FieldLabel","hasVisibleLabel","id","inputId","isOptional","testId","translate","text","t","useTranslation","inputLabel","useMemo","jsxs","_InputLabel2","htmlFor","children","jsx","Subordinate","ScreenReaderText","MemoizedFieldLabel","exports","memo","displayName"],"sources":["../../src/FieldLabel.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { InputLabel as MuiInputLabel } from \"@mui/material\";\nimport { memo, useMemo } from \"react\";\n\nimport type { HtmlProps } from \"./HtmlProps.js\";\n\nimport { useTranslation } from \"./i18n.generated/i18n.js\";\nimport { ScreenReaderText } from \"./ScreenReaderText.js\";\nimport { Subordinate } from \"./Typography.js\";\n\nexport type FieldLabelProps = {\n  /**\n   * If `true`, the label text is rendered visibly. If `false`, the label is visually hidden but remains accessible to screen readers.\n   */\n  hasVisibleLabel: boolean;\n  id: string;\n  inputId: string;\n  /**\n   * If `true`, an \"(Optional)\" indicator is appended to the label text.\n   */\n  isOptional: boolean;\n  text: string;\n} & Pick<HtmlProps, \"testId\" | \"translate\">;\n\nconst FieldLabel = ({\n  hasVisibleLabel,\n  id,\n  inputId,\n  isOptional,\n  testId,\n  translate,\n  text,\n}: FieldLabelProps) => {\n  const { t } = useTranslation();\n\n  const inputLabel = useMemo(\n    () => (\n      <MuiInputLabel\n        data-se={testId}\n        htmlFor={inputId}\n        id={id}\n        translate={translate}\n      >\n        <span>{text}</span>\n        {isOptional && (\n          <Subordinate>{t(\"fieldlabel.optional.text\")}</Subordinate>\n        )}\n      </MuiInputLabel>\n    ),\n    [id, inputId, isOptional, testId, translate, text, t],\n  );\n\n  return hasVisibleLabel ? (\n    inputLabel\n  ) : (\n    <ScreenReaderText translate={translate}>{inputLabel}</ScreenReaderText>\n  );\n};\n\nconst MemoizedFieldLabel = memo(FieldLabel);\nMemoizedFieldLabel.displayName = \"FieldLabel\";\n\nexport { MemoizedFieldLabel as FieldLabel };\n"],"mappings":";;;;;;;AAaA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAA8C,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAK,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAnB9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA,MAAMG,UAAU,GAAGA,CAAC;EAClBC,eAAe;EACfC,EAAE;EACFC,OAAO;EACPC,UAAU;EACVC,MAAM;EACNC,SAAS;EACTC;AACe,CAAC,KAAK;EACrB,MAAM;IAAEC;EAAE,CAAC,GAAG,IAAAC,oBAAc,EAAC,CAAC;EAE9B,MAAMC,UAAU,GAAG,IAAAC,cAAO,EACxB,MACE,IAAAhB,WAAA,CAAAiB,IAAA,EAAAC,YAAA,CAAAd,OAAA;IACE,WAASM,MAAO;IAChBS,OAAO,EAAEX,OAAQ;IACjBD,EAAE,EAAEA,EAAG;IACPI,SAAS,EAAEA,SAAU;IAAAS,QAAA,GAErB,IAAApB,WAAA,CAAAqB,GAAA;MAAAD,QAAA,EAAOR;IAAI,CAAO,CAAC,EAClBH,UAAU,IACT,IAAAT,WAAA,CAAAqB,GAAA,EAACtB,WAAA,CAAAuB,WAAW;MAAAF,QAAA,EAAEP,CAAC,CAAC,0BA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