{"version":3,"file":"Fieldset.cjs","names":["_styled","_interopRequireDefault","require","_react","_FieldsetContext","_OdysseyDesignTokensContext","_Typography","_useUniqueId","_jsxRuntime","e","__esModule","default","StyledFieldset","styled","fieldset","odysseyDesignTokens","border","margin","Spacing0","marginBlockEnd","Spacing6","maxWidth","TypographyLineLengthMax","padding","Fieldset","alert","children","description","id","idOverride","isDisabled","legend","name","testId","translate","useOdysseyDesignTokens","useUniqueId","fieldsetContextValue","useMemo","jsxs","disabled","jsx","Legend","Support","FieldsetContext","Provider","value","MemoizedFieldset","exports","memo","displayName"],"sources":["../../src/Fieldset.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-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 styled from \"@emotion/styled\";\nimport { memo, ReactElement, useMemo } from \"react\";\n\nimport type { HtmlProps } from \"./HtmlProps.js\";\n\nimport { Callout } from \"./Callout.js\";\nimport { FieldsetContext } from \"./FieldsetContext.js\";\nimport {\n  DesignTokens,\n  useOdysseyDesignTokens,\n} from \"./OdysseyDesignTokensContext.js\";\nimport { Legend, Support } from \"./Typography.js\";\nimport { useUniqueId } from \"./useUniqueId.js\";\n\nconst StyledFieldset = styled.fieldset<{\n  odysseyDesignTokens: DesignTokens;\n}>(({ odysseyDesignTokens }) => ({\n  border: \"0\",\n  margin: odysseyDesignTokens.Spacing0,\n  marginBlockEnd: odysseyDesignTokens.Spacing6,\n  maxWidth: odysseyDesignTokens.TypographyLineLengthMax,\n  padding: odysseyDesignTokens.Spacing0,\n\n  \"&:last-child\": {\n    marginBlockEnd: odysseyDesignTokens.Spacing0,\n  },\n}));\n\nexport type FieldsetProps = {\n  /**\n   * A Callout indicating a Fieldset-wide error or status update.\n   */\n  alert?: ReactElement<typeof Callout>;\n  /**\n   * The Field components within the Fieldset\n   */\n  children: ReactElement | Array<ReactElement>;\n  /**\n   * Secondary text displayed below the legend, providing context for the contained fields.\n   */\n  description?: string;\n  /**\n   * Defines a unique identifier (ID) which must be unique in the whole document.\n   */\n  id?: string;\n  /**\n   * If `true`, the fieldset and all contained input fields are disabled.\n   * @default false\n   */\n  isDisabled?: boolean;\n  /**\n   * The title of the Fieldset\n   */\n  legend: string;\n  /**\n   * The name associated with the group.\n   */\n  name?: string;\n} & Pick<HtmlProps, \"testId\" | \"translate\">;\n\n/**\n * A grouping of related form fields with a legend, optional description, and optional status alert. Propagates a disabled state to all child fields via context.\n */\nconst Fieldset = ({\n  alert,\n  children,\n  description,\n  id: idOverride,\n  isDisabled = false,\n  legend,\n  name,\n  testId,\n  translate,\n}: FieldsetProps) => {\n  const odysseyDesignTokens = useOdysseyDesignTokens();\n  const id = useUniqueId(idOverride);\n\n  const fieldsetContextValue = useMemo(\n    () => ({\n      isDisabled,\n    }),\n    [isDisabled],\n  );\n\n  return (\n    <StyledFieldset\n      data-se={testId}\n      disabled={isDisabled}\n      id={id}\n      name={name}\n      odysseyDesignTokens={odysseyDesignTokens}\n    >\n      <Legend translate={translate}>{legend}</Legend>\n\n      {description && <Support translate={translate}>{description}</Support>}\n\n      {alert}\n\n      <FieldsetContext.Provider value={fieldsetContextValue}>\n        {children}\n      </FieldsetContext.Provider>\n    </StyledFieldset>\n  );\n};\n\nconst MemoizedFieldset = memo(Fieldset);\nMemoizedFieldset.displayName = \"Fieldset\";\n\nexport { MemoizedFieldset as Fieldset };\n"],"mappings":";;;;;;AAYA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,2BAAA,GAAAH,OA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