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Z,YAAY;QACZ,iBAAiB;qBACjB,0DAAC,CAAA,GAAA,0EAAoB,EAAE,QAAQ;QAAC,OAAO,oBAAoB,CAAC;OACzD;AAMb","sources":["packages/@adobe/react-spectrum/src/form/Form.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Alignment, DOMProps, DOMRef, FormProps, LabelPosition, SpectrumLabelableProps, StyleProps, ValidationState} from '@react-types/shared';\nimport {classNames} from '../utils/classNames';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormValidationContext} from 'react-stately/private/form/useFormValidationState';\nimport {Provider, useProviderProps} from '../provider/Provider';\nimport React, {ReactElement, useContext} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/fieldlabel/vars.css';\nimport {useDOMRef} from '../utils/useDOMRef';\nimport {useStyleProps} from '../utils/styleProps';\n\nexport interface SpectrumFormProps extends FormProps, DOMProps, StyleProps, Omit<SpectrumLabelableProps, 'contextualHelp' | 'label'> {\n  /** The contents of the Form. */\n  children: ReactElement<SpectrumLabelableProps> | ReactElement<SpectrumLabelableProps>[],\n  /** Whether the Form elements are displayed with their quiet style. */\n  isQuiet?: boolean,\n  /** Whether the Form elements are rendered with their emphasized style. */\n  isEmphasized?: boolean,\n  /** Whether the Form elements are disabled. */\n  isDisabled?: boolean,\n  /** Whether user input is required on each of the Form elements before Form submission. */\n  isRequired?: boolean,\n  /** Whether the Form elements can be selected but not changed by the user. */\n  isReadOnly?: boolean,\n  /**\n   * Whether the Form elements should display their \"valid\" or \"invalid\" visual styling.\n   * @default 'valid'\n   */\n  validationState?: ValidationState,\n  /**\n   * Whether to use native HTML form validation to prevent form submission\n   * when a field value is missing or invalid, or mark fields as required\n   * or invalid via ARIA.\n   * @default 'aria'\n   */\n  validationBehavior?: 'aria' | 'native'\n}\n\ninterface FormContextValue extends SpectrumLabelableProps {\n  validationBehavior?: 'aria' | 'native'\n}\n\nlet FormContext = React.createContext<FormContextValue | null>(null);\nexport function useFormProps<T extends SpectrumLabelableProps>(props: T): T {\n  let ctx = useContext(FormContext);\n  if (ctx) {\n    return {...ctx, ...props};\n  }\n\n  return props;\n}\n\nconst formPropNames = new Set([\n  'action',\n  'autoComplete',\n  'encType',\n  'method',\n  'target',\n  'onSubmit',\n  'onReset',\n  'onInvalid'\n]);\n\n/**\n * Forms allow users to enter data that can be submitted while providing alignment and styling for form fields.\n */\nexport const Form = React.forwardRef(function Form(props: SpectrumFormProps, ref: DOMRef<HTMLFormElement>) {\n  props = useProviderProps(props);\n  let {\n    children,\n    labelPosition = 'top' as LabelPosition,\n    labelAlign = 'start' as Alignment,\n    isRequired,\n    necessityIndicator,\n    isQuiet,\n    isEmphasized,\n    isDisabled,\n    isReadOnly,\n    validationState,\n    validationBehavior,\n    validationErrors,\n    ...otherProps\n  } = props;\n\n  let {styleProps} = useStyleProps(otherProps);\n  let domRef = useDOMRef(ref);\n\n  let ctx = {\n    labelPosition,\n    labelAlign,\n    necessityIndicator,\n    validationBehavior\n  };\n\n  return (\n    <form\n      {...filterDOMProps(otherProps, {labelable: true, propNames: formPropNames})}\n      {...styleProps}\n      noValidate={validationBehavior !== 'native'}\n      ref={domRef}\n      className={\n        classNames(\n          styles,\n          'spectrum-Form',\n          {\n            'spectrum-Form--positionSide': labelPosition === 'side',\n            'spectrum-Form--positionTop': labelPosition === 'top'\n          },\n          styleProps.className\n        )\n      }>\n      <FormContext.Provider value={ctx}>\n        <Provider\n          isQuiet={isQuiet}\n          isEmphasized={isEmphasized}\n          isDisabled={isDisabled}\n          isReadOnly={isReadOnly}\n          isRequired={isRequired}\n          validationState={validationState}>\n          <FormValidationContext.Provider value={validationErrors || {}}>\n            {children}\n          </FormValidationContext.Provider>\n        </Provider>\n      </FormContext.Provider>\n    </form>\n  );\n});\n"],"names":[],"version":3,"file":"Form.cjs.map"}