{"version":3,"file":"Form.cjs","names":["_styled","_interopRequireDefault","require","_react","_OdysseyDesignTokensContext","_Typography","_useUniqueId","_jsxRuntime","e","__esModule","default","formEncodingTypeValues","exports","formAutoCompleteTypeValues","formMethodValues","StyledForm","styled","form","isFullWidth","odysseyDesignTokens","maxWidth","TypographyLineLengthMax","margin","padding","TitleContainer","div","marginBlockEnd","Spacing4","FormActionContainer","display","justifyContent","gap","Spacing1","marginBlockStart","Spacing7","Form","alert","autoCompleteType","children","description","encodingType","formActions","id","idOverride","method","name","noValidate","onSubmit","target","testId","title","translate","useUniqueId","useOdysseyDesignTokens","jsxs","autoComplete","encType","jsx","Heading4","component","Support","MemoizedForm","memo","displayName"],"sources":["../../src/Form.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 { FormEventHandler, memo, ReactElement } from \"react\";\n\nimport type { HtmlProps } from \"./HtmlProps.js\";\n\nimport { Button } from \"./Buttons/Button.js\";\nimport { Callout } from \"./Callout.js\";\nimport { FieldComponentProps } from \"./FieldComponentProps.js\";\nimport {\n  DesignTokens,\n  useOdysseyDesignTokens,\n} from \"./OdysseyDesignTokensContext.js\";\nimport { Heading4, Support } from \"./Typography.js\";\nimport { useUniqueId } from \"./useUniqueId.js\";\n\nexport const formEncodingTypeValues = [\n  \"application/x-www-form-urlencoded\",\n  \"application/json\",\n  \"multipart/form-data\",\n  \"text/plain\",\n] as const;\nexport const formAutoCompleteTypeValues = [\"on\", \"off\"] as const;\nexport const formMethodValues = [\"post\", \"get\", \"dialog\"] as const;\n\nconst StyledForm = styled.form<{\n  isFullWidth?: boolean;\n  odysseyDesignTokens: DesignTokens;\n}>(({ isFullWidth, odysseyDesignTokens }) => ({\n  maxWidth: isFullWidth ? \"100%\" : odysseyDesignTokens.TypographyLineLengthMax,\n  margin: 0,\n  padding: 0,\n}));\n\nconst TitleContainer = styled.div<{\n  odysseyDesignTokens: DesignTokens;\n}>(({ odysseyDesignTokens }) => ({\n  marginBlockEnd: odysseyDesignTokens.Spacing4,\n}));\n\nconst FormActionContainer = styled.div<{\n  odysseyDesignTokens: DesignTokens;\n}>(\n  {\n    display: \"flex\",\n    justifyContent: \"flex-end\",\n  },\n  ({ odysseyDesignTokens }) => ({\n    gap: odysseyDesignTokens.Spacing1,\n    marginBlockStart: odysseyDesignTokens.Spacing7,\n  }),\n);\n\nexport type FormProps = {\n  /**\n   * A Callout indicating a Form-wide error or status update.\n   */\n  alert?: ReactElement<typeof Callout>;\n  /**\n   * Indicates whether input elements can by default have their values automatically completed by the browser.\n   * `autocomplete` attributes on form elements override it on <form>\n   */\n  autoCompleteType?: (typeof formAutoCompleteTypeValues)[number];\n  /**\n   * The Field or FieldSet components within the Form\n   */\n  children: ReactElement | Array<ReactElement>;\n  /**\n   * Secondary text displayed below the form heading, providing context for the form's purpose.\n   */\n  description?: string;\n  /**\n   * If the value of the method attribute is post, enctype is the MIME type of the form submission. This value can be overridden by formenctype attributes on <button>, <input type=\"submit\">, or <input type=\"image\"> elements.\n   */\n  encodingType?: (typeof formEncodingTypeValues)[number];\n  /**\n   * The Field or FieldGroup components within the Form\n   */\n  formActions?:\n    | ReactElement<typeof Button>\n    | Array<ReactElement<typeof Button>>;\n  /**\n   * Defines a unique identifier (ID) which must be unique in the whole document.\n   */\n  id?: string;\n  /**\n   * The HTTP method to submit the form with.\n   * This value is overridden by formmethod attributes on <button>, <input type=\"submit\">, or <input type=\"image\"> elements.\n   */\n  method?: (typeof formMethodValues)[number];\n  /**\n   * The name of the form. The value must not be the empty string, and must be unique among the form elements in the forms collection that it is in, if any.\n   */\n  name: string;\n  /**\n   * If `true`, skips native browser validation when the form is submitted.\n   * @default false\n   */\n  noValidate?: boolean;\n  /**\n   * Called when the form is submitted. Receives the native form submit event.\n   */\n  onSubmit?: FormEventHandler<HTMLFormElement>;\n  /**\n   * Indicates where to display the response after submitting the form. It is a name/keyword for a browsing context (for example, tab, window, or iframe).\n   * This value can be overridden by a formtarget attribute on a <button>, <input type=\"submit\">, or <input type=\"image\"> element.\n   */\n  target?: string;\n  /**\n   * The title of the Form\n   */\n  title?: string;\n} & Pick<FieldComponentProps, \"isFullWidth\"> &\n  Pick<HtmlProps, \"testId\" | \"translate\">;\n\n/**\n * A structured container for collecting user input. Wraps form fields and actions with an optional title, description, and alert area.\n */\nconst Form = ({\n  alert,\n  autoCompleteType,\n  children,\n  description,\n  encodingType,\n  formActions,\n  id: idOverride,\n  isFullWidth,\n  method,\n  name,\n  noValidate = false,\n  onSubmit,\n  target,\n  testId,\n  title,\n  translate,\n}: FormProps) => {\n  const id = useUniqueId(idOverride);\n  const odysseyDesignTokens = useOdysseyDesignTokens();\n\n  return (\n    <StyledForm\n      autoComplete={autoCompleteType}\n      data-se={testId}\n      encType={encodingType}\n      id={id}\n      isFullWidth={isFullWidth}\n      method={method}\n      name={name}\n      noValidate={noValidate}\n      odysseyDesignTokens={odysseyDesignTokens}\n      onSubmit={onSubmit}\n      target={target}\n    >\n      <TitleContainer odysseyDesignTokens={odysseyDesignTokens}>\n        {title && (\n          <Heading4 component=\"h1\" translate={translate}>\n            {title}\n          </Heading4>\n        )}\n        {description && <Support translate={translate}>{description}</Support>}\n        {alert}\n      </TitleContainer>\n      <div>{children}</div>\n      {formActions && (\n        <FormActionContainer odysseyDesignTokens={odysseyDesignTokens}>\n          {formActions}\n        </FormActionContainer>\n      )}\n    </StyledForm>\n  );\n};\n\nconst MemoizedForm = memo(Form);\nMemoizedForm.displayName = \"Form\";\n\nexport { MemoizedForm as Form };\n"],"mappings":";;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